From e46d21bde64dbc533064f2b56ce8c227be26944a Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 1 May 2024 04:05:22 +0100 Subject: [PATCH] General refactor and cleanup. --- .../Aaru.Archives.csproj.DotSettings | 5 +- Aaru.Archives/Symbian/Conditions.cs | 26 +- Aaru.Archives/Symbian/Files.cs | 56 +- Aaru.Archives/Symbian/Info.cs | 73 +- Aaru.Archives/Symbian/Open.cs | 21 +- Aaru.Archives/Symbian/Parser.cs | 82 +- Aaru.Archives/Symbian/Structs.cs | 1 + Aaru.Archives/Symbian/Symbian.cs | 13 +- Aaru.Archives/Symbian/UID.cs | 378 ++-- Aaru.Archives/Symbian/Xattrs.cs | 15 +- Aaru.Checksums/Adler32/neon.cs | 77 +- Aaru.Checksums/Adler32/ssse3.cs | 13 +- Aaru.Checksums/Adler32Context.cs | 27 +- Aaru.Checksums/CDChecksums.cs | 168 +- Aaru.Checksums/CRC16Context.cs | 42 +- Aaru.Checksums/CRC16IBMContext.cs | 1 + Aaru.Checksums/CRC32/arm_simd.cs | 6 +- Aaru.Checksums/CRC32/clmul.cs | 28 +- Aaru.Checksums/CRC32Context.cs | 28 +- Aaru.Checksums/CRC64/clmul.cs | 35 +- Aaru.Checksums/CRC64Context.cs | 28 +- Aaru.Checksums/Fletcher32/neon.cs | 83 +- Aaru.Checksums/Fletcher32/ssse3.cs | 13 +- Aaru.Checksums/FletcherContext.cs | 54 +- Aaru.Checksums/MD5Context.cs | 12 +- Aaru.Checksums/Native.cs | 6 +- Aaru.Checksums/ReedSolomon.cs | 89 +- Aaru.Checksums/SHA1Context.cs | 13 +- Aaru.Checksums/SHA256Context.cs | 13 +- Aaru.Checksums/SHA384Context.cs | 13 +- Aaru.Checksums/SHA512Context.cs | 12 +- Aaru.Checksums/SpamSumContext.cs | 60 +- Aaru.CommonTypes/AaruMetadata/AaruMetadata.cs | 40 +- .../AaruMetadata/Advertisement.cs | 18 +- Aaru.CommonTypes/AaruMetadata/AudioMedia.cs | 24 +- Aaru.CommonTypes/AaruMetadata/AudioVideo.cs | 36 +- Aaru.CommonTypes/AaruMetadata/BlockMedia.cs | 30 +- Aaru.CommonTypes/AaruMetadata/Book.cs | 12 +- Aaru.CommonTypes/AaruMetadata/Contents.cs | 45 +- Aaru.CommonTypes/AaruMetadata/Dimensions.cs | 51 +- Aaru.CommonTypes/AaruMetadata/Dump.cs | 18 +- Aaru.CommonTypes/AaruMetadata/DumpHardware.cs | 9 +- Aaru.CommonTypes/AaruMetadata/FileSystem.cs | 7 +- Aaru.CommonTypes/AaruMetadata/Layers.cs | 9 +- Aaru.CommonTypes/AaruMetadata/LinearMedia.cs | 15 +- Aaru.CommonTypes/AaruMetadata/Magazine.cs | 12 +- Aaru.CommonTypes/AaruMetadata/OpticalDisc.cs | 63 +- Aaru.CommonTypes/AaruMetadata/PCMCIA.cs | 11 +- Aaru.CommonTypes/AaruMetadata/Partition.cs | 9 +- .../AaruMetadata/RequiredOperatingSystem.cs | 15 +- Aaru.CommonTypes/AaruMetadata/SCSI.cs | 18 +- Aaru.CommonTypes/AaruMetadata/Scanning.cs | 44 +- Aaru.CommonTypes/AaruMetadata/Tape.cs | 21 +- Aaru.CommonTypes/AaruMetadata/UserManual.cs | 9 +- Aaru.CommonTypes/AaruMetadata/Xbox.cs | 26 +- Aaru.CommonTypes/Extents/ExtentsByte.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsConverter.cs | 6 +- Aaru.CommonTypes/Extents/ExtentsInt.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsLong.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsSByte.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsShort.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsUInt.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsULong.cs | 24 +- Aaru.CommonTypes/Extents/ExtentsUShort.cs | 24 +- .../Interfaces/IReadOnlyFilesystem.cs | 9 +- Aaru.CommonTypes/Interop/DetectOS.cs | 73 +- Aaru.CommonTypes/Interop/Version.cs | 23 +- .../MediaTypeFromDevice/FromAta.cs | 7 +- .../MediaTypeFromDevice/FromMmc.cs | 61 +- .../MediaTypeFromDevice/FromOdc.cs | 272 ++- .../MediaTypeFromDevice/FromSbc.cs | 798 +++++-- .../MediaTypeFromDevice/FromScsi.cs | 45 +- .../MediaTypeFromDevice/FromSsc.cs | 483 +++-- Aaru.CommonTypes/Metadata/DeviceReport.cs | 15 +- Aaru.CommonTypes/Metadata/Resume.cs | 4 +- Aaru.CommonTypes/Metadata/Statistics.cs | 4 +- Aaru.CommonTypes/Partition.cs | 6 +- Aaru.CommonTypes/PluginRegister.cs | 29 +- .../Structs/Devices/ATA/Identify.cs | 68 +- .../Structs/Devices/SCSI/Inquiry.cs | 124 +- .../Structs/Devices/SCSI/Modes/2A.cs | 148 +- Aaru.CommonTypes/Structs/Filesystems.cs | 44 +- Aaru.Compression/ADC.cs | 18 +- Aaru.Compression/AppleRle.cs | 6 +- Aaru.Compression/FLAC.cs | 31 +- Aaru.Compression/LZFSE.cs | 12 +- Aaru.Compression/LZIP.cs | 6 +- Aaru.Compression/LZMA.cs | 21 +- Aaru.Compression/Native.cs | 6 +- Aaru.Compression/TeleDiskLzh.cs | 49 +- Aaru.Compression/ZSTD.cs | 5 +- Aaru.Console/AaruConsole.cs | 3 +- Aaru.Core/ArchiveFormat.cs | 8 +- Aaru.Core/Checksum.cs | 42 +- Aaru.Core/DataFile.cs | 3 +- Aaru.Core/Devices/Dumping/ATA.cs | 317 +-- .../Devices/Dumping/CompactDisc/CdiReady.cs | 170 +- Aaru.Core/Devices/Dumping/CompactDisc/Data.cs | 470 +++-- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 751 ++++--- .../Devices/Dumping/CompactDisc/Error.cs | 347 ++- .../Devices/Dumping/CompactDisc/LeadOuts.cs | 212 +- .../Devices/Dumping/CompactDisc/Offset.cs | 3 +- .../Devices/Dumping/CompactDisc/Plextor.cs | 82 +- .../Devices/Dumping/CompactDisc/Pregap.cs | 502 +++-- .../Devices/Dumping/CompactDisc/Recordable.cs | 12 +- .../Devices/Dumping/CompactDisc/Subchannel.cs | 34 +- Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs | 8 +- .../Devices/Dumping/CompactDisc/Tracks.cs | 25 +- Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs | 209 +- Aaru.Core/Devices/Dumping/Dump.cs | 23 +- .../Devices/Dumping/LinearMemory/Retrode.cs | 187 +- Aaru.Core/Devices/Dumping/MMC.cs | 368 +++- Aaru.Core/Devices/Dumping/Metadata.cs | 31 +- Aaru.Core/Devices/Dumping/MiniDisc.cs | 310 +-- .../PlayStationPortable/MemoryStick.cs | 283 ++- .../PlayStationPortable.cs | 54 +- .../Dumping/PlayStationPortable/UMD.cs | 264 ++- Aaru.Core/Devices/Dumping/ResumeSupport.cs | 53 +- Aaru.Core/Devices/Dumping/SCSI.cs | 59 +- Aaru.Core/Devices/Dumping/SSC.cs | 520 +++-- Aaru.Core/Devices/Dumping/Sbc/Cache.cs | 55 +- Aaru.Core/Devices/Dumping/Sbc/Data.cs | 85 +- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 519 +++-- Aaru.Core/Devices/Dumping/Sbc/Error.cs | 135 +- Aaru.Core/Devices/Dumping/Sbc/Optical.cs | 95 +- Aaru.Core/Devices/Dumping/Sbc/Trim.cs | 6 +- Aaru.Core/Devices/Dumping/SecureDigital.cs | 311 +-- Aaru.Core/Devices/Dumping/XGD.cs | 458 ++-- Aaru.Core/Devices/Info/DeviceInfo.cs | 183 +- Aaru.Core/Devices/Reader.cs | 3 +- Aaru.Core/Devices/ReaderATA.cs | 60 +- Aaru.Core/Devices/ReaderSCSI.cs | 392 +++- Aaru.Core/Devices/Report/ATA.cs | 335 ++- Aaru.Core/Devices/Report/GdRomSwapTrick.cs | 1076 ++++++---- Aaru.Core/Devices/Report/MMC.cs | 1851 ++++++++++++----- Aaru.Core/Devices/Report/PCMCIA.cs | 3 +- Aaru.Core/Devices/Report/SSC.cs | 36 +- Aaru.Core/Devices/Report/Scsi.cs | 524 +++-- Aaru.Core/Devices/Scanning/ATA.cs | 85 +- Aaru.Core/Devices/Scanning/SCSI.cs | 215 +- Aaru.Core/Devices/Scanning/SecureDigital.cs | 103 +- Aaru.Core/Entropy.cs | 81 +- Aaru.Core/Filesystems.cs | 5 +- Aaru.Core/Graphics/BlockMap.cs | 124 +- Aaru.Core/Graphics/Spiral.cs | 190 +- Aaru.Core/ImageFormat.cs | 39 +- Aaru.Core/ImageInfo.cs | 138 +- Aaru.Core/Logging/DumpLog.cs | 26 +- Aaru.Core/Logging/ErrorLog.cs | 300 ++- Aaru.Core/Logging/IBGLog.cs | 19 +- Aaru.Core/Logging/MHDDLog.cs | 9 +- Aaru.Core/Logging/SubchannelLog.cs | 20 +- Aaru.Core/Media/CompactDisc.cs | 379 ++-- Aaru.Core/Media/Detection/MMC.cs | 1245 ++++++++--- Aaru.Core/Media/Info/CompactDisc.cs | 179 +- Aaru.Core/Media/Info/ScsiInfo.cs | 711 +++++-- Aaru.Core/Options.cs | 18 +- Aaru.Core/Partitions.cs | 68 +- Aaru.Core/PrintScsiModePages.cs | 9 +- Aaru.Core/Remote.cs | 149 +- Aaru.Core/Sidecar/BlockMedia.cs | 225 +- Aaru.Core/Sidecar/BlockTape.cs | 12 +- Aaru.Core/Sidecar/Files.cs | 30 +- Aaru.Core/Sidecar/OpticalDisc.cs | 99 +- Aaru.Core/Sidecar/Sidecar.cs | 34 +- Aaru.Core/Spectre.cs | 10 +- Aaru.Core/Statistics.cs | 196 +- Aaru.Database/Context.cs | 341 +-- Aaru.Decoders/ATA/Identify.cs | 865 ++++---- Aaru.Decoders/Bluray/BCA.cs | 13 +- Aaru.Decoders/Bluray/Cartridge.cs | 29 +- Aaru.Decoders/Bluray/DDS.cs | 10 +- Aaru.Decoders/Bluray/DI.cs | 65 +- Aaru.Decoders/Bluray/Spare.cs | 14 +- Aaru.Decoders/CD/ATIP.cs | 83 +- Aaru.Decoders/CD/CDTextOnLeadIn.cs | 55 +- Aaru.Decoders/CD/FullTOC.cs | 220 +- Aaru.Decoders/CD/PMA.cs | 273 ++- Aaru.Decoders/CD/Sector.cs | 54 +- Aaru.Decoders/CD/SectorBuilder.cs | 9 +- Aaru.Decoders/CD/Session.cs | 28 +- Aaru.Decoders/CD/Subchannel.cs | 797 ++++--- Aaru.Decoders/CD/TOC.cs | 24 +- Aaru.Decoders/DVD/CSS&CPRM.cs | 71 +- Aaru.Decoders/DVD/Cartridge.cs | 22 +- Aaru.Decoders/DVD/DDS.cs | 29 +- Aaru.Decoders/DVD/PFI.cs | 201 +- Aaru.Decoders/DVD/PRI.cs | 33 +- Aaru.Decoders/DVD/Sector.cs | 30 +- Aaru.Decoders/DVD/Spare.cs | 14 +- Aaru.Decoders/Floppy/Apple2.cs | 84 +- Aaru.Decoders/Floppy/AppleSony.cs | 57 +- Aaru.Decoders/LisaTag.cs | 24 +- Aaru.Decoders/MMC/CID.cs | 21 +- Aaru.Decoders/MMC/CSD.cs | 79 +- Aaru.Decoders/MMC/ExtendedCSD.cs | 312 +-- Aaru.Decoders/MMC/OCR.cs | 54 +- Aaru.Decoders/PCMCIA/CIS.cs | 85 +- Aaru.Decoders/PCMCIA/VendorCode.cs | 4 +- .../SCSI/DiscStructureCapabilities.cs | 3 +- Aaru.Decoders/SCSI/EVPD.cs | 719 +++---- Aaru.Decoders/SCSI/Inquiry.cs | 298 ++- Aaru.Decoders/SCSI/MMC/AACS.cs | 72 +- Aaru.Decoders/SCSI/MMC/CPRM.cs | 18 +- Aaru.Decoders/SCSI/MMC/DiscInformation.cs | 106 +- Aaru.Decoders/SCSI/MMC/Features.cs | 1385 +++++------- Aaru.Decoders/SCSI/MMC/Hybrid.cs | 43 +- Aaru.Decoders/SCSI/MMC/TrackInformation.cs | 6 +- Aaru.Decoders/SCSI/MMC/WriteProtect.cs | 22 +- Aaru.Decoders/SCSI/Modes/00_SFF.cs | 27 +- Aaru.Decoders/SCSI/Modes/01.cs | 89 +- Aaru.Decoders/SCSI/Modes/01_MMC.cs | 36 +- Aaru.Decoders/SCSI/Modes/02.cs | 87 +- Aaru.Decoders/SCSI/Modes/03.cs | 64 +- Aaru.Decoders/SCSI/Modes/04.cs | 29 +- Aaru.Decoders/SCSI/Modes/05.cs | 82 +- Aaru.Decoders/SCSI/Modes/06.cs | 21 +- Aaru.Decoders/SCSI/Modes/07.cs | 38 +- Aaru.Decoders/SCSI/Modes/07_MMC.cs | 22 +- Aaru.Decoders/SCSI/Modes/08.cs | 111 +- Aaru.Decoders/SCSI/Modes/0A.cs | 141 +- Aaru.Decoders/SCSI/Modes/0B.cs | 34 +- Aaru.Decoders/SCSI/Modes/0D.cs | 22 +- Aaru.Decoders/SCSI/Modes/0E.cs | 72 +- Aaru.Decoders/SCSI/Modes/0F.cs | 22 +- Aaru.Decoders/SCSI/Modes/10.cs | 38 +- Aaru.Decoders/SCSI/Modes/10_SSC.cs | 71 +- Aaru.Decoders/SCSI/Modes/11.cs | 52 +- Aaru.Decoders/SCSI/Modes/12_13_14.cs | 18 +- Aaru.Decoders/SCSI/Modes/1A.cs | 55 +- Aaru.Decoders/SCSI/Modes/1B.cs | 33 +- Aaru.Decoders/SCSI/Modes/1C.cs | 97 +- Aaru.Decoders/SCSI/Modes/1C_SFF.cs | 88 +- Aaru.Decoders/SCSI/Modes/1D.cs | 29 +- Aaru.Decoders/SCSI/Modes/21_Certance.cs | 41 +- Aaru.Decoders/SCSI/Modes/22_Certance.cs | 30 +- Aaru.Decoders/SCSI/Modes/24_IBM.cs | 24 +- Aaru.Decoders/SCSI/Modes/2A.cs | 114 +- Aaru.Decoders/SCSI/Modes/2F_IBM.cs | 41 +- Aaru.Decoders/SCSI/Modes/30_Apple.cs | 12 +- Aaru.Decoders/SCSI/Modes/3B_HP.cs | 18 +- Aaru.Decoders/SCSI/Modes/3C_HP.cs | 46 +- Aaru.Decoders/SCSI/Modes/3D_HP.cs | 18 +- Aaru.Decoders/SCSI/Modes/3D_IBM.cs | 18 +- Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs | 25 +- Aaru.Decoders/SCSI/Modes/3E_HP.cs | 21 +- Aaru.Decoders/SCSI/Modes/Headers.cs | 280 +-- Aaru.Decoders/SCSI/Modes/Mode10.cs | 51 +- Aaru.Decoders/SCSI/Modes/Mode6.cs | 54 +- Aaru.Decoders/SCSI/SSC/BlockLimits.cs | 13 +- Aaru.Decoders/SCSI/SSC/DensitySupport.cs | 52 +- Aaru.Decoders/SCSI/Sense.cs | 122 +- Aaru.Decoders/SecureDigital/CID.cs | 23 +- Aaru.Decoders/SecureDigital/CSD.cs | 71 +- Aaru.Decoders/SecureDigital/OCR.cs | 42 +- Aaru.Decoders/SecureDigital/SCR.cs | 50 +- Aaru.Decoders/Sega/CD.cs | 75 +- Aaru.Decoders/Sega/Dreamcast.cs | 92 +- Aaru.Decoders/Sega/Saturn.cs | 58 +- Aaru.Decoders/Xbox/DMI.cs | 66 +- Aaru.Decoders/Xbox/SS.cs | 55 +- Aaru.Decryption/DVD/CSS.cs | 114 +- Aaru.Decryption/DVD/Dump.cs | 111 +- Aaru.Decryption/DVD/MPEG.cs | 3 +- Aaru.Devices/Device/AtaCommands/Ata28.cs | 88 +- Aaru.Devices/Device/AtaCommands/Ata48.cs | 77 +- Aaru.Devices/Device/AtaCommands/AtaCHS.cs | 110 +- Aaru.Devices/Device/AtaCommands/Atapi.cs | 11 +- Aaru.Devices/Device/AtaCommands/Cfa.cs | 33 +- Aaru.Devices/Device/AtaCommands/MCPT.cs | 11 +- Aaru.Devices/Device/AtaCommands/Smart.cs | 88 +- Aaru.Devices/Device/Constructor.cs | 56 +- Aaru.Devices/Device/List.cs | 6 +- Aaru.Devices/Device/MmcCommands/MMC.cs | 157 +- .../Device/MmcCommands/SecureDigital.cs | 45 +- Aaru.Devices/Device/ScsiCommands/Adaptec.cs | 44 +- .../Device/ScsiCommands/ArchiveCorp.cs | 20 +- Aaru.Devices/Device/ScsiCommands/Certance.cs | 10 +- Aaru.Devices/Device/ScsiCommands/Fujitsu.cs | 16 +- Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs | 28 +- Aaru.Devices/Device/ScsiCommands/HP.cs | 16 +- Aaru.Devices/Device/ScsiCommands/Kreon.cs | 37 +- Aaru.Devices/Device/ScsiCommands/MMC.cs | 326 ++- Aaru.Devices/Device/ScsiCommands/MediaTek.cs | 7 +- Aaru.Devices/Device/ScsiCommands/MiniDisc.cs | 42 +- Aaru.Devices/Device/ScsiCommands/NEC.cs | 7 +- Aaru.Devices/Device/ScsiCommands/Optical.cs | 26 +- Aaru.Devices/Device/ScsiCommands/Pioneer.cs | 21 +- Aaru.Devices/Device/ScsiCommands/Plasmon.cs | 25 +- Aaru.Devices/Device/ScsiCommands/Plextor.cs | 126 +- Aaru.Devices/Device/ScsiCommands/SBC.cs | 104 +- Aaru.Devices/Device/ScsiCommands/SMC.cs | 20 +- Aaru.Devices/Device/ScsiCommands/SPC.cs | 207 +- Aaru.Devices/Device/ScsiCommands/SSC.cs | 301 ++- Aaru.Devices/Device/ScsiCommands/SyQuest.cs | 51 +- Aaru.Devices/Linux/Command.cs | 98 +- Aaru.Devices/Linux/Device.cs | 72 +- Aaru.Devices/Linux/ListDevices.cs | 3 +- Aaru.Devices/Remote/Command.cs | 87 +- Aaru.Devices/Remote/Device.cs | 55 +- Aaru.Devices/Remote/Remote.cs | 138 +- Aaru.Devices/Windows/Command.cs | 149 +- Aaru.Devices/Windows/Device.cs | 118 +- Aaru.Devices/Windows/ListDevices.cs | 41 +- Aaru.Devices/Windows/Usb.cs | 196 +- Aaru.Devices/Windows/UsbFunctions.cs | 27 +- Aaru.Dto/DeviceDto.cs | 21 +- Aaru.Filesystems/AODOS/Info.cs | 19 +- Aaru.Filesystems/APFS/Info.cs | 20 +- Aaru.Filesystems/Acorn/Helpers.cs | 6 +- Aaru.Filesystems/Acorn/Info.cs | 124 +- Aaru.Filesystems/AmigaDOS/Helpers.cs | 3 +- Aaru.Filesystems/AmigaDOS/Info.cs | 79 +- Aaru.Filesystems/AppleCommon/Info.cs | 46 +- Aaru.Filesystems/AppleDOS/Dir.cs | 39 +- Aaru.Filesystems/AppleDOS/File.cs | 124 +- Aaru.Filesystems/AppleDOS/Info.cs | 16 +- Aaru.Filesystems/AppleDOS/Structs.cs | 8 +- Aaru.Filesystems/AppleDOS/Super.cs | 6 +- Aaru.Filesystems/AppleDOS/Xattr.cs | 47 +- Aaru.Filesystems/AppleHFS/Info.cs | 60 +- Aaru.Filesystems/AppleHFSPlus/Info.cs | 85 +- Aaru.Filesystems/AppleMFS/Dir.cs | 42 +- Aaru.Filesystems/AppleMFS/File.cs | 126 +- Aaru.Filesystems/AppleMFS/Info.cs | 21 +- Aaru.Filesystems/AppleMFS/Structs.cs | 8 +- Aaru.Filesystems/AppleMFS/Super.cs | 65 +- Aaru.Filesystems/AppleMFS/Xattr.cs | 38 +- Aaru.Filesystems/AtheOS/Info.cs | 96 +- Aaru.Filesystems/BFS/Info.cs | 85 +- Aaru.Filesystems/BTRFS/Info.cs | 19 +- Aaru.Filesystems/CBM/CBM.cs | 6 +- Aaru.Filesystems/CBM/Dir.cs | 22 +- Aaru.Filesystems/CBM/File.cs | 77 +- Aaru.Filesystems/CBM/Info.cs | 93 +- Aaru.Filesystems/CBM/Structs.cs | 8 +- Aaru.Filesystems/CBM/Super.cs | 129 +- Aaru.Filesystems/CPM/Definitions.cs | 24 +- Aaru.Filesystems/CPM/Dir.cs | 36 +- Aaru.Filesystems/CPM/File.cs | 66 +- Aaru.Filesystems/CPM/Info.cs | 152 +- Aaru.Filesystems/CPM/Structs.cs | 8 +- Aaru.Filesystems/CPM/Super.cs | 105 +- Aaru.Filesystems/CPM/Xattr.cs | 38 +- Aaru.Filesystems/Cram/Info.cs | 13 +- Aaru.Filesystems/ECMA67/Info.cs | 19 +- Aaru.Filesystems/EFS/Info.cs | 92 +- Aaru.Filesystems/F2FS/Consts.cs | 1 + Aaru.Filesystems/F2FS/Info.cs | 55 +- Aaru.Filesystems/FAT/BPB.cs | 12 +- Aaru.Filesystems/FAT/Dir.cs | 128 +- Aaru.Filesystems/FAT/File.cs | 121 +- Aaru.Filesystems/FAT/Info.cs | 219 +- Aaru.Filesystems/FAT/Structs.cs | 17 +- Aaru.Filesystems/FAT/Super.cs | 195 +- Aaru.Filesystems/FAT/Xattr.cs | 66 +- Aaru.Filesystems/FATX/Dir.cs | 67 +- Aaru.Filesystems/FATX/File.cs | 112 +- Aaru.Filesystems/FATX/Info.cs | 32 +- Aaru.Filesystems/FATX/Structs.cs | 8 +- Aaru.Filesystems/FATX/Super.cs | 72 +- Aaru.Filesystems/FFS/Consts.cs | 2 - Aaru.Filesystems/FFS/FFS.cs | 2 - Aaru.Filesystems/FFS/Info.cs | 152 +- Aaru.Filesystems/FFS/Structs.cs | 2 - Aaru.Filesystems/Fossil/Info.cs | 12 +- Aaru.Filesystems/HAMMER/Consts.cs | 4 - Aaru.Filesystems/HAMMER/HAMMER.cs | 3 - Aaru.Filesystems/HAMMER/Info.cs | 40 +- Aaru.Filesystems/HPFS/Info.cs | 64 +- Aaru.Filesystems/HPOFS/Info.cs | 69 +- Aaru.Filesystems/ISO9660/Date.cs | 22 +- Aaru.Filesystems/ISO9660/Dir.cs | 278 ++- Aaru.Filesystems/ISO9660/File.cs | 246 +-- Aaru.Filesystems/ISO9660/Info.cs | 297 ++- Aaru.Filesystems/ISO9660/Mode2.cs | 87 +- Aaru.Filesystems/ISO9660/PathTable.cs | 25 +- Aaru.Filesystems/ISO9660/Structs/Internal.cs | 8 +- Aaru.Filesystems/ISO9660/Structs/Joliet.cs | 21 +- Aaru.Filesystems/ISO9660/Super.cs | 375 ++-- Aaru.Filesystems/ISO9660/Xattr.cs | 94 +- Aaru.Filesystems/JFS/Info.cs | 88 +- Aaru.Filesystems/LIF/Info.cs | 15 +- Aaru.Filesystems/LisaFS/Dir.cs | 75 +- Aaru.Filesystems/LisaFS/Extent.cs | 120 +- Aaru.Filesystems/LisaFS/File.cs | 169 +- Aaru.Filesystems/LisaFS/Info.cs | 102 +- Aaru.Filesystems/LisaFS/Structs.cs | 12 +- Aaru.Filesystems/LisaFS/Super.cs | 27 +- Aaru.Filesystems/LisaFS/Xattr.cs | 48 +- Aaru.Filesystems/Locus/Consts.cs | 8 - Aaru.Filesystems/Locus/Enums.cs | 7 - Aaru.Filesystems/Locus/Info.cs | 93 +- Aaru.Filesystems/Locus/Locus.cs | 7 - Aaru.Filesystems/MicroDOS/Info.cs | 16 +- Aaru.Filesystems/MinixFS/Info.cs | 64 +- Aaru.Filesystems/NILFS2/Info.cs | 55 +- Aaru.Filesystems/NTFS/Info.cs | 36 +- Aaru.Filesystems/Nintendo/Helpers.cs | 80 +- Aaru.Filesystems/Nintendo/Info.cs | 102 +- Aaru.Filesystems/ODS/Info.cs | 132 +- Aaru.Filesystems/Opera/Dir.cs | 60 +- Aaru.Filesystems/Opera/File.cs | 67 +- Aaru.Filesystems/Opera/Info.cs | 64 +- Aaru.Filesystems/Opera/Structs.cs | 8 +- Aaru.Filesystems/Opera/Super.cs | 18 +- Aaru.Filesystems/PCEngine/Info.cs | 6 +- Aaru.Filesystems/PCFX/Info.cs | 9 +- Aaru.Filesystems/PFS/Info.cs | 35 +- Aaru.Filesystems/ProDOS/Info.cs | 140 +- Aaru.Filesystems/QNX4/Info.cs | 18 +- Aaru.Filesystems/QNX6/Info.cs | 40 +- Aaru.Filesystems/RBF/Helpers.cs | 3 +- Aaru.Filesystems/RBF/Info.cs | 131 +- Aaru.Filesystems/RT11/Info.cs | 23 +- Aaru.Filesystems/ReFS/Info.cs | 50 +- Aaru.Filesystems/Reiser/Info.cs | 52 +- Aaru.Filesystems/Reiser4/Info.cs | 36 +- Aaru.Filesystems/SFS/Info.cs | 50 +- Aaru.Filesystems/SolarFS/Info.cs | 47 +- Aaru.Filesystems/Squash/Info.cs | 21 +- Aaru.Filesystems/SysV/Info.cs | 215 +- Aaru.Filesystems/UCSDPascal/Dir.cs | 18 +- Aaru.Filesystems/UCSDPascal/File.cs | 83 +- Aaru.Filesystems/UCSDPascal/Info.cs | 58 +- Aaru.Filesystems/UCSDPascal/Structs.cs | 8 +- Aaru.Filesystems/UCSDPascal/Super.cs | 21 +- Aaru.Filesystems/UDF/Helpers.cs | 11 +- Aaru.Filesystems/UDF/Info.cs | 110 +- Aaru.Filesystems/UNICOS/Consts.cs | 7 - Aaru.Filesystems/UNICOS/Info.cs | 43 +- Aaru.Filesystems/UNICOS/UNICOS.cs | 6 - Aaru.Filesystems/UNIXBFS/Info.cs | 17 +- Aaru.Filesystems/VMfs/Info.cs | 24 +- Aaru.Filesystems/VxFS/Info.cs | 28 +- Aaru.Filesystems/XFS/Info.cs | 106 +- Aaru.Filesystems/Xia/Info.cs | 51 +- Aaru.Filesystems/ZFS/Helpers.cs | 46 +- Aaru.Filesystems/ZFS/Info.cs | 42 +- Aaru.Filesystems/dump/Consts.cs | 1 - Aaru.Filesystems/dump/Info.cs | 43 +- Aaru.Filesystems/dump/Structs.cs | 1 - Aaru.Filesystems/dump/dump.cs | 1 - Aaru.Filesystems/exFAT/Info.cs | 68 +- Aaru.Filesystems/ext2FS/Info.cs | 167 +- Aaru.Filesystems/extFS/Info.cs | 25 +- Aaru.Filters/AppleDouble.cs | 68 +- Aaru.Filters/AppleSingle.cs | 40 +- Aaru.Filters/BZip2.cs | 15 +- Aaru.Filters/GZip.cs | 6 +- Aaru.Filters/LZip.cs | 6 +- Aaru.Filters/MacBinary.cs | 66 +- Aaru.Filters/PCExchange.cs | 18 +- Aaru.Filters/XZ.cs | 15 +- Aaru.Generators/PluginRegisterGenerator.cs | 97 +- Aaru.Gui/App.xaml | 15 +- Aaru.Gui/App.xaml.cs | 3 +- Aaru.Gui/ConsoleHandler.cs | 27 +- Aaru.Gui/ViewLocator.cs | 6 +- Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs | 3 +- .../ViewModels/Dialogs/ConsoleViewModel.cs | 22 +- .../ViewModels/Dialogs/EncodingsViewModel.cs | 15 +- .../ViewModels/Dialogs/LicenseViewModel.cs | 3 +- .../ViewModels/Dialogs/PluginsViewModel.cs | 24 +- .../ViewModels/Dialogs/SettingsViewModel.cs | 3 +- .../ViewModels/Dialogs/StatisticsViewModel.cs | 146 +- .../ViewModels/Panels/DeviceInfoViewModel.cs | 34 +- .../ViewModels/Panels/FileSystemViewModel.cs | 6 +- .../ViewModels/Panels/ImageInfoViewModel.cs | 122 +- .../ViewModels/Panels/MediaInfoViewModel.cs | 129 +- .../ViewModels/Panels/PartitionViewModel.cs | 3 +- .../Panels/SubdirectoryViewModel.cs | 89 +- Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs | 14 +- .../ViewModels/Tabs/BlurayInfoViewModel.cs | 3 +- .../Tabs/CompactDiscInfoViewModel.cs | 39 +- Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs | 9 +- .../Tabs/DvdWritableInfoViewModel.cs | 12 +- .../ViewModels/Tabs/PcmciaInfoViewModel.cs | 9 +- Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs | 102 +- .../ViewModels/Tabs/SdMmcInfoViewModel.cs | 24 +- Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs | 11 +- .../Windows/DecodeMediaTagsViewModel.cs | 6 +- .../Windows/ImageChecksumViewModel.cs | 110 +- .../Windows/ImageConvertViewModel.cs | 616 +++--- .../Windows/ImageEntropyViewModel.cs | 21 +- .../Windows/ImageSidecarViewModel.cs | 14 +- .../Windows/ImageVerifyViewModel.cs | 32 +- .../ViewModels/Windows/MainWindowViewModel.cs | 149 +- .../ViewModels/Windows/MediaDumpViewModel.cs | 117 +- .../ViewModels/Windows/MediaScanViewModel.cs | 36 +- .../Windows/SplashWindowViewModel.cs | 30 +- .../ViewModels/Windows/ViewSectorViewModel.cs | 3 +- Aaru.Gui/Views/Dialogs/About.xaml | 91 +- Aaru.Gui/Views/Dialogs/About.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/Console.xaml | 39 +- Aaru.Gui/Views/Dialogs/Console.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/Encodings.xaml | 37 +- Aaru.Gui/Views/Dialogs/Encodings.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/LicenseDialog.xaml | 30 +- Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/PluginsDialog.xaml | 221 +- Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/SettingsDialog.xaml | 28 +- Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml | 172 +- .../Views/Dialogs/StatisticsDialog.xaml.cs | 4 +- Aaru.Gui/Views/Panels/DeviceInfo.xaml | 252 ++- Aaru.Gui/Views/Panels/FileSystem.xaml | 58 +- Aaru.Gui/Views/Panels/ImageInfo.xaml | 205 +- Aaru.Gui/Views/Panels/MediaInfo.xaml | 49 +- Aaru.Gui/Views/Panels/Partition.xaml | 17 +- Aaru.Gui/Views/Panels/Subdirectory.xaml | 73 +- Aaru.Gui/Views/Tabs/AtaInfo.xaml | 21 +- Aaru.Gui/Views/Tabs/BlurayInfo.xaml | 43 +- Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml | 44 +- Aaru.Gui/Views/Tabs/DvdInfo.xaml | 42 +- Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml | 53 +- Aaru.Gui/Views/Tabs/PcmciaInfo.xaml | 19 +- Aaru.Gui/Views/Tabs/ScsiInfo.xaml | 56 +- Aaru.Gui/Views/Tabs/SdMmcInfo.xaml | 25 +- Aaru.Gui/Views/Tabs/XboxInfo.xaml | 57 +- Aaru.Gui/Views/Windows/DecodeMediaTags.xaml | 25 +- .../Views/Windows/DecodeMediaTags.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageChecksum.xaml | 101 +- Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageConvert.xaml | 86 +- Aaru.Gui/Views/Windows/ImageConvert.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageEntropy.xaml | 71 +- Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageSidecar.xaml | 50 +- Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageVerify.xaml | 66 +- Aaru.Gui/Views/Windows/ImageVerify.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MainWindow.xaml | 118 +- Aaru.Gui/Views/Windows/MainWindow.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MediaDump.xaml | 68 +- Aaru.Gui/Views/Windows/MediaDump.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MediaScan.xaml | 45 +- Aaru.Gui/Views/Windows/MediaScan.xaml.cs | 4 +- Aaru.Gui/Views/Windows/SplashWindow.xaml | 30 +- Aaru.Gui/Views/Windows/SplashWindow.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ViewSector.xaml | 22 +- Aaru.Gui/Views/Windows/ViewSector.xaml.cs | 4 +- Aaru.Helpers/ArrayFill.cs | 12 +- Aaru.Helpers/BigEndianBitConverter.cs | 13 +- Aaru.Helpers/CompareBytes.cs | 3 +- Aaru.Helpers/DateHandlers.cs | 89 +- Aaru.Helpers/IO/ForcedSeekStream.cs | 30 +- Aaru.Helpers/IO/OffsetStream.cs | 63 +- Aaru.Helpers/IO/SplitJoinStream.cs | 30 +- Aaru.Helpers/Marshal.cs | 33 +- Aaru.Helpers/PrintHex.cs | 27 +- Aaru.Helpers/StringHandlers.cs | 30 +- Aaru.Images/A2R/A2R.cs | 47 +- Aaru.Images/A2R/Helpers.cs | 6 +- Aaru.Images/A2R/Identify.cs | 3 +- Aaru.Images/A2R/Properties.cs | 1 + Aaru.Images/A2R/Read.cs | 79 +- Aaru.Images/A2R/Write.cs | 16 +- Aaru.Images/AaruFormat/CdEcc.cs | 48 +- .../AaruFormat/ClauniaSubchannelTransform.cs | 24 +- Aaru.Images/AaruFormat/Helpers.cs | 355 ++-- Aaru.Images/AaruFormat/Identify.cs | 3 +- Aaru.Images/AaruFormat/Properties.cs | 1 + Aaru.Images/AaruFormat/Read.cs | 588 +++--- Aaru.Images/AaruFormat/Verify.cs | 71 +- Aaru.Images/AaruFormat/Write.cs | 1027 +++++---- Aaru.Images/Alcohol120/Identify.cs | 3 +- Aaru.Images/Alcohol120/Properties.cs | 10 +- Aaru.Images/Alcohol120/Read.cs | 256 +-- Aaru.Images/Alcohol120/Verify.cs | 12 +- Aaru.Images/Alcohol120/Write.cs | 386 ++-- Aaru.Images/Anex86/Identify.cs | 3 +- Aaru.Images/Anex86/Properties.cs | 1 + Aaru.Images/Anex86/Read.cs | 12 +- Aaru.Images/Anex86/Write.cs | 15 +- Aaru.Images/Apple2MG/Identify.cs | 24 +- Aaru.Images/Apple2MG/Properties.cs | 1 + Aaru.Images/Apple2MG/Read.cs | 27 +- Aaru.Images/AppleDOS/Properties.cs | 1 + Aaru.Images/AppleDOS/Read.cs | 13 +- Aaru.Images/AppleDOS/Write.cs | 13 +- Aaru.Images/AppleNIB/Identify.cs | 3 +- Aaru.Images/AppleNIB/Properties.cs | 1 + Aaru.Images/AppleNIB/Read.cs | 55 +- Aaru.Images/Apridisk/Compression.cs | 3 +- Aaru.Images/Apridisk/Identify.cs | 3 +- Aaru.Images/Apridisk/Properties.cs | 1 + Aaru.Images/Apridisk/Read.cs | 62 +- Aaru.Images/Apridisk/Write.cs | 6 +- Aaru.Images/BLU/Identify.cs | 6 +- Aaru.Images/BLU/Properties.cs | 1 + Aaru.Images/BLU/Read.cs | 36 +- Aaru.Images/BLU/Verify.cs | 3 +- Aaru.Images/BLU/Write.cs | 3 +- Aaru.Images/BlindWrite4/Identify.cs | 3 +- Aaru.Images/BlindWrite4/Properties.cs | 1 + Aaru.Images/BlindWrite4/Read.cs | 248 +-- Aaru.Images/BlindWrite4/Structs.cs | 4 +- Aaru.Images/BlindWrite4/Verify.cs | 12 +- Aaru.Images/BlindWrite5/Identify.cs | 3 +- Aaru.Images/BlindWrite5/Properties.cs | 1 + Aaru.Images/BlindWrite5/Read.cs | 359 ++-- Aaru.Images/BlindWrite5/Verify.cs | 12 +- Aaru.Images/ByteAddressable/AtariLynx.cs | 54 +- Aaru.Images/ByteAddressable/GameBoy.cs | 67 +- Aaru.Images/ByteAddressable/GameBoyAdvance.cs | 40 +- Aaru.Images/ByteAddressable/MasterSystem.cs | 43 +- Aaru.Images/ByteAddressable/NES.cs | 80 +- Aaru.Images/ByteAddressable/Nintendo64.cs | 49 +- Aaru.Images/ByteAddressable/SegaMegaDrive.cs | 119 +- Aaru.Images/ByteAddressable/SuperNintendo.cs | 77 +- Aaru.Images/CDRDAO/Identify.cs | 9 +- Aaru.Images/CDRDAO/Properties.cs | 1 + Aaru.Images/CDRDAO/Read.cs | 259 ++- Aaru.Images/CDRDAO/Verify.cs | 12 +- Aaru.Images/CDRDAO/Write.cs | 90 +- Aaru.Images/CDRWin/Identify.cs | 6 +- Aaru.Images/CDRWin/Properties.cs | 4 +- Aaru.Images/CDRWin/Read.cs | 347 +-- Aaru.Images/CDRWin/Verify.cs | 23 +- Aaru.Images/CDRWin/Write.cs | 111 +- Aaru.Images/CHD/Helpers.cs | 29 +- Aaru.Images/CHD/Properties.cs | 4 +- Aaru.Images/CHD/Read.cs | 175 +- Aaru.Images/CHD/Verify.cs | 27 +- Aaru.Images/CPCDSK/Identify.cs | 9 +- Aaru.Images/CPCDSK/Properties.cs | 1 + Aaru.Images/CPCDSK/Read.cs | 124 +- Aaru.Images/CisCopy/Identify.cs | 24 +- Aaru.Images/CisCopy/Properties.cs | 1 + Aaru.Images/CisCopy/Read.cs | 9 +- Aaru.Images/CisCopy/Write.cs | 6 +- Aaru.Images/CloneCD/Identify.cs | 6 +- Aaru.Images/CloneCD/Properties.cs | 1 + Aaru.Images/CloneCD/Read.cs | 156 +- Aaru.Images/CloneCD/Verify.cs | 12 +- Aaru.Images/CloneCD/Write.cs | 39 +- Aaru.Images/CopyQM/Identify.cs | 3 +- Aaru.Images/CopyQM/Properties.cs | 1 + Aaru.Images/CopyQM/Read.cs | 20 +- Aaru.Images/CopyTape/Identify.cs | 15 +- Aaru.Images/CopyTape/Properties.cs | 1 + Aaru.Images/CopyTape/Read.cs | 27 +- Aaru.Images/CopyTape/Write.cs | 9 +- Aaru.Images/D88/Identify.cs | 21 +- Aaru.Images/D88/Properties.cs | 1 + Aaru.Images/D88/Read.cs | 57 +- Aaru.Images/DART/DART.cs | 1 + Aaru.Images/DART/Identify.cs | 24 +- Aaru.Images/DART/Properties.cs | 1 + Aaru.Images/DART/Read.cs | 85 +- Aaru.Images/DIM/Identify.cs | 3 +- Aaru.Images/DIM/Properties.cs | 1 + Aaru.Images/DIM/Read.cs | 33 +- Aaru.Images/DiscFerret/Properties.cs | 1 + Aaru.Images/DiscFerret/Read.cs | 9 +- Aaru.Images/DiscJuggler/Identify.cs | 6 +- Aaru.Images/DiscJuggler/Properties.cs | 1 + Aaru.Images/DiscJuggler/Read.cs | 138 +- Aaru.Images/DiscJuggler/Verify.cs | 12 +- Aaru.Images/DiskCopy42/Helpers.cs | 3 +- Aaru.Images/DiskCopy42/Identify.cs | 15 +- Aaru.Images/DiskCopy42/Read.cs | 77 +- Aaru.Images/DiskCopy42/Verify.cs | 3 +- Aaru.Images/DiskCopy42/Write.cs | 12 +- Aaru.Images/DiskDupe/Helpers.cs | 15 +- Aaru.Images/DiskDupe/Properties.cs | 1 + Aaru.Images/DiskDupe/Read.cs | 21 +- Aaru.Images/DriDiskCopy/Identify.cs | 15 +- Aaru.Images/DriDiskCopy/Properties.cs | 1 + Aaru.Images/DriDiskCopy/Read.cs | 16 +- Aaru.Images/GDI/Identify.cs | 15 +- Aaru.Images/GDI/Properties.cs | 1 + Aaru.Images/GDI/Read.cs | 142 +- Aaru.Images/GDI/Verify.cs | 12 +- Aaru.Images/HDCopy/Helpers.cs | 18 +- Aaru.Images/HDCopy/Properties.cs | 1 + Aaru.Images/HDCopy/Read.cs | 38 +- Aaru.Images/IMD/Identify.cs | 3 +- Aaru.Images/IMD/Properties.cs | 1 + Aaru.Images/IMD/Read.cs | 36 +- Aaru.Images/KryoFlux/Identify.cs | 3 +- Aaru.Images/KryoFlux/KryoFlux.cs | 1 + Aaru.Images/KryoFlux/Properties.cs | 1 + Aaru.Images/KryoFlux/Read.cs | 46 +- Aaru.Images/MaxiDisk/Identify.cs | 12 +- Aaru.Images/MaxiDisk/Properties.cs | 1 + Aaru.Images/MaxiDisk/Read.cs | 21 +- Aaru.Images/NDIF/Identify.cs | 12 +- Aaru.Images/NDIF/Properties.cs | 1 + Aaru.Images/NDIF/Read.cs | 68 +- Aaru.Images/NHDr0/Identify.cs | 12 +- Aaru.Images/NHDr0/Properties.cs | 1 + Aaru.Images/NHDr0/Read.cs | 9 +- Aaru.Images/NHDr0/Write.cs | 8 +- Aaru.Images/Nero/Identify.cs | 3 +- Aaru.Images/Nero/Properties.cs | 1 + Aaru.Images/Nero/Read.cs | 442 ++-- Aaru.Images/Nero/Verify.cs | 12 +- Aaru.Images/Parallels/Identify.cs | 3 +- Aaru.Images/Parallels/Properties.cs | 1 + Aaru.Images/Parallels/Read.cs | 24 +- Aaru.Images/Parallels/Write.cs | 21 +- Aaru.Images/PartClone/Identify.cs | 6 +- Aaru.Images/PartClone/PartClone.cs | 1 + Aaru.Images/PartClone/Properties.cs | 1 + Aaru.Images/PartClone/Read.cs | 30 +- Aaru.Images/Partimage/Identify.cs | 3 +- Aaru.Images/Partimage/Properties.cs | 1 + Aaru.Images/Partimage/Read.cs | 147 +- Aaru.Images/QCOW/Identify.cs | 3 +- Aaru.Images/QCOW/Properties.cs | 1 + Aaru.Images/QCOW/Read.cs | 48 +- Aaru.Images/QCOW/Write.cs | 24 +- Aaru.Images/QCOW2/Identify.cs | 3 +- Aaru.Images/QCOW2/Properties.cs | 1 + Aaru.Images/QCOW2/Read.cs | 54 +- Aaru.Images/QCOW2/Write.cs | 47 +- Aaru.Images/QED/Helpers.cs | 6 +- Aaru.Images/QED/Identify.cs | 3 +- Aaru.Images/QED/Properties.cs | 1 + Aaru.Images/QED/Read.cs | 36 +- Aaru.Images/QED/Write.cs | 18 +- Aaru.Images/RayDIM/Identify.cs | 3 +- Aaru.Images/RayDIM/Properties.cs | 1 + Aaru.Images/RayDIM/Read.cs | 12 +- Aaru.Images/RsIde/Helpers.cs | 3 +- Aaru.Images/RsIde/Properties.cs | 1 + Aaru.Images/RsIde/Read.cs | 9 +- Aaru.Images/RsIde/Write.cs | 38 +- Aaru.Images/SaveDskF/Identify.cs | 3 +- Aaru.Images/SaveDskF/Properties.cs | 1 + Aaru.Images/SaveDskF/Read.cs | 19 +- Aaru.Images/SaveDskF/Write.cs | 6 +- Aaru.Images/SuperCardPro/Helpers.cs | 10 +- Aaru.Images/SuperCardPro/Identify.cs | 3 +- Aaru.Images/SuperCardPro/Properties.cs | 1 + Aaru.Images/SuperCardPro/Read.cs | 113 +- Aaru.Images/SuperCardPro/SuperCardPro.cs | 8 +- Aaru.Images/SuperCardPro/Verify.cs | 6 +- Aaru.Images/SuperCardPro/Write.cs | 9 +- Aaru.Images/T98/Identify.cs | 6 +- Aaru.Images/T98/Properties.cs | 1 + Aaru.Images/T98/Read.cs | 12 +- Aaru.Images/TeleDisk/Helpers.cs | 22 +- Aaru.Images/TeleDisk/Identify.cs | 18 +- Aaru.Images/TeleDisk/Properties.cs | 1 + Aaru.Images/TeleDisk/Read.cs | 131 +- Aaru.Images/TeleDisk/Verify.cs | 3 +- Aaru.Images/UDIF/Identify.cs | 6 +- Aaru.Images/UDIF/Properties.cs | 1 + Aaru.Images/UDIF/Read.cs | 95 +- Aaru.Images/UDIF/Write.cs | 17 +- Aaru.Images/UkvFdi/Identify.cs | 3 +- Aaru.Images/UkvFdi/Properties.cs | 1 + Aaru.Images/UkvFdi/Read.cs | 40 +- Aaru.Images/VDI/Identify.cs | 3 +- Aaru.Images/VDI/Properties.cs | 1 + Aaru.Images/VDI/Read.cs | 30 +- Aaru.Images/VDI/Write.cs | 21 +- Aaru.Images/VHD/Properties.cs | 1 + Aaru.Images/VHD/Read.cs | 169 +- Aaru.Images/VHD/Write.cs | 46 +- Aaru.Images/VHDX/Helpers.cs | 3 +- Aaru.Images/VHDX/Identify.cs | 3 +- Aaru.Images/VHDX/Properties.cs | 1 + Aaru.Images/VHDX/Read.cs | 67 +- Aaru.Images/VMware/Properties.cs | 1 + Aaru.Images/VMware/Read.cs | 93 +- Aaru.Images/VMware/Write.cs | 9 +- Aaru.Images/Virtual98/Identify.cs | 12 +- Aaru.Images/Virtual98/Properties.cs | 1 + Aaru.Images/Virtual98/Read.cs | 15 +- Aaru.Images/Virtual98/Write.cs | 3 +- Aaru.Images/WCDiskImage/Identify.cs | 18 +- Aaru.Images/WCDiskImage/Properties.cs | 1 + Aaru.Images/WCDiskImage/Read.cs | 57 +- Aaru.Images/ZZZRawImage/Helpers.cs | 7 +- Aaru.Images/ZZZRawImage/Identify.cs | 10 +- Aaru.Images/ZZZRawImage/Properties.cs | 41 +- Aaru.Images/ZZZRawImage/Read.cs | 124 +- Aaru.Images/ZZZRawImage/Verify.cs | 21 +- Aaru.Images/ZZZRawImage/Write.cs | 21 +- Aaru.Partitions/Acorn.cs | 46 +- Aaru.Partitions/AppleMap.cs | 82 +- Aaru.Partitions/Apricot.cs | 120 +- Aaru.Partitions/Atari.cs | 56 +- Aaru.Partitions/BSD.cs | 48 +- Aaru.Partitions/DEC.cs | 13 +- Aaru.Partitions/DragonFlyBSD.cs | 18 +- Aaru.Partitions/GPT.cs | 28 +- Aaru.Partitions/Human68k.cs | 19 +- Aaru.Partitions/MBR.cs | 95 +- Aaru.Partitions/NeXT.cs | 85 +- Aaru.Partitions/PC98.cs | 28 +- Aaru.Partitions/Plan9.cs | 15 +- Aaru.Partitions/RDB.cs | 159 +- Aaru.Partitions/RioKarma.cs | 6 +- Aaru.Partitions/SGI.cs | 27 +- Aaru.Partitions/Sun.cs | 119 +- Aaru.Partitions/UNIX.cs | 6 +- Aaru.Partitions/VTOC.cs | 121 +- Aaru.Partitions/XENIX.cs | 24 +- Aaru.Partitions/Xbox.cs | 15 +- Aaru.Settings/Settings.cs | 144 +- Aaru.Tests.Devices/ATA/Ata28.cs | 95 +- Aaru.Tests.Devices/ATA/Ata48.cs | 79 +- Aaru.Tests.Devices/ATA/AtaCHS.cs | 73 +- Aaru.Tests.Devices/ATA/Atapi.cs | 6 +- Aaru.Tests.Devices/ATA/Cfa.cs | 32 +- Aaru.Tests.Devices/ATA/MCPT.cs | 4 +- Aaru.Tests.Devices/ATA/Smart.cs | 29 +- Aaru.Tests.Devices/DecodeATARegisters.cs | 48 +- Aaru.Tests.Devices/Device.cs | 6 +- Aaru.Tests.Devices/Main.cs | 33 +- Aaru.Tests.Devices/SCSI/Adaptec.cs | 32 +- Aaru.Tests.Devices/SCSI/ArchiveCorp.cs | 37 +- Aaru.Tests.Devices/SCSI/Certance.cs | 6 +- Aaru.Tests.Devices/SCSI/Fujitsu.cs | 17 +- Aaru.Tests.Devices/SCSI/HL-DT-ST.cs | 12 +- Aaru.Tests.Devices/SCSI/HP.cs | 35 +- Aaru.Tests.Devices/SCSI/Kreon.cs | 27 +- Aaru.Tests.Devices/SCSI/MMC.cs | 248 ++- Aaru.Tests.Devices/SCSI/NEC.cs | 12 +- Aaru.Tests.Devices/SCSI/Pioneer.cs | 62 +- Aaru.Tests.Devices/SCSI/Plasmon.cs | 56 +- Aaru.Tests.Devices/SCSI/Plextor.cs | 139 +- Aaru.Tests.Devices/SCSI/SBC.cs | 112 +- Aaru.Tests.Devices/SCSI/SMC.cs | 28 +- Aaru.Tests.Devices/SCSI/SPC.cs | 115 +- Aaru.Tests.Devices/SCSI/SSC.cs | 238 ++- Aaru.Tests.Devices/SCSI/SyQuest.cs | 40 +- Aaru.Tests.Devices/SCSI_MMC/GdRom.cs | 341 +-- Aaru.Tests.Devices/SCSI_MMC/LeadOutTrap.cs | 234 ++- Aaru.Tests.Devices/SCSI_MMC/MediaTek.cs | 28 +- Aaru.Tests.Devices/SCSI_MMC/SCSI_MMC.cs | 4 +- .../SecureDigital/MultiMediaCard.cs | 64 +- .../SecureDigital/SecureDigital.cs | 64 +- Aaru.Tests/Checksums/Adler32.cs | 24 +- Aaru.Tests/Checksums/CRC16CCITT.cs | 24 +- Aaru.Tests/Checksums/CRC16IBM.cs | 24 +- Aaru.Tests/Checksums/CRC32.cs | 24 +- Aaru.Tests/Checksums/CRC64.cs | 24 +- Aaru.Tests/Checksums/MD5.cs | 12 +- Aaru.Tests/Checksums/SHA1.cs | 12 +- Aaru.Tests/Checksums/SHA256.cs | 12 +- Aaru.Tests/Checksums/SHA384.cs | 12 +- Aaru.Tests/Checksums/SHA512.cs | 12 +- Aaru.Tests/Checksums/SpamSum.cs | 12 +- Aaru.Tests/Consts.cs | 7 +- Aaru.Tests/Devices/IomegaJaz.cs | 12 +- Aaru.Tests/Devices/LS120.cs | 12 +- Aaru.Tests/Devices/MultiMediaCard/CID.cs | 15 +- Aaru.Tests/Devices/MultiMediaCard/CSD.cs | 72 +- Aaru.Tests/Devices/PocketZip.cs | 12 +- Aaru.Tests/Devices/SecureDigital/CID.cs | 15 +- Aaru.Tests/Devices/SecureDigital/CSD.cs | 60 +- Aaru.Tests/Devices/SecureDigital/SCR.cs | 21 +- Aaru.Tests/Filesystems/ADFS.cs | 4 +- Aaru.Tests/Filesystems/FilesystemTest.cs | 63 +- Aaru.Tests/Filesystems/HPFS.cs | 4 +- Aaru.Tests/Filesystems/HPOFS.cs | 4 +- Aaru.Tests/Filesystems/NILFS2.cs | 3 +- Aaru.Tests/Filesystems/PFS3/APM.cs | 4 +- Aaru.Tests/Filesystems/PFS3/RDB.cs | 4 +- Aaru.Tests/Filesystems/ReFS.cs | 4 +- .../Filesystems/ReadOnlyFilesystemTest.cs | 210 +- Aaru.Tests/Filters/AppleDoubleNetatalk.cs | 6 +- Aaru.Tests/Images/Alcohol120.cs | 4 +- Aaru.Tests/Images/BlindWrite4.cs | 4 +- Aaru.Tests/Images/BlindWrite5.cs | 4 +- Aaru.Tests/Images/BlockMediaImageTest.cs | 98 +- Aaru.Tests/Images/CloneCD.cs | 4 +- Aaru.Tests/Images/DART.cs | 4 +- Aaru.Tests/Images/DiscJuggler.cs | 4 +- Aaru.Tests/Images/GameJack6.cs | 2 - Aaru.Tests/Images/Nero/V1.cs | 4 +- Aaru.Tests/Images/Nero/V2.cs | 85 +- Aaru.Tests/Images/OpticalMediaImageTest.cs | 392 ++-- Aaru.Tests/Images/ShrinkWrap/NDIF/ROCo.cs | 7 +- Aaru.Tests/Images/ShrinkWrap/NDIF/RdWr.cs | 8 +- Aaru.Tests/Images/ShrinkWrap/NDIF/Rdxx.cs | 7 +- Aaru.Tests/Images/TapeMediaImageTest.cs | 35 +- Aaru.Tests/Images/cdrdao/raw/rw_raw.cs | 4 +- .../590/asus-driver-gpu-tweak-v1231-2014.cs | 4 +- Aaru.Tests/Issues/FsExtractHashIssueTest.cs | 96 +- Aaru.Tests/Issues/FsExtractIssueTest.cs | 49 +- .../Issues/OpticalImageConvertIssueTest.cs | 127 +- .../Issues/OpticalImageReadIssueTest.cs | 4 +- Aaru.Tests/Partitions/PartitionSchemeTest.cs | 3 +- .../WritableOpticalMediaImageTest.cs | 395 ++-- Aaru/Commands/Archive/Extract.cs | 134 +- Aaru/Commands/Archive/Info.cs | 11 +- Aaru/Commands/Archive/List.cs | 86 +- Aaru/Commands/Configure.cs | 8 +- Aaru/Commands/Database/Statistics.cs | 82 +- Aaru/Commands/Database/Update.cs | 9 +- Aaru/Commands/Device/DeviceReport.cs | 426 ++-- Aaru/Commands/Device/Info.cs | 352 ++-- Aaru/Commands/Device/List.cs | 23 +- Aaru/Commands/Filesystem/ExtractFiles.cs | 200 +- Aaru/Commands/Filesystem/Info.cs | 74 +- Aaru/Commands/Filesystem/Ls.cs | 78 +- Aaru/Commands/Filesystem/Options.cs | 18 +- Aaru/Commands/Formats.cs | 47 +- Aaru/Commands/Image/Checksum.cs | 324 +-- Aaru/Commands/Image/Compare.cs | 147 +- Aaru/Commands/Image/Convert.cs | 573 ++--- Aaru/Commands/Image/CreateSidecar.cs | 79 +- Aaru/Commands/Image/Decode.cs | 112 +- Aaru/Commands/Image/Entropy.cs | 54 +- Aaru/Commands/Image/Options.cs | 21 +- Aaru/Commands/Image/Print.cs | 31 +- Aaru/Commands/Image/Verify.cs | 100 +- Aaru/Commands/ListEncodings.cs | 12 +- Aaru/Commands/ListNamespaces.cs | 3 +- Aaru/Commands/Media/Dump.cs | 333 +-- Aaru/Commands/Media/Info.cs | 380 +++- Aaru/Commands/Media/Scan.cs | 49 +- Aaru/Commands/Remote.cs | 7 +- Aaru/Main.cs | 60 +- 922 files changed, 36437 insertions(+), 29485 deletions(-) diff --git a/Aaru.Archives/Aaru.Archives.csproj.DotSettings b/Aaru.Archives/Aaru.Archives.csproj.DotSettings index 246d36963..45681b16d 100644 --- a/Aaru.Archives/Aaru.Archives.csproj.DotSettings +++ b/Aaru.Archives/Aaru.Archives.csproj.DotSettings @@ -1,3 +1,6 @@ - + True True \ No newline at end of file diff --git a/Aaru.Archives/Symbian/Conditions.cs b/Aaru.Archives/Symbian/Conditions.cs index eaccc0103..29bd833b7 100644 --- a/Aaru.Archives/Symbian/Conditions.cs +++ b/Aaru.Archives/Symbian/Conditions.cs @@ -42,19 +42,18 @@ public sealed partial class Symbian ConditionalExpression ParseConditionalExpression(BinaryReader br, uint maxOffset, StringBuilder sb, ref Attribute? attribute) { - if(br.BaseStream.Position >= maxOffset) - return null; + if(br.BaseStream.Position >= maxOffset) return null; var type = (ConditionalType)br.ReadUInt32(); var operatorString = ""; SubConditionalExpression subExpression; TwoSubsConditionalExpression twoSubsConditionalExpression; + switch(type) { case ConditionalType.Equals: - if(type == ConditionalType.Equals) - operatorString = " == "; + if(type == ConditionalType.Equals) operatorString = " == "; twoSubsConditionalExpression = new TwoSubsConditionalExpression { @@ -64,8 +63,10 @@ public sealed partial class Symbian sb.Append("("); twoSubsConditionalExpression.leftOperand = ParseConditionalExpression(br, maxOffset, sb, ref attribute); sb.Append(operatorString); + twoSubsConditionalExpression.rightOperand = ParseConditionalExpression(br, maxOffset, sb, ref attribute); + sb.Append(")"); attribute = null; @@ -94,11 +95,13 @@ public sealed partial class Symbian goto case ConditionalType.Equals; case ConditionalType.Exists: sb.Append("exists("); + subExpression = new SubConditionalExpression { type = type, subExpression = ParseConditionalExpression(br, maxOffset, sb, ref attribute) }; + sb.Append(")"); attribute = null; @@ -106,11 +109,13 @@ public sealed partial class Symbian return subExpression; case ConditionalType.DeviceCapability: sb.Append("devcap("); + subExpression = new SubConditionalExpression { type = type, subExpression = ParseConditionalExpression(br, maxOffset, sb, ref attribute) }; + sb.Append(')'); attribute = null; @@ -125,8 +130,10 @@ public sealed partial class Symbian sb.Append("appcap("); twoSubsConditionalExpression.leftOperand = ParseConditionalExpression(br, maxOffset, sb, ref attribute); sb.Append(", "); + twoSubsConditionalExpression.rightOperand = ParseConditionalExpression(br, maxOffset, sb, ref attribute); + sb.Append(')'); attribute = null; @@ -134,6 +141,7 @@ public sealed partial class Symbian return twoSubsConditionalExpression; case ConditionalType.Not: sb.Append('!'); + subExpression = new SubConditionalExpression { type = type, @@ -208,11 +216,13 @@ public sealed partial class Symbian { case Attribute.Manufacturer: sb.Append($"{(ManufacturerCode)numberExpression.number}"); + break; case Attribute.ManufacturerHardwareRev: case Attribute.ManufacturerSoftwareRev: case Attribute.DeviceFamilyRev: sb.Append($"{numberExpression.number >> 8}.{numberExpression.number & 0xFF}"); + break; case Attribute.MachineUid: sb.Append($"{DecodeMachineUid(numberExpression.number)}"); @@ -220,18 +230,23 @@ public sealed partial class Symbian break; case Attribute.DeviceFamily: sb.Append($"{(DeviceFamilyCode)numberExpression.number}"); + break; case Attribute.CPU: sb.Append($"{(CpuCode)numberExpression.number}"); + break; case Attribute.CPUArch: sb.Append($"{(CpuArchitecture)numberExpression.number}"); + break; case Attribute.CPUABI: sb.Append($"{(CpuAbiCode)numberExpression.number}"); + break; case Attribute.CPUSpeed: sb.Append($"{numberExpression.number / 1024}MHz"); + break; case Attribute.SystemTickPeriod: sb.Append($"{numberExpression.number}μs"); @@ -264,6 +279,7 @@ public sealed partial class Symbian case Attribute.NumHalAttributes: case Attribute.Language: sb.Append($"{numberExpression.number}"); + break; case Attribute.PowerBackup: case Attribute.KeyboardClick: @@ -276,9 +292,11 @@ public sealed partial class Symbian case Attribute.IntegratedPhone: case Attribute.RemoteInstall: sb.Append(numberExpression.number == 0 ? "false" : "true"); + break; default: sb.Append($"0x{numberExpression.number:X8}"); + break; } } diff --git a/Aaru.Archives/Symbian/Files.cs b/Aaru.Archives/Symbian/Files.cs index d9149f2d2..4596ba757 100644 --- a/Aaru.Archives/Symbian/Files.cs +++ b/Aaru.Archives/Symbian/Files.cs @@ -54,11 +54,9 @@ public sealed partial class Symbian { fileName = null; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; fileName = _files[entryNumber].destinationName; @@ -70,11 +68,9 @@ public sealed partial class Symbian { entryNumber = -1; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(string.IsNullOrEmpty(fileName)) - return ErrorNumber.InvalidArgument; + if(string.IsNullOrEmpty(fileName)) return ErrorNumber.InvalidArgument; entryNumber = _files.FindIndex(x => caseInsensitiveMatch ? x.destinationName.Equals(fileName, @@ -88,11 +84,10 @@ public sealed partial class Symbian public ErrorNumber GetCompressedSize(int entryNumber, out long length) { length = -1; - if(!Opened) - return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(!Opened) return ErrorNumber.NotOpened; + + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; length = _files[entryNumber].length; @@ -103,11 +98,10 @@ public sealed partial class Symbian public ErrorNumber GetUncompressedSize(int entryNumber, out long length) { length = -1; - if(!Opened) - return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(!Opened) return ErrorNumber.NotOpened; + + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; length = _compressed ? _files[entryNumber].originalLength : _files[entryNumber].length; @@ -119,11 +113,9 @@ public sealed partial class Symbian { attributes = FileAttributes.None; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; attributes = FileAttributes.Normal; @@ -135,11 +127,9 @@ public sealed partial class Symbian { stat = null; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; stat = new FileEntryInfo { @@ -155,23 +145,25 @@ public sealed partial class Symbian public ErrorNumber GetEntry(int entryNumber, out IFilter filter) { filter = null; - if(!Opened) - return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(!Opened) return ErrorNumber.NotOpened; - Stream stream = new OffsetStream(new NonClosableStream(_stream), _files[entryNumber].pointer, + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; + + Stream stream = new OffsetStream(new NonClosableStream(_stream), + _files[entryNumber].pointer, _files[entryNumber].pointer + _files[entryNumber].length); ErrorNumber errno; + if(_compressed) { if(_files[entryNumber].originalLength == 0) stream = new MemoryStream(Array.Empty()); else { - stream = new ForcedSeekStream(_files[entryNumber].originalLength, stream, + stream = new ForcedSeekStream(_files[entryNumber].originalLength, + stream, CompressionMode.Decompress); } } @@ -179,10 +171,10 @@ public sealed partial class Symbian filter = new ZZZNoFilter(); errno = filter.Open(stream); - if(errno == ErrorNumber.NoError) - return ErrorNumber.NoError; + if(errno == ErrorNumber.NoError) return ErrorNumber.NoError; stream.Close(); + return errno; } diff --git a/Aaru.Archives/Symbian/Info.cs b/Aaru.Archives/Symbian/Info.cs index 216634aaf..e41c22fb4 100644 --- a/Aaru.Archives/Symbian/Info.cs +++ b/Aaru.Archives/Symbian/Info.cs @@ -50,8 +50,7 @@ public sealed partial class Symbian /// public bool Identify(IFilter filter) { - if(filter.DataForkLength < Marshal.SizeOf()) - return false; + if(filter.DataForkLength < Marshal.SizeOf()) return false; Stream stream = filter.GetDataForkStream(); @@ -61,11 +60,9 @@ public sealed partial class Symbian SymbianHeader header = Marshal.ByteArrayToStructureLittleEndian(hdr); - if(header.uid1 == SYMBIAN9_MAGIC) - return true; + if(header.uid1 == SYMBIAN9_MAGIC) return true; - if(header.uid3 != SYMBIAN_MAGIC) - return false; + if(header.uid3 != SYMBIAN_MAGIC) return false; return header.uid2 is EPOC_MAGIC or EPOC6_MAGIC; } @@ -78,8 +75,7 @@ public sealed partial class Symbian var capabilities = new Dictionary(); Stream stream = filter.GetDataForkStream(); - if(stream.Length < Marshal.SizeOf()) - return; + if(stream.Length < Marshal.SizeOf()) return; var buffer = new byte[Marshal.SizeOf()]; @@ -142,13 +138,16 @@ public sealed partial class Symbian { case EPOC_MAGIC: description.AppendLine(Localization.Symbian_3_or_later); + break; case EPOC6_MAGIC: description.AppendLine(Localization.Symbian_6_or_later); _release6 = true; + break; default: description.AppendFormat(Localization.Unknown_EPOC_magic_0, sh.uid2).AppendLine(); + break; } @@ -164,15 +163,16 @@ public sealed partial class Symbian // Go to enumerate languages br.BaseStream.Seek(sh.lang_ptr, SeekOrigin.Begin); - for(var i = 0; i < sh.languages; i++) - languages.Add(((LanguageCodes)br.ReadUInt16()).ToString("G")); + for(var i = 0; i < sh.languages; i++) languages.Add(((LanguageCodes)br.ReadUInt16()).ToString("G")); // Go to component record br.BaseStream.Seek(sh.comp_ptr, SeekOrigin.Begin); + var componentRecord = new ComponentRecord { names = new string[languages.Count] }; + buffer = new byte[sizeof(uint) * languages.Count]; // Read the component string lenghts @@ -189,7 +189,9 @@ public sealed partial class Symbian { AaruConsole.DebugWriteLine(MODULE_NAME, "Found component name for language {0} at {1} with a length of {2} bytes", - languages[i], componentRecord.namesPointers[i], componentRecord.namesLengths[i]); + languages[i], + componentRecord.namesPointers[i], + componentRecord.namesLengths[i]); br.BaseStream.Seek(componentRecord.namesPointers[i], SeekOrigin.Begin); buffer = br.ReadBytes((int)componentRecord.namesLengths[i]); @@ -198,6 +200,7 @@ public sealed partial class Symbian // Go to capabilities (???) br.BaseStream.Seek(sh.caps_ptr, SeekOrigin.Begin); + for(var i = 0; i < sh.capabilities; i++) { uint cap_Key = br.ReadUInt32(); @@ -214,6 +217,7 @@ public sealed partial class Symbian { case SymbianType.Application: description.AppendLine(Localization.SIS_contains_an_application); + break; } @@ -225,8 +229,7 @@ public sealed partial class Symbian for(var i = 0; i < languages.Count; i++) { - if(i > 0) - description.Append(", "); + if(i > 0) description.Append(", "); description.Append($"{languages[i]}"); } @@ -235,9 +238,10 @@ public sealed partial class Symbian for(var i = 0; i < languages.Count; i++) { - description.AppendFormat(Localization.Component_name_for_language_with_code_0_1, languages[i], - componentRecord.names[i]). - AppendLine(); + description.AppendFormat(Localization.Component_name_for_language_with_code_0_1, + languages[i], + componentRecord.names[i]) + .AppendLine(); } description.AppendLine(); @@ -252,6 +256,7 @@ public sealed partial class Symbian for(var r = 0; r < sh.requisites; r++) { br.BaseStream.Seek(offset, SeekOrigin.Begin); + var requisiteRecord = new RequisiteRecord { uid = br.ReadUInt32(), @@ -269,10 +274,13 @@ public sealed partial class Symbian requisiteRecord.namesPointers = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); description.AppendFormat(Localization.Requisite_0, r).AppendLine(); + description.AppendFormat("\t" + Localization.Required_UID_0_version_1_2, - DecodePlatformUid(requisiteRecord.uid), requisiteRecord.majorVersion, - requisiteRecord.minorVersion). - AppendLine(); + DecodePlatformUid(requisiteRecord.uid), + requisiteRecord.majorVersion, + requisiteRecord.minorVersion) + .AppendLine(); + description.AppendFormat("\t" + Localization.Required_variant_0, requisiteRecord.variant).AppendLine(); offset = (uint)br.BaseStream.Position; @@ -281,9 +289,11 @@ public sealed partial class Symbian { br.BaseStream.Seek(requisiteRecord.namesPointers[i], SeekOrigin.Begin); buffer = br.ReadBytes((int)requisiteRecord.namesLengths[i]); - description.AppendFormat("\t" + Localization.Requisite_for_language_0_1, languages[i], - _encoding.GetString(buffer)). - AppendLine(); + + description.AppendFormat("\t" + Localization.Requisite_for_language_0_1, + languages[i], + _encoding.GetString(buffer)) + .AppendLine(); } description.AppendLine(); @@ -313,6 +323,7 @@ public sealed partial class Symbian offset = sh.files_ptr; currentFile = 0; conditionLevel = 0; + do { Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, false); @@ -322,25 +333,29 @@ public sealed partial class Symbian // Files appear on .sis in the reverse order they should be processed _files.Reverse(); + // Conditions do as well _conditions.Reverse(); if(_files.Any(t => t.language is null)) { description.AppendLine(Localization.Files_for_all_languages); + foreach(DecodedFileRecord file in _files.Where(t => t.language is null)) description.AppendLine($"{file.destinationName}"); + description.AppendLine(); } foreach(string lang in languages) { - if(_files.All(t => t.language != lang)) - continue; + if(_files.All(t => t.language != lang)) continue; description.AppendFormat(Localization.Files_for_0_language, lang).AppendLine(); + foreach(DecodedFileRecord file in _files.Where(t => t.language == lang)) description.AppendLine($"{file.destinationName}"); + description.AppendLine(); } @@ -351,9 +366,12 @@ public sealed partial class Symbian OptionRecord option = _options[i]; description.AppendFormat(Localization.Option_0, i + 1).AppendLine(); + foreach(KeyValuePair kvp in option.names) - description.AppendFormat("\t" + Localization.Name_for_language_0_1, kvp.Key, kvp.Value). - AppendLine(); + { + description.AppendFormat("\t" + Localization.Name_for_language_0_1, kvp.Key, kvp.Value) + .AppendLine(); + } } description.AppendLine(); @@ -362,8 +380,7 @@ public sealed partial class Symbian if(_conditions.Count > 0) { description.AppendLine("Conditions:"); - foreach(string condition in _conditions) - description.AppendLine(condition); + foreach(string condition in _conditions) description.AppendLine(condition); } information = description.ToString(); diff --git a/Aaru.Archives/Symbian/Open.cs b/Aaru.Archives/Symbian/Open.cs index c224ea0a7..1346202b7 100644 --- a/Aaru.Archives/Symbian/Open.cs +++ b/Aaru.Archives/Symbian/Open.cs @@ -49,14 +49,12 @@ public sealed partial class Symbian public ErrorNumber Open(IFilter filter, Encoding encoding) { // Already opened! - if(Opened) - return ErrorNumber.InvalidArgument; + if(Opened) return ErrorNumber.InvalidArgument; var languages = new List(); _stream = filter.GetDataForkStream(); - if(_stream.Length < Marshal.SizeOf()) - return ErrorNumber.InvalidArgument; + if(_stream.Length < Marshal.SizeOf()) return ErrorNumber.InvalidArgument; var buffer = new byte[Marshal.SizeOf()]; @@ -99,6 +97,7 @@ public sealed partial class Symbian if(sh.uid1 == SYMBIAN9_MAGIC) { AaruConsole.ErrorWriteLine("Symbian Installation Files from Symbian OS 9 or later are not yet supported."); + return ErrorNumber.NotSupported; } @@ -110,6 +109,7 @@ public sealed partial class Symbian break; case EPOC6_MAGIC: _release6 = true; + break; } } @@ -123,8 +123,7 @@ public sealed partial class Symbian // Go to enumerate languages br.BaseStream.Seek(sh.lang_ptr, SeekOrigin.Begin); - for(var i = 0; i < sh.languages; i++) - languages.Add(((LanguageCodes)br.ReadUInt16()).ToString("G")); + for(var i = 0; i < sh.languages; i++) languages.Add(((LanguageCodes)br.ReadUInt16()).ToString("G")); _files = new List(); _conditions = new List(); @@ -144,6 +143,7 @@ public sealed partial class Symbian offset = sh.files_ptr; currentFile = 0; conditionLevel = 0; + do { Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, false); @@ -163,8 +163,7 @@ public sealed partial class Symbian file.destinationName = file.destinationName.Replace('\\', '/'); - if(file.language != null) - file.destinationName = $"{file.language}/{file.destinationName}"; + if(file.language != null) file.destinationName = $"{file.language}/{file.destinationName}"; filesWithFixedFilenames.Add(file); } @@ -179,8 +178,7 @@ public sealed partial class Symbian _compressed = true; } - if(_files.Any(t => t.mime is not null)) - _features |= ArchiveSupportedFeature.SupportsXAttrs; + if(_files.Any(t => t.mime is not null)) _features |= ArchiveSupportedFeature.SupportsXAttrs; Opened = true; @@ -191,8 +189,7 @@ public sealed partial class Symbian public void Close() { // Already closed - if(!Opened) - return; + if(!Opened) return; _stream?.Close(); diff --git a/Aaru.Archives/Symbian/Parser.cs b/Aaru.Archives/Symbian/Parser.cs index 3c0bae384..185c8b208 100644 --- a/Aaru.Archives/Symbian/Parser.cs +++ b/Aaru.Archives/Symbian/Parser.cs @@ -49,15 +49,16 @@ public sealed partial class Symbian { currentFile++; - if(currentFile > maxFiles) - return; + if(currentFile > maxFiles) return; - var tabulationChars = new char[conditionLevel]; - for(var i = 0; i < conditionLevel; i++) - tabulationChars[i] = '\t'; - string tabulation = new(tabulationChars); + var tabulationChars = new char[conditionLevel]; + for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; + string tabulation = new(tabulationChars); - AaruConsole.DebugWriteLine(MODULE_NAME, "Seeking to {0} for parsing of file {1} of {2}", offset, currentFile, + AaruConsole.DebugWriteLine(MODULE_NAME, + "Seeking to {0} for parsing of file {1} of {2}", + offset, + currentFile, maxFiles); br.BaseStream.Seek(offset, SeekOrigin.Begin); @@ -72,6 +73,7 @@ public sealed partial class Symbian StringBuilder conditionSb; Attribute? nullAttribute; + switch(recordType) { case FileRecordType.SimpleFile: @@ -81,11 +83,9 @@ public sealed partial class Symbian offset = (uint)br.BaseStream.Position; // Remove the 3 fields that exist only on >= ER6 - if(!_release6) - offset -= sizeof(uint) * 3; + if(!_release6) offset -= sizeof(uint) * 3; - if(optionsOnly) - break; + if(optionsOnly) break; var decodedFileRecord = new DecodedFileRecord { @@ -118,8 +118,10 @@ public sealed partial class Symbian decodedFileRecord.mime = _encoding.GetString(buffer); } - AaruConsole.DebugWriteLine(MODULE_NAME, "Found file for \"{0}\" with length {1} at {2}", - decodedFileRecord.destinationName, decodedFileRecord.length, + AaruConsole.DebugWriteLine(MODULE_NAME, + "Found file for \"{0}\" with length {1} at {2}", + decodedFileRecord.destinationName, + decodedFileRecord.length, decodedFileRecord.pointer); _files.Add(decodedFileRecord); @@ -127,10 +129,12 @@ public sealed partial class Symbian if(conditionLevel > 0) { bool wait, close; + switch(decodedFileRecord.type) { case FileType.File: _conditions.Add(tabulation + $"InstallFileTo(\"{decodedFileRecord.destinationName}\")"); + break; case FileType.FileText: switch((FileDetails)((uint)decodedFileRecord.details & 0xFF)) @@ -138,18 +142,22 @@ public sealed partial class Symbian case FileDetails.TextContinue: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecord.sourceName}\", BUTTONS_CONTINUE, ACTION_CONTINUE)"); + break; case FileDetails.TextSkip: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecord.sourceName}\", BUTTONS_YES_NO, ACTION_SKIP)"); + break; case FileDetails.TextAbort: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecord.sourceName}\", BUTTONS_YES_NO, ACTION_ABORT)"); + break; case FileDetails.TextExit: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecord.sourceName}\", BUTTONS_YES_NO, ACTION_EXIT)"); + break; } @@ -158,7 +166,9 @@ public sealed partial class Symbian // ReSharper disable BitwiseOperatorOnEnumWithoutFlags wait = (decodedFileRecord.details & FileDetails.RunWait) != 0; close = (decodedFileRecord.details & FileDetails.RunsEnd) != 0; + // ReSharper restore BitwiseOperatorOnEnumWithoutFlags + switch((FileDetails)((uint)decodedFileRecord.details & 0xFF)) { case FileDetails.RunInstall: @@ -237,7 +247,9 @@ public sealed partial class Symbian // ReSharper disable BitwiseOperatorOnEnumWithoutFlags wait = (decodedFileRecord.details & FileDetails.RunWait) != 0; close = (decodedFileRecord.details & FileDetails.RunsEnd) != 0; + // ReSharper restore BitwiseOperatorOnEnumWithoutFlags + if(wait && close) _conditions.Add(tabulation + $"Open(\"{decodedFileRecord.sourceName}\", WAIT | CLOSE)"); else if(close) @@ -246,6 +258,7 @@ public sealed partial class Symbian _conditions.Add(tabulation + $"Open(\"{decodedFileRecord.sourceName}\", WAIT)"); else _conditions.Add(tabulation + $"Open(\"{decodedFileRecord.sourceName}\", 0)"); + break; } } @@ -270,8 +283,10 @@ public sealed partial class Symbian { buffer = br.ReadBytes(sizeof(uint) * languages.Count); span = buffer; + multipleFileRecord.originalLengths = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); + multipleFileRecord.mimeLen = br.ReadUInt32(); multipleFileRecord.mimePtr = br.ReadUInt32(); } @@ -279,8 +294,8 @@ public sealed partial class Symbian multipleFileRecord.originalLengths = multipleFileRecord.lengths; offset = (uint)br.BaseStream.Position; - if(optionsOnly) - break; + + if(optionsOnly) break; br.BaseStream.Seek(multipleFileRecord.record.sourceNamePtr, SeekOrigin.Begin); buffer = br.ReadBytes((int)multipleFileRecord.record.sourceNameLen); @@ -326,10 +341,12 @@ public sealed partial class Symbian if(conditionLevel > 0) { bool wait, close; + switch(decodedFileRecords[0].type) { case FileType.File: _conditions.Add(tabulation + $"InstallFileTo(\"{decodedFileRecords[0].destinationName}\")"); + break; case FileType.FileText: switch((FileDetails)((uint)decodedFileRecords[0].details & 0xFF)) @@ -337,18 +354,22 @@ public sealed partial class Symbian case FileDetails.TextContinue: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecords[0].sourceName}\", BUTTONS_CONTINUE, ACTION_CONTINUE)"); + break; case FileDetails.TextSkip: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecords[0].sourceName}\", BUTTONS_YES_NO, ACTION_SKIP)"); + break; case FileDetails.TextAbort: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecords[0].sourceName}\", BUTTONS_YES_NO, ACTION_ABORT)"); + break; case FileDetails.TextExit: _conditions.Add(tabulation + $"ShowText(\"{decodedFileRecords[0].sourceName}\", BUTTONS_YES_NO, ACTION_EXIT)"); + break; } @@ -357,7 +378,9 @@ public sealed partial class Symbian // ReSharper disable BitwiseOperatorOnEnumWithoutFlags wait = (decodedFileRecords[0].details & FileDetails.RunWait) != 0; close = (decodedFileRecords[0].details & FileDetails.RunsEnd) != 0; + // ReSharper restore BitwiseOperatorOnEnumWithoutFlags + switch((FileDetails)((uint)decodedFileRecords[0].details & 0xFF)) { case FileDetails.RunInstall: @@ -436,7 +459,9 @@ public sealed partial class Symbian // ReSharper disable BitwiseOperatorOnEnumWithoutFlags wait = (decodedFileRecords[0].details & FileDetails.RunWait) != 0; close = (decodedFileRecords[0].details & FileDetails.RunsEnd) != 0; + // ReSharper restore BitwiseOperatorOnEnumWithoutFlags + if(wait && close) { _conditions.Add(tabulation + @@ -469,11 +494,13 @@ public sealed partial class Symbian buffer = br.ReadBytes(sizeof(uint) * languages.Count); span = buffer; + optionsLineRecord.options[i].lengths = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); buffer = br.ReadBytes(sizeof(uint) * languages.Count); span = buffer; + optionsLineRecord.options[i].pointers = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); @@ -490,18 +517,17 @@ public sealed partial class Symbian br.BaseStream.Seek(offset, SeekOrigin.Begin); - if(optionsOnly) - _options.Add(optionsLineRecord.options[i]); + if(optionsOnly) _options.Add(optionsLineRecord.options[i]); } offset = (uint)br.BaseStream.Position; + break; case FileRecordType.If: conditionLevel--; tabulationChars = new char[conditionLevel]; - for(var i = 0; i < conditionLevel; i++) - tabulationChars[i] = '\t'; + for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; tabulation = new string(tabulationChars); conditionalRecord = new ConditionalRecord @@ -512,8 +538,7 @@ public sealed partial class Symbian offset = (uint)(br.BaseStream.Position + conditionalRecord.length); - if(optionsOnly) - break; + if(optionsOnly) break; conditionSb = new StringBuilder(); nullAttribute = null; @@ -527,8 +552,7 @@ public sealed partial class Symbian break; case FileRecordType.ElseIf: tabulationChars = new char[conditionLevel - 1]; - for(var i = 0; i < conditionLevel - 1; i++) - tabulationChars[i] = '\t'; + for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; tabulation = new string(tabulationChars); conditionalRecord = new ConditionalRecord @@ -539,8 +563,7 @@ public sealed partial class Symbian offset = (uint)(br.BaseStream.Position + conditionalRecord.length); - if(optionsOnly) - break; + if(optionsOnly) break; conditionSb = new StringBuilder(); nullAttribute = null; @@ -554,14 +577,12 @@ public sealed partial class Symbian break; case FileRecordType.Else: tabulationChars = new char[conditionLevel - 1]; - for(var i = 0; i < conditionLevel - 1; i++) - tabulationChars[i] = '\t'; + for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; tabulation = new string(tabulationChars); offset = (uint)(br.BaseStream.Position + Marshal.SizeOf()); - if(optionsOnly) - break; + if(optionsOnly) break; _conditions.Add(tabulation + "else"); @@ -570,8 +591,7 @@ public sealed partial class Symbian conditionLevel++; offset = (uint)(br.BaseStream.Position + Marshal.SizeOf()); - if(optionsOnly) - break; + if(optionsOnly) break; _conditions.Add(tabulation + "endif()" + Environment.NewLine); diff --git a/Aaru.Archives/Symbian/Structs.cs b/Aaru.Archives/Symbian/Structs.cs index 0f988c05a..2dc4d61b9 100644 --- a/Aaru.Archives/Symbian/Structs.cs +++ b/Aaru.Archives/Symbian/Structs.cs @@ -542,6 +542,7 @@ public sealed partial class Symbian /// Pointer to component name record /// public uint comp_ptr; + // From EPOC Release 6 /// /// Pointer to signature record diff --git a/Aaru.Archives/Symbian/Symbian.cs b/Aaru.Archives/Symbian/Symbian.cs index 8bc926a54..735024121 100644 --- a/Aaru.Archives/Symbian/Symbian.cs +++ b/Aaru.Archives/Symbian/Symbian.cs @@ -62,13 +62,12 @@ public sealed partial class Symbian : IArchive public Guid Id => new("0EC84EC7-EAE6-4196-83FE-943B3FE48DBD"); /// - public ArchiveSupportedFeature ArchiveFeatures => - !Opened - ? ArchiveSupportedFeature.SupportsFilenames | - ArchiveSupportedFeature.SupportsCompression | - ArchiveSupportedFeature.SupportsSubdirectories | - ArchiveSupportedFeature.SupportsXAttrs - : _features; + public ArchiveSupportedFeature ArchiveFeatures => !Opened + ? ArchiveSupportedFeature.SupportsFilenames | + ArchiveSupportedFeature.SupportsCompression | + ArchiveSupportedFeature.SupportsSubdirectories | + ArchiveSupportedFeature.SupportsXAttrs + : _features; #endregion } \ No newline at end of file diff --git a/Aaru.Archives/Symbian/UID.cs b/Aaru.Archives/Symbian/UID.cs index 6755fa31a..f00a98d0a 100644 --- a/Aaru.Archives/Symbian/UID.cs +++ b/Aaru.Archives/Symbian/UID.cs @@ -34,192 +34,196 @@ namespace Aaru.Archives; public sealed partial class Symbian { - static string DecodePlatformUid(uint uid) => - uid switch - { - 0x101F61CE => Localization.SIS_Platform_UID_UIQ_21, - 0x101F6300 => Localization.SIS_Platform_UID_UIQ_30, - 0x101F6F87 => Localization.SIS_Platform_UID_Nokia_7650, - 0x101F6F88 => Localization.SIS_Platform_UID_Series_60_1st_Edition, - 0x101F795F => Localization.SIS_Platform_UID_Series_60_v1_0, - 0x101F7960 => Localization.SIS_Platform_UID_Series_60_2nd_Edition, - 0x101F7961 => Localization.SIS_Platform_UID_Series_60_3rd_Edition, - 0x101F7962 => Localization.SIS_Platform_UID_Nokia_3650, - 0x101F7963 => Localization.SIS_Platform_UID_Nokia_6600, - 0x101F7964 => Localization.SIS_Platform_UID_Nokia_6630, - 0x101F80BE => Localization.SIS_Platform_UID_SonyEricsson_P80x, - 0x101F8201 => Localization.SIS_Platform_UID_Series_60_v1_1, - 0x101F8202 => Localization.SIS_Platform_UID_Series_60_1st_Edition_Feature_Pack_1, - 0x101F8A64 => Localization.SIS_Platform_UID_Nokia_N_Gage, - 0x101F8DDB => Localization.SIS_Platform_UID_Nokia_9500, - 0x101F8ED1 => Localization.SIS_Platform_UID_Nokia_9300, - 0x101F8ED2 => Localization.SIS_Platform_UID_Series_80_2nd_edition, - 0x101F9071 => Localization.SIS_Platform_UID_Siemens_SX1, - 0x101F9115 => Localization.SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_1, - 0x101FB3F4 => Localization.SIS_Platform_UID_Nokia_6260, - 0x101FBB35 => Localization.SIS_Platform_UID_SonyEricsson_P90x, - 0x101FBE05 => Localization.SIS_Platform_UID_Nokia_7710_Series_90, - 0x101FD5DB => Localization.SIS_Platform_UID_Nokia_7610, - 0x101FD5DC => Localization.SIS_Platform_UID_Nokia_6670, - 0x101f617b => Localization.SIS_Platform_UID_UIQ_20, - 0x10200BAB => Localization.SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_2, - 0x10200F97 => Localization.SIS_Platform_UID_Nokia_3230, - 0x10200F98 => Localization.SIS_Platform_UID_Nokia_N90, - 0x10200F9A => Localization.SIS_Platform_UID_Nokia_N70, - 0x10200f99 => Localization.SIS_Platform_UID_Nokia_6680, - 0x1020216B => Localization.SIS_Platform_UID_Nokia_6620, - 0x102032BD => Localization.SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_3, - 0x102032BE => Localization.SIS_Platform_UID_Series_60_3rd_Edition_Feature_Pack_1, - 0x102078CF => Localization.SIS_Platform_UID_Nokia_6682, - 0x102078D0 => Localization.SIS_Platform_UID_Nokia_6681, - 0x102752AE => Localization.SIS_Platform_UID_Series_60_3rd_Edition_Feature_Pack_2, - 0x1028315F => Localization.SIS_Platform_UID_Series_60_5th_Edition, - 0x200005F8 => Localization.SIS_Platform_UID_Nokia_3250, - 0x200005F9 => Localization.SIS_Platform_UID_Nokia_N80, - 0x200005FA => Localization.SIS_Platform_UID_Nokia_N92, - 0x200005FB => Localization.SIS_Platform_UID_Nokia_N73, - 0x200005FC => Localization.SIS_Platform_UID_Nokia_N91, - 0x200005FF => Localization.SIS_Platform_UID_Nokia_N71, - 0x20001856 => Localization.SIS_Platform_UID_Nokia_E60, - 0x20001857 => Localization.SIS_Platform_UID_Nokia_E70, - 0x20001858 => Localization.SIS_Platform_UID_Nokia_E61, - 0x20022E6D => Localization.SIS_Platform_UID_Symbian_3, - 0x2003A678 => Localization.SIS_Platform_UID_Nokia_Belle, - _ => string.Format(Localization.SIS_Platform_UID_0, uid) - }; + static string DecodePlatformUid(uint uid) => uid switch + { + 0x101F61CE => Localization.SIS_Platform_UID_UIQ_21, + 0x101F6300 => Localization.SIS_Platform_UID_UIQ_30, + 0x101F6F87 => Localization.SIS_Platform_UID_Nokia_7650, + 0x101F6F88 => Localization.SIS_Platform_UID_Series_60_1st_Edition, + 0x101F795F => Localization.SIS_Platform_UID_Series_60_v1_0, + 0x101F7960 => Localization.SIS_Platform_UID_Series_60_2nd_Edition, + 0x101F7961 => Localization.SIS_Platform_UID_Series_60_3rd_Edition, + 0x101F7962 => Localization.SIS_Platform_UID_Nokia_3650, + 0x101F7963 => Localization.SIS_Platform_UID_Nokia_6600, + 0x101F7964 => Localization.SIS_Platform_UID_Nokia_6630, + 0x101F80BE => Localization.SIS_Platform_UID_SonyEricsson_P80x, + 0x101F8201 => Localization.SIS_Platform_UID_Series_60_v1_1, + 0x101F8202 => Localization + .SIS_Platform_UID_Series_60_1st_Edition_Feature_Pack_1, + 0x101F8A64 => Localization.SIS_Platform_UID_Nokia_N_Gage, + 0x101F8DDB => Localization.SIS_Platform_UID_Nokia_9500, + 0x101F8ED1 => Localization.SIS_Platform_UID_Nokia_9300, + 0x101F8ED2 => Localization.SIS_Platform_UID_Series_80_2nd_edition, + 0x101F9071 => Localization.SIS_Platform_UID_Siemens_SX1, + 0x101F9115 => Localization + .SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_1, + 0x101FB3F4 => Localization.SIS_Platform_UID_Nokia_6260, + 0x101FBB35 => Localization.SIS_Platform_UID_SonyEricsson_P90x, + 0x101FBE05 => Localization.SIS_Platform_UID_Nokia_7710_Series_90, + 0x101FD5DB => Localization.SIS_Platform_UID_Nokia_7610, + 0x101FD5DC => Localization.SIS_Platform_UID_Nokia_6670, + 0x101f617b => Localization.SIS_Platform_UID_UIQ_20, + 0x10200BAB => Localization + .SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_2, + 0x10200F97 => Localization.SIS_Platform_UID_Nokia_3230, + 0x10200F98 => Localization.SIS_Platform_UID_Nokia_N90, + 0x10200F9A => Localization.SIS_Platform_UID_Nokia_N70, + 0x10200f99 => Localization.SIS_Platform_UID_Nokia_6680, + 0x1020216B => Localization.SIS_Platform_UID_Nokia_6620, + 0x102032BD => Localization + .SIS_Platform_UID_Series_60_2nd_Edition_Feature_Pack_3, + 0x102032BE => Localization + .SIS_Platform_UID_Series_60_3rd_Edition_Feature_Pack_1, + 0x102078CF => Localization.SIS_Platform_UID_Nokia_6682, + 0x102078D0 => Localization.SIS_Platform_UID_Nokia_6681, + 0x102752AE => Localization + .SIS_Platform_UID_Series_60_3rd_Edition_Feature_Pack_2, + 0x1028315F => Localization.SIS_Platform_UID_Series_60_5th_Edition, + 0x200005F8 => Localization.SIS_Platform_UID_Nokia_3250, + 0x200005F9 => Localization.SIS_Platform_UID_Nokia_N80, + 0x200005FA => Localization.SIS_Platform_UID_Nokia_N92, + 0x200005FB => Localization.SIS_Platform_UID_Nokia_N73, + 0x200005FC => Localization.SIS_Platform_UID_Nokia_N91, + 0x200005FF => Localization.SIS_Platform_UID_Nokia_N71, + 0x20001856 => Localization.SIS_Platform_UID_Nokia_E60, + 0x20001857 => Localization.SIS_Platform_UID_Nokia_E70, + 0x20001858 => Localization.SIS_Platform_UID_Nokia_E61, + 0x20022E6D => Localization.SIS_Platform_UID_Symbian_3, + 0x2003A678 => Localization.SIS_Platform_UID_Nokia_Belle, + _ => string.Format(Localization.SIS_Platform_UID_0, uid) + }; - static string DecodeMachineUid(uint uid) => - uid switch - { - 0x200005f8 => "UID_NOKIA_3250", - 0x20024104 => "UID_NOKIA_5228", - 0x20023763 => "UID_NOKIA_5230", - 0x20023764 => "UID_NOKIA_5230a", - 0x2002376b => "UID_NOKIA_5230_NURON", - 0x20024105 => "UID_NOKIA_5235", - 0x2002bf93 => "UID_NOKIA_5250", - 0x2000da5a => "UID_NOKIA_5320", - 0x20000602 => "UID_NOKIA_5500", - 0x2001de9d => "UID_NOKIA_5530", - 0x2001de9e => "UID_NOKIA_5530_chinese", - 0x2000da61 => "UID_NOKIA_5630", - 0x20002d7c => "UID_NOKIA_5700", - 0x20014dd3 => "UID_NOKIA_5730", - 0x2000da56 => "UID_NOKIA_5800", - 0x20002d7b => "UID_NOKIA_6110", - 0x20002d7e => "UID_NOKIA_6120", - 0x2000da55 => "UID_NOKIA_6124", - 0x2000da54 => "UID_NOKIA_6210", - 0x2000da52 => "UID_NOKIA_6220", - 0x2000da53 => "UID_NOKIA_6220_cn", - 0x20000606 => "UID_NOKIA_6290", - 0x2000da57 => "UID_NOKIA_6650", - 0x2001de9b => "UID_NOKIA_6700", - 0x20014dd1 => "UID_NOKIA_6710", - 0x20014dcd => "UID_NOKIA_6720", - 0x2001de9a => "UID_NOKIA_6730", - 0x200227e2 => "UID_NOKIA_6760", - 0x200227e6 => "UID_NOKIA_6788", - 0x2001de98 => "UID_NOKIA_6790", - 0x20024107 => "UID_NOKIA_C5_00", - 0x20029a75 => "UID_NOKIA_C5_01", - 0x2002bf91 => "UID_NOKIA_C6_00", - 0x2002376a => "UID_NOKIA_C6_01", - 0x2002bf92 => "UID_NOKIA_C7_00", - 0x20002495 => "UID_NOKIA_E50", - 0x20002498 => "UID_NOKIA_E51", - 0x20014dcc => "UID_NOKIA_E52", - 0x20014dcf => "UID_NOKIA_E55", - 0x20001856 => "UID_NOKIA_E60", - 0x20001858 => "UID_NOKIA_E61", - 0x20002d7f => "UID_NOKIA_E61i", - 0x20001859 => "UID_NOKIA_E62", - 0x200025c3 => "UID_NOKIA_E63", - 0x20000604 => "UID_NOKIA_E65", - 0x2000249c => "UID_NOKIA_E66", - 0x2002bf96 => "UID_NOKIA_E7_00", - 0x20001857 => "UID_NOKIA_E70", - 0x2000249b => "UID_NOKIA_E71", - 0x20014dd8 => "UID_NOKIA_E71x", - 0x20014dd0 => "UID_NOKIA_E72", - 0x20029a6d => "UID_NOKIA_E73", - 0x2000249d => "UID_NOKIA_E75", - 0x20002496 => "UID_NOKIA_E90", - 0x20024100 => "UID_NOKIA_E5_00", - 0x10200f9a => "UID_NOKIA_N70", - 0x200005ff => "UID_NOKIA_N71", - 0x200005fb => "UID_NOKIA_N73", - 0x200005fe => "UID_NOKIA_N75", - 0x2000060a => "UID_NOKIA_N76", - 0x20000601 => "UID_NOKIA_N77", - 0x20002d81 => "UID_NOKIA_N78", - 0x2000da64 => "UID_NOKIA_N79", - 0x20029a73 => "UID_NOKIA_N8_00", - 0x200005f9 => "UID_NOKIA_N80", - 0x20002d83 => "UID_NOKIA_N81", - 0x20002d85 => "UID_NOKIA_N82", - 0x20002d86 => "UID_NOKIA_N85", - 0x20014dd2 => "UID_NOKIA_N86", - 0x200005fc => "UID_NOKIA_N91", - 0x200005fa => "UID_NOKIA_N92", - 0x20000600 => "UID_NOKIA_N93", - 0x20000605 => "UID_NOKIA_N93i", - 0x2000060b => "UID_NOKIA_N95", - 0x20002d84 => "UID_NOKIA_N95_8GB", - 0x20002d82 => "UID_NOKIA_N96", - 0x20014ddd => "UID_NOKIA_N97", - 0x20014dde => "UID_NOKIA_N97a", - 0x20023766 => "UID_NOKIA_N97_mini", - 0x20029a76 => "UID_NOKIA_X5_00", - 0x20024101 => "UID_NOKIA_X5_01", - 0x200227dd => "UID_NOKIA_X6", - 0x20008610 => "UID_SAMSUNG_I400", - 0x2000a677 => "UID_SAMSUNG_I450", - 0x20003abd => "UID_SAMSUNG_I520", - 0x2000a678 => "UID_SAMSUNG_I550", - 0x2000c51c => "UID_SAMSUNG_I560", - 0x2000a679 => "UID_SAMSUNG_I590", - 0x2000c51f => "UID_SAMSUNG_I7110", - 0x2000c51e => "UID_SAMSUNG_I8510", - 0x2000c520 => "UID_SAMSUNG_I8910", - 0x2001f0a1 => "UID_SONYERICSSON_SATIO", - 0x10274bf9 => "UID_SONYERICSSON_M600", - 0x10274bfa => "UID_SONYERICSSON_W950", - 0x20002e6a => "UID_SONYERICSSON_W960", - 0x1020e285 => "UID_SONYERICSSON_P990", - 0x20002e69 => "UID_SONYERICSSON_P1", - 0x2000cc70 => "UID_SONYERICSSON_G700", - 0x2000cc6c => "UID_SONYERICSSON_G900", - 0x20024eec => "UID_SONYERICSSON_VIVAZ_U5i", - 0x20024eed => "UID_SONYERICSSON_VIVAZ_U8", - 0x1027400d => "UID_MOTOROLA_Z8", - 0x101ff809 => "UID_LG_KT610", - 0x10200f97 => "UID_NOKIA_3230", - 0x101f466a => "UID_NOKIA_3650", - 0x101f8c19 => "UID_NOKIA_NGAGE", - 0x101fb2b1 => "UID_NOKIA_NGAGE_QD", - 0x101fb3f4 => "UID_NOKIA_6260", - 0x101fb3dd => "UID_NOKIA_6600", - 0x101f3ee3 => "UID_NOKIA_6620", - 0x101fbb55 => "UID_NOKIA_6630", - 0x101fb3f3 => "UID_NOKIA_6670", - 0x10200f99 => "UID_NOKIA_6680", - 0x10200f9c => "UID_NOKIA_6681", - 0x10200f9b => "UID_NOKIA_6682", - 0x101f4fc3 => "UID_NOKIA_7650", - 0x10005e33 => "UID_NOKIA_92XX", - 0x101f8ddb => "UID_NOKIA_9x00", - 0x1020e048 => "UID_NOKIA_9300i", - 0x10200f98 => "UID_NOKIA_N90", - 0x101fbe09 => "UID_NOKIA_7710", - 0x101fa031 => "UID_SENDO_X", - 0x101f9071 => "UID_SIEMENS_SX1", - 0x101fe7b7 => "SAMSUNG_SGH_D730", - 0x101f408b => "UID_SONYERICSSON_P800", - 0x101fb2ae => "UID_SONYERICSSON_P900", - 0x10200ac6 => "UID_SONYERICSSON_P910", - 0x101f6b26 => "UID_MOTOROLA_A9XX", - 0x101f6b27 => "UID_MOTOROLA_A1000", - _ => $"{uid:X8}" - }; + static string DecodeMachineUid(uint uid) => uid switch + { + 0x200005f8 => "UID_NOKIA_3250", + 0x20024104 => "UID_NOKIA_5228", + 0x20023763 => "UID_NOKIA_5230", + 0x20023764 => "UID_NOKIA_5230a", + 0x2002376b => "UID_NOKIA_5230_NURON", + 0x20024105 => "UID_NOKIA_5235", + 0x2002bf93 => "UID_NOKIA_5250", + 0x2000da5a => "UID_NOKIA_5320", + 0x20000602 => "UID_NOKIA_5500", + 0x2001de9d => "UID_NOKIA_5530", + 0x2001de9e => "UID_NOKIA_5530_chinese", + 0x2000da61 => "UID_NOKIA_5630", + 0x20002d7c => "UID_NOKIA_5700", + 0x20014dd3 => "UID_NOKIA_5730", + 0x2000da56 => "UID_NOKIA_5800", + 0x20002d7b => "UID_NOKIA_6110", + 0x20002d7e => "UID_NOKIA_6120", + 0x2000da55 => "UID_NOKIA_6124", + 0x2000da54 => "UID_NOKIA_6210", + 0x2000da52 => "UID_NOKIA_6220", + 0x2000da53 => "UID_NOKIA_6220_cn", + 0x20000606 => "UID_NOKIA_6290", + 0x2000da57 => "UID_NOKIA_6650", + 0x2001de9b => "UID_NOKIA_6700", + 0x20014dd1 => "UID_NOKIA_6710", + 0x20014dcd => "UID_NOKIA_6720", + 0x2001de9a => "UID_NOKIA_6730", + 0x200227e2 => "UID_NOKIA_6760", + 0x200227e6 => "UID_NOKIA_6788", + 0x2001de98 => "UID_NOKIA_6790", + 0x20024107 => "UID_NOKIA_C5_00", + 0x20029a75 => "UID_NOKIA_C5_01", + 0x2002bf91 => "UID_NOKIA_C6_00", + 0x2002376a => "UID_NOKIA_C6_01", + 0x2002bf92 => "UID_NOKIA_C7_00", + 0x20002495 => "UID_NOKIA_E50", + 0x20002498 => "UID_NOKIA_E51", + 0x20014dcc => "UID_NOKIA_E52", + 0x20014dcf => "UID_NOKIA_E55", + 0x20001856 => "UID_NOKIA_E60", + 0x20001858 => "UID_NOKIA_E61", + 0x20002d7f => "UID_NOKIA_E61i", + 0x20001859 => "UID_NOKIA_E62", + 0x200025c3 => "UID_NOKIA_E63", + 0x20000604 => "UID_NOKIA_E65", + 0x2000249c => "UID_NOKIA_E66", + 0x2002bf96 => "UID_NOKIA_E7_00", + 0x20001857 => "UID_NOKIA_E70", + 0x2000249b => "UID_NOKIA_E71", + 0x20014dd8 => "UID_NOKIA_E71x", + 0x20014dd0 => "UID_NOKIA_E72", + 0x20029a6d => "UID_NOKIA_E73", + 0x2000249d => "UID_NOKIA_E75", + 0x20002496 => "UID_NOKIA_E90", + 0x20024100 => "UID_NOKIA_E5_00", + 0x10200f9a => "UID_NOKIA_N70", + 0x200005ff => "UID_NOKIA_N71", + 0x200005fb => "UID_NOKIA_N73", + 0x200005fe => "UID_NOKIA_N75", + 0x2000060a => "UID_NOKIA_N76", + 0x20000601 => "UID_NOKIA_N77", + 0x20002d81 => "UID_NOKIA_N78", + 0x2000da64 => "UID_NOKIA_N79", + 0x20029a73 => "UID_NOKIA_N8_00", + 0x200005f9 => "UID_NOKIA_N80", + 0x20002d83 => "UID_NOKIA_N81", + 0x20002d85 => "UID_NOKIA_N82", + 0x20002d86 => "UID_NOKIA_N85", + 0x20014dd2 => "UID_NOKIA_N86", + 0x200005fc => "UID_NOKIA_N91", + 0x200005fa => "UID_NOKIA_N92", + 0x20000600 => "UID_NOKIA_N93", + 0x20000605 => "UID_NOKIA_N93i", + 0x2000060b => "UID_NOKIA_N95", + 0x20002d84 => "UID_NOKIA_N95_8GB", + 0x20002d82 => "UID_NOKIA_N96", + 0x20014ddd => "UID_NOKIA_N97", + 0x20014dde => "UID_NOKIA_N97a", + 0x20023766 => "UID_NOKIA_N97_mini", + 0x20029a76 => "UID_NOKIA_X5_00", + 0x20024101 => "UID_NOKIA_X5_01", + 0x200227dd => "UID_NOKIA_X6", + 0x20008610 => "UID_SAMSUNG_I400", + 0x2000a677 => "UID_SAMSUNG_I450", + 0x20003abd => "UID_SAMSUNG_I520", + 0x2000a678 => "UID_SAMSUNG_I550", + 0x2000c51c => "UID_SAMSUNG_I560", + 0x2000a679 => "UID_SAMSUNG_I590", + 0x2000c51f => "UID_SAMSUNG_I7110", + 0x2000c51e => "UID_SAMSUNG_I8510", + 0x2000c520 => "UID_SAMSUNG_I8910", + 0x2001f0a1 => "UID_SONYERICSSON_SATIO", + 0x10274bf9 => "UID_SONYERICSSON_M600", + 0x10274bfa => "UID_SONYERICSSON_W950", + 0x20002e6a => "UID_SONYERICSSON_W960", + 0x1020e285 => "UID_SONYERICSSON_P990", + 0x20002e69 => "UID_SONYERICSSON_P1", + 0x2000cc70 => "UID_SONYERICSSON_G700", + 0x2000cc6c => "UID_SONYERICSSON_G900", + 0x20024eec => "UID_SONYERICSSON_VIVAZ_U5i", + 0x20024eed => "UID_SONYERICSSON_VIVAZ_U8", + 0x1027400d => "UID_MOTOROLA_Z8", + 0x101ff809 => "UID_LG_KT610", + 0x10200f97 => "UID_NOKIA_3230", + 0x101f466a => "UID_NOKIA_3650", + 0x101f8c19 => "UID_NOKIA_NGAGE", + 0x101fb2b1 => "UID_NOKIA_NGAGE_QD", + 0x101fb3f4 => "UID_NOKIA_6260", + 0x101fb3dd => "UID_NOKIA_6600", + 0x101f3ee3 => "UID_NOKIA_6620", + 0x101fbb55 => "UID_NOKIA_6630", + 0x101fb3f3 => "UID_NOKIA_6670", + 0x10200f99 => "UID_NOKIA_6680", + 0x10200f9c => "UID_NOKIA_6681", + 0x10200f9b => "UID_NOKIA_6682", + 0x101f4fc3 => "UID_NOKIA_7650", + 0x10005e33 => "UID_NOKIA_92XX", + 0x101f8ddb => "UID_NOKIA_9x00", + 0x1020e048 => "UID_NOKIA_9300i", + 0x10200f98 => "UID_NOKIA_N90", + 0x101fbe09 => "UID_NOKIA_7710", + 0x101fa031 => "UID_SENDO_X", + 0x101f9071 => "UID_SIEMENS_SX1", + 0x101fe7b7 => "SAMSUNG_SGH_D730", + 0x101f408b => "UID_SONYERICSSON_P800", + 0x101fb2ae => "UID_SONYERICSSON_P900", + 0x10200ac6 => "UID_SONYERICSSON_P910", + 0x101f6b26 => "UID_MOTOROLA_A9XX", + 0x101f6b27 => "UID_MOTOROLA_A1000", + _ => $"{uid:X8}" + }; } \ No newline at end of file diff --git a/Aaru.Archives/Symbian/Xattrs.cs b/Aaru.Archives/Symbian/Xattrs.cs index c76ac6207..4efc570d1 100644 --- a/Aaru.Archives/Symbian/Xattrs.cs +++ b/Aaru.Archives/Symbian/Xattrs.cs @@ -45,16 +45,13 @@ public sealed partial class Symbian { xattrs = null; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; xattrs = new List(); - if(_files[entryNumber].mime is not null) - xattrs.Add("org.iana.mime_type"); + if(_files[entryNumber].mime is not null) xattrs.Add("org.iana.mime_type"); return ErrorNumber.NoError; } @@ -64,11 +61,9 @@ public sealed partial class Symbian { buffer = null; - if(!Opened) - return ErrorNumber.NotOpened; + if(!Opened) return ErrorNumber.NotOpened; - if(entryNumber < 0 || entryNumber >= _files.Count) - return ErrorNumber.OutOfRange; + if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange; if(xattr != "org.iana.mime_type" || _files[entryNumber].mime is null) return ErrorNumber.NoSuchExtendedAttribute; diff --git a/Aaru.Checksums/Adler32/neon.cs b/Aaru.Checksums/Adler32/neon.cs index d25064403..0d6dfc27e 100644 --- a/Aaru.Checksums/Adler32/neon.cs +++ b/Aaru.Checksums/Adler32/neon.cs @@ -73,8 +73,7 @@ static class Neon { uint n = Adler32Context.NMAX / blockSize; /* The NMAX constraint. */ - if(n > blocks) - n = blocks; + if(n > blocks) n = blocks; blocks -= n; /* @@ -93,17 +92,41 @@ static class Neon /* * Load 32 input bytes. */ - var bytes1 = Vector128.Create(buf[bufPos], buf[bufPos + 1], buf[bufPos + 2], buf[bufPos + 3], - buf[bufPos + 4], buf[bufPos + 5], buf[bufPos + 6], buf[bufPos + 7], - buf[bufPos + 8], buf[bufPos + 9], buf[bufPos + 10], buf[bufPos + 11], - buf[bufPos + 12], buf[bufPos + 13], buf[bufPos + 14], buf[bufPos + 15]); + var bytes1 = Vector128.Create(buf[bufPos], + buf[bufPos + 1], + buf[bufPos + 2], + buf[bufPos + 3], + buf[bufPos + 4], + buf[bufPos + 5], + buf[bufPos + 6], + buf[bufPos + 7], + buf[bufPos + 8], + buf[bufPos + 9], + buf[bufPos + 10], + buf[bufPos + 11], + buf[bufPos + 12], + buf[bufPos + 13], + buf[bufPos + 14], + buf[bufPos + 15]); bufPos += 16; - var bytes2 = Vector128.Create(buf[bufPos], buf[bufPos + 1], buf[bufPos + 2], buf[bufPos + 3], - buf[bufPos + 4], buf[bufPos + 5], buf[bufPos + 6], buf[bufPos + 7], - buf[bufPos + 8], buf[bufPos + 9], buf[bufPos + 10], buf[bufPos + 11], - buf[bufPos + 12], buf[bufPos + 13], buf[bufPos + 14], buf[bufPos + 15]); + var bytes2 = Vector128.Create(buf[bufPos], + buf[bufPos + 1], + buf[bufPos + 2], + buf[bufPos + 3], + buf[bufPos + 4], + buf[bufPos + 5], + buf[bufPos + 6], + buf[bufPos + 7], + buf[bufPos + 8], + buf[bufPos + 9], + buf[bufPos + 10], + buf[bufPos + 11], + buf[bufPos + 12], + buf[bufPos + 13], + buf[bufPos + 14], + buf[bufPos + 15]); bufPos += 16; /* @@ -114,11 +137,11 @@ static class Neon /* * Horizontally add the bytes for s1. */ - vS1 = - AdvSimd.AddPairwiseWideningAndAdd(vS1, - AdvSimd. - AddPairwiseWideningAndAdd(AdvSimd.AddPairwiseWidening(bytes1), - bytes2)); + vS1 = AdvSimd.AddPairwiseWideningAndAdd(vS1, + AdvSimd + .AddPairwiseWideningAndAdd(AdvSimd + .AddPairwiseWidening(bytes1), + bytes2)); /* * Vertically add the bytes for s2. @@ -134,22 +157,28 @@ static class Neon /* * Multiply-add bytes by [ 32, 31, 30, ... ] for s2. */ - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum1.GetLower(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum1.GetLower(), Vector64.Create((ushort)32, 31, 30, 29)); - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum1.GetUpper(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum1.GetUpper(), Vector64.Create((ushort)28, 27, 26, 25)); - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum2.GetLower(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum2.GetLower(), Vector64.Create((ushort)24, 23, 22, 21)); - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum2.GetUpper(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum2.GetUpper(), Vector64.Create((ushort)20, 19, 18, 17)); - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum3.GetLower(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum3.GetLower(), Vector64.Create((ushort)16, 15, 14, 13)); - vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum3.GetUpper(), + vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, + vColumnSum3.GetUpper(), Vector64.Create((ushort)12, 11, 10, 9)); vS2 = AdvSimd.MultiplyWideningLowerAndAdd(vS2, vColumnSum4.GetLower(), Vector64.Create((ushort)8, 7, 6, 5)); @@ -197,11 +226,9 @@ static class Neon len -= 16; } - while(len-- != 0) - s2 += s1 += buf[bufPos++]; + while(len-- != 0) s2 += s1 += buf[bufPos++]; - if(s1 >= Adler32Context.ADLER_MODULE) - s1 -= Adler32Context.ADLER_MODULE; + if(s1 >= Adler32Context.ADLER_MODULE) s1 -= Adler32Context.ADLER_MODULE; s2 %= Adler32Context.ADLER_MODULE; } diff --git a/Aaru.Checksums/Adler32/ssse3.cs b/Aaru.Checksums/Adler32/ssse3.cs index 9490ea972..49a60da8b 100644 --- a/Aaru.Checksums/Adler32/ssse3.cs +++ b/Aaru.Checksums/Adler32/ssse3.cs @@ -70,13 +70,12 @@ static class Ssse3 { uint n = Adler32Context.NMAX / blockSize; /* The NMAX constraint. */ - if(n > blocks) - n = blocks; + if(n > blocks) n = blocks; blocks -= n; - Vector128 tap1 = Vector128.Create(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17). - AsByte(); + Vector128 tap1 = Vector128.Create(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17) + .AsByte(); Vector128 tap2 = Vector128.Create(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1).AsByte(); Vector128 zero = Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).AsByte(); @@ -173,11 +172,9 @@ static class Ssse3 len -= 16; } - while(len-- != 0) - s2 += s1 += buf[bufPos++]; + while(len-- != 0) s2 += s1 += buf[bufPos++]; - if(s1 >= Adler32Context.ADLER_MODULE) - s1 -= Adler32Context.ADLER_MODULE; + if(s1 >= Adler32Context.ADLER_MODULE) s1 -= Adler32Context.ADLER_MODULE; s2 %= Adler32Context.ADLER_MODULE; } diff --git a/Aaru.Checksums/Adler32Context.cs b/Aaru.Checksums/Adler32Context.cs index 2fe11c355..d724f1b4c 100644 --- a/Aaru.Checksums/Adler32Context.cs +++ b/Aaru.Checksums/Adler32Context.cs @@ -66,8 +66,7 @@ public sealed class Adler32Context : IChecksum _sum1 = 1; _sum2 = 0; - if(!Native.IsSupported) - return; + if(!Native.IsSupported) return; _nativeContext = adler32_init(); _useNative = _nativeContext != IntPtr.Zero; @@ -101,8 +100,7 @@ public sealed class Adler32Context : IChecksum { var finalSum = (uint)(_sum2 << 16 | _sum1); - if(!_useNative) - return BigEndianBitConverter.GetBytes(finalSum); + if(!_useNative) return BigEndianBitConverter.GetBytes(finalSum); adler32_final(_nativeContext, ref finalSum); adler32_free(_nativeContext); @@ -179,13 +177,11 @@ public sealed class Adler32Context : IChecksum { sum1 += data[dataOff]; - if(sum1 >= ADLER_MODULE) - sum1 -= ADLER_MODULE; + if(sum1 >= ADLER_MODULE) sum1 -= ADLER_MODULE; sum2 += sum1; - if(sum2 >= ADLER_MODULE) - sum2 -= ADLER_MODULE; + if(sum2 >= ADLER_MODULE) sum2 -= ADLER_MODULE; preSum1 = (ushort)(sum1 & 0xFFFF); preSum2 = (ushort)(sum2 & 0xFFFF); @@ -201,8 +197,7 @@ public sealed class Adler32Context : IChecksum sum2 += sum1; } - if(sum1 >= ADLER_MODULE) - sum1 -= ADLER_MODULE; + if(sum1 >= ADLER_MODULE) sum1 -= ADLER_MODULE; sum2 %= ADLER_MODULE; /* only added so many ADLER_MODULE's */ preSum1 = (ushort)(sum1 & 0xFFFF); @@ -339,8 +334,7 @@ public sealed class Adler32Context : IChecksum { nativeContext = adler32_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } var fileStream = new FileStream(filename, FileMode.Open); @@ -369,8 +363,7 @@ public sealed class Adler32Context : IChecksum var adlerOutput = new StringBuilder(); - foreach(byte h in hash) - adlerOutput.Append(h.ToString("x2")); + foreach(byte h in hash) adlerOutput.Append(h.ToString("x2")); fileStream.Close(); @@ -390,8 +383,7 @@ public sealed class Adler32Context : IChecksum { nativeContext = adler32_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } ushort localSum1 = 1; @@ -411,8 +403,7 @@ public sealed class Adler32Context : IChecksum var adlerOutput = new StringBuilder(); - foreach(byte h in hash) - adlerOutput.Append(h.ToString("x2")); + foreach(byte h in hash) adlerOutput.Append(h.ToString("x2")); return adlerOutput.ToString(); } diff --git a/Aaru.Checksums/CDChecksums.cs b/Aaru.Checksums/CDChecksums.cs index 6772f9061..1920749df 100644 --- a/Aaru.Checksums/CDChecksums.cs +++ b/Aaru.Checksums/CDChecksums.cs @@ -93,8 +93,7 @@ public static class CdChecksums bool? subchannelStatus = CheckCdSectorSubChannel(subchannel); bool? status = null; - if(channelStatus == false || subchannelStatus == false) - status = false; + if(channelStatus == false || subchannelStatus == false) status = false; status = channelStatus switch { @@ -126,8 +125,7 @@ public static class CdChecksums _eccFTable[i] = (byte)j; _eccBTable[i ^ j] = (byte)i; - for(j = 0; j < 8; j++) - edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); + for(j = 0; j < 8; j++) edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); _edcTable[i] = edc; } @@ -151,8 +149,7 @@ public static class CdChecksums byte temp = index < 4 ? address[index] : data[index - 4]; index += minorInc; - if(index >= size) - index -= size; + if(index >= size) index -= size; eccA ^= temp; eccB ^= temp; @@ -161,8 +158,7 @@ public static class CdChecksums 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; @@ -203,11 +199,13 @@ public static class CdChecksums // channel[0x00C], channel[0x00D], channel[0x00E]); for(var i = 0x010; i < 0x930; i++) { - if(channel[i] == 0x00) - continue; + if(channel[i] == 0x00) continue; - AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}", - channel[0x00C], channel[0x00D], channel[0x00E]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}", + channel[0x00C], + channel[0x00D], + channel[0x00E]); return false; } @@ -228,7 +226,9 @@ public static class CdChecksums channel[0x81B] != 0x00: AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); return false; case 0x01: @@ -255,14 +255,18 @@ public static class CdChecksums { AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } if(failedEccQ) { AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } var storedEdc = BitConverter.ToUInt32(channel, 0x810); @@ -270,12 +274,15 @@ public static class CdChecksums correctEdc = calculatedEdc == storedEdc; - if(calculatedEdc == storedEdc) - return !failedEccP && !failedEccQ; + if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ; AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", - channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc, storedEdc); + channel[0x00C], + channel[0x00D], + channel[0x00E], + calculatedEdc, + storedEdc); return false; } @@ -297,25 +304,28 @@ public static class CdChecksums { AaruConsole.DebugWriteLine(MODULE_NAME, "Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C); // No CRC stored! - if(storedEdc == 0x00000000) - return true; + if(storedEdc == 0x00000000) return true; uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x91C); correctEdc = calculatedEdc == storedEdc; - if(calculatedEdc == storedEdc) - return true; + if(calculatedEdc == storedEdc) return true; AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", - channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc, + channel[0x00C], + channel[0x00D], + channel[0x00E], + calculatedEdc, storedEdc); return false; @@ -329,7 +339,9 @@ public static class CdChecksums { AaruConsole.DebugWriteLine(MODULE_NAME, "Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } var address = new byte[4]; @@ -349,14 +361,18 @@ public static class CdChecksums { AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } if(failedEccQ) { AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", - channel[0x00C], channel[0x00D], channel[0x00E]); + channel[0x00C], + channel[0x00D], + channel[0x00E]); } var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808); @@ -364,20 +380,26 @@ public static class CdChecksums correctEdc = calculatedEdc == storedEdc; - if(calculatedEdc == storedEdc) - return !failedEccP && !failedEccQ; + if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ; AaruConsole.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", - channel[0x00C], channel[0x00D], channel[0x00E], calculatedEdc, + channel[0x00C], + channel[0x00D], + channel[0x00E], + calculatedEdc, storedEdc); return false; } } default: - AaruConsole.DebugWriteLine(MODULE_NAME, "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}", - channel[0x00F], channel[0x00C], channel[0x00D], channel[0x00E]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}", + channel[0x00F], + channel[0x00C], + channel[0x00D], + channel[0x00E]); return null; } @@ -387,8 +409,7 @@ public static class CdChecksums { var pos = 0; - for(; size > 0; size--) - edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; + for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; return edc; } @@ -408,8 +429,7 @@ public static class CdChecksums var i = 0; - for(var j = 0; j < 12; j++) - qSubChannel[j] = 0; + for(var j = 0; j < 12; j++) qSubChannel[j] = 0; for(var j = 0; j < 18; j++) { @@ -445,13 +465,11 @@ public static class CdChecksums { cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2); - if(j < 17) - cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0xC0) >> 4); + if(j < 17) cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0xC0) >> 4); cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 17) - cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 17) cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x03) << 6); @@ -462,13 +480,11 @@ public static class CdChecksums { cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2); - if(j < 17) - cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0xC0) >> 4); + if(j < 17) cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0xC0) >> 4); cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 17) - cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 17) cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x03) << 6); @@ -479,13 +495,11 @@ public static class CdChecksums { cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2); - if(j < 17) - cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0xC0) >> 4); + if(j < 17) cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0xC0) >> 4); cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 17) - cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 17) cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x03) << 6); @@ -496,13 +510,11 @@ public static class CdChecksums { cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2); - if(j < 17) - cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0xC0) >> 4); + if(j < 17) cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0xC0) >> 4); cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 17) - cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 17) cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x03) << 6); @@ -511,17 +523,13 @@ public static class CdChecksums i = 0; - for(var j = 0; j < 24; j++) - cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) { @@ -569,7 +577,9 @@ public static class CdChecksums if(qSubChannelCrc != calculatedQcrc) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Q_subchannel_CRC_0_expected_1, calculatedQcrc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Q_subchannel_CRC_0_expected_1, + calculatedQcrc, qSubChannelCrc); status = false; @@ -584,7 +594,9 @@ public static class CdChecksums if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.CD_Text_Pack_one_CRC_0_expected_1, cdTextPack1Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.CD_Text_Pack_one_CRC_0_expected_1, + cdTextPack1Crc, calculatedCdtp1Crc); status = false; @@ -598,12 +610,16 @@ public static class CdChecksums Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Cyclic_CDTP2_0_Calc_CDTP2_1, cdTextPack2Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Cyclic_CDTP2_0_Calc_CDTP2_1, + cdTextPack2Crc, calculatedCdtp2Crc); if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.CD_Text_Pack_two_CRC_0_expected_1, cdTextPack2Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.CD_Text_Pack_two_CRC_0_expected_1, + cdTextPack2Crc, calculatedCdtp2Crc); status = false; @@ -617,33 +633,39 @@ public static class CdChecksums Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Cyclic_CDTP3_0_Calc_CDTP3_1, cdTextPack3Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Cyclic_CDTP3_0_Calc_CDTP3_1, + cdTextPack3Crc, calculatedCdtp3Crc); if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.CD_Text_Pack_three_CRC_0_expected_1, - cdTextPack3Crc, calculatedCdtp3Crc); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.CD_Text_Pack_three_CRC_0_expected_1, + cdTextPack3Crc, + calculatedCdtp3Crc); status = false; } } - if((cdTextPack4[0] & 0x80) != 0x80) - return status; + if((cdTextPack4[0] & 0x80) != 0x80) return status; var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); var cdTextPack4ForCrc = new byte[16]; Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Cyclic_CDTP4_0_Calc_CDTP4_1, cdTextPack4Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Cyclic_CDTP4_0_Calc_CDTP4_1, + cdTextPack4Crc, calculatedCdtp4Crc); - if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) - return status; + if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.CD_Text_Pack_four_CRC_0_expected_1, cdTextPack4Crc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.CD_Text_Pack_four_CRC_0_expected_1, + cdTextPack4Crc, calculatedCdtp4Crc); return false; diff --git a/Aaru.Checksums/CRC16Context.cs b/Aaru.Checksums/CRC16Context.cs index 2cc3c4ba0..65bebf05b 100644 --- a/Aaru.Checksums/CRC16Context.cs +++ b/Aaru.Checksums/CRC16Context.cs @@ -80,8 +80,7 @@ public class Crc16Context : IChecksum else _useNative = false; - if(!_useNative) - _table = table ?? GenerateTable(polynomial, inverse); + if(!_useNative) _table = table ?? GenerateTable(polynomial, inverse); } #region IChecksum Members @@ -192,8 +191,7 @@ public class Crc16Context : IChecksum byte[] finalBytes = BigEndianBitConverter.GetBytes(final); - foreach(byte t in finalBytes) - crc16Output.Append(t.ToString("x2")); + foreach(byte t in finalBytes) crc16Output.Append(t.ToString("x2")); return crc16Output.ToString(); } @@ -261,8 +259,7 @@ public class Crc16Context : IChecksum len -= bytesAtOnce; } - while(len-- != 0) - crc = (ushort)(crc >> 8 ^ table[0][crc & 0xFF ^ data[currentPos++]]); + while(len-- != 0) crc = (ushort)(crc >> 8 ^ table[0][crc & 0xFF ^ data[currentPos++]]); previousCrc = crc; } @@ -300,8 +297,7 @@ public class Crc16Context : IChecksum len -= bytesAtOnce; } - while(len-- != 0) - crc = (ushort)(crc << 8 ^ table[0][crc >> 8 ^ data[currentPos++]]); + while(len-- != 0) crc = (ushort)(crc << 8 ^ table[0][crc >> 8 ^ data[currentPos++]]); previousCrc = crc; } @@ -310,8 +306,7 @@ public class Crc16Context : IChecksum { var table = new ushort[8][]; - for(var i = 0; i < 8; i++) - table[i] = new ushort[256]; + for(var i = 0; i < 8; i++) table[i] = new ushort[256]; if(!inverseTable) { @@ -349,12 +344,14 @@ public class Crc16Context : IChecksum } for(var slice = 1; slice < 8; slice++) - for(var i = 0; i < 256; i++) { - if(inverseTable) - table[slice][i] = (ushort)(table[slice - 1][i] << 8 ^ table[0][table[slice - 1][i] >> 8]); - else - table[slice][i] = (ushort)(table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]); + for(var i = 0; i < 256; i++) + { + if(inverseTable) + table[slice][i] = (ushort)(table[slice - 1][i] << 8 ^ table[0][table[slice - 1][i] >> 8]); + else + table[slice][i] = (ushort)(table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]); + } } return table; @@ -447,8 +444,7 @@ public class Crc16Context : IChecksum break; default: { - if(inverse) - localHashInt = (ushort)~localHashInt; + if(inverse) localHashInt = (ushort)~localHashInt; break; } @@ -458,8 +454,7 @@ public class Crc16Context : IChecksum var crc16Output = new StringBuilder(); - foreach(byte h in hash) - crc16Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc16Output.Append(h.ToString("x2")); fileStream.Close(); @@ -544,8 +539,7 @@ public class Crc16Context : IChecksum break; default: { - if(inverse) - localHashInt = (ushort)~localHashInt; + if(inverse) localHashInt = (ushort)~localHashInt; break; } @@ -555,8 +549,7 @@ public class Crc16Context : IChecksum var crc16Output = new StringBuilder(); - foreach(byte h in hash) - crc16Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc16Output.Append(h.ToString("x2")); return crc16Output.ToString(); } @@ -637,8 +630,7 @@ public class Crc16Context : IChecksum break; default: { - if(inverse) - localHashInt = (ushort)~localHashInt; + if(inverse) localHashInt = (ushort)~localHashInt; break; } diff --git a/Aaru.Checksums/CRC16IBMContext.cs b/Aaru.Checksums/CRC16IBMContext.cs index 19baf4787..5e787eb80 100644 --- a/Aaru.Checksums/CRC16IBMContext.cs +++ b/Aaru.Checksums/CRC16IBMContext.cs @@ -248,6 +248,7 @@ public sealed class CRC16IbmContext : Crc16Context /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { diff --git a/Aaru.Checksums/CRC32/arm_simd.cs b/Aaru.Checksums/CRC32/arm_simd.cs index 61ea8d900..f32287c8e 100644 --- a/Aaru.Checksums/CRC32/arm_simd.cs +++ b/Aaru.Checksums/CRC32/arm_simd.cs @@ -86,8 +86,7 @@ static class ArmSimd len -= 8; } - while(len-- > 0) - c = Crc32.ComputeCrc32(c, buf[bufPos++]); + while(len-- > 0) c = Crc32.ComputeCrc32(c, buf[bufPos++]); return c; } @@ -126,8 +125,7 @@ static class ArmSimd len -= 4; } - while(len-- > 0) - c = Crc32.ComputeCrc32(c, buf[bufPos++]); + while(len-- > 0) c = Crc32.ComputeCrc32(c, buf[bufPos++]); return c; } diff --git a/Aaru.Checksums/CRC32/clmul.cs b/Aaru.Checksums/CRC32/clmul.cs index a92905bba..22f7b744c 100644 --- a/Aaru.Checksums/CRC32/clmul.cs +++ b/Aaru.Checksums/CRC32/clmul.cs @@ -120,27 +120,31 @@ static class Clmul while((len -= 64) >= 0) { - var xmmT0 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), BitConverter.ToUInt32(src, bufPos + 4), - BitConverter.ToUInt32(src, bufPos + 8), - BitConverter.ToUInt32(src, bufPos + 12)); + var xmmT0 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), + BitConverter.ToUInt32(src, bufPos + 4), + BitConverter.ToUInt32(src, bufPos + 8), + BitConverter.ToUInt32(src, bufPos + 12)); bufPos += 16; - var xmmT1 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), BitConverter.ToUInt32(src, bufPos + 4), - BitConverter.ToUInt32(src, bufPos + 8), - BitConverter.ToUInt32(src, bufPos + 12)); + var xmmT1 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), + BitConverter.ToUInt32(src, bufPos + 4), + BitConverter.ToUInt32(src, bufPos + 8), + BitConverter.ToUInt32(src, bufPos + 12)); bufPos += 16; - var xmmT2 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), BitConverter.ToUInt32(src, bufPos + 4), - BitConverter.ToUInt32(src, bufPos + 8), - BitConverter.ToUInt32(src, bufPos + 12)); + var xmmT2 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), + BitConverter.ToUInt32(src, bufPos + 4), + BitConverter.ToUInt32(src, bufPos + 8), + BitConverter.ToUInt32(src, bufPos + 12)); bufPos += 16; - var xmmT3 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), BitConverter.ToUInt32(src, bufPos + 4), - BitConverter.ToUInt32(src, bufPos + 8), - BitConverter.ToUInt32(src, bufPos + 12)); + var xmmT3 = Vector128.Create(BitConverter.ToUInt32(src, bufPos), + BitConverter.ToUInt32(src, bufPos + 4), + BitConverter.ToUInt32(src, bufPos + 8), + BitConverter.ToUInt32(src, bufPos + 12)); bufPos += 16; diff --git a/Aaru.Checksums/CRC32Context.cs b/Aaru.Checksums/CRC32Context.cs index 089fc0461..a3cef88d6 100644 --- a/Aaru.Checksums/CRC32Context.cs +++ b/Aaru.Checksums/CRC32Context.cs @@ -329,8 +329,7 @@ public sealed class Crc32Context : IChecksum _table = ISOCrc32Table; _useIso = true; - if(!Native.IsSupported) - return; + if(!Native.IsSupported) return; _nativeContext = crc32_init(); _useNative = _nativeContext != IntPtr.Zero; @@ -381,8 +380,7 @@ public sealed class Crc32Context : IChecksum { uint crc = _hashInt ^ _finalSeed; - if(!_useNative || !_useIso) - return BigEndianBitConverter.GetBytes(crc); + if(!_useNative || !_useIso) return BigEndianBitConverter.GetBytes(crc); crc32_final(_nativeContext, ref crc); crc32_free(_nativeContext); @@ -428,8 +426,7 @@ public sealed class Crc32Context : IChecksum { var table = new uint[8][]; - for(var i = 0; i < 8; i++) - table[i] = new uint[256]; + for(var i = 0; i < 8; i++) table[i] = new uint[256]; for(var i = 0; i < 256; i++) { @@ -447,8 +444,10 @@ public sealed class Crc32Context : IChecksum } for(var slice = 1; slice < 8; slice++) - for(var i = 0; i < 256; i++) - table[slice][i] = table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]; + { + for(var i = 0; i < 256; i++) + table[slice][i] = table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]; + } return table; } @@ -480,8 +479,7 @@ public sealed class Crc32Context : IChecksum len -= blocks * 64; } - if(len == 0) - return; + if(len == 0) return; } if(Crc32.Arm64.IsSupported) @@ -530,14 +528,14 @@ public sealed class Crc32Context : IChecksum len -= bytesAtOnce; } - while(len-- != 0) - crc = crc >> 8 ^ table[0][crc & 0xFF ^ data[currentPos++]]; + while(len-- != 0) crc = crc >> 8 ^ table[0][crc & 0xFF ^ data[currentPos++]]; previousCrc = crc; } /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { @@ -597,8 +595,7 @@ public sealed class Crc32Context : IChecksum var crc32Output = new StringBuilder(); - foreach(byte h in hash) - crc32Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc32Output.Append(h.ToString("x2")); fileStream.Close(); @@ -648,8 +645,7 @@ public sealed class Crc32Context : IChecksum var crc32Output = new StringBuilder(); - foreach(byte h in hash) - crc32Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc32Output.Append(h.ToString("x2")); return crc32Output.ToString(); } diff --git a/Aaru.Checksums/CRC64/clmul.cs b/Aaru.Checksums/CRC64/clmul.cs index c9cd1f925..6389fb3f7 100644 --- a/Aaru.Checksums/CRC64/clmul.cs +++ b/Aaru.Checksums/CRC64/clmul.cs @@ -42,12 +42,21 @@ static class Clmul { uint maskPos = 16 - n; - var maskA = Vector128.Create(_shuffleMasks[maskPos], _shuffleMasks[maskPos + 1], _shuffleMasks[maskPos + 2], - _shuffleMasks[maskPos + 3], _shuffleMasks[maskPos + 4], _shuffleMasks[maskPos + 5], - _shuffleMasks[maskPos + 6], _shuffleMasks[maskPos + 7], _shuffleMasks[maskPos + 8], - _shuffleMasks[maskPos + 9], _shuffleMasks[maskPos + 10], - _shuffleMasks[maskPos + 11], _shuffleMasks[maskPos + 12], - _shuffleMasks[maskPos + 13], _shuffleMasks[maskPos + 14], + var maskA = Vector128.Create(_shuffleMasks[maskPos], + _shuffleMasks[maskPos + 1], + _shuffleMasks[maskPos + 2], + _shuffleMasks[maskPos + 3], + _shuffleMasks[maskPos + 4], + _shuffleMasks[maskPos + 5], + _shuffleMasks[maskPos + 6], + _shuffleMasks[maskPos + 7], + _shuffleMasks[maskPos + 8], + _shuffleMasks[maskPos + 9], + _shuffleMasks[maskPos + 10], + _shuffleMasks[maskPos + 11], + _shuffleMasks[maskPos + 12], + _shuffleMasks[maskPos + 13], + _shuffleMasks[maskPos + 14], _shuffleMasks[maskPos + 15]); Vector128 maskB = Sse2.Xor(maskA, Sse2.CompareEqual(Vector128.Zero, Vector128.Zero)); @@ -77,13 +86,17 @@ static class Clmul ShiftRight128(initialCrc, 0, out Vector128 crc0, out Vector128 crc1); Vector128 accumulator = - Sse2.Xor(Fold(Sse2.Xor(crc0, Vector128.Create(BitConverter.ToUInt64(data, 0), BitConverter.ToUInt64(data, 8))), foldConstants1), + Sse2.Xor(Fold(Sse2.Xor(crc0, + Vector128.Create(BitConverter.ToUInt64(data, 0), BitConverter.ToUInt64(data, 8))), + foldConstants1), crc1); while(length >= 32) { accumulator = - Fold(Sse2.Xor(Vector128.Create(BitConverter.ToUInt64(data, bufPos), BitConverter.ToUInt64(data, bufPos + 8)), accumulator), + Fold(Sse2.Xor(Vector128.Create(BitConverter.ToUInt64(data, bufPos), + BitConverter.ToUInt64(data, bufPos + 8)), + accumulator), foldConstants1); length -= 16; @@ -100,9 +113,9 @@ static class Clmul // Final Barrett reduction Vector128 t1 = Pclmulqdq.CarrylessMultiply(r, foldConstants2, 0x00); - Vector128 t2 = - Sse2.Xor(Sse2.Xor(Pclmulqdq.CarrylessMultiply(t1, foldConstants2, 0x10), Sse2.ShiftLeftLogical128BitLane(t1, 8)), - r); + Vector128 t2 = Sse2.Xor(Sse2.Xor(Pclmulqdq.CarrylessMultiply(t1, foldConstants2, 0x10), + Sse2.ShiftLeftLogical128BitLane(t1, 8)), + r); return ~((ulong)Sse41.Extract(t2.AsUInt32(), 3) << 32 | Sse41.Extract(t2.AsUInt32(), 2)); } diff --git a/Aaru.Checksums/CRC64Context.cs b/Aaru.Checksums/CRC64Context.cs index c0ef7524f..66219ba73 100644 --- a/Aaru.Checksums/CRC64Context.cs +++ b/Aaru.Checksums/CRC64Context.cs @@ -294,8 +294,7 @@ public sealed class Crc64Context : IChecksum _finalSeed = CRC64_ECMA_SEED; _useEcma = true; - if(!Native.IsSupported) - return; + if(!Native.IsSupported) return; _nativeContext = crc64_init(); _useNative = _nativeContext != IntPtr.Zero; @@ -346,8 +345,7 @@ public sealed class Crc64Context : IChecksum { ulong crc = _hashInt ^ _finalSeed; - if(!_useNative || !_useEcma) - return BigEndianBitConverter.GetBytes(crc); + if(!_useNative || !_useEcma) return BigEndianBitConverter.GetBytes(crc); crc64_final(_nativeContext, ref crc); crc64_free(_nativeContext); @@ -393,8 +391,7 @@ public sealed class Crc64Context : IChecksum { var table = new ulong[8][]; - for(var i = 0; i < 8; i++) - table[i] = new ulong[256]; + for(var i = 0; i < 8; i++) table[i] = new ulong[256]; for(var i = 0; i < 256; i++) { @@ -412,8 +409,10 @@ public sealed class Crc64Context : IChecksum } for(var slice = 1; slice < 4; slice++) - for(var i = 0; i < 256; i++) - table[slice][i] = table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]; + { + for(var i = 0; i < 256; i++) + table[slice][i] = table[slice - 1][i] >> 8 ^ table[0][table[slice - 1][i] & 0xFF]; + } return table; } @@ -443,8 +442,7 @@ public sealed class Crc64Context : IChecksum len -= blocks * 32; } - if(len == 0) - return; + if(len == 0) return; } // Unroll according to Intel slicing by uint8_t @@ -471,14 +469,14 @@ public sealed class Crc64Context : IChecksum } } - while(len-- != 0) - crc = table[0][data[dataOff++] ^ crc & 0xFF] ^ crc >> 8; + while(len-- != 0) crc = table[0][data[dataOff++] ^ crc & 0xFF] ^ crc >> 8; previousCrc = crc; } /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { @@ -538,8 +536,7 @@ public sealed class Crc64Context : IChecksum var crc64Output = new StringBuilder(); - foreach(byte h in hash) - crc64Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc64Output.Append(h.ToString("x2")); fileStream.Close(); @@ -589,8 +586,7 @@ public sealed class Crc64Context : IChecksum var crc64Output = new StringBuilder(); - foreach(byte h in hash) - crc64Output.Append(h.ToString("x2")); + foreach(byte h in hash) crc64Output.Append(h.ToString("x2")); return crc64Output.ToString(); } diff --git a/Aaru.Checksums/Fletcher32/neon.cs b/Aaru.Checksums/Fletcher32/neon.cs index 88bec36f6..ad3be0b51 100644 --- a/Aaru.Checksums/Fletcher32/neon.cs +++ b/Aaru.Checksums/Fletcher32/neon.cs @@ -73,8 +73,7 @@ static class Neon { uint n = Fletcher32Context.NMAX / block_Size; /* The NMAX constraint. */ - if(n > blocks) - n = blocks; + if(n > blocks) n = blocks; blocks -= n; /* @@ -93,17 +92,41 @@ static class Neon /* * Load 32 input bytes. */ - var bytes1 = Vector128.Create(buf[bufPos], buf[bufPos + 1], buf[bufPos + 2], buf[bufPos + 3], - buf[bufPos + 4], buf[bufPos + 5], buf[bufPos + 6], buf[bufPos + 7], - buf[bufPos + 8], buf[bufPos + 9], buf[bufPos + 10], buf[bufPos + 11], - buf[bufPos + 12], buf[bufPos + 13], buf[bufPos + 14], buf[bufPos + 15]); + var bytes1 = Vector128.Create(buf[bufPos], + buf[bufPos + 1], + buf[bufPos + 2], + buf[bufPos + 3], + buf[bufPos + 4], + buf[bufPos + 5], + buf[bufPos + 6], + buf[bufPos + 7], + buf[bufPos + 8], + buf[bufPos + 9], + buf[bufPos + 10], + buf[bufPos + 11], + buf[bufPos + 12], + buf[bufPos + 13], + buf[bufPos + 14], + buf[bufPos + 15]); bufPos += 16; - var bytes2 = Vector128.Create(buf[bufPos], buf[bufPos + 1], buf[bufPos + 2], buf[bufPos + 3], - buf[bufPos + 4], buf[bufPos + 5], buf[bufPos + 6], buf[bufPos + 7], - buf[bufPos + 8], buf[bufPos + 9], buf[bufPos + 10], buf[bufPos + 11], - buf[bufPos + 12], buf[bufPos + 13], buf[bufPos + 14], buf[bufPos + 15]); + var bytes2 = Vector128.Create(buf[bufPos], + buf[bufPos + 1], + buf[bufPos + 2], + buf[bufPos + 3], + buf[bufPos + 4], + buf[bufPos + 5], + buf[bufPos + 6], + buf[bufPos + 7], + buf[bufPos + 8], + buf[bufPos + 9], + buf[bufPos + 10], + buf[bufPos + 11], + buf[bufPos + 12], + buf[bufPos + 13], + buf[bufPos + 14], + buf[bufPos + 15]); bufPos += 16; /* @@ -114,11 +137,11 @@ static class Neon /* * Horizontally add the bytes for s1. */ - v_S1 = - AdvSimd.AddPairwiseWideningAndAdd(v_S1, - AdvSimd. - AddPairwiseWideningAndAdd(AdvSimd.AddPairwiseWidening(bytes1), - bytes2)); + v_S1 = AdvSimd.AddPairwiseWideningAndAdd(v_S1, + AdvSimd + .AddPairwiseWideningAndAdd(AdvSimd + .AddPairwiseWidening(bytes1), + bytes2)); /* * Vertically add the bytes for s2. @@ -134,28 +157,36 @@ static class Neon /* * Multiply-add bytes by [ 32, 31, 30, ... ] for s2. */ - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_1.GetLower(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_1.GetLower(), Vector64.Create((ushort)32, 31, 30, 29)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_1.GetUpper(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_1.GetUpper(), Vector64.Create((ushort)28, 27, 26, 25)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_2.GetLower(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_2.GetLower(), Vector64.Create((ushort)24, 23, 22, 21)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_2.GetUpper(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_2.GetUpper(), Vector64.Create((ushort)20, 19, 18, 17)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_3.GetLower(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_3.GetLower(), Vector64.Create((ushort)16, 15, 14, 13)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_3.GetUpper(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_3.GetUpper(), Vector64.Create((ushort)12, 11, 10, 9)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_4.GetLower(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_4.GetLower(), Vector64.Create((ushort)8, 7, 6, 5)); - v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, v_Column_Sum_4.GetUpper(), + v_S2 = AdvSimd.MultiplyWideningLowerAndAdd(v_S2, + v_Column_Sum_4.GetUpper(), Vector64.Create((ushort)4, 3, 2, 1)); /* @@ -199,11 +230,9 @@ static class Neon len -= 16; } - while(len-- != 0) - s2 += s1 += buf[bufPos++]; + while(len-- != 0) s2 += s1 += buf[bufPos++]; - if(s1 >= Fletcher32Context.FLETCHER_MODULE) - s1 -= Fletcher32Context.FLETCHER_MODULE; + if(s1 >= Fletcher32Context.FLETCHER_MODULE) s1 -= Fletcher32Context.FLETCHER_MODULE; s2 %= Fletcher32Context.FLETCHER_MODULE; } diff --git a/Aaru.Checksums/Fletcher32/ssse3.cs b/Aaru.Checksums/Fletcher32/ssse3.cs index 37804cd2b..efddea9db 100644 --- a/Aaru.Checksums/Fletcher32/ssse3.cs +++ b/Aaru.Checksums/Fletcher32/ssse3.cs @@ -70,13 +70,12 @@ static class Ssse3 { uint n = Fletcher32Context.NMAX / block_Size; /* The NMAX constraint. */ - if(n > blocks) - n = blocks; + if(n > blocks) n = blocks; blocks -= n; - Vector128 tap1 = Vector128.Create(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17). - AsByte(); + Vector128 tap1 = Vector128.Create(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17) + .AsByte(); Vector128 tap2 = Vector128.Create(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1).AsByte(); Vector128 zero = Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).AsByte(); @@ -173,11 +172,9 @@ static class Ssse3 len -= 16; } - while(len-- != 0) - s2 += s1 += buf[bufPos++]; + while(len-- != 0) s2 += s1 += buf[bufPos++]; - if(s1 >= Fletcher32Context.FLETCHER_MODULE) - s1 -= Fletcher32Context.FLETCHER_MODULE; + if(s1 >= Fletcher32Context.FLETCHER_MODULE) s1 -= Fletcher32Context.FLETCHER_MODULE; s2 %= Fletcher32Context.FLETCHER_MODULE; } diff --git a/Aaru.Checksums/FletcherContext.cs b/Aaru.Checksums/FletcherContext.cs index 8ca63928f..e22e8a74e 100644 --- a/Aaru.Checksums/FletcherContext.cs +++ b/Aaru.Checksums/FletcherContext.cs @@ -64,8 +64,7 @@ public sealed class Fletcher32Context : IChecksum _sum1 = 0xFFFF; _sum2 = 0xFFFF; - if(!Native.IsSupported) - return; + if(!Native.IsSupported) return; _nativeContext = fletcher32_init(); _useNative = _nativeContext != IntPtr.Zero; @@ -99,8 +98,7 @@ public sealed class Fletcher32Context : IChecksum { var finalSum = (uint)(_sum2 << 16 | _sum1); - if(!_useNative) - return BigEndianBitConverter.GetBytes(finalSum); + if(!_useNative) return BigEndianBitConverter.GetBytes(finalSum); fletcher32_final(_nativeContext, ref finalSum); fletcher32_free(_nativeContext); @@ -177,13 +175,11 @@ public sealed class Fletcher32Context : IChecksum { sum1 += data[dataOff]; - if(sum1 >= FLETCHER_MODULE) - sum1 -= FLETCHER_MODULE; + if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE; sum2 += sum1; - if(sum2 >= FLETCHER_MODULE) - sum2 -= FLETCHER_MODULE; + if(sum2 >= FLETCHER_MODULE) sum2 -= FLETCHER_MODULE; previousSum1 = (ushort)(sum1 & 0xFFFF); previousSum2 = (ushort)(sum2 & 0xFFFF); @@ -199,8 +195,7 @@ public sealed class Fletcher32Context : IChecksum sum2 += sum1; } - if(sum1 >= FLETCHER_MODULE) - sum1 -= FLETCHER_MODULE; + if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE; sum2 %= FLETCHER_MODULE; /* only added so many FLETCHER_MODULE's */ previousSum1 = (ushort)(sum1 & 0xFFFF); @@ -337,8 +332,7 @@ public sealed class Fletcher32Context : IChecksum { nativeContext = fletcher32_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } var fileStream = new FileStream(filename, FileMode.Open); @@ -368,8 +362,7 @@ public sealed class Fletcher32Context : IChecksum var fletcherOutput = new StringBuilder(); - foreach(byte h in hash) - fletcherOutput.Append(h.ToString("x2")); + foreach(byte h in hash) fletcherOutput.Append(h.ToString("x2")); fileStream.Close(); @@ -389,8 +382,7 @@ public sealed class Fletcher32Context : IChecksum { nativeContext = fletcher32_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } ushort localSum1 = 0xFFFF; @@ -410,8 +402,7 @@ public sealed class Fletcher32Context : IChecksum var adlerOutput = new StringBuilder(); - foreach(byte h in hash) - adlerOutput.Append(h.ToString("x2")); + foreach(byte h in hash) adlerOutput.Append(h.ToString("x2")); return adlerOutput.ToString(); } @@ -442,8 +433,7 @@ public sealed class Fletcher16Context : IChecksum _sum1 = 0xFF; _sum2 = 0xFF; - if(!Native.IsSupported) - return; + if(!Native.IsSupported) return; _nativeContext = fletcher16_init(); _useNative = _nativeContext != IntPtr.Zero; @@ -477,8 +467,7 @@ public sealed class Fletcher16Context : IChecksum { var finalSum = (ushort)(_sum2 << 8 | _sum1); - if(!_useNative) - return BigEndianBitConverter.GetBytes(finalSum); + if(!_useNative) return BigEndianBitConverter.GetBytes(finalSum); fletcher16_final(_nativeContext, ref finalSum); fletcher16_free(_nativeContext); @@ -541,13 +530,11 @@ public sealed class Fletcher16Context : IChecksum { sum1 += data[dataOff]; - if(sum1 >= FLETCHER_MODULE) - sum1 -= FLETCHER_MODULE; + if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE; sum2 += sum1; - if(sum2 >= FLETCHER_MODULE) - sum2 -= FLETCHER_MODULE; + if(sum2 >= FLETCHER_MODULE) sum2 -= FLETCHER_MODULE; previousSum1 = (byte)(sum1 & 0xFF); previousSum2 = (byte)(sum2 & 0xFF); @@ -563,8 +550,7 @@ public sealed class Fletcher16Context : IChecksum sum2 += sum1; } - if(sum1 >= FLETCHER_MODULE) - sum1 -= FLETCHER_MODULE; + if(sum1 >= FLETCHER_MODULE) sum1 -= FLETCHER_MODULE; sum2 %= FLETCHER_MODULE; /* only added so many FLETCHER_MODULE's */ previousSum1 = (byte)(sum1 & 0xFF); @@ -681,8 +667,7 @@ public sealed class Fletcher16Context : IChecksum { nativeContext = fletcher16_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } var fileStream = new FileStream(filename, FileMode.Open); @@ -712,8 +697,7 @@ public sealed class Fletcher16Context : IChecksum var fletcherOutput = new StringBuilder(); - foreach(byte h in hash) - fletcherOutput.Append(h.ToString("x2")); + foreach(byte h in hash) fletcherOutput.Append(h.ToString("x2")); fileStream.Close(); @@ -733,8 +717,7 @@ public sealed class Fletcher16Context : IChecksum { nativeContext = fletcher16_init(); - if(nativeContext == IntPtr.Zero) - useNative = false; + if(nativeContext == IntPtr.Zero) useNative = false; } byte localSum1 = 0xFF; @@ -754,8 +737,7 @@ public sealed class Fletcher16Context : IChecksum var adlerOutput = new StringBuilder(); - foreach(byte h in hash) - adlerOutput.Append(h.ToString("x2")); + foreach(byte h in hash) adlerOutput.Append(h.ToString("x2")); return adlerOutput.ToString(); } diff --git a/Aaru.Checksums/MD5Context.cs b/Aaru.Checksums/MD5Context.cs index 692c5e83a..6641bf9c0 100644 --- a/Aaru.Checksums/MD5Context.cs +++ b/Aaru.Checksums/MD5Context.cs @@ -85,11 +85,9 @@ public sealed class Md5Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var md5Output = new StringBuilder(); - if(_provider.Hash is null) - return null; + if(_provider.Hash is null) return null; - foreach(byte h in _provider.Hash) - md5Output.Append(h.ToString("x2")); + foreach(byte h in _provider.Hash) md5Output.Append(h.ToString("x2")); return md5Output.ToString(); } @@ -118,8 +116,7 @@ public sealed class Md5Context : IChecksum hash = localMd5Provider.ComputeHash(fileStream); var md5Output = new StringBuilder(); - foreach(byte h in hash) - md5Output.Append(h.ToString("x2")); + foreach(byte h in hash) md5Output.Append(h.ToString("x2")); fileStream.Close(); @@ -136,8 +133,7 @@ public sealed class Md5Context : IChecksum hash = localMd5Provider.ComputeHash(data, 0, (int)len); var md5Output = new StringBuilder(); - foreach(byte h in hash) - md5Output.Append(h.ToString("x2")); + foreach(byte h in hash) md5Output.Append(h.ToString("x2")); return md5Output.ToString(); } diff --git a/Aaru.Checksums/Native.cs b/Aaru.Checksums/Native.cs index bcd7973f1..770ff61fb 100644 --- a/Aaru.Checksums/Native.cs +++ b/Aaru.Checksums/Native.cs @@ -51,11 +51,9 @@ public static class Native { get { - if(ForceManaged) - return false; + if(ForceManaged) return false; - if(_checked) - return _supported; + if(_checked) return _supported; ulong version; _checked = true; diff --git a/Aaru.Checksums/ReedSolomon.cs b/Aaru.Checksums/ReedSolomon.cs index 8207d860d..a66c24034 100644 --- a/Aaru.Checksums/ReedSolomon.cs +++ b/Aaru.Checksums/ReedSolomon.cs @@ -188,24 +188,21 @@ public class ReedSolomon { int ci; - for(ci = n - 1; ci >= 0; ci--) - a[ci] = 0; + for(ci = n - 1; ci >= 0; ci--) a[ci] = 0; } static void Copy(ref int[] a, ref int[] b, int n) { int ci; - for(ci = n - 1; ci >= 0; ci--) - a[ci] = b[ci]; + for(ci = n - 1; ci >= 0; ci--) a[ci] = b[ci]; } static void Copydown(ref int[] a, ref int[] b, int n) { int ci; - for(ci = n - 1; ci >= 0; ci--) - a[ci] = b[ci]; + for(ci = n - 1; ci >= 0; ci--) a[ci] = b[ci]; } /* generate GF(2**m) from the irreducible polynomial p(X) in p[0]..p[m] @@ -251,8 +248,7 @@ public class ReedSolomon _indexOf[_alphaTo[i]] = i; /* If Pp[i] == 1 then, term @^i occurs in poly-repr of @^MM */ - if(_pp[i] != 0) - _alphaTo[_mm] ^= mask; /* Bit-wise EXOR operation */ + if(_pp[i] != 0) _alphaTo[_mm] ^= mask; /* Bit-wise EXOR operation */ mask <<= 1; /* single left-shift */ } @@ -320,8 +316,7 @@ public class ReedSolomon } /* convert Gg[] to index form for quicker encoding */ - for(i = 0; i <= _nn - _kk; i++) - _gg[i] = _indexOf[_gg[i]]; + for(i = 0; i <= _nn - _kk; i++) _gg[i] = _indexOf[_gg[i]]; } /* @@ -350,8 +345,7 @@ public class ReedSolomon { if(_mm != 8) { - if(data[i] > _nn) - return -1; /* Illegal symbol */ + if(data[i] > _nn) return -1; /* Illegal symbol */ } int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]]; @@ -373,8 +367,7 @@ public class ReedSolomon { /* feedback term is zero. encoder becomes a * single-byte shifter */ - for(int j = _nn - _kk - 1; j > 0; j--) - bb[j] = bb[j - 1]; + for(int j = _nn - _kk - 1; j > 0; j--) bb[j] = bb[j - 1]; bb[0] = 0; } @@ -425,8 +418,7 @@ public class ReedSolomon { if(_mm != 8) { - if(data[i] > _nn) - return -1; /* Illegal symbol */ + if(data[i] > _nn) return -1; /* Illegal symbol */ } recd[i] = _indexOf[data[i]]; @@ -443,8 +435,7 @@ public class ReedSolomon for(j = 0; j < _nn; j++) { - if(recd[j] != _a0) /* recd[j] in index form */ - tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; + if(recd[j] != _a0) /* recd[j] in index form */ tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; } synError |= tmp; /* set flag if non-zero syndrome => @@ -454,8 +445,7 @@ public class ReedSolomon s[i] = _indexOf[tmp]; } - if(synError == 0) - return 0; + if(synError == 0) return 0; Clear(ref lambda, _nn - _kk); lambda[0] = 1; @@ -473,15 +463,13 @@ public class ReedSolomon { tmp = _indexOf[lambda[j - 1]]; - if(tmp != _a0) - lambda[j] ^= _alphaTo[Modnn(u + tmp)]; + if(tmp != _a0) lambda[j] ^= _alphaTo[Modnn(u + tmp)]; } } - #if DEBUG +#if DEBUG /* find roots of the erasure location polynomial */ - for(i = 1; i <= noEras; i++) - reg[i] = _indexOf[lambda[i]]; + for(i = 1; i <= noEras; i++) reg[i] = _indexOf[lambda[i]]; count = 0; @@ -491,15 +479,13 @@ public class ReedSolomon for(j = 1; j <= noEras; j++) { - if(reg[j] == _a0) - continue; + if(reg[j] == _a0) continue; reg[j] = Modnn(reg[j] + j); q ^= _alphaTo[reg[j]]; } - if(q != 0) - continue; + if(q != 0) continue; /* store root and error location * number indices @@ -519,15 +505,13 @@ public class ReedSolomon AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Erasure_positions_as_determined_by_roots_of_Eras_Loc_Poly); - for(i = 0; i < count; i++) - AaruConsole.DebugWriteLine(MODULE_NAME, "{0} ", loc[i]); + for(i = 0; i < count; i++) AaruConsole.DebugWriteLine(MODULE_NAME, "{0} ", loc[i]); AaruConsole.DebugWriteLine(MODULE_NAME, "\n"); - #endif +#endif } - for(i = 0; i < _nn - _kk + 1; i++) - b[i] = _indexOf[lambda[i]]; + for(i = 0; i < _nn - _kk + 1; i++) b[i] = _indexOf[lambda[i]]; /* * Begin Berlekamp-Massey algorithm to determine error+erasure @@ -544,8 +528,7 @@ public class ReedSolomon for(i = 0; i < r; i++) { - if(lambda[i] != 0 && s[r - i] != _a0) - discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; + if(lambda[i] != 0 && s[r - i] != _a0) discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; } discrR = _indexOf[discrR]; /* Index form */ @@ -598,8 +581,7 @@ public class ReedSolomon { lambda[i] = _indexOf[lambda[i]]; - if(lambda[i] != _a0) - degLambda = i; + if(lambda[i] != _a0) degLambda = i; } /* @@ -617,15 +599,13 @@ public class ReedSolomon for(j = degLambda; j > 0; j--) { - if(reg[j] == _a0) - continue; + if(reg[j] == _a0) continue; reg[j] = Modnn(reg[j] + j); q ^= _alphaTo[reg[j]]; } - if(q != 0) - continue; + if(q != 0) continue; /* store root (index-form) and error location number */ root[count] = i; @@ -633,17 +613,15 @@ public class ReedSolomon count++; } - #if DEBUG +#if DEBUG AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Final_error_positions); - for(i = 0; i < count; i++) - AaruConsole.DebugWriteLine(MODULE_NAME, "{0} ", loc[i]); + for(i = 0; i < count; i++) AaruConsole.DebugWriteLine(MODULE_NAME, "{0} ", loc[i]); AaruConsole.DebugWriteLine(MODULE_NAME, "\n"); - #endif +#endif - if(degLambda != count) - return -1; + if(degLambda != count) return -1; /* * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo @@ -658,12 +636,10 @@ public class ReedSolomon for(; j >= 0; j--) { - if(s[i + 1 - j] != _a0 && lambda[j] != _a0) - tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; + if(s[i + 1 - j] != _a0 && lambda[j] != _a0) tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; } - if(tmp != 0) - degOmega = i; + if(tmp != 0) degOmega = i; omega[i] = _indexOf[tmp]; } @@ -680,8 +656,7 @@ public class ReedSolomon for(i = degOmega; i >= 0; i--) { - if(omega[i] != _a0) - num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; + if(omega[i] != _a0) num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; } int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)]; @@ -690,8 +665,7 @@ public class ReedSolomon /* 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 ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; + if(lambda[i + 1] != _a0) den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; } if(den == 0) @@ -702,8 +676,7 @@ public class ReedSolomon } /* Apply error to data */ - if(num1 != 0) - data[loc[j]] ^= _alphaTo[Modnn(_indexOf[num1] + _indexOf[num2] + _nn - _indexOf[den])]; + if(num1 != 0) data[loc[j]] ^= _alphaTo[Modnn(_indexOf[num1] + _indexOf[num2] + _nn - _indexOf[den])]; } return count; diff --git a/Aaru.Checksums/SHA1Context.cs b/Aaru.Checksums/SHA1Context.cs index c796f3a51..7bbc3f753 100644 --- a/Aaru.Checksums/SHA1Context.cs +++ b/Aaru.Checksums/SHA1Context.cs @@ -89,11 +89,9 @@ public sealed class Sha1Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha1Output = new StringBuilder(); - if(_provider.Hash is null) - return null; + if(_provider.Hash is null) return null; - foreach(byte h in _provider.Hash) - sha1Output.Append(h.ToString("x2")); + foreach(byte h in _provider.Hash) sha1Output.Append(h.ToString("x2")); return sha1Output.ToString(); } @@ -102,6 +100,7 @@ public sealed class Sha1Context : IChecksum /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { @@ -123,8 +122,7 @@ public sealed class Sha1Context : IChecksum hash = localSha1Provider.ComputeHash(fileStream); var sha1Output = new StringBuilder(); - foreach(byte h in hash) - sha1Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha1Output.Append(h.ToString("x2")); fileStream.Close(); @@ -141,8 +139,7 @@ public sealed class Sha1Context : IChecksum hash = localSha1Provider.ComputeHash(data, 0, (int)len); var sha1Output = new StringBuilder(); - foreach(byte h in hash) - sha1Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha1Output.Append(h.ToString("x2")); return sha1Output.ToString(); } diff --git a/Aaru.Checksums/SHA256Context.cs b/Aaru.Checksums/SHA256Context.cs index ccf00ff79..a40f24144 100644 --- a/Aaru.Checksums/SHA256Context.cs +++ b/Aaru.Checksums/SHA256Context.cs @@ -89,11 +89,9 @@ public sealed class Sha256Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha256Output = new StringBuilder(); - if(_provider.Hash is null) - return null; + if(_provider.Hash is null) return null; - foreach(byte h in _provider.Hash) - sha256Output.Append(h.ToString("x2")); + foreach(byte h in _provider.Hash) sha256Output.Append(h.ToString("x2")); return sha256Output.ToString(); } @@ -102,6 +100,7 @@ public sealed class Sha256Context : IChecksum /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { @@ -123,8 +122,7 @@ public sealed class Sha256Context : IChecksum hash = localSha256Provider.ComputeHash(fileStream); var sha256Output = new StringBuilder(); - foreach(byte h in hash) - sha256Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha256Output.Append(h.ToString("x2")); fileStream.Close(); @@ -141,8 +139,7 @@ public sealed class Sha256Context : IChecksum hash = localSha256Provider.ComputeHash(data, 0, (int)len); var sha256Output = new StringBuilder(); - foreach(byte h in hash) - sha256Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha256Output.Append(h.ToString("x2")); return sha256Output.ToString(); } diff --git a/Aaru.Checksums/SHA384Context.cs b/Aaru.Checksums/SHA384Context.cs index 73b6aeef9..cb5abe884 100644 --- a/Aaru.Checksums/SHA384Context.cs +++ b/Aaru.Checksums/SHA384Context.cs @@ -90,11 +90,9 @@ public sealed class Sha384Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha384Output = new StringBuilder(); - if(_provider.Hash is null) - return null; + if(_provider.Hash is null) return null; - foreach(byte h in _provider.Hash) - sha384Output.Append(h.ToString("x2")); + foreach(byte h in _provider.Hash) sha384Output.Append(h.ToString("x2")); return sha384Output.ToString(); } @@ -103,6 +101,7 @@ public sealed class Sha384Context : IChecksum /// Gets the hash of a file /// File path. + // ReSharper disable once ReturnTypeCanBeEnumerable.Global public static byte[] File(string filename) { @@ -124,8 +123,7 @@ public sealed class Sha384Context : IChecksum hash = localSha384Provider.ComputeHash(fileStream); var sha384Output = new StringBuilder(); - foreach(byte h in hash) - sha384Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha384Output.Append(h.ToString("x2")); fileStream.Close(); @@ -142,8 +140,7 @@ public sealed class Sha384Context : IChecksum hash = localSha384Provider.ComputeHash(data, 0, (int)len); var sha384Output = new StringBuilder(); - foreach(byte h in hash) - sha384Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha384Output.Append(h.ToString("x2")); return sha384Output.ToString(); } diff --git a/Aaru.Checksums/SHA512Context.cs b/Aaru.Checksums/SHA512Context.cs index 203ebde8f..02d2a6407 100644 --- a/Aaru.Checksums/SHA512Context.cs +++ b/Aaru.Checksums/SHA512Context.cs @@ -90,11 +90,9 @@ public sealed class Sha512Context : IChecksum _provider.TransformFinalBlock(Array.Empty(), 0, 0); var sha512Output = new StringBuilder(); - if(_provider.Hash is null) - return null; + if(_provider.Hash is null) return null; - foreach(byte h in _provider.Hash) - sha512Output.Append(h.ToString("x2")); + foreach(byte h in _provider.Hash) sha512Output.Append(h.ToString("x2")); return sha512Output.ToString(); } @@ -123,8 +121,7 @@ public sealed class Sha512Context : IChecksum hash = localSha512Provider.ComputeHash(fileStream); var sha512Output = new StringBuilder(); - foreach(byte h in hash) - sha512Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha512Output.Append(h.ToString("x2")); fileStream.Close(); @@ -141,8 +138,7 @@ public sealed class Sha512Context : IChecksum hash = localSha512Provider.ComputeHash(data, 0, (int)len); var sha512Output = new StringBuilder(); - foreach(byte h in hash) - sha512Output.Append(h.ToString("x2")); + foreach(byte h in hash) sha512Output.Append(h.ToString("x2")); return sha512Output.ToString(); } diff --git a/Aaru.Checksums/SpamSumContext.cs b/Aaru.Checksums/SpamSumContext.cs index 6c0db8c61..53faefeef 100644 --- a/Aaru.Checksums/SpamSumContext.cs +++ b/Aaru.Checksums/SpamSumContext.cs @@ -76,8 +76,7 @@ public sealed class SpamSumContext : IChecksum Bh = new BlockhashContext[NUM_BLOCKHASHES] }; - for(var i = 0; i < NUM_BLOCKHASHES; i++) - _self.Bh[i].Digest = new byte[SPAMSUM_LENGTH]; + for(var i = 0; i < NUM_BLOCKHASHES; i++) _self.Bh[i].Digest = new byte[SPAMSUM_LENGTH]; _self.Bhstart = 0; _self.Bhend = 1; @@ -109,8 +108,7 @@ public sealed class SpamSumContext : IChecksum { _self.TotalSize += len; - for(var i = 0; i < len; i++) - fuzzy_engine_step(data[i]); + for(var i = 0; i < len; i++) fuzzy_engine_step(data[i]); } /// @@ -205,8 +203,7 @@ public sealed class SpamSumContext : IChecksum [MethodImpl(MethodImplOptions.AggressiveInlining)] void fuzzy_try_reduce_blockhash() { - if(_self.Bhstart >= _self.Bhend) - throw new Exception(Localization.Assertion_failed); + if(_self.Bhstart >= _self.Bhend) throw new Exception(Localization.Assertion_failed); if(_self.Bhend - _self.Bhstart < 2) /* Need at least two working hashes. */ @@ -254,8 +251,7 @@ public sealed class SpamSumContext : IChecksum /* 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) - 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]; @@ -271,8 +267,7 @@ public sealed class SpamSumContext : IChecksum _self.Bh[i].Digest[++_self.Bh[i].Dlen] = 0; _self.Bh[i].H = HASH_INIT; - if(_self.Bh[i].Dlen >= SPAMSUM_LENGTH / 2) - continue; + if(_self.Bh[i].Dlen >= SPAMSUM_LENGTH / 2) continue; _self.Bh[i].Halfh = HASH_INIT; _self.Bh[i].Halfdigest = 0; @@ -301,19 +296,15 @@ public sealed class SpamSumContext : IChecksum { ++bi; - if(bi >= NUM_BLOCKHASHES) - throw new OverflowException(Localization.The_input_exceeds_data_types); + if(bi >= NUM_BLOCKHASHES) throw new OverflowException(Localization.The_input_exceeds_data_types); } /* Adapt blocksize guess to actual digest length. */ - while(bi >= _self.Bhend) - --bi; + while(bi >= _self.Bhend) --bi; - while(bi > _self.Bhstart && _self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) - --bi; + while(bi > _self.Bhstart && _self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) --bi; - if(bi > 0 && _self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) - throw new Exception(Localization.Assertion_failed); + if(bi > 0 && _self.Bh[bi].Dlen < SPAMSUM_LENGTH / 2) throw new Exception(Localization.Assertion_failed); sb.Append($"{SSDEEP_BS(bi)}:"); int i = Encoding.ASCII.GetBytes(sb.ToString()).Length; @@ -322,8 +313,7 @@ public sealed class SpamSumContext : IChecksum /* Maybe snprintf has set errno here? */ throw new OverflowException(Localization.The_input_exceeds_data_types); - if(i >= remain) - throw new Exception(Localization.Assertion_failed); + if(i >= remain) throw new Exception(Localization.Assertion_failed); remain -= i; @@ -333,8 +323,7 @@ public sealed class SpamSumContext : IChecksum i = (int)_self.Bh[bi].Dlen; - if(i > remain) - throw new Exception(Localization.Assertion_failed); + if(i > remain) throw new Exception(Localization.Assertion_failed); Array.Copy(_self.Bh[bi].Digest, 0, result, resultOff, i); resultOff += i; @@ -342,8 +331,7 @@ public sealed class SpamSumContext : IChecksum if(h != 0) { - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); result[resultOff] = _b64[_self.Bh[bi].H % 64]; @@ -358,8 +346,7 @@ public sealed class SpamSumContext : IChecksum } else if(_self.Bh[bi].Digest[i] != 0) { - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); result[resultOff] = _self.Bh[bi].Digest[i]; @@ -373,8 +360,7 @@ public sealed class SpamSumContext : IChecksum } } - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); result[resultOff++] = 0x3A; // ':' --remain; @@ -384,8 +370,7 @@ public sealed class SpamSumContext : IChecksum ++bi; i = (int)_self.Bh[bi].Dlen; - if(i > remain) - throw new Exception(Localization.Assertion_failed); + if(i > remain) throw new Exception(Localization.Assertion_failed); Array.Copy(_self.Bh[bi].Digest, 0, result, resultOff, i); resultOff += i; @@ -393,8 +378,7 @@ public sealed class SpamSumContext : IChecksum if(h != 0) { - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); h = _self.Bh[bi].Halfh; result[resultOff] = _b64[h % 64]; @@ -414,8 +398,7 @@ public sealed class SpamSumContext : IChecksum if(i != 0) { - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); result[resultOff] = (byte)i; @@ -432,11 +415,9 @@ public sealed class SpamSumContext : IChecksum } else if(h != 0) { - if(_self.Bh[bi].Dlen != 0) - throw new Exception(Localization.Assertion_failed); + if(_self.Bh[bi].Dlen != 0) throw new Exception(Localization.Assertion_failed); - if(remain <= 0) - throw new Exception(Localization.Assertion_failed); + if(remain <= 0) throw new Exception(Localization.Assertion_failed); result[resultOff++] = _b64[_self.Bh[bi].H % 64]; /* No need to bother with FUZZY_FLAG_ELIMSEQ, because this @@ -490,8 +471,7 @@ public sealed class SpamSumContext : IChecksum // LINQ is six times slower foreach(byte c in cString) { - if(c == 0) - break; + if(c == 0) break; count++; } diff --git a/Aaru.CommonTypes/AaruMetadata/AaruMetadata.cs b/Aaru.CommonTypes/AaruMetadata/AaruMetadata.cs index 123aa68de..4fc00fd8c 100644 --- a/Aaru.CommonTypes/AaruMetadata/AaruMetadata.cs +++ b/Aaru.CommonTypes/AaruMetadata/AaruMetadata.cs @@ -48,6 +48,7 @@ namespace Aaru.CommonTypes.AaruMetadata; [JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] [JsonSerializable(typeof(MetadataJson))] + // ReSharper disable once PartialTypeWithSinglePart public partial class MetadataJsonContext : JsonSerializerContext; @@ -89,8 +90,7 @@ public class Metadata [Obsolete("Will be removed in Aaru 7")] public static implicit operator Metadata(CICMMetadataType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var metadata = new Metadata { @@ -114,32 +114,28 @@ public class Metadata { metadata.Barcodes = new List(); - foreach(Schemas.BarcodeType code in cicm.Barcodes) - metadata.Barcodes.Add(code); + foreach(Schemas.BarcodeType code in cicm.Barcodes) metadata.Barcodes.Add(code); } if(cicm.Magazine is not null) { metadata.Magazines = new List(); - foreach(MagazineType magazine in cicm.Magazine) - metadata.Magazines.Add(magazine); + foreach(MagazineType magazine in cicm.Magazine) metadata.Magazines.Add(magazine); } if(cicm.Book is not null) { metadata.Books = new List(); - foreach(BookType book in cicm.Book) - metadata.Books.Add(book); + foreach(BookType book in cicm.Book) metadata.Books.Add(book); } if(cicm.Languages is not null) { metadata.Languages = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Languages) - metadata.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Languages) metadata.Languages.Add((Language)lng); } if(cicm.Architectures is not null) @@ -162,57 +158,49 @@ public class Metadata { metadata.UserManuals = new List(); - foreach(UserManualType manual in cicm.UserManual) - metadata.UserManuals.Add(manual); + foreach(UserManualType manual in cicm.UserManual) metadata.UserManuals.Add(manual); } if(cicm.OpticalDisc is not null) { metadata.OpticalDiscs = new List(); - foreach(OpticalDiscType disc in cicm.OpticalDisc) - metadata.OpticalDiscs.Add(disc); + foreach(OpticalDiscType disc in cicm.OpticalDisc) metadata.OpticalDiscs.Add(disc); } if(cicm.Advertisement is not null) { metadata.Advertisements = new List(); - foreach(AdvertisementType adv in cicm.Advertisement) - metadata.Advertisements.Add(adv); + foreach(AdvertisementType adv in cicm.Advertisement) metadata.Advertisements.Add(adv); } if(cicm.LinearMedia is not null) { metadata.LinearMedias = new List(); - foreach(LinearMediaType media in cicm.LinearMedia) - metadata.LinearMedias.Add(media); + foreach(LinearMediaType media in cicm.LinearMedia) metadata.LinearMedias.Add(media); } if(cicm.PCICard is not null) { metadata.PciCards = new List(); - foreach(PCIType pci in cicm.PCICard) - metadata.PciCards.Add(pci); + foreach(PCIType pci in cicm.PCICard) metadata.PciCards.Add(pci); } if(cicm.BlockMedia is not null) { metadata.BlockMedias = new List(); - foreach(BlockMediaType media in cicm.BlockMedia) - metadata.BlockMedias.Add(media); + foreach(BlockMediaType media in cicm.BlockMedia) metadata.BlockMedias.Add(media); } - if(cicm.AudioMedia is null) - return metadata; + if(cicm.AudioMedia is null) return metadata; metadata.AudioMedias = new List(); - foreach(AudioMediaType media in cicm.AudioMedia) - metadata.AudioMedias.Add(media); + foreach(AudioMediaType media in cicm.AudioMedia) metadata.AudioMedias.Add(media); return metadata; } diff --git a/Aaru.CommonTypes/AaruMetadata/Advertisement.cs b/Aaru.CommonTypes/AaruMetadata/Advertisement.cs index 6b0584de3..461c19735 100644 --- a/Aaru.CommonTypes/AaruMetadata/Advertisement.cs +++ b/Aaru.CommonTypes/AaruMetadata/Advertisement.cs @@ -63,8 +63,7 @@ public class Advertisement [Obsolete("Will be removed in Aaru 7")] public static implicit operator Advertisement(AdvertisementType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var adv = new Advertisement { @@ -82,34 +81,29 @@ public class Advertisement { adv.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - adv.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) adv.Checksums.Add(chk); } if(cicm.AudioTrack is not null) { adv.AudioTracks = new List(); - foreach(AudioTracksType trk in cicm.AudioTrack) - adv.AudioTracks.Add(trk); + foreach(AudioTracksType trk in cicm.AudioTrack) adv.AudioTracks.Add(trk); } if(cicm.VideoTrack is not null) { adv.VideoTracks = new List(); - foreach(VideoTracksType trk in cicm.VideoTrack) - adv.VideoTracks.Add(trk); + foreach(VideoTracksType trk in cicm.VideoTrack) adv.VideoTracks.Add(trk); } - if(cicm.SubtitleTrack is null) - return adv; + if(cicm.SubtitleTrack is null) return adv; { adv.SubtitleTracks = new List(); - foreach(SubtitleTracksType trk in cicm.SubtitleTrack) - adv.SubtitleTracks.Add(trk); + foreach(SubtitleTracksType trk in cicm.SubtitleTrack) adv.SubtitleTracks.Add(trk); } return adv; diff --git a/Aaru.CommonTypes/AaruMetadata/AudioMedia.cs b/Aaru.CommonTypes/AaruMetadata/AudioMedia.cs index 12ea1397f..476227c87 100644 --- a/Aaru.CommonTypes/AaruMetadata/AudioMedia.cs +++ b/Aaru.CommonTypes/AaruMetadata/AudioMedia.cs @@ -65,8 +65,7 @@ public class AudioMedia [Obsolete("Will be removed in Aaru 7")] public static implicit operator AudioMedia(AudioMediaType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var media = new AudioMedia { @@ -87,25 +86,21 @@ public class AudioMedia { media.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - media.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) media.Checksums.Add(chk); } if(cicm.Block is not null) { media.Blocks = new List(); - foreach(AudioBlockType blk in cicm.Block) - media.Blocks.Add(blk); + foreach(AudioBlockType blk in cicm.Block) media.Blocks.Add(blk); } - if(cicm.DumpHardwareArray is null) - return media; + if(cicm.DumpHardwareArray is null) return media; media.DumpHardware = new List(); - foreach(DumpHardwareType hw in cicm.DumpHardwareArray) - media.DumpHardware.Add(hw); + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) media.DumpHardware.Add(hw); return media; } @@ -122,8 +117,7 @@ public class AudioBlock [Obsolete("Will be removed in Aaru 7")] public static implicit operator AudioBlock(AudioBlockType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var blk = new AudioBlock { @@ -133,13 +127,11 @@ public class AudioBlock Format = cicm.Format }; - if(cicm.Checksums is null) - return blk; + if(cicm.Checksums is null) return blk; blk.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - blk.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) blk.Checksums.Add(chk); return blk; } diff --git a/Aaru.CommonTypes/AaruMetadata/AudioVideo.cs b/Aaru.CommonTypes/AaruMetadata/AudioVideo.cs index d2a682f32..e80b0da3c 100644 --- a/Aaru.CommonTypes/AaruMetadata/AudioVideo.cs +++ b/Aaru.CommonTypes/AaruMetadata/AudioVideo.cs @@ -60,8 +60,7 @@ public class AudioTrack [Obsolete("Will be removed in Aaru 7")] public static implicit operator AudioTrack(AudioTracksType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var trk = new AudioTrack { @@ -73,13 +72,11 @@ public class AudioTrack MeanBitrate = cicm.MeanBitrate }; - if(cicm.Languages is null) - return trk; + if(cicm.Languages is null) return trk; trk.Languages = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Languages) - trk.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Languages) trk.Languages.Add((Language)lng); return trk; } @@ -100,8 +97,7 @@ public class VideoTrack [Obsolete("Will be removed in Aaru 7")] public static implicit operator VideoTrack(VideoTracksType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var trk = new VideoTrack { @@ -113,13 +109,11 @@ public class VideoTrack ThreeD = cicm.ThreeD }; - if(cicm.Languages is null) - return trk; + if(cicm.Languages is null) return trk; trk.Languages = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Languages) - trk.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Languages) trk.Languages.Add((Language)lng); return trk; } @@ -134,8 +128,7 @@ public class SubtitleTrack [Obsolete("Will be removed in Aaru 7")] public static implicit operator SubtitleTrack(SubtitleTracksType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var sub = new SubtitleTrack { @@ -143,13 +136,11 @@ public class SubtitleTrack Codec = cicm.Codec }; - if(cicm.Languages is null) - return sub; + if(cicm.Languages is null) return sub; sub.Languages = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Languages) - sub.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Languages) sub.Languages.Add((Language)lng); return sub; } @@ -167,8 +158,7 @@ public class Recording [Obsolete("Will be removed in Aaru 7")] public static implicit operator Recording(RecordingType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var recording = new Recording { @@ -179,13 +169,11 @@ public class Recording Coordinates = cicm.Coordinates }; - if(cicm.Software is null) - return recording; + if(cicm.Software is null) return recording; recording.Software = new List(); - foreach(SoftwareType sw in cicm.Software) - recording.Software.Add(sw); + foreach(SoftwareType sw in cicm.Software) recording.Software.Add(sw); return recording; } diff --git a/Aaru.CommonTypes/AaruMetadata/BlockMedia.cs b/Aaru.CommonTypes/AaruMetadata/BlockMedia.cs index 037bf8e89..a1911b6dc 100644 --- a/Aaru.CommonTypes/AaruMetadata/BlockMedia.cs +++ b/Aaru.CommonTypes/AaruMetadata/BlockMedia.cs @@ -87,8 +87,7 @@ public class BlockMedia [Obsolete("Will be removed in Aaru 7")] public static implicit operator BlockMedia(BlockMediaType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var media = new BlockMedia { @@ -127,24 +126,21 @@ public class BlockMedia { media.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - media.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) media.Checksums.Add(chk); } if(cicm.ContentChecksums is not null) { media.ContentChecksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.ContentChecksums) - media.ContentChecksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.ContentChecksums) media.ContentChecksums.Add(chk); } if(cicm.VariableBlockSize is not null) { media.VariableBlockSize = new List(); - foreach(BlockSizeType blkSize in cicm.VariableBlockSize) - media.VariableBlockSize.Add(blkSize); + foreach(BlockSizeType blkSize in cicm.VariableBlockSize) media.VariableBlockSize.Add(blkSize); } if(cicm.TapeInformation is not null) @@ -159,17 +155,14 @@ public class BlockMedia { media.FileSystemInformation = new List(); - foreach(PartitionType fsInfo in cicm.FileSystemInformation) - media.FileSystemInformation.Add(fsInfo); + foreach(PartitionType fsInfo in cicm.FileSystemInformation) media.FileSystemInformation.Add(fsInfo); } - if(cicm.DumpHardwareArray is null) - return media; + if(cicm.DumpHardwareArray is null) return media; media.DumpHardware = new List(); - foreach(DumpHardwareType hw in cicm.DumpHardwareArray) - media.DumpHardware.Add(hw); + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) media.DumpHardware.Add(hw); return media; } @@ -191,8 +184,7 @@ public class BlockTrack [Obsolete("Will be removed in Aaru 7")] public static implicit operator BlockTrack(BlockTrackType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var trk = new BlockTrack { @@ -207,13 +199,11 @@ public class BlockTrack Format = cicm.Format }; - if(cicm.Checksums is null) - return trk; + if(cicm.Checksums is null) return trk; trk.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - trk.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) trk.Checksums.Add(chk); return trk; } diff --git a/Aaru.CommonTypes/AaruMetadata/Book.cs b/Aaru.CommonTypes/AaruMetadata/Book.cs index 960b749d6..17e12f5de 100644 --- a/Aaru.CommonTypes/AaruMetadata/Book.cs +++ b/Aaru.CommonTypes/AaruMetadata/Book.cs @@ -61,8 +61,7 @@ public class Book [Obsolete("Will be removed in Aaru 7")] public static implicit operator Book(BookType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var book = new Book { @@ -80,17 +79,14 @@ public class Book { book.Barcodes = new List(); - foreach(Schemas.BarcodeType code in cicm.Barcodes) - book.Barcodes.Add(code); + foreach(Schemas.BarcodeType code in cicm.Barcodes) book.Barcodes.Add(code); } - if(cicm.Language is null) - return book; + if(cicm.Language is null) return book; book.Languages = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Language) - book.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Language) book.Languages.Add((Language)lng); return book; } diff --git a/Aaru.CommonTypes/AaruMetadata/Contents.cs b/Aaru.CommonTypes/AaruMetadata/Contents.cs index ffca286fa..0950a46e2 100644 --- a/Aaru.CommonTypes/AaruMetadata/Contents.cs +++ b/Aaru.CommonTypes/AaruMetadata/Contents.cs @@ -54,8 +54,7 @@ public class FilesystemContents [Obsolete("Will be removed in Aaru 7")] public static implicit operator FilesystemContents(FilesystemContentsType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var fs = new FilesystemContents { @@ -66,17 +65,14 @@ public class FilesystemContents { fs.Files = new List(); - foreach(ContentsFileType file in cicm.File) - fs.Files.Add(file); + foreach(ContentsFileType file in cicm.File) fs.Files.Add(file); } - if(cicm.Directory is null) - return fs; + if(cicm.Directory is null) return fs; fs.Directories = new List(); - foreach(DirectoryType dir in cicm.Directory) - fs.Directories.Add(dir); + foreach(DirectoryType dir in cicm.Directory) fs.Directories.Add(dir); return fs; } @@ -104,8 +100,7 @@ public class ContentsFile [Obsolete("Will be removed in Aaru 7")] public static implicit operator ContentsFile(ContentsFileType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var file = new ContentsFile { @@ -129,17 +124,14 @@ public class ContentsFile { file.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - file.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) file.Checksums.Add(chk); } - if(cicm.ExtendedAttributes is null) - return file; + if(cicm.ExtendedAttributes is null) return file; file.ExtendedAttributes = new List(); - foreach(ExtendedAttributeType xa in cicm.ExtendedAttributes) - file.ExtendedAttributes.Add(xa); + foreach(ExtendedAttributeType xa in cicm.ExtendedAttributes) file.ExtendedAttributes.Add(xa); return file; } @@ -154,8 +146,7 @@ public class ExtendedAttribute [Obsolete("Will be removed in Aaru 7")] public static implicit operator ExtendedAttribute(ExtendedAttributeType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var xa = new ExtendedAttribute { @@ -163,13 +154,11 @@ public class ExtendedAttribute Length = cicm.length }; - if(cicm.Checksums is null) - return xa; + if(cicm.Checksums is null) return xa; xa.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - xa.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) xa.Checksums.Add(chk); return xa; } @@ -196,8 +185,7 @@ public class Directory [Obsolete("Will be removed in Aaru 7")] public static implicit operator Directory(DirectoryType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var dir = new Directory { @@ -220,17 +208,14 @@ public class Directory { dir.Directories = new List(); - foreach(DirectoryType d in cicm.Directory) - dir.Directories.Add(d); + foreach(DirectoryType d in cicm.Directory) dir.Directories.Add(d); } - if(cicm.File is null) - return dir; + if(cicm.File is null) return dir; dir.Files = new List(); - foreach(ContentsFileType file in cicm.File) - dir.Files.Add(file); + foreach(ContentsFileType file in cicm.File) dir.Files.Add(file); return dir; } diff --git a/Aaru.CommonTypes/AaruMetadata/Dimensions.cs b/Aaru.CommonTypes/AaruMetadata/Dimensions.cs index cc5017f1b..3c1c53baa 100644 --- a/Aaru.CommonTypes/AaruMetadata/Dimensions.cs +++ b/Aaru.CommonTypes/AaruMetadata/Dimensions.cs @@ -56,9 +56,10 @@ public class Dimensions ? null : new Dimensions { - Diameter = cicm.DiameterSpecified - ? cicm.Diameter - : null, + Diameter = + cicm.DiameterSpecified + ? cicm.Diameter + : null, Height = cicm.HeightSpecified ? cicm.Height : null, @@ -77,7 +78,7 @@ public class Dimensions switch(mediaType) { - #region 5.25" floppy disk +#region 5.25" floppy disk case MediaType.Apple32SS: case MediaType.Apple32DS: @@ -122,9 +123,9 @@ public class Dimensions return dmns; - #endregion 5.25" floppy disk +#endregion 5.25" floppy disk - #region 3.5" floppy disk +#region 3.5" floppy disk case MediaType.AppleSonySS: case MediaType.AppleSonyDS: @@ -159,9 +160,9 @@ public class Dimensions return dmns; - #endregion 3.5" floppy disk +#endregion 3.5" floppy disk - #region 8" floppy disk +#region 8" floppy disk case MediaType.IBM23FD: case MediaType.IBM33FD_128: @@ -190,9 +191,9 @@ public class Dimensions return dmns; - #endregion 8" floppy disk +#endregion 8" floppy disk - #region 356mm magneto optical +#region 356mm magneto optical case MediaType.ECMA_260: case MediaType.ECMA_260_Double: @@ -205,9 +206,9 @@ public class Dimensions return dmns; - #endregion 356mm magneto optical +#endregion 356mm magneto optical - #region 300mm magneto optical +#region 300mm magneto optical case MediaType.ECMA_189: case MediaType.ECMA_190: @@ -221,9 +222,9 @@ public class Dimensions return dmns; - #endregion 300mm magneto optical +#endregion 300mm magneto optical - #region 5.25" magneto optical +#region 5.25" magneto optical case MediaType.ECMA_153: case MediaType.ECMA_153_512: @@ -258,9 +259,9 @@ public class Dimensions return dmns; - #endregion 5.25" magneto optical +#endregion 5.25" magneto optical - #region 3.5" magneto optical +#region 3.5" magneto optical case MediaType.ECMA_154: case MediaType.ECMA_201: @@ -279,7 +280,7 @@ public class Dimensions return dmns; - #endregion 3.5" magneto optical +#endregion 3.5" magneto optical case MediaType.PD650: case MediaType.PD650_WORM: @@ -941,9 +942,9 @@ public class Dimensions dmns.Thickness = 16.6; return dmns; - #pragma warning disable CS0612 // Type or member is obsolete +#pragma warning disable CS0612 // Type or member is obsolete case MediaType.Bernoulli: - #pragma warning restore CS0612 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete case MediaType.Bernoulli10: case MediaType.Bernoulli20: dmns.Height = 280; @@ -953,9 +954,9 @@ public class Dimensions dmns.Thickness = 18; return dmns; - #pragma warning disable CS0612 // Type or member is obsolete +#pragma warning disable CS0612 // Type or member is obsolete case MediaType.Bernoulli2: - #pragma warning restore CS0612 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete case MediaType.BernoulliBox2_20: case MediaType.Bernoulli35: case MediaType.Bernoulli44: @@ -1009,7 +1010,7 @@ public class Dimensions return dmns; - #region CD/DVD/BD +#region CD/DVD/BD case MediaType.CDDA: case MediaType.CDG: @@ -1111,9 +1112,9 @@ public class Dimensions return dmns; - #endregion CD/DVD/BD +#endregion CD/DVD/BD - #region Apple Hard Disks +#region Apple Hard Disks // TODO: Find Apple Widget size case MediaType.AppleProfile: @@ -1133,7 +1134,7 @@ public class Dimensions return dmns; - #endregion Apple Hard Disks +#endregion Apple Hard Disks case MediaType.UMD: dmns.Height = 64; diff --git a/Aaru.CommonTypes/AaruMetadata/Dump.cs b/Aaru.CommonTypes/AaruMetadata/Dump.cs index 0f7e6144e..dbb2f0948 100644 --- a/Aaru.CommonTypes/AaruMetadata/Dump.cs +++ b/Aaru.CommonTypes/AaruMetadata/Dump.cs @@ -71,8 +71,7 @@ public class Dump [Obsolete("Will be removed in Aaru 7")] public static implicit operator Dump(DumpType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; Dump dump = new() { @@ -80,13 +79,11 @@ public class Dump Size = cicm.Size }; - if(cicm.Checksums is null) - return dump; + if(cicm.Checksums is null) return dump; dump.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - dump.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) dump.Checksums.Add(chk); return dump; } @@ -102,8 +99,7 @@ public class Border [Obsolete("Will be removed in Aaru 7")] public static implicit operator Border(BorderType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var border = new Border { @@ -112,13 +108,11 @@ public class Border Session = cicm.sessionSpecified ? cicm.session : null }; - if(cicm.Checksums is null) - return border; + if(cicm.Checksums is null) return border; border.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - border.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) border.Checksums.Add(chk); return border; } diff --git a/Aaru.CommonTypes/AaruMetadata/DumpHardware.cs b/Aaru.CommonTypes/AaruMetadata/DumpHardware.cs index ec28aae1a..f3fa1c4dc 100644 --- a/Aaru.CommonTypes/AaruMetadata/DumpHardware.cs +++ b/Aaru.CommonTypes/AaruMetadata/DumpHardware.cs @@ -58,8 +58,7 @@ public class DumpHardware [Obsolete("Will be removed in Aaru 7")] public static implicit operator DumpHardware(DumpHardwareType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var hw = new DumpHardware { @@ -71,13 +70,11 @@ public class DumpHardware Software = cicm.Software }; - if(cicm.Extents is null) - return hw; + if(cicm.Extents is null) return hw; hw.Extents = new List(); - foreach(ExtentType ext in cicm.Extents) - hw.Extents.Add(ext); + foreach(ExtentType ext in cicm.Extents) hw.Extents.Add(ext); return hw; } diff --git a/Aaru.CommonTypes/AaruMetadata/FileSystem.cs b/Aaru.CommonTypes/AaruMetadata/FileSystem.cs index c437bb789..2c66263a0 100644 --- a/Aaru.CommonTypes/AaruMetadata/FileSystem.cs +++ b/Aaru.CommonTypes/AaruMetadata/FileSystem.cs @@ -87,9 +87,10 @@ public class FileSystem : null, ClusterSize = cicm.ClusterSize, Clusters = cicm.Clusters, - Files = cicm.FilesSpecified - ? cicm.Files - : null, + Files = + cicm.FilesSpecified + ? cicm.Files + : null, Bootable = cicm.Bootable, VolumeSerial = cicm.VolumeSerial, VolumeName = cicm.VolumeName, diff --git a/Aaru.CommonTypes/AaruMetadata/Layers.cs b/Aaru.CommonTypes/AaruMetadata/Layers.cs index 83c949028..08df4f17a 100644 --- a/Aaru.CommonTypes/AaruMetadata/Layers.cs +++ b/Aaru.CommonTypes/AaruMetadata/Layers.cs @@ -55,21 +55,18 @@ public class Layers [Obsolete("Will be removed in Aaru 7")] public static implicit operator Layers(LayersType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var layers = new Layers { Type = cicm.typeSpecified ? (LayerType)cicm.type : null }; - if(cicm.Sectors is null) - return layers; + if(cicm.Sectors is null) return layers; layers.Sectors = new List(); - foreach(SectorsType sec in cicm.Sectors) - layers.Sectors.Add(sec); + foreach(SectorsType sec in cicm.Sectors) layers.Sectors.Add(sec); return layers; } diff --git a/Aaru.CommonTypes/AaruMetadata/LinearMedia.cs b/Aaru.CommonTypes/AaruMetadata/LinearMedia.cs index 37533b534..b9dbc1bf3 100644 --- a/Aaru.CommonTypes/AaruMetadata/LinearMedia.cs +++ b/Aaru.CommonTypes/AaruMetadata/LinearMedia.cs @@ -70,8 +70,7 @@ public class LinearMedia [Obsolete("Will be removed in Aaru 7")] public static implicit operator LinearMedia(LinearMediaType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var linearMedia = new LinearMedia { @@ -97,25 +96,21 @@ public class LinearMedia { linearMedia.ImageChecksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.ImageChecksums) - linearMedia.ImageChecksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.ImageChecksums) linearMedia.ImageChecksums.Add(chk); } if(cicm.Checksums is not null) { linearMedia.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - linearMedia.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) linearMedia.Checksums.Add(chk); } - if(cicm.DumpHardwareArray is null) - return linearMedia; + if(cicm.DumpHardwareArray is null) return linearMedia; linearMedia.DumpHardware = new List(); - foreach(DumpHardwareType hw in cicm.DumpHardwareArray) - linearMedia.DumpHardware.Add(hw); + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) linearMedia.DumpHardware.Add(hw); return linearMedia; } diff --git a/Aaru.CommonTypes/AaruMetadata/Magazine.cs b/Aaru.CommonTypes/AaruMetadata/Magazine.cs index 31fd8280b..230eb8ed6 100644 --- a/Aaru.CommonTypes/AaruMetadata/Magazine.cs +++ b/Aaru.CommonTypes/AaruMetadata/Magazine.cs @@ -61,8 +61,7 @@ public class Magazine [Obsolete("Will be removed in Aaru 7")] public static implicit operator Magazine(MagazineType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var magazine = new Magazine { @@ -79,15 +78,12 @@ public class Magazine { magazine.Barcodes = new List(); - foreach(Schemas.BarcodeType code in cicm.Barcodes) - magazine.Barcodes.Add(code); + foreach(Schemas.BarcodeType code in cicm.Barcodes) magazine.Barcodes.Add(code); } - if(cicm.Language is null) - return magazine; + if(cicm.Language is null) return magazine; - foreach(LanguagesTypeLanguage lng in cicm.Language) - magazine.Languages.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Language) magazine.Languages.Add((Language)lng); return magazine; } diff --git a/Aaru.CommonTypes/AaruMetadata/OpticalDisc.cs b/Aaru.CommonTypes/AaruMetadata/OpticalDisc.cs index 37e4206a4..846570669 100644 --- a/Aaru.CommonTypes/AaruMetadata/OpticalDisc.cs +++ b/Aaru.CommonTypes/AaruMetadata/OpticalDisc.cs @@ -99,8 +99,7 @@ public class OpticalDisc [Obsolete("Will be removed in Aaru 7")] public static implicit operator OpticalDisc(OpticalDiscType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var disc = new OpticalDisc { @@ -145,89 +144,77 @@ public class OpticalDisc { disc.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - disc.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) disc.Checksums.Add(chk); } if(cicm.RingCode is not null) { disc.RingCode = new List(); - foreach(LayeredTextType lt in cicm.RingCode) - disc.RingCode.Add(lt); + foreach(LayeredTextType lt in cicm.RingCode) disc.RingCode.Add(lt); } if(cicm.MasteringSID is not null) { disc.MasteringSid = new List(); - foreach(LayeredTextType lt in cicm.MasteringSID) - disc.MasteringSid.Add(lt); + foreach(LayeredTextType lt in cicm.MasteringSID) disc.MasteringSid.Add(lt); } if(cicm.Toolstamp is not null) { disc.Toolstamp = new List(); - foreach(LayeredTextType lt in cicm.Toolstamp) - disc.Toolstamp.Add(lt); + foreach(LayeredTextType lt in cicm.Toolstamp) disc.Toolstamp.Add(lt); } if(cicm.MouldSID is not null) { disc.MouldSid = new List(); - foreach(LayeredTextType lt in cicm.MouldSID) - disc.MouldSid.Add(lt); + foreach(LayeredTextType lt in cicm.MouldSID) disc.MouldSid.Add(lt); } if(cicm.MouldText is not null) { disc.MouldText = new List(); - foreach(LayeredTextType lt in cicm.MouldText) - disc.MouldText.Add(lt); + foreach(LayeredTextType lt in cicm.MouldText) disc.MouldText.Add(lt); } if(cicm.FirstTrackPregrap is not null) { disc.FirstTrackPregrap = new List(); - foreach(BorderType lt in cicm.FirstTrackPregrap) - disc.FirstTrackPregrap.Add(lt); + foreach(BorderType lt in cicm.FirstTrackPregrap) disc.FirstTrackPregrap.Add(lt); } if(cicm.LeadIn is not null) { disc.LeadIn = new List(); - foreach(BorderType lt in cicm.LeadIn) - disc.LeadIn.Add(lt); + foreach(BorderType lt in cicm.LeadIn) disc.LeadIn.Add(lt); } if(cicm.LeadOut is not null) { disc.LeadOut = new List(); - foreach(BorderType lt in cicm.LeadOut) - disc.LeadOut.Add(lt); + foreach(BorderType lt in cicm.LeadOut) disc.LeadOut.Add(lt); } if(cicm.Track is not null) { disc.Track = new List(); - foreach(Schemas.TrackType lt in cicm.Track) - disc.Track.Add(lt); + foreach(Schemas.TrackType lt in cicm.Track) disc.Track.Add(lt); } - if(cicm.DumpHardwareArray is null) - return disc; + if(cicm.DumpHardwareArray is null) return disc; disc.DumpHardware = new List(); - foreach(DumpHardwareType hw in cicm.DumpHardwareArray) - disc.DumpHardware.Add(hw); + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) disc.DumpHardware.Add(hw); return disc; } @@ -255,8 +242,7 @@ public class Track [Obsolete("Will be removed in Aaru 7")] public static implicit operator Track(Schemas.TrackType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var trk = new Track { @@ -279,25 +265,21 @@ public class Track { trk.Indexes = new List(); - foreach(TrackIndexType idx in cicm.Indexes) - trk.Indexes.Add(idx); + foreach(TrackIndexType idx in cicm.Indexes) trk.Indexes.Add(idx); } if(cicm.Checksums is not null) { trk.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - trk.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) trk.Checksums.Add(chk); } - if(cicm.FileSystemInformation is null) - return trk; + if(cicm.FileSystemInformation is null) return trk; trk.FileSystemInformation = new List(); - foreach(PartitionType fs in cicm.FileSystemInformation) - trk.FileSystemInformation.Add(fs); + foreach(PartitionType fs in cicm.FileSystemInformation) trk.FileSystemInformation.Add(fs); return trk; } @@ -376,8 +358,7 @@ public class SubChannel [Obsolete("Will be removed in Aaru 7")] public static implicit operator SubChannel(SubChannelType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var subchannel = new SubChannel { @@ -385,13 +366,11 @@ public class SubChannel Size = cicm.Size }; - if(cicm.Checksums is null) - return subchannel; + if(cicm.Checksums is null) return subchannel; subchannel.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - subchannel.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) subchannel.Checksums.Add(chk); return subchannel; } diff --git a/Aaru.CommonTypes/AaruMetadata/PCMCIA.cs b/Aaru.CommonTypes/AaruMetadata/PCMCIA.cs index fab5b3dbf..e444b52bc 100644 --- a/Aaru.CommonTypes/AaruMetadata/PCMCIA.cs +++ b/Aaru.CommonTypes/AaruMetadata/PCMCIA.cs @@ -66,15 +66,16 @@ public class Pcmcia cicm.ManufacturerCodeSpecified ? cicm.ManufacturerCode : null, - CardCode = cicm.CardCodeSpecified - ? cicm.CardCode - : null, + CardCode = + cicm.CardCodeSpecified + ? cicm.CardCode + : null, Manufacturer = cicm.Manufacturer, ProductName = cicm.ProductName, AdditionalInformation = cicm.AdditionalInformation is null ? null - : new List(cicm. - AdditionalInformation) + : new List(cicm + .AdditionalInformation) }; } \ No newline at end of file diff --git a/Aaru.CommonTypes/AaruMetadata/Partition.cs b/Aaru.CommonTypes/AaruMetadata/Partition.cs index 9927b3784..21c11232e 100644 --- a/Aaru.CommonTypes/AaruMetadata/Partition.cs +++ b/Aaru.CommonTypes/AaruMetadata/Partition.cs @@ -58,8 +58,7 @@ public class Partition [Obsolete("Will be removed in Aaru 7")] public static implicit operator Partition(PartitionType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var part = new Partition { @@ -71,13 +70,11 @@ public class Partition Description = cicm.Description }; - if(cicm.FileSystems is null) - return part; + if(cicm.FileSystems is null) return part; part.FileSystems = new List(); - foreach(FileSystemType fs in cicm.FileSystems) - part.FileSystems.Add(fs); + foreach(FileSystemType fs in cicm.FileSystems) part.FileSystems.Add(fs); return part; } diff --git a/Aaru.CommonTypes/AaruMetadata/RequiredOperatingSystem.cs b/Aaru.CommonTypes/AaruMetadata/RequiredOperatingSystem.cs index de486ed02..a0b59bc4c 100644 --- a/Aaru.CommonTypes/AaruMetadata/RequiredOperatingSystem.cs +++ b/Aaru.CommonTypes/AaruMetadata/RequiredOperatingSystem.cs @@ -51,12 +51,11 @@ public class RequiredOperatingSystem public List Versions { get; set; } [Obsolete("Will be removed in Aaru 7")] - public static implicit operator RequiredOperatingSystem(RequiredOperatingSystemType cicm) => - cicm is null - ? null - : new RequiredOperatingSystem - { - Name = cicm.Name, - Versions = cicm.Version is null ? null : new List(cicm.Version) - }; + public static implicit operator RequiredOperatingSystem(RequiredOperatingSystemType cicm) => cicm is null + ? null + : new RequiredOperatingSystem + { + Name = cicm.Name, + Versions = cicm.Version is null ? null : new List(cicm.Version) + }; } \ No newline at end of file diff --git a/Aaru.CommonTypes/AaruMetadata/SCSI.cs b/Aaru.CommonTypes/AaruMetadata/SCSI.cs index de503f48e..d0c30e399 100644 --- a/Aaru.CommonTypes/AaruMetadata/SCSI.cs +++ b/Aaru.CommonTypes/AaruMetadata/SCSI.cs @@ -56,8 +56,7 @@ public class SCSI [Obsolete("Will be removed in Aaru 7")] public static implicit operator SCSI(SCSIType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var scsi = new SCSI { @@ -67,13 +66,11 @@ public class SCSI ModeSense10 = cicm.ModeSense10 }; - if(cicm.EVPD is null) - return cicm; + if(cicm.EVPD is null) return cicm; scsi.Evpds = new List(); - foreach(EVPDType evpd in cicm.EVPD) - scsi.Evpds.Add(evpd); + foreach(EVPDType evpd in cicm.EVPD) scsi.Evpds.Add(evpd); return scsi; } @@ -89,8 +86,7 @@ public class Evpd [Obsolete("Will be removed in Aaru 7")] public static implicit operator Evpd(EVPDType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var evpd = new Evpd { @@ -99,13 +95,11 @@ public class Evpd Page = cicm.pageSpecified ? cicm.page : null }; - if(cicm.Checksums is null) - return evpd; + if(cicm.Checksums is null) return evpd; evpd.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - evpd.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) evpd.Checksums.Add(chk); return evpd; } diff --git a/Aaru.CommonTypes/AaruMetadata/Scanning.cs b/Aaru.CommonTypes/AaruMetadata/Scanning.cs index 0fdd943c3..3528cab96 100644 --- a/Aaru.CommonTypes/AaruMetadata/Scanning.cs +++ b/Aaru.CommonTypes/AaruMetadata/Scanning.cs @@ -57,8 +57,7 @@ public class Scan [Obsolete("Will be removed in Aaru 7")] public static implicit operator Scan(ScanType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var scan = new Scan { @@ -69,33 +68,28 @@ public class Scan { scan.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - scan.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) scan.Checksums.Add(chk); } if(cicm.Scanner is not null) { scan.Scanner = new List(); - foreach(ScannerType scanner in cicm.Scanner) - scan.Scanner.Add(scanner); + foreach(ScannerType scanner in cicm.Scanner) scan.Scanner.Add(scanner); } if(cicm.ScanProcessing is not null) { scan.ScanProcessing = new List(); - foreach(ScanProcessingType processing in cicm.ScanProcessing) - scan.ScanProcessing.Add(processing); + foreach(ScanProcessingType processing in cicm.ScanProcessing) scan.ScanProcessing.Add(processing); } - if(cicm.OCR is null) - return scan; + if(cicm.OCR is null) return scan; scan.OCR = new List(); - foreach(OCRType ocr in cicm.OCR) - scan.OCR.Add(ocr); + foreach(OCRType ocr in cicm.OCR) scan.OCR.Add(ocr); return scan; } @@ -110,8 +104,7 @@ public class Cover [Obsolete("Will be removed in Aaru 7")] public static implicit operator Cover(CoverType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var cover = new Cover { @@ -119,13 +112,11 @@ public class Cover Thumbnail = cicm.Thumbnail }; - if(cicm.Checksums is null) - return cover; + if(cicm.Checksums is null) return cover; cover.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - cover.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) cover.Checksums.Add(chk); return cover; } @@ -203,8 +194,8 @@ public class CaseScan ? null : new CaseScan { - Element = (CaseScanElement)cicm. - CaseScanElement, + Element = (CaseScanElement)cicm + .CaseScanElement, Scan = cicm.Scan }; } @@ -233,8 +224,8 @@ public class MediaScan ? null : new MediaScan { - Element = (MediaScanElement)cicm. - MediaScanElement, + Element = (MediaScanElement)cicm + .MediaScanElement, Scan = cicm.Scan }; } @@ -301,8 +292,7 @@ public class OCR [Obsolete("Will be removed in Aaru 7")] public static implicit operator OCR(OCRType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var ocr = new OCR { @@ -311,13 +301,11 @@ public class OCR SoftwareVersion = cicm.SoftwareVersion }; - if(cicm.Language is null) - return ocr; + if(cicm.Language is null) return ocr; ocr.Language = new List(); - foreach(Language lng in cicm.Language) - ocr.Language.Add(lng); + foreach(Language lng in cicm.Language) ocr.Language.Add(lng); return ocr; } diff --git a/Aaru.CommonTypes/AaruMetadata/Tape.cs b/Aaru.CommonTypes/AaruMetadata/Tape.cs index e6c012562..8c15bb816 100644 --- a/Aaru.CommonTypes/AaruMetadata/Tape.cs +++ b/Aaru.CommonTypes/AaruMetadata/Tape.cs @@ -58,8 +58,7 @@ public class TapePartition [Obsolete("Will be removed in Aaru 7")] public static implicit operator TapePartition(TapePartitionType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; TapePartition partition = new() { @@ -74,17 +73,14 @@ public class TapePartition { partition.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - partition.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) partition.Checksums.Add(chk); } - if(cicm.File is null) - return partition; + if(cicm.File is null) return partition; partition.Files = new List(); - foreach(TapeFileType file in cicm.File) - partition.Files.Add(file); + foreach(TapeFileType file in cicm.File) partition.Files.Add(file); return partition; } @@ -103,8 +99,7 @@ public class TapeFile [Obsolete("Will be removed in Aaru 7")] public static implicit operator TapeFile(TapeFileType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var file = new TapeFile { @@ -116,13 +111,11 @@ public class TapeFile EndBlock = cicm.EndBlock }; - if(cicm.Checksums is null) - return file; + if(cicm.Checksums is null) return file; file.Checksums = new List(); - foreach(Schemas.ChecksumType chk in cicm.Checksums) - file.Checksums.Add(chk); + foreach(Schemas.ChecksumType chk in cicm.Checksums) file.Checksums.Add(chk); return file; } diff --git a/Aaru.CommonTypes/AaruMetadata/UserManual.cs b/Aaru.CommonTypes/AaruMetadata/UserManual.cs index 023d10936..bc0a74b3f 100644 --- a/Aaru.CommonTypes/AaruMetadata/UserManual.cs +++ b/Aaru.CommonTypes/AaruMetadata/UserManual.cs @@ -55,8 +55,7 @@ public class UserManual [Obsolete("Will be removed in Aaru 7")] public static implicit operator UserManual(UserManualType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; var manual = new UserManual { @@ -65,13 +64,11 @@ public class UserManual Scan = cicm.Scan }; - if(cicm.Language is null) - return manual; + if(cicm.Language is null) return manual; manual.Language = new List(); - foreach(LanguagesTypeLanguage lng in cicm.Language) - manual.Language.Add((Language)lng); + foreach(LanguagesTypeLanguage lng in cicm.Language) manual.Language.Add((Language)lng); return manual; } diff --git a/Aaru.CommonTypes/AaruMetadata/Xbox.cs b/Aaru.CommonTypes/AaruMetadata/Xbox.cs index f538f2f41..fc7152249 100644 --- a/Aaru.CommonTypes/AaruMetadata/Xbox.cs +++ b/Aaru.CommonTypes/AaruMetadata/Xbox.cs @@ -54,8 +54,7 @@ public class Xbox [Obsolete("Will be removed in Aaru 7")] public static implicit operator Xbox(XboxType cicm) { - if(cicm is null) - return null; + if(cicm is null) return null; Xbox xbox = new() { @@ -63,11 +62,9 @@ public class Xbox Dmi = cicm.DMI }; - if(cicm.SecuritySectors is null) - return xbox; + if(cicm.SecuritySectors is null) return xbox; - foreach(XboxSecuritySectorsType ss in cicm.SecuritySectors) - xbox.SecuritySectors.Add(ss); + foreach(XboxSecuritySectorsType ss in cicm.SecuritySectors) xbox.SecuritySectors.Add(ss); return xbox; } @@ -80,13 +77,12 @@ public class XboxSecuritySector public Dump SecuritySectors { get; set; } [Obsolete("Will be removed in Aaru 7")] - public static implicit operator XboxSecuritySector(XboxSecuritySectorsType cicm) => - cicm is null - ? null - : new XboxSecuritySector - { - RequestNumber = cicm.RequestNumber, - RequestVersion = cicm.RequestVersion, - SecuritySectors = cicm.SecuritySectors - }; + public static implicit operator XboxSecuritySector(XboxSecuritySectorsType cicm) => cicm is null + ? null + : new XboxSecuritySector + { + RequestNumber = cicm.RequestNumber, + RequestVersion = cicm.RequestVersion, + SecuritySectors = cicm.SecuritySectors + }; } \ No newline at end of file diff --git a/Aaru.CommonTypes/Extents/ExtentsByte.cs b/Aaru.CommonTypes/Extents/ExtentsByte.cs index b7f5a5a5b..6576e0640 100644 --- a/Aaru.CommonTypes/Extents/ExtentsByte.cs +++ b/Aaru.CommonTypes/Extents/ExtentsByte.cs @@ -61,8 +61,7 @@ public sealed class ExtentsByte _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsByte for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsByte } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsByte realEnd = end; // TODO: Optimize this - for(byte t = start; t <= realEnd; t++) - Add(t); + for(byte t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsByte } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsByte } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsConverter.cs b/Aaru.CommonTypes/Extents/ExtentsConverter.cs index 0a3c3e036..185777f64 100644 --- a/Aaru.CommonTypes/Extents/ExtentsConverter.cs +++ b/Aaru.CommonTypes/Extents/ExtentsConverter.cs @@ -51,8 +51,7 @@ public static class ExtentsConverter /// XML based extents public static List ToMetadata(ExtentsULong extents) { - if(extents == null) - return null; + if(extents == null) return null; Tuple[] tuples = extents.ToArray(); List list = new(); @@ -74,8 +73,7 @@ public static class ExtentsConverter /// Extents public static ExtentsULong FromMetadata(IEnumerable extents) { - if(extents == null) - return null; + if(extents == null) return null; var tuples = extents.Select(extent => new Tuple(extent.Start, extent.End)).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsInt.cs b/Aaru.CommonTypes/Extents/ExtentsInt.cs index 0b8275ea4..f0c663265 100644 --- a/Aaru.CommonTypes/Extents/ExtentsInt.cs +++ b/Aaru.CommonTypes/Extents/ExtentsInt.cs @@ -61,8 +61,7 @@ public sealed class ExtentsInt _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsInt for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsInt } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsInt realEnd = end; // TODO: Optimize this - for(int t = start; t <= realEnd; t++) - Add(t); + for(int t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsInt } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsInt } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsLong.cs b/Aaru.CommonTypes/Extents/ExtentsLong.cs index f5d12551b..537973894 100644 --- a/Aaru.CommonTypes/Extents/ExtentsLong.cs +++ b/Aaru.CommonTypes/Extents/ExtentsLong.cs @@ -60,8 +60,7 @@ public sealed class ExtentsLong _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -78,8 +77,7 @@ public sealed class ExtentsLong for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -98,8 +96,7 @@ public sealed class ExtentsLong } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -144,8 +141,7 @@ public sealed class ExtentsLong realEnd = end; // TODO: Optimize this - for(long t = start; t <= realEnd; t++) - Add(t); + for(long t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -196,8 +192,7 @@ public sealed class ExtentsLong } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -205,16 +200,13 @@ public sealed class ExtentsLong } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsSByte.cs b/Aaru.CommonTypes/Extents/ExtentsSByte.cs index c5133fba1..1d66937c9 100644 --- a/Aaru.CommonTypes/Extents/ExtentsSByte.cs +++ b/Aaru.CommonTypes/Extents/ExtentsSByte.cs @@ -61,8 +61,7 @@ public sealed class ExtentsSByte _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsSByte for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsSByte } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsSByte realEnd = end; // TODO: Optimize this - for(sbyte t = start; t <= realEnd; t++) - Add(t); + for(sbyte t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsSByte } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsSByte } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsShort.cs b/Aaru.CommonTypes/Extents/ExtentsShort.cs index 69ea3bc07..141c9a0ec 100644 --- a/Aaru.CommonTypes/Extents/ExtentsShort.cs +++ b/Aaru.CommonTypes/Extents/ExtentsShort.cs @@ -61,8 +61,7 @@ public sealed class ExtentsShort _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsShort for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsShort } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsShort realEnd = end; // TODO: Optimize this - for(short t = start; t <= realEnd; t++) - Add(t); + for(short t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsShort } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsShort } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsUInt.cs b/Aaru.CommonTypes/Extents/ExtentsUInt.cs index e6ffa6310..022e4b8f9 100644 --- a/Aaru.CommonTypes/Extents/ExtentsUInt.cs +++ b/Aaru.CommonTypes/Extents/ExtentsUInt.cs @@ -61,8 +61,7 @@ public sealed class ExtentsUInt _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsUInt for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsUInt } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsUInt realEnd = end; // TODO: Optimize this - for(uint t = start; t <= realEnd; t++) - Add(t); + for(uint t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsUInt } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsUInt } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsULong.cs b/Aaru.CommonTypes/Extents/ExtentsULong.cs index 45374bea4..01b077e5a 100644 --- a/Aaru.CommonTypes/Extents/ExtentsULong.cs +++ b/Aaru.CommonTypes/Extents/ExtentsULong.cs @@ -61,8 +61,7 @@ public sealed class ExtentsULong _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsULong for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsULong } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsULong realEnd = end; // TODO: Optimize this - for(ulong t = start; t <= realEnd; t++) - Add(t); + for(ulong t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsULong } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsULong } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Extents/ExtentsUShort.cs b/Aaru.CommonTypes/Extents/ExtentsUShort.cs index e96143ade..edda26a01 100644 --- a/Aaru.CommonTypes/Extents/ExtentsUShort.cs +++ b/Aaru.CommonTypes/Extents/ExtentsUShort.cs @@ -61,8 +61,7 @@ public sealed class ExtentsUShort _backend = new List>(); // This ensure no overlapping extents are added on creation - foreach(Tuple t in list) - Add(t.Item1, t.Item2); + foreach(Tuple t in list) Add(t.Item1, t.Item2); } /// Gets a count of how many extents are stored @@ -79,8 +78,7 @@ public sealed class ExtentsUShort for(var i = 0; i < _backend.Count; i++) { // Already contained in an extent - if(item >= _backend[i].Item1 && item <= _backend[i].Item2) - return; + if(item >= _backend[i].Item1 && item <= _backend[i].Item2) return; // Expands existing extent start if(item == _backend[i].Item1 - 1) @@ -99,8 +97,7 @@ public sealed class ExtentsUShort } // Expands existing extent end - if(item != _backend[i].Item2 + 1) - continue; + if(item != _backend[i].Item2 + 1) continue; removeOne = _backend[i]; @@ -145,8 +142,7 @@ public sealed class ExtentsUShort realEnd = end; // TODO: Optimize this - for(ushort t = start; t <= realEnd; t++) - Add(t); + for(ushort t = start; t <= realEnd; t++) Add(t); } /// Checks if the specified item is contained by an extent on this instance @@ -197,8 +193,7 @@ public sealed class ExtentsUShort } // Extent is only element - if(item != extent.Item1 || item != extent.Item2) - continue; + if(item != extent.Item1 || item != extent.Item2) continue; toRemove = extent; @@ -206,16 +201,13 @@ public sealed class ExtentsUShort } // Item not found - if(toRemove == null) - return false; + if(toRemove == null) return false; _backend.Remove(toRemove); - if(toAddOne != null) - _backend.Add(toAddOne); + if(toAddOne != null) _backend.Add(toAddOne); - if(toAddTwo != null) - _backend.Add(toAddTwo); + if(toAddTwo != null) _backend.Add(toAddTwo); // Sort _backend = _backend.OrderBy(t => t.Item1).ToList(); diff --git a/Aaru.CommonTypes/Interfaces/IReadOnlyFilesystem.cs b/Aaru.CommonTypes/Interfaces/IReadOnlyFilesystem.cs index 8dea58691..828eba756 100644 --- a/Aaru.CommonTypes/Interfaces/IReadOnlyFilesystem.cs +++ b/Aaru.CommonTypes/Interfaces/IReadOnlyFilesystem.cs @@ -132,8 +132,7 @@ public interface IReadOnlyFilesystem : IFilesystem /// Error number. ErrorNumber Seek(IFileNode node, long position, SeekOrigin origin) { - if(node is null) - return ErrorNumber.InvalidArgument; + if(node is null) return ErrorNumber.InvalidArgument; long desiredPosition = origin switch { @@ -142,11 +141,9 @@ public interface IReadOnlyFilesystem : IFilesystem _ => node.Offset + position }; - if(desiredPosition < 0) - return ErrorNumber.InvalidArgument; + if(desiredPosition < 0) return ErrorNumber.InvalidArgument; - if(desiredPosition >= node.Length) - return ErrorNumber.InvalidArgument; + if(desiredPosition >= node.Length) return ErrorNumber.InvalidArgument; node.Offset = desiredPosition; diff --git a/Aaru.CommonTypes/Interop/DetectOS.cs b/Aaru.CommonTypes/Interop/DetectOS.cs index 197a65650..c0617626d 100644 --- a/Aaru.CommonTypes/Interop/DetectOS.cs +++ b/Aaru.CommonTypes/Interop/DetectOS.cs @@ -70,8 +70,7 @@ public static class DetectOS { get { - if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - return Environment.UserName == "root"; + if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return Environment.UserName == "root"; bool isAdmin; WindowsIdentity user = null; @@ -126,11 +125,11 @@ public static class DetectOS // TODO: Differentiate Linux, Android, Tizen case "Linux": { - #if __ANDROID__ - return PlatformID.Android; - #else +#if __ANDROID__ + return PlatformID.Android; +#else return PlatformID.Linux; - #endif +#endif } case "Darwin": @@ -238,8 +237,7 @@ public static class DetectOS switch(GetRealPlatformID()) { case PlatformID.MacOSX: - if(Environment.OSVersion.Version.Major >= 11) - return environ; + if(Environment.OSVersion.Version.Major >= 11) return environ; if(Environment.OSVersion.Version.Major != 1) return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}"; @@ -258,10 +256,10 @@ public static class DetectOS if(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 2 || Environment.OSVersion.Version.Major > 6) { - return FileVersionInfo. - GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), - "KERNEL32.DLL")). - ProductVersion; + return FileVersionInfo + .GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), + "KERNEL32.DLL")) + .ProductVersion; } return environ; @@ -297,26 +295,22 @@ public static class DetectOS case PlatformID.IRIX: return "IRIX"; case PlatformID.Linux: - if(!File.Exists("/proc/version")) - return "Linux"; + if(!File.Exists("/proc/version")) return "Linux"; string s = File.ReadAllText("/proc/version"); return s.Contains("Microsoft") || s.Contains("WSL") ? "Windows Subsystem for Linux" : "Linux"; case PlatformID.MacOSX: - if(string.IsNullOrEmpty(version)) - return "macOS"; + if(string.IsNullOrEmpty(version)) return "macOS"; string[] pieces = version.Split('.'); - if(pieces.Length < 2 || !int.TryParse(pieces[1], out int minor)) - return "macOS"; + if(pieces.Length < 2 || !int.TryParse(pieces[1], out int minor)) return "macOS"; int.TryParse(pieces[0], out int major); - if(minor >= 12 || major >= 11) - return "macOS"; + if(minor >= 12 || major >= 11) return "macOS"; return minor >= 8 ? "OS X" : "Mac OS X"; @@ -357,36 +351,27 @@ public static class DetectOS case PlatformID.WiiU: return "Nintendo Wii U"; case PlatformID.Win32NT: - if(string.IsNullOrEmpty(version)) - return "Windows NT/2000/XP/Vista/7/10"; + if(string.IsNullOrEmpty(version)) return "Windows NT/2000/XP/Vista/7/10"; if(version.StartsWith("3.", StringComparison.Ordinal) || version.StartsWith("4.", StringComparison.Ordinal)) return "Windows NT"; - if(version.StartsWith("5.0", StringComparison.Ordinal)) - return "Windows 2000"; + if(version.StartsWith("5.0", StringComparison.Ordinal)) return "Windows 2000"; - if(version.StartsWith("5.1", StringComparison.Ordinal)) - return "Windows XP"; + if(version.StartsWith("5.1", StringComparison.Ordinal)) return "Windows XP"; - if(version.StartsWith("5.2", StringComparison.Ordinal)) - return "Windows 2003"; + if(version.StartsWith("5.2", StringComparison.Ordinal)) return "Windows 2003"; - if(version.StartsWith("6.0", StringComparison.Ordinal)) - return "Windows Vista"; + if(version.StartsWith("6.0", StringComparison.Ordinal)) return "Windows Vista"; - if(version.StartsWith("6.1", StringComparison.Ordinal)) - return "Windows 7"; + if(version.StartsWith("6.1", StringComparison.Ordinal)) return "Windows 7"; - if(version.StartsWith("6.2", StringComparison.Ordinal)) - return "Windows 8"; + if(version.StartsWith("6.2", StringComparison.Ordinal)) return "Windows 8"; - if(version.StartsWith("6.3", StringComparison.Ordinal)) - return "Windows 8.1"; + if(version.StartsWith("6.3", StringComparison.Ordinal)) return "Windows 8.1"; - if(version.StartsWith("10.0", StringComparison.Ordinal)) - return "Windows 10"; + if(version.StartsWith("10.0", StringComparison.Ordinal)) return "Windows 10"; return version.StartsWith("11.0", StringComparison.Ordinal) ? "Windows 11" @@ -395,17 +380,13 @@ public static class DetectOS case PlatformID.Win32S: return "Windows 3.x with win32s"; case PlatformID.Win32Windows: - if(string.IsNullOrEmpty(version)) - return "Windows 9x/Me"; + if(string.IsNullOrEmpty(version)) return "Windows 9x/Me"; - if(version.StartsWith("4.0", StringComparison.Ordinal)) - return "Windows 95"; + if(version.StartsWith("4.0", StringComparison.Ordinal)) return "Windows 95"; - if(version.StartsWith("4.10.2222", StringComparison.Ordinal)) - return "Windows 98 SE"; + if(version.StartsWith("4.10.2222", StringComparison.Ordinal)) return "Windows 98 SE"; - if(version.StartsWith("4.1", StringComparison.Ordinal)) - return "Windows 98"; + if(version.StartsWith("4.1", StringComparison.Ordinal)) return "Windows 98"; return version.StartsWith("4.9", StringComparison.Ordinal) ? "Windows Me" : "Windows 9x/Me"; diff --git a/Aaru.CommonTypes/Interop/Version.cs b/Aaru.CommonTypes/Interop/Version.cs index 1c6e9e4ba..a7e48ac54 100644 --- a/Aaru.CommonTypes/Interop/Version.cs +++ b/Aaru.CommonTypes/Interop/Version.cs @@ -56,17 +56,16 @@ public static class Version Assembly assembly = typeof(GCSettings).Assembly; string[] assemblyPath = assembly.CodeBase?.Split(new[] - { - '/', '\\' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/', '\\' + }, + StringSplitOptions.RemoveEmptyEntries); - if(assemblyPath is null) - return null; + if(assemblyPath is null) return null; int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); - if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) - return assemblyPath[netCoreAppIndex + 1]; + if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) return assemblyPath[netCoreAppIndex + 1]; return null; } @@ -75,14 +74,12 @@ public static class Version /// Version public static string GetMonoVersion() { - if(!DetectOS.IsMono) - return null; + if(!DetectOS.IsMono) return null; - MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")?. - GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); + MethodInfo monoDisplayName = Type.GetType("Mono.Runtime") + ?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); - if(monoDisplayName != null) - return (string)monoDisplayName.Invoke(null, null); + if(monoDisplayName != null) return (string)monoDisplayName.Invoke(null, null); return null; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromAta.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromAta.cs index e794b34f2..eefcc792d 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromAta.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromAta.cs @@ -52,8 +52,7 @@ public static partial class MediaTypeFromDevice { if(!removable) { - if(compactFlash) - return MediaType.CompactFlash; + if(compactFlash) return MediaType.CompactFlash; return pcmcia ? MediaType.PCCardTypeI : MediaType.GENERIC_HDD; } @@ -64,8 +63,8 @@ public static partial class MediaTypeFromDevice return MediaType.Unknown; AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ); + Localization + .Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ); return MediaType.SparQ; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromMmc.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromMmc.cs index 2062a4f1c..a2127ec7a 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromMmc.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromMmc.cs @@ -60,17 +60,21 @@ public static partial class MediaTypeFromDevice if(blocks == 1281856) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650_WORM; } AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650; } @@ -82,15 +86,16 @@ public static partial class MediaTypeFromDevice return MediaType.CD; case 0x01: case 0x05: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_ROM, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_ROM, mediumType); return MediaType.CDROM; case 0x02: case 0x06: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio, + Localization + .SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio, mediumType); return MediaType.CDDA; @@ -116,7 +121,8 @@ public static partial class MediaTypeFromDevice case 0x16: case 0x17: case 0x18: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_medium_type_is_0_setting_media_type_to_CDR, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_medium_type_is_0_setting_media_type_to_CDR, mediumType); return MediaType.CDR; @@ -129,7 +135,8 @@ public static partial class MediaTypeFromDevice case 0x26: case 0x27: case 0x28: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_medium_type_is_0_setting_media_type_to_CDRW, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_medium_type_is_0_setting_media_type_to_CDRW, mediumType); return MediaType.CDRW; @@ -137,8 +144,8 @@ public static partial class MediaTypeFromDevice case 0x41 when isUsb && !opticalDisc: case 0x42 when isUsb && !opticalDisc: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_and_device_is_USB_setting_media_type_to_Flash_Drive, + Localization + .SCSI_medium_type_is_0_and_device_is_USB_setting_media_type_to_Flash_Drive, mediumType); return MediaType.FlashDrive; @@ -149,30 +156,34 @@ public static partial class MediaTypeFromDevice { case 0x42: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO2, - mediumType, densityCode); + Localization + .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO2, + mediumType, + densityCode); return MediaType.LTO2; case 0x44: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO3, - mediumType, densityCode); + Localization + .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO3, + mediumType, + densityCode); return MediaType.LTO3; case 0x46: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO4, - mediumType, densityCode); + Localization + .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO4, + mediumType, + densityCode); return MediaType.LTO4; case 0x58: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO5, - mediumType, densityCode); + Localization + .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO5, + mediumType, + densityCode); return MediaType.LTO5; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromOdc.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromOdc.cs index 834edb69f..019e73ef2 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromOdc.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromOdc.cs @@ -61,70 +61,103 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 248826: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA154, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA154, + mediumType, + blocks, + blockSize); return MediaType.ECMA_154; case 429975: AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA201_embossed, - mediumType, blocks, blockSize); + mediumType, + blocks, + blockSize); return MediaType.ECMA_201_ROM; case 446325: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA201, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA201, + mediumType, + blocks, + blockSize); return MediaType.ECMA_201; case 694929: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA223, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA223, + mediumType, + blocks, + blockSize); return MediaType.ECMA_223_512; case 904995: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA183, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA183, + mediumType, + blocks, + blockSize); return MediaType.ECMA_183_512; case 1041500: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15041, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15041, + mediumType, + blocks, + blockSize); return MediaType.ISO_15041_512; case 1128772: case 1163337: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA184, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA184, + mediumType, + blocks, + blockSize); return MediaType.ECMA_184_512; case 1281856: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650_WORM; case 1298496: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650; case 1644581: case 1647371: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA195, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA195, + mediumType, + blocks, + blockSize); return MediaType.ECMA_195_512; case 2244958: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO14517, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO14517, + mediumType, + blocks, + blockSize); return MediaType.ISO_14517_512; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } @@ -135,65 +168,101 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 314569: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO10089, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO10089, + mediumType, + blocks, + blockSize); return MediaType.ISO_10089; case 371371: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA223, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA223, + mediumType, + blocks, + blockSize); return MediaType.ECMA_223; case 498526: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA184, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA184, + mediumType, + blocks, + blockSize); return MediaType.ECMA_183; case 603466: case 637041: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA184, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA184, + mediumType, + blocks, + blockSize); return MediaType.ECMA_184; case 936921: case 948770: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA195, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA195, + mediumType, + blocks, + blockSize); return MediaType.ECMA_195; case 1244621: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA238, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA238, + mediumType, + blocks, + blockSize); return MediaType.ECMA_238; case 1273011: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO14517, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO14517, + mediumType, + blocks, + blockSize); return MediaType.ISO_14517; case 2319786: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15286, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15286, + mediumType, + blocks, + blockSize); return MediaType.ISO_15286_1024; case 4383356: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322_1k; case 14476734: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA260, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA260, + mediumType, + blocks, + blockSize); return MediaType.ECMA_260; case 24445990: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA260, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA260, + mediumType, + blocks, + blockSize); return MediaType.ECMA_260_Double; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } @@ -207,43 +276,67 @@ public static partial class MediaTypeFromDevice case 318988: case 320332: case 321100: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA239, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA239, + mediumType, + blocks, + blockSize); return MediaType.ECMA_239; case 605846: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_GigaMO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_GigaMO, + mediumType, + blocks, + blockSize); return MediaType.GigaMo; case 1063146: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_GigaMO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_GigaMO2, + mediumType, + blocks, + blockSize); return MediaType.GigaMo2; case 1128134: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA280, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA280, + mediumType, + blocks, + blockSize); return MediaType.ECMA_280; case 1263472: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15286, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15286, + mediumType, + blocks, + blockSize); return MediaType.ISO_15286; case 2043664: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322_2k; case 7355716: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA317, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA317, + mediumType, + blocks, + blockSize); return MediaType.ECMA_317; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } @@ -254,13 +347,19 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 1095840: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } @@ -271,31 +370,46 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 1834348: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_UDO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_UDO, + mediumType, + blocks, + blockSize); return MediaType.UDO; case 3668759: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_UDO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_UDO2, + mediumType, + blocks, + blockSize); return MediaType.UDO2_WORM; case 3669724: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_UDO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_UDO2, + mediumType, + blocks, + blockSize); return MediaType.UDO2; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } } default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown_MO, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown_MO, + mediumType, + blocks, + blockSize); return MediaType.UnknownMO; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromSbc.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromSbc.cs index a474ff35a..000372607 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromSbc.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromSbc.cs @@ -51,126 +51,189 @@ public static partial class MediaTypeFromDevice switch(mediumType) { case 0x09: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA54, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA54, + mediumType, + blocks, + blockSize); return MediaType.ECMA_54; case 0x0A: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA59, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA59, + mediumType, + blocks, + blockSize); return MediaType.ECMA_59; case 0x0B: switch(blockSize) { case 256: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA69, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA69, + mediumType, + blocks, + blockSize); return MediaType.ECMA_69_26; case 512: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA69, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA69, + mediumType, + blocks, + blockSize); return MediaType.ECMA_69_15; case 1024: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA69, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA69, + mediumType, + blocks, + blockSize); return MediaType.ECMA_69_8; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown, + mediumType, + blocks, + blockSize); return MediaType.Unknown; case 0x0E: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA66, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA66, + mediumType, + blocks, + blockSize); return MediaType.ECMA_66; case 0x12: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA70, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA70, + mediumType, + blocks, + blockSize); return MediaType.ECMA_70; case 0x16: switch(blockSize) { case 256: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA78, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA78, + mediumType, + blocks, + blockSize); return MediaType.ECMA_78; case 512: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA78, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA78, + mediumType, + blocks, + blockSize); return MediaType.ECMA_78_2; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown, + mediumType, + blocks, + blockSize); return MediaType.Unknown; case 0x1A: switch(blockSize) { case 256: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_26; case 512: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_15; case 1024: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_8; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Unknown, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Unknown, + mediumType, + blocks, + blockSize); return MediaType.Unknown; case 0x1E: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2DD, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_DS_DD_9; case 0x41: switch(blocks) { case 58620544: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_REV120, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_REV120, + mediumType, + blocks, + blockSize); return MediaType.REV120; case 34185728: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_REV70, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_REV70, + mediumType, + blocks, + blockSize); return MediaType.REV70; case 17090880: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_REV35, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_REV35, + mediumType, + blocks, + blockSize); return MediaType.REV35; } break; case 0x93: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_PC98_MF2HD, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_PC98_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.NEC_35_HD_15; case 0x94: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2HD, mediumType, - blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_HD; } @@ -181,33 +244,51 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 720: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Atari_MD1SD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Atari_MD1SD, + mediumType, + blocks, + blockSize); return MediaType.ATARI_525_SD; case 1040: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Atari_MD1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Atari_MD1DD, + mediumType, + blocks, + blockSize); return MediaType.ATARI_525_DD; case 1898: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_33FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_33FD, + mediumType, + blocks, + blockSize); return MediaType.IBM33FD_128; case 2002: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA54, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA54, + mediumType, + blocks, + blockSize); return MediaType.ECMA_54; case 3848: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_43FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_43FD, + mediumType, + blocks, + blockSize); return MediaType.IBM43FD_128; case 4004: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA59, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA59, + mediumType, + blocks, + blockSize); return MediaType.ECMA_59; } @@ -217,93 +298,145 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 322: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA56, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA56, + mediumType, + blocks, + blockSize); return MediaType.ECMA_66; case 400: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MD1SD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MD1SD, + mediumType, + blocks, + blockSize); return MediaType.ACORN_525_SS_SD_40; case 455: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apple_DOS32, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apple_DOS32, + mediumType, + blocks, + blockSize); return MediaType.Apple32SS; case 560: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apple_DOS33, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apple_DOS33, + mediumType, + blocks, + blockSize); return MediaType.Apple33SS; case 640: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MD1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MD1DD, + mediumType, + blocks, + blockSize); return MediaType.ACORN_525_SS_DD_40; case 720: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Atari_MD1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Atari_MD1DD, + mediumType, + blocks, + blockSize); return MediaType.ATARI_525_DD; case 800: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MD1DD_80, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MD1DD_80, + mediumType, + blocks, + blockSize); return MediaType.ACORN_525_SS_SD_80; case 910: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apple_DOS32_DS, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apple_DOS32_DS, + mediumType, + blocks, + blockSize); return MediaType.Apple32DS; case 1120: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apple_DOS33_DS, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apple_DOS33_DS, + mediumType, + blocks, + blockSize); return MediaType.Apple33DS; case 1121: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_33FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_33FD, + mediumType, + blocks, + blockSize); return MediaType.IBM33FD_256; case 1232: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MetaFloppy, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MetaFloppy, + mediumType, + blocks, + blockSize); return MediaType.MetaFloppy_Mod_II; case 1280 when mediumType == 0x01: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MD1DD_80, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MD1DD_80, + mediumType, + blocks, + blockSize); return MediaType.ACORN_525_SS_DD_80; case 1280: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA70, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA70, + mediumType, + blocks, + blockSize); return MediaType.ECMA_70; case 2002: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DEC_RX02, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DEC_RX02, + mediumType, + blocks, + blockSize); return MediaType.RX02; case 2560: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA78, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA78, + mediumType, + blocks, + blockSize); return MediaType.ECMA_78; case 3848: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_53FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_53FD, + mediumType, + blocks, + blockSize); return MediaType.IBM53FD_256; case 4004: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_26; case 39168 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase): case 41004 when vendor.StartsWith("iomega", StringComparison.OrdinalIgnoreCase): - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Bernoulli10, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Bernoulli10, blocks); return MediaType.Bernoulli10; @@ -322,8 +455,11 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 256: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_23FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_23FD, + mediumType, + blocks, + blockSize); return MediaType.IBM23FD; } @@ -333,118 +469,187 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 320: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MD1DD_8, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MD1DD_8, + mediumType, + blocks, + blockSize); return MediaType.DOS_525_SS_DD_8; case 360: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MD1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MD1DD, + mediumType, + blocks, + blockSize); return MediaType.DOS_525_SS_DD_9; case 610: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_33FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_33FD, + mediumType, + blocks, + blockSize); return MediaType.IBM33FD_512; case 630 when mediumType == 0x01: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apricot_MF2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apricot_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.Apricot_35; case 640 when mediumType == 0x01: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF1DD_8, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF1DD_8, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_SS_DD_8; case 640: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MD2DD_8, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MD2DD_8, + mediumType, + blocks, + blockSize); return MediaType.DOS_525_DS_DD_8; case 720 when mediumType == 0x01: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF1DD, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_SS_DD_9; case 720: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MD2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MD2DD, + mediumType, + blocks, + blockSize); return MediaType.DOS_525_DS_DD_9; case 800: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Apple_MF1DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Apple_MF1DD, + mediumType, + blocks, + blockSize); return MediaType.AppleSonySS; case 1280: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2DD_8, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2DD_8, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_DS_DD_8; case 1440: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_DS_DD_9; case 1640: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_FDFORMAT_MF2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_FDFORMAT_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.FDFORMAT_35_DD; case 1760: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Amiga_MF2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Amiga_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.CBM_AMIGA_35_DD; case 2242: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_53FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_53FD, + mediumType, + blocks, + blockSize); return MediaType.IBM53FD_512; case 2332: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_15; case 2400: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MD2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MD2HD, + mediumType, + blocks, + blockSize); return MediaType.DOS_525_HD; case 2788: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_FDFORMAT_MD2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_FDFORMAT_MD2HD, + mediumType, + blocks, + blockSize); return MediaType.FDFORMAT_525_HD; case 2880: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_HD; case 3360: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DMF_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DMF_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.DMF; case 3444: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_FDFORMAT_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_FDFORMAT_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.FDFORMAT_35_HD; case 3520: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Amiga_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Amiga_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.CBM_AMIGA_35_HD; case 5760: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_MF2ED, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_MF2ED, + mediumType, + blocks, + blockSize); return MediaType.DOS_35_ED; case 40662 when mediumType == 0x20: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Floptical, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Floptical, + mediumType, + blocks, + blockSize); return MediaType.Floptical; case 65536 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal): @@ -485,8 +690,11 @@ public static partial class MediaTypeFromDevice return MediaType.LS120; case 248826 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA154, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA154, + mediumType, + blocks, + blockSize); return MediaType.ECMA_154; case 262144 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase): @@ -503,19 +711,26 @@ public static partial class MediaTypeFromDevice return MediaType.SQ2000; case 393380 when model.ToLowerInvariant().StartsWith("hifd", StringComparison.Ordinal): - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_HiFD, blocks, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_HiFD, + blocks, blockSize); return MediaType.HiFD; case 429975 when mediumType is 0x01 or 0x02: AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA201_embossed, - mediumType, blocks, blockSize); + mediumType, + blocks, + blockSize); return MediaType.ECMA_201_ROM; case 446325 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA201, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA201, + mediumType, + blocks, + blockSize); return MediaType.ECMA_201; case 450560 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase): @@ -535,38 +750,54 @@ public static partial class MediaTypeFromDevice return MediaType.SQ327; case 694929 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA223, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA223, + mediumType, + blocks, + blockSize); return MediaType.ECMA_223_512; case 904995 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA183, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA183, + mediumType, + blocks, + blockSize); return MediaType.ECMA_183_512; case 1041500 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15041, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15041, + mediumType, + blocks, + blockSize); return MediaType.ISO_15041_512; case 1128772 when mediumType is 0x01 or 0x02: case 1163337 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA184, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA184, + mediumType, + blocks, + blockSize); return MediaType.ECMA_184_512; case 1281856 when mediumType is 0x01 or 0x02: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650_WORM; case 1298496 when mediumType is 0x01 or 0x02: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, - mediumType, blocks, blockSize); + Localization + .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, + mediumType, + blocks, + blockSize); return MediaType.PD650; case 1470500 when model.ToLowerInvariant().StartsWith("zip", StringComparison.OrdinalIgnoreCase): @@ -575,14 +806,17 @@ public static partial class MediaTypeFromDevice return MediaType.ZIP750; case 1644581 when mediumType is 0x01 or 0x02: case 1647371 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA195, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA195, + mediumType, + blocks, + blockSize); return MediaType.ECMA_195_512; case 1961069 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase): AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ); + Localization + .Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ); return MediaType.SparQ; case 2091050 when model.ToLowerInvariant().StartsWith("jaz", StringComparison.Ordinal): @@ -590,8 +824,11 @@ public static partial class MediaTypeFromDevice return MediaType.Jaz; case 2244958 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO14517, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO14517, + mediumType, + blocks, + blockSize); return MediaType.ISO_14517_512; case 2929800 when vendor.Equals("syquest", StringComparison.InvariantCultureIgnoreCase): @@ -607,7 +844,9 @@ public static partial class MediaTypeFromDevice return MediaType.Orb; case 625134256 when model.ToLowerInvariant().StartsWith("rdx", StringComparison.Ordinal): - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_RDX320, blocks, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_RDX320, + blocks, blockSize); return MediaType.RDX320; @@ -619,13 +858,19 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 800 when mediumType == 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MF2DD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MF2DD, + mediumType, + blocks, + blockSize); return MediaType.ACORN_35_DS_DD; case 1220: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM_53FD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM_53FD, + mediumType, + blocks, + blockSize); return MediaType.IBM53FD_1024; case 1232 when model.ToLowerInvariant().StartsWith("ls-", StringComparison.Ordinal): @@ -633,85 +878,133 @@ public static partial class MediaTypeFromDevice return MediaType.NEC_35_HD_8; case 1232: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Sharp_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Sharp_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.SHARP_35; case 1268: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA69, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA69, + mediumType, + blocks, + blockSize); return MediaType.ECMA_69_8; case 1280: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_PC98_MD2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_PC98_MD2HD, + mediumType, + blocks, + blockSize); return MediaType.NEC_525_HD; case 1316: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA99, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA99, + mediumType, + blocks, + blockSize); return MediaType.ECMA_99_8; case 1600 when mediumType == 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Acorn_MF2HD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Acorn_MF2HD, + mediumType, + blocks, + blockSize); return MediaType.ACORN_35_DS_HD; case 314569 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO10089, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO10089, + mediumType, + blocks, + blockSize); return MediaType.ISO_10089; case 371371 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA223, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA223, + mediumType, + blocks, + blockSize); return MediaType.ECMA_223; case 498526 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA183, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA183, + mediumType, + blocks, + blockSize); return MediaType.ECMA_183; case 603466 when mediumType is 0x01 or 0x02: case 637041 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA184, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA184, + mediumType, + blocks, + blockSize); return MediaType.ECMA_184; case 936921 when mediumType is 0x01 or 0x02: case 948770 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA195, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA195, + mediumType, + blocks, + blockSize); return MediaType.ECMA_195; case 1244621 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA238, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA238, + mediumType, + blocks, + blockSize); return MediaType.ECMA_238; case 1273011 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO14517, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO14517, + mediumType, + blocks, + blockSize); return MediaType.ISO_14517; case 2319786 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15286, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15286, + mediumType, + blocks, + blockSize); return MediaType.ISO_15286_1024; case 4383356 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322_1k; case 14476734 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA260, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA260, + mediumType, + blocks, + blockSize); return MediaType.ECMA_260; case 24445990 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA260, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA260, + mediumType, + blocks, + blockSize); return MediaType.ECMA_260_Double; } @@ -723,61 +1016,94 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 112311: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD60, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD60, + mediumType, + blocks, + blockSize); return MediaType.MD60; case 138363: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD74, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD74, + mediumType, + blocks, + blockSize); return MediaType.MD74; case 149373: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD80, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD80, + mediumType, + blocks, + blockSize); return MediaType.MD80; case 310352 when mediumType is 0x01 or 0x02: // Found in real media case 318988 when mediumType is 0x01 or 0x02: case 320332 when mediumType is 0x01 or 0x02: case 321100 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA239, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA239, + mediumType, + blocks, + blockSize); return MediaType.ECMA_239; case 494023: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_HiMD, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_HiMD, + mediumType, + blocks, + blockSize); return MediaType.HiMD; case 605846 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_GigaMO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_GigaMO, + mediumType, + blocks, + blockSize); return MediaType.GigaMo; case 1063146 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_GigaMO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_GigaMO2, + mediumType, + blocks, + blockSize); return MediaType.GigaMo2; case 1128134 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA280, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA280, + mediumType, + blocks, + blockSize); return MediaType.ECMA_280; case 1263472 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ISO15286, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ISO15286, + mediumType, + blocks, + blockSize); return MediaType.ISO_15286; case 2043664 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322_2k; case 7355716 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA317, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA317, + mediumType, + blocks, + blockSize); return MediaType.ECMA_317; } @@ -789,8 +1115,11 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 1095840 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ECMA322, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ECMA322, + mediumType, + blocks, + blockSize); return MediaType.ECMA_322; } @@ -802,18 +1131,27 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 1834348 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_UDO, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_UDO, + mediumType, + blocks, + blockSize); return MediaType.UDO; case 3668759 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_UDO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_UDO2, + mediumType, + blocks, + blockSize); return MediaType.UDO2_WORM; case 3669724 when mediumType is 0x01 or 0x02: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_UDO2, - mediumType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_UDO2, + mediumType, + blocks, + blockSize); return MediaType.UDO2; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromScsi.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromScsi.cs index d34870594..91c854dff 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromScsi.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromScsi.cs @@ -61,8 +61,7 @@ public static partial class MediaTypeFromDevice case 0x00: // Simplified access device case 0x0E: - if(mediumType is 0x03 or 0x05 or 0x07) - goto case 0x07; + if(mediumType is 0x03 or 0x05 or 0x07) goto case 0x07; return GetFromSbc(vendor, model, mediumType, blocks, blockSize); @@ -85,8 +84,11 @@ public static partial class MediaTypeFromDevice model.StartsWith("MDH", StringComparison.Ordinal): if(blockSize == 2048) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MDDATA, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MDDATA, + scsiPeripheralType, + blocks, + blockSize); return MediaType.MDData; } @@ -94,31 +96,46 @@ public static partial class MediaTypeFromDevice switch(blocks) { case 57312: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD60_MDDATA, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD60_MDDATA, + scsiPeripheralType, + blocks, + blockSize); return MediaType.MD60; case 70464: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD74_MDDATA, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD74_MDDATA, + scsiPeripheralType, + blocks, + blockSize); return MediaType.MD74; case 76096: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD80_MDDATA, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD80_MDDATA, + scsiPeripheralType, + blocks, + blockSize); return MediaType.MD80; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_MD60_MDDATA, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_MD60_MDDATA, + scsiPeripheralType, + blocks, + blockSize); return MediaType.MD; // Host managed zoned block device case 0x14: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_ZBC_Host_Managed, - scsiPeripheralType, blocks, blockSize); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_ZBC_Host_Managed, + scsiPeripheralType, + blocks, + blockSize); return MediaType.Zone_HDD; } diff --git a/Aaru.CommonTypes/MediaTypeFromDevice/FromSsc.cs b/Aaru.CommonTypes/MediaTypeFromDevice/FromSsc.cs index ad361a1c3..55a274c75 100644 --- a/Aaru.CommonTypes/MediaTypeFromDevice/FromSsc.cs +++ b/Aaru.CommonTypes/MediaTypeFromDevice/FromSsc.cs @@ -53,68 +53,92 @@ public static partial class MediaTypeFromDevice switch(densityCode) { case 0x04: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_QIC11, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_QIC11, + mediumType, + densityCode); return MediaType.QIC11; case 0x05: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_QIC24, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_QIC24, + mediumType, + densityCode); return MediaType.QIC24; case 0x09: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3490, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3490, + mediumType, + densityCode); return MediaType.IBM3490; case 0x0F: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_QIC120, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_QIC120, + mediumType, + densityCode); return MediaType.QIC120; case 0x10: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_QIC150, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_QIC150, + mediumType, + densityCode); return MediaType.QIC150; case 0x13: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS, + mediumType, + densityCode); return MediaType.DDS1; case 0x24: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS2, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS2, + mediumType, + densityCode); return MediaType.DDS2; case 0x25: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS3, + mediumType, + densityCode); return MediaType.DDS3; case 0x26: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS4, + mediumType, + densityCode); return MediaType.DDS4; case 0x28: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3490E, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3490E, + mediumType, + densityCode); return MediaType.IBM3490E; case 0x40: if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO_ult, + mediumType, + densityCode); return MediaType.LTO; } if(model.StartsWith("sdz", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_SAIT, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_SAIT, + mediumType, + densityCode); return MediaType.SAIT1; } @@ -125,8 +149,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO2_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO2_ult, + mediumType, + densityCode); return MediaType.LTO2; } @@ -138,16 +164,20 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO2_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO2_ult, + mediumType, + densityCode); return MediaType.LTO2; } if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T9840A, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T9840A, + mediumType, + densityCode); return MediaType.T9840A; } @@ -159,8 +189,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T9940A, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T9940A, + mediumType, + densityCode); return MediaType.T9940A; } @@ -172,16 +204,20 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO3, + mediumType, + densityCode); return MediaType.LTO3; } if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T9940B, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T9940B, + mediumType, + densityCode); return MediaType.T9940B; } @@ -193,8 +229,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T9940C, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T9940C, + mediumType, + densityCode); return MediaType.T9840C; } @@ -206,16 +244,20 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO4, + mediumType, + densityCode); return MediaType.LTO4; } if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T9840D, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T9840D, + mediumType, + densityCode); return MediaType.T9840D; } @@ -227,8 +269,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T10000A, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T10000A, + mediumType, + densityCode); return MediaType.T10000A; } @@ -240,8 +284,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T10000B, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T10000B, + mediumType, + densityCode); return MediaType.T10000B; } @@ -253,8 +299,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T10000C, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T10000C, + mediumType, + densityCode); return MediaType.T10000C; } @@ -266,8 +314,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("stk", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_T10000D, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_T10000D, + mediumType, + densityCode); return MediaType.T10000D; } @@ -279,8 +329,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO5, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO5, + mediumType, + densityCode); return MediaType.LTO5; } @@ -291,8 +343,10 @@ public static partial class MediaTypeFromDevice // Used by some HP drives for all generations case 0x8C: { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS, + mediumType, + densityCode); return MediaType.DDS1; } @@ -307,8 +361,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO3, + mediumType, + densityCode); return MediaType.LTO3WORM; } @@ -320,8 +376,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO4, + mediumType, + densityCode); return MediaType.LTO4WORM; } @@ -333,8 +391,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO5, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO5, + mediumType, + densityCode); return MediaType.LTO5WORM; } @@ -353,8 +413,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO_ult, + mediumType, + densityCode); return MediaType.LTO; } @@ -364,8 +426,10 @@ public static partial class MediaTypeFromDevice case 0x40: { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO, + mediumType, + densityCode); return MediaType.LTO; } @@ -381,8 +445,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO2_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO2_ult, + mediumType, + densityCode); return MediaType.LTO2; } @@ -392,8 +458,10 @@ public static partial class MediaTypeFromDevice case 0x42: { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO2, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO2, + mediumType, + densityCode); return MediaType.LTO2; } @@ -410,8 +478,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("dat", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS3_dat, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS3_dat, + mediumType, + densityCode); return MediaType.DDS3; } @@ -431,8 +501,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("dat", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS4_alt, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS4_alt, + mediumType, + densityCode); return MediaType.DDS4; } @@ -452,8 +524,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("dat", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DAT72_dat, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DAT72_dat, + mediumType, + densityCode); return MediaType.DAT72; } @@ -473,8 +547,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO3, + mediumType, + densityCode); return MediaType.LTO3; } @@ -494,8 +570,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO3, + mediumType, + densityCode); return MediaType.LTO3WORM; } @@ -515,8 +593,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO4, + mediumType, + densityCode); return MediaType.LTO4; } @@ -536,8 +616,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO4, + mediumType, + densityCode); return MediaType.LTO4WORM; } @@ -557,8 +639,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("dat", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DDS2_dat, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DDS2_dat, + mediumType, + densityCode); return MediaType.DDS2; } @@ -578,8 +662,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO5, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO5, + mediumType, + densityCode); return MediaType.LTO5; } @@ -599,8 +685,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO5, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_WORM_LTO5, + mediumType, + densityCode); return MediaType.LTO5WORM; } @@ -620,8 +708,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO6_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO6_ult, + mediumType, + densityCode); return MediaType.LTO6; } @@ -643,7 +733,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO6_ult, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.LTO6WORM; } @@ -663,8 +754,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("ult", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_LTO7_ult, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_LTO7_ult, + mediumType, + densityCode); return MediaType.LTO7; } @@ -686,7 +779,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_WORM_LTO7_ult, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.LTO7WORM; } @@ -706,7 +800,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_15m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_15m, + mediumType, densityCode); return MediaType.Exatape15m; @@ -714,16 +809,20 @@ public static partial class MediaTypeFromDevice if(vendor.Equals("ibm", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3592, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3592, + mediumType, + densityCode); return MediaType.IBM3592; } if(model.StartsWith("vxa", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_VXA, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_VXA, + mediumType, + densityCode); return MediaType.VXA1; } @@ -740,7 +839,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_15m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_15m, + mediumType, densityCode); return MediaType.Exatape15m; @@ -754,8 +854,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("ibm", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3592, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3592, + mediumType, + densityCode); return MediaType.IBM3592; } @@ -767,8 +869,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("vxa", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_VXA, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_VXA, + mediumType, + densityCode); return MediaType.VXA1; } @@ -788,7 +892,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_28m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_28m, + mediumType, densityCode); return MediaType.Exatape28m; @@ -796,8 +901,10 @@ public static partial class MediaTypeFromDevice if(vendor.Equals("ibm", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3592, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3592, + mediumType, + densityCode); return MediaType.IBM3592; } @@ -810,7 +917,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("dlt", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_CompactTape, mediumType, + Localization.SCSI_Media_Type_Description_CompactTape, + mediumType, densityCode); return MediaType.CompactTapeI; @@ -828,7 +936,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_28m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_28m, + mediumType, densityCode); return MediaType.Exatape28m; @@ -843,7 +952,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_CompactTapeII, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.CompactTapeII; } @@ -856,8 +966,10 @@ public static partial class MediaTypeFromDevice { if(vendor.Equals("ibm", StringComparison.InvariantCultureIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_IBM3592, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_IBM3592, + mediumType, + densityCode); return MediaType.IBM3592; } @@ -869,8 +981,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("vxa", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_VXA2, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_VXA2, + mediumType, + densityCode); return MediaType.VXA2; } @@ -882,8 +996,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("vxa", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_VXA3, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_VXA3, + mediumType, + densityCode); return MediaType.VXA3; } @@ -903,7 +1019,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_54m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_54m, + mediumType, densityCode); return MediaType.Exatape54m; @@ -911,8 +1028,10 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("dlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIII, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DLTtapeIII, + mediumType, + densityCode); return MediaType.DLTtapeIII; } @@ -929,7 +1048,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_54m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_54m, + mediumType, densityCode); return MediaType.Exatape54m; @@ -946,8 +1066,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("dlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIII, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DLTtapeIII, + mediumType, + densityCode); return MediaType.DLTtapeIII; } @@ -967,7 +1089,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_80m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_80m, + mediumType, densityCode); return MediaType.Exatape80m; @@ -977,7 +1100,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIIIxt, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.DLTtapeIIIxt; } @@ -994,7 +1118,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_80m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_80m, + mediumType, densityCode); return MediaType.Exatape80m; @@ -1011,7 +1136,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIIIxt, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.DLTtapeIIIxt; } @@ -1032,7 +1158,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_106m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape106m; } @@ -1041,8 +1168,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIV, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DLTtapeIV, + mediumType, + densityCode); return MediaType.DLTtapeIV; } @@ -1050,7 +1179,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("stt", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Travan5_stt, mediumType, + Localization.SCSI_Media_Type_Description_Travan5_stt, + mediumType, densityCode); return MediaType.Travan5; @@ -1069,7 +1199,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_106m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape106m; } @@ -1094,8 +1225,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_DLTtapeIV, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_DLTtapeIV, + mediumType, + densityCode); return MediaType.DLTtapeIV; } @@ -1108,7 +1241,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("stt", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Travan5_stt, mediumType, + Localization.SCSI_Media_Type_Description_Travan5_stt, + mediumType, densityCode); return MediaType.Travan5; @@ -1131,7 +1265,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_160m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape160mXL; } @@ -1140,8 +1275,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_SDLT, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_SDLT, + mediumType, + densityCode); return MediaType.SDLT1; } @@ -1155,7 +1292,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_160m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape160mXL; } @@ -1171,8 +1309,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_SDLT, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_SDLT, + mediumType, + densityCode); return MediaType.SDLT1; } @@ -1194,8 +1334,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_SDLT2, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_SDLT2, + mediumType, + densityCode); return MediaType.SDLT2; } @@ -1219,8 +1361,10 @@ public static partial class MediaTypeFromDevice model.StartsWith("sdlt", StringComparison.OrdinalIgnoreCase) || model.StartsWith("superdlt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_VStape, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_VStape, + mediumType, + densityCode); return MediaType.VStapeI; } @@ -1235,8 +1379,10 @@ public static partial class MediaTypeFromDevice { if(model.StartsWith("stt", StringComparison.OrdinalIgnoreCase)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Travan7, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Travan7, + mediumType, + densityCode); return MediaType.Travan7; } @@ -1249,8 +1395,10 @@ public static partial class MediaTypeFromDevice { case 0x45: // HP Colorado tapes have a different capacity but return same density code at least in Seagate drives - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Travan4, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Travan4, + mediumType, + densityCode); return MediaType.Travan4; } @@ -1262,8 +1410,10 @@ public static partial class MediaTypeFromDevice switch(densityCode) { case 0x47: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Travan5, - mediumType, densityCode); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.SCSI_Media_Type_Description_Travan5, + mediumType, + densityCode); return MediaType.Travan5; } @@ -1283,7 +1433,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_22m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_22m, + mediumType, densityCode); return MediaType.Exatape22m; @@ -1309,7 +1460,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_40m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_40m, + mediumType, densityCode); return MediaType.Exatape40m; @@ -1335,7 +1487,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_76m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_76m, + mediumType, densityCode); return MediaType.Exatape76m; @@ -1362,7 +1515,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_112m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape112m; } @@ -1385,7 +1539,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_22m_AME, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape22mAME; } @@ -1408,7 +1563,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_170m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape170m; } @@ -1431,7 +1587,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_125m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape125m; } @@ -1453,7 +1610,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_45m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_45m, + mediumType, densityCode); return MediaType.Exatape45m; @@ -1477,7 +1635,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_225m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape225m; } @@ -1500,7 +1659,8 @@ public static partial class MediaTypeFromDevice { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SCSI_Media_Type_Description_Exatape_150m, - mediumType, densityCode); + mediumType, + densityCode); return MediaType.Exatape150m; } @@ -1522,7 +1682,8 @@ public static partial class MediaTypeFromDevice if(model.StartsWith("exb", StringComparison.OrdinalIgnoreCase)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SCSI_Media_Type_Description_Exatape_75m, mediumType, + Localization.SCSI_Media_Type_Description_Exatape_75m, + mediumType, densityCode); return MediaType.Exatape75m; diff --git a/Aaru.CommonTypes/Metadata/DeviceReport.cs b/Aaru.CommonTypes/Metadata/DeviceReport.cs index cfc0b3136..aca058ecc 100644 --- a/Aaru.CommonTypes/Metadata/DeviceReport.cs +++ b/Aaru.CommonTypes/Metadata/DeviceReport.cs @@ -59,7 +59,8 @@ using Aaru.CommonTypes.Structs.Devices.SCSI.Modes; namespace Aaru.CommonTypes.Metadata; // ReSharper disable once PartialTypeWithSinglePart -[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +[JsonSourceGenerationOptions(WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, IncludeFields = true)] [JsonSerializable(typeof(DeviceReport))] public partial class DeviceReportContext : JsonSerializerContext; @@ -1269,11 +1270,9 @@ public class DensityCode : IEquatable public bool Equals(DensityCode other) { - if(ReferenceEquals(null, other)) - return false; + if(ReferenceEquals(null, other)) return false; - if(ReferenceEquals(this, other)) - return true; + if(ReferenceEquals(this, other)) return true; return Code == other.Code; } @@ -1282,11 +1281,9 @@ public class DensityCode : IEquatable public override bool Equals(object obj) { - if(ReferenceEquals(null, obj)) - return false; + if(ReferenceEquals(null, obj)) return false; - if(ReferenceEquals(this, obj)) - return true; + if(ReferenceEquals(this, obj)) return true; return obj.GetType() == GetType() && Equals((DensityCode)obj); } diff --git a/Aaru.CommonTypes/Metadata/Resume.cs b/Aaru.CommonTypes/Metadata/Resume.cs index 7aaca0c16..ce20f18fd 100644 --- a/Aaru.CommonTypes/Metadata/Resume.cs +++ b/Aaru.CommonTypes/Metadata/Resume.cs @@ -44,9 +44,11 @@ using Aaru.CommonTypes.AaruMetadata; namespace Aaru.CommonTypes.Metadata; -[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +[JsonSourceGenerationOptions(WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, IncludeFields = true)] [JsonSerializable(typeof(ResumeJson))] + // ReSharper disable once PartialTypeWithSinglePart public partial class ResumeJsonContext : JsonSerializerContext; diff --git a/Aaru.CommonTypes/Metadata/Statistics.cs b/Aaru.CommonTypes/Metadata/Statistics.cs index 58bad04d1..a97c5f2bc 100644 --- a/Aaru.CommonTypes/Metadata/Statistics.cs +++ b/Aaru.CommonTypes/Metadata/Statistics.cs @@ -95,9 +95,11 @@ public class Stats public VerifyStats Verify { get; set; } } -[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +[JsonSourceGenerationOptions(WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, IncludeFields = true)] [JsonSerializable(typeof(StatsDto))] + // ReSharper disable once PartialTypeWithSinglePart public partial class StatsDtoContext : JsonSerializerContext; diff --git a/Aaru.CommonTypes/Partition.cs b/Aaru.CommonTypes/Partition.cs index 44a23b2a3..a524a3dc0 100644 --- a/Aaru.CommonTypes/Partition.cs +++ b/Aaru.CommonTypes/Partition.cs @@ -91,11 +91,9 @@ public struct Partition : IEquatable, IComparable /// public int CompareTo(Partition other) { - if(Start == other.Start && End == other.End) - return 0; + if(Start == other.Start && End == other.End) return 0; - if(Start > other.Start || End > other.End) - return 1; + if(Start > other.Start || End > other.End) return 1; return -1; } diff --git a/Aaru.CommonTypes/PluginRegister.cs b/Aaru.CommonTypes/PluginRegister.cs index 1ec417a56..62f7168c2 100644 --- a/Aaru.CommonTypes/PluginRegister.cs +++ b/Aaru.CommonTypes/PluginRegister.cs @@ -55,6 +55,7 @@ public class PluginRegister get { SortedDictionary byteAddressableImages = new(); + foreach(IByteAddressableImage plugin in _serviceProvider.GetServices()) byteAddressableImages[plugin.Name.ToLower()] = plugin; @@ -68,6 +69,7 @@ public class PluginRegister get { SortedDictionary mediaImages = new(); + foreach(IBaseWritableImage plugin in _serviceProvider.GetServices()) mediaImages[plugin.Name.ToLower()] = plugin; @@ -81,6 +83,7 @@ public class PluginRegister get { SortedDictionary floppyImages = new(); + foreach(IWritableFloppyImage plugin in _serviceProvider.GetServices()) floppyImages[plugin.Name.ToLower()] = plugin; @@ -94,6 +97,7 @@ public class PluginRegister get { SortedDictionary floppyImages = new(); + foreach(IFloppyImage plugin in _serviceProvider.GetServices()) floppyImages[plugin.Name.ToLower()] = plugin; @@ -107,6 +111,7 @@ public class PluginRegister get { SortedDictionary mediaImages = new(); + foreach(IMediaImage plugin in _serviceProvider.GetServices()) mediaImages[plugin.Name.ToLower()] = plugin; @@ -120,6 +125,7 @@ public class PluginRegister get { SortedDictionary readOnlyFilesystems = new(); + foreach(IReadOnlyFilesystem plugin in _serviceProvider.GetServices()) readOnlyFilesystems[plugin.Name.ToLower()] = plugin; @@ -133,6 +139,7 @@ public class PluginRegister get { SortedDictionary filesystems = new(); + foreach(IFilesystem plugin in _serviceProvider.GetServices()) filesystems[plugin.Name.ToLower()] = plugin; @@ -146,6 +153,7 @@ public class PluginRegister get { SortedDictionary archives = new(); + foreach(IArchive plugin in _serviceProvider.GetServices()) archives[plugin.Name.ToLower()] = plugin; @@ -159,6 +167,7 @@ public class PluginRegister get { SortedDictionary partitions = new(); + foreach(IPartition plugin in _serviceProvider.GetServices()) partitions[plugin.Name.ToLower()] = plugin; @@ -172,8 +181,8 @@ public class PluginRegister get { SortedDictionary filters = new(); - foreach(IFilter plugin in _serviceProvider.GetServices()) - filters[plugin.Name.ToLower()] = plugin; + + foreach(IFilter plugin in _serviceProvider.GetServices()) filters[plugin.Name.ToLower()] = plugin; return filters; } @@ -185,6 +194,7 @@ public class PluginRegister get { SortedDictionary checksums = new(); + foreach(IChecksum plugin in _serviceProvider.GetServices()) checksums[plugin.Name.ToLower()] = plugin; @@ -197,8 +207,7 @@ public class PluginRegister { get { - if(_instance != null) - return _instance; + if(_instance != null) return _instance; _instance = new PluginRegister { @@ -220,8 +229,7 @@ public class PluginRegister { _services = new ServiceCollection(); - foreach(IPluginRegister registrator in registrators) - AddPlugins(registrator); + foreach(IPluginRegister registrator in registrators) AddPlugins(registrator); _instance._serviceProvider = _instance._services.BuildServiceProvider(); } @@ -256,14 +264,12 @@ public class PluginRegister { if(filter.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) { - if(!filter.Identify(path)) - continue; + if(!filter.Identify(path)) continue; var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()); - if(foundFilter?.Open(path) == ErrorNumber.NoError) - return foundFilter; + if(foundFilter?.Open(path) == ErrorNumber.NoError) return foundFilter; } else noFilter = filter; @@ -274,8 +280,7 @@ public class PluginRegister } } - if(!noFilter?.Identify(path) == true) - return null; + if(!noFilter?.Identify(path) == true) return null; noFilter?.Open(path); diff --git a/Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs b/Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs index d705ed869..377a599cb 100644 --- a/Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs +++ b/Aaru.CommonTypes/Structs/Devices/ATA/Identify.cs @@ -114,7 +114,7 @@ public static class Identify MustBeClear = 0x8000, /// MUST be set MustBeSet = 0x4000, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, @@ -128,7 +128,7 @@ public static class Identify Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Indicates a device specific minimum standby timer value SpecificStandbyTimer = 0x0001 } @@ -153,9 +153,9 @@ public static class Identify SanitizeCommands = 0x0008, /// SANITIZE ANTIFREEZE LOCK EXT is supported SanitizeAntifreeze = 0x0004, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved01 = 0x0002, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Multiple logical sector setting is valid MultipleValid = 0x0001 } @@ -298,12 +298,12 @@ public static class Identify MustBeClear = 0x8000, /// MUST be set MustBeSet = 0x4000, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, - #pragma warning restore 1591 +#pragma warning restore 1591 /// DSN feature set is supported DSN = 0x0200, /// Accessible Max Address Configuration is supported @@ -376,7 +376,7 @@ public static class Identify [Flags] public enum DataSetMgmtBit : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, @@ -392,7 +392,7 @@ public static class Identify Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002, - #pragma warning restore 1591 +#pragma warning restore 1591 /// TRIM is supported Trim = 0x0001 } @@ -496,12 +496,12 @@ public static class Identify [Flags] public enum MajorVersionBit : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved12 = 0x1000, - #pragma warning restore 1591 +#pragma warning restore 1591 /// ACS-4 ACS4 = 0x0800, /// ACS-3 @@ -524,9 +524,9 @@ public static class Identify Ata2 = 0x0004, /// ATA-1 Ata1 = 0x0002, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved00 = 0x0001 - #pragma warning restore 1591 +#pragma warning restore 1591 } #endregion @@ -553,12 +553,12 @@ public static class Identify PowerReceipt = 0x0200, /// Supports NCQ NCQ = 0x0100, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved04 = 0x0010, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Supports SATA Gen. 3 Signaling Speed (6.0Gb/s) Gen3Speed = 0x0008, /// Supports SATA Gen. 2 Signaling Speed (3.0Gb/s) @@ -577,7 +577,7 @@ public static class Identify [Flags] public enum SATACapabilitiesBit2 : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, @@ -587,7 +587,7 @@ public static class Identify Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Supports RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED FPDMAQ = 0x0040, /// Supports NCQ Queue Management @@ -616,7 +616,7 @@ public static class Identify [Flags] public enum SATAFeaturesBit : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, @@ -625,7 +625,7 @@ public static class Identify Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Supports NCQ autosense NCQAutoSense = 0x0080, /// Automatic Partial to Slumber transitions are enabled @@ -656,7 +656,7 @@ public static class Identify [Flags] public enum SCTCommandTransportBit : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Vendor15 = 0x8000, Vendor14 = 0x4000, Vendor13 = 0x2000, @@ -667,7 +667,7 @@ public static class Identify Reserved08 = 0x0100, Reserved07 = 0x0080, Reserved06 = 0x0040, - #pragma warning restore 1591 +#pragma warning restore 1591 /// SCT Command Transport Data Tables supported DataTables = 0x0020, /// SCT Command Transport Features Control supported @@ -690,7 +690,7 @@ public static class Identify [Flags] public enum SecurityStatusBit : ushort { - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, @@ -698,13 +698,13 @@ public static class Identify Reserved11 = 0x0800, Reserved10 = 0x0400, Reserved09 = 0x0200, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Maximum security level Maximum = 0x0100, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved07 = 0x0080, Reserved06 = 0x0040, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Supports enhanced security erase Enhanced = 0x0020, /// Security count expired @@ -744,7 +744,7 @@ public static class Identify [Flags] public enum TransferMode : byte { - #pragma warning disable 1591 +#pragma warning disable 1591 Mode7 = 0x80, Mode6 = 0x40, Mode5 = 0x20, @@ -753,7 +753,7 @@ public static class Identify Mode2 = 0x04, Mode1 = 0x02, Mode0 = 0x01 - #pragma warning restore 1591 +#pragma warning restore 1591 } #endregion @@ -768,7 +768,7 @@ public static class Identify Clear = 0x8000, /// MUST be set Set = 0x4000, - #pragma warning disable 1591 +#pragma warning disable 1591 Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, @@ -782,7 +782,7 @@ public static class Identify Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002, - #pragma warning restore 1591 +#pragma warning restore 1591 /// Trusted Computing feature set is supported TrustedComputing = 0x0001 } @@ -796,8 +796,7 @@ public static class Identify /// Decoded IDENTIFY DEVICE public static IdentifyDevice? Decode(byte[] IdentifyDeviceResponse) { - if(IdentifyDeviceResponse == null) - return null; + if(IdentifyDeviceResponse == null) return null; if(IdentifyDeviceResponse.Length != 512) { @@ -827,8 +826,7 @@ public static class Identify /// Raw IDENTIFY DEVICE response public static byte[] Encode(IdentifyDevice? identify) { - if(identify is null) - return null; + if(identify is null) return null; IdentifyDevice ataId = identify.Value; @@ -893,11 +891,9 @@ public static class Identify { var buf = new byte[length]; - for(var i = 0; i < length; i++) - buf[i] = 0x20; + for(var i = 0; i < length; i++) buf[i] = 0x20; - if(str is null) - return buf; + if(str is null) return buf; byte[] bytes = Encoding.ASCII.GetBytes(str); diff --git a/Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs b/Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs index 9a9ee87e3..d7612d076 100644 --- a/Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs +++ b/Aaru.CommonTypes/Structs/Devices/SCSI/Inquiry.cs @@ -271,8 +271,7 @@ public struct Inquiry public static Inquiry? Decode(byte[] SCSIInquiryResponse) { - if(SCSIInquiryResponse == null) - return null; + if(SCSIInquiryResponse == null) return null; if(SCSIInquiryResponse.Length < 36 && SCSIInquiryResponse.Length != 5) { @@ -287,9 +286,10 @@ public struct Inquiry SCSIInquiryResponse.Length != SCSIInquiryResponse[4]) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field, - SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4); + Localization + .INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field, + SCSIInquiryResponse.Length, + SCSIInquiryResponse[4] + 4); return null; } @@ -324,8 +324,7 @@ public struct Inquiry decoded.ResponseDataFormat = (byte)(SCSIInquiryResponse[3] & 0x07); } - if(SCSIInquiryResponse.Length >= 5) - decoded.AdditionalLength = SCSIInquiryResponse[4]; + if(SCSIInquiryResponse.Length >= 5) decoded.AdditionalLength = SCSIInquiryResponse[4]; if(SCSIInquiryResponse.Length >= 6) { @@ -465,8 +464,7 @@ public struct Inquiry decoded.IUS = Convert.ToBoolean(SCSIInquiryResponse[56] & 0x01); } - if(SCSIInquiryResponse.Length >= 58) - decoded.Reserved4 = SCSIInquiryResponse[57]; + if(SCSIInquiryResponse.Length >= 58) decoded.Reserved4 = SCSIInquiryResponse[57]; if(SCSIInquiryResponse.Length >= 60) { @@ -511,8 +509,7 @@ public struct Inquiry Array.Copy(SCSIInquiryResponse, 96, decoded.Seagate_Copyright, 0, 48); } - if(SCSIInquiryResponse.Length < 148) - return decoded; + if(SCSIInquiryResponse.Length < 148) return decoded; // Seagate 2 decoded.Seagate3Present = true; @@ -527,8 +524,7 @@ public struct Inquiry /// Raw SCSI INQUIRY response public static byte[] Encode(Inquiry? inq) { - if(inq is null) - return null; + if(inq is null) return null; Inquiry decoded = inq.Value; @@ -538,8 +534,7 @@ public struct Inquiry buffer[0] = (byte)(decoded.PeripheralQualifier << 5); buffer[0] += decoded.PeripheralDeviceType; - if(decoded.RMB) - buffer[1] = 0x80; + if(decoded.RMB) buffer[1] = 0x80; buffer[1] += decoded.DeviceTypeModifier; @@ -547,17 +542,13 @@ public struct Inquiry buffer[2] += (byte)(decoded.ECMAVersion << 3); buffer[2] += decoded.ANSIVersion; - if(decoded.AERC) - buffer[3] = 0x80; + if(decoded.AERC) buffer[3] = 0x80; - if(decoded.TrmTsk) - buffer[3] += 0x40; + if(decoded.TrmTsk) buffer[3] += 0x40; - if(decoded.NormACA) - buffer[3] += 0x20; + if(decoded.NormACA) buffer[3] += 0x20; - if(decoded.HiSup) - buffer[3] += 0x10; + if(decoded.HiSup) buffer[3] += 0x10; buffer[3] += decoded.ResponseDataFormat; @@ -576,21 +567,17 @@ public struct Inquiry { length = 6; - if(decoded.SCCS) - buffer[5] = 0x80; + if(decoded.SCCS) buffer[5] = 0x80; - if(decoded.ACC) - buffer[5] += 0x40; + if(decoded.ACC) buffer[5] += 0x40; buffer[5] += (byte)(decoded.TPGS << 4); - if(decoded.ThreePC) - buffer[5] += 0x08; + if(decoded.ThreePC) buffer[5] += 0x08; buffer[5] += (byte)(decoded.Reserved2 << 1); - if(decoded.Protect) - buffer[5] += 0x01; + if(decoded.Protect) buffer[5] += 0x01; } if(decoded.BQue || @@ -604,29 +591,21 @@ public struct Inquiry { length = 7; - if(decoded.BQue) - buffer[6] = 0x80; + if(decoded.BQue) buffer[6] = 0x80; - if(decoded.EncServ) - buffer[6] += 0x40; + if(decoded.EncServ) buffer[6] += 0x40; - if(decoded.VS1) - buffer[6] += 0x20; + if(decoded.VS1) buffer[6] += 0x20; - if(decoded.MultiP) - buffer[6] += 0x10; + if(decoded.MultiP) buffer[6] += 0x10; - if(decoded.MChngr) - buffer[6] += 0x08; + if(decoded.MChngr) buffer[6] += 0x08; - if(decoded.ACKREQQ) - buffer[6] += 0x04; + if(decoded.ACKREQQ) buffer[6] += 0x04; - if(decoded.Addr32) - buffer[6] += 0x02; + if(decoded.Addr32) buffer[6] += 0x02; - if(decoded.Addr16) - buffer[6] += 0x01; + if(decoded.Addr16) buffer[6] += 0x01; } if(decoded.RelAddr || @@ -641,36 +620,31 @@ public struct Inquiry { length = 8; - if(decoded.RelAddr) - buffer[7] = 0x80; + if(decoded.RelAddr) buffer[7] = 0x80; - if(decoded.WBus32) - buffer[7] += 0x40; + if(decoded.WBus32) buffer[7] += 0x40; - if(decoded.WBus16) - buffer[7] += 0x20; + if(decoded.WBus16) buffer[7] += 0x20; - if(decoded.Sync) - buffer[7] += 0x10; + if(decoded.Sync) buffer[7] += 0x10; - if(decoded.Linked) - buffer[7] += 0x08; + if(decoded.Linked) buffer[7] += 0x08; - if(decoded.TranDis) - buffer[7] += 0x04; + if(decoded.TranDis) buffer[7] += 0x04; - if(decoded.CmdQue) - buffer[7] += 0x02; + if(decoded.CmdQue) buffer[7] += 0x02; - if(decoded.SftRe) - buffer[7] += 0x01; + if(decoded.SftRe) buffer[7] += 0x01; } if(decoded.VendorIdentification != null) { length = 16; - Array.Copy(decoded.VendorIdentification, 0, buffer, 8, + Array.Copy(decoded.VendorIdentification, + 0, + buffer, + 8, decoded.VendorIdentification.Length >= 8 ? 8 : decoded.VendorIdentification.Length); } @@ -678,7 +652,10 @@ public struct Inquiry { length = 32; - Array.Copy(decoded.ProductIdentification, 0, buffer, 16, + Array.Copy(decoded.ProductIdentification, + 0, + buffer, + 16, decoded.ProductIdentification.Length >= 16 ? 16 : decoded.ProductIdentification.Length); } @@ -686,7 +663,10 @@ public struct Inquiry { length = 36; - Array.Copy(decoded.ProductRevisionLevel, 0, buffer, 32, + Array.Copy(decoded.ProductRevisionLevel, + 0, + buffer, + 32, decoded.ProductRevisionLevel.Length >= 4 ? 4 : decoded.ProductRevisionLevel.Length); } @@ -708,8 +688,7 @@ public struct Inquiry { length = 49; - if(decoded.HP_WORM) - buffer[40] = 0x01; + if(decoded.HP_WORM) buffer[40] = 0x01; buffer[40] += (byte)(decoded.HP_WORMVersion << 1); Array.Copy(decoded.HP_OBDR, 0, buffer, 43, 6); @@ -720,8 +699,7 @@ public struct Inquiry length = 56; Array.Copy(HiMDSignatureContents, 0, buffer, 36, 8); - if(decoded.HiMDSpecific != null) - Array.Copy(decoded.HiMDSpecific, 0, buffer, 44, 12); + if(decoded.HiMDSpecific != null) Array.Copy(decoded.HiMDSpecific, 0, buffer, 44, 12); } if(decoded is { VendorSpecific: not null, IsHiMD: false }) @@ -736,11 +714,9 @@ public struct Inquiry buffer[56] = (byte)(decoded.Reserved3 << 4); buffer[56] += (byte)(decoded.Clocking << 2); - if(decoded.QAS) - buffer[56] += 0x02; + if(decoded.QAS) buffer[56] += 0x02; - if(decoded.IUS) - buffer[56] += 0x01; + if(decoded.IUS) buffer[56] += 0x01; } if(decoded.Reserved4 != 0) diff --git a/Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs b/Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs index 0e4e30c13..f5b3d6a2a 100644 --- a/Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs +++ b/Aaru.CommonTypes/Structs/Devices/SCSI/Modes/2A.cs @@ -215,6 +215,7 @@ public class ModePage_2A /// Database ID [JsonIgnore] [Key] + // ReSharper disable once UnusedMember.Global public int Id { get; set; } @@ -223,17 +224,13 @@ public class ModePage_2A /// Decoded page 2Ah public static ModePage_2A Decode(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x2A) - return null; + if((pageResponse?[0] & 0x3F) != 0x2A) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_2A(); @@ -266,8 +263,7 @@ public class ModePage_2A decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]); decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]); - if(pageResponse.Length < 20) - return decoded; + if(pageResponse.Length < 20) return decoded; decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04; decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02; @@ -288,8 +284,7 @@ public class ModePage_2A decoded.RCK |= (pageResponse[17] & 0x04) == 0x04; decoded.BCK |= (pageResponse[17] & 0x02) == 0x02; - if(pageResponse.Length < 22) - return decoded; + if(pageResponse.Length < 22) return decoded; decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04; decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]); @@ -297,8 +292,7 @@ public class ModePage_2A decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80; - if(pageResponse.Length < 26) - return decoded; + if(pageResponse.Length < 26) return decoded; decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20; decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10; @@ -312,8 +306,7 @@ public class ModePage_2A decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]); - if(pageResponse.Length < 32) - return decoded; + if(pageResponse.Length < 32) return decoded; decoded.BUF |= (pageResponse[4] & 0x80) == 0x80; decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03); @@ -344,61 +337,43 @@ public class ModePage_2A pageResponse[0] = 0x2A; - if(decoded.PS) - pageResponse[0] += 0x80; + if(decoded.PS) pageResponse[0] += 0x80; - if(decoded.AudioPlay) - pageResponse[4] += 0x01; + if(decoded.AudioPlay) pageResponse[4] += 0x01; - if(decoded.Mode2Form1) - pageResponse[4] += 0x10; + if(decoded.Mode2Form1) pageResponse[4] += 0x10; - if(decoded.Mode2Form2) - pageResponse[4] += 0x20; + if(decoded.Mode2Form2) pageResponse[4] += 0x20; - if(decoded.MultiSession) - pageResponse[4] += 0x40; + if(decoded.MultiSession) pageResponse[4] += 0x40; - if(decoded.CDDACommand) - pageResponse[5] += 0x01; + if(decoded.CDDACommand) pageResponse[5] += 0x01; - if(decoded.AccurateCDDA) - pageResponse[5] += 0x02; + if(decoded.AccurateCDDA) pageResponse[5] += 0x02; - if(decoded.Subchannel) - pageResponse[5] += 0x04; + if(decoded.Subchannel) pageResponse[5] += 0x04; - if(decoded.DeinterlaveSubchannel) - pageResponse[5] += 0x08; + if(decoded.DeinterlaveSubchannel) pageResponse[5] += 0x08; - if(decoded.C2Pointer) - pageResponse[5] += 0x10; + if(decoded.C2Pointer) pageResponse[5] += 0x10; - if(decoded.UPC) - pageResponse[5] += 0x20; + if(decoded.UPC) pageResponse[5] += 0x20; - if(decoded.ISRC) - pageResponse[5] += 0x40; + if(decoded.ISRC) pageResponse[5] += 0x40; decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5); - if(decoded.Lock) - pageResponse[6] += 0x01; + if(decoded.Lock) pageResponse[6] += 0x01; - if(decoded.LockState) - pageResponse[6] += 0x02; + if(decoded.LockState) pageResponse[6] += 0x02; - if(decoded.PreventJumper) - pageResponse[6] += 0x04; + if(decoded.PreventJumper) pageResponse[6] += 0x04; - if(decoded.Eject) - pageResponse[6] += 0x08; + if(decoded.Eject) pageResponse[6] += 0x08; - if(decoded.SeparateChannelVolume) - pageResponse[7] += 0x01; + if(decoded.SeparateChannelVolume) pageResponse[7] += 0x01; - if(decoded.SeparateChannelMute) - pageResponse[7] += 0x02; + if(decoded.SeparateChannelMute) pageResponse[7] += 0x02; decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]); decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]); @@ -422,62 +397,47 @@ public class ModePage_2A { length = 20; - if(decoded.Method2) - pageResponse[2] += 0x04; + if(decoded.Method2) pageResponse[2] += 0x04; - if(decoded.ReadCDRW) - pageResponse[2] += 0x02; + if(decoded.ReadCDRW) pageResponse[2] += 0x02; - if(decoded.ReadCDR) - pageResponse[2] += 0x01; + if(decoded.ReadCDR) pageResponse[2] += 0x01; - if(decoded.WriteCDRW) - pageResponse[3] += 0x02; + if(decoded.WriteCDRW) pageResponse[3] += 0x02; - if(decoded.WriteCDR) - pageResponse[3] += 0x01; + if(decoded.WriteCDR) pageResponse[3] += 0x01; - if(decoded.Composite) - pageResponse[4] += 0x02; + if(decoded.Composite) pageResponse[4] += 0x02; - if(decoded.DigitalPort1) - pageResponse[4] += 0x04; + if(decoded.DigitalPort1) pageResponse[4] += 0x04; - if(decoded.DigitalPort2) - pageResponse[4] += 0x08; + if(decoded.DigitalPort2) pageResponse[4] += 0x08; - if(decoded.SDP) - pageResponse[7] += 0x04; + if(decoded.SDP) pageResponse[7] += 0x04; - if(decoded.SSS) - pageResponse[7] += 0x08; + if(decoded.SSS) pageResponse[7] += 0x08; pageResponse[17] = (byte)(decoded.Length << 4); - if(decoded.LSBF) - pageResponse[17] += 0x08; + if(decoded.LSBF) pageResponse[17] += 0x08; - if(decoded.RCK) - pageResponse[17] += 0x04; + if(decoded.RCK) pageResponse[17] += 0x04; - if(decoded.BCK) - pageResponse[17] += 0x02; + if(decoded.BCK) pageResponse[17] += 0x02; } if(decoded.TestWrite || decoded.MaxWriteSpeed > 0 || decoded.CurrentWriteSpeed > 0 || decoded.ReadBarcode) { length = 22; - if(decoded.TestWrite) - pageResponse[3] += 0x04; + if(decoded.TestWrite) pageResponse[3] += 0x04; pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8); pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF); pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8); pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF); - if(decoded.ReadBarcode) - pageResponse[5] += 0x80; + if(decoded.ReadBarcode) pageResponse[5] += 0x80; } if(decoded.ReadDVDRAM || @@ -492,26 +452,19 @@ public class ModePage_2A { length = 26; - if(decoded.ReadDVDRAM) - pageResponse[2] += 0x20; + if(decoded.ReadDVDRAM) pageResponse[2] += 0x20; - if(decoded.ReadDVDR) - pageResponse[2] += 0x10; + if(decoded.ReadDVDR) pageResponse[2] += 0x10; - if(decoded.ReadDVDROM) - pageResponse[2] += 0x08; + if(decoded.ReadDVDROM) pageResponse[2] += 0x08; - if(decoded.WriteDVDRAM) - pageResponse[3] += 0x20; + if(decoded.WriteDVDRAM) pageResponse[3] += 0x20; - if(decoded.WriteDVDR) - pageResponse[3] += 0x10; + if(decoded.WriteDVDR) pageResponse[3] += 0x10; - if(decoded.LeadInPW) - pageResponse[3] += 0x20; + if(decoded.LeadInPW) pageResponse[3] += 0x20; - if(decoded.SCC) - pageResponse[3] += 0x10; + if(decoded.SCC) pageResponse[3] += 0x10; pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8); pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF); @@ -521,8 +474,7 @@ public class ModePage_2A { length = 32; - if(decoded.BUF) - pageResponse[4] += 0x80; + if(decoded.BUF) pageResponse[4] += 0x80; pageResponse[27] += decoded.RotationControlSelected; pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8); diff --git a/Aaru.CommonTypes/Structs/Filesystems.cs b/Aaru.CommonTypes/Structs/Filesystems.cs index 770c6b1e8..794cc5a68 100644 --- a/Aaru.CommonTypes/Structs/Filesystems.cs +++ b/Aaru.CommonTypes/Structs/Filesystems.cs @@ -164,49 +164,49 @@ public class FileEntryInfo { /// File attributes public FileAttributes Attributes { get; set; } - + /// File length in blocks public long Blocks { get; set; } - + /// File block size in bytes public long BlockSize { get; set; } - + /// If file points to a device, device number. Null if the underlying filesystem does not support them. public ulong? DeviceNo { get; set; } - + /// POSIX group ID. Null if the underlying filesystem does not support them. public ulong? GID { get; set; } - + /// inode number for this file (or other unique identifier for the volume) public ulong Inode { get; set; } - + /// File length in bytes public long Length { get; set; } - + /// Number of hard links pointing to this file (. and .. entries count as hard links) public ulong Links { get; set; } - + /// POSIX permissions/mode for this file. Null if the underlying filesystem does not support them. public uint? Mode { get; set; } - + /// POSIX owner ID. Null if the underlying filesystem does not support them. public ulong? UID { get; set; } - + /// File creation date in UTC. Null if the underlying filesystem does not support them. public DateTime? CreationTimeUtc { get; set; } - + /// File last access date in UTC. Null if the underlying filesystem does not support them. public DateTime? AccessTimeUtc { get; set; } - + /// File attributes change date in UTC. Null if the underlying filesystem does not support them. public DateTime? StatusChangeTimeUtc { get; set; } - + /// File last backup date in UTC. Null if the underlying filesystem does not support them. public DateTime? BackupTimeUtc { get; set; } - + /// File last modification date in UTC. Null if the underlying filesystem does not support them. public DateTime? LastWriteTimeUtc { get; set; } - + /// File creation date. Null if the underlying filesystem does not support them. [JsonIgnore] public DateTime? CreationTime @@ -214,7 +214,7 @@ public class FileEntryInfo get => CreationTimeUtc?.ToLocalTime(); set => CreationTimeUtc = value?.ToUniversalTime(); } - + /// File last access date. Null if the underlying filesystem does not support them. [JsonIgnore] public DateTime? AccessTime @@ -222,7 +222,7 @@ public class FileEntryInfo get => AccessTimeUtc?.ToLocalTime(); set => AccessTimeUtc = value?.ToUniversalTime(); } - + /// File attributes change date. Null if the underlying filesystem does not support them. [JsonIgnore] public DateTime? StatusChangeTime @@ -230,7 +230,7 @@ public class FileEntryInfo get => StatusChangeTimeUtc?.ToLocalTime(); set => StatusChangeTimeUtc = value?.ToUniversalTime(); } - + /// File last backup date. Null if the underlying filesystem does not support them. [JsonIgnore] public DateTime? BackupTime @@ -238,7 +238,7 @@ public class FileEntryInfo get => BackupTimeUtc?.ToLocalTime(); set => BackupTimeUtc = value?.ToUniversalTime(); } - + /// File last modification date. Null if the underlying filesystem does not support them. [JsonIgnore] public DateTime? LastWriteTime @@ -268,10 +268,10 @@ public class FileSystemInfo public Guid PluginId; /// Filesystem type public string Type; - + /// Initializes an empty instance of this structure public FileSystemInfo() => Id = new FileSystemId(); - + /// Gets a clone of this structure /// Clone of this structure public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone(); @@ -290,7 +290,7 @@ public struct FileSystemId /// Set to true if the identifier is a GUID [FieldOffset(2)] public bool IsGuid; - + /// Identifier as a 32-bit integer [FieldOffset(3)] public uint Serial32; diff --git a/Aaru.Compression/ADC.cs b/Aaru.Compression/ADC.cs index 5cc328894..144393ff7 100644 --- a/Aaru.Compression/ADC.cs +++ b/Aaru.Compression/ADC.cs @@ -57,7 +57,11 @@ public static class ADC static extern int AARU_adc_decode_buffer(byte[] dstBuffer, int dstSize, byte[] srcBuffer, int srcSize); [MethodImpl(MethodImplOptions.AggressiveInlining)] - static int GetChunkType(byte byt) => (byt & 0x80) == 0x80 ? PLAIN : (byt & 0x40) == 0x40 ? THREE_BYTE : TWO_BYTE; + static int GetChunkType(byte byt) => (byt & 0x80) == 0x80 + ? PLAIN + : (byt & 0x40) == 0x40 + ? THREE_BYTE + : TWO_BYTE; [MethodImpl(MethodImplOptions.AggressiveInlining)] static int GetChunkSize(byte byt) => GetChunkType(byt) switch @@ -84,8 +88,7 @@ public static class ADC [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static int DecodeBuffer(byte[] source, byte[] destination) { - if(Native.IsSupported) - return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length); + if(Native.IsSupported) return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length); var inputPosition = 0; var outPosition = 0; @@ -106,8 +109,7 @@ public static class ADC case PLAIN: chunkSize = GetChunkSize(readByte); - if(outPosition + chunkSize > destination.Length) - goto finished; + if(outPosition + chunkSize > destination.Length) goto finished; Array.Copy(source, inputPosition, destination, outPosition, chunkSize); outPosition += chunkSize; @@ -120,8 +122,7 @@ public static class ADC temp[1] = source[inputPosition++]; offset = GetOffset(temp); - if(outPosition + chunkSize > destination.Length) - goto finished; + if(outPosition + chunkSize > destination.Length) goto finished; if(offset == 0) { @@ -150,8 +151,7 @@ public static class ADC temp[2] = source[inputPosition++]; offset = GetOffset(temp); - if(outPosition + chunkSize > destination.Length) - goto finished; + if(outPosition + chunkSize > destination.Length) goto finished; if(offset == 0) { diff --git a/Aaru.Compression/AppleRle.cs b/Aaru.Compression/AppleRle.cs index a49b61903..469a28210 100644 --- a/Aaru.Compression/AppleRle.cs +++ b/Aaru.Compression/AppleRle.cs @@ -92,8 +92,7 @@ public static class AppleRle continue; } - if(inPosition == source.Length) - break; + if(inPosition == source.Length) break; while(true) { @@ -101,8 +100,7 @@ public static class AppleRle byte b2 = source[inPosition++]; var s = (short)(b1 << 8 | b2); - if(s == 0 || s >= DART_CHUNK || s <= -DART_CHUNK) - continue; + if(s == 0 || s >= DART_CHUNK || s <= -DART_CHUNK) continue; if(s < 0) { diff --git a/Aaru.Compression/FLAC.cs b/Aaru.Compression/FLAC.cs index 767ff9afd..9da83c6f4 100644 --- a/Aaru.Compression/FLAC.cs +++ b/Aaru.Compression/FLAC.cs @@ -62,7 +62,9 @@ public class FLAC { if(Native.IsSupported) { - return (int)AARU_flac_decode_redbook_buffer(destination, (nuint)destination.Length, source, + return (int)AARU_flac_decode_redbook_buffer(destination, + (nuint)destination.Length, + source, (nuint)source.Length); } @@ -99,12 +101,21 @@ public class FLAC { if(Native.IsSupported) { - return (int)AARU_flac_encode_redbook_buffer(destination, (nuint)destination.Length, source, - (nuint)source.Length, blockSize, doMidSideStereo ? 1 : 0, - looseMidSideStereo ? 1 : 0, apodization, maxLpcOrder, - qlpCoeffPrecision, doQlpCoeffPrecSearch ? 1 : 0, - doExhaustiveModelSearch ? 1 : 0, minResidualPartitionOrder, - maxResidualPartitionOrder, applicationID, + return (int)AARU_flac_encode_redbook_buffer(destination, + (nuint)destination.Length, + source, + (nuint)source.Length, + blockSize, + doMidSideStereo ? 1 : 0, + looseMidSideStereo ? 1 : 0, + apodization, + maxLpcOrder, + qlpCoeffPrecision, + doQlpCoeffPrecSearch ? 1 : 0, + doExhaustiveModelSearch ? 1 : 0, + minResidualPartitionOrder, + maxResidualPartitionOrder, + applicationID, (uint)applicationID.Length); } @@ -131,11 +142,9 @@ public class FLAC }; // Check if FLAKE's block size is bigger than what we want - if(flakeWriterSettings.BlockSize > 4608) - flakeWriterSettings.BlockSize = 4608; + if(flakeWriterSettings.BlockSize > 4608) flakeWriterSettings.BlockSize = 4608; - if(flakeWriterSettings.BlockSize < 256) - flakeWriterSettings.BlockSize = 256; + if(flakeWriterSettings.BlockSize < 256) flakeWriterSettings.BlockSize = 256; var flacMs = new NonClosableStream(destination); var flakeWriter = new AudioEncoder(flakeWriterSettings, "", flacMs); diff --git a/Aaru.Compression/LZFSE.cs b/Aaru.Compression/LZFSE.cs index ec0f27b91..94a0805ce 100644 --- a/Aaru.Compression/LZFSE.cs +++ b/Aaru.Compression/LZFSE.cs @@ -52,8 +52,10 @@ public class LZFSE public static int DecodeBuffer(byte[] source, byte[] destination) => Native.IsSupported ? (int) AARU_lzfse_decode_buffer(destination, - (nuint)destination.Length, source, - (nuint)source.Length, null) + (nuint)destination.Length, + source, + (nuint)source.Length, + null) : 0; /// Compresses a buffer using BZIP2 @@ -63,7 +65,9 @@ public class LZFSE public static int EncodeBuffer(byte[] source, byte[] destination) => Native.IsSupported ? (int) AARU_lzfse_encode_buffer(destination, - (nuint)destination.Length, source, - (nuint)source.Length, null) + (nuint)destination.Length, + source, + (nuint)source.Length, + null) : 0; } \ No newline at end of file diff --git a/Aaru.Compression/LZIP.cs b/Aaru.Compression/LZIP.cs index 01697494d..d1e5cca13 100644 --- a/Aaru.Compression/LZIP.cs +++ b/Aaru.Compression/LZIP.cs @@ -59,7 +59,11 @@ public class LZIP /// The size of the compressed data public static int EncodeBuffer(byte[] source, byte[] destination, int dictionarySize, int matchLengthLimit) => Native.IsSupported - ? AARU_lzip_encode_buffer(destination, destination.Length, source, source.Length, dictionarySize, + ? AARU_lzip_encode_buffer(destination, + destination.Length, + source, + source.Length, + dictionarySize, matchLengthLimit) : 0; } \ No newline at end of file diff --git a/Aaru.Compression/LZMA.cs b/Aaru.Compression/LZMA.cs index 2f621a93c..3306cd5d1 100644 --- a/Aaru.Compression/LZMA.cs +++ b/Aaru.Compression/LZMA.cs @@ -60,7 +60,11 @@ public class LZMA var srcSize = (nuint)source.Length; var dstSize = (nuint)destination.Length; - AARU_lzma_decode_buffer(destination, ref dstSize, source, ref srcSize, properties, + AARU_lzma_decode_buffer(destination, + ref dstSize, + source, + ref srcSize, + properties, (nuint)properties.Length); return (int)dstSize; @@ -94,8 +98,19 @@ public class LZMA var propsSize = (nuint)properties.Length; var srcSize = (nuint)source.Length; - AARU_lzma_encode_buffer(destination, ref dstSize, source, srcSize, properties, ref propsSize, level, - dictSize, lc, lp, pb, fb, 0); + AARU_lzma_encode_buffer(destination, + ref dstSize, + source, + srcSize, + properties, + ref propsSize, + level, + dictSize, + lc, + lp, + pb, + fb, + 0); return (int)dstSize; } diff --git a/Aaru.Compression/Native.cs b/Aaru.Compression/Native.cs index 0fdf59761..d562d3b7f 100644 --- a/Aaru.Compression/Native.cs +++ b/Aaru.Compression/Native.cs @@ -51,11 +51,9 @@ public static class Native { get { - if(ForceManaged) - return false; + if(ForceManaged) return false; - if(_checked) - return _supported; + if(_checked) return _supported; ulong version; _checked = true; diff --git a/Aaru.Compression/TeleDiskLzh.cs b/Aaru.Compression/TeleDiskLzh.cs index ed40e6021..f252897b8 100644 --- a/Aaru.Compression/TeleDiskLzh.cs +++ b/Aaru.Compression/TeleDiskLzh.cs @@ -147,8 +147,7 @@ public class TeleDiskLzh _tdctl.Bufcnt = 0; StartHuff(); - for(i = 0; i < N - F; i++) - _textBuf[i] = 0x20; + for(i = 0; i < N - F; i++) _textBuf[i] = 0x20; _tdctl.R = N - F; _inStream = dataStream; @@ -175,10 +174,10 @@ public class TeleDiskLzh for(count = 0; count < len;) { short c; + if(_tdctl.Bufcnt == 0) { - if((c = DecodeChar()) < 0) - return count; // fatal error + if((c = DecodeChar()) < 0) return count; // fatal error if(c < 256) { @@ -191,8 +190,7 @@ public class TeleDiskLzh { short pos; - if((pos = DecodePosition()) < 0) - return count; // fatal error + if((pos = DecodePosition()) < 0) return count; // fatal error _tdctl.Bufpos = (ushort)(_tdctl.R - pos - 1 & N - 1); _tdctl.Bufcnt = (ushort)(c - 255 + THRESHOLD); @@ -213,8 +211,7 @@ public class TeleDiskLzh } // reset bufcnt after copy string from text_buf[] - if(_tdctl.Bufndx >= _tdctl.Bufcnt) - _tdctl.Bufndx = _tdctl.Bufcnt = 0; + if(_tdctl.Bufndx >= _tdctl.Bufcnt) _tdctl.Bufndx = _tdctl.Bufcnt = 0; } } @@ -223,8 +220,7 @@ public class TeleDiskLzh long DataRead(out byte[] buf, long size) { - if(size > _inStream.Length - _inStream.Position) - size = _inStream.Length - _inStream.Position; + if(size > _inStream.Length - _inStream.Position) size = _inStream.Length - _inStream.Position; buf = new byte[size]; _inStream.EnsureRead(buf, 0, (int)size); @@ -239,8 +235,7 @@ public class TeleDiskLzh _tdctl.Ibufndx = 0; _tdctl.Ibufcnt = (ushort)DataRead(out _tdctl.Inbuf, BUFSZ); - if(_tdctl.Ibufcnt <= 0) - return -1; + if(_tdctl.Ibufcnt <= 0) return -1; } while(_getlen <= 8) @@ -255,8 +250,7 @@ public class TeleDiskLzh int GetBit() /* get one bit */ { - if(NextWord() < 0) - return -1; + if(NextWord() < 0) return -1; var i = (short)_getbuf; _getbuf <<= 1; @@ -267,8 +261,7 @@ public class TeleDiskLzh int GetByte() /* get a byte */ { - if(NextWord() != 0) - return -1; + if(NextWord() != 0) return -1; ushort i = _getbuf; _getbuf <<= 8; @@ -318,8 +311,7 @@ public class TeleDiskLzh for(i = 0; i < T; i++) { - if(_son[i] < T) - continue; + if(_son[i] < T) continue; _freq[j] = (ushort)((_freq[i] + 1) / 2); _son[j] = _son[i]; @@ -357,8 +349,7 @@ public class TeleDiskLzh void Update(int c) { - if(_freq[ROOT] == MAX_FREQ) - Reconst(); + if(_freq[ROOT] == MAX_FREQ) Reconst(); c = _prnt[c + T]; @@ -369,8 +360,7 @@ public class TeleDiskLzh /* swap nodes to keep the tree freq-ordered */ int l; - if(k <= _freq[l = c + 1]) - continue; + if(k <= _freq[l = c + 1]) continue; while(k > _freq[++l]) {} @@ -381,16 +371,14 @@ public class TeleDiskLzh int i = _son[c]; _prnt[i] = (short)l; - if(i < T) - _prnt[i + 1] = (short)l; + if(i < T) _prnt[i + 1] = (short)l; int j = _son[l]; _son[l] = (short)i; _prnt[j] = (short)c; - if(j < T) - _prnt[j + 1] = (short)c; + if(j < T) _prnt[j + 1] = (short)c; _son[c] = (short)j; @@ -411,8 +399,7 @@ public class TeleDiskLzh { int ret; - if((ret = GetBit()) < 0) - return -1; + if((ret = GetBit()) < 0) return -1; c += (ushort)ret; c = (ushort)_son[c]; @@ -429,8 +416,7 @@ public class TeleDiskLzh short bit; /* decode upper 6 bits from given table */ - if((bit = (short)GetByte()) < 0) - return -1; + if((bit = (short)GetByte()) < 0) return -1; var i = (ushort)bit; var c = (ushort)(_dCode[i] << 6); @@ -441,8 +427,7 @@ public class TeleDiskLzh while(j-- > 0) { - if((bit = (short)GetBit()) < 0) - return -1; + if((bit = (short)GetBit()) < 0) return -1; i = (ushort)((i << 1) + bit); } diff --git a/Aaru.Compression/ZSTD.cs b/Aaru.Compression/ZSTD.cs index ecb625d9f..5d925b4e8 100644 --- a/Aaru.Compression/ZSTD.cs +++ b/Aaru.Compression/ZSTD.cs @@ -60,7 +60,10 @@ public class ZSTD /// Length of the compressed data public static int EncodeBuffer(byte[] source, byte[] destination, int compressionLevel) => (int)(Native.IsSupported - ? AARU_zstd_encode_buffer(destination, (nuint)destination.Length, source, (nuint)source.Length, + ? AARU_zstd_encode_buffer(destination, + (nuint)destination.Length, + source, + (nuint)source.Length, compressionLevel) : 0); } \ No newline at end of file diff --git a/Aaru.Console/AaruConsole.cs b/Aaru.Console/AaruConsole.cs index d57bd8875..cbcbb4ff9 100644 --- a/Aaru.Console/AaruConsole.cs +++ b/Aaru.Console/AaruConsole.cs @@ -257,6 +257,5 @@ public static class AaruConsole /// Writes the exception to the debug output console. /// /// Exception. - public static void WriteException(Exception ex) => - WriteExceptionEvent?.Invoke(ex); + public static void WriteException(Exception ex) => WriteExceptionEvent?.Invoke(ex); } \ No newline at end of file diff --git a/Aaru.Core/ArchiveFormat.cs b/Aaru.Core/ArchiveFormat.cs index 6e533b3e0..c5405cfef 100644 --- a/Aaru.Core/ArchiveFormat.cs +++ b/Aaru.Core/ArchiveFormat.cs @@ -55,21 +55,19 @@ public static class ArchiveFormat // Check all but RAW plugin foreach(IArchive plugin in plugins.Archives.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; try { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Trying_plugin_0, plugin.Name); - if(!plugin.Identify(archiveFilter)) - continue; + if(!plugin.Identify(archiveFilter)) continue; format = plugin; break; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored diff --git a/Aaru.Core/Checksum.cs b/Aaru.Core/Checksum.cs index 5d9a557a5..26236e7ae 100644 --- a/Aaru.Core/Checksum.cs +++ b/Aaru.Core/Checksum.cs @@ -341,41 +341,29 @@ public sealed class Checksum _f16Thread.IsAlive || _f32Thread.IsAlive) {} - if(_enabled.HasFlag(EnableChecksum.Adler32)) - _adlerThread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Adler32)) _adlerThread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Crc16)) - _crc16Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc16)) _crc16Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Crc32)) - _crc32Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc32)) _crc32Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Crc16)) - _crc64Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc16)) _crc64Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Md5)) - _md5Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Md5)) _md5Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Sha1)) - _sha1Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha1)) _sha1Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Sha256)) - _sha256Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha256)) _sha256Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Sha384)) - _sha384Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha384)) _sha384Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Sha512)) - _sha512Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha512)) _sha512Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.SpamSum)) - _spamsumThread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.SpamSum)) _spamsumThread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Fletcher16)) - _f16Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Fletcher16)) _f16Thread = new Thread(UpdateHash); - if(_enabled.HasFlag(EnableChecksum.Fletcher32)) - _f32Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Fletcher32)) _f32Thread = new Thread(UpdateHash); } /// Finishes the checksums @@ -483,8 +471,7 @@ public sealed class Checksum }); } - if(!_enabled.HasFlag(EnableChecksum.Fletcher32)) - return chks; + if(!_enabled.HasFlag(EnableChecksum.Fletcher32)) return chks; chks.Add(new CommonTypes.AaruMetadata.Checksum { @@ -794,8 +781,7 @@ public sealed class Checksum }); } - if(!enabled.HasFlag(EnableChecksum.Fletcher32)) - return dataChecksums; + if(!enabled.HasFlag(EnableChecksum.Fletcher32)) return dataChecksums; dataChecksums.Add(new CommonTypes.AaruMetadata.Checksum { diff --git a/Aaru.Core/DataFile.cs b/Aaru.Core/DataFile.cs index 5d3c10d11..6c5aa76f4 100644 --- a/Aaru.Core/DataFile.cs +++ b/Aaru.Core/DataFile.cs @@ -129,8 +129,7 @@ public sealed class DataFile public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null, bool overwrite = false) { - if(string.IsNullOrEmpty(filename)) - return; + if(string.IsNullOrEmpty(filename)) return; if(File.Exists(filename)) { diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 8e0a00e02..4f5873356 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -149,12 +149,15 @@ public partial class Dump byte heads = ataReader.Heads; byte sectors = ataReader.Sectors; - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Device_reports_0_cylinders_1_heads_2_sectors_per_track, - cylinders, heads, sectors)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Device_reports_0_cylinders_1_heads_2_sectors_per_track, + cylinders, + heads, + sectors)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead)); @@ -166,8 +169,10 @@ public partial class Dump _dumpLog.WriteLine(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, blocks * blockSize); - _dumpLog.WriteLine(Localization.Core.Device_reports_0_cylinders_1_heads_2_sectors_per_track, cylinders, - heads, sectors); + _dumpLog.WriteLine(Localization.Core.Device_reports_0_cylinders_1_heads_2_sectors_per_track, + cylinders, + heads, + sectors); _dumpLog.WriteLine(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead); _dumpLog.WriteLine(Localization.Core.Device_reports_0_bytes_per_logical_block, blockSize); @@ -179,9 +184,19 @@ public partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(ataReader.IsLba, removable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force); + ResumeSupport.Process(ataReader.IsLba, + removable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -237,8 +252,12 @@ public partial class Dump } } - mediaType = MediaTypeFromDevice.GetFromAta(_dev.Manufacturer, _dev.Model, _dev.IsRemovable, - _dev.IsCompactFlash, _dev.IsPcmcia, blocks); + mediaType = MediaTypeFromDevice.GetFromAta(_dev.Manufacturer, + _dev.Model, + _dev.IsRemovable, + _dev.IsCompactFlash, + _dev.IsPcmcia, + blocks); ret = outputFormat.Create(_outputPath, mediaType, _formatOptions, blocks, blockSize); @@ -264,11 +283,15 @@ public partial class Dump { UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); - if(_skip < blocksToRead) - _skip = blocksToRead; + if(_skip < blocksToRead) _skip = blocksToRead; - mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, - _private, _dimensions); + mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, + _dimensions); ibgLog = new IbgLog(_outputPrefix + ".ibg", ataProfile); @@ -314,24 +337,27 @@ public partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize()), + (long)i, + (long)blocks); _speedStopwatch.Start(); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); _speedStopwatch.Stop(); _writeStopwatch.Restart(); + if(!error) { mhddLog.Write(i, duration, blocksToRead); @@ -343,11 +369,9 @@ public partial class Dump } else { - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip); @@ -366,8 +390,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -382,36 +405,41 @@ public partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize()); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -440,8 +468,7 @@ public partial class Dump totalDuration += duration; - if(error && !recoveredError) - continue; + if(error && !recoveredError) continue; _resume.BadBlocks.Remove(badSector); extents.Add(badSector); @@ -459,9 +486,9 @@ public partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -486,22 +513,26 @@ public partial class Dump if(forward) { PulseProgress?.Invoke(_persistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) - : string. - Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badSector, pass)); + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) + : string.Format(Localization.Core + .Retrying_sector_0_pass_1_forward, + badSector, + pass)); } else { PulseProgress?.Invoke(_persistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) - : string. - Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badSector, pass)); + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) + : string.Format(Localization.Core + .Retrying_sector_0_pass_1_reverse, + badSector, + pass)); } bool error = @@ -516,15 +547,16 @@ public partial class Dump outputFormat.WriteSector(cmdBuf, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, - badSector, pass)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Correctly_retried_block_0_in_pass_1, + badSector, + pass)); - _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass); } - else if(_persistent) - outputFormat.WriteSector(cmdBuf, badSector); + else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -533,8 +565,7 @@ public partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetryLba; } @@ -542,14 +573,19 @@ public partial class Dump EndProgress?.Invoke(); } - #endregion Error handling LBA +#endregion Error handling LBA currentTry.Extents = ExtentsConverter.ToMetadata(extents); } else { - mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, - _private, _dimensions); + mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, + _dimensions); ibgLog = new IbgLog(_outputPrefix + ".ibg", ataProfile); @@ -593,21 +629,24 @@ public partial class Dump break; } - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; + + PulseProgress?.Invoke(string.Format(Localization.Core + .Reading_cylinder_0_head_1_sector_2_3, + cy, + hd, + sc, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize())); - PulseProgress?. - Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, cy, hd, - sc, - ByteSize.FromMegabytes(currentSpeed). - Per(_oneSecond). - Humanize())); _speedStopwatch.Start(); + bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out recoveredError); + _speedStopwatch.Stop(); totalDuration += duration; @@ -625,8 +664,10 @@ public partial class Dump extents.Add(currentBlock); _mediaGraph?.PaintSectorGood((ulong)((cy * heads + hd) * sectors + (sc - 1))); - _dumpLog.WriteLine(Localization.Core.Error_reading_cylinder_0_head_1_sector_2, cy, - hd, sc); + _dumpLog.WriteLine(Localization.Core.Error_reading_cylinder_0_head_1_sector_2, + cy, + hd, + sc); } else { @@ -648,8 +689,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -665,34 +705,39 @@ public partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize()); _dumpLog.WriteLine(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize()); } foreach(ulong bad in _resume.BadBlocks) @@ -714,8 +759,7 @@ public partial class Dump outputFormat.ErrorMessage); } - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -744,8 +788,7 @@ public partial class Dump if(_dev.IsUsb && _dev.UsbDescriptors != null) outputFormat.WriteMediaTag(_dev.UsbDescriptors, MediaTagType.USB_Descriptors); - if(_dev.IsPcmcia && _dev.Cis != null) - outputFormat.WriteMediaTag(_dev.Cis, MediaTagType.PCMCIA_CIS); + if(_dev.IsPcmcia && _dev.Cis != null) outputFormat.WriteMediaTag(_dev.Cis, MediaTagType.PCMCIA_CIS); if(_metadata) { @@ -861,8 +904,7 @@ public partial class Dump } } - if(_private) - DeviceReport.ClearIdentify(ataIdentify); + if(_private) DeviceReport.ClearIdentify(ataIdentify); sidecar.BlockMedias[0].ATA = new ATA { @@ -879,21 +921,21 @@ public partial class Dump totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds; UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, - _sidecarStopwatch.Elapsed. - Humanize(minUnit: TimeUnit.Second))); + _sidecarStopwatch.Elapsed + .Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); List<(ulong start, string type)> filesystems = new(); @@ -911,13 +953,15 @@ public partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) { UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1, - filesystem.type, filesystem.start)); + filesystem.type, + filesystem.start)); - _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, + _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, + filesystem.type, filesystem.start); } } @@ -933,8 +977,7 @@ public partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; @@ -949,10 +992,13 @@ public partial class Dump var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -960,18 +1006,18 @@ public partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { @@ -988,8 +1034,7 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); - if(_resume.BadBlocks.Count > 0) - _resume.BadBlocks.Sort(); + if(_resume.BadBlocks.Count > 0) _resume.BadBlocks.Sort(); UpdateStatus?.Invoke(""); } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index 281625128..056956514 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -56,8 +56,7 @@ partial class Dump /// true if it contains Yellow Book data, false otherwise static bool IsData(byte[] sector) { - if(sector?.Length != 2352) - return false; + if(sector?.Length != 2352) return false; byte[] syncMark = { @@ -79,8 +78,7 @@ partial class Dump { offset = 0; - if(sector?.Length != 2352) - return false; + if(sector?.Length != 2352) return false; byte[] syncMark = { @@ -166,8 +164,7 @@ partial class Dump uint blocksToRead; // How many sectors to read at once var outputOptical = _outputPlugin as IWritableOpticalImage; - if(firstTrack is null) - return; + if(firstTrack is null) return; if(cdiReadyReadAsAudio) { @@ -194,8 +191,7 @@ partial class Dump blocksToRead = _maximumReadable; - if(blocksToRead == 1 && cdiReadyReadAsAudio) - blocksToRead += (uint)sectorsForOffset; + if(blocksToRead == 1 && cdiReadyReadAsAudio) blocksToRead += (uint)sectorsForOffset; if(cdiReadyReadAsAudio) { @@ -208,19 +204,35 @@ partial class Dump } } - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; + + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; _speedStopwatch.Stop(); @@ -231,16 +243,37 @@ partial class Dump { for(uint r = 0; r < _maximumReadable; r++) { - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i + r, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i + r, + blocks, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize()), + (long)i + r, + (long)blocks); + _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, (uint)sectorsForOffset + 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)(i + r), + blockSize, + (uint)sectorsForOffset + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; _speedStopwatch.Stop(); + if(!sense && !_dev.Error) { mhddLog.Write(i + r, cmdDuration); @@ -250,8 +283,15 @@ partial class Dump if(cdiReadyReadAsAudio) { - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, - ref blocksToRead, subSize, ref cmdBuf, blockSize, false); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref blocksToRead, + subSize, + ref cmdBuf, + blockSize, + false); } if(supportedSubchannel != MmcSubchannel.None) @@ -263,15 +303,29 @@ partial class Dump Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); - if(cdiReadyReadAsAudio) - data = Sector.Scramble(data); + if(cdiReadyReadAsAudio) data = Sector.Scramble(data); outputOptical.WriteSectorsLong(data, i + r, 1); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i + r, 1, subLog, isrcs, 1, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, + desiredSubchannel, + sub, + i + r, + 1, + subLog, + isrcs, + 1, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, out List _); // Set tracks and go back @@ -296,11 +350,13 @@ partial class Dump leadOutExtents.Add(i + r, firstTrack.EndSector); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Adding_CD_i_Ready_hole_from_LBA_0_to_1_inclusive, - i + r, firstTrack.EndSector)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Adding_CD_i_Ready_hole_from_LBA_0_to_1_inclusive, + i + r, + firstTrack.EndSector)); - _dumpLog.WriteLine(Localization.Core.Adding_CD_i_Ready_hole_from_LBA_0_to_1_inclusive, i + r, + _dumpLog.WriteLine(Localization.Core.Adding_CD_i_Ready_hole_from_LBA_0_to_1_inclusive, + i + r, firstTrack.EndSector); break; @@ -313,8 +369,7 @@ partial class Dump elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -326,8 +381,15 @@ partial class Dump { if(cdiReadyReadAsAudio) { - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, - subSize, ref cmdBuf, blockSize, false); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref blocksToRead, + subSize, + ref cmdBuf, + blockSize, + false); } mhddLog.Write(i, cmdDuration); @@ -358,9 +420,24 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, blocksToRead); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, 1, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, + desiredSubchannel, + sub, + i, + blocksToRead, + subLog, + isrcs, + 1, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, out List newPregapSectors); // Set tracks and go back @@ -368,16 +445,14 @@ partial class Dump { outputOptical.SetTracks(tracks.ToList()); - foreach(ulong newPregapSector in newPregapSectors) - _resume.BadBlocks.Add(newPregapSector); + foreach(ulong newPregapSector in newPregapSectors) _resume.BadBlocks.Add(newPregapSector); if(i >= blocksToRead) i -= blocksToRead; else i = 0; - if(i > 0) - i--; + if(i > 0) i--; continue; } @@ -422,8 +497,7 @@ partial class Dump elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 488f82004..e3838caab 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -144,8 +144,7 @@ partial class Dump i++; } - if((long)i > lastSector) - break; + if((long)i > lastSector) break; var firstSectorToRead = (uint)i; @@ -158,11 +157,9 @@ partial class Dump { if(j > (ulong)lastSector) { - if(!failedCrossingLeadOut && !inData) - blocksToRead += (uint)sectorsForOffset; + if(!failedCrossingLeadOut && !inData) blocksToRead += (uint)sectorsForOffset; - if(sectorsForOffset > 0 && !inData) - crossingLeadOut = true; + if(sectorsForOffset > 0 && !inData) crossingLeadOut = true; break; } @@ -194,13 +191,11 @@ partial class Dump if(track.Sequence != 0 && i + blocksToRead - (ulong)sectorsForOffset > track.EndSector + 1) blocksToRead = (uint)(track.EndSector + 1 - i + (ulong)sectorsForOffset); - if(blocksToRead == 1 && !inData) - blocksToRead += (uint)sectorsForOffset; + if(blocksToRead == 1 && !inData) blocksToRead += (uint)sectorsForOffset; if(blocksToRead == 0) { - if(!skippingLead) - i += (ulong)sectorsForOffset; + if(!skippingLead) i += (ulong)sectorsForOffset; skippingLead = false; @@ -216,8 +211,7 @@ partial class Dump else firstSectorToRead -= (uint)sectorsForOffset; - if(blocksToRead <= sectorsForOffset) - blocksToRead += (uint)sectorsForOffset; + if(blocksToRead <= sectorsForOffset) blocksToRead += (uint)sectorsForOffset; } } @@ -246,8 +240,7 @@ partial class Dump _speed *= _speedMultiplier; - if(_speed is 0 or > 0xFFFF) - _speed = 0xFFFF; + if(_speed is 0 or > 0xFFFF) _speed = 0xFFFF; currentReadSpeed = _speed; @@ -264,24 +257,30 @@ partial class Dump crossingLeadOut = false; } - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); - if(crossingLeadOut && failedCrossingLeadOut && blocksToRead > 1) - blocksToRead--; + if(crossingLeadOut && failedCrossingLeadOut && blocksToRead > 1) blocksToRead--; if(_supportsPlextorD8 && !inData) { _speedStopwatch.Start(); - sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - supportedPlextorSubchannel, out cmdDuration); + + sense = ReadPlextorWithSubchannel(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + supportedPlextorSubchannel, + out cmdDuration); totalDuration += cmdDuration; _speedStopwatch.Stop(); @@ -291,9 +290,24 @@ partial class Dump if(inData) { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); if(sense) @@ -309,10 +323,24 @@ partial class Dump for(var bi = 0; bi < blocksToRead; bi++) { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(firstSectorToRead + bi), blockSize, - 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out double cmdDuration2); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)(firstSectorToRead + bi), + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out double cmdDuration2); + _speedStopwatch.Stop(); cmdDuration += cmdDuration2; @@ -354,10 +382,24 @@ partial class Dump // Try again _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out cmdDuration); + _speedStopwatch.Stop(); if(sense) @@ -367,14 +409,27 @@ partial class Dump for(uint bi = blocksToRead; bi > 0; bi--) { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, bi, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out cmdDuration); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + bi, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); - if(sense) - continue; + if(sense) continue; blocksToRead = bi; @@ -387,9 +442,24 @@ partial class Dump else { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); if(sense) @@ -400,10 +470,24 @@ partial class Dump if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out _, firstSectorToRead, blockSize, blocksToRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + + sense = _dev.ReadCd(out cmdBuf, + out _, + firstSectorToRead, + blockSize, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out double cmdDuration2); + _speedStopwatch.Stop(); cmdDuration += cmdDuration2; @@ -416,29 +500,76 @@ partial class Dump else if(read16) { _speedStopwatch.Start(); - sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, false, false, firstSectorToRead, blockSize, 0, - blocksToRead, false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read16(out cmdBuf, + out senseBuf, + 0, + false, + false, + false, + firstSectorToRead, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read12) { _speedStopwatch.Start(); - sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead, - blockSize, 0, blocksToRead, false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read12(out cmdBuf, + out senseBuf, + 0, + false, + false, + false, + false, + firstSectorToRead, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read10) { _speedStopwatch.Start(); - sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead, - blockSize, 0, (ushort)blocksToRead, _dev.Timeout, out cmdDuration); + + sense = _dev.Read10(out cmdBuf, + out senseBuf, + 0, + false, + false, + false, + false, + firstSectorToRead, + blockSize, + 0, + (ushort)blocksToRead, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read6) { _speedStopwatch.Start(); - sense = _dev.Read6(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, (byte)blocksToRead, - _dev.Timeout, out cmdDuration); + + sense = _dev.Read6(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + (byte)blocksToRead, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } @@ -449,22 +580,31 @@ partial class Dump { for(uint r = 0; r < blocksToRead; r++) { - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i + r, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i + r, + blocks, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize()), + (long)i + r, + (long)blocks); if(_supportsPlextorD8) { var adjustment = 0; - if(offsetBytes < 0) - adjustment = -sectorsForOffset; + if(offsetBytes < 0) adjustment = -sectorsForOffset; _speedStopwatch.Start(); - sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, - (uint)(firstSectorToRead + r + adjustment), blockSize, - (uint)sectorsForOffset + 1, supportedPlextorSubchannel, + + sense = ReadPlextorWithSubchannel(out cmdBuf, + out senseBuf, + (uint)(firstSectorToRead + r + adjustment), + blockSize, + (uint)sectorsForOffset + 1, + supportedPlextorSubchannel, out cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -473,14 +613,23 @@ partial class Dump { var sectorsForFix = (uint)(1 + sectorsForOffset); - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, - ref sectorsForFix, subSize, ref cmdBuf, blockSize, false); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref sectorsForFix, + subSize, + ref cmdBuf, + blockSize, + false); // Descramble cmdBuf = Sector.Scramble(cmdBuf); // Check valid sector - CdChecksums.CheckCdSector(cmdBuf, out bool? correctEccP, out bool? correctEccQ, + CdChecksums.CheckCdSector(cmdBuf, + out bool? correctEccP, + out bool? correctEccQ, out bool? correctEdc); // Check mode, set sense if EDC/ECC validity is not correct @@ -490,8 +639,7 @@ partial class Dump for(var c = 16; c < 2352; c++) { - if(cmdBuf[c] == 0x00) - continue; + if(cmdBuf[c] == 0x00) continue; sense = true; @@ -506,15 +654,12 @@ partial class Dump case 2: if((cmdBuf[18] & 0x20) != 0x20) { - if(correctEccP != true) - sense = true; + if(correctEccP != true) sense = true; - if(correctEccQ != true) - sense = true; + if(correctEccQ != true) sense = true; } - if(correctEdc != true) - sense = true; + if(correctEdc != true) sense = true; break; } @@ -523,10 +668,24 @@ partial class Dump else if(readcd) { _speedStopwatch.Start(); - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)(i + r), + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -534,29 +693,76 @@ partial class Dump else if(read16) { _speedStopwatch.Start(); - sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i + r, blockSize, 0, 1, - false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read16(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + i + r, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read12) { _speedStopwatch.Start(); - sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)(i + r), - blockSize, 0, 1, false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read12(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(i + r), + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read10) { _speedStopwatch.Start(); - sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)(i + r), - blockSize, 0, 1, _dev.Timeout, out cmdDuration); + + sense = _dev.Read10(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(i + r), + blockSize, + 0, + 1, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); } else if(read6) { _speedStopwatch.Start(); - sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, 1, _dev.Timeout, + + sense = _dev.Read6(out cmdBuf, + out senseBuf, + (uint)(i + r), + blockSize, + 1, + _dev.Timeout, out cmdDuration); + _speedStopwatch.Stop(); } @@ -594,10 +800,25 @@ partial class Dump } bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i + r, 1, subLog, isrcs, (byte)track.Sequence, ref mcn, - tracks, subchannelExtents, _fixSubchannelPosition, - outputFormat as IWritableOpticalImage, _fixSubchannel, _fixSubchannelCrc, _dumpLog, - UpdateStatus, smallestPregapLbaPerTrack, true, out List newPregapSectors); + desiredSubchannel, + sub, + i + r, + 1, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputFormat as IWritableOpticalImage, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out List newPregapSectors); // Set tracks and go back if(indexesChanged) @@ -612,8 +833,7 @@ partial class Dump else i = 0; - if(i > 0) - i--; + if(i > 0) i--; foreach(Track aTrack in tracks.Where(aTrack => aTrack.Type == TrackType.Audio)) audioExtents.Add(aTrack.StartSector, aTrack.EndSector); @@ -658,7 +878,9 @@ partial class Dump if(desiredSubchannel != MmcSubchannel.None) { - outputFormat.WriteSectorsTag(new byte[subSize], i + r, 1, + outputFormat.WriteSectorsTag(new byte[subSize], + i + r, + 1, SectorTagType.CdSectorSubchannel); } } @@ -681,7 +903,8 @@ partial class Dump _resume.BadBlocks.Add(i + r); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_error_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_error_0, Sense.PrettifySense(senseBuf)); mhddLog.Write(i + r, cmdDuration < 500 ? 65535 : cmdDuration); @@ -699,8 +922,7 @@ partial class Dump elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -721,8 +943,15 @@ partial class Dump // Because one block has been partially used to fix the offset if(_fixOffset && !inData && offsetBytes != 0) { - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, - subSize, ref cmdBuf, blockSize, failedCrossingLeadOut); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref blocksToRead, + subSize, + ref cmdBuf, + blockSize, + failedCrossingLeadOut); } mhddLog.Write(i, cmdDuration, blocksToRead); @@ -760,9 +989,24 @@ partial class Dump } bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn, - tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage, - _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, + desiredSubchannel, + sub, + i, + blocksToRead, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputFormat as IWritableOpticalImage, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, out List newPregapSectors); // Set tracks and go back @@ -770,16 +1014,14 @@ partial class Dump { (outputFormat as IWritableOpticalImage).SetTracks(tracks.ToList()); - foreach(ulong newPregapSector in newPregapSectors) - _resume.BadBlocks.Add(newPregapSector); + foreach(ulong newPregapSector in newPregapSectors) _resume.BadBlocks.Add(newPregapSector); if(i >= blocksToRead) i -= blocksToRead; else i = 0; - if(i > 0) - i--; + if(i > 0) i--; foreach(Track aTrack in tracks.Where(aTrack => aTrack.Type == TrackType.Audio)) audioExtents.Add(aTrack.StartSector, aTrack.EndSector); @@ -815,8 +1057,7 @@ partial class Dump { if(crossingLeadOut && Sense.Decode(senseBuf)?.ASC == 0x21) { - if(failedCrossingLeadOut) - break; + if(failedCrossingLeadOut) break; failedCrossingLeadOut = true; blocksToRead = 0; @@ -827,11 +1068,9 @@ partial class Dump _errorLog?.WriteLine(firstSectorToRead, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); @@ -842,7 +1081,9 @@ partial class Dump if(desiredSubchannel != MmcSubchannel.None) { - outputFormat.WriteSectorsTag(new byte[subSize * _skip], i, _skip, + outputFormat.WriteSectorsTag(new byte[subSize * _skip], + i, + _skip, SectorTagType.CdSectorSubchannel); } } @@ -861,8 +1102,7 @@ partial class Dump imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_error_0, Sense.PrettifySense(senseBuf)); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -881,8 +1121,7 @@ partial class Dump elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -894,8 +1133,7 @@ partial class Dump _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); - if(!failedCrossingLeadOut) - return; + if(!failedCrossingLeadOut) return; _dumpLog.WriteLine(Localization.Core.Failed_crossing_into_Lead_Out); UpdateStatus?.Invoke(Localization.Core.Failed_crossing_into_Lead_Out); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index 833e12f1c..83d887b1c 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -133,8 +133,16 @@ sealed partial class Dump return; } - tracks = GetCdTracks(_dev, _dumpLog, _force, out lastSector, leadOutStarts, mediaTags, StoppingErrorMessage, - out toc, trackFlags, UpdateStatus); + tracks = GetCdTracks(_dev, + _dumpLog, + _force, + out lastSector, + leadOutStarts, + mediaTags, + StoppingErrorMessage, + out toc, + trackFlags, + UpdateStatus); if(tracks is null) { @@ -173,11 +181,11 @@ sealed partial class Dump desiredSubchannel = MmcSubchannel.Raw; else { - _dumpLog.WriteLine(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); return; } @@ -190,11 +198,11 @@ sealed partial class Dump desiredSubchannel = MmcSubchannel.Q16; else { - _dumpLog.WriteLine(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); return; } @@ -205,11 +213,11 @@ sealed partial class Dump desiredSubchannel = MmcSubchannel.Q16; else { - _dumpLog.WriteLine(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_does_not_support_the_requested_subchannel_format_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_does_not_support_the_requested_subchannel_format_not_continuing); return; } @@ -223,8 +231,7 @@ sealed partial class Dump throw new ArgumentOutOfRangeException(); } - if(desiredSubchannel == MmcSubchannel.Q16 && supportsPqSubchannel) - supportedSubchannel = MmcSubchannel.Q16; + if(desiredSubchannel == MmcSubchannel.Q16 && supportsPqSubchannel) supportedSubchannel = MmcSubchannel.Q16; // Check if output format supports subchannels if(!outputOptical.SupportedSectorTags.Contains(SectorTagType.CdSectorSubchannel) && @@ -239,8 +246,8 @@ sealed partial class Dump { _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_subchannels_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_subchannels_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_subchannels_not_continuing); return; } @@ -254,9 +261,22 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Checking_if_drive_supports_reading_without_subchannel); UpdateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_reading_without_subchannel); - readcd = !_dev.ReadCd(out cmdBuf, out _, firstLba, sectorSize, 1, MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out _); + readcd = !_dev.ReadCd(out cmdBuf, + out _, + firstLba, + sectorSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out _); if(!readcd) { @@ -269,20 +289,54 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Checking_if_drive_supports_READ_10); UpdateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_READ_10); - read10 = !_dev.Read10(out cmdBuf, out _, 0, false, true, false, false, firstLba, 2048, 0, 1, - _dev.Timeout, out _); + read10 = !_dev.Read10(out cmdBuf, + out _, + 0, + false, + true, + false, + false, + firstLba, + 2048, + 0, + 1, + _dev.Timeout, + out _); _dumpLog.WriteLine(Localization.Core.Checking_if_drive_supports_READ_12); UpdateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_READ_12); - read12 = !_dev.Read12(out cmdBuf, out _, 0, false, true, false, false, firstLba, 2048, 0, 1, false, - _dev.Timeout, out _); + read12 = !_dev.Read12(out cmdBuf, + out _, + 0, + false, + true, + false, + false, + firstLba, + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); _dumpLog.WriteLine(Localization.Core.Checking_if_drive_supports_READ_16); UpdateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_READ_16); - read16 = !_dev.Read16(out cmdBuf, out _, 0, false, true, false, firstLba, 2048, 0, 1, false, - _dev.Timeout, out _); + read16 = !_dev.Read16(out cmdBuf, + out _, + 0, + false, + true, + false, + firstLba, + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); switch(read6) { @@ -362,17 +416,29 @@ sealed partial class Dump // Check if subchannel is BCD if(supportedSubchannel != MmcSubchannel.None) { - sense = _dev.ReadCd(out cmdBuf, out _, (firstLba / 75 + 1) * 75 + 35, blockSize, 1, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out _); + sense = _dev.ReadCd(out cmdBuf, + out _, + (firstLba / 75 + 1) * 75 + 35, + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out _); if(!sense) { tmpBuf = new byte[subSize]; Array.Copy(cmdBuf, sectorSize, tmpBuf, 0, subSize); - if(supportedSubchannel == MmcSubchannel.Q16) - tmpBuf = Subchannel.ConvertQToRaw(tmpBuf); + if(supportedSubchannel == MmcSubchannel.Q16) tmpBuf = Subchannel.ConvertQToRaw(tmpBuf); tmpBuf = Subchannel.Deinterleave(tmpBuf); @@ -394,14 +460,20 @@ sealed partial class Dump } } - foreach(Track trk in tracks) - trk.SubchannelType = subType; + foreach(Track trk in tracks) trk.SubchannelType = subType; _dumpLog.WriteLine(Localization.Core.Calculating_pregaps__can_take_some_time); UpdateStatus?.Invoke(Localization.Core.Calculating_pregaps__can_take_some_time); - SolveTrackPregaps(_dev, _dumpLog, UpdateStatus, tracks, supportsPqSubchannel, supportsRwSubchannel, _dbDev, - out bool inexactPositioning, true); + SolveTrackPregaps(_dev, + _dumpLog, + UpdateStatus, + tracks, + supportsPqSubchannel, + supportsRwSubchannel, + _dbDev, + out bool inexactPositioning, + true); if(inexactPositioning) { @@ -416,8 +488,8 @@ sealed partial class Dump { _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_storing_raw_data_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_storing_raw_data_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_storing_raw_data_not_continuing); return; } @@ -438,8 +510,8 @@ sealed partial class Dump } if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStorePregaps) && - tracks.Where(track => track.Sequence != tracks.First(t => t.Session == track.Session).Sequence). - Any(track => track.Pregap > 0)) + tracks.Where(track => track.Sequence != tracks.First(t => t.Session == track.Session).Sequence) + .Any(track => track.Pregap > 0)) { if(!_force) { @@ -455,8 +527,7 @@ sealed partial class Dump ErrorMessage?.Invoke(Localization.Core.Output_format_does_not_support_pregaps_continuing); } - for(var t = 1; t < tracks.Length; t++) - tracks[t - 1].EndSector = tracks[t].StartSector - 1; + for(var t = 1; t < tracks.Length; t++) tracks[t - 1].EndSector = tracks[t].StartSector - 1; tracks[^1].EndSector = (ulong)lastSector; blocks = (ulong)(lastSector + 1); @@ -468,8 +539,19 @@ sealed partial class Dump return; } - ResumeSupport.Process(true, true, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId, - ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force); + ResumeSupport.Process(true, + true, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -511,8 +593,9 @@ sealed partial class Dump { _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_0_not_continuing, tag); - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Output_format_does_not_support_0_not_continuing, tag)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Output_format_does_not_support_0_not_continuing, + tag)); return; } @@ -523,14 +606,15 @@ sealed partial class Dump UpdateStatus?.Invoke(Localization.Core.Solving_lead_outs); foreach(KeyValuePair leadOuts in leadOutStarts) - foreach(Track trk in tracks.Where(trk => trk.Session == leadOuts.Key). - Where(trk => trk.EndSector >= (ulong)leadOuts.Value)) - trk.EndSector = (ulong)leadOuts.Value - 1; + { + foreach(Track trk in tracks.Where(trk => trk.Session == leadOuts.Key) + .Where(trk => trk.EndSector >= (ulong)leadOuts.Value)) + trk.EndSector = (ulong)leadOuts.Value - 1; + } var dataExtents = new ExtentsULong(); - foreach(Track trk in tracks) - dataExtents.Add(trk.StartSector, trk.EndSector); + foreach(Track trk in tracks) dataExtents.Add(trk.StartSector, trk.EndSector); Tuple[] dataExtentsArray = dataExtents.ToArray(); @@ -541,7 +625,13 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Detecting_disc_type); UpdateStatus?.Invoke(Localization.Core.Detecting_disc_type); - MMC.DetectDiscType(ref dskType, sessions, toc, _dev, out hiddenTrack, out hiddenData, firstTrackLastSession, + MMC.DetectDiscType(ref dskType, + sessions, + toc, + _dev, + out hiddenTrack, + out hiddenData, + firstTrackLastSession, blocks); if(hiddenTrack || firstLba > 0) @@ -596,9 +686,22 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Checking_mode_for_track_0, trk.Sequence); UpdateStatus?.Invoke(string.Format(Localization.Core.Checking_mode_for_track_0, trk.Sequence)); - sense = _dev.ReadCd(out cmdBuf, out _, (uint)(trk.StartSector + trk.Pregap), blockSize, 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, supportedSubchannel, _dev.Timeout, out _); + sense = _dev.ReadCd(out cmdBuf, + out _, + (uint)(trk.StartSector + trk.Pregap), + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out _); if(sense) { @@ -625,8 +728,7 @@ sealed partial class Dump cmdBuf[10 + bufOffset] != 0xFF || cmdBuf[11 + bufOffset] != 0x00) { - if(bufOffset + 12 >= cmdBuf.Length) - break; + if(bufOffset + 12 >= cmdBuf.Length) break; bufOffset++; } @@ -665,12 +767,12 @@ sealed partial class Dump trk.Type = TrackType.CdMode2Form1; // These media type specifications do not legally allow mode 2 tracks to be present - if(dskType is MediaType.CDROM or MediaType.CDPLUS or MediaType.CDV) - dskType = MediaType.CD; + if(dskType is MediaType.CDROM or MediaType.CDPLUS or MediaType.CDV) dskType = MediaType.CD; break; default: - UpdateStatus?.Invoke(string.Format(Localization.Core.Track_0_is_unknown_mode_1, trk.Sequence, + UpdateStatus?.Invoke(string.Format(Localization.Core.Track_0_is_unknown_mode_1, + trk.Sequence, cmdBuf[15])); _dumpLog.WriteLine(Localization.Core.Track_0_is_unknown_mode_1, trk.Sequence, cmdBuf[15]); @@ -683,8 +785,8 @@ sealed partial class Dump { if(tracks.Length > 1) { - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_more_than_1_track_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_more_than_1_track_not_continuing); _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_more_than_1_track_not_continuing); @@ -693,8 +795,8 @@ sealed partial class Dump if(tracks.Any(t => t.Type == TrackType.Audio)) { - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_audio_tracks_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_audio_tracks_not_continuing); _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_audio_tracks_not_continuing); @@ -703,8 +805,8 @@ sealed partial class Dump if(tracks.Any(t => t.Type != TrackType.CdMode1)) { - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_only_supports_MODE_1_tracks_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_only_supports_MODE_1_tracks_not_continuing); _dumpLog.WriteLine(Localization.Core.Output_format_only_supports_MODE_1_tracks_not_continuing); @@ -721,19 +823,19 @@ sealed partial class Dump { if(_force) { - _dumpLog.WriteLine(Localization.Core. - Output_format_does_not_support_CD_first_track_pregap_continuing); + _dumpLog.WriteLine(Localization.Core + .Output_format_does_not_support_CD_first_track_pregap_continuing); - ErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_CD_first_track_pregap_continuing); + ErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_CD_first_track_pregap_continuing); } else { - _dumpLog.WriteLine(Localization.Core. - Output_format_does_not_support_CD_first_track_pregap_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Output_format_does_not_support_CD_first_track_pregap_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_CD_first_track_pregap_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_CD_first_track_pregap_not_continuing); return; } @@ -747,56 +849,97 @@ sealed partial class Dump { if(readcd) { - sense = _dev.ReadCd(out cmdBuf, out _, firstLba, blockSize, _maximumReadable, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out _); + sense = _dev.ReadCd(out cmdBuf, + out _, + firstLba, + blockSize, + _maximumReadable, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out _); - if(_dev.Error || sense) - _maximumReadable /= 2; + if(_dev.Error || sense) _maximumReadable /= 2; } else if(read16) { - sense = _dev.Read16(out cmdBuf, out _, 0, false, true, false, firstLba, blockSize, 0, _maximumReadable, - false, _dev.Timeout, out _); + sense = _dev.Read16(out cmdBuf, + out _, + 0, + false, + true, + false, + firstLba, + blockSize, + 0, + _maximumReadable, + false, + _dev.Timeout, + out _); - if(_dev.Error || sense) - _maximumReadable /= 2; + if(_dev.Error || sense) _maximumReadable /= 2; } else if(read12) { - sense = _dev.Read12(out cmdBuf, out _, 0, false, true, false, false, firstLba, blockSize, 0, - _maximumReadable, false, _dev.Timeout, out _); + sense = _dev.Read12(out cmdBuf, + out _, + 0, + false, + true, + false, + false, + firstLba, + blockSize, + 0, + _maximumReadable, + false, + _dev.Timeout, + out _); - if(_dev.Error || sense) - _maximumReadable /= 2; + if(_dev.Error || sense) _maximumReadable /= 2; } else if(read10) { - sense = _dev.Read10(out cmdBuf, out _, 0, false, true, false, false, firstLba, blockSize, 0, - (ushort)_maximumReadable, _dev.Timeout, out _); + sense = _dev.Read10(out cmdBuf, + out _, + 0, + false, + true, + false, + false, + firstLba, + blockSize, + 0, + (ushort)_maximumReadable, + _dev.Timeout, + out _); - if(_dev.Error || sense) - _maximumReadable /= 2; + if(_dev.Error || sense) _maximumReadable /= 2; } else if(read6) { sense = _dev.Read6(out cmdBuf, out _, firstLba, blockSize, (byte)_maximumReadable, _dev.Timeout, out _); - if(_dev.Error || sense) - _maximumReadable /= 2; + if(_dev.Error || sense) _maximumReadable /= 2; } - if(!_dev.Error || _maximumReadable == 1) - break; + if(!_dev.Error || _maximumReadable == 1) break; } if(_dev.Error || sense) { _dumpLog.WriteLine(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, _dev.LastError); - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); } var cdiWithHiddenTrack1 = false; @@ -820,7 +963,8 @@ sealed partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, _maximumReadable)); - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, _maximumReadable)); @@ -828,7 +972,10 @@ sealed partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_device_type_0, _dev.ScsiType)); UpdateStatus?.Invoke(string.Format(Localization.Core.Media_identified_as_0, dskType)); - ret = outputOptical.Create(_outputPath, dskType, _formatOptions, blocks, + ret = outputOptical.Create(_outputPath, + dskType, + _formatOptions, + blocks, supportsLongSectors ? blockSize : 2048); // Cannot create image @@ -846,8 +993,7 @@ sealed partial class Dump ErrorNumber errno = outputOptical.ReadMediaTag(MediaTagType.CD_MCN, out byte[] mcnBytes); - if(errno == ErrorNumber.NoError) - mcn = Encoding.ASCII.GetString(mcnBytes); + if(errno == ErrorNumber.NoError) mcn = Encoding.ASCII.GetString(mcnBytes); if(outputOptical.Tracks != null) { @@ -855,20 +1001,17 @@ sealed partial class Dump { errno = outputOptical.ReadSectorTag(imgTrack.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcBytes); - if(errno == ErrorNumber.NoError) - isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes); + if(errno == ErrorNumber.NoError) isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes); Track trk = tracks.FirstOrDefault(t => t.Sequence == imgTrack.Sequence); - if(trk == null) - continue; + if(trk == null) continue; trk.Pregap = imgTrack.Pregap; trk.StartSector = imgTrack.StartSector; trk.EndSector = imgTrack.EndSector; - foreach(KeyValuePair imgIdx in imgTrack.Indexes) - trk.Indexes[imgIdx.Key] = imgIdx.Value; + foreach(KeyValuePair imgIdx in imgTrack.Indexes) trk.Indexes[imgIdx.Key] = imgIdx.Value; } } @@ -900,8 +1043,8 @@ sealed partial class Dump { _dumpLog.WriteLine(Localization.Core.Output_format_does_not_support_subchannels_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Output_format_does_not_support_subchannels_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Output_format_does_not_support_subchannels_not_continuing); return; } @@ -920,16 +1063,17 @@ sealed partial class Dump { Track track = tracks.FirstOrDefault(t => t.Sequence == kvp.Key); - if(track is null) - continue; + if(track is null) continue; _dumpLog.WriteLine(Localization.Core.Setting_flags_for_track_0, track.Sequence); UpdateStatus?.Invoke(string.Format(Localization.Core.Setting_flags_for_track_0, track.Sequence)); outputOptical.WriteSectorTag(new[] - { - kvp.Value - }, kvp.Key, SectorTagType.CdTrackFlags); + { + kvp.Value + }, + kvp.Key, + SectorTagType.CdTrackFlags); } // Set MCN @@ -953,8 +1097,7 @@ sealed partial class Dump { sense = _dev.ReadIsrc((byte)trk.Sequence, out string isrc, out _, out _, _dev.Timeout, out _); - if(sense || isrc is null or "000000000000") - continue; + if(sense || isrc is null or "000000000000") continue; isrcs[(byte)trk.Sequence] = isrc; @@ -969,13 +1112,11 @@ sealed partial class Dump _resume.BadSubchannels ??= new List(); - foreach(int sub in _resume.BadSubchannels) - subchannelExtents.Add(sub); + foreach(int sub in _resume.BadSubchannels) subchannelExtents.Add(sub); if(_resume.NextBlock < blocks) { - for(ulong i = _resume.NextBlock; i < blocks; i++) - subchannelExtents.Add((int)i); + for(ulong i = _resume.NextBlock; i < blocks; i++) subchannelExtents.Add((int)i); } } @@ -985,16 +1126,17 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock); } - if(_skip < _maximumReadable) - _skip = _maximumReadable; + if(_skip < _maximumReadable) _skip = _maximumReadable; - #if DEBUG +#if DEBUG foreach(Track trk in tracks) { UpdateStatus?.Invoke(string.Format(Localization.Core.Track_0_starts_at_LBA_1_and_ends_at_LBA_2, - trk.Sequence, trk.StartSector, trk.EndSector)); + trk.Sequence, + trk.StartSector, + trk.EndSector)); } - #endif +#endif // Check offset if(_fixOffset) @@ -1010,22 +1152,22 @@ sealed partial class Dump if(!readcd) { - _dumpLog.WriteLine(Localization.Core. - READ_CD_command_is_not_supported_disabling_offset_fix_Dump_may_not_be_correct); + _dumpLog.WriteLine(Localization.Core + .READ_CD_command_is_not_supported_disabling_offset_fix_Dump_may_not_be_correct); - UpdateStatus?.Invoke(Localization.Core. - READ_CD_command_is_not_supported_disabling_offset_fix_Dump_may_not_be_correct); + UpdateStatus?.Invoke(Localization.Core + .READ_CD_command_is_not_supported_disabling_offset_fix_Dump_may_not_be_correct); _fixOffset = false; } } else if(tracks.Any(t => t.Type == TrackType.Audio)) { - _dumpLog.WriteLine(Localization.Core. - There_are_audio_tracks_and_offset_fixing_is_disabled_dump_may_not_be_correct); + _dumpLog.WriteLine(Localization.Core + .There_are_audio_tracks_and_offset_fixing_is_disabled_dump_may_not_be_correct); - UpdateStatus?.Invoke(Localization.Core. - There_are_audio_tracks_and_offset_fixing_is_disabled_dump_may_not_be_correct); + UpdateStatus?.Invoke(Localization.Core + .There_are_audio_tracks_and_offset_fixing_is_disabled_dump_may_not_be_correct); } // Search for read offset in main database @@ -1034,8 +1176,17 @@ sealed partial class Dump d.Manufacturer == _dev.Manufacturer.Replace('/', '-')) && (d.Model == _dev.Model || d.Model == _dev.Model.Replace('/', '-'))); - Media.Info.CompactDisc.GetOffset(cdOffset, _dbDev, _debug, _dev, dskType, _dumpLog, tracks, UpdateStatus, - out int? driveOffset, out int? combinedOffset, out _supportsPlextorD8); + Media.Info.CompactDisc.GetOffset(cdOffset, + _dbDev, + _debug, + _dev, + dskType, + _dumpLog, + tracks, + UpdateStatus, + out int? driveOffset, + out int? combinedOffset, + out _supportsPlextorD8); if(combinedOffset is null) { @@ -1053,16 +1204,17 @@ sealed partial class Dump UpdateStatus?.Invoke(Localization.Core.Dump_may_not_be_correct); } - if(_fixOffset) - _fixOffset = false; + if(_fixOffset) _fixOffset = false; } else { _dumpLog.WriteLine(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); UpdateStatus?.Invoke(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); _dumpLog.WriteLine(Localization.Core.Disc_write_offset_is_unknown_dump_may_not_be_correct); UpdateStatus?.Invoke(Localization.Core.Disc_write_offset_is_unknown_dump_may_not_be_correct); @@ -1071,11 +1223,9 @@ sealed partial class Dump sectorsForOffset = offsetBytes / (int)sectorSize; - if(sectorsForOffset < 0) - sectorsForOffset *= -1; + if(sectorsForOffset < 0) sectorsForOffset *= -1; - if(offsetBytes % sectorSize != 0) - sectorsForOffset++; + if(offsetBytes % sectorSize != 0) sectorsForOffset++; } } else @@ -1083,11 +1233,9 @@ sealed partial class Dump offsetBytes = combinedOffset.Value; sectorsForOffset = offsetBytes / (int)sectorSize; - if(sectorsForOffset < 0) - sectorsForOffset *= -1; + if(sectorsForOffset < 0) sectorsForOffset *= -1; - if(offsetBytes % sectorSize != 0) - sectorsForOffset++; + if(offsetBytes % sectorSize != 0) sectorsForOffset++; if(driveOffset is null) { @@ -1095,31 +1243,42 @@ sealed partial class Dump UpdateStatus?.Invoke(Localization.Core.Drive_reading_offset_not_found_in_database); _dumpLog.WriteLine(string.Format(Localization.Core.Combined_disc_and_drive_offset_are_0_bytes_1_samples, - offsetBytes, offsetBytes / 4)); + offsetBytes, + offsetBytes / 4)); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Combined_disc_and_drive_offset_are_0_bytes_1_samples, - offsetBytes, offsetBytes / 4)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Combined_disc_and_drive_offset_are_0_bytes_1_samples, + offsetBytes, + offsetBytes / 4)); } else { _dumpLog.WriteLine(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); UpdateStatus?.Invoke(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); discOffset = offsetBytes - driveOffset; - _dumpLog.WriteLine(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, discOffset, + _dumpLog.WriteLine(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, + discOffset, discOffset / 4)); - UpdateStatus?.Invoke(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, discOffset, + UpdateStatus?.Invoke(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, + discOffset, discOffset / 4)); } } - mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, _maximumReadable, _private, + mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + _maximumReadable, + _private, _dimensions); ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008); @@ -1160,8 +1319,7 @@ sealed partial class Dump _speed *= _speedMultiplier; - if(_speed is 0 or > 0xFFFF) - _speed = 0xFFFF; + if(_speed is 0 or > 0xFFFF) _speed = 0xFFFF; _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, _dev.Timeout, out _); } @@ -1177,28 +1335,41 @@ sealed partial class Dump if(!supportsLongSectors) { - _dumpLog.WriteLine(Localization.Core. - Dumping_CD_i_Ready_requires_the_output_image_format_to_support_long_sectors); + _dumpLog.WriteLine(Localization.Core + .Dumping_CD_i_Ready_requires_the_output_image_format_to_support_long_sectors); - StoppingErrorMessage?.Invoke(Localization.Core. - Dumping_CD_i_Ready_requires_the_output_image_format_to_support_long_sectors); + StoppingErrorMessage?.Invoke(Localization.Core + .Dumping_CD_i_Ready_requires_the_output_image_format_to_support_long_sectors); return; } if(!readcd) { - _dumpLog.WriteLine(Localization.Core. - Dumping_CD_i_Ready_requires_the_drive_to_support_the_READ_CD_command); + _dumpLog.WriteLine(Localization.Core + .Dumping_CD_i_Ready_requires_the_drive_to_support_the_READ_CD_command); - StoppingErrorMessage?.Invoke(Localization.Core. - Dumping_CD_i_Ready_requires_the_drive_to_support_the_READ_CD_command); + StoppingErrorMessage?.Invoke(Localization.Core + .Dumping_CD_i_Ready_requires_the_drive_to_support_the_READ_CD_command); return; } - _dev.ReadCd(out cmdBuf, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + _dev.ReadCd(out cmdBuf, + out _, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, out _); hiddenData = IsData(cmdBuf); @@ -1212,17 +1383,15 @@ sealed partial class Dump offsetBytes = combinedOffset.Value; sectorsForOffset = offsetBytes / (int)sectorSize; - if(sectorsForOffset < 0) - sectorsForOffset *= -1; + if(sectorsForOffset < 0) sectorsForOffset *= -1; - if(offsetBytes % sectorSize != 0) - sectorsForOffset++; + if(offsetBytes % sectorSize != 0) sectorsForOffset++; - _dumpLog.WriteLine(Localization.Core. - Enabling_skipping_CD_i_Ready_hole_because_drive_returns_data_as_audio); + _dumpLog.WriteLine(Localization.Core + .Enabling_skipping_CD_i_Ready_hole_because_drive_returns_data_as_audio); - UpdateStatus?.Invoke(Localization.Core. - Enabling_skipping_CD_i_Ready_hole_because_drive_returns_data_as_audio); + UpdateStatus?.Invoke(Localization.Core + .Enabling_skipping_CD_i_Ready_hole_because_drive_returns_data_as_audio); _skipCdireadyHole = true; @@ -1231,57 +1400,110 @@ sealed partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_reading_offset_not_found_in_database); UpdateStatus?.Invoke(Localization.Core.Drive_reading_offset_not_found_in_database); - _dumpLog. - WriteLine(string. - Format(Localization.Core.Combined_disc_and_drive_offset_are_0_bytes_1_samples, - offsetBytes, offsetBytes / 4)); + _dumpLog.WriteLine(string.Format(Localization.Core + .Combined_disc_and_drive_offset_are_0_bytes_1_samples, + offsetBytes, + offsetBytes / 4)); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Combined_disc_and_drive_offset_are_0_bytes_1_samples, - offsetBytes, offsetBytes / 4)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Combined_disc_and_drive_offset_are_0_bytes_1_samples, + offsetBytes, + offsetBytes / 4)); } else { _dumpLog.WriteLine(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); UpdateStatus?.Invoke(string.Format(Localization.Core.Drive_reading_offset_is_0_bytes_1_samples, - driveOffset, driveOffset / 4)); + driveOffset, + driveOffset / 4)); discOffset = offsetBytes - driveOffset; - _dumpLog.WriteLine(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, discOffset, + _dumpLog.WriteLine(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, + discOffset, discOffset / 4)); UpdateStatus?.Invoke(string.Format(Localization.Core.Disc_offset_is_0_bytes_1_samples, - discOffset, discOffset / 4)); + discOffset, + discOffset / 4)); } } } if(!_skipCdireadyHole) { - _dumpLog.WriteLine(Localization.Core. - There_will_be_thousand_of_errors_between_track_0_and_track_1_that_is_normal_and_you_can_ignore_them); + _dumpLog.WriteLine(Localization.Core + .There_will_be_thousand_of_errors_between_track_0_and_track_1_that_is_normal_and_you_can_ignore_them); - UpdateStatus?.Invoke(Localization.Core. - There_will_be_thousand_of_errors_between_track_0_and_track_1_that_is_normal_and_you_can_ignore_them); + UpdateStatus?.Invoke(Localization.Core + .There_will_be_thousand_of_errors_between_track_0_and_track_1_that_is_normal_and_you_can_ignore_them); } if(_skipCdireadyHole) { - ReadCdiReady(blockSize, ref currentSpeed, currentTry, extents, ibgLog, ref imageWriteDuration, - leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, subSize, supportedSubchannel, - ref totalDuration, tracks, subLog, desiredSubchannel, isrcs, ref mcn, subchannelExtents, - blocks, cdiReadyReadAsAudio, offsetBytes, sectorsForOffset, smallestPregapLbaPerTrack); + ReadCdiReady(blockSize, + ref currentSpeed, + currentTry, + extents, + ibgLog, + ref imageWriteDuration, + leadOutExtents, + ref maxSpeed, + mhddLog, + ref minSpeed, + subSize, + supportedSubchannel, + ref totalDuration, + tracks, + subLog, + desiredSubchannel, + isrcs, + ref mcn, + subchannelExtents, + blocks, + cdiReadyReadAsAudio, + offsetBytes, + sectorsForOffset, + smallestPregapLbaPerTrack); } } - ReadCdData(audioExtents, blocks, blockSize, ref currentSpeed, currentTry, extents, ibgLog, - ref imageWriteDuration, lastSector, leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, out newTrim, - tracks[0].Type != TrackType.Audio, offsetBytes, read6, read10, read12, read16, readcd, - sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, ref totalDuration, tracks, - subLog, desiredSubchannel, isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack); + ReadCdData(audioExtents, + blocks, + blockSize, + ref currentSpeed, + currentTry, + extents, + ibgLog, + ref imageWriteDuration, + lastSector, + leadOutExtents, + ref maxSpeed, + mhddLog, + ref minSpeed, + out newTrim, + tracks[0].Type != TrackType.Audio, + offsetBytes, + read6, + read10, + read12, + read16, + readcd, + sectorsForOffset, + subSize, + supportedSubchannel, + supportsLongSectors, + ref totalDuration, + tracks, + subLog, + desiredSubchannel, + isrcs, + ref mcn, + subchannelExtents, + smallestPregapLbaPerTrack); // TODO: Enable when underlying images support lead-outs /* @@ -1294,8 +1516,13 @@ sealed partial class Dump _dumpStopwatch.Stop(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); @@ -1323,31 +1550,79 @@ sealed partial class Dump .Per(imageWriteDuration.Seconds()) .Humanize())); - TrimCdUserData(audioExtents, blockSize, currentTry, extents, newTrim, offsetBytes, read6, read10, read12, - read16, readcd, sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, - ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn, subchannelExtents, + TrimCdUserData(audioExtents, + blockSize, + currentTry, + extents, + newTrim, + offsetBytes, + read6, + read10, + read12, + read16, + readcd, + sectorsForOffset, + subSize, + supportedSubchannel, + supportsLongSectors, + ref totalDuration, + subLog, + desiredSubchannel, + tracks, + isrcs, + ref mcn, + subchannelExtents, smallestPregapLbaPerTrack); if(dskType is MediaType.CDR or MediaType.CDRW && _resume.BadBlocks.Count > 0 && _ignoreCdrRunOuts > 0) { - HandleCdrRunOutSectors(blocks, desiredSubchannel, extents, subchannelExtents, subLog, supportsLongSectors, - trackFlags, tracks); + HandleCdrRunOutSectors(blocks, + desiredSubchannel, + extents, + subchannelExtents, + subLog, + supportsLongSectors, + trackFlags, + tracks); } - RetryCdUserData(audioExtents, blockSize, currentTry, extents, offsetBytes, readcd, sectorsForOffset, subSize, - supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn, - subchannelExtents, smallestPregapLbaPerTrack, supportsLongSectors); + RetryCdUserData(audioExtents, + blockSize, + currentTry, + extents, + offsetBytes, + readcd, + sectorsForOffset, + subSize, + supportedSubchannel, + ref totalDuration, + subLog, + desiredSubchannel, + tracks, + isrcs, + ref mcn, + subchannelExtents, + smallestPregapLbaPerTrack, + supportsLongSectors); foreach(Tuple leadoutExtent in leadOutExtents.ToArray()) { - for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) - subchannelExtents.Remove((int)e); + for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) subchannelExtents.Remove((int)e); } if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel) { - RetrySubchannel(readcd, subSize, supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks, - isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack); + RetrySubchannel(readcd, + subSize, + supportedSubchannel, + ref totalDuration, + subLog, + desiredSubchannel, + tracks, + isrcs, + ref mcn, + subchannelExtents, + smallestPregapLbaPerTrack); } // Write media tags to image @@ -1364,8 +1639,7 @@ sealed partial class Dump ret = outputOptical.WriteMediaTag(tag.Value, tag.Key); - if(ret || _force) - continue; + if(ret || _force) continue; // Cannot write tag to image _dumpLog.WriteLine(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key)); @@ -1377,8 +1651,7 @@ sealed partial class Dump _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -1390,8 +1663,16 @@ sealed partial class Dump outputOptical.SupportedSectorTags.Contains(SectorTagType.CdSectorSubchannel) && !_aborted) { - Media.CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, blocks, subLog, _dumpLog, - InitProgress, UpdateProgress, EndProgress, outputOptical); + Media.CompactDisc.GenerateSubchannels(subchannelExtents, + tracks, + trackFlags, + blocks, + subLog, + _dumpLog, + InitProgress, + UpdateProgress, + EndProgress, + outputOptical); } // TODO: Disc ID @@ -1410,8 +1691,7 @@ sealed partial class Dump outputOptical.SetDumpHardware(_resume.Tries); - if(_preSidecar != null) - outputOptical.SetMetadata(_preSidecar); + if(_preSidecar != null) outputOptical.SetMetadata(_preSidecar); foreach(KeyValuePair isrc in isrcs) { @@ -1434,8 +1714,7 @@ sealed partial class Dump // Fix track starts in each session's first track if(tracks.Where(t => t.Session == trk.Session).MinBy(t => t.Sequence).Sequence == trk.Sequence) { - if(trk.Sequence == 1) - continue; + if(trk.Sequence == 1) continue; trk.StartSector -= trk.Pregap; trk.Indexes[0] = (int)trk.StartSector; @@ -1471,20 +1750,26 @@ sealed partial class Dump if(_metadata) { - WriteOpticalSidecar(blockSize, blocks, dskType, null, mediaTags, sessions, out totalChkDuration, + WriteOpticalSidecar(blockSize, + blocks, + dskType, + null, + mediaTags, + sessions, + out totalChkDuration, discOffset); } _dumpStopwatch.Stop(); UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index dd4151a8b..5b3675e62 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -96,8 +96,7 @@ partial class Dump _ => PlextorSubchannel.None }; - if(_resume.BadBlocks.Count <= 0 || _aborted || _retryPasses <= 0) - return; + if(_resume.BadBlocks.Count <= 0 || _aborted || _retryPasses <= 0) return; var pass = 1; var forward = true; @@ -111,16 +110,25 @@ partial class Dump { Modes.ModePage_01_MMC pgMmc; - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, out _); Modes.DecodedMode? dcMode6 = null; - if(!sense) - dcMode6 = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); + if(!sense) dcMode6 = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); if(sense || dcMode6 is null) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, out _); if(!sense) @@ -130,7 +138,7 @@ partial class Dump if(dcMode10?.Pages != null) { foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -140,9 +148,9 @@ partial class Dump if(dcMode6?.Pages != null) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is - { - Page: 0x01, Subpage: 0x00 - })) + { + Page: 0x01, Subpage: 0x00 + })) currentModePage = modePage; } } @@ -192,18 +200,17 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks); sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _); - if(sense) - sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -229,19 +236,23 @@ partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) - : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, badSector, + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) + : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, + badSector, pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) - : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, badSector, + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) + : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, + badSector, pass)); } @@ -265,8 +276,13 @@ partial class Dump if(_supportsPlextorD8 && audioExtents.Contains(badSector)) { - sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToReRead, blockSize, - sectorsToReRead, supportedPlextorSubchannel, out cmdDuration); + sense = ReadPlextorWithSubchannel(out cmdBuf, + out senseBuf, + badSectorToReRead, + blockSize, + sectorsToReRead, + supportedPlextorSubchannel, + out cmdDuration); totalDuration += cmdDuration; } @@ -274,9 +290,22 @@ partial class Dump { if(audioExtents.Contains(badSector)) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToReRead, blockSize, sectorsToReRead, - MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + badSectorToReRead, + blockSize, + sectorsToReRead, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); if(sense) { @@ -285,9 +314,21 @@ partial class Dump // Try to workaround firmware if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { - sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + sense = _dev.ReadCd(out cmdBuf, + out _, + badSectorToReRead, + blockSize, + sectorsToReRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out double cmdDuration2); cmdDuration += cmdDuration2; @@ -296,9 +337,22 @@ partial class Dump } else { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToReRead, blockSize, sectorsToReRead, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + badSectorToReRead, + blockSize, + sectorsToReRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); if(sense) { @@ -324,24 +378,46 @@ partial class Dump scrambledSectorsToReRead += (byte)sectorsForOffset; } - sense = _dev.ReadCd(out cmdBuf, out _, scrambledBadSectorToReRead, blockSize, - scrambledSectorsToReRead, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out double cmdDuration2); + sense = _dev.ReadCd(out cmdBuf, + out _, + scrambledBadSectorToReRead, + blockSize, + scrambledSectorsToReRead, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out double cmdDuration2); cmdDuration += cmdDuration2; if(!sense) { uint scrambledBlocksToReRead = scrambledSectorsToReRead; - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, - ref scrambledBlocksToReRead, subSize, ref cmdBuf, blockSize, false); + + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref scrambledBlocksToReRead, + subSize, + ref cmdBuf, + blockSize, + false); // Descramble cmdBuf = Sector.Scramble(cmdBuf); // Check valid sector - CdChecksums.CheckCdSector(cmdBuf, out bool? correctEccP, out bool? correctEccQ, + CdChecksums.CheckCdSector(cmdBuf, + out bool? correctEccP, + out bool? correctEccQ, out bool? correctEdc); // Check mode, set sense if EDC/ECC validity is not correct @@ -351,8 +427,7 @@ partial class Dump for(var c = 16; c < 2352; c++) { - if(cmdBuf[c] == 0x00) - continue; + if(cmdBuf[c] == 0x00) continue; sense = true; @@ -367,15 +442,12 @@ partial class Dump case 2: if((cmdBuf[18] & 0x20) != 0x20) { - if(correctEccP != true) - sense = true; + if(correctEccP != true) sense = true; - if(correctEccQ != true) - sense = true; + if(correctEccQ != true) sense = true; } - if(correctEdc != true) - sense = true; + if(correctEdc != true) sense = true; break; } @@ -391,16 +463,14 @@ partial class Dump { _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf); - if(!runningPersistent) - continue; + if(!runningPersistent) continue; DecodedSense? decSense = Sense.Decode(senseBuf); // MEDIUM ERROR, retry with ignore error below if(decSense is { ASC: 0x11 }) { - if(!sectorsNotEvenPartial.Contains(badSector)) - sectorsNotEvenPartial.Add(badSector); + if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector); } } @@ -409,8 +479,15 @@ partial class Dump { uint blocksToRead = sectorsToReRead; - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, subSize, - ref cmdBuf, blockSize, false); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref blocksToRead, + subSize, + ref cmdBuf, + blockSize, + false); } if(!sense && !_dev.Error) @@ -419,7 +496,8 @@ partial class Dump extents.Add(badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_sector_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_sector_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_sector_0_in_pass_1, badSector, pass); @@ -440,18 +518,29 @@ partial class Dump else outputOptical.WriteSector(Sector.GetUserData(data), badSector); - bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, - sub, badSector, 1, subLog, isrcs, - (byte)track.Sequence, ref mcn, tracks, + bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, + desiredSubchannel, + sub, + badSector, + 1, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, subchannelExtents, - _fixSubchannelPosition, outputOptical, - _fixSubchannel, _fixSubchannelCrc, - _dumpLog, UpdateStatus, - smallestPregapLbaPerTrack, true, out _); + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); // Set tracks and go back - if(!indexesChanged) - continue; + if(!indexesChanged) continue; outputOptical.SetTracks(tracks.ToList()); i--; @@ -471,8 +560,7 @@ partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto cdRepeatRetry; } @@ -516,8 +604,7 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_ignore_error_correction); sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _); - if(sense) - sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); if(!sense) { @@ -544,9 +631,21 @@ partial class Dump if(readcd) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)badSector, blockSize, 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)badSector, + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; @@ -574,13 +673,28 @@ partial class Dump outputOptical.WriteSector(Sector.GetUserData(data), badSector); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence, ref mcn, - tracks, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, out _); + desiredSubchannel, + sub, + badSector, + 1, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); // Set tracks and go back - if(!indexesChanged) - continue; + if(!indexesChanged) continue; outputOptical.SetTracks(tracks.ToList()); i--; @@ -615,8 +729,7 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_device_to_previous_status); sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _); - if(sense) - _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); } EndProgress?.Invoke(); @@ -646,8 +759,7 @@ partial class Dump PlextorSubchannel supportedPlextorSubchannel; var outputOptical = _outputPlugin as IWritableOpticalImage; - if(supportedSubchannel == MmcSubchannel.None || desiredSubchannel == MmcSubchannel.None) - return; + if(supportedSubchannel == MmcSubchannel.None || desiredSubchannel == MmcSubchannel.None) return; supportedPlextorSubchannel = supportedSubchannel switch { @@ -657,8 +769,7 @@ partial class Dump _ => PlextorSubchannel.None }; - if(_aborted) - return; + if(_aborted) return; var pass = 1; var forward = true; @@ -671,8 +782,7 @@ partial class Dump _resume.BadSubchannels.AddRange(subchannelExtents); _resume.BadSubchannels.Sort(); - if(!forward) - _resume.BadSubchannels.Reverse(); + if(!forward) _resume.BadSubchannels.Reverse(); int[] tmpArray = _resume.BadSubchannels.ToArray(); @@ -691,25 +801,45 @@ partial class Dump PulseProgress?.Invoke(forward ? string.Format(Localization.Core.Retrying_sector_0_subchannel_pass_1_forward, - badSector, pass) + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_subchannel_pass_1_reverse, - badSector, pass)); + badSector, + pass)); uint startSector = badSector - 2; if(_supportsPlextorD8) { - sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, startSector, subSize, 5, - supportedPlextorSubchannel, 0, out cmdDuration); + sense = _dev.PlextorReadCdDa(out cmdBuf, + out senseBuf, + startSector, + subSize, + 5, + supportedPlextorSubchannel, + 0, + out cmdDuration); totalDuration += cmdDuration; } else if(readcd) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, startSector, subSize, 5, + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + startSector, + subSize, + 5, track.Type == TrackType.Audio ? MmcSectorTypes.Cdda : MmcSectorTypes.AllTypes, - false, false, false, MmcHeaderCodes.None, false, false, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out cmdDuration); + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; } @@ -721,17 +851,32 @@ partial class Dump continue; } - Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, cmdBuf, badSector, 5, - subLog, isrcs, (byte)track.Sequence, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, - _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, - smallestPregapLbaPerTrack, true, out _); + Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, + desiredSubchannel, + cmdBuf, + badSector, + 5, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); - if(subchannelExtents.Contains(bs)) - continue; + if(subchannelExtents.Contains(bs)) continue; UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_sector_0_subchannel_in_pass_1, - badSector, pass)); + badSector, + pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_sector_0_subchannel_in_pass_1, badSector, pass); } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index 555a38cbb..dfa2772de 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -114,37 +114,83 @@ partial class Dump double cmdDuration = 0; - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i, + PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, + i, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); if(readcd) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes, false, - false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)i, + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; } else if(read16) { - sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i, blockSize, 0, 1, false, - _dev.Timeout, out cmdDuration); + sense = _dev.Read16(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + i, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); } else if(read12) { - sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, - 1, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)i, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); } else if(read10) { - sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, - 1, _dev.Timeout, out cmdDuration); + sense = _dev.Read10(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)i, + blockSize, + 0, + 1, + _dev.Timeout, + out cmdDuration); } else if(read6) sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration); @@ -172,9 +218,25 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, _maximumReadable); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, _maximumReadable, subLog, isrcs, 0xAA, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, out _); + desiredSubchannel, + sub, + i, + _maximumReadable, + subLog, + isrcs, + 0xAA, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); // Set tracks and go back if(indexesChanged) @@ -195,8 +257,7 @@ partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly // Write empty data _writeStopwatch.Restart(); @@ -205,7 +266,9 @@ partial class Dump { outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1); - outputOptical.WriteSectorsTag(new byte[subSize * _skip], i, 1, + outputOptical.WriteSectorsTag(new byte[subSize * _skip], + i, + 1, SectorTagType.CdSectorSubchannel); } else @@ -221,8 +284,7 @@ partial class Dump _writeStopwatch.Stop(); double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); - if(!double.IsInfinity(newSpeed)) - currentSpeed = newSpeed; + if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed; _resume.NextBlock = i + 1; } @@ -292,37 +354,83 @@ partial class Dump double cmdDuration = 0; - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i, + PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, + i, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); if(readcd) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, MmcSectorTypes.AllTypes, false, - false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + (uint)i, + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; } else if(read16) { - sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i, blockSize, 0, 1, false, - _dev.Timeout, out cmdDuration); + sense = _dev.Read16(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + i, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); } else if(read12) { - sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, - 1, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)i, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); } else if(read10) { - sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, - 1, _dev.Timeout, out cmdDuration); + sense = _dev.Read10(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)i, + blockSize, + 0, + 1, + _dev.Timeout, + out cmdDuration); } else if(read6) sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration); @@ -350,9 +458,25 @@ partial class Dump outputOptical.WriteSectorsLong(data, i, _maximumReadable); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, _maximumReadable, subLog, isrcs, 0xAA, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, out _); + desiredSubchannel, + sub, + i, + _maximumReadable, + subLog, + isrcs, + 0xAA, + ref mcn, + tracks, + subchannelExtents, + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); // Set tracks and go back if(indexesChanged) @@ -373,8 +497,7 @@ partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly // Write empty data _writeStopwatch.Restart(); @@ -385,7 +508,9 @@ partial class Dump if(desiredSubchannel != MmcSubchannel.None) { - outputOptical.WriteSectorsTag(new byte[subSize * _skip], i, 1, + outputOptical.WriteSectorsTag(new byte[subSize * _skip], + i, + 1, SectorTagType.CdSectorSubchannel); } } @@ -402,8 +527,7 @@ partial class Dump _writeStopwatch.Stop(); double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); - if(!double.IsInfinity(newSpeed)) - currentSpeed = newSpeed; + if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed; } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs index f826a8d2e..0cbe2cc7a 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs @@ -55,8 +55,7 @@ partial class Dump ref uint blocksToRead, uint subSize, ref byte[] cmdBuf, uint blockSize, bool failedCrossingLeadOut) { - if(cmdBuf.Length == 0) - return; + if(cmdBuf.Length == 0) return; int offsetFix = offsetBytes < 0 ? (int)(sectorSize * sectorsForOffset + offsetBytes) : offsetBytes; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs index 72b49894b..b0821acde 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs @@ -55,18 +55,35 @@ partial class Dump if(supportedPlextorSubchannel == PlextorSubchannel.None) { - sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - supportedPlextorSubchannel, 0, out cmdDuration); + sense = _dev.PlextorReadCdDa(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + supportedPlextorSubchannel, + 0, + out cmdDuration); - if(!sense) - return false; + if(!sense) return false; // As a workaround for some firmware bugs, seek far away. - _dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize, blocksToRead, - supportedPlextorSubchannel, 0, out _); + _dev.PlextorReadCdDa(out _, + out senseBuf, + firstSectorToRead - 32, + blockSize, + blocksToRead, + supportedPlextorSubchannel, + 0, + out _); - sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, - supportedPlextorSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.PlextorReadCdDa(out cmdBuf, + out senseBuf, + firstSectorToRead, + blockSize, + blocksToRead, + supportedPlextorSubchannel, + _dev.Timeout, + out cmdDuration); return sense; } @@ -75,30 +92,51 @@ partial class Dump if(supportedPlextorSubchannel is PlextorSubchannel.Q16 or PlextorSubchannel.Pack) { - sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, 2352 + subSize, blocksToRead, - supportedPlextorSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.PlextorReadCdDa(out cmdBuf, + out senseBuf, + firstSectorToRead, + 2352 + subSize, + blocksToRead, + supportedPlextorSubchannel, + _dev.Timeout, + out cmdDuration); - if(!sense) - return false; + if(!sense) return false; } // As a workaround for some firmware bugs, seek far away. - _dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize, blocksToRead, - supportedPlextorSubchannel, 0, out _); + _dev.PlextorReadCdDa(out _, + out senseBuf, + firstSectorToRead - 32, + blockSize, + blocksToRead, + supportedPlextorSubchannel, + 0, + out _); - sense = _dev.PlextorReadCdDa(out byte[] dataBuf, out senseBuf, firstSectorToRead, 2352, blocksToRead, - PlextorSubchannel.None, 0, out cmdDuration); + sense = _dev.PlextorReadCdDa(out byte[] dataBuf, + out senseBuf, + firstSectorToRead, + 2352, + blocksToRead, + PlextorSubchannel.None, + 0, + out cmdDuration); - if(sense) - return true; + if(sense) return true; - sense = _dev.PlextorReadCdDa(out byte[] subBuf, out senseBuf, firstSectorToRead, subSize, blocksToRead, + sense = _dev.PlextorReadCdDa(out byte[] subBuf, + out senseBuf, + firstSectorToRead, + subSize, + blocksToRead, supportedPlextorSubchannel == PlextorSubchannel.Pack ? PlextorSubchannel.All - : supportedPlextorSubchannel, 0, out cmdDuration); + : supportedPlextorSubchannel, + 0, + out cmdDuration); - if(sense) - return true; + if(sense) return true; cmdBuf = new byte[2352 * blocksToRead + subSize * blocksToRead]; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs index 89f3f4415..7ecf7373e 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs @@ -92,9 +92,22 @@ partial class Dump ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); // ReSharper disable IntVariableOverflowInUncheckedContext - sense = _dev.ReadCd(out cmdBuf, out _, (uint)firstTrackPregapBlock, blockSize, 1, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out _, + (uint)firstTrackPregapBlock, + blockSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); // ReSharper restore IntVariableOverflowInUncheckedContext @@ -108,16 +121,14 @@ partial class Dump else { // Write empty data - if(gotFirstTrackPregap) - firstTrackPregapMs.Write(new byte[blockSize], 0, (int)blockSize); + if(gotFirstTrackPregap) firstTrackPregapMs.Write(new byte[blockSize], 0, (int)blockSize); } sectorSpeedStart++; double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -162,8 +173,7 @@ partial class Dump Dictionary pregaps = new(); inexactPositioning = false; - if(!supportsPqSubchannel && !supportsRwSubchannel) - return; + if(!supportsPqSubchannel && !supportsRwSubchannel) return; // Check if subchannel is BCD for(retries = 0; retries < 10; retries++) @@ -172,35 +182,34 @@ partial class Dump ? GetSectorForPregapRaw(dev, 11, dbDev, out subBuf, false) : GetSectorForPregapQ16(dev, 11, out subBuf, false); - if(sense) - continue; + if(sense) continue; bcd = (subBuf[9] & 0x10) > 0; break; } - AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, bcd switch - { - true => Localization.Core.Subchannel_is_BCD, - false => Localization.Core.Subchannel_is_not_BCD, - _ => Localization.Core.Could_not_detect_drive_subchannel_BCD - }); + AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, + bcd switch + { + true => Localization.Core.Subchannel_is_BCD, + false => Localization.Core.Subchannel_is_not_BCD, + _ => Localization.Core.Could_not_detect_drive_subchannel_BCD + }); if(bcd is null) { - dumpLog?.WriteLine(Localization.Core. - Could_not_detect_if_drive_subchannel_is_BCD_or_not_pregaps_could_not_be_calculated_dump_may_be_incorrect); + dumpLog?.WriteLine(Localization.Core + .Could_not_detect_if_drive_subchannel_is_BCD_or_not_pregaps_could_not_be_calculated_dump_may_be_incorrect); - updateStatus?.Invoke(Localization.Core. - Could_not_detect_if_drive_subchannel_is_BCD_or_not_pregaps_could_not_be_calculated_dump_may_be_incorrect); + updateStatus?.Invoke(Localization.Core + .Could_not_detect_if_drive_subchannel_is_BCD_or_not_pregaps_could_not_be_calculated_dump_may_be_incorrect); return; } // Initialize the dictionary - foreach(Track t in tracks) - pregaps[t.Sequence] = 0; + foreach(Track t in tracks) pregaps[t.Sequence] = 0; for(var t = 0; t < tracks.Length; t++) { @@ -212,8 +221,7 @@ partial class Dump { AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.Skipping_track_0, track.Sequence); - if(track.Sequence > 1) - pregaps[track.Sequence] = 150; + if(track.Sequence > 1) pregaps[track.Sequence] = 150; continue; } @@ -255,23 +263,39 @@ partial class Dump if(sense) { - AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.LBA_0_Try_1_Sense_2, lba, - retries + 1, sense); + AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, + Localization.Core.LBA_0_Try_1_Sense_2, + lba, + retries + 1, + sense); continue; } - if(bcd == false) - BinaryToBcdQ(subBuf); + if(bcd == false) BinaryToBcdQ(subBuf); CRC16CcittContext.Data(subBuf, 10, out crc); AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, - Localization.Core. - LBA_0_Try_1_Sense_2_Q_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, - lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3], - subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9], subBuf[10], - subBuf[11], crc[0], crc[1]); + Localization.Core + .LBA_0_Try_1_Sense_2_Q_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, + lba, + retries + 1, + sense, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crc[0], + crc[1]); crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11]; @@ -279,8 +303,7 @@ partial class Dump if(!crcOk) { // Data track cannot have 11xxb in CONTROL - if((subBuf[0] & 0x40) > 0) - subBuf[0] &= 0x7F; + if((subBuf[0] & 0x40) > 0) subBuf[0] &= 0x7F; // ADR only uses two bits subBuf[0] &= 0xF3; @@ -294,11 +317,9 @@ partial class Dump // Fix BCD numbering for(var i = 1; i < 10; i++) { - if((subBuf[i] & 0xF0) > 0xA0) - subBuf[i] &= 0x7F; + if((subBuf[i] & 0xF0) > 0xA0) subBuf[i] &= 0x7F; - if((subBuf[i] & 0x0F) > 0x0A) - subBuf[i] &= 0xF7; + if((subBuf[i] & 0x0F) > 0x0A) subBuf[i] &= 0xF7; } } @@ -309,11 +330,25 @@ partial class Dump if(crcOk) { AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, - Localization.Core. - LBA_0_Try_1_Sense_2_Q_FIXED_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, - lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3], - subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9], - subBuf[10], subBuf[11], crc[0], crc[1]); + Localization.Core + .LBA_0_Try_1_Sense_2_Q_FIXED_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, + lba, + retries + 1, + sense, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crc[0], + crc[1]); } else continue; @@ -322,21 +357,18 @@ partial class Dump BcdToBinaryQ(subBuf); // Q position - if((subBuf[0] & 0xF) != 1) - continue; + if((subBuf[0] & 0xF) != 1) continue; posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150; - if(subBuf[1] != track.Sequence - 1 || subBuf[2] == 0 || posQ != lba) - break; + if(subBuf[1] != track.Sequence - 1 || subBuf[2] == 0 || posQ != lba) break; pregaps[track.Sequence] = 0; pregapFound = true; } - if(pregapFound) - continue; + if(pregapFound) continue; // Calculate pregap lba = (int)track.StartSector - 150; @@ -347,7 +379,10 @@ partial class Dump if(!forward) { sense = supportsRwSubchannel - ? GetSectorForPregapRaw(dev, (uint)lba - 10, dbDev, out subBuf, + ? GetSectorForPregapRaw(dev, + (uint)lba - 10, + dbDev, + out subBuf, track.Type == TrackType.Audio) : GetSectorForPregapQ16(dev, (uint)lba - 10, out subBuf, track.Type == TrackType.Audio); } @@ -355,24 +390,39 @@ partial class Dump for(retries = 0; retries < 10; retries++) { sense = supportsRwSubchannel - ? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf, + ? GetSectorForPregapRaw(dev, + (uint)lba, + dbDev, + out subBuf, track.Type == TrackType.Audio) : GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio); - if(sense) - continue; + if(sense) continue; - if(bcd == false) - BinaryToBcdQ(subBuf); + if(bcd == false) BinaryToBcdQ(subBuf); CRC16CcittContext.Data(subBuf, 10, out crc); AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, - Localization.Core. - LBA_0_Try_1_Sense_2_Q_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, - lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3], - subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9], - subBuf[10], subBuf[11], crc[0], crc[1]); + Localization.Core + .LBA_0_Try_1_Sense_2_Q_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, + lba, + retries + 1, + sense, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crc[0], + crc[1]); crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11]; @@ -380,8 +430,7 @@ partial class Dump if(!crcOk) { // Data track cannot have 11xxb in CONTROL - if((subBuf[0] & 0x40) > 0) - subBuf[0] &= 0x7F; + if((subBuf[0] & 0x40) > 0) subBuf[0] &= 0x7F; // ADR only uses two bits subBuf[0] &= 0xF3; @@ -395,11 +444,9 @@ partial class Dump // Fix BCD numbering for(var i = 1; i < 10; i++) { - if((subBuf[i] & 0xF0) > 0xA0) - subBuf[i] &= 0x7F; + if((subBuf[i] & 0xF0) > 0xA0) subBuf[i] &= 0x7F; - if((subBuf[i] & 0x0F) > 0x0A) - subBuf[i] &= 0xF7; + if((subBuf[i] & 0x0F) > 0x0A) subBuf[i] &= 0xF7; } } @@ -410,18 +457,31 @@ partial class Dump if(crcOk) { AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, - Localization.Core. - LBA_0_Try_1_Sense_2_Q_FIXED_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, - lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], - subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], - subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]); + Localization.Core + .LBA_0_Try_1_Sense_2_Q_FIXED_3_4_5_6_7_8_9_10_11_12_CRC_13_14_Calculated_CRC_15_16, + lba, + retries + 1, + sense, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crc[0], + crc[1]); break; } } - if(crcOk) - break; + if(crcOk) break; } if(retries == 10) @@ -437,32 +497,30 @@ partial class Dump if(previousTrack.Type == TrackType.Audio && track.Type != TrackType.Audio || previousTrack.Type != TrackType.Audio && track.Type == TrackType.Audio) { - dumpLog?.WriteLine(Localization.Core. - Could_not_read_subchannel_for_this_track_supposing_hundred_fifty_sectors); + dumpLog?.WriteLine(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_hundred_fifty_sectors); - updateStatus?.Invoke(Localization.Core. - Could_not_read_subchannel_for_this_track_supposing_hundred_fifty_sectors); + updateStatus?.Invoke(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_hundred_fifty_sectors); } else { - dumpLog?.WriteLine(Localization.Core. - Could_not_read_subchannel_for_this_track_supposing_zero_sectors); + dumpLog?.WriteLine(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_zero_sectors); - updateStatus?.Invoke(Localization.Core. - Could_not_read_subchannel_for_this_track_supposing_zero_sectors); + updateStatus?.Invoke(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_zero_sectors); } } else { - dumpLog?. - WriteLine(string. - Format(Localization.Core.Could_not_read_subchannel_for_this_track_supposing_0_sectors, - pregaps[track.Sequence])); + dumpLog?.WriteLine(string.Format(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_0_sectors, + pregaps[track.Sequence])); - updateStatus?. - Invoke(string. - Format(Localization.Core.Could_not_read_subchannel_for_this_track_supposing_0_sectors, - pregaps[track.Sequence])); + updateStatus?.Invoke(string.Format(Localization.Core + .Could_not_read_subchannel_for_this_track_supposing_0_sectors, + pregaps[track.Sequence])); } break; @@ -507,8 +565,7 @@ partial class Dump lba++; forward = true; - if(lba == (int)previousTrack.StartSector) - break; + if(lba == (int)previousTrack.StartSector) break; continue; } @@ -529,8 +586,7 @@ partial class Dump previousPregapIsPreviousTrack = true; // Already gone back, so go forward - if(goneBack) - goFront = true; + if(goneBack) goFront = true; continue; } @@ -541,8 +597,7 @@ partial class Dump lba--; forward = false; - if(previousPregapIsPreviousTrack) - break; + if(previousPregapIsPreviousTrack) break; continue; } @@ -556,8 +611,10 @@ partial class Dump if(diff != 0) { - AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.Invalid_Q_position_for_LBA_0_got_1, - lba, posQ); + AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, + Localization.Core.Invalid_Q_position_for_LBA_0_got_1, + lba, + posQ); inexactPositioning = true; } @@ -565,8 +622,7 @@ partial class Dump // Received a Q post the LBA we wanted, just go back. If we are already going forward, break if(posQ > lba) { - if(forward) - break; + if(forward) break; lba--; @@ -579,8 +635,10 @@ partial class Dump // If CRC is not OK, only accept pregaps less than 10 sectors longer than previously now if(crcOk || pregapQ - pregaps[track.Sequence] < 10) { - AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.Pregap_for_track_0_1, - track.Sequence, pregapQ); + AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, + Localization.Core.Pregap_for_track_0_1, + track.Sequence, + pregapQ); pregaps[track.Sequence] = pregapQ; } @@ -593,8 +651,7 @@ partial class Dump break; } } - else if(pregapQ == pregaps[track.Sequence]) - break; + else if(pregapQ == pregaps[track.Sequence]) break; lba--; forward = false; @@ -606,8 +663,7 @@ partial class Dump trk.Pregap = (ulong)pregaps[trk.Sequence]; // Do not reduce pregap, or starting position of session's first track - if(tracks.Where(t => t.Session == trk.Session).MinBy(t => t.Sequence).Sequence == trk.Sequence) - continue; + if(tracks.Where(t => t.Session == trk.Session).MinBy(t => t.Sequence).Sequence == trk.Sequence) continue; if(dumping) { @@ -623,12 +679,13 @@ partial class Dump trk.StartSector -= trk.Pregap; - #if DEBUG +#if DEBUG dumpLog?.WriteLine(string.Format(Localization.Core.Track_0_pregap_is_1_sectors, trk.Sequence, trk.Pregap)); - updateStatus?.Invoke(string.Format(Localization.Core.Track_0_pregap_is_1_sectors, trk.Sequence, + updateStatus?.Invoke(string.Format(Localization.Core.Track_0_pregap_is_1_sectors, + trk.Sequence, trk.Pregap)); - #endif +#endif } } @@ -648,27 +705,79 @@ partial class Dump if(audioTrack) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2448, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2448, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, + out _); } } else { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, + out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2448, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2448, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, out _); } } @@ -681,15 +790,41 @@ partial class Dump } else { - sense = dev.ReadCd(out cmdBuf, out _, lba, 96, 1, MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 96, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 96, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 96, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, + out _); } if(!sense) @@ -700,8 +835,7 @@ partial class Dump sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout, out _); { - if(!sense) - subBuf = DeinterleaveQ(cmdBuf); + if(!sense) subBuf = DeinterleaveQ(cmdBuf); } } @@ -722,27 +856,79 @@ partial class Dump if(audioTrack) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2368, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2368, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2368, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2368, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, + out _); } } else { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2368, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2368, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, + out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 2368, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 2368, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, out _); } } @@ -754,19 +940,44 @@ partial class Dump } else { - sense = dev.ReadCd(out cmdBuf, out _, lba, 16, 1, MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 16, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, out _); if(sense) { - sense = dev.ReadCd(out cmdBuf, out _, lba, 16, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Q16, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + lba, + 16, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, + out _); } - if(!sense) - subBuf = cmdBuf; + if(!sense) subBuf = cmdBuf; } return sense; @@ -794,8 +1005,7 @@ partial class Dump var deQ = new byte[q.Length]; - for(var iq = 0; iq < q.Length; iq++) - deQ[iq] = (byte)q[iq]; + for(var iq = 0; iq < q.Length; iq++) deQ[iq] = (byte)q[iq]; return deQ; } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs index 136883cdf..e418fc89b 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs @@ -50,8 +50,7 @@ partial class Dump { List runOutSectors = new(); - if(_outputPlugin is not IWritableOpticalImage outputOptical) - return; + if(_outputPlugin is not IWritableOpticalImage outputOptical) return; // Count how many run end sectors are detected as bad blocks for(ulong i = blocks - 1; i > blocks - 1 - _ignoreCdrRunOuts; i--) @@ -62,8 +61,7 @@ partial class Dump break; } - if(runOutSectors.Count == 0) - return; + if(runOutSectors.Count == 0) return; _dumpLog.WriteLine(string.Format(Localization.Core._0_sectors_at_the_end_of_the_disc_are_unreadable, runOutSectors.Count)); @@ -75,8 +73,7 @@ partial class Dump { Track track = tracks.FirstOrDefault(t => t.StartSector <= s && t.EndSector >= s); - if(track is null) - continue; + if(track is null) continue; var sector = new byte[2352]; @@ -115,8 +112,7 @@ partial class Dump _resume.BadBlocks.Remove(s); extents.Add(s); - if(desiredSubchannel == MmcSubchannel.None) - continue; + if(desiredSubchannel == MmcSubchannel.None) continue; // Hidden track ulong trackStart; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs index 11aca2ecf..419082d13 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs @@ -53,8 +53,21 @@ partial class Dump dumpLog?.WriteLine(Localization.Core.Checking_if_drive_supports_full_raw_subchannel_reading); updateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_full_raw_subchannel_reading); - return !dev.ReadCd(out _, out _, lba, 2352 + 96, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + return !dev.ReadCd(out _, + out _, + lba, + 2352 + 96, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, out _); } @@ -69,8 +82,21 @@ partial class Dump dumpLog?.WriteLine(Localization.Core.Checking_if_drive_supports_PQ_subchannel_reading); updateStatus?.Invoke(Localization.Core.Checking_if_drive_supports_PQ_subchannel_reading); - return !dev.ReadCd(out _, out _, lba, 2352 + 16, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout, + return !dev.ReadCd(out _, + out _, + lba, + 2352 + 16, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + dev.Timeout, out _); } } \ No newline at end of file diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs index a04c9a64f..93a55ec1e 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs @@ -84,7 +84,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Disc_Information); UpdateStatus?.Invoke(Localization.Core.Reading_Disc_Information); - sense = _dev.ReadDiscInformation(out cmdBuf, out _, MmcDiscInformationDataTypes.DiscInformation, _dev.Timeout, + sense = _dev.ReadDiscInformation(out cmdBuf, + out _, + MmcDiscInformationDataTypes.DiscInformation, + _dev.Timeout, out _); if(!sense) @@ -133,8 +136,7 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_CD_Text_from_Lead_In); sense = _dev.ReadCdText(out cmdBuf, out _, _dev.Timeout, out _); - if(sense || !CDTextOnLeadIn.Decode(cmdBuf).HasValue) - return; + if(sense || !CDTextOnLeadIn.Decode(cmdBuf).HasValue) return; tmpBuf = new byte[cmdBuf.Length - 4]; Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs index 600672080..b5c8eb9ec 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs @@ -186,19 +186,19 @@ partial class Dump if((sense || !oldToc.HasValue) && !force) { - dumpLog?.WriteLine(Localization.Core. - Could_not_read_TOC_if_you_want_to_continue_use_force_and_will_try_from_LBA_0_to_360000); + dumpLog?.WriteLine(Localization.Core + .Could_not_read_TOC_if_you_want_to_continue_use_force_and_will_try_from_LBA_0_to_360000); - stoppingErrorMessage?.Invoke(Localization.Core. - Could_not_read_TOC_if_you_want_to_continue_use_force_and_will_try_from_LBA_0_to_360000); + stoppingErrorMessage?.Invoke(Localization.Core + .Could_not_read_TOC_if_you_want_to_continue_use_force_and_will_try_from_LBA_0_to_360000); return null; } if(oldToc.HasValue) { - foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.OrderBy(t => t.TrackNumber). - Where(trk => trk.ADR is 1 or 4)) + foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.OrderBy(t => t.TrackNumber) + .Where(trk => trk.ADR is 1 or 4)) { switch(trk.TrackNumber) { @@ -252,8 +252,7 @@ partial class Dump trackFlags?.Add(1, (byte)(leadoutTrackType == TrackType.Audio ? 0 : 4)); } - if(lastSector != 0) - return trackList.ToArray(); + if(lastSector != 0) return trackList.ToArray(); sense = dev.ReadCapacity16(out cmdBuf, out _, dev.Timeout, out _); @@ -269,17 +268,15 @@ partial class Dump { sense = dev.ReadCapacity(out cmdBuf, out _, dev.Timeout, out _); - if(!sense) - lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3] & 0xFFFFFFFF; + if(!sense) lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3] & 0xFFFFFFFF; } - if(lastSector > 0) - return trackList.ToArray(); + if(lastSector > 0) return trackList.ToArray(); if(!force) { - stoppingErrorMessage?.Invoke(Localization.Core. - Could_not_find_Lead_Out_if_you_want_to_continue_use_force_option); + stoppingErrorMessage?.Invoke(Localization.Core + .Could_not_find_Lead_Out_if_you_want_to_continue_use_force_option); dumpLog?.WriteLine(Localization.Core.Could_not_find_Lead_Out_if_you_want_to_continue_use_force_option); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index f119e6c3c..470c5b101 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -100,8 +100,7 @@ partial class Dump _ => PlextorSubchannel.None }; - if(_resume.BadBlocks.Count <= 0 || _aborted || !_trim || !newTrim) - return; + if(_resume.BadBlocks.Count <= 0 || _aborted || !_trim || !newTrim) return; UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); @@ -146,16 +145,34 @@ partial class Dump if(_supportsPlextorD8 && audioExtents.Contains(badSector)) { - sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, - supportedPlextorSubchannel, out cmdDuration); + sense = ReadPlextorWithSubchannel(out cmdBuf, + out senseBuf, + badSectorToRead, + blockSize, + sectorsToTrim, + supportedPlextorSubchannel, + out cmdDuration); } else if(readcd) { if(audioExtents.Contains(badSector)) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, - MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + badSectorToRead, + blockSize, + sectorsToTrim, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); if(sense) { @@ -164,9 +181,21 @@ partial class Dump // Try to workaround firmware if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { - sense = _dev.ReadCd(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + sense = _dev.ReadCd(out cmdBuf, + out _, + badSectorToRead, + blockSize, + sectorsToTrim, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, out double cmdDuration2); cmdDuration += cmdDuration2; @@ -175,9 +204,22 @@ partial class Dump } else { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out cmdBuf, + out senseBuf, + badSectorToRead, + blockSize, + sectorsToTrim, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out cmdDuration); if(sense) { @@ -203,24 +245,46 @@ partial class Dump scrambledSectorsToTrim += (byte)sectorsForOffset; } - sense = _dev.ReadCd(out cmdBuf, out _, scrambledBadSectorToRead, blockSize, - scrambledSectorsToTrim, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - supportedSubchannel, _dev.Timeout, out double cmdDuration2); + sense = _dev.ReadCd(out cmdBuf, + out _, + scrambledBadSectorToRead, + blockSize, + scrambledSectorsToTrim, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + supportedSubchannel, + _dev.Timeout, + out double cmdDuration2); cmdDuration += cmdDuration2; if(!sense) { uint scrambledBlocksToRead = scrambledSectorsToTrim; - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, - ref scrambledBlocksToRead, subSize, ref cmdBuf, blockSize, false); + + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref scrambledBlocksToRead, + subSize, + ref cmdBuf, + blockSize, + false); // Descramble cmdBuf = Sector.Scramble(cmdBuf); // Check valid sector - CdChecksums.CheckCdSector(cmdBuf, out bool? correctEccP, out bool? correctEccQ, + CdChecksums.CheckCdSector(cmdBuf, + out bool? correctEccP, + out bool? correctEccQ, out bool? correctEdc); // Check mode, set sense if EDC/ECC validity is not correct @@ -230,8 +294,7 @@ partial class Dump for(var c = 16; c < 2352; c++) { - if(cmdBuf[c] == 0x00) - continue; + if(cmdBuf[c] == 0x00) continue; sense = true; @@ -246,15 +309,12 @@ partial class Dump case 2: if((cmdBuf[18] & 0x20) != 0x20) { - if(correctEccP != true) - sense = true; + if(correctEccP != true) sense = true; - if(correctEccQ != true) - sense = true; + if(correctEccQ != true) sense = true; } - if(correctEdc != true) - sense = true; + if(correctEdc != true) sense = true; break; } @@ -267,22 +327,61 @@ partial class Dump } else if(read16) { - sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, badSectorToRead, blockSize, 0, - sectorsToTrim, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read16(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + badSectorToRead, + blockSize, + 0, + sectorsToTrim, + false, + _dev.Timeout, + out cmdDuration); } else if(read12) { - sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead, blockSize, - 0, sectorsToTrim, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + badSectorToRead, + blockSize, + 0, + sectorsToTrim, + false, + _dev.Timeout, + out cmdDuration); } else if(read10) { - sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, badSectorToRead, blockSize, - 0, sectorsToTrim, _dev.Timeout, out cmdDuration); + sense = _dev.Read10(out cmdBuf, + out senseBuf, + 0, + false, + true, + false, + false, + badSectorToRead, + blockSize, + 0, + sectorsToTrim, + _dev.Timeout, + out cmdDuration); } else if(read6) { - sense = _dev.Read6(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, _dev.Timeout, + sense = _dev.Read6(out cmdBuf, + out senseBuf, + badSectorToRead, + blockSize, + sectorsToTrim, + _dev.Timeout, out cmdDuration); } @@ -307,8 +406,15 @@ partial class Dump { uint blocksToRead = sectorsToTrim; - FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead, subSize, - ref cmdBuf, blockSize, false); + FixOffsetData(offsetBytes, + sectorSize, + sectorsForOffset, + supportedSubchannel, + ref blocksToRead, + subSize, + ref cmdBuf, + blockSize, + false); } if(supportedSubchannel != MmcSubchannel.None) @@ -325,18 +431,29 @@ partial class Dump ulong trkStartBefore = track.StartSector; - bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, - sub, badSector, 1, subLog, isrcs, - (byte)track.Sequence, ref mcn, tracks, + bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, + desiredSubchannel, + sub, + badSector, + 1, + subLog, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks, subchannelExtents, - _fixSubchannelPosition, outputOptical, - _fixSubchannel, _fixSubchannelCrc, - _dumpLog, UpdateStatus, - smallestPregapLbaPerTrack, true, out _); + _fixSubchannelPosition, + outputOptical, + _fixSubchannel, + _fixSubchannelCrc, + _dumpLog, + UpdateStatus, + smallestPregapLbaPerTrack, + true, + out _); // Set tracks and go back - if(!indexesChanged) - continue; + if(!indexesChanged) continue; outputOptical.SetTracks(tracks.ToList()); diff --git a/Aaru.Core/Devices/Dumping/Dump.cs b/Aaru.Core/Devices/Dumping/Dump.cs index 074cd139c..6df6fb128 100644 --- a/Aaru.Core/Devices/Dumping/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Dump.cs @@ -247,8 +247,7 @@ public partial class Dump _dumpLog.WriteLine(string.Format(Localization.Core.Device_in_database_since_0, _dbDev.LastSynchronized)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_in_database_since_0, _dbDev.LastSynchronized)); - if(_dbDev.OptimalMultipleSectorsRead > 0) - _maximumReadable = (uint)_dbDev.OptimalMultipleSectorsRead; + if(_dbDev.OptimalMultipleSectorsRead > 0) _maximumReadable = (uint)_dbDev.OptimalMultipleSectorsRead; } switch(_dev.IsUsb) @@ -296,8 +295,7 @@ public partial class Dump _errorLog.Close(); _dumpLog.Close(); - if(_resume == null || !_doResume) - return; + if(_resume == null || !_doResume) return; _resume.LastWriteDate = DateTime.UtcNow; _resume.BadBlocks.Sort(); @@ -308,18 +306,19 @@ public partial class Dump _mediaGraph?.WriteTo($"{_outputPrefix}.graph.png"); } - if(File.Exists(_outputPrefix + ".resume.xml")) - File.Delete(_outputPrefix + ".resume.xml"); + if(File.Exists(_outputPrefix + ".resume.xml")) File.Delete(_outputPrefix + ".resume.xml"); - if(File.Exists(_outputPrefix + ".resume.json")) - File.Delete(_outputPrefix + ".resume.json"); + if(File.Exists(_outputPrefix + ".resume.json")) File.Delete(_outputPrefix + ".resume.json"); var fs = new FileStream(_outputPrefix + ".resume.json", FileMode.Create, FileAccess.ReadWrite); - JsonSerializer.Serialize(fs, new ResumeJson - { - Resume = _resume - }, typeof(ResumeJson), ResumeJsonContext.Default); + JsonSerializer.Serialize(fs, + new ResumeJson + { + Resume = _resume + }, + typeof(ResumeJson), + ResumeJsonContext.Default); fs.Close(); } diff --git a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs index b2b74e0b8..37a176e42 100644 --- a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs +++ b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs @@ -56,7 +56,18 @@ public partial class Dump /// Dumps a game cartridge using a Retrode adapter void Retrode() { - bool sense = _dev.Read10(out byte[] buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, _dev.Timeout, + bool sense = _dev.Read10(out byte[] buffer, + out _, + 0, + false, + true, + false, + false, + 0, + 512, + 0, + 1, + _dev.Timeout, out _); if(sense) @@ -155,8 +166,7 @@ public partial class Dump break; } - if(!tmp.SequenceEqual(_gbaExtension)) - continue; + if(!tmp.SequenceEqual(_gbaExtension)) continue; gbaFound = true; @@ -174,11 +184,17 @@ public partial class Dump var cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A); var romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C); - MediaType mediaType = gbaFound ? MediaType.GameBoyAdvanceGamePak : - gbFound || gbcFound ? MediaType.GameBoyGamePak : - n64Found ? MediaType.N64GamePak : - smsFound ? MediaType.MasterSystemCartridge : - genesisFound ? MediaType.MegaDriveCartridge : MediaType.SNESGamePak; + MediaType mediaType = gbaFound + ? MediaType.GameBoyAdvanceGamePak + : gbFound || gbcFound + ? MediaType.GameBoyGamePak + : n64Found + ? MediaType.N64GamePak + : smsFound + ? MediaType.MasterSystemCartridge + : genesisFound + ? MediaType.MegaDriveCartridge + : MediaType.SNESGamePak; uint blocksToRead = 64; double totalDuration = 0; @@ -191,13 +207,24 @@ public partial class Dump { _dumpLog.WriteLine(Localization.Core.The_specified_format_does_not_support_the_inserted_cartridge); - StoppingErrorMessage?.Invoke(Localization.Core. - The_specified_format_does_not_support_the_inserted_cartridge); + StoppingErrorMessage?.Invoke(Localization.Core + .The_specified_format_does_not_support_the_inserted_cartridge); return; } - sense = _dev.Read10(out byte[] readBuffer, out _, 0, false, true, false, false, 0, 512, 0, 1, _dev.Timeout, + sense = _dev.Read10(out byte[] readBuffer, + out _, + 0, + false, + true, + false, + false, + 0, + 512, + 0, + 1, + _dev.Timeout, out _); if(sense) @@ -215,17 +242,20 @@ public partial class Dump switch(romSize) { case > 1073741824: - UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_GiB, romSize, + UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_GiB, + romSize, romSize / 1073741824d)); break; case > 1048576: - UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_MiB, romSize, + UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_MiB, + romSize, romSize / 1048576d)); break; case > 1024: - UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_KiB, romSize, + UpdateStatus?.Invoke(string.Format(Localization.Core.Cartridge_has_0_bytes_1_KiB, + romSize, romSize / 1024d)); break; @@ -253,8 +283,7 @@ public partial class Dump return; } - if(_createGraph) - _mediaGraph = new BlockMap((int)_dimensions, (int)_dimensions, romSectors); + if(_createGraph) _mediaGraph = new BlockMap((int)_dimensions, (int)_dimensions, romSectors); _dumpStopwatch.Restart(); double imageWriteDuration = 0; @@ -273,22 +302,35 @@ public partial class Dump break; } - if(romSectors - i < blocksToRead) - blocksToRead = (uint)(romSectors - i); + if(romSectors - i < blocksToRead) blocksToRead = (uint)(romSectors - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i * 512, romSize); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, + i * 512, + romSize, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i * 512, + romSize); _speedStopwatch.Start(); - sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(startSector + i), - 512, 0, (ushort)blocksToRead, _dev.Timeout, out double cmdDuration); + + sense = _dev.Read10(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(startSector + i), + 512, + 0, + (ushort)blocksToRead, + _dev.Timeout, + out double cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -305,8 +347,7 @@ public partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly _dumpLog.WriteLine(Localization.Core.Skipping_0_bytes_from_errored_byte_1, _skip * 512, i * 512); i += _skip - blocksToRead; @@ -318,8 +359,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * 512 < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * 512 < 524288) continue; currentSpeed = sectorSpeedStart * 512 / (1048576 * elapsed); sectorSpeedStart = 0; @@ -330,18 +370,30 @@ public partial class Dump if(romRemaining > 0 && !_aborted) { - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)romSectors * 512, romSize); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, + romSectors * 512, + romSize, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)romSectors * 512, + romSize); - sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, romSectors, 512, 0, 1, - _dev.Timeout, out double cmdDuration); + sense = _dev.Read10(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + romSectors, + 512, + 0, + 1, + _dev.Timeout, + out double cmdDuration); totalDuration += cmdDuration; @@ -357,11 +409,11 @@ public partial class Dump _errorLog?.WriteLine(romSectors, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - _dumpLog.WriteLine(Localization.Core.Skipping_0_bytes_from_errored_byte_1, _skip * 512, - romSectors * 512); + _dumpLog.WriteLine(Localization.Core.Skipping_0_bytes_from_errored_byte_1, + _skip * 512, + romSectors * 512); } } @@ -371,27 +423,27 @@ public partial class Dump _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(512 * (romSectors + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(512 * (romSectors + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(512 * (romSectors + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(512 * (romSectors + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); var metadata = new CommonTypes.Structs.ImageInfo { @@ -409,8 +461,7 @@ public partial class Dump // TODO: Set dump hardware //outputBAI.SetDumpHardware(); - if(_preSidecar != null) - outputBai.SetMetadata(_preSidecar); + if(_preSidecar != null) outputBai.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -437,18 +488,18 @@ public partial class Dump */ UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(512 * (romSectors + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index 483eb7d51..76eb0ecf2 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -209,34 +209,66 @@ partial class Dump if(sense || _dev.Error) { - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout, + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x00, + _dev.Timeout, out _); - if(!sense && !_dev.Error) - decMode = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); + if(!sense && !_dev.Error) decMode = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); } else decMode = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); if(decMode is null) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x00, - 0x00, _dev.Timeout, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x00, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, false, ScsiModeSensePageControl.Current, - 0x00, 0x00, _dev.Timeout, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + false, + ScsiModeSensePageControl.Current, + 0x00, + 0x00, + _dev.Timeout, + out _); if(!sense && !_dev.Error) decMode = Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); @@ -254,8 +286,9 @@ partial class Dump if(decMode.HasValue && _dev.IsUsb && !gotConfiguration && - decMode.Value.Header.MediumType is MediumTypes.UnknownBlockDevice or MediumTypes.ReadOnlyBlockDevice - or MediumTypes.ReadWriteBlockDevice) + decMode.Value.Header.MediumType is MediumTypes.UnknownBlockDevice + or MediumTypes.ReadOnlyBlockDevice + or MediumTypes.ReadWriteBlockDevice) { _speedMultiplier = -1; Sbc(null, MediaType.Unknown, false); @@ -290,15 +323,22 @@ partial class Dump }; } - #region Nintendo +#region Nintendo switch(dskType) { case MediaType.Unknown when blocks > 0: _dumpLog.WriteLine(Localization.Core.Reading_Physical_Format_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -306,11 +346,11 @@ partial class Dump if(nintendoPfi is { DiskCategory: DiskCategory.Nintendo, PartVersion: 15 }) { - _dumpLog.WriteLine(Localization.Core. - Dumping_Nintendo_GameCube_or_Wii_discs_is_not_yet_implemented); + _dumpLog.WriteLine(Localization.Core + .Dumping_Nintendo_GameCube_or_Wii_discs_is_not_yet_implemented); - StoppingErrorMessage?.Invoke(Localization.Core. - Dumping_Nintendo_GameCube_or_Wii_discs_is_not_yet_implemented); + StoppingErrorMessage?.Invoke(Localization.Core + .Dumping_Nintendo_GameCube_or_Wii_discs_is_not_yet_implemented); return; } @@ -336,8 +376,15 @@ partial class Dump case MediaType.HDDVDRWDL: _dumpLog.WriteLine(Localization.Core.Reading_Physical_Format_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -379,8 +426,14 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Disc_Manufacturing_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, _dev.Timeout, + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + _dev.Timeout, out _); if(!sense) @@ -406,22 +459,21 @@ partial class Dump if(sense || Inquiry.Decode(inqBuf)?.KreonPresent != true) { - _dumpLog.WriteLine(Localization.Core. - Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware); + _dumpLog.WriteLine(Localization.Core + .Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware); - StoppingErrorMessage?.Invoke(Localization.Core. - Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware); + StoppingErrorMessage?.Invoke(Localization.Core + .Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware); - if(!_force) - return; + if(!_force) return; isXbox = false; } if(_dumpRaw && !_force) { - StoppingErrorMessage?.Invoke(Localization.Core. - If_you_want_to_continue_reading_cooked_data_when_raw_is_not_available_use_the_force_option); + StoppingErrorMessage?.Invoke(Localization.Core + .If_you_want_to_continue_reading_cooked_data_when_raw_is_not_available_use_the_force_option); // TODO: Exit more gracefully return; @@ -439,20 +491,27 @@ partial class Dump break; } - #endregion Nintendo +#endregion Nintendo - #region All DVD and HD DVD types +#region All DVD and HD DVD types - #endregion All DVD and HD DVD types +#endregion All DVD and HD DVD types - #region DVD-ROM +#region DVD-ROM if(dskType is MediaType.DVDDownload or MediaType.DVDROM) { _dumpLog.WriteLine(Localization.Core.Reading_Lead_in_Copyright_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.CopyrightInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.CopyrightInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -470,8 +529,8 @@ partial class Dump { if(!Settings.Settings.Current.EnableDecryption) { - UpdateStatus?.Invoke(Localization.Core. - Drive_reports_the_disc_uses_copy_protection_The_dump_will_be_incorrect_unless_decryption_is_enabled); + UpdateStatus?.Invoke(Localization.Core + .Drive_reports_the_disc_uses_copy_protection_The_dump_will_be_incorrect_unless_decryption_is_enabled); } else { @@ -481,9 +540,12 @@ partial class Dump dvdDecrypt = new DVDDecryption(_dev); - sense = dvdDecrypt.ReadBusKey(out cmdBuf, out _, + sense = dvdDecrypt.ReadBusKey(out cmdBuf, + out _, CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ?? - CopyrightType.NoProtection, _dev.Timeout, out _); + CopyrightType.NoProtection, + _dev.Timeout, + out _); if(!sense) { @@ -496,19 +558,24 @@ partial class Dump { CSS_CPRM.DiscKey? decodedDiscKey = CSS.DecodeDiscKey(cmdBuf, busKey); - sense = dvdDecrypt.ReadAsf(out cmdBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm, - _dev.Timeout, out _); + sense = dvdDecrypt.ReadAsf(out cmdBuf, + out _, + DvdCssKeyClass.DvdCssCppmOrCprm, + _dev.Timeout, + out _); if(!sense) { if(cmdBuf[7] == 1) { - UpdateStatus?.Invoke(Localization.Core. - Disc_and_drive_authentication_succeeded); + UpdateStatus?.Invoke(Localization.Core + .Disc_and_drive_authentication_succeeded); - sense = dvdDecrypt.ReadRpc(out cmdBuf, out _, + sense = dvdDecrypt.ReadRpc(out cmdBuf, + out _, DvdCssKeyClass.DvdCssCppmOrCprm, - _dev.Timeout, out _); + _dev.Timeout, + out _); if(!sense) { @@ -518,10 +585,10 @@ partial class Dump if(rpc.HasValue) { UpdateStatus?.Invoke(CSS.CheckRegion(rpc.Value, cmi.Value) - ? Localization.Core. - Disc_and_drive_regions_match - : Localization.Core. - Disc_and_drive_regions_do_not_match_The_dump_will_be_incorrect); + ? Localization.Core + .Disc_and_drive_regions_match + : Localization.Core + .Disc_and_drive_regions_do_not_match_The_dump_will_be_incorrect); } } @@ -535,15 +602,15 @@ partial class Dump if(discKey != null) { - UpdateStatus?.Invoke(Localization.Core. - Decryption_of_disc_key_succeeded); + UpdateStatus?.Invoke(Localization.Core + .Decryption_of_disc_key_succeeded); mediaTags.Add(MediaTagType.DVD_DiscKey_Decrypted, discKey); } else { - UpdateStatus?.Invoke(Localization.Core. - Decryption_of_disc_key_failed); + UpdateStatus?.Invoke(Localization.Core + .Decryption_of_disc_key_failed); } } } @@ -553,11 +620,11 @@ partial class Dump } else { - UpdateStatus?. - Invoke(string. - Format(Localization.Core.Drive_reports_0_copy_protection_not_yet_supported_dump_incorrect, - (CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ?? - CopyrightType.NoProtection).ToString())); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Drive_reports_0_copy_protection_not_yet_supported_dump_incorrect, + (CSS_CPRM.DecodeLeadInCopyright(cmdBuf) + ?.CopyrightType ?? + CopyrightType.NoProtection).ToString())); } } } @@ -565,19 +632,26 @@ partial class Dump } } - #endregion DVD-ROM +#endregion DVD-ROM switch(dskType) { - #region DVD-ROM and HD DVD-ROM +#region DVD-ROM and HD DVD-ROM case MediaType.DVDDownload: case MediaType.DVDROM: case MediaType.HDDVDROM: _dumpLog.WriteLine(Localization.Core.Reading_Burst_Cutting_Area); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.BurstCuttingArea, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.BurstCuttingArea, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -588,16 +662,23 @@ partial class Dump break; - #endregion DVD-ROM and HD DVD-ROM +#endregion DVD-ROM and HD DVD-ROM - #region DVD-RAM and HD DVD-RAM +#region DVD-RAM and HD DVD-RAM case MediaType.DVDRAM: case MediaType.HDDVDRAM: _dumpLog.WriteLine(Localization.Core.Reading_Disc_Description_Structure); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramDds, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -611,8 +692,14 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Spare_Area_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, _dev.Timeout, + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramSpareAreaInformation, + 0, + _dev.Timeout, out _); if(!sense) @@ -627,16 +714,23 @@ partial class Dump break; - #endregion DVD-RAM and HD DVD-RAM +#endregion DVD-RAM and HD DVD-RAM - #region DVD-R and DVD-RW +#region DVD-R and DVD-RW case MediaType.DVDR: case MediaType.DVDRW: _dumpLog.WriteLine(Localization.Core.Reading_Pre_Recorded_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PreRecordedInfo, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PreRecordedInfo, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -647,20 +741,27 @@ partial class Dump break; - #endregion DVD-R and DVD-RW +#endregion DVD-R and DVD-RW } switch(dskType) { - #region DVD-R, DVD-RW and HD DVD-R +#region DVD-R, DVD-RW and HD DVD-R case MediaType.DVDR: case MediaType.DVDRW: case MediaType.HDDVDR: _dumpLog.WriteLine(Localization.Core.Reading_Media_Identifier); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrMediaIdentifier, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrMediaIdentifier, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -671,8 +772,15 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Recordable_Physical_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrPhysicalInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -683,9 +791,9 @@ partial class Dump break; - #endregion DVD-R, DVD-RW and HD DVD-R +#endregion DVD-R, DVD-RW and HD DVD-R - #region All DVD+ +#region All DVD+ case MediaType.DVDPR: case MediaType.DVDPRDL: @@ -693,8 +801,15 @@ partial class Dump case MediaType.DVDPRWDL: _dumpLog.WriteLine(Localization.Core.Reading_ADdress_In_Pregroove); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Adip, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Adip, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -705,8 +820,15 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Disc_Control_Blocks); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Dcb, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Dcb, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -717,15 +839,21 @@ partial class Dump break; - #endregion All DVD+ +#endregion All DVD+ - #region HD DVD-ROM +#region HD DVD-ROM case MediaType.HDDVDROM: _dumpLog.WriteLine(Localization.Core.Reading_Lead_in_Copyright_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdCopyrightInformation, 0, _dev.Timeout, + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.HddvdCopyrightInformation, + 0, + _dev.Timeout, out _); if(!sense) @@ -737,9 +865,9 @@ partial class Dump break; - #endregion HD DVD-ROM +#endregion HD DVD-ROM - #region All Blu-ray +#region All Blu-ray case MediaType.BDR: case MediaType.BDRE: @@ -749,8 +877,15 @@ partial class Dump case MediaType.UHDBD: _dumpLog.WriteLine(Localization.Core.Reading_Disc_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.DiscInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.DiscInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -775,19 +910,26 @@ partial class Dump }*/ break; - #endregion All Blu-ray +#endregion All Blu-ray } switch(dskType) { - #region BD-ROM only +#region BD-ROM only case MediaType.BDROM: case MediaType.UHDBD: _dumpLog.WriteLine(Localization.Core.Reading_Burst_Cutting_Area); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdBurstCuttingArea, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdBurstCuttingArea, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -798,9 +940,9 @@ partial class Dump break; - #endregion BD-ROM only +#endregion BD-ROM only - #region Writable Blu-ray only +#region Writable Blu-ray only case MediaType.BDR: case MediaType.BDRE: @@ -808,8 +950,15 @@ partial class Dump case MediaType.BDREXL: _dumpLog.WriteLine(Localization.Core.Reading_Disc_Definition_Structure); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdDds, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -820,8 +969,15 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_Spare_Area_Information); - sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout, out _); + sense = _dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdSpareAreaInformation, + 0, + _dev.Timeout, + out _); if(!sense) { @@ -832,7 +988,7 @@ partial class Dump break; - #endregion Writable Blu-ray only +#endregion Writable Blu-ray only } if(isXbox) diff --git a/Aaru.Core/Devices/Dumping/Metadata.cs b/Aaru.Core/Devices/Dumping/Metadata.cs index 55ad16a82..dc5abb11d 100644 --- a/Aaru.Core/Devices/Dumping/Metadata.cs +++ b/Aaru.Core/Devices/Dumping/Metadata.cs @@ -93,8 +93,7 @@ partial class Dump Metadata sidecar = _sidecarClass.Create(); _sidecarStopwatch.Stop(); - if(_aborted) - return; + if(_aborted) return; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds; @@ -102,9 +101,9 @@ partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); if(_preSidecar != null) { @@ -130,8 +129,8 @@ partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, filesystem.start); } @@ -143,13 +142,12 @@ partial class Dump sidecar.OpticalDiscs[0].Sessions = (uint)sessions; sidecar.OpticalDiscs[0].Layers = layers; - if(discOffset.HasValue) - sidecar.OpticalDiscs[0].Offset = (int)(discOffset / 4); + if(discOffset.HasValue) sidecar.OpticalDiscs[0].Offset = (int)(discOffset / 4); if(mediaTags != null) { - foreach(KeyValuePair tag in mediaTags.Where(tag => _outputPlugin.SupportedMediaTags. - Contains(tag.Key))) + foreach(KeyValuePair tag in + mediaTags.Where(tag => _outputPlugin.SupportedMediaTags.Contains(tag.Key))) AddMediaTagToSidecar(_outputPath, tag.Key, tag.Value, ref sidecar); } @@ -157,10 +155,13 @@ partial class Dump var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 9b217918f..d55b1b666 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -92,16 +92,15 @@ partial class Dump if(!sense && !_dev.Error && Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); - if(decMode.HasValue) - scsiMediumType = (byte)(decMode?.Header.MediumType ?? default(MediumTypes)); + if(decMode.HasValue) scsiMediumType = (byte)(decMode?.Header.MediumType ?? default(MediumTypes)); if(blockSize != 2048) { - _dumpLog.WriteLine(Localization.Core. - MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); + _dumpLog.WriteLine(Localization.Core + .MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); - StoppingErrorMessage?.Invoke(Localization.Core. - MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); + StoppingErrorMessage?.Invoke(Localization.Core + .MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); return; } @@ -121,7 +120,8 @@ partial class Dump blocks++; UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - blocks, blockSize, + blocks, + blockSize, ByteSize.FromBytes(blocks * blockSize).ToString("0.000"))); } @@ -146,7 +146,8 @@ partial class Dump return; } - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead)); @@ -169,18 +170,15 @@ partial class Dump sense = _dev.MiniDiscGetType(out cmdBuf, out _, _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTags.Add(MediaTagType.MiniDiscType, cmdBuf); + if(!sense && !_dev.Error) mediaTags.Add(MediaTagType.MiniDiscType, cmdBuf); sense = _dev.MiniDiscD5(out cmdBuf, out _, _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTags.Add(MediaTagType.MiniDiscD5, cmdBuf); + if(!sense && !_dev.Error) mediaTags.Add(MediaTagType.MiniDiscD5, cmdBuf); sense = _dev.MiniDiscReadDataTOC(out cmdBuf, out _, _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTags.Add(MediaTagType.MiniDiscDTOC, cmdBuf); + if(!sense && !_dev.Error) mediaTags.Add(MediaTagType.MiniDiscDTOC, cmdBuf); var utocMs = new MemoryStream(); @@ -188,14 +186,12 @@ partial class Dump { sense = _dev.MiniDiscReadUserTOC(out cmdBuf, out _, i, _dev.Timeout, out _); - if(sense || _dev.Error) - break; + if(sense || _dev.Error) break; utocMs.Write(cmdBuf, 0, 2336); } - if(utocMs.Length > 0) - mediaTags.Add(MediaTagType.MiniDiscUTOC, utocMs.ToArray()); + if(utocMs.Length > 0) mediaTags.Add(MediaTagType.MiniDiscUTOC, utocMs.ToArray()); ret = true; @@ -225,7 +221,12 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); _dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead); - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); @@ -259,21 +260,24 @@ partial class Dump { Modes.ModePage_04? rigidPage = Modes.DecodeModePage_04(page.PageResponse); - if(!rigidPage.HasValue || setGeometry) - continue; + if(!rigidPage.HasValue || setGeometry) continue; - _dumpLog. - WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - rigidPage.Value.Cylinders, rigidPage.Value.Heads, - (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); + _dumpLog.WriteLine(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + rigidPage.Value.Cylinders, + rigidPage.Value.Heads, + (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); - UpdateStatus?. - Invoke(string. - Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - rigidPage.Value.Cylinders, rigidPage.Value.Heads, - (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + rigidPage.Value.Cylinders, + rigidPage.Value.Heads, + (uint)(blocks / + (rigidPage.Value.Cylinders * + rigidPage.Value.Heads)))); - outputFormat.SetGeometry(rigidPage.Value.Cylinders, rigidPage.Value.Heads, + outputFormat.SetGeometry(rigidPage.Value.Cylinders, + rigidPage.Value.Heads, (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); setGeometry = true; @@ -284,21 +288,22 @@ partial class Dump { Modes.ModePage_05? flexiblePage = Modes.DecodeModePage_05(page.PageResponse); - if(!flexiblePage.HasValue) - continue; + if(!flexiblePage.HasValue) continue; - _dumpLog. - WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, - flexiblePage.Value.SectorsPerTrack); + _dumpLog.WriteLine(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, + flexiblePage.Value.SectorsPerTrack); - UpdateStatus?. - Invoke(string. - Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, - flexiblePage.Value.SectorsPerTrack)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, + flexiblePage.Value.SectorsPerTrack)); - outputFormat.SetGeometry(flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, + outputFormat.SetGeometry(flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, flexiblePage.Value.SectorsPerTrack); setGeometry = true; @@ -312,9 +317,19 @@ partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force); + ResumeSupport.Process(true, + _dev.IsRemovable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -363,22 +378,29 @@ partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); _speedStopwatch.Start(); - sense = _dev.Read6(out readBuffer, out _, (uint)i, blockSize, (byte)blocksToRead, _dev.Timeout, + + sense = _dev.Read6(out readBuffer, + out _, + (uint)i, + blockSize, + (byte)blocksToRead, + _dev.Timeout, out double cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -396,19 +418,16 @@ partial class Dump else { // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -424,8 +443,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -439,36 +457,41 @@ partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -494,8 +517,7 @@ partial class Dump sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, out double _); - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; _resume.BadBlocks.Remove(badSector); extents.Add(badSector); @@ -513,9 +535,9 @@ partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -530,8 +552,13 @@ partial class Dump { Modes.ModePage_01 pg; - sense = _dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); if(!sense) { @@ -540,7 +567,7 @@ partial class Dump if(dcMode6?.Pages != null) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -605,13 +632,13 @@ partial class Dump if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -635,23 +662,32 @@ partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badSector, pass)); + badSector, + pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badSector, pass)); + badSector, + pass)); } - sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, + sense = _dev.Read6(out readBuffer, + out _, + (uint)badSector, + blockSize, + 1, + _dev.Timeout, out double cmdDuration); totalDuration += cmdDuration; @@ -663,13 +699,13 @@ partial class Dump outputFormat.WriteSector(readBuffer, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); } - else if(runningPersistent) - outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -678,8 +714,7 @@ partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -705,12 +740,11 @@ partial class Dump EndProgress?.Invoke(); } - #endregion Error handling +#endregion Error handling _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -729,8 +763,7 @@ partial class Dump outputFormat.ErrorMessage); } - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -789,17 +822,17 @@ partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); if(_preSidecar != null) { @@ -823,13 +856,15 @@ partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) { UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1, - filesystem.type, filesystem.start)); + filesystem.type, + filesystem.start)); - _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, + _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, + filesystem.type, filesystem.start); } } @@ -857,22 +892,23 @@ partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; - if(_dev.IsRemovable) - sidecar.BlockMedias[0].DumpHardware = _resume.Tries; + if(_dev.IsRemovable) sidecar.BlockMedias[0].DumpHardware = _resume.Tries; UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar); var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -880,18 +916,18 @@ partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index d89bdc90d..e8018b0c4 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -92,7 +92,8 @@ public partial class Dump blocks++; UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - blocks, blockSize, + blocks, + blockSize, ByteSize.FromBytes(blocks * blockSize).ToString("0.000"))); if(blocks == 0) @@ -103,7 +104,8 @@ public partial class Dump return; } - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead)); @@ -125,7 +127,12 @@ public partial class Dump bool ret; - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); @@ -150,9 +157,19 @@ public partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force); + ResumeSupport.Process(true, + _dev.IsRemovable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -161,8 +178,7 @@ public partial class Dump return; } - if(_resume.NextBlock > 0) - _dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock); + if(_resume.NextBlock > 0) _dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock); if(_createGraph) { @@ -199,22 +215,36 @@ public partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + blocks); _speedStopwatch.Start(); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, - blocksToRead, false, _dev.Timeout, out double cmdDuration); + + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)i, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out double cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -234,19 +264,16 @@ public partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -262,8 +289,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -277,36 +303,41 @@ public partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -330,8 +361,20 @@ public partial class Dump PulseProgress?.Invoke(string.Format(Localization.Core.Trimming_sector_0, badSector)); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, - blockSize, 0, 1, false, _dev.Timeout, out double _); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)badSector, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out double _); if(sense || _dev.Error) { @@ -353,9 +396,9 @@ public partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -370,17 +413,26 @@ public partial class Dump { Modes.ModePage_01 pg; - sense = _dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); Modes.DecodedMode? dcMode6 = null; - if(!sense) - dcMode6 = Modes.DecodeMode6(readBuffer, _dev.ScsiType); + if(!sense) dcMode6 = Modes.DecodeMode6(readBuffer, _dev.ScsiType); if(sense || dcMode6 is null) { - sense = _dev.ModeSense10(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); if(!sense) { @@ -389,7 +441,7 @@ public partial class Dump if(dcMode10.HasValue) { foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -399,7 +451,7 @@ public partial class Dump if(dcMode6.HasValue) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -464,13 +516,13 @@ public partial class Dump if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -493,29 +545,44 @@ public partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badSector, pass)); + badSector, + pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badSector, pass)); + badSector, + pass)); } - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, - blockSize, 0, 1, false, _dev.Timeout, out double cmdDuration); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)badSector, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out double cmdDuration); totalDuration += cmdDuration; - if(sense || _dev.Error) - _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf); + if(sense || _dev.Error) _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf); if(!sense && !_dev.Error) { @@ -524,13 +591,13 @@ public partial class Dump outputFormat.WriteSector(readBuffer, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); } - else if(runningPersistent) - outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -539,8 +606,7 @@ public partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -566,12 +632,11 @@ public partial class Dump EndProgress?.Invoke(); } - #endregion Error handling +#endregion Error handling _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -590,8 +655,7 @@ public partial class Dump outputFormat.SetDumpHardware(_resume.Tries); - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -650,17 +714,17 @@ public partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); if(_preSidecar != null) { @@ -684,13 +748,15 @@ public partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) { UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1, - filesystem.type, filesystem.start)); + filesystem.type, + filesystem.start)); - _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, + _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, + filesystem.type, filesystem.start); } } @@ -706,22 +772,23 @@ public partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; - if(_dev.IsRemovable) - sidecar.BlockMedias[0].DumpHardware = _resume.Tries; + if(_dev.IsRemovable) sidecar.BlockMedias[0].DumpHardware = _resume.Tries; UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar); var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -729,18 +796,18 @@ public partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs index 275ad9b0d..27af9692e 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs @@ -52,11 +52,11 @@ public partial class Dump !_outputPlugin.SupportedMediaTypes.Contains(MediaType.MemoryStickProDuo) && !_outputPlugin.SupportedMediaTypes.Contains(MediaType.UMD)) { - _dumpLog.WriteLine(Localization.Core. - Selected_output_format_does_not_support_MemoryStick_Duo_or_UMD_cannot_dump); + _dumpLog.WriteLine(Localization.Core + .Selected_output_format_does_not_support_MemoryStick_Duo_or_UMD_cannot_dump); - StoppingErrorMessage?.Invoke(Localization.Core. - Selected_output_format_does_not_support_MemoryStick_Duo_or_UMD_cannot_dump); + StoppingErrorMessage?.Invoke(Localization.Core + .Selected_output_format_does_not_support_MemoryStick_Duo_or_UMD_cannot_dump); return; } @@ -64,7 +64,12 @@ public partial class Dump UpdateStatus?.Invoke(Localization.Core.Checking_if_media_is_UMD_or_MemoryStick); _dumpLog.WriteLine(Localization.Core.Checking_if_media_is_UMD_or_MemoryStick); - bool sense = _dev.ModeSense6(out byte[] buffer, out _, false, ScsiModeSensePageControl.Current, 0, _dev.Timeout, + bool sense = _dev.ModeSense6(out byte[] buffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0, + _dev.Timeout, out _); if(sense) @@ -122,7 +127,19 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_root_directory_in_sector_0, rootStart)); _dumpLog.WriteLine(Localization.Core.Reading_root_directory_in_sector_0, rootStart); - sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, rootStart, 512, 0, 1, false, _dev.Timeout, + sense = _dev.Read12(out buffer, + out _, + 0, + false, + true, + false, + false, + rootStart, + 512, + 0, + 1, + false, + _dev.Timeout, out _); if(sense) @@ -143,7 +160,8 @@ public partial class Dump return; } - UpdateStatus?.Invoke(string.Format(Localization.Core.FAT_starts_at_sector_0_and_runs_for_1_sectors, fatStart, + UpdateStatus?.Invoke(string.Format(Localization.Core.FAT_starts_at_sector_0_and_runs_for_1_sectors, + fatStart, sectorsPerFat)); _dumpLog.WriteLine(Localization.Core.FAT_starts_at_sector_0_and_runs_for_1_sectors, fatStart, sectorsPerFat); @@ -159,11 +177,22 @@ public partial class Dump { uint transfer = 64; - if(transfer + position > sectorsPerFat) - transfer = sectorsPerFat - position; + if(transfer + position > sectorsPerFat) transfer = sectorsPerFat - position; - sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, position + fatStart, 512, 0, transfer, - false, _dev.Timeout, out _); + sense = _dev.Read12(out buffer, + out _, + 0, + false, + true, + false, + false, + position + fatStart, + 512, + 0, + transfer, + false, + _dev.Timeout, + out _); if(sense) { @@ -194,8 +223,7 @@ public partial class Dump continue; } - if(nextCluster == 0xFFFF) - break; + if(nextCluster == 0xFFFF) break; DumpMs(); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 6155129ba..8af196178 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -75,8 +75,20 @@ public partial class Dump return; } - bool sense = _dev.Read12(out byte[] readBuffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false, - _dev.Timeout, out _); + bool sense = _dev.Read12(out byte[] readBuffer, + out _, + 0, + false, + true, + false, + false, + 0, + 512, + 0, + 1, + false, + _dev.Timeout, + out _); if(sense) { @@ -95,8 +107,20 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_root_directory_in_sector_0, rootStart)); _dumpLog.WriteLine(Localization.Core.Reading_root_directory_in_sector_0, rootStart); - sense = _dev.Read12(out readBuffer, out _, 0, false, true, false, false, rootStart, 512, 0, 1, false, - _dev.Timeout, out _); + sense = _dev.Read12(out readBuffer, + out _, + 0, + false, + true, + false, + false, + rootStart, + 512, + 0, + 1, + false, + _dev.Timeout, + out _); if(sense) { @@ -111,10 +135,12 @@ public partial class Dump string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim(); UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - blocks, blockSize, + blocks, + blockSize, ByteSize.FromBytes(blocks * blockSize).ToString("0.000"))); - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead)); @@ -133,7 +159,12 @@ public partial class Dump bool ret; - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010); @@ -172,9 +203,19 @@ public partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force); + ResumeSupport.Process(true, + _dev.IsRemovable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -183,8 +224,7 @@ public partial class Dump return; } - if(_resume.NextBlock > 0) - _dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock); + if(_resume.NextBlock > 0) _dumpLog.WriteLine(Localization.Core.Resuming_from_block_0, _resume.NextBlock); if(_createGraph) { @@ -221,22 +261,36 @@ public partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); _speedStopwatch.Start(); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(umdStart + i * 4), - 512, 0, blocksToRead * 4, false, _dev.Timeout, out double cmdDuration); + + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(umdStart + i * 4), + 512, + 0, + blocksToRead * 4, + false, + _dev.Timeout, + out double cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -257,18 +311,15 @@ public partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data outputOptical.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -284,8 +335,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -298,36 +348,41 @@ public partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -349,8 +404,20 @@ public partial class Dump PulseProgress?.Invoke(string.Format(Localization.Core.Trimming_sector_0, badSector)); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, - (uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout, out double _); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(umdStart + badSector * 4), + 512, + 0, + 4, + false, + _dev.Timeout, + out double _); if(sense || _dev.Error) { @@ -372,9 +439,9 @@ public partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -389,8 +456,13 @@ public partial class Dump { Modes.ModePage_01 pg; - sense = _dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); if(!sense) { @@ -399,7 +471,7 @@ public partial class Dump if(dcMode6.HasValue) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -463,13 +535,13 @@ public partial class Dump if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -492,30 +564,44 @@ public partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badSector, pass)); + badSector, + pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badSector, pass)); + badSector, + pass)); } - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, - (uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout, + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + (uint)(umdStart + badSector * 4), + 512, + 0, + 4, + false, + _dev.Timeout, out double cmdDuration); totalDuration += cmdDuration; - if(sense || _dev.Error) - _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf); + if(sense || _dev.Error) _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf); if(!sense && !_dev.Error) { @@ -524,13 +610,13 @@ public partial class Dump outputOptical.WriteSector(readBuffer, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); } - else if(runningPersistent) - outputOptical.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -539,8 +625,7 @@ public partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -566,12 +651,11 @@ public partial class Dump AaruConsole.WriteLine(); } - #endregion Error handling +#endregion Error handling _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -591,8 +675,7 @@ public partial class Dump outputOptical.SetDumpHardware(_resume.Tries); - if(_preSidecar != null) - outputOptical.SetMetadata(_preSidecar); + if(_preSidecar != null) outputOptical.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -613,23 +696,22 @@ public partial class Dump double totalChkDuration = 0; - if(_metadata) - WriteOpticalSidecar(blockSize, blocks, dskType, null, null, 1, out totalChkDuration, null); + if(_metadata) WriteOpticalSidecar(blockSize, blocks, dskType, null, null, 1, out totalChkDuration, null); UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/ResumeSupport.cs b/Aaru.Core/Devices/Dumping/ResumeSupport.cs index 67e24bf38..f3be1cf0e 100644 --- a/Aaru.Core/Devices/Dumping/ResumeSupport.cs +++ b/Aaru.Core/Devices/Dumping/ResumeSupport.cs @@ -68,8 +68,7 @@ static class ResumeSupport ref ExtentsULong extents, string firmware, bool @private, bool force, bool isTape = false) { - if(@private) - serial = null; + if(@private) serial = null; if(resume != null) { @@ -88,19 +87,20 @@ static class ResumeSupport { if(resume.Removable) { - throw new InvalidOperationException(Localization.Core. - Resume_specifies_removable_but_device_is_non_removable); + throw new InvalidOperationException(Localization.Core + .Resume_specifies_removable_but_device_is_non_removable); } - throw new InvalidOperationException(Localization.Core. - Resume_specifies_non_removable_but_device_is_removable); + throw new InvalidOperationException(Localization.Core + .Resume_specifies_non_removable_but_device_is_removable); } if(!isTape && resume.LastBlock != blocks - 1 && !force) { - throw new - InvalidOperationException(string.Format(Localization.Core.Resume_file_different_number_of_blocks_not_continuing, - resume.LastBlock + 1, blocks)); + throw new InvalidOperationException(string.Format(Localization.Core + .Resume_file_different_number_of_blocks_not_continuing, + resume.LastBlock + 1, + blocks)); } foreach(DumpHardware oldTry in resume.Tries) @@ -109,34 +109,34 @@ static class ResumeSupport { if(oldTry.Manufacturer != manufacturer) { - throw new - InvalidOperationException(string. - Format(Localization.Core.Resume_file_different_manufacturer_not_continuing, - oldTry.Manufacturer, manufacturer)); + throw new InvalidOperationException(string.Format(Localization.Core + .Resume_file_different_manufacturer_not_continuing, + oldTry.Manufacturer, + manufacturer)); } if(oldTry.Model != model) { - throw new - InvalidOperationException(string. - Format(Localization.Core.Resume_file_different_model_not_continuing, - oldTry.Model, model)); + throw new InvalidOperationException(string.Format(Localization.Core + .Resume_file_different_model_not_continuing, + oldTry.Model, + model)); } if(oldTry.Serial != serial) { - throw new - InvalidOperationException(string. - Format(Localization.Core.Resume_file_different_serial_number_not_continuing, - oldTry.Serial, serial)); + throw new InvalidOperationException(string.Format(Localization.Core + .Resume_file_different_serial_number_not_continuing, + oldTry.Serial, + serial)); } if(oldTry.Firmware != firmware) { - throw new - InvalidOperationException(string. - Format(Localization.Core.Resume_file_different_firmware_revision_not_continuing, - oldTry.Firmware, firmware)); + throw new InvalidOperationException(string.Format(Localization.Core + .Resume_file_different_firmware_revision_not_continuing, + oldTry.Firmware, + firmware)); } } @@ -161,8 +161,7 @@ static class ResumeSupport break; } - if(currentTry != null) - return; + if(currentTry != null) return; currentTry = new DumpHardware { diff --git a/Aaru.Core/Devices/Dumping/SCSI.cs b/Aaru.Core/Devices/Dumping/SCSI.cs index 0ccf77e52..3b1188197 100644 --- a/Aaru.Core/Devices/Dumping/SCSI.cs +++ b/Aaru.Core/Devices/Dumping/SCSI.cs @@ -61,19 +61,21 @@ public partial class Dump if(decSense.HasValue) { ErrorMessage?.Invoke(string.Format(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ)); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); // Just retry, for 5 times if(decSense.Value.ASC == 0x29) { resets++; - if(resets < 5) - goto deviceGotReset; + if(resets < 5) goto deviceGotReset; } switch(decSense.Value.ASC) @@ -88,19 +90,20 @@ public partial class Dump Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; decSense = Sense.Decode(senseBuf); if(decSense.HasValue) { ErrorMessage?.Invoke(string.Format(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ)); _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); } @@ -126,19 +129,20 @@ public partial class Dump Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; decSense = Sense.Decode(senseBuf); if(decSense.HasValue) { ErrorMessage?.Invoke(string.Format(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ)); _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); } @@ -147,9 +151,9 @@ public partial class Dump if(sense) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Error_testing_unit_was_ready_0, - Sense.PrettifySense(senseBuf))); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Error_testing_unit_was_ready_0, + Sense.PrettifySense(senseBuf))); return; } @@ -180,19 +184,20 @@ public partial class Dump Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; decSense = Sense.Decode(senseBuf); if(decSense.HasValue) { ErrorMessage?.Invoke(string.Format(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ)); _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, - decSense.Value.SenseKey, decSense.Value.ASC, + decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); } @@ -201,9 +206,9 @@ public partial class Dump if(sense) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Error_testing_unit_was_ready_0, - Sense.PrettifySense(senseBuf))); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Error_testing_unit_was_ready_0, + Sense.PrettifySense(senseBuf))); return; } @@ -242,8 +247,8 @@ public partial class Dump Ssc(); else { - StoppingErrorMessage?.Invoke(Localization.Core. - The_specified_image_format_cannot_represent_streaming_tapes); + StoppingErrorMessage?.Invoke(Localization.Core + .The_specified_image_format_cannot_represent_streaming_tapes); } return; @@ -252,8 +257,8 @@ public partial class Dump Mmc(); else { - StoppingErrorMessage?.Invoke(Localization.Core. - The_specified_image_format_cannot_represent_optical_discs); + StoppingErrorMessage?.Invoke(Localization.Core + .The_specified_image_format_cannot_represent_optical_discs); } return; diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 76da1c6e9..4ebde21c3 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -80,7 +80,9 @@ partial class Dump if(decSense.HasValue && decSense?.SenseKey != SenseKeys.NoSense) { - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); StoppingErrorMessage?.Invoke(Localization.Core.Drive_has_status_error_please_correct_Sense_follows + @@ -124,7 +126,9 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); return; @@ -150,7 +154,9 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Could_not_get_position_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); return; @@ -175,7 +181,9 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); return; @@ -201,7 +209,9 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); return; @@ -219,7 +229,9 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC, + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense?.SenseKey, + decSense?.ASC, decSense?.ASCQ); return; @@ -228,8 +240,8 @@ partial class Dump // Still not in partition 0!!!? if(cmdBuf[1] != 0) { - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_could_not_rewind_to_partition_0_but_no_error_occurred); + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_could_not_rewind_to_partition_0_but_no_error_occurred); _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_to_partition_0_but_no_error_occurred); @@ -247,41 +259,64 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_10); - sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, + 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); + sense = _dev.ModeSense10(out cmdBuf, + out senseBuf, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out duration); } Modes.DecodedMode? decMode = null; if(!sense && !_dev.Error) { - if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); + if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); } UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); - sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, + sense = _dev.ModeSense6(out cmdBuf, + out senseBuf, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, out duration); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, + sense = _dev.ModeSense6(out cmdBuf, + out senseBuf, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, out duration); } - if(sense || _dev.Error) - sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); + if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(!sense && !_dev.Error) { - if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); + if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); } // TODO: Check partitions page @@ -303,19 +338,22 @@ partial class Dump { BlockLimits.BlockLimitsData? blockLimits = BlockLimits.Decode(cmdBuf); - if(blockLimits?.minBlockLen > blockSize) - blockSize = blockLimits?.minBlockLen ?? 0; + if(blockLimits?.minBlockLen > blockSize) blockSize = blockLimits?.minBlockLen ?? 0; } - if(blockSize == 0) - blockSize = 1; + if(blockSize == 0) blockSize = 1; - dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model, - scsiMediumTypeTape, scsiDensityCodeTape, blocks, blockSize, - _dev.IsUsb, false); + dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, + _dev.Manufacturer, + _dev.Model, + scsiMediumTypeTape, + scsiDensityCodeTape, + blocks, + blockSize, + _dev.IsUsb, + false); - if(dskType == MediaType.Unknown) - dskType = MediaType.UnknownTape; + if(dskType == MediaType.Unknown) dskType = MediaType.UnknownTape; UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_device_type_0, _dev.ScsiType)); UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_medium_type_0, scsiMediumTypeTape)); @@ -337,7 +375,13 @@ partial class Dump firstRead: - sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout, + sense = _dev.Read6(out cmdBuf, + out senseBuf, + false, + fixedLen, + transferLen, + blockSize, + _dev.Timeout, out duration); if(sense) @@ -364,15 +408,17 @@ partial class Dump if(!eom) { - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_could_not_return_back_Sense_follows + + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_could_not_return_back_Sense_follows + Environment.NewLine + decSense.Value.Description); _dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -381,8 +427,14 @@ partial class Dump fixedLen = true; transferLen = 1; - sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, - _dev.Timeout, out duration); + sense = _dev.Read6(out cmdBuf, + out senseBuf, + false, + fixedLen, + transferLen, + blockSize, + _dev.Timeout, + out duration); if(sense) { @@ -394,8 +446,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -412,8 +466,7 @@ partial class Dump { valid = decSense.Value.Descriptor.Value.Descriptors.TryGetValue(0, out byte[] desc00); - if(valid) - information = (uint)Sense.DecodeDescriptor00(desc00); + if(valid) information = (uint)Sense.DecodeDescriptor00(desc00); if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] desc04)) Sense.DecodeDescriptor04(desc04, out _, out _, out ili); @@ -426,14 +479,19 @@ partial class Dump transferLen = blockSize; - UpdateStatus?. - Invoke(string.Format(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, - blockSize, currentBlock)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Blocksize_changed_to_0_bytes_at_block_1, + blockSize, + currentBlock)); - _dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, blockSize, + _dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, + blockSize, currentBlock); - sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, + sense = _dev.Space(out senseBuf, + SscSpaceCodes.LogicalBlock, + -1, + _dev.Timeout, out duration); totalDuration += duration; @@ -442,15 +500,17 @@ partial class Dump { decSense = Sense.Decode(senseBuf); - StoppingErrorMessage?.Invoke(Localization.Core. - Drive_could_not_go_back_one_block_Sense_follows + + StoppingErrorMessage?.Invoke(Localization.Core + .Drive_could_not_go_back_one_block_Sense_follows + Environment.NewLine + decSense.Value.Description); _dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -464,8 +524,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -476,8 +538,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -511,8 +575,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -521,9 +587,20 @@ partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force, true); + ResumeSupport.Process(true, + _dev.IsRemovable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force, + true); if(currentTry == null || extents == null) { @@ -593,20 +670,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); canLocateLong = false; } @@ -618,20 +695,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); canLocateLong = false; } @@ -641,20 +718,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); canLocateLong = false; } @@ -671,20 +748,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Could_not_check_current_position_unable_to_resume_Dumping_from_the_start); canLocate = false; } @@ -696,20 +773,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start); canLocate = false; } @@ -719,20 +796,20 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); return; } - _dumpLog.WriteLine(Localization.Core. - Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); + _dumpLog.WriteLine(Localization.Core + .Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); - ErrorMessage?.Invoke(Localization.Core. - Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); + ErrorMessage?.Invoke(Localization.Core + .Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start); canLocate = false; } @@ -741,11 +818,11 @@ partial class Dump { if(!_force) { - _dumpLog.WriteLine(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + _dumpLog.WriteLine(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); - StoppingErrorMessage?.Invoke(Localization.Core. - Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); + StoppingErrorMessage?.Invoke(Localization.Core + .Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force); return; } @@ -780,8 +857,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -846,11 +925,9 @@ partial class Dump outputTape?.TapePartitions.Max(g => g.LastBlock)); } - if(mode6Data != null) - outputTape.WriteMediaTag(mode6Data, MediaTagType.SCSI_MODESENSE_6); + if(mode6Data != null) outputTape.WriteMediaTag(mode6Data, MediaTagType.SCSI_MODESENSE_6); - if(mode10Data != null) - outputTape.WriteMediaTag(mode10Data, MediaTagType.SCSI_MODESENSE_10); + if(mode10Data != null) outputTape.WriteMediaTag(mode10Data, MediaTagType.SCSI_MODESENSE_10); ulong currentSpeedSize = 0; double imageWriteDuration = 0; @@ -877,8 +954,7 @@ partial class Dump currentTapeFile.LastBlock = currentBlock - 1; - if(currentTapeFile.LastBlock > currentTapeFile.FirstBlock) - outputTape.AddFile(currentTapeFile); + if(currentTapeFile.LastBlock > currentTapeFile.FirstBlock) outputTape.AddFile(currentTapeFile); currentTapePartition.LastBlock = currentBlock - 1; outputTape.AddPartition(currentTapePartition); @@ -910,18 +986,25 @@ partial class Dump continue; } - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - PulseProgress?.Invoke(string.Format(Localization.Core.Reading_block_0_1, currentBlock, + PulseProgress?.Invoke(string.Format(Localization.Core.Reading_block_0_1, + currentBlock, ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize())); _speedStopwatch.Start(); - sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout, + + sense = _dev.Read6(out cmdBuf, + out senseBuf, + false, + fixedLen, + transferLen, + blockSize, + _dev.Timeout, out duration); + _speedStopwatch.Stop(); totalDuration += duration; @@ -951,13 +1034,14 @@ partial class Dump { blockSize = (uint)((int)blockSize - BitConverter.ToInt32(BitConverter.GetBytes(information), 0)); - if(!fixedLen) - transferLen = blockSize; + if(!fixedLen) transferLen = blockSize; UpdateStatus?.Invoke(string.Format(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, - blockSize, currentBlock)); + blockSize, + currentBlock)); - _dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, blockSize, + _dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, + blockSize, currentBlock); sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration); @@ -975,8 +1059,10 @@ partial class Dump outputTape.Close(); _dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); return; } @@ -1032,7 +1118,8 @@ partial class Dump Partition = currentPartition }; - UpdateStatus?.Invoke(string.Format(Localization.Core.Changed_to_file_0_at_block_1, currentFile, + UpdateStatus?.Invoke(string.Format(Localization.Core.Changed_to_file_0_at_block_1, + currentFile, currentBlock)); _dumpLog.WriteLine(Localization.Core.Changed_to_file_0_at_block_1, currentFile, currentBlock); @@ -1042,9 +1129,9 @@ partial class Dump if(decSense is null) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_cannot_be_decoded_look_at_log_for_dump, - currentBlock)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Drive_could_not_read_block_0_Sense_cannot_be_decoded_look_at_log_for_dump, + currentBlock)); _dumpLog.WriteLine(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_bytes_follow, currentBlock)); @@ -1053,20 +1140,23 @@ partial class Dump } else { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_follow_1_2, - currentBlock, decSense.Value.SenseKey, decSense.Value.Description)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Drive_could_not_read_block_0_Sense_follow_1_2, + currentBlock, + decSense.Value.SenseKey, + decSense.Value.Description)); _dumpLog.WriteLine(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_follows, currentBlock)); - _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, - decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, + decSense.Value.SenseKey, + decSense.Value.ASC, + decSense.Value.ASCQ); } // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly // Write empty data _writeStopwatch.Restart(); @@ -1094,8 +1184,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || currentSpeedSize < 524288) - continue; + if(elapsed <= 0 || currentSpeedSize < 524288) continue; currentSpeed = currentSpeedSize / (1048576 * elapsed); currentSpeedSize = 0; @@ -1120,36 +1209,41 @@ partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0 && (canLocate || canLocateLong)) { @@ -1182,20 +1276,24 @@ partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badBlock, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badBlock, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badBlock, pass)); + badBlock, + pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badBlock, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badBlock, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badBlock, pass)); + badBlock, + pass)); } UpdateStatus?.Invoke(string.Format(Localization.Core.Positioning_tape_to_block_0, badBlock)); @@ -1223,8 +1321,8 @@ partial class Dump { _dumpLog.WriteLine(Localization.Core.Current_position_is_not_as_expected_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_continuing); continue; } @@ -1261,8 +1359,8 @@ partial class Dump { _dumpLog.WriteLine(Localization.Core.Current_position_is_not_as_expected_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Current_position_is_not_as_expected_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Current_position_is_not_as_expected_continuing); continue; } @@ -1278,7 +1376,13 @@ partial class Dump } } - sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout, + sense = _dev.Read6(out cmdBuf, + out senseBuf, + false, + fixedLen, + transferLen, + blockSize, + _dev.Timeout, out duration); totalDuration += duration; @@ -1289,13 +1393,13 @@ partial class Dump extents.Add(badBlock); outputTape.WriteSector(cmdBuf, badBlock); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badBlock, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock, pass); } - else if(runningPersistent) - outputTape.WriteSector(cmdBuf, badBlock); + else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -1304,8 +1408,7 @@ partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -1318,12 +1421,11 @@ partial class Dump EndProgress?.Invoke(); } - #endregion Error handling +#endregion Error handling _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Block_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Block_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -1343,8 +1445,7 @@ partial class Dump outputTape.ErrorMessage); } - if(_preSidecar != null) - outputTape.SetMetadata(_preSidecar); + if(_preSidecar != null) outputTape.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -1411,17 +1512,17 @@ partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); if(_preSidecar != null) { @@ -1445,13 +1546,15 @@ partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) { UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1, - filesystem.type, filesystem.start)); + filesystem.type, + filesystem.start)); - _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, + _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, + filesystem.type, filesystem.start); } } @@ -1480,22 +1583,23 @@ partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; - if(_dev.IsRemovable) - sidecar.BlockMedias[0].DumpHardware = _resume.Tries; + if(_dev.IsRemovable) sidecar.BlockMedias[0].DumpHardware = _resume.Tries; UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar); var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -1503,18 +1607,18 @@ partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs index 2f164ab02..87fe6e462 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs @@ -34,7 +34,6 @@ using Aaru.Core.Logging; using Aaru.Decryption.DVD; using Humanizer; using Humanizer.Bytes; -using DVDDecryption = Aaru.Decryption.DVD.Dump; // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable InlineOutVariableDeclaration @@ -77,11 +76,12 @@ partial class Dump InitProgress?.Invoke(); if(scsiReader.HldtstReadRaw && _resume.NextBlock > 0) + // The HL-DT-ST buffer is stored and read in 96-sector chunks. If we start to read at an LBA which is // not modulo 96, the data will not be correctly fetched. Therefore, we begin every resume read with // filling the buffer at a known offset. // TODO: This is very ugly and there probably exist a more elegant way to solve this issue. - scsiReader.ReadBlock(out _, _resume.NextBlock - (_resume.NextBlock % 96) + 1, out _, out _, out _); + scsiReader.ReadBlock(out _, _resume.NextBlock - _resume.NextBlock % 96 + 1, out _, out _, out _); for(ulong i = _resume.NextBlock; i < blocks; i += blocksToRead) { @@ -94,18 +94,18 @@ partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _); totalDuration += cmdDuration; @@ -118,18 +118,20 @@ partial class Dump _writeStopwatch.Restart(); byte[] tmpBuf; - byte[] cmi = new byte[blocksToRead]; + var cmi = new byte[blocksToRead]; for(uint j = 0; j < blocksToRead; j++) { - byte[] key = buffer.Skip((int)((2064 * j) + 7)).Take(5).ToArray(); + byte[] key = buffer.Skip((int)(2064 * j + 7)).Take(5).ToArray(); if(key.All(static k => k == 0)) { outputFormat.WriteSectorTag(new byte[] - { - 0, 0, 0, 0, 0 - }, i + j, SectorTagType.DvdTitleKeyDecrypted); + { + 0, 0, 0, 0, 0 + }, + i + j, + SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(i + j); @@ -140,8 +142,7 @@ partial class Dump outputFormat.WriteSectorTag(tmpBuf, i + j, SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys?.Remove(i + j); - if(_storeEncrypted) - continue; + if(_storeEncrypted) continue; cmi[j] = buffer[2064 * j + 6]; } @@ -150,12 +151,16 @@ partial class Dump if(!_storeEncrypted) { ErrorNumber errno = - outputFormat.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdTitleKeyDecrypted, + outputFormat.ReadSectorsTag(i, + blocksToRead, + SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); if(errno != ErrorNumber.NoError) + { ErrorMessage?.Invoke(string.Format(Localization.Core.Error_retrieving_title_key_for_sector_0, i)); + } else buffer = CSS.DecryptSectorLong(buffer, titleKey, cmi, blocksToRead); } @@ -169,19 +174,16 @@ partial class Dump else { // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -197,8 +199,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index 32a3d967e..f6e0445f0 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -89,18 +89,18 @@ partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (uint)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (uint)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); _speedStopwatch.Start(); sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _); @@ -113,8 +113,7 @@ partial class Dump { for(ulong j = 0; j < blocksToRead; j++) { - if(_aborted) - break; + if(_aborted) break; if(!_resume.MissingTitleKeys.Contains(i + j)) @@ -123,20 +122,25 @@ partial class Dump byte[] tmpBuf; - bool tmpSense = dvdDecrypt.ReadTitleKey(out tmpBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm, - i + j, _dev.Timeout, out _); + bool tmpSense = dvdDecrypt.ReadTitleKey(out tmpBuf, + out _, + DvdCssKeyClass.DvdCssCppmOrCprm, + i + j, + _dev.Timeout, + out _); - if(tmpSense) - continue; + if(tmpSense) continue; CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(tmpBuf, dvdDecrypt.BusKey); if(titleKey.HasValue) { outputFormat.WriteSectorTag(new[] - { - titleKey.Value.CMI - }, i + j, SectorTagType.DvdSectorCmi); + { + titleKey.Value.CMI + }, + i + j, + SectorTagType.DvdSectorCmi); } else continue; @@ -146,14 +150,18 @@ partial class Dump if(titleKey.Value.Key.All(static k => k == 0)) { outputFormat.WriteSectorTag(new byte[] - { - 0, 0, 0, 0, 0 - }, i + j, SectorTagType.DvdSectorTitleKey); + { + 0, 0, 0, 0, 0 + }, + i + j, + SectorTagType.DvdSectorTitleKey); outputFormat.WriteSectorTag(new byte[] - { - 0, 0, 0, 0, 0 - }, i + j, SectorTagType.DvdTitleKeyDecrypted); + { + 0, 0, 0, 0, 0 + }, + i + j, + SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys.Remove(i + j); @@ -178,13 +186,16 @@ partial class Dump ErrorMessage?.Invoke(string.Format(Localization.Core.Error_retrieving_CMI_for_sector_0, i)); else { - errno = outputFormat.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdTitleKeyDecrypted, + errno = outputFormat.ReadSectorsTag(i, + blocksToRead, + SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); if(errno != ErrorNumber.NoError) { - ErrorMessage?. - Invoke(string.Format(Localization.Core.Error_retrieving_title_key_for_sector_0, i)); + ErrorMessage?.Invoke(string.Format(Localization.Core + .Error_retrieving_title_key_for_sector_0, + i)); } else buffer = CSS.DecryptSector(buffer, titleKey, cmi, blocksToRead, blockSize); @@ -209,29 +220,26 @@ partial class Dump _resume.NextBlock++; _aborted = true; - _dumpLog?.WriteLine(Localization.Core. - INSITE_floptical_drives_get_crazy_on_the_SCSI_bus_when_an_error_is_found); + _dumpLog?.WriteLine(Localization.Core + .INSITE_floptical_drives_get_crazy_on_the_SCSI_bus_when_an_error_is_found); - UpdateStatus?.Invoke(Localization.Core. - INSITE_floptical_drives_get_crazy_on_the_SCSI_bus_when_an_error_is_found); + UpdateStatus?.Invoke(Localization.Core + .INSITE_floptical_drives_get_crazy_on_the_SCSI_bus_when_an_error_is_found); continue; } // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -247,8 +255,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index 1cf68d6a5..80c9d31ee 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -111,19 +111,15 @@ partial class Dump { mediaTags = new Dictionary(); - if(_dev.IsUsb && _dev.UsbDescriptors != null) - mediaTags.Add(MediaTagType.USB_Descriptors, null); + if(_dev.IsUsb && _dev.UsbDescriptors != null) mediaTags.Add(MediaTagType.USB_Descriptors, null); - if(_dev.Type == DeviceType.ATAPI) - mediaTags.Add(MediaTagType.ATAPI_IDENTIFY, null); + if(_dev.Type == DeviceType.ATAPI) mediaTags.Add(MediaTagType.ATAPI_IDENTIFY, null); - if(_dev.IsPcmcia && _dev.Cis != null) - mediaTags.Add(MediaTagType.PCMCIA_CIS, null); + if(_dev.IsPcmcia && _dev.Cis != null) mediaTags.Add(MediaTagType.PCMCIA_CIS, null); sense = _dev.ScsiInquiry(out byte[] cmdBuf, out _); - if(_private) - cmdBuf = DeviceReport.ClearInquiry(cmdBuf); + if(_private) cmdBuf = DeviceReport.ClearInquiry(cmdBuf); mediaTags.Add(MediaTagType.SCSI_INQUIRY, cmdBuf); @@ -132,13 +128,27 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_10); UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_10); - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, - 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0xFF, + 5, + out _); if(!sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0x00, 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); } if(!sense && !_dev.Error) @@ -153,17 +163,28 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_6); UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, out _); } - if(sense || _dev.Error) - sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); + if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); if(!sense && !_dev.Error) { @@ -192,9 +213,15 @@ partial class Dump if(dskType == MediaType.Unknown) { - dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model, - scsiMediumType, scsiDensityCode, blocks + 1, blockSize, - _dev.IsUsb, opticalDisc); + dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, + _dev.Manufacturer, + _dev.Model, + scsiMediumType, + scsiDensityCode, + blocks + 1, + blockSize, + _dev.IsUsb, + opticalDisc); } if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) @@ -206,11 +233,11 @@ partial class Dump // SonicStage changes the device mode, so it is no longer a mass storage device, and can only read // tracks written by that same application ID (changes between computers). case MediaType.MD: - _dumpLog.WriteLine(Localization.Core. - MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); + _dumpLog.WriteLine(Localization.Core + .MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); - StoppingErrorMessage?.Invoke(Localization.Core. - MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); + StoppingErrorMessage?.Invoke(Localization.Core + .MiniDisc_albums_NetMD_discs_or_user_written_audio_MiniDisc_cannot_be_dumped); return; case MediaType.Unknown when _dev.IsUsb && containsFloppyPage: @@ -232,7 +259,8 @@ partial class Dump blocks++; UpdateStatus?.Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - blocks, blockSize, + blocks, + blockSize, ByteSize.FromBytes(blocks * blockSize).ToString("0.000"))); } @@ -257,7 +285,8 @@ partial class Dump return; } - UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, blocks, + UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks_1_bytes, + blocks, blocks * blockSize)); UpdateStatus?.Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time, blocksToRead)); @@ -290,13 +319,13 @@ partial class Dump { ErrorMessage?.Invoke(!scsiReader.CanReadRaw ? Localization.Core.Device_doesnt_seem_capable_of_reading_raw_data_from_media - : Localization.Core. - Device_is_capable_of_reading_raw_data_but_Ive_been_unable_to_guess_correct_sector_size); + : Localization.Core + .Device_is_capable_of_reading_raw_data_but_Ive_been_unable_to_guess_correct_sector_size); if(!_force) { - StoppingErrorMessage?.Invoke(Localization.Core. - If_you_want_to_continue_reading_cooked_data_when_raw_is_not_available_use_the_force_option); + StoppingErrorMessage?.Invoke(Localization.Core + .If_you_want_to_continue_reading_cooked_data_when_raw_is_not_available_use_the_force_option); // TODO: Exit more gracefully return; @@ -310,7 +339,8 @@ partial class Dump blocksToRead = (uint)(longBlockSize == 37856 ? 16 : 1); UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_raw_bytes_1_cooked_bytes_per_sector, - longBlockSize, blockSize * blocksToRead)); + longBlockSize, + blockSize * blocksToRead)); physicalBlockSize = longBlockSize; blockSize = longBlockSize; @@ -345,7 +375,12 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); _dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead); - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); @@ -379,8 +414,11 @@ partial class Dump { if(outputFormat is IWritableOpticalImage opticalPlugin) { - sense = _dev.ReadDiscInformation(out byte[] readBuffer, out _, - MmcDiscInformationDataTypes.DiscInformation, _dev.Timeout, out _); + sense = _dev.ReadDiscInformation(out byte[] readBuffer, + out _, + MmcDiscInformationDataTypes.DiscInformation, + _dev.Timeout, + out _); if(!sense) { @@ -402,19 +440,19 @@ partial class Dump { if(_force) { - _dumpLog.WriteLine(Localization.Core. - Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_continuing); + _dumpLog.WriteLine(Localization.Core + .Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_continuing); - ErrorMessage?.Invoke(Localization.Core. - Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_continuing); + ErrorMessage?.Invoke(Localization.Core + .Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_continuing); } else { - _dumpLog.WriteLine(Localization.Core. - Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Image_does_not_support_multiple_sessions_in_non_Compact_Disc_dumps_not_continuing); return; } @@ -426,19 +464,19 @@ partial class Dump { if(_force) { - _dumpLog.WriteLine(Localization.Core. - Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_continuing); + _dumpLog.WriteLine(Localization.Core + .Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_continuing); - ErrorMessage?.Invoke(Localization.Core. - Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_continuing); + ErrorMessage?.Invoke(Localization.Core + .Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_continuing); } else { - _dumpLog.WriteLine(Localization.Core. - Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_not_continuing); - StoppingErrorMessage?.Invoke(Localization.Core. - Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_not_continuing); + StoppingErrorMessage?.Invoke(Localization.Core + .Image_does_not_support_multiple_tracks_in_non_Compact_Disc_dumps_not_continuing); return; } @@ -453,25 +491,25 @@ partial class Dump tno <= discInformation?.LastTrackLastSession; tno++) { - sense = _dev.ReadTrackInformation(out readBuffer, out _, false, - TrackInformationType.LogicalTrackNumber, tno, - _dev.Timeout, out _); + sense = _dev.ReadTrackInformation(out readBuffer, + out _, + false, + TrackInformationType.LogicalTrackNumber, + tno, + _dev.Timeout, + out _); - if(sense) - continue; + if(sense) continue; var trkInfo = TrackInformation.Decode(readBuffer); - if(trkInfo is null) - continue; + if(trkInfo is null) continue; // Some drives return this invalid value with recordable discs - if(trkInfo.LogicalTrackNumber == 0) - continue; + if(trkInfo.LogicalTrackNumber == 0) continue; // Fixes a firmware bug in some DVD drives - if((int)trkInfo.LogicalTrackStartAddress < 0) - trkInfo.LogicalTrackStartAddress = 0; + if((int)trkInfo.LogicalTrackStartAddress < 0) trkInfo.LogicalTrackStartAddress = 0; // Some drives return this invalid value with recordable discs if(trkInfo.LogicalTrackSize == 0xFFFFFFFF) @@ -489,8 +527,7 @@ partial class Dump SubchannelType = TrackSubchannelType.None }; - if(track.EndSector >= blocks) - blocks = track.EndSector + 1; + if(track.EndSector >= blocks) blocks = track.EndSector + 1; tracks.Add(track); } @@ -528,14 +565,16 @@ partial class Dump imageCreated = true; - #if DEBUG +#if DEBUG foreach(Track trk in tracks) { - UpdateStatus?. - Invoke(string.Format(Localization.Core.Track_0_starts_at_LBA_1_and_ends_at_LBA_2, - trk.Sequence, trk.StartSector, trk.EndSector)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Track_0_starts_at_LBA_1_and_ends_at_LBA_2, + trk.Sequence, + trk.StartSector, + trk.EndSector)); } - #endif +#endif if(canStoreNotCdTracks) { @@ -543,13 +582,13 @@ partial class Dump if(!ret) { - _dumpLog.WriteLine(Localization.Core. - Error_sending_tracks_to_output_image_not_continuing); + _dumpLog.WriteLine(Localization.Core + .Error_sending_tracks_to_output_image_not_continuing); _dumpLog.WriteLine(opticalPlugin.ErrorMessage); - StoppingErrorMessage?.Invoke(Localization.Core. - Error_sending_tracks_to_output_image_not_continuing + + StoppingErrorMessage?.Invoke(Localization.Core + .Error_sending_tracks_to_output_image_not_continuing + Environment.NewLine + opticalPlugin.ErrorMessage); @@ -579,8 +618,8 @@ partial class Dump { _dumpLog.WriteLine(Localization.Core.The_specified_image_format_cannot_represent_optical_discs); - StoppingErrorMessage?.Invoke(Localization.Core. - The_specified_image_format_cannot_represent_optical_discs); + StoppingErrorMessage?.Invoke(Localization.Core + .The_specified_image_format_cannot_represent_optical_discs); return; } @@ -597,21 +636,24 @@ partial class Dump { Modes.ModePage_04? rigidPage = Modes.DecodeModePage_04(page.PageResponse); - if(!rigidPage.HasValue || setGeometry) - continue; + if(!rigidPage.HasValue || setGeometry) continue; - _dumpLog. - WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - rigidPage.Value.Cylinders, rigidPage.Value.Heads, - (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); + _dumpLog.WriteLine(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + rigidPage.Value.Cylinders, + rigidPage.Value.Heads, + (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); - UpdateStatus?. - Invoke(string. - Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - rigidPage.Value.Cylinders, rigidPage.Value.Heads, - (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + rigidPage.Value.Cylinders, + rigidPage.Value.Heads, + (uint)(blocks / + (rigidPage.Value.Cylinders * + rigidPage.Value.Heads)))); - outputFormat.SetGeometry(rigidPage.Value.Cylinders, rigidPage.Value.Heads, + outputFormat.SetGeometry(rigidPage.Value.Cylinders, + rigidPage.Value.Heads, (uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))); setGeometry = true; @@ -622,21 +664,22 @@ partial class Dump { Modes.ModePage_05? flexiblePage = Modes.DecodeModePage_05(page.PageResponse); - if(!flexiblePage.HasValue) - continue; + if(!flexiblePage.HasValue) continue; - _dumpLog. - WriteLine(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, - flexiblePage.Value.SectorsPerTrack); + _dumpLog.WriteLine(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, + flexiblePage.Value.SectorsPerTrack); - UpdateStatus?. - Invoke(string. - Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, - flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, - flexiblePage.Value.SectorsPerTrack)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track, + flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, + flexiblePage.Value.SectorsPerTrack)); - outputFormat.SetGeometry(flexiblePage.Value.Cylinders, flexiblePage.Value.Heads, + outputFormat.SetGeometry(flexiblePage.Value.Cylinders, + flexiblePage.Value.Heads, flexiblePage.Value.SectorsPerTrack); setGeometry = true; @@ -668,8 +711,8 @@ partial class Dump { _dumpLog.WriteLine(Localization.Core.Creating_single_track_as_could_not_retrieve_track_list_from_drive); - UpdateStatus?.Invoke(Localization.Core. - Creating_single_track_as_could_not_retrieve_track_list_from_drive); + UpdateStatus?.Invoke(Localization.Core + .Creating_single_track_as_could_not_retrieve_track_list_from_drive); (outputFormat as IWritableOpticalImage)?.SetTracks(new List { @@ -690,9 +733,19 @@ partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, - _dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, - _private, _force); + ResumeSupport.Process(true, + _dev.IsRemovable, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(_createGraph) { @@ -747,14 +800,12 @@ partial class Dump _speed *= _speedMultiplier; - if(_speed is 0 or > 0xFFFF) - _speed = 0xFFFF; + if(_speed is 0 or > 0xFFFF) _speed = 0xFFFF; _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, _dev.Timeout, out _); } - if(_resume?.BlankExtents != null) - blankExtents = ExtentsConverter.FromMetadata(_resume.BlankExtents); + if(_resume?.BlankExtents != null) blankExtents = ExtentsConverter.FromMetadata(_resume.BlankExtents); var newTrim = false; @@ -770,60 +821,103 @@ partial class Dump if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice) { - ReadOpticalData(blocks, blocksToRead, blockSize, currentTry, extents, ref currentSpeed, ref minSpeed, - ref maxSpeed, ref totalDuration, scsiReader, mhddLog, ibgLog, ref imageWriteDuration, - ref newTrim, ref blankExtents); + ReadOpticalData(blocks, + blocksToRead, + blockSize, + currentTry, + extents, + ref currentSpeed, + ref minSpeed, + ref maxSpeed, + ref totalDuration, + scsiReader, + mhddLog, + ibgLog, + ref imageWriteDuration, + ref newTrim, + ref blankExtents); } else { mediaTags.TryGetValue(MediaTagType.DVD_DiscKey_Decrypted, out byte[] discKey); + if(scsiReader.HldtstReadRaw) { - ReadCacheData(blocks, blocksToRead, blockSize, currentTry, extents, ref currentSpeed, ref minSpeed, - ref maxSpeed, ref totalDuration, scsiReader, mhddLog, ibgLog, ref imageWriteDuration, - ref newTrim, discKey ?? null); + ReadCacheData(blocks, + blocksToRead, + blockSize, + currentTry, + extents, + ref currentSpeed, + ref minSpeed, + ref maxSpeed, + ref totalDuration, + scsiReader, + mhddLog, + ibgLog, + ref imageWriteDuration, + ref newTrim, + discKey ?? null); } else { - ReadSbcData(blocks, blocksToRead, blockSize, currentTry, extents, ref currentSpeed, ref minSpeed, - ref maxSpeed, ref totalDuration, scsiReader, mhddLog, ibgLog, ref imageWriteDuration, - ref newTrim, ref dvdDecrypt, discKey ?? null); + ReadSbcData(blocks, + blocksToRead, + blockSize, + currentTry, + extents, + ref currentSpeed, + ref minSpeed, + ref maxSpeed, + ref totalDuration, + scsiReader, + mhddLog, + ibgLog, + ref imageWriteDuration, + ref newTrim, + ref dvdDecrypt, + discKey ?? null); } } _dumpStopwatch.Stop(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -847,9 +941,9 @@ partial class Dump _trimStopwatch.Stop(); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) RetrySbcData(scsiReader, currentTry, extents, ref totalDuration, blankExtents); @@ -862,7 +956,7 @@ partial class Dump mediaTags.TryGetValue(MediaTagType.DVD_DiscKey_Decrypted, out byte[] mediaTag)) RetryTitleKeys(dvdDecrypt, mediaTag, ref totalDuration); - #endregion Error handling +#endregion Error handling if(opticalDisc) { @@ -877,8 +971,7 @@ partial class Dump ret = outputFormat.WriteMediaTag(tag.Value, tag.Key); - if(ret || _force) - continue; + if(ret || _force) continue; // Cannot write tag to image StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key)); @@ -922,8 +1015,7 @@ partial class Dump if(!sense) { - if(_private) - cmdBuf = DeviceReport.ClearIdentify(cmdBuf); + if(_private) cmdBuf = DeviceReport.ClearIdentify(cmdBuf); ret = outputFormat.WriteMediaTag(cmdBuf, MediaTagType.ATAPI_IDENTIFY); @@ -962,13 +1054,27 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_10); _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_10); - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0xFF, 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0xFF, + 5, + out _); if(!sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0x00, 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); } if(!sense && !_dev.Error) @@ -993,17 +1099,28 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_6); - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, - 5, out _); + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); } - if(sense || _dev.Error) - sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); + if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); if(!sense && !_dev.Error) { @@ -1029,8 +1146,7 @@ partial class Dump _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -1051,8 +1167,7 @@ partial class Dump outputFormat.ErrorMessage); } - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -1117,17 +1232,17 @@ partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); if(_preSidecar != null) { @@ -1233,13 +1348,27 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_10); _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_10); - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, - 0x3F, 0xFF, 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0xFF, + 5, + out _); if(!sense || _dev.Error) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, true, - ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _); + sense = _dev.ModeSense10(out cmdBuf, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); } if(!sense && !_dev.Error) @@ -1261,17 +1390,28 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); _dumpLog.WriteLine(Localization.Core.Requesting_MODE_SENSE_6); - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, - 0x00, 5, out _); + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, - 0x3F, 0x00, 5, out _); + sense = _dev.ModeSense6(out cmdBuf, + out _, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); } - if(sense || _dev.Error) - sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); + if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out _, 5, out _); if(!sense && !_dev.Error) { @@ -1307,13 +1447,15 @@ partial class Dump { o.start, o.type - }). - Distinct()) + }) + .Distinct()) { UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1, - filesystem.type, filesystem.start)); + filesystem.type, + filesystem.start)); - _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, + _dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, + filesystem.type, filesystem.start); } } @@ -1344,22 +1486,23 @@ partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; - if(_dev.IsRemovable) - sidecar.BlockMedias[0].DumpHardware = _resume.Tries; + if(_dev.IsRemovable) sidecar.BlockMedias[0].DumpHardware = _resume.Tries; UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar); var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -1368,18 +1511,18 @@ partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds())). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds())) + .Humanize()); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/Sbc/Error.cs b/Aaru.Core/Devices/Dumping/Sbc/Error.cs index 7443b42fa..ceba8e6d2 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Error.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Error.cs @@ -74,16 +74,25 @@ partial class Dump Modes.ModePage_01_MMC pgMmc; Modes.ModePage_01 pg; - sense = _dev.ModeSense6(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + sense = _dev.ModeSense6(out buffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, out _); Modes.DecodedMode? dcMode6 = null; - if(!sense) - dcMode6 = Modes.DecodeMode6(buffer, _dev.ScsiType); + if(!sense) dcMode6 = Modes.DecodeMode6(buffer, _dev.ScsiType); if(sense || dcMode6 is null) { - sense = _dev.ModeSense10(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + sense = _dev.ModeSense10(out buffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, out _); if(!sense) @@ -93,7 +102,7 @@ partial class Dump if(dcMode10?.Pages != null) { foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -103,9 +112,9 @@ partial class Dump if(dcMode6?.Pages != null) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is - { - Page: 0x01, Subpage: 0x00 - })) + { + Page: 0x01, Subpage: 0x00 + })) currentModePage = modePage; } } @@ -217,18 +226,17 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks); sense = _dev.ModeSelect(md6, out byte[] senseBuf, true, false, _dev.Timeout, out _); - if(sense) - sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -252,30 +260,38 @@ partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) - : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, badSector, + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) + : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, + badSector, pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) - : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, badSector, + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) + : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, + badSector, pass)); } if(scsiReader.HldtstReadRaw) + // The HL-DT-ST buffer is stored and read in 96-sector chunks. If we start to read at an LBA which is // not modulo 96, the data will not be correctly fetched. Therefore, we begin every recovery read with // filling the buffer at a known offset. // TODO: This is very ugly and there probably exist a more elegant way to solve this issue. - scsiReader.ReadBlock(out _, badSector - (badSector % 96) + 1, out _, out _, out _); + scsiReader.ReadBlock(out _, badSector - badSector % 96 + 1, out _, out _, out _); - sense = scsiReader.ReadBlock(out buffer, badSector, out double cmdDuration, out recoveredError, + sense = scsiReader.ReadBlock(out buffer, + badSector, + out double cmdDuration, + out recoveredError, out blankCheck); totalDuration += cmdDuration; @@ -299,13 +315,13 @@ partial class Dump outputFormat.WriteSector(buffer, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); } - else if(runningPersistent) - outputFormat.WriteSector(buffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(buffer, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -314,8 +330,7 @@ partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -338,12 +353,10 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_device_to_previous_status); sense = _dev.ModeSelect(md6, out _, true, false, _dev.Timeout, out _); - if(sense) - _dev.ModeSelect10(md10, out _, true, false, _dev.Timeout, out _); + if(sense) _dev.ModeSelect10(md10, out _, true, false, _dev.Timeout, out _); } - if(newBlank) - _resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray(); + if(newBlank) _resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray(); EndProgress?.Invoke(); } @@ -355,8 +368,7 @@ partial class Dump bool sense; byte[] buffer; - if(_outputPlugin is not IWritableImage outputFormat) - return; + if(_outputPlugin is not IWritableImage outputFormat) return; InitProgress?.Invoke(); @@ -374,47 +386,58 @@ partial class Dump } PulseProgress?.Invoke(forward - ? string.Format(Localization.Core.Retrying_title_key_0_pass_1_forward, missingKey, + ? string.Format(Localization.Core.Retrying_title_key_0_pass_1_forward, + missingKey, pass) - : string.Format(Localization.Core.Retrying_title_key_0_pass_1_reverse, missingKey, + : string.Format(Localization.Core.Retrying_title_key_0_pass_1_reverse, + missingKey, pass)); - sense = dvdDecrypt.ReadTitleKey(out buffer, out _, DvdCssKeyClass.DvdCssCppmOrCprm, missingKey, - _dev.Timeout, out double cmdDuration); + sense = dvdDecrypt.ReadTitleKey(out buffer, + out _, + DvdCssKeyClass.DvdCssCppmOrCprm, + missingKey, + _dev.Timeout, + out double cmdDuration); totalDuration += cmdDuration; - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; CSS_CPRM.TitleKey? titleKey = CSS.DecodeTitleKey(buffer, dvdDecrypt.BusKey); - if(!titleKey.HasValue) - continue; + if(!titleKey.HasValue) continue; outputFormat.WriteSectorTag(new[] - { - titleKey.Value.CMI - }, missingKey, SectorTagType.DvdSectorCmi); + { + titleKey.Value.CMI + }, + missingKey, + SectorTagType.DvdSectorCmi); // If the CMI bit is 1, the sector is using copy protection, else it is not // If the decoded title key is zeroed, there should be no copy protection if((titleKey.Value.CMI & 0x80) >> 7 == 0 || titleKey.Value.Key.All(k => k == 0)) { outputFormat.WriteSectorTag(new byte[] - { - 0, 0, 0, 0, 0 - }, missingKey, SectorTagType.DvdSectorTitleKey); + { + 0, 0, 0, 0, 0 + }, + missingKey, + SectorTagType.DvdSectorTitleKey); outputFormat.WriteSectorTag(new byte[] - { - 0, 0, 0, 0, 0 - }, missingKey, SectorTagType.DvdTitleKeyDecrypted); + { + 0, 0, 0, 0, 0 + }, + missingKey, + SectorTagType.DvdTitleKeyDecrypted); _resume.MissingTitleKeys.Remove(missingKey); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_title_key_0_in_pass_1, - missingKey, pass)); + missingKey, + pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_title_key_0_in_pass_1, missingKey, pass); } @@ -430,7 +453,8 @@ partial class Dump } UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_title_key_0_in_pass_1, - missingKey, pass)); + missingKey, + pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_title_key_0_in_pass_1, missingKey, pass); } @@ -442,8 +466,7 @@ partial class Dump forward = !forward; _resume.MissingTitleKeys.Sort(); - if(!forward) - _resume.MissingTitleKeys.Reverse(); + if(!forward) _resume.MissingTitleKeys.Reverse(); goto repeatRetry; } diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 326589814..ca5bea3ec 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -62,8 +62,19 @@ partial class Dump { blankExtents = new ExtentsULong(); - written = _dev.MediumScan(out buffer, true, false, false, false, false, 0, 1, 1, out _, out _, - uint.MaxValue, out _); + written = _dev.MediumScan(out buffer, + true, + false, + false, + false, + false, + 0, + 1, + 1, + out _, + out _, + uint.MaxValue, + out _); DecodedSense? decodedSense = Sense.Decode(buffer); @@ -84,8 +95,7 @@ partial class Dump for(uint b = 0; b < blocks; b += c) { - if(!canMediumScan) - break; + if(!canMediumScan) break; if(_aborted) { @@ -109,15 +119,33 @@ partial class Dump changingCounter = false; } - if(b + c >= blocks) - c = (uint)(blocks - b); + if(b + c >= blocks) c = (uint)(blocks - b); - UpdateProgress?. - Invoke(written ? string.Format(Localization.Core.Scanning_for_0_written_blocks_starting_in_block_1, c, b) : string.Format(Localization.Core.Scanning_for_0_blank_blocks_starting_in_block_1, c, b), - b, (long)blocks); + UpdateProgress?.Invoke(written + ? string.Format(Localization.Core + .Scanning_for_0_written_blocks_starting_in_block_1, + c, + b) + : string.Format(Localization.Core + .Scanning_for_0_blank_blocks_starting_in_block_1, + c, + b), + b, + (long)blocks); - conditionMet = _dev.MediumScan(out _, written, false, false, false, false, b, c, c, out _, out _, - uint.MaxValue, out _); + conditionMet = _dev.MediumScan(out _, + written, + false, + false, + false, + false, + b, + c, + c, + out _, + out _, + uint.MaxValue, + out _); if(conditionMet) { @@ -126,8 +154,7 @@ partial class Dump else blankExtents.Add(b, c, true); - if(c < maxBlocks) - changingWritten = true; + if(c < maxBlocks) changingWritten = true; } else { @@ -138,8 +165,7 @@ partial class Dump changingCounter = true; - if(c != 0) - continue; + if(c != 0) continue; written = !written; c = maxBlocks; @@ -157,8 +183,7 @@ partial class Dump foreach(Tuple blank in blankExtents.ToArray()) { - for(ulong b = blank.Item1; b <= blank.Item2; b++) - writtenExtents.Remove(b); + for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b); } } @@ -176,13 +201,11 @@ partial class Dump foreach(Tuple extent in extentsToDump) { - if(extent.Item2 < _resume.NextBlock) - continue; // Skip this extent + if(extent.Item2 < _resume.NextBlock) continue; // Skip this extent ulong nextBlock = extent.Item1; - if(extent.Item1 < _resume.NextBlock) - nextBlock = (uint)_resume.NextBlock; + if(extent.Item1 < _resume.NextBlock) nextBlock = (uint)_resume.NextBlock; _speedStopwatch.Restart(); @@ -197,18 +220,18 @@ partial class Dump break; } - if(extent.Item2 + 1 - i < blocksToRead) - blocksToRead = (uint)(extent.Item2 + 1 - i); + if(extent.Item2 + 1 - i < blocksToRead) blocksToRead = (uint)(extent.Item2 + 1 - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _); totalDuration += cmdDuration; @@ -225,19 +248,16 @@ partial class Dump else { // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > extent.Item2 + 1) - _skip = (uint)(extent.Item2 + 1 - i); + if(i + _skip > extent.Item2 + 1) _skip = (uint)(extent.Item2 + 1 - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -253,8 +273,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; diff --git a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs index 781c0dacb..7bf2e5e2b 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs @@ -84,8 +84,7 @@ partial class Dump continue; } - if((sense || _dev.Error) && !recoveredError) - continue; + if((sense || _dev.Error) && !recoveredError) continue; _resume.BadBlocks.Remove(badSector); extents.Add(badSector); @@ -93,7 +92,6 @@ partial class Dump _mediaGraph?.PaintSectorGood(badSector); } - if(newBlank) - _resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray(); + if(newBlank) _resume.BlankExtents = ExtentsConverter.ToMetadata(blankExtents).ToArray(); } } \ No newline at end of file diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 85bc6611b..9aa5d5b1e 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -67,8 +67,8 @@ public partial class Dump ErrorMessage?.Invoke(Localization.Core.Raw_dumping_is_not_supported_in_MMC_or_SD_devices_Continuing); else { - StoppingErrorMessage?.Invoke(Localization.Core. - Raw_dumping_is_not_supported_in_MMC_or_SD_devices_Aborting); + StoppingErrorMessage?.Invoke(Localization.Core + .Raw_dumping_is_not_supported_in_MMC_or_SD_devices_Aborting); return; } @@ -133,8 +133,7 @@ public partial class Dump blocksToRead = (ushort)(ecsdDecoded.OptimalReadSize * 4096 / blockSize); - if(blocksToRead == 0) - blocksToRead = 128; + if(blocksToRead == 0) blocksToRead = 128; // Supposing it's high-capacity MMC if it has Extended CSD... byteAddressed = false; @@ -226,8 +225,8 @@ public partial class Dump } else { - supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr)?. - CommandSupport.HasFlag(CommandSupport.SetBlockCount) ?? + supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr) + ?.CommandSupport.HasFlag(CommandSupport.SetBlockCount) ?? false; mediaTags.Add(MediaTagType.SD_SCR, null); @@ -268,15 +267,13 @@ public partial class Dump byte[] cmdBuf; bool error; - if(blocksToRead > _maximumReadable) - blocksToRead = (ushort)_maximumReadable; + if(blocksToRead > _maximumReadable) blocksToRead = (ushort)_maximumReadable; if(supportsCmd23 && blocksToRead > 1) { sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, out duration); - if(sense || _dev.Error) - supportsCmd23 = false; + if(sense || _dev.Error) supportsCmd23 = false; // Need to restart device, otherwise is it just busy streaming data with no one listening sense = _dev.ReOpen(); @@ -293,23 +290,27 @@ public partial class Dump { while(true) { - error = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, + error = _dev.ReadWithBlockCount(out cmdBuf, + out _, + 0, + blockSize, + blocksToRead, + byteAddressed, + timeout, out duration); - if(error) - blocksToRead /= 2; + if(error) blocksToRead /= 2; - if(!error || blocksToRead == 1) - break; + if(!error || blocksToRead == 1) break; } if(error) { _dumpLog.WriteLine(Localization.Core.ERROR_Cannot_get_blocks_to_read_device_error_0, _dev.LastError); - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); return; } @@ -321,15 +322,12 @@ public partial class Dump { error = _dev.BufferedOsRead(out cmdBuf, 0, blockSize * blocksToRead, out duration); - if(error) - blocksToRead /= 2; + if(error) blocksToRead /= 2; - if(!error || blocksToRead == 1) - break; + if(!error || blocksToRead == 1) break; // Device is in timeout, reopen to reset - if(_dev.LastError == 110) - _dev.ReOpen(); + if(_dev.LastError == 110) _dev.ReOpen(); } if(error) @@ -345,27 +343,30 @@ public partial class Dump { while(true) { - error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadMultipleUsingSingle(out cmdBuf, + out _, + 0, + blockSize, + blocksToRead, + byteAddressed, + timeout, + out duration); - if(error) - blocksToRead /= 2; + if(error) blocksToRead /= 2; // Device is in timeout, reopen to reset - if(_dev.LastError == 110) - _dev.ReOpen(); + if(_dev.LastError == 110) _dev.ReOpen(); - if(!error || blocksToRead == 1) - break; + if(!error || blocksToRead == 1) break; } if(error) { _dumpLog.WriteLine(Localization.Core.ERROR_Cannot_get_blocks_to_read_device_error_0, _dev.LastError); - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); return; } @@ -393,9 +394,9 @@ public partial class Dump } else if(_useBufferedReads) { - UpdateStatus?. - Invoke(string.Format(Localization.Core.Device_can_read_0_blocks_at_a_time_using_OS_buffered_reads, - blocksToRead)); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Device_can_read_0_blocks_at_a_time_using_OS_buffered_reads, + blocksToRead)); _dumpLog.WriteLine(Localization.Core.Device_can_read_0_blocks_at_a_time_using_OS_buffered_reads, blocksToRead); @@ -408,14 +409,24 @@ public partial class Dump _dumpLog.WriteLine(Localization.Core.Device_can_read_0_blocks_using_sequential_commands, blocksToRead); } - if(_skip < blocksToRead) - _skip = blocksToRead; + if(_skip < blocksToRead) _skip = blocksToRead; DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, false, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId, - ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force); + ResumeSupport.Process(true, + false, + blocks, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) { @@ -449,14 +460,21 @@ public partial class Dump } } - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", sdProfile); ret = outputFormat.Create(_outputPath, _dev.Type == DeviceType.SecureDigital ? MediaType.SecureDigital : MediaType.MMC, - _formatOptions, blocks, blockSize); + _formatOptions, + blocks, + blockSize); // Cannot create image if(!ret) @@ -496,11 +514,10 @@ public partial class Dump break; } - ret = - outputFormat.WriteMediaTag(cid, - _dev.Type == DeviceType.SecureDigital - ? MediaTagType.SD_CID - : MediaTagType.MMC_CID); + ret = outputFormat.WriteMediaTag(cid, + _dev.Type == DeviceType.SecureDigital + ? MediaTagType.SD_CID + : MediaTagType.MMC_CID); // Cannot write CID to image if(!ret && !_force) @@ -517,11 +534,10 @@ public partial class Dump if(csd != null) { - ret = - outputFormat.WriteMediaTag(csd, - _dev.Type == DeviceType.SecureDigital - ? MediaTagType.SD_CSD - : MediaTagType.MMC_CSD); + ret = outputFormat.WriteMediaTag(csd, + _dev.Type == DeviceType.SecureDigital + ? MediaTagType.SD_CSD + : MediaTagType.MMC_CSD); // Cannot write CSD to image if(!ret && !_force) @@ -555,11 +571,10 @@ public partial class Dump if(ocr != null) { - ret = - outputFormat.WriteMediaTag(ocr, - _dev.Type == DeviceType.SecureDigital - ? MediaTagType.SD_OCR - : MediaTagType.MMC_OCR); + ret = outputFormat.WriteMediaTag(ocr, + _dev.Type == DeviceType.SecureDigital + ? MediaTagType.SD_OCR + : MediaTagType.MMC_OCR); // Cannot write OCR to image if(!ret && !_force) @@ -637,36 +652,54 @@ public partial class Dump break; } - if(blocks - i < blocksToRead) - blocksToRead = (byte)(blocks - i); + if(blocks - i < blocksToRead) blocksToRead = (byte)(blocks - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)blocks); _speedStopwatch.Start(); + if(blocksToRead == 1) { - error = _dev.ReadSingleBlock(out cmdBuf, out _, (uint)i, blockSize, byteAddressed, timeout, + error = _dev.ReadSingleBlock(out cmdBuf, + out _, + (uint)i, + blockSize, + byteAddressed, + timeout, out duration); } else if(supportsCmd23) { - error = _dev.ReadWithBlockCount(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadWithBlockCount(out cmdBuf, + out _, + (uint)i, + blockSize, + blocksToRead, + byteAddressed, + timeout, + out duration); } else if(_useBufferedReads) error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead, out duration); else { - error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadMultipleUsingSingle(out cmdBuf, + out _, + (uint)i, + blockSize, + blocksToRead, + byteAddressed, + timeout, + out duration); } _speedStopwatch.Stop(); @@ -685,11 +718,9 @@ public partial class Dump { _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, byteAddressed, response); - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip); @@ -708,8 +739,7 @@ public partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -723,36 +753,41 @@ public partial class Dump EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -776,8 +811,13 @@ public partial class Dump PulseProgress?.Invoke(string.Format(Localization.Core.Trimming_sector_0, badSector)); - error = _dev.ReadSingleBlock(out cmdBuf, out response, (uint)badSector, blockSize, byteAddressed, - timeout, out duration); + error = _dev.ReadSingleBlock(out cmdBuf, + out response, + (uint)badSector, + blockSize, + byteAddressed, + timeout, + out duration); totalDuration += duration; @@ -804,9 +844,9 @@ public partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -829,13 +869,20 @@ public partial class Dump } PulseProgress?.Invoke(forward - ? string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, badSector, + ? string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, + badSector, pass) - : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, badSector, + : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, + badSector, pass)); - error = _dev.ReadSingleBlock(out cmdBuf, out response, (uint)badSector, blockSize, byteAddressed, - timeout, out duration); + error = _dev.ReadSingleBlock(out cmdBuf, + out response, + (uint)badSector, + blockSize, + byteAddressed, + timeout, + out duration); totalDuration += duration; @@ -851,7 +898,8 @@ public partial class Dump outputFormat.WriteSector(cmdBuf, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); @@ -863,8 +911,7 @@ public partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetryLba; } @@ -872,7 +919,7 @@ public partial class Dump EndProgress?.Invoke(); } - #endregion Error handling +#endregion Error handling currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -892,8 +939,7 @@ public partial class Dump outputFormat.ErrorMessage); } - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -954,17 +1000,17 @@ public partial class Dump _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()). - Humanize()); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalChkDuration.Milliseconds()) + .Humanize()); (string type, string subType) xmlType = (null, null); @@ -994,8 +1040,7 @@ public partial class Dump sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedias[0].Model = _dev.Model; - if(!_private) - sidecar.BlockMedias[0].Serial = _dev.Serial; + if(!_private) sidecar.BlockMedias[0].Serial = _dev.Serial; sidecar.BlockMedias[0].Size = blocks * blockSize; @@ -1003,10 +1048,13 @@ public partial class Dump var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create); - JsonSerializer.Serialize(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); } @@ -1014,18 +1062,18 @@ public partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { @@ -1042,8 +1090,7 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); - if(_resume.BadBlocks.Count > 0) - _resume.BadBlocks.Sort(); + if(_resume.BadBlocks.Count > 0) _resume.BadBlocks.Sort(); switch(_dev.Type) { diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index 27436d593..9024cab87 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -90,8 +90,8 @@ partial class Dump if(!isAdmin) { - AaruConsole.ErrorWriteLine(Localization.Core. - Because_of_commands_sent_dumping_XGD_must_be_administrative_Cannot_continue); + AaruConsole.ErrorWriteLine(Localization.Core + .Because_of_commands_sent_dumping_XGD_must_be_administrative_Cannot_continue); _dumpLog.WriteLine(Localization.Core.Cannot_dump_XGD_without_administrative_privileges); @@ -99,11 +99,9 @@ partial class Dump } } - if(mediaTags.ContainsKey(MediaTagType.DVD_PFI)) - mediaTags.Remove(MediaTagType.DVD_PFI); + if(mediaTags.ContainsKey(MediaTagType.DVD_PFI)) mediaTags.Remove(MediaTagType.DVD_PFI); - if(mediaTags.ContainsKey(MediaTagType.DVD_DMI)) - mediaTags.Remove(MediaTagType.DVD_DMI); + if(mediaTags.ContainsKey(MediaTagType.DVD_DMI)) mediaTags.Remove(MediaTagType.DVD_DMI); // Drive shall move to lock state when a new disc is inserted. Old kreon versions do not lock correctly so save this sense = _dev.ReadCapacity(out byte[] coldReadCapacity, out byte[] senseBuf, _dev.Timeout, out _); @@ -117,8 +115,15 @@ partial class Dump } // Drive shall move to lock state when a new disc is inserted. Old kreon versions do not lock correctly so save this - sense = _dev.ReadDiscStructure(out byte[] coldPfi, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); + sense = _dev.ReadDiscStructure(out byte[] coldPfi, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + 0, + out _); if(sense) { @@ -190,8 +195,15 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_Physical_Format_Information); _dumpLog.WriteLine(Localization.Core.Reading_Physical_Format_Information); - sense = _dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); + sense = _dev.ReadDiscStructure(out readBuffer, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + 0, + out _); if(sense) { @@ -215,8 +227,15 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_Disc_Manufacturing_Information); _dumpLog.WriteLine(Localization.Core.Reading_Disc_Manufacturing_Information); - sense = _dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _); + sense = _dev.ReadDiscStructure(out readBuffer, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + 0, + out _); if(sense) { @@ -332,8 +351,15 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_Physical_Format_Information); _dumpLog.WriteLine(Localization.Core.Reading_Physical_Format_Information); - sense = _dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); + sense = _dev.ReadDiscStructure(out readBuffer, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + 0, + out _); if(sense) { @@ -380,8 +406,15 @@ partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_Disc_Manufacturing_Information); _dumpLog.WriteLine(Localization.Core.Reading_Disc_Manufacturing_Information); - sense = _dev.ReadDiscStructure(out readBuffer, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, 0, out _); + sense = _dev.ReadDiscStructure(out readBuffer, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + 0, + out _); if(sense) { @@ -413,8 +446,20 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Total_size_0_sectors, totalSize); _dumpLog.WriteLine(Localization.Core.Real_layer_break_0, layerBreak); - bool read12 = !_dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1, - false, _dev.Timeout, out _); + bool read12 = !_dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + true, + false, + false, + 0, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out _); if(!read12) { @@ -443,37 +488,45 @@ partial class Dump _speed *= _speedMultiplier; - if(_speed is 0 or > 0xFFFF) - _speed = 0xFFFF; + if(_speed is 0 or > 0xFFFF) _speed = 0xFFFF; _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, _dev.Timeout, out _); } while(true) { - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, blockSize, 0, - blocksToRead, false, _dev.Timeout, out _); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + false, + false, + false, + 0, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out _); - if(sense || _dev.Error) - blocksToRead /= 2; + if(sense || _dev.Error) blocksToRead /= 2; - if(!_dev.Error || blocksToRead == 1) - break; + if(!_dev.Error || blocksToRead == 1) break; } if(_dev.Error) { _dumpLog.WriteLine(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, _dev.LastError); - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); return; } - if(_skip < blocksToRead) - _skip = blocksToRead; + if(_skip < blocksToRead) _skip = blocksToRead; var ret = true; @@ -503,7 +556,12 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead); UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private, + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", + _dev, + blocks, + blockSize, + blocksToRead, + _private, _dimensions); var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010); @@ -530,8 +588,19 @@ partial class Dump DumpHardware currentTry = null; ExtentsULong extents = null; - ResumeSupport.Process(true, true, totalSize, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId, - ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force); + ResumeSupport.Process(true, + true, + totalSize, + _dev.Manufacturer, + _dev.Model, + _dev.Serial, + _dev.PlatformId, + ref _resume, + ref currentTry, + ref extents, + _dev.FirmwareRevision, + _private, + _force); if(currentTry == null || extents == null) StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing); @@ -596,8 +665,7 @@ partial class Dump break; } - if(currentSector >= blocks) - break; + if(currentSector >= blocks) break; ulong extentStart, extentEnd; @@ -630,8 +698,7 @@ partial class Dump extentEnd = blocks; } - if(currentSector > extentEnd) - continue; + if(currentSector > extentEnd) continue; for(ulong i = currentSector; i < extentStart; i += blocksToRead) { @@ -646,22 +713,36 @@ partial class Dump break; } - if(extentStart - i < blocksToRead) - blocksToRead = (uint)(extentStart - i); + if(extentStart - i < blocksToRead) blocksToRead = (uint)(extentStart - i); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)totalSize); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)totalSize); _speedStopwatch.Start(); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, 0, - blocksToRead, false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)i, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -681,21 +762,19 @@ partial class Dump _errorLog?.WriteLine(i, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly - if(i + _skip > blocks) - _skip = (uint)(blocks - i); + if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data _writeStopwatch.Restart(); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; - for(ulong b = i; b < i + _skip; b++) - _resume.BadBlocks.Add(b); + for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_error_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_error_0, Sense.PrettifySense(senseBuf)); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); @@ -705,14 +784,14 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i); i += _skip - blocksToRead; - string[] senseLines = Sense.PrettifySense(senseBuf). - Split(new[] - { - Environment.NewLine - }, StringSplitOptions.RemoveEmptyEntries); + string[] senseLines = Sense.PrettifySense(senseBuf) + .Split(new[] + { + Environment.NewLine + }, + StringSplitOptions.RemoveEmptyEntries); - foreach(string senseLine in senseLines) - _dumpLog.WriteLine(senseLine); + foreach(string senseLine in senseLines) _dumpLog.WriteLine(senseLine); newTrim = true; } @@ -725,8 +804,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -748,8 +826,7 @@ partial class Dump break; } - if(extentEnd - i < blocksToRead) - blocksToRead = (uint)(extentEnd - i) + 1; + if(extentEnd - i < blocksToRead) blocksToRead = (uint)(extentEnd - i) + 1; mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); @@ -765,8 +842,7 @@ partial class Dump _mediaGraph?.PaintSectorsGood(i, blocksToRead); } - if(!_aborted) - currentSector = extentEnd + 1; + if(!_aborted) currentSector = extentEnd + 1; } _writeStopwatch.Stop(); @@ -790,12 +866,14 @@ partial class Dump break; } - if(middleZone - 1 - middle < blocksToRead) - blocksToRead = (uint)(middleZone - 1 - middle); + if(middleZone - 1 - middle < blocksToRead) blocksToRead = (uint)(middleZone - 1 - middle); - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, middle + currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)(middle + currentSector), (long)totalSize); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + middle + currentSector, + totalSize, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)(middle + currentSector), + (long)totalSize); mhddLog.Write(middle + currentSector, cmdDuration, blocksToRead); ibgLog.Write(middle + currentSector, currentSpeed * 1024); @@ -852,22 +930,36 @@ partial class Dump break; } - if(l0Video + l1Video - l1 < blocksToRead) - blocksToRead = (uint)(l0Video + l1Video - l1); + if(l0Video + l1Video - l1 < blocksToRead) blocksToRead = (uint)(l0Video + l1Video - l1); - if(currentSpeed > maxSpeed && currentSpeed > 0) - maxSpeed = currentSpeed; + if(currentSpeed > maxSpeed && currentSpeed > 0) maxSpeed = currentSpeed; - if(currentSpeed < minSpeed && currentSpeed > 0) - minSpeed = currentSpeed; + if(currentSpeed < minSpeed && currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)currentSector, (long)totalSize); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + currentSector, + totalSize, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)currentSector, + (long)totalSize); _speedStopwatch.Start(); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, blockSize, 0, - blocksToRead, false, _dev.Timeout, out cmdDuration); + + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)l1, + blockSize, + 0, + blocksToRead, + false, + _dev.Timeout, + out cmdDuration); + _speedStopwatch.Stop(); totalDuration += cmdDuration; @@ -887,8 +979,7 @@ partial class Dump _errorLog?.WriteLine(currentSector, _dev.Error, _dev.LastError, senseBuf); // TODO: Reset device after X errors - if(_stopOnError) - return; // TODO: Return more cleanly + if(_stopOnError) return; // TODO: Return more cleanly // Write empty data _writeStopwatch.Restart(); @@ -905,14 +996,14 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, l1); l1 += _skip - blocksToRead; - string[] senseLines = Sense.PrettifySense(senseBuf). - Split(new[] - { - Environment.NewLine - }, StringSplitOptions.RemoveEmptyEntries); + string[] senseLines = Sense.PrettifySense(senseBuf) + .Split(new[] + { + Environment.NewLine + }, + StringSplitOptions.RemoveEmptyEntries); - foreach(string senseLine in senseLines) - _dumpLog.WriteLine(senseLine); + foreach(string senseLine in senseLines) _dumpLog.WriteLine(senseLine); } _writeStopwatch.Stop(); @@ -923,8 +1014,7 @@ partial class Dump double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) - continue; + if(elapsed <= 0 || sectorSpeedStart * blockSize < 524288) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); sectorSpeedStart = 0; @@ -959,36 +1049,41 @@ partial class Dump AaruConsole.WriteLine(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, + blocks, + blockSize, + _dumpStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), + _devicePath); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); - #region Trimming +#region Trimming if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim) { @@ -1011,8 +1106,20 @@ partial class Dump PulseProgress?.Invoke(string.Format(Localization.Core.Trimming_sector_0, badSector)); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector, - blockSize, 0, 1, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)badSector, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; @@ -1039,9 +1146,9 @@ partial class Dump _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); } - #endregion Trimming +#endregion Trimming - #region Error handling +#region Error handling if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { @@ -1049,8 +1156,7 @@ partial class Dump foreach(ulong ur in _resume.BadBlocks) { - for(ulong i = ur; i < ur + blocksToRead; i++) - tmpList.Add(i); + for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); } tmpList.Sort(); @@ -1068,17 +1174,26 @@ partial class Dump { Modes.ModePage_01_MMC pgMmc; - sense = _dev.ModeSense6(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); Modes.DecodedMode? dcMode6 = null; - if(!sense) - dcMode6 = Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); + if(!sense) dcMode6 = Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); if(sense || dcMode6 is null) { - sense = _dev.ModeSense10(out readBuffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out readBuffer, + out _, + false, + ScsiModeSensePageControl.Current, + 0x01, + _dev.Timeout, + out _); if(!sense) { @@ -1088,7 +1203,7 @@ partial class Dump if(dcMode10.HasValue) { foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -1098,7 +1213,7 @@ partial class Dump if(dcMode6.HasValue) { foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } } @@ -1148,18 +1263,17 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks); sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _); - if(sense) - sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); if(sense) { - UpdateStatus?.Invoke(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + UpdateStatus?.Invoke(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); AaruConsole.DebugWriteLine(Localization.Core.Error_0, Sense.PrettifySense(senseBuf)); - _dumpLog.WriteLine(Localization.Core. - Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); + _dumpLog.WriteLine(Localization.Core + .Drive_did_not_accept_MODE_SELECT_command_for_persistent_error_reading); } else runningPersistent = true; @@ -1183,29 +1297,44 @@ partial class Dump if(forward) { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_forward, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, - badSector, pass)); + badSector, + pass)); } else { PulseProgress?.Invoke(runningPersistent - ? string. - Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse, - badSector, pass) + ? string.Format(Localization.Core + .Retrying_sector_0_pass_1_recovering_partial_data_reverse, + badSector, + pass) : string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, - badSector, pass)); + badSector, + pass)); } - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector, - blockSize, 0, 1, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out readBuffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)badSector, + blockSize, + 0, + 1, + false, + _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; - if(sense || _dev.Error) - _errorLog?.WriteLine(currentSector, _dev.Error, _dev.LastError, senseBuf); + if(sense || _dev.Error) _errorLog?.WriteLine(currentSector, _dev.Error, _dev.LastError, senseBuf); if(!sense && !_dev.Error) { @@ -1214,13 +1343,13 @@ partial class Dump outputFormat.WriteSector(readBuffer, badSector); _mediaGraph?.PaintSectorGood(badSector); - UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, + UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, + badSector, pass)); _dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass); } - else if(runningPersistent) - outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -1229,8 +1358,7 @@ partial class Dump forward = !forward; _resume.BadBlocks.Sort(); - if(!forward) - _resume.BadBlocks.Reverse(); + if(!forward) _resume.BadBlocks.Reverse(); goto repeatRetry; } @@ -1253,14 +1381,13 @@ partial class Dump _dumpLog.WriteLine(Localization.Core.Sending_MODE_SELECT_to_drive_return_device_to_previous_status); sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _); - if(sense) - _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); + if(sense) _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _); } EndProgress?.Invoke(); } - #endregion Error handling +#endregion Error handling _resume.BadBlocks.Sort(); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -1276,8 +1403,7 @@ partial class Dump ret = outputFormat.WriteMediaTag(tag.Value, tag.Key); - if(ret || _force) - continue; + if(ret || _force) continue; // Cannot write tag to image _dumpLog.WriteLine(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key)); @@ -1291,8 +1417,7 @@ partial class Dump _resume.BadBlocks.Sort(); - foreach(ulong bad in _resume.BadBlocks) - _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); + foreach(ulong bad in _resume.BadBlocks) _dumpLog.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); currentTry.Extents = ExtentsConverter.ToMetadata(extents); @@ -1311,8 +1436,7 @@ partial class Dump outputFormat.ErrorMessage); } - if(_preSidecar != null) - outputFormat.SetMetadata(_preSidecar); + if(_preSidecar != null) outputFormat.SetMetadata(_preSidecar); _dumpLog.WriteLine(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file); @@ -1355,18 +1479,18 @@ partial class Dump UpdateStatus?.Invoke(""); - UpdateStatus?. - Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, - _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), - totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), - imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), - _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, + _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second), + totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), + imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), + _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Info/DeviceInfo.cs b/Aaru.Core/Devices/Info/DeviceInfo.cs index fd42ddfee..1aaa5f4a7 100644 --- a/Aaru.Core/Devices/Info/DeviceInfo.cs +++ b/Aaru.Core/Devices/Info/DeviceInfo.cs @@ -117,8 +117,7 @@ public partial class DeviceInfo dev.EnableMediaCardPassThrough(out errorRegisters, dev.Timeout, out _); - if(errorRegisters is { Sector: 0xAA, SectorCount: 0x55 }) - AtaMcptError = errorRegisters; + if(errorRegisters is { Sector: 0xAA, SectorCount: 0x55 }) AtaMcptError = errorRegisters; break; } @@ -184,8 +183,7 @@ public partial class DeviceInfo { sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); - if(sense) - continue; + if(sense) continue; ScsiEvpdPages.Add(page, inqBuf); } @@ -194,51 +192,70 @@ public partial class DeviceInfo var devType = (PeripheralDeviceTypes)ScsiInquiry.Value.PeripheralDeviceType; - sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, - 0x3F, 0xFF, 5, out _); + sense = dev.ModeSense10(out byte[] modeBuf, + out senseBuf, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0xFF, + 5, + out _); - if(!sense && !dev.Error) - ScsiModeSense10 = modeBuf; + if(!sense && !dev.Error) ScsiModeSense10 = modeBuf; if(sense || dev.Error) { - sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, - 0x3F, 0x00, 5, out _); + sense = dev.ModeSense10(out modeBuf, + out senseBuf, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); - if(!sense && !dev.Error) - ScsiModeSense10 = modeBuf; + if(!sense && !dev.Error) ScsiModeSense10 = modeBuf; } - if(!sense && !dev.Error) - ScsiMode = Modes.DecodeMode10(modeBuf, devType); + if(!sense && !dev.Error) ScsiMode = Modes.DecodeMode10(modeBuf, devType); bool useMode10 = !(sense || dev.Error || !ScsiMode.HasValue); - sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF, - 5, out _); + sense = dev.ModeSense6(out modeBuf, + out senseBuf, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0xFF, + 5, + out _); - if(!sense && !dev.Error) - ScsiModeSense6 = modeBuf; + if(!sense && !dev.Error) ScsiModeSense6 = modeBuf; if(sense || dev.Error) { - sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, - 0x00, 5, out _); + sense = dev.ModeSense6(out modeBuf, + out senseBuf, + false, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + 5, + out _); - if(!sense && !dev.Error) - ScsiModeSense6 = modeBuf; + if(!sense && !dev.Error) ScsiModeSense6 = modeBuf; } if(sense || dev.Error) { sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out _); - if(!sense && !dev.Error) - ScsiModeSense6 = modeBuf; + if(!sense && !dev.Error) ScsiModeSense6 = modeBuf; } - if(!sense && !dev.Error && !useMode10) - ScsiMode = Modes.DecodeMode6(modeBuf, devType); + if(!sense && !dev.Error && !useMode10) ScsiMode = Modes.DecodeMode6(modeBuf, devType); switch(devType) { @@ -246,21 +263,22 @@ public partial class DeviceInfo { sense = dev.GetConfiguration(out byte[] confBuf, out senseBuf, dev.Timeout, out _); - if(!sense) - MmcConfiguration = confBuf; + if(!sense) MmcConfiguration = confBuf; var dvdDecrypt = new DVDDecryption(dev); - sense = dvdDecrypt.ReadRpc(out byte[] cmdBuf, out _, DvdCssKeyClass.DvdCssCppmOrCprm, - dev.Timeout, out _); + sense = dvdDecrypt.ReadRpc(out byte[] cmdBuf, + out _, + DvdCssKeyClass.DvdCssCppmOrCprm, + dev.Timeout, + out _); if(!sense) { CSS_CPRM.RegionalPlaybackControlState? rpc = CSS_CPRM.DecodeRegionalPlaybackControlState(cmdBuf); - if(rpc.HasValue) - RPC = rpc; + if(rpc.HasValue) RPC = rpc; } // TODO: DVD drives respond correctly to BD status. @@ -308,7 +326,7 @@ public partial class DeviceInfo } */ - #region Plextor +#region Plextor if(dev.Manufacturer == "PLEXTOR") { @@ -336,11 +354,14 @@ public partial class DeviceInfo for(byte i = 0; i < 4; i++) { - plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, out senseBuf, i, - 256, dev.Timeout, out _); + plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, + out senseBuf, + i, + 256, + dev.Timeout, + out _); - if(plxtSense) - break; + if(plxtSense) break; Array.Copy(plxtBufSmall, 0, plxtBuf, i * 256, 256); } @@ -354,7 +375,9 @@ public partial class DeviceInfo { if(dev.Model.StartsWith("CD-R ", StringComparison.Ordinal)) { - plxtSense = dev.PlextorReadEepromCdr(out plxtBuf, out senseBuf, dev.Timeout, + plxtSense = dev.PlextorReadEepromCdr(out plxtBuf, + out senseBuf, + dev.Timeout, out _); } @@ -387,8 +410,11 @@ public partial class DeviceInfo } } - plxtSense = dev.PlextorGetPoweRec(out senseBuf, out bool plxtPwrRecEnabled, - out ushort plxtPwrRecSpeed, dev.Timeout, out _); + plxtSense = dev.PlextorGetPoweRec(out senseBuf, + out bool plxtPwrRecEnabled, + out ushort plxtPwrRecSpeed, + dev.Timeout, + out _); if(!plxtSense) { @@ -399,9 +425,12 @@ public partial class DeviceInfo PlextorFeatures.PoweRecEnabled = true; PlextorFeatures.PoweRecRecommendedSpeed = plxtPwrRecSpeed; - plxtSense = dev.PlextorGetSpeeds(out senseBuf, out ushort plxtPwrRecSelected, + plxtSense = dev.PlextorGetSpeeds(out senseBuf, + out ushort plxtPwrRecSelected, out ushort plxtPwrRecMax, - out ushort plxtPwrRecLast, dev.Timeout, out _); + out ushort plxtPwrRecLast, + dev.Timeout, + out _); if(!plxtSense) { @@ -440,13 +469,11 @@ public partial class DeviceInfo plxtSense = dev.PlextorGetGigaRec(out plxtBuf, out senseBuf, dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.GigaRec = true; + if(!plxtSense) PlextorFeatures.GigaRec = true; plxtSense = dev.PlextorGetSecuRec(out plxtBuf, out senseBuf, dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.SecuRec = true; + if(!plxtSense) PlextorFeatures.SecuRec = true; plxtSense = dev.PlextorGetSpeedRead(out plxtBuf, out senseBuf, dev.Timeout, out _); @@ -454,8 +481,7 @@ public partial class DeviceInfo { PlextorFeatures.SpeedRead = true; - if((plxtBuf[2] & 0x01) == 0x01) - PlextorFeatures.SpeedReadEnabled = true; + if((plxtBuf[2] & 0x01) == 0x01) PlextorFeatures.SpeedReadEnabled = true; } plxtSense = dev.PlextorGetHiding(out plxtBuf, out senseBuf, dev.Timeout, out _); @@ -464,46 +490,47 @@ public partial class DeviceInfo { PlextorFeatures.Hiding = true; - if((plxtBuf[2] & 0x02) == 0x02) - PlextorFeatures.HidesRecordables = true; + if((plxtBuf[2] & 0x02) == 0x02) PlextorFeatures.HidesRecordables = true; - if((plxtBuf[2] & 0x01) == 0x01) - PlextorFeatures.HidesSessions = true; + if((plxtBuf[2] & 0x01) == 0x01) PlextorFeatures.HidesSessions = true; } plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.VariRec = true; + if(!plxtSense) PlextorFeatures.VariRec = true; if(plxtDvd) { plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.VariRecDvd = true; + if(!plxtSense) PlextorFeatures.VariRecDvd = true; - plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, false, dev.Timeout, + plxtSense = dev.PlextorGetBitsetting(out plxtBuf, + out senseBuf, + false, + dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.BitSetting = true; + if(!plxtSense) PlextorFeatures.BitSetting = true; - plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, true, dev.Timeout, + plxtSense = dev.PlextorGetBitsetting(out plxtBuf, + out senseBuf, + true, + dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.BitSettingDl = true; + if(!plxtSense) PlextorFeatures.BitSettingDl = true; - plxtSense = dev.PlextorGetTestWriteDvdPlus(out plxtBuf, out senseBuf, dev.Timeout, + plxtSense = dev.PlextorGetTestWriteDvdPlus(out plxtBuf, + out senseBuf, + dev.Timeout, out _); - if(!plxtSense) - PlextorFeatures.DvdPlusWriteTest = true; + if(!plxtSense) PlextorFeatures.DvdPlusWriteTest = true; } } - #endregion Plextor +#endregion Plextor if(ScsiInquiry.Value.KreonPresent) { @@ -557,23 +584,19 @@ public partial class DeviceInfo { bool sense = dev.ReadCid(out byte[] mmcBuf, out _, dev.Timeout, out _); - if(!sense) - CID = mmcBuf; + if(!sense) CID = mmcBuf; sense = dev.ReadCsd(out mmcBuf, out _, dev.Timeout, out _); - if(!sense) - CSD = mmcBuf; + if(!sense) CSD = mmcBuf; sense = dev.ReadOcr(out mmcBuf, out _, dev.Timeout, out _); - if(!sense) - OCR = mmcBuf; + if(!sense) OCR = mmcBuf; sense = dev.ReadExtendedCsd(out mmcBuf, out _, dev.Timeout, out _); - if(!sense && !ArrayHelpers.ArrayIsNullOrEmpty(mmcBuf)) - ExtendedCSD = mmcBuf; + if(!sense && !ArrayHelpers.ArrayIsNullOrEmpty(mmcBuf)) ExtendedCSD = mmcBuf; } break; @@ -581,23 +604,19 @@ public partial class DeviceInfo { bool sense = dev.ReadCid(out byte[] sdBuf, out _, dev.Timeout, out _); - if(!sense) - CID = sdBuf; + if(!sense) CID = sdBuf; sense = dev.ReadCsd(out sdBuf, out _, dev.Timeout, out _); - if(!sense) - CSD = sdBuf; + if(!sense) CSD = sdBuf; sense = dev.ReadSdocr(out sdBuf, out _, dev.Timeout, out _); - if(!sense) - OCR = sdBuf; + if(!sense) OCR = sdBuf; sense = dev.ReadScr(out sdBuf, out _, dev.Timeout, out _); - if(!sense) - SCR = sdBuf; + if(!sense) SCR = sdBuf; } break; diff --git a/Aaru.Core/Devices/Reader.cs b/Aaru.Core/Devices/Reader.cs index 698598894..507e0e4df 100644 --- a/Aaru.Core/Devices/Reader.cs +++ b/Aaru.Core/Devices/Reader.cs @@ -62,8 +62,7 @@ sealed partial class Reader case DeviceType.ATA: Identify.IdentifyDevice? ataIdNullable = Identify.Decode(identification); - if(ataIdNullable.HasValue) - _ataId = ataIdNullable.Value; + if(ataIdNullable.HasValue) _ataId = ataIdNullable.Value; break; case DeviceType.NVMe: diff --git a/Aaru.Core/Devices/ReaderATA.cs b/Aaru.Core/Devices/ReaderATA.cs index f4482f375..9bcffe0a1 100644 --- a/Aaru.Core/Devices/ReaderATA.cs +++ b/Aaru.Core/Devices/ReaderATA.cs @@ -61,8 +61,7 @@ sealed partial class Reader void GetDeviceChs() { - if(_dev.Type != DeviceType.ATA) - return; + if(_dev.Type != DeviceType.ATA) return; if(_ataId.CurrentCylinders > 0 && _ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 }) { @@ -94,8 +93,7 @@ sealed partial class Reader IsLba = true; } - if(!_ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48)) - return Blocks; + if(!_ataId.CommandSet2.HasFlag(Identify.CommandSetBit2.LBA48)) return Blocks; Blocks = _ataId.LBA48Sectors; IsLba = true; @@ -105,8 +103,7 @@ sealed partial class Reader bool AtaFindReadCommand() { - if(Blocks == 0) - GetDeviceBlocks(); + if(Blocks == 0) GetDeviceBlocks(); bool sense; var tries = 0; @@ -311,15 +308,12 @@ sealed partial class Reader } } - if(error) - BlocksToRead /= 2; + if(error) BlocksToRead /= 2; - if(!error || BlocksToRead == 1) - break; + if(!error || BlocksToRead == 1) break; } - if(!error || !IsLba) - return false; + if(!error || !IsLba) return false; BlocksToRead = 1; @@ -347,8 +341,7 @@ sealed partial class Reader status = errorLba48.Status; errorByte = errorLba48.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba48); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba48); } else if(_ataReadLba48) { @@ -357,8 +350,7 @@ sealed partial class Reader status = errorLba48.Status; errorByte = errorLba48.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba48); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba48); } else if(_ataReadDmaRetryLba) { @@ -368,8 +360,7 @@ sealed partial class Reader status = errorLba.Status; errorByte = errorLba.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); } else if(_ataReadDmaLba) { @@ -379,8 +370,7 @@ sealed partial class Reader status = errorLba.Status; errorByte = errorLba.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); } else if(_ataReadRetryLba) { @@ -389,8 +379,7 @@ sealed partial class Reader status = errorLba.Status; errorByte = errorLba.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); } else if(_ataReadLba) { @@ -399,15 +388,12 @@ sealed partial class Reader status = errorLba.Status; errorByte = errorLba.Error; - if(error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); + if(error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, errorLba); } - if(!error) - return false; + if(!error) return false; - if((status & 0x04) == 0x04) - recoveredError = true; + if((status & 0x04) == 0x04) recoveredError = true; AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.ATA_ERROR_0_STATUS_1, errorByte, status); @@ -433,8 +419,7 @@ sealed partial class Reader status = errorChs.Status; errorByte = errorChs.Error; - if(error) - _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); + if(error) _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); } else if(_ataReadDma) { @@ -444,8 +429,7 @@ sealed partial class Reader status = errorChs.Status; errorByte = errorChs.Error; - if(error) - _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); + if(error) _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); } else if(_ataReadRetry) { @@ -454,8 +438,7 @@ sealed partial class Reader status = errorChs.Status; errorByte = errorChs.Error; - if(error) - _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); + if(error) _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); } else if(_ataRead) { @@ -464,15 +447,12 @@ sealed partial class Reader status = errorChs.Status; errorByte = errorChs.Error; - if(error) - _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); + if(error) _errorLog?.WriteLine(cylinder, head, sector, _dev.Error, _dev.LastError, errorChs); } - if(!error) - return false; + if(!error) return false; - if((status & 0x04) == 0x04) - recoveredError = true; + if((status & 0x04) == 0x04) recoveredError = true; AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.ATA_ERROR_0_STATUS_1, errorByte, status); diff --git a/Aaru.Core/Devices/ReaderSCSI.cs b/Aaru.Core/Devices/ReaderSCSI.cs index 43df1f1b7..23daa0d14 100644 --- a/Aaru.Core/Devices/ReaderSCSI.cs +++ b/Aaru.Core/Devices/ReaderSCSI.cs @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Linq; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Console; using Aaru.Decoders.SCSI; @@ -40,8 +39,6 @@ namespace Aaru.Core.Devices; sealed partial class Reader { - // TODO: Raw reading - public bool HldtstReadRaw; bool _plextorReadRaw; bool _read10; bool _read12; @@ -55,15 +52,16 @@ sealed partial class Reader bool _syqReadLong10; bool _syqReadLong6; + // TODO: Raw reading + public bool HldtstReadRaw; + ulong ScsiGetBlocks() => ScsiGetBlockSize() ? 0 : Blocks; bool ScsiFindReadCommand() { - if(Blocks == 0) - GetDeviceBlocks(); + if(Blocks == 0) GetDeviceBlocks(); - if(Blocks == 0) - return true; + if(Blocks == 0) return true; byte[] senseBuf; var tries = 0; @@ -72,11 +70,21 @@ sealed partial class Reader if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice) { - mediumScan = !_dev.MediumScan(out _, true, false, false, false, false, lba, 1, (uint)Blocks, - out uint foundLba, out _, _timeout, out _); + mediumScan = !_dev.MediumScan(out _, + true, + false, + false, + false, + false, + lba, + 1, + (uint)Blocks, + out uint foundLba, + out _, + _timeout, + out _); - if(mediumScan) - lba = foundLba; + if(mediumScan) lba = foundLba; } var rnd = new Random(); @@ -85,27 +93,70 @@ sealed partial class Reader { _read6 = !_dev.Read6(out _, out senseBuf, lba, LogicalBlockSize, _timeout, out _); - _read10 = !_dev.Read10(out _, out senseBuf, 0, false, false, false, false, lba, LogicalBlockSize, 0, 1, - _timeout, out _); + _read10 = !_dev.Read10(out _, + out senseBuf, + 0, + false, + false, + false, + false, + lba, + LogicalBlockSize, + 0, + 1, + _timeout, + out _); - _read12 = !_dev.Read12(out _, out senseBuf, 0, false, false, false, false, lba, LogicalBlockSize, 0, 1, - false, _timeout, out _); + _read12 = !_dev.Read12(out _, + out senseBuf, + 0, + false, + false, + false, + false, + lba, + LogicalBlockSize, + 0, + 1, + false, + _timeout, + out _); - _read16 = !_dev.Read16(out _, out senseBuf, 0, false, false, false, lba, LogicalBlockSize, 0, 1, false, - _timeout, out _); + _read16 = !_dev.Read16(out _, + out senseBuf, + 0, + false, + false, + false, + lba, + LogicalBlockSize, + 0, + 1, + false, + _timeout, + out _); - if(_read6 || _read10 || _read12 || _read16) - break; + if(_read6 || _read10 || _read12 || _read16) break; lba = (uint)rnd.Next(1, (int)Blocks); if(mediumScan) { - mediumScan = !_dev.MediumScan(out _, true, false, false, false, false, lba, 1, (uint)Blocks, - out uint foundLba, out _, _timeout, out _); + mediumScan = !_dev.MediumScan(out _, + true, + false, + false, + false, + false, + lba, + 1, + (uint)Blocks, + out uint foundLba, + out _, + _timeout, + out _); - if(mediumScan) - lba = foundLba; + if(mediumScan) lba = foundLba; } tries++; @@ -129,23 +180,25 @@ sealed partial class Reader } case true when !_read10 && !_read12 && !_read16 && Blocks > 0x001FFFFF + 1: ErrorMessage = - string.Format(Localization.Core.Device_only_supports_SCSI_READ_6_but_has_more_than_0_blocks_1_blocks_total, - 0x001FFFFF + 1, Blocks); + string.Format(Localization.Core + .Device_only_supports_SCSI_READ_6_but_has_more_than_0_blocks_1_blocks_total, + 0x001FFFFF + 1, + Blocks); return true; } - if(Blocks > 0x001FFFFF + 1) - _read6 = false; + if(Blocks > 0x001FFFFF + 1) _read6 = false; - if(_read10) - _read12 = false; + if(_read10) _read12 = false; if(!_read16 && Blocks > 0xFFFFFFFF + (long)1) { ErrorMessage = - string.Format(Localization.Core.Device_only_supports_SCSI_READ_10_but_has_more_than_0_blocks_1_blocks_total, - 0xFFFFFFFF + (long)1, Blocks); + string.Format(Localization.Core + .Device_only_supports_SCSI_READ_10_but_has_more_than_0_blocks_1_blocks_total, + 0xFFFFFFFF + (long)1, + Blocks); return true; } @@ -216,8 +269,14 @@ sealed partial class Reader { LongBlockSize = 0xFFFF - (information & 0xFFFF); - _readLong10 = !_dev.ReadLong10(out _, out senseBuf, false, false, 0, (ushort)LongBlockSize, - _timeout, out _); + _readLong10 = !_dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + (ushort)LongBlockSize, + _timeout, + out _); } } } @@ -229,16 +288,16 @@ sealed partial class Reader case 512: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 514, + { + // Long sector sizes for floppies + 514, - // Long sector sizes for SuperDisk - 536, 558, + // Long sector sizes for SuperDisk + 536, 558, - // Long sector sizes for 512-byte magneto-opticals - 600, 610, 630 - }) + // Long sector sizes for 512-byte magneto-opticals + 600, 610, 630 + }) { testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); @@ -251,11 +310,16 @@ sealed partial class Reader break; } - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, + testSense = _dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + testSize, + _timeout, out _); - if(testSense || _dev.Error) - continue; + if(testSense || _dev.Error) continue; _readLong10 = true; LongBlockSize = testSize; @@ -269,13 +333,13 @@ sealed partial class Reader case 1024: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 1026, + { + // Long sector sizes for floppies + 1026, - // Long sector sizes for 1024-byte magneto-opticals - 1200 - }) + // Long sector sizes for 1024-byte magneto-opticals + 1200 + }) { testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); @@ -288,11 +352,16 @@ sealed partial class Reader break; } - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, + testSense = _dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + testSize, + _timeout, out _); - if(testSense || _dev.Error) - continue; + if(testSense || _dev.Error) continue; _readLong10 = true; LongBlockSize = testSize; @@ -315,7 +384,13 @@ sealed partial class Reader } else { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 2380, _timeout, + testSense = _dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + 2380, + _timeout, out _); if(!testSense && !_dev.Error) @@ -340,7 +415,13 @@ sealed partial class Reader } else { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 4760, _timeout, + testSense = _dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + 4760, + _timeout, out _); if(!testSense && !_dev.Error) @@ -365,7 +446,13 @@ sealed partial class Reader } else { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 9424, _timeout, + testSense = _dev.ReadLong10(out _, + out senseBuf, + false, + false, + 0, + 9424, + _timeout, out _); if(!testSense && !_dev.Error) @@ -435,15 +522,15 @@ sealed partial class Reader uint information = decSense?.Fixed?.Information ?? 0; if(decSense.Value.Descriptor.HasValue && - decSense.Value.Descriptor.Value.Descriptors. - TryGetValue(0, out byte[] desc00)) + decSense.Value.Descriptor.Value.Descriptors + .TryGetValue(0, out byte[] desc00)) { valid = true; ili = true; information = (uint)Sense.DecodeDescriptor00(desc00); - if(decSense.Value.Descriptor.Value.Descriptors. - TryGetValue(4, out byte[] desc04)) + if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, + out byte[] desc04)) Sense.DecodeDescriptor04(desc04, out _, out _, out ili); } @@ -452,7 +539,11 @@ sealed partial class Reader LongBlockSize = 0xFFFF - (information & 0xFFFF); _syqReadLong6 = - !_dev.SyQuestReadLong6(out _, out senseBuf, 0, LongBlockSize, _timeout, + !_dev.SyQuestReadLong6(out _, + out senseBuf, + 0, + LongBlockSize, + _timeout, out _); } } @@ -521,8 +612,7 @@ sealed partial class Reader AaruConsole.WriteLine(Localization.Core.Using_SyQuest_READ_LONG_6_command); else if(HldtstReadRaw) AaruConsole.WriteLine(Localization.Core.Using_HL_DT_ST_raw_DVD_reading); - else if(_plextorReadRaw) - AaruConsole.WriteLine(Localization.Core.Using_Plextor_raw_DVD_reading); + else if(_plextorReadRaw) AaruConsole.WriteLine(Localization.Core.Using_Plextor_raw_DVD_reading); } else if(_read6) AaruConsole.WriteLine(Localization.Core.Using_SCSI_READ_6_command); @@ -530,8 +620,7 @@ sealed partial class Reader AaruConsole.WriteLine(Localization.Core.Using_SCSI_READ_10_command); else if(_read12) AaruConsole.WriteLine(Localization.Core.Using_SCSI_READ_12_command); - else if(_read16) - AaruConsole.WriteLine(Localization.Core.Using_SCSI_READ_16_command); + else if(_read16) AaruConsole.WriteLine(Localization.Core.Using_SCSI_READ_16_command); return false; } @@ -586,47 +675,73 @@ sealed partial class Reader while(true) { if(HldtstReadRaw) - { BlocksToRead = 1; - } else if(_read6) { _dev.Read6(out _, out _, 0, LogicalBlockSize, (byte)BlocksToRead, _timeout, out _); - if(_dev.Error) - BlocksToRead /= 2; + if(_dev.Error) BlocksToRead /= 2; } else if(_read10) { - _dev.Read10(out _, out _, 0, false, true, false, false, 0, LogicalBlockSize, 0, (ushort)BlocksToRead, - _timeout, out _); + _dev.Read10(out _, + out _, + 0, + false, + true, + false, + false, + 0, + LogicalBlockSize, + 0, + (ushort)BlocksToRead, + _timeout, + out _); - if(_dev.Error) - BlocksToRead /= 2; + if(_dev.Error) BlocksToRead /= 2; } else if(_read12) { - _dev.Read12(out _, out _, 0, false, false, false, false, 0, LogicalBlockSize, 0, BlocksToRead, false, - _timeout, out _); + _dev.Read12(out _, + out _, + 0, + false, + false, + false, + false, + 0, + LogicalBlockSize, + 0, + BlocksToRead, + false, + _timeout, + out _); - if(_dev.Error) - BlocksToRead /= 2; + if(_dev.Error) BlocksToRead /= 2; } else if(_read16) { - _dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0, BlocksToRead, false, _timeout, + _dev.Read16(out _, + out _, + 0, + false, + true, + false, + 0, + LogicalBlockSize, + 0, + BlocksToRead, + false, + _timeout, out _); - if(_dev.Error) - BlocksToRead /= 2; + if(_dev.Error) BlocksToRead /= 2; } - if(!_dev.Error || BlocksToRead == 1) - break; + if(!_dev.Error || BlocksToRead == 1) break; } - if(!_dev.Error) - return false; + if(!_dev.Error) return false; // Magneto-opticals may have LBA 0 empty, we can hard code the value to a safe one if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice) @@ -660,30 +775,61 @@ sealed partial class Reader 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); + 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, + 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, + sense = _dev.SyQuestReadLong6(out buffer, + out senseBuf, + (uint)block, + LongBlockSize, + _timeout, out duration); } else if(HldtstReadRaw) { // We need to fill the buffer before reading it with the HL-DT-ST command. We don't care about sense, // because the data can be wrong anyway, so we need to check the buffer data instead. - _dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)(block), LogicalBlockSize, 0, - 16, false, _timeout, out duration); + _dev.Read12(out buffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)block, + LogicalBlockSize, + 0, + 16, + false, + _timeout, + out duration); + sense = _dev.HlDtStReadRawDvd(out buffer, out senseBuf, (uint)block, count, _timeout, out duration); } else if(_plextorReadRaw) { - sense = _dev.PlextorReadRawDvd(out buffer, out senseBuf, (uint)block, LongBlockSize, _timeout, + sense = _dev.PlextorReadRawDvd(out buffer, + out senseBuf, + (uint)block, + LongBlockSize, + _timeout, out duration); } else @@ -693,33 +839,70 @@ sealed partial class Reader { if(_read6) { - sense = _dev.Read6(out buffer, out senseBuf, (uint)block, LogicalBlockSize, (byte)count, _timeout, + sense = _dev.Read6(out buffer, + out senseBuf, + (uint)block, + LogicalBlockSize, + (byte)count, + _timeout, out duration); } else if(_read10) { - sense = _dev.Read10(out buffer, out senseBuf, 0, false, false, false, false, (uint)block, - LogicalBlockSize, 0, (ushort)count, _timeout, out duration); + sense = _dev.Read10(out buffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)block, + LogicalBlockSize, + 0, + (ushort)count, + _timeout, + out duration); } else if(_read12) { - sense = _dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)block, - LogicalBlockSize, 0, count, false, _timeout, out duration); + sense = _dev.Read12(out buffer, + out senseBuf, + 0, + false, + false, + false, + false, + (uint)block, + LogicalBlockSize, + 0, + count, + false, + _timeout, + out duration); } else if(_read16) { - sense = _dev.Read16(out buffer, out senseBuf, 0, false, false, false, block, LogicalBlockSize, 0, count, - false, _timeout, out duration); + sense = _dev.Read16(out buffer, + out senseBuf, + 0, + false, + false, + false, + block, + LogicalBlockSize, + 0, + count, + false, + _timeout, + out duration); } else return true; } - if(sense || _dev.Error) - _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, senseBuf); + if(sense || _dev.Error) _errorLog?.WriteLine(block, _dev.Error, _dev.LastError, senseBuf); - if(!sense && !_dev.Error) - return false; + if(!sense && !_dev.Error) return false; recoveredError = Sense.Decode(senseBuf)?.SenseKey == SenseKeys.RecoveredError; @@ -736,9 +919,8 @@ sealed partial class Reader duration = 0; if(_seek6) - sense = _dev.Seek6(out _, (uint)block, _timeout, out duration); - else if(_seek10) - sense = _dev.Seek10(out _, (uint)block, _timeout, out duration); + sense = _dev.Seek6(out _, (uint)block, _timeout, out duration); + else if(_seek10) sense = _dev.Seek10(out _, (uint)block, _timeout, out duration); return sense; } diff --git a/Aaru.Core/Devices/Report/ATA.cs b/Aaru.Core/Devices/Report/ATA.cs index 834e68ec1..804ea44f3 100644 --- a/Aaru.Core/Devices/Report/ATA.cs +++ b/Aaru.Core/Devices/Report/ATA.cs @@ -73,11 +73,9 @@ public sealed partial class DeviceReport { Identify.IdentifyDevice ataId = mediaTest.IdentifyDevice.Value; - if(ataId.UnformattedBPT != 0) - mediaTest.UnformattedBPT = ataId.UnformattedBPT; + if(ataId.UnformattedBPT != 0) mediaTest.UnformattedBPT = ataId.UnformattedBPT; - if(ataId.UnformattedBPS != 0) - mediaTest.UnformattedBPS = ataId.UnformattedBPS; + if(ataId.UnformattedBPS != 0) mediaTest.UnformattedBPS = ataId.UnformattedBPS; if(ataId.Cylinders > 0 && ataId is { Heads: > 0, SectorsPerTrack: > 0 }) { @@ -194,8 +192,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadSectorsData = readBuf; @@ -208,8 +210,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadSectorsRetryData = readBuf; @@ -222,8 +228,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDma = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadDmaData = readBuf; @@ -236,8 +246,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadDmaRetryData = readBuf; @@ -249,8 +263,11 @@ public sealed partial class DeviceReport mediaTest.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense, - errorChs.Status, errorChs.Error); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2, + sense, + errorChs.Status, + errorChs.Error); Spectre.ProgressSingleSpinner(ctx => { @@ -261,8 +278,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLbaData = readBuf; @@ -275,8 +296,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadRetryLbaData = readBuf; @@ -289,8 +314,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadDmaLbaData = readBuf; @@ -303,8 +332,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadDmaRetryLbaData = readBuf; @@ -316,8 +349,11 @@ public sealed partial class DeviceReport mediaTest.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense, - errorChs.Status, errorChs.Error); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2, + sense, + errorChs.Status, + errorChs.Error); Spectre.ProgressSingleSpinner(ctx => { @@ -328,8 +364,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLba48Data = readBuf; @@ -342,8 +382,12 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadDmaLba48Data = readBuf; @@ -370,8 +414,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_in_CHS_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, + out errorChs, + false, + 0, + 0, + 1, + mediaTest.LongBlockSize ?? 0, + _dev.Timeout, + out _); }); mediaTest.SupportsReadLong = !sense && @@ -380,8 +431,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLongData = readBuf; @@ -389,8 +444,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_RETRY_in_CHS_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, + out errorChs, + true, + 0, + 0, + 1, + mediaTest.LongBlockSize ?? 0, + _dev.Timeout, + out _); }); mediaTest.SupportsReadLongRetry = !sense && @@ -399,8 +461,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLongRetryData = readBuf; @@ -408,7 +474,12 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_in_LBA_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout, + sense = _dev.ReadLong(out readBuf, + out errorLba, + false, + 0, + mediaTest.LongBlockSize ?? 0, + _dev.Timeout, out _); }); @@ -418,8 +489,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLongLbaData = readBuf; @@ -427,7 +502,12 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_RETRY_in_LBA_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout, + sense = _dev.ReadLong(out readBuf, + out errorLba, + true, + 0, + mediaTest.LongBlockSize ?? 0, + _dev.Timeout, out _); }); @@ -437,8 +517,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); mediaTest.ReadLongRetryLbaData = readBuf; } @@ -458,11 +542,9 @@ public sealed partial class DeviceReport AtaErrorRegistersLba48 errorLba48 = new(); var capabilities = new TestedMedia(); - if(ataId.UnformattedBPT != 0) - capabilities.UnformattedBPT = ataId.UnformattedBPT; + if(ataId.UnformattedBPT != 0) capabilities.UnformattedBPT = ataId.UnformattedBPT; - if(ataId.UnformattedBPS != 0) - capabilities.UnformattedBPS = ataId.UnformattedBPS; + if(ataId.UnformattedBPS != 0) capabilities.UnformattedBPS = ataId.UnformattedBPS; if(ataId.Cylinders > 0 && ataId is { Heads: > 0, SectorsPerTrack: > 0 }) { @@ -560,8 +642,7 @@ public sealed partial class DeviceReport { capabilities.CanReadMediaSerial = true; - if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer)) - capabilities.Manufacturer = ataId.MediaManufacturer; + if(!string.IsNullOrWhiteSpace(ataId.MediaManufacturer)) capabilities.Manufacturer = ataId.MediaManufacturer; } const ulong checkCorrectRead = 0; @@ -575,8 +656,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadSectorsData = readBuf; @@ -589,8 +674,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadSectorsRetryData = readBuf; @@ -603,8 +692,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadDma = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadDmaData = readBuf; @@ -617,8 +710,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadDmaRetryData = readBuf; @@ -630,7 +727,10 @@ public sealed partial class DeviceReport capabilities.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense, errorChs.Status, + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2, + sense, + errorChs.Status, errorChs.Error); Spectre.ProgressSingleSpinner(ctx => @@ -642,8 +742,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadLbaData = readBuf; @@ -656,8 +760,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadRetryLbaData = readBuf; @@ -670,8 +778,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadDmaLbaData = readBuf; @@ -684,8 +796,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadDmaRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadDmaRetryLbaData = readBuf; @@ -697,7 +813,10 @@ public sealed partial class DeviceReport capabilities.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense, errorLba.Status, + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2, + sense, + errorLba.Status, errorLba.Error); Spectre.ProgressSingleSpinner(ctx => @@ -709,8 +828,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba48.Status, errorLba48.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba48.Status, + errorLba48.Error, + readBuf.Length); capabilities.ReadLba48Data = readBuf; @@ -723,8 +846,12 @@ public sealed partial class DeviceReport capabilities.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba48.Status, errorLba48.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba48.Status, + errorLba48.Error, + readBuf.Length); capabilities.ReadDmaLba48Data = readBuf; @@ -751,8 +878,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_in_CHS_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, capabilities.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, + out errorChs, + false, + 0, + 0, + 1, + capabilities.LongBlockSize ?? 0, + _dev.Timeout, + out _); }); capabilities.SupportsReadLong = !sense && @@ -761,8 +895,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadLongData = readBuf; @@ -770,8 +908,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_RETRY_in_CHS_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, capabilities.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, + out errorChs, + true, + 0, + 0, + 1, + capabilities.LongBlockSize ?? 0, + _dev.Timeout, + out _); }); capabilities.SupportsReadLongRetry = !sense && @@ -780,8 +925,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorChs.Status, + errorChs.Error, + readBuf.Length); capabilities.ReadLongRetryData = readBuf; @@ -789,7 +938,12 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_in_LBA_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, capabilities.LongBlockSize ?? 0, _dev.Timeout, + sense = _dev.ReadLong(out readBuf, + out errorLba, + false, + 0, + capabilities.LongBlockSize ?? 0, + _dev.Timeout, out _); }); @@ -799,8 +953,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadLongLbaData = readBuf; @@ -808,7 +966,12 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_READ_LONG_RETRY_in_LBA_mode).IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, capabilities.LongBlockSize ?? 0, _dev.Timeout, + sense = _dev.ReadLong(out readBuf, + out errorLba, + true, + 0, + capabilities.LongBlockSize ?? 0, + _dev.Timeout, out _); }); @@ -818,8 +981,12 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense, - errorLba.Status, errorLba.Error, readBuf.Length); + AaruConsole.DebugWriteLine(ATA_MODULE_NAME, + Localization.Core.Sense_0_Status_1_Error_2_Length_3, + sense, + errorLba.Status, + errorLba.Error, + readBuf.Length); capabilities.ReadLongRetryLbaData = readBuf; diff --git a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs index 6218ffd2e..1b63ee829 100644 --- a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs +++ b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs @@ -55,8 +55,8 @@ public sealed partial class DeviceReport while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N) { - AaruConsole.Write(Localization.Core. - Have_you_previously_tried_with_a_GD_ROM_disc_and_did_the_computer_hang_or_crash_Q); + AaruConsole.Write(Localization.Core + .Have_you_previously_tried_with_a_GD_ROM_disc_and_did_the_computer_hang_or_crash_Q); pressedKey = System.Console.ReadKey(); AaruConsole.WriteLine(); @@ -90,13 +90,11 @@ public sealed partial class DeviceReport retries++; sense = _dev.ScsiTestUnitReady(out senseBuffer, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; DecodedSense? decodedSense = Sense.Decode(senseBuffer); - if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) - break; + if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) break; Thread.Sleep(2000); } while(retries < 25); @@ -210,13 +208,11 @@ public sealed partial class DeviceReport retries++; sense = _dev.ReadRawToc(out buffer, out senseBuffer, 1, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; DecodedSense? decodedSense = Sense.Decode(senseBuffer); - if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) - break; + if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) break; } while(retries < 25); if(sense) @@ -257,15 +253,14 @@ public sealed partial class DeviceReport return; } - if(newLeadOutTrack.PMIN >= 0xA0 && !tocIsNotBcd) - newLeadOutTrack.PMIN -= 0x90; + if(newLeadOutTrack.PMIN >= 0xA0 && !tocIsNotBcd) newLeadOutTrack.PMIN -= 0x90; if(newLeadOutTrack.PMIN != leadOutTrack.PMIN || newLeadOutTrack.PSEC != leadOutTrack.PSEC || newLeadOutTrack.PFRAME != leadOutTrack.PFRAME) { - AaruConsole.WriteLine(Localization.Core. - Lead_out_has_changed_this_drive_does_not_support_hot_swapping_discs); + AaruConsole.WriteLine(Localization.Core + .Lead_out_has_changed_this_drive_does_not_support_hot_swapping_discs); report.GdRomSwapDiscCapabilities.RecognizedSwapDisc = false; report.GdRomSwapDiscCapabilities.TestCrashed = false; @@ -277,11 +272,22 @@ public sealed partial class DeviceReport AaruConsole.Write(Localization.Core.Reading_LBA_zero); - report.GdRomSwapDiscCapabilities.Lba0Readable = !_dev.ReadCd(out byte[] lba0Buffer, out byte[] lba0Sense, 0, - 2352, 1, MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + report.GdRomSwapDiscCapabilities.Lba0Readable = !_dev.ReadCd(out byte[] lba0Buffer, + out byte[] lba0Sense, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba0Data = lba0Buffer; report.GdRomSwapDiscCapabilities.Lba0Sense = lba0Sense; @@ -294,11 +300,21 @@ public sealed partial class DeviceReport AaruConsole.Write(Localization.Core.Reading_LBA_zero_as_audio_scrambled); report.GdRomSwapDiscCapabilities.Lba0ScrambledReadable = !_dev.ReadCd(out byte[] lba0ScrambledBuffer, - out byte[] lba0ScrambledSense, 0, 2352, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba0ScrambledSense, + 0, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba0ScrambledData = lba0ScrambledBuffer; report.GdRomSwapDiscCapabilities.Lba0ScrambledSense = lba0ScrambledSense; @@ -315,11 +331,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba100000AudioReadable = !_dev.ReadCd(out byte[] lba100000AudioBuffer, out byte[] lba100000AudioSenseBuffer, - 100000, 2352, cluster, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + 100000, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba100000AudioData = lba100000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba100000AudioSense = lba100000AudioSenseBuffer; @@ -329,11 +354,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba100000AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -349,10 +372,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba50000AudioReadable = !_dev.ReadCd(out byte[] lba50000AudioBuffer, out byte[] lba50000AudioSenseBuffer, - 50000, 2352, cluster, MmcSectorTypes.Cdda, - false, false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + 50000, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000AudioData = lba50000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba50000AudioSense = lba50000AudioSenseBuffer; @@ -361,11 +394,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba50000AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -381,11 +412,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba450000AudioReadable = !_dev.ReadCd(out byte[] lba450000AudioBuffer, out byte[] lba450000AudioSenseBuffer, - 450000, 2352, cluster, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + 450000, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba450000AudioData = lba450000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba450000AudioSense = lba450000AudioSenseBuffer; @@ -395,11 +435,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba450000AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -415,11 +453,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba400000AudioReadable = !_dev.ReadCd(out byte[] lba400000AudioBuffer, out byte[] lba400000AudioSenseBuffer, - 400000, 2352, cluster, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + 400000, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba400000AudioData = lba400000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba400000AudioSense = lba400000AudioSenseBuffer; @@ -429,11 +476,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba400000AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -449,10 +494,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba45000AudioReadable = !_dev.ReadCd(out byte[] lba45000AudioBuffer, out byte[] lba45000AudioSenseBuffer, - 45000, 2352, cluster, MmcSectorTypes.Cdda, - false, false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + 45000, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000AudioData = lba45000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba45000AudioSense = lba45000AudioSenseBuffer; @@ -461,11 +516,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba45000AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -481,10 +534,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba44990AudioReadable = !_dev.ReadCd(out byte[] lba44990AudioBuffer, out byte[] lba44990AudioSenseBuffer, - 44990, 2352, cluster, MmcSectorTypes.Cdda, - false, false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + 44990, + 2352, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990AudioData = lba44990AudioBuffer; report.GdRomSwapDiscCapabilities.Lba44990AudioSense = lba44990AudioSenseBuffer; @@ -493,11 +556,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba44990AudioReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990AudioReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990AudioReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -513,11 +574,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable = !_dev.ReadCd(out byte[] lba100000AudioPqBuffer, out byte[] lba100000AudioPqSenseBuffer, - 100000, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 100000, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000AudioPqData = lba100000AudioPqBuffer; @@ -528,11 +597,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -548,11 +615,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable = !_dev.ReadCd(out byte[] lba50000AudioPqBuffer, out byte[] lba50000AudioPqSenseBuffer, - 50000, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + 50000, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000AudioPqData = lba50000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba50000AudioPqSense = lba50000AudioPqSenseBuffer; @@ -562,11 +638,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -582,11 +656,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable = !_dev.ReadCd(out byte[] lba450000AudioPqBuffer, out byte[] lba450000AudioPqSenseBuffer, - 450000, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 450000, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000AudioPqData = lba450000AudioPqBuffer; @@ -597,11 +679,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -617,11 +697,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable = !_dev.ReadCd(out byte[] lba400000AudioPqBuffer, out byte[] lba400000AudioPqSenseBuffer, - 400000, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 400000, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000AudioPqData = lba400000AudioPqBuffer; @@ -632,11 +720,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -652,11 +738,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable = !_dev.ReadCd(out byte[] lba45000AudioPqBuffer, out byte[] lba45000AudioPqSenseBuffer, - 45000, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + 45000, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000AudioPqData = lba45000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba45000AudioPqSense = lba45000AudioPqSenseBuffer; @@ -666,11 +761,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -686,11 +779,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable = !_dev.ReadCd(out byte[] lba44990AudioPqBuffer, out byte[] lba44990AudioPqSenseBuffer, - 44990, 2368, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + 44990, + 2368, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990AudioPqData = lba44990AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba44990AudioPqSense = lba44990AudioPqSenseBuffer; @@ -700,11 +802,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990AudioPqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -720,11 +820,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable = !_dev.ReadCd(out byte[] lba100000AudioRwBuffer, out byte[] lba100000AudioRwSenseBuffer, - 100000, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 100000, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000AudioRwData = lba100000AudioRwBuffer; @@ -735,11 +843,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -755,11 +861,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable = !_dev.ReadCd(out byte[] lba50000AudioRwBuffer, out byte[] lba50000AudioRwSenseBuffer, - 50000, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + 50000, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000AudioRwData = lba50000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba50000AudioRwSense = lba50000AudioRwSenseBuffer; @@ -769,11 +884,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -789,11 +902,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable = !_dev.ReadCd(out byte[] lba450000AudioRwBuffer, out byte[] lba450000AudioRwSenseBuffer, - 450000, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 450000, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000AudioRwData = lba450000AudioRwBuffer; @@ -804,11 +925,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -824,11 +943,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable = !_dev.ReadCd(out byte[] lba400000AudioRwBuffer, out byte[] lba400000AudioRwSenseBuffer, - 400000, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 400000, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000AudioRwData = lba400000AudioRwBuffer; @@ -839,11 +966,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -859,11 +984,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable = !_dev.ReadCd(out byte[] lba45000AudioRwBuffer, out byte[] lba45000AudioRwSenseBuffer, - 45000, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + 45000, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000AudioRwData = lba45000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba45000AudioRwSense = lba45000AudioRwSenseBuffer; @@ -873,11 +1007,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -893,11 +1025,20 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable = !_dev.ReadCd(out byte[] lba44990AudioRwBuffer, out byte[] lba44990AudioRwSenseBuffer, - 44990, 2448, cluster, - MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + 44990, + 2448, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990AudioRwData = lba44990AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba44990AudioRwSense = lba44990AudioRwSenseBuffer; @@ -907,11 +1048,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990AudioRwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -926,23 +1065,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba100000Readable = !_dev.ReadCd(out byte[] lba100000Buffer, - out byte[] lba100000SenseBuffer, 100000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba100000SenseBuffer, + 100000, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba100000Data = lba100000Buffer; report.GdRomSwapDiscCapabilities.Lba100000Sense = lba100000SenseBuffer; report.GdRomSwapDiscCapabilities.Lba100000DecodedSense = Sense.PrettifySense(lba100000SenseBuffer); report.GdRomSwapDiscCapabilities.Lba100000ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -957,23 +1103,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba50000Readable = !_dev.ReadCd(out byte[] lba50000Buffer, - out byte[] lba50000SenseBuffer, 50000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba50000SenseBuffer, + 50000, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000Data = lba50000Buffer; report.GdRomSwapDiscCapabilities.Lba50000Sense = lba50000SenseBuffer; report.GdRomSwapDiscCapabilities.Lba50000DecodedSense = Sense.PrettifySense(lba50000SenseBuffer); report.GdRomSwapDiscCapabilities.Lba50000ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -988,23 +1141,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba450000Readable = !_dev.ReadCd(out byte[] lba450000Buffer, - out byte[] lba450000SenseBuffer, 450000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba450000SenseBuffer, + 450000, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba450000Data = lba450000Buffer; report.GdRomSwapDiscCapabilities.Lba450000Sense = lba450000SenseBuffer; report.GdRomSwapDiscCapabilities.Lba450000DecodedSense = Sense.PrettifySense(lba450000SenseBuffer); report.GdRomSwapDiscCapabilities.Lba450000ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1019,23 +1179,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba400000Readable = !_dev.ReadCd(out byte[] lba400000Buffer, - out byte[] lba400000SenseBuffer, 400000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba400000SenseBuffer, + 400000, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba400000Data = lba400000Buffer; report.GdRomSwapDiscCapabilities.Lba400000Sense = lba400000SenseBuffer; report.GdRomSwapDiscCapabilities.Lba400000DecodedSense = Sense.PrettifySense(lba400000SenseBuffer); report.GdRomSwapDiscCapabilities.Lba400000ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1050,23 +1217,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba45000Readable = !_dev.ReadCd(out byte[] lba45000Buffer, - out byte[] lba45000SenseBuffer, 45000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba45000SenseBuffer, + 45000, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000Data = lba45000Buffer; report.GdRomSwapDiscCapabilities.Lba45000Sense = lba45000SenseBuffer; report.GdRomSwapDiscCapabilities.Lba45000DecodedSense = Sense.PrettifySense(lba45000SenseBuffer); report.GdRomSwapDiscCapabilities.Lba45000ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1081,23 +1255,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba44990Readable = !_dev.ReadCd(out byte[] lba44990Buffer, - out byte[] lba44990SenseBuffer, 44990, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba44990SenseBuffer, + 44990, + 2352, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990Data = lba44990Buffer; report.GdRomSwapDiscCapabilities.Lba44990Sense = lba44990SenseBuffer; report.GdRomSwapDiscCapabilities.Lba44990DecodedSense = Sense.PrettifySense(lba44990SenseBuffer); report.GdRomSwapDiscCapabilities.Lba44990ReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990Readable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990Readable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1113,12 +1294,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba100000PqReadable = !_dev.ReadCd(out byte[] lba100000PqBuffer, out byte[] lba100000PqSenseBuffer, - 100000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 100000, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer; @@ -1126,11 +1314,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba100000PqDecodedSense = Sense.PrettifySense(lba100000PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba100000PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1145,23 +1331,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba50000PqReadable = !_dev.ReadCd(out byte[] lba50000PqBuffer, - out byte[] lba50000PqSenseBuffer, 50000, - 2368, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + out byte[] lba50000PqSenseBuffer, + 50000, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000PqData = lba50000PqBuffer; report.GdRomSwapDiscCapabilities.Lba50000PqSense = lba50000PqSenseBuffer; report.GdRomSwapDiscCapabilities.Lba50000PqDecodedSense = Sense.PrettifySense(lba50000PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba50000PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1177,12 +1370,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba450000PqReadable = !_dev.ReadCd(out byte[] lba450000PqBuffer, out byte[] lba450000PqSenseBuffer, - 450000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 450000, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer; @@ -1190,11 +1390,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba450000PqDecodedSense = Sense.PrettifySense(lba450000PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba450000PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1210,12 +1408,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba400000PqReadable = !_dev.ReadCd(out byte[] lba400000PqBuffer, out byte[] lba400000PqSenseBuffer, - 400000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, + 400000, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer; @@ -1223,11 +1428,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba400000PqDecodedSense = Sense.PrettifySense(lba400000PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba400000PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1242,23 +1445,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba45000PqReadable = !_dev.ReadCd(out byte[] lba45000PqBuffer, - out byte[] lba45000PqSenseBuffer, 45000, - 2368, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + out byte[] lba45000PqSenseBuffer, + 45000, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000PqData = lba45000PqBuffer; report.GdRomSwapDiscCapabilities.Lba45000PqSense = lba45000PqSenseBuffer; report.GdRomSwapDiscCapabilities.Lba45000PqDecodedSense = Sense.PrettifySense(lba45000PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba45000PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1273,23 +1483,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba44990PqReadable = !_dev.ReadCd(out byte[] lba44990PqBuffer, - out byte[] lba44990PqSenseBuffer, 44990, - 2368, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Q16, - _dev.Timeout, out _); + out byte[] lba44990PqSenseBuffer, + 44990, + 2368, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990PqData = lba44990PqBuffer; report.GdRomSwapDiscCapabilities.Lba44990PqSense = lba44990PqSenseBuffer; report.GdRomSwapDiscCapabilities.Lba44990PqDecodedSense = Sense.PrettifySense(lba44990PqSenseBuffer); report.GdRomSwapDiscCapabilities.Lba44990PqReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990PqReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990PqReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1305,12 +1522,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba100000RwReadable = !_dev.ReadCd(out byte[] lba100000RwBuffer, out byte[] lba100000RwSenseBuffer, - 100000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 100000, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer; @@ -1318,11 +1542,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba100000RwDecodedSense = Sense.PrettifySense(lba100000RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba100000RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba100000RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba100000RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1337,23 +1559,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba50000RwReadable = !_dev.ReadCd(out byte[] lba50000RwBuffer, - out byte[] lba50000RwSenseBuffer, 50000, - 2448, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + out byte[] lba50000RwSenseBuffer, + 50000, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba50000RwData = lba50000RwBuffer; report.GdRomSwapDiscCapabilities.Lba50000RwSense = lba50000RwSenseBuffer; report.GdRomSwapDiscCapabilities.Lba50000RwDecodedSense = Sense.PrettifySense(lba50000RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba50000RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba50000RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba50000RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1369,12 +1598,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba450000RwReadable = !_dev.ReadCd(out byte[] lba450000RwBuffer, out byte[] lba450000RwSenseBuffer, - 450000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 450000, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer; @@ -1382,11 +1618,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba450000RwDecodedSense = Sense.PrettifySense(lba450000RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba450000RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba450000RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba450000RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1402,12 +1636,19 @@ public sealed partial class DeviceReport { report.GdRomSwapDiscCapabilities.Lba400000RwReadable = !_dev.ReadCd(out byte[] lba400000RwBuffer, out byte[] lba400000RwSenseBuffer, - 400000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, + 400000, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer; @@ -1415,11 +1656,9 @@ public sealed partial class DeviceReport report.GdRomSwapDiscCapabilities.Lba400000RwDecodedSense = Sense.PrettifySense(lba400000RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba400000RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba400000RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba400000RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1434,23 +1673,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba45000RwReadable = !_dev.ReadCd(out byte[] lba45000RwBuffer, - out byte[] lba45000RwSenseBuffer, 45000, - 2448, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + out byte[] lba45000RwSenseBuffer, + 45000, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba45000RwData = lba45000RwBuffer; report.GdRomSwapDiscCapabilities.Lba45000RwSense = lba45000RwSenseBuffer; report.GdRomSwapDiscCapabilities.Lba45000RwDecodedSense = Sense.PrettifySense(lba45000RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba45000RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba45000RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba45000RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1465,23 +1711,30 @@ public sealed partial class DeviceReport while(true) { report.GdRomSwapDiscCapabilities.Lba44990RwReadable = !_dev.ReadCd(out byte[] lba44990RwBuffer, - out byte[] lba44990RwSenseBuffer, 44990, - 2448, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Raw, - _dev.Timeout, out _); + out byte[] lba44990RwSenseBuffer, + 44990, + 2448, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba44990RwData = lba44990RwBuffer; report.GdRomSwapDiscCapabilities.Lba44990RwSense = lba44990RwSenseBuffer; report.GdRomSwapDiscCapabilities.Lba44990RwDecodedSense = Sense.PrettifySense(lba44990RwSenseBuffer); report.GdRomSwapDiscCapabilities.Lba44990RwReadableCluster = (int)cluster; - if(report.GdRomSwapDiscCapabilities.Lba44990RwReadable) - break; + if(report.GdRomSwapDiscCapabilities.Lba44990RwReadable) break; - if(cluster == 1) - break; + if(cluster == 1) break; cluster /= 2; } @@ -1512,8 +1765,7 @@ public sealed partial class DeviceReport AaruConsole.WriteLine(); } - if(pressedKey.Key == ConsoleKey.N) - return; + if(pressedKey.Key == ConsoleKey.N) return; uint startingSector = 45000; var readAsAudio = false; @@ -1528,9 +1780,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba45000ReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba45000RwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba45000PqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba45000PqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba50000Readable == false) { @@ -1539,9 +1790,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba50000ReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba50000RwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba50000PqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba50000PqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba100000Readable == false) { @@ -1550,9 +1800,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba100000ReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba100000RwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba100000PqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba100000PqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba400000Readable == false) { @@ -1561,9 +1810,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba400000ReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba400000RwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba400000PqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba400000PqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba450000Readable == false) { @@ -1572,9 +1820,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba450000ReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba450000RwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba450000PqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba450000PqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba45000AudioReadable == false) { @@ -1583,9 +1830,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba45000AudioReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba45000AudioRwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba45000AudioPqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba50000AudioReadable == false) { @@ -1594,9 +1840,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba50000AudioReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba50000AudioRwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba50000AudioPqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba100000AudioReadable == false) { @@ -1605,9 +1850,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba100000AudioReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba100000AudioRwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba100000AudioPqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba400000AudioReadable == false) { @@ -1616,9 +1860,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba400000AudioReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba400000AudioRwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba400000AudioPqReadable) subchannel = MmcSubchannel.Q16; } else if(report.GdRomSwapDiscCapabilities.Lba450000AudioReadable == false) { @@ -1627,9 +1870,8 @@ public sealed partial class DeviceReport cluster = (uint)report.GdRomSwapDiscCapabilities.Lba450000AudioReadableCluster; if(report.GdRomSwapDiscCapabilities.Lba450000AudioRwReadable) - subchannel = MmcSubchannel.Raw; - else if(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable) - subchannel = MmcSubchannel.Q16; + subchannel = MmcSubchannel.Raw; + else if(report.GdRomSwapDiscCapabilities.Lba450000AudioPqReadable) subchannel = MmcSubchannel.Q16; } System.Console.CancelKeyPress += (_, e) => @@ -1672,22 +1914,46 @@ public sealed partial class DeviceReport AaruConsole.Write(Localization.Core.Reading_LBA_0_of_1, lba, sectors); sense = readAsAudio - ? _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.Cdda, false, - false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, subchannel, - _dev.Timeout, out _) - : _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - subchannel, _dev.Timeout, out _); + ? _dev.ReadCd(out buffer, + out senseBuffer, + lba, + blockSize, + cluster, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + subchannel, + _dev.Timeout, + out _) + : _dev.ReadCd(out buffer, + out senseBuffer, + lba, + blockSize, + cluster, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + subchannel, + _dev.Timeout, + out _); if(sense) { - if(trackModeChange) - break; + if(trackModeChange) break; DecodedSense? decoded = Sense.Decode(senseBuffer); - if(decoded is not { ASC: 0x64, ASCQ: 0x00 }) - break; + if(decoded is not { ASC: 0x64, ASCQ: 0x00 }) break; trackModeChange = true; readAsAudio = !readAsAudio; diff --git a/Aaru.Core/Devices/Report/MMC.cs b/Aaru.Core/Devices/Report/MMC.cs index 483f5de31..c7b100038 100644 --- a/Aaru.Core/Devices/Report/MMC.cs +++ b/Aaru.Core/Devices/Report/MMC.cs @@ -62,8 +62,7 @@ public sealed partial class DeviceReport continue; } - if(data.Length + offset > response.Length) - data = new byte[response.Length - offset]; + if(data.Length + offset > response.Length) data = new byte[response.Length - offset]; Array.Copy(data, 4, response, offset + 4, data.Length - 4); offset += (uint)data.Length; @@ -85,13 +84,11 @@ public sealed partial class DeviceReport sense = _dev.GetConfiguration(out buffer, out _, _dev.Timeout, out _); }); - if(sense) - return null; + if(sense) return null; Features.SeparatedFeatures ftr = Features.Separate(buffer); - if(ftr.Descriptors is not { Length: > 0 }) - return null; + if(ftr.Descriptors is not { Length: > 0 }) return null; var report = new MmcFeatures { @@ -151,11 +148,9 @@ public sealed partial class DeviceReport if(ftr0010.HasValue) { - if(ftr0010.Value.LogicalBlockSize > 0) - report.LogicalBlockSize = ftr0010.Value.LogicalBlockSize; + if(ftr0010.Value.LogicalBlockSize > 0) report.LogicalBlockSize = ftr0010.Value.LogicalBlockSize; - if(ftr0010.Value.Blocking > 0) - report.BlocksPerReadableUnit = ftr0010.Value.Blocking; + if(ftr0010.Value.Blocking > 0) report.BlocksPerReadableUnit = ftr0010.Value.Blocking; report.ErrorRecoveryPage = ftr0010.Value.PP; } @@ -242,8 +237,7 @@ public sealed partial class DeviceReport report.CanReadDVDPlusRW = true; Feature_002A? ftr002A = Features.Decode_002A(desc.Data); - if(ftr002A.HasValue) - report.CanWriteDVDPlusRW = ftr002A.Value.Write; + if(ftr002A.HasValue) report.CanWriteDVDPlusRW = ftr002A.Value.Write; } break; @@ -252,8 +246,7 @@ public sealed partial class DeviceReport report.CanReadDVDPlusR = true; Feature_002B? ftr002B = Features.Decode_002B(desc.Data); - if(ftr002B.HasValue) - report.CanWriteDVDPlusR = ftr002B.Value.Write; + if(ftr002B.HasValue) report.CanWriteDVDPlusR = ftr002B.Value.Write; } break; @@ -315,8 +308,7 @@ public sealed partial class DeviceReport report.CanWriteDDCDR = true; Feature_0031? ftr0031 = Features.Decode_0031(desc.Data); - if(ftr0031.HasValue) - report.CanTestWriteDDCDR = ftr0031.Value.TestWrite; + if(ftr0031.HasValue) report.CanTestWriteDDCDR = ftr0031.Value.TestWrite; } break; @@ -337,8 +329,7 @@ public sealed partial class DeviceReport report.CanReadDVDPlusRWDL = true; Feature_003A? ftr003A = Features.Decode_003A(desc.Data); - if(ftr003A.HasValue) - report.CanWriteDVDPlusRWDL = ftr003A.Value.Write; + if(ftr003A.HasValue) report.CanWriteDVDPlusRWDL = ftr003A.Value.Write; } break; @@ -347,8 +338,7 @@ public sealed partial class DeviceReport report.CanReadDVDPlusRDL = true; Feature_003B? ftr003B = Features.Decode_003B(desc.Data); - if(ftr003B.HasValue) - report.CanWriteDVDPlusRDL = ftr003B.Value.Write; + if(ftr003B.HasValue) report.CanWriteDVDPlusRDL = ftr003B.Value.Write; } break; @@ -446,8 +436,7 @@ public sealed partial class DeviceReport report.CanMuteSeparateChannels = ftr0103.Value.SCM; report.SupportsSeparateVolume = ftr0103.Value.SV; - if(ftr0103.Value.VolumeLevels > 0) - report.VolumeLevels = ftr0103.Value.VolumeLevels; + if(ftr0103.Value.VolumeLevels > 0) report.VolumeLevels = ftr0103.Value.VolumeLevels; } } @@ -461,8 +450,7 @@ public sealed partial class DeviceReport report.SupportsCSS = true; Feature_0106? ftr0106 = Features.Decode_0106(desc.Data); - if(ftr0106?.CSSVersion > 0) - report.CSSVersion = ftr0106.Value.CSSVersion; + if(ftr0106?.CSSVersion > 0) report.CSSVersion = ftr0106.Value.CSSVersion; } break; @@ -479,8 +467,7 @@ public sealed partial class DeviceReport report.SupportsCPRM = true; Feature_010B? ftr010B = Features.Decode_010B(desc.Data); - if(ftr010B?.CPRMVersion > 0) - report.CPRMVersion = ftr010B.Value.CPRMVersion; + if(ftr010B?.CPRMVersion > 0) report.CPRMVersion = ftr010B.Value.CPRMVersion; } break; @@ -519,16 +506,20 @@ public sealed partial class DeviceReport try { - report.FirmwareDate = new DateTime(int.Parse(syear), int.Parse(smonth), int.Parse(sday), - int.Parse(shour), int.Parse(sminute), int.Parse(ssecond), + report.FirmwareDate = new DateTime(int.Parse(syear), + int.Parse(smonth), + int.Parse(sday), + int.Parse(shour), + int.Parse(sminute), + int.Parse(ssecond), DateTimeKind.Utc); } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored } - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } } @@ -546,14 +537,11 @@ public sealed partial class DeviceReport report.SupportsBusEncryption = ftr010D.Value.BEC; report.CanGenerateBindingNonce = ftr010D.Value.BNG; - if(ftr010D.Value.BindNonceBlocks > 0) - report.BindingNonceBlocks = ftr010D.Value.BindNonceBlocks; + if(ftr010D.Value.BindNonceBlocks > 0) report.BindingNonceBlocks = ftr010D.Value.BindNonceBlocks; - if(ftr010D.Value.AGIDs > 0) - report.AGIDs = ftr010D.Value.AGIDs; + if(ftr010D.Value.AGIDs > 0) report.AGIDs = ftr010D.Value.AGIDs; - if(ftr010D.Value.AACSVersion > 0) - report.AACSVersion = ftr010D.Value.AACSVersion; + if(ftr010D.Value.AACSVersion > 0) report.AACSVersion = ftr010D.Value.AACSVersion; } } @@ -635,8 +623,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_SCSI_MODE_SENSE_10).IsIndeterminate(); - sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0x00, _dev.Timeout, out _); + sense = _dev.ModeSense10(out buffer, + out senseBuffer, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); }); if(!sense && !_dev.Error) @@ -725,10 +720,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_PFI).IsIndeterminate(); - mediaTest.CanReadPFI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadPFI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadPFI); @@ -739,10 +739,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_DMI).IsIndeterminate(); - mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadDMI); @@ -756,10 +761,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_CMI).IsIndeterminate(); - mediaTest.CanReadCMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.CopyrightInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadCMI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.CopyrightInformation, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadCMI); @@ -775,10 +785,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_BCA).IsIndeterminate(); - mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.BurstCuttingArea, 0, - _dev.Timeout, out _); + mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.BurstCuttingArea, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadBCA); @@ -789,9 +804,14 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_AACS).IsIndeterminate(); - mediaTest.CanReadAACS = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdAacs, 0, _dev.Timeout, + mediaTest.CanReadAACS = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdAacs, + 0, + _dev.Timeout, out _); }); @@ -806,10 +826,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_BCA).IsIndeterminate(); - mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.BurstCuttingArea, 0, - _dev.Timeout, out _); + mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.BurstCuttingArea, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadBCA); @@ -820,10 +845,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_PFI).IsIndeterminate(); - mediaTest.CanReadPFI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadPFI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadPFI); @@ -834,10 +864,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_DMI).IsIndeterminate(); - mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, + mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, MmcDiscStructureFormat.DiscManufacturingInformation, - 0, _dev.Timeout, out _); + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadDMI); @@ -856,10 +891,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_BD_BCA).IsIndeterminate(); - mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdBurstCuttingArea, 0, - _dev.Timeout, out _); + mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdBurstCuttingArea, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadBCA); @@ -875,9 +915,14 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_Disc_Definition_Structure).IsIndeterminate(); - mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout, + mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramDds, + 0, + _dev.Timeout, out _); }); @@ -890,12 +935,19 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Querying_Spare_Area_Information).IsIndeterminate(); mediaTest.CanReadSpareAreaInformation = - !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, _dev.Timeout, + !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramSpareAreaInformation, + 0, + _dev.Timeout, out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadSpareAreaInformation); mediaTest.DvdSaiData = buffer; @@ -909,9 +961,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_BD_DDS).IsIndeterminate(); - mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, out _); + mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdDds, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadDDS); @@ -923,11 +981,19 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Querying_BD_SAI).IsIndeterminate(); mediaTest.CanReadSpareAreaInformation = - !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout, out _); + !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdSpareAreaInformation, + 0, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadSpareAreaInformation); mediaTest.BluSaiData = buffer; @@ -939,9 +1005,14 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_PRI).IsIndeterminate(); - mediaTest.CanReadPRI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PreRecordedInfo, 0, _dev.Timeout, + mediaTest.CanReadPRI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PreRecordedInfo, + 0, + _dev.Timeout, out _); }); @@ -956,10 +1027,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_Media_ID).IsIndeterminate(); - mediaTest.CanReadMediaID = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrMediaIdentifier, 0, - _dev.Timeout, out _); + mediaTest.CanReadMediaID = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrMediaIdentifier, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadMediaID); @@ -968,13 +1044,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_Embossed_PFI).IsIndeterminate(); - mediaTest.CanReadRecordablePFI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, + mediaTest.CanReadRecordablePFI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, MmcDiscStructureFormat.DvdrPhysicalInformation, - 0, _dev.Timeout, out _); + 0, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRecordablePFI); mediaTest.EmbossedPfiData = buffer; @@ -986,9 +1068,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_ADIP).IsIndeterminate(); - mediaTest.CanReadADIP = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Adip, 0, _dev.Timeout, out _); + mediaTest.CanReadADIP = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Adip, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadADIP); @@ -999,9 +1087,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_DCB).IsIndeterminate(); - mediaTest.CanReadDCB = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Dcb, 0, _dev.Timeout, out _); + mediaTest.CanReadDCB = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Dcb, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadDCB); @@ -1015,10 +1109,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_HD_DVD_CMI).IsIndeterminate(); - mediaTest.CanReadHDCMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdCopyrightInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadHDCMI = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.HddvdCopyrightInformation, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadHDCMI); @@ -1032,33 +1131,49 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_DVD_Layer_Capacity).IsIndeterminate(); - mediaTest.CanReadLayerCapacity = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrLayerCapacity, 0, - _dev.Timeout, out _); + mediaTest.CanReadLayerCapacity = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrLayerCapacity, + 0, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadLayerCapacity); mediaTest.DvdLayerData = buffer; } if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) || - mediaType is "Ultra HD Blu-ray movie" or "PlayStation 3 game" or "PlayStation 4 game" or "PlayStation 5 game" - or "Xbox One game" or "Nintendo Wii game") + mediaType is "Ultra HD Blu-ray movie" + or "PlayStation 3 game" + or "PlayStation 4 game" + or "PlayStation 5 game" + or "Xbox One game" + or "Nintendo Wii game") { Spectre.ProgressSingleSpinner(ctx => { ctx.AddTask(Localization.Core.Querying_BD_Disc_Information).IsIndeterminate(); - mediaTest.CanReadDiscInformation = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.DiscInformation, 0, - _dev.Timeout, out _); + mediaTest.CanReadDiscInformation = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.DiscInformation, + 0, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadDiscInformation); mediaTest.BluDiData = buffer; @@ -1067,9 +1182,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_BD_PAC).IsIndeterminate(); - mediaTest.CanReadPAC = !_dev.ReadDiscStructure(out buffer, out senseBuffer, - MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.Pac, 0, _dev.Timeout, out _); + mediaTest.CanReadPAC = !_dev.ReadDiscStructure(out buffer, + out senseBuffer, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.Pac, + 0, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.CanReadPAC); @@ -1083,10 +1204,22 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_scrambled).IsIndeterminate(); - mediaTest.CanReadCdScrambled = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2352, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.CanReadCdScrambled = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); mediaTest.ReadCdScrambledData = buffer; @@ -1108,8 +1241,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_10).IsIndeterminate(); - mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 16, - 512, 0, 1, _dev.Timeout, out _); + mediaTest.SupportsRead10 = !_dev.Read10(out buffer, + out senseBuffer, + 0, + false, + true, + false, + false, + 16, + 512, + 0, + 1, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead10); @@ -1120,8 +1264,20 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_12).IsIndeterminate(); - mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 16, - 512, 0, 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead12 = !_dev.Read12(out buffer, + out senseBuffer, + 0, + false, + true, + false, + false, + 16, + 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead12); @@ -1132,8 +1288,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_16).IsIndeterminate(); - mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16, 512, 0, - 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead16 = !_dev.Read16(out buffer, + out senseBuffer, + 0, + false, + true, + false, + 16, + 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead16); @@ -1156,8 +1323,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_10).IsIndeterminate(); - mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 16, - 2048, 0, 1, _dev.Timeout, out _); + mediaTest.SupportsRead10 = !_dev.Read10(out buffer, + out senseBuffer, + 0, + false, + true, + false, + false, + 16, + 2048, + 0, + 1, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead10); @@ -1168,8 +1346,20 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_12).IsIndeterminate(); - mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 16, - 2048, 0, 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead12 = !_dev.Read12(out buffer, + out senseBuffer, + 0, + false, + true, + false, + false, + 16, + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead12); @@ -1180,8 +1370,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_16).IsIndeterminate(); - mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 16, 2048, 0, - 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead16 = !_dev.Read16(out buffer, + out senseBuffer, + 0, + false, + true, + false, + 16, + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead16); @@ -1199,13 +1400,26 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD).IsIndeterminate(); - mediaTest.SupportsReadCd = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2352, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.SupportsReadCd = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCd); mediaTest.ReadCdFullData = buffer; @@ -1214,13 +1428,25 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_MSF).IsIndeterminate(); - mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210, 0x00000211, - 2352, MmcSectorTypes.Cdda, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, + out senseBuffer, + 0x00000210, + 0x00000211, + 2352, + MmcSectorTypes.Cdda, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsf); mediaTest.ReadCdMsfFullData = buffer; @@ -1231,13 +1457,26 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD).IsIndeterminate(); - mediaTest.SupportsReadCd = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2048, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.SupportsReadCd = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2048, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCd); mediaTest.ReadCdData = buffer; @@ -1246,13 +1485,25 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_MSF).IsIndeterminate(); - mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210, 0x00000211, - 2048, MmcSectorTypes.AllTypes, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.SupportsReadCdMsf = !_dev.ReadCdMsf(out buffer, + out senseBuffer, + 0x00000210, + 0x00000211, + 2048, + MmcSectorTypes.AllTypes, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsf); mediaTest.ReadCdMsfData = buffer; @@ -1261,14 +1512,26 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_full_sector).IsIndeterminate(); - mediaTest.SupportsReadCdRaw = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2352, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + mediaTest.SupportsReadCdRaw = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdRaw); mediaTest.ReadCdFullData = buffer; @@ -1277,14 +1540,25 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_MSF_full_sector).IsIndeterminate(); - mediaTest.SupportsReadCdMsfRaw = !_dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000210, - 0x00000211, 2352, MmcSectorTypes.AllTypes, false, - false, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + mediaTest.SupportsReadCdMsfRaw = !_dev.ReadCdMsf(out buffer, + out senseBuffer, + 0x00000210, + 0x00000211, + 2352, + MmcSectorTypes.AllTypes, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsReadCdMsfRaw); mediaTest.ReadCdMsfFullData = buffer; @@ -1301,15 +1575,41 @@ public sealed partial class DeviceReport // ReSharper disable IntVariableOverflowInUncheckedContext 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, _dev.Timeout, out _); + sense = _dev.ReadCd(out buffer, + out senseBuffer, + (uint)i, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } 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, _dev.Timeout, out _); + sense = _dev.ReadCd(out buffer, + out senseBuffer, + (uint)i, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } // ReSharper restore IntVariableOverflowInUncheckedContext @@ -1318,8 +1618,7 @@ public sealed partial class DeviceReport mediaTest.Track1PregapData = buffer; - if(sense) - continue; + if(sense) continue; mediaTest.CanReadFirstTrackPreGap = true; @@ -1334,29 +1633,54 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Trying_to_read_CD_Lead_In).IsIndeterminate(); foreach(int i in new[] - { - -5000, -4000, -3000, -2000, -1000, -500, -250 - }) + { + -5000, -4000, -3000, -2000, -1000, -500, -250 + }) { 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, _dev.Timeout, out _); + sense = _dev.ReadCd(out buffer, + out senseBuffer, + (uint)i, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } 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, _dev.Timeout, out _); + sense = _dev.ReadCd(out buffer, + out senseBuffer, + (uint)i, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, sense); mediaTest.LeadInData = buffer; - if(sense) - continue; + if(sense) continue; mediaTest.CanReadLeadIn = true; @@ -1372,24 +1696,46 @@ public sealed partial class DeviceReport if(mediaType == "Audio CD") { - mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - (uint)((mediaTest.Blocks ?? 0) + 1), 2352, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, + out senseBuffer, + (uint)((mediaTest.Blocks ?? 0) + 1), + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } else { - mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - (uint)((mediaTest.Blocks ?? 0) + 1), 2352, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, + out senseBuffer, + (uint)((mediaTest.Blocks ?? 0) + 1), + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, out _); } }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadLeadOut); mediaTest.LeadOutData = buffer; @@ -1406,22 +1752,45 @@ public sealed partial class DeviceReport mediaTest.CanReadC2Pointers = false; else { - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2646, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.None, - _dev.Timeout, out _); + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2646, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.None, + _dev.Timeout, + out _); if(!mediaTest.CanReadC2Pointers == true) { - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2648, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2648, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.None, _dev.Timeout, out _); + MmcSubchannel.None, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; @@ -1432,22 +1801,48 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_to_read_subchannels).IsIndeterminate(); - mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2368, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2368, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; - mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2448, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2448, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -1457,13 +1852,25 @@ public sealed partial class DeviceReport mediaTest.CanReadCorrectedSubchannel = false; else { - mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2448, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Rw, - _dev.Timeout, out _); + mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2448, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Rw, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; @@ -1483,64 +1890,131 @@ public sealed partial class DeviceReport } else { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2662, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.Q16, - _dev.Timeout, out _); + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2662, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.Q16, + _dev.Timeout, + out _); if(mediaTest.CanReadPQSubchannelWithC2 == false) { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2664, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2664, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Q16, _dev.Timeout, out _); + MmcSubchannel.Q16, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2712, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.Raw, - _dev.Timeout, out _); + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2712, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.Raw, + _dev.Timeout, + out _); if(mediaTest.CanReadRWSubchannelWithC2 == false) { - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2714, 1, - MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2714, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Raw, _dev.Timeout, out _); + MmcSubchannel.Raw, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, 2712, - 1, MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2712, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2Pointers, - MmcSubchannel.Rw, _dev.Timeout, out _); + MmcSubchannel.Rw, + _dev.Timeout, + out _); if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) { - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 11, - 2714, 1, MmcSectorTypes.Cdda, false, - false, false, MmcHeaderCodes.None, - true, false, + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 11, + 2714, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, + MmcSubchannel.Rw, + _dev.Timeout, out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; @@ -1558,22 +2032,45 @@ public sealed partial class DeviceReport mediaTest.CanReadC2Pointers = false; else { - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2646, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.C2Pointers, MmcSubchannel.None, - _dev.Timeout, out _); + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2646, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2Pointers, + MmcSubchannel.None, + _dev.Timeout, + out _); if(mediaTest.CanReadC2Pointers == false) { - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2648, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2648, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.None, _dev.Timeout, out _); + MmcSubchannel.None, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; @@ -1584,24 +2081,48 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_to_read_subchannels).IsIndeterminate(); - mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2368, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, + mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2368, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; - mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2448, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, + mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -1611,13 +2132,25 @@ public sealed partial class DeviceReport mediaTest.CanReadCorrectedSubchannel = false; else { - mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2448, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.Rw, - _dev.Timeout, out _); + mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.Rw, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; @@ -1636,51 +2169,108 @@ public sealed partial class DeviceReport } else { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2662, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.C2Pointers, MmcSubchannel.Q16, - _dev.Timeout, out _); + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2662, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2Pointers, + MmcSubchannel.Q16, + _dev.Timeout, + out _); if(mediaTest.CanReadPQSubchannelWithC2 == false) { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2664, 1, - MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Q16, _dev.Timeout, out _); + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2664, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2PointersAndBlock, + MmcSubchannel.Q16, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2712, 1, - MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.C2Pointers, MmcSubchannel.Raw, - _dev.Timeout, out _); + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2712, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2Pointers, + MmcSubchannel.Raw, + _dev.Timeout, + out _); if(mediaTest.CanReadRWSubchannelWithC2 == false) { - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2714, 1, - MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Raw, _dev.Timeout, out _); + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2714, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2PointersAndBlock, + MmcSubchannel.Raw, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2712, - 1, MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.C2Pointers, - MmcSubchannel.Rw, _dev.Timeout, out _); + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2712, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.C2Pointers, + MmcSubchannel.Rw, + _dev.Timeout, + out _); // AccessTek/Optorite DD0203 returns OK but then the firmware dies if(_dev.Model.StartsWith("DVD RW 4XMax", StringComparison.Ordinal)) @@ -1689,18 +2279,26 @@ public sealed partial class DeviceReport { if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) { - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, - 16, 2714, 1, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2714, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, true, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, + MmcSubchannel.Rw, + _dev.Timeout, out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; @@ -1718,23 +2316,46 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_to_read_C2_Pointers).IsIndeterminate(); - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2342, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.None, - _dev.Timeout, out _); + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2342, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.None, + _dev.Timeout, + out _); if(mediaTest.CanReadC2Pointers == false) { - mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2344, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, + mediaTest.CanReadC2Pointers = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2344, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.None, _dev.Timeout, out _); + MmcSubchannel.None, + _dev.Timeout, + out _); } }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadC2Pointers); mediaTest.C2PointersData = buffer; @@ -1744,22 +2365,48 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_to_read_subchannels).IsIndeterminate(); - mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2064, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + mediaTest.CanReadPQSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2064, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannel); mediaTest.PQSubchannelData = buffer; - mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2144, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + mediaTest.CanReadRWSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2144, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; @@ -1769,13 +2416,25 @@ public sealed partial class DeviceReport mediaTest.CanReadCorrectedSubchannel = false; else { - mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2144, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.Rw, - _dev.Timeout, out _); + mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2144, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.Rw, + _dev.Timeout, + out _); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannel); mediaTest.CorrectedSubchannelData = buffer; @@ -1794,64 +2453,131 @@ public sealed partial class DeviceReport } else { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2358, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.Q16, - _dev.Timeout, out _); + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2358, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.Q16, + _dev.Timeout, + out _); if(mediaTest.CanReadPQSubchannelWithC2 == false) { - mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2360, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.None, true, false, + mediaTest.CanReadPQSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2360, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Q16, _dev.Timeout, out _); + MmcSubchannel.Q16, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadPQSubchannelWithC2); mediaTest.PQSubchannelWithC2Data = buffer; - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2438, 1, - MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.C2Pointers, MmcSubchannel.Raw, - _dev.Timeout, out _); + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2438, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.C2Pointers, + MmcSubchannel.Raw, + _dev.Timeout, + out _); if(mediaTest.CanReadRWSubchannelWithC2 == false) { - mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2440, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.None, true, false, + mediaTest.CanReadRWSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2440, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Raw, _dev.Timeout, out _); + MmcSubchannel.Raw, + _dev.Timeout, + out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadRWSubchannelWithC2); mediaTest.RWSubchannelWithC2Data = buffer; - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2438, - 1, MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.None, true, false, + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2438, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2Pointers, - MmcSubchannel.Rw, _dev.Timeout, out _); + MmcSubchannel.Rw, + _dev.Timeout, + out _); if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) { - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, 16, - 2440, 1, MmcSectorTypes.AllTypes, - false, false, false, - MmcHeaderCodes.None, true, false, + mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, + out senseBuffer, + 16, + 2440, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, MmcErrorField.C2PointersAndBlock, - MmcSubchannel.Rw, _dev.Timeout, + MmcSubchannel.Rw, + _dev.Timeout, out _); } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadCorrectedSubchannelWithC2); mediaTest.CorrectedSubchannelWithC2Data = buffer; @@ -1866,11 +2592,18 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Plextor_READ_CD_DA).IsIndeterminate(); mediaTest.SupportsPlextorReadCDDA = - !_dev.PlextorReadCdDa(out buffer, out senseBuffer, 16, 2352, 1, PlextorSubchannel.None, - _dev.Timeout, out _); + !_dev.PlextorReadCdDa(out buffer, + out senseBuffer, + 16, + 2352, + 1, + PlextorSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsPlextorReadCDDA); mediaTest.PlextorReadCddaData = buffer; @@ -1883,11 +2616,18 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Trying_Pioneer_READ_CD_DA).IsIndeterminate(); mediaTest.SupportsPioneerReadCDDA = - !_dev.PioneerReadCdDa(out buffer, out senseBuffer, 16, 2352, 1, PioneerSubchannel.None, - _dev.Timeout, out _); + !_dev.PioneerReadCdDa(out buffer, + out senseBuffer, + 16, + 2352, + 1, + PioneerSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsPioneerReadCDDA); mediaTest.PioneerReadCddaData = buffer; @@ -1897,11 +2637,18 @@ public sealed partial class DeviceReport ctx.AddTask(Localization.Core.Trying_Pioneer_READ_CD_DA_MSF).IsIndeterminate(); mediaTest.SupportsPioneerReadCDDAMSF = - !_dev.PioneerReadCdDaMsf(out buffer, out senseBuffer, 0x00000210, 0x00000211, 2352, - PioneerSubchannel.None, _dev.Timeout, out _); + !_dev.PioneerReadCdDaMsf(out buffer, + out senseBuffer, + 0x00000210, + 0x00000211, + 2352, + PioneerSubchannel.None, + _dev.Timeout, + out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsPioneerReadCDDAMSF); mediaTest.PioneerReadCddaMsfData = buffer; @@ -1917,7 +2664,8 @@ public sealed partial class DeviceReport !_dev.NecReadCdDa(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsNECReadCDDA); mediaTest.NecReadCddaData = buffer; @@ -1952,8 +2700,7 @@ public sealed partial class DeviceReport information = (uint)Sense.DecodeDescriptor00(desc00); } - if(valid && ili) - mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); + if(valid && ili) mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); } } @@ -1980,14 +2727,14 @@ public sealed partial class DeviceReport !_dev.PlextorReadRawDvd(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsPlextorReadRawDVD); if(mediaTest.SupportsPlextorReadRawDVD == true) mediaTest.SupportsPlextorReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); - if(mediaTest.SupportsPlextorReadRawDVD == true) - mediaTest.PlextorReadRawDVDData = buffer; + if(mediaTest.SupportsPlextorReadRawDVD == true) mediaTest.PlextorReadRawDVDData = buffer; } if(tryHldtst) @@ -2000,14 +2747,14 @@ public sealed partial class DeviceReport !_dev.HlDtStReadRawDvd(out buffer, out senseBuffer, 16, 1, _dev.Timeout, out _); }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.SupportsHLDTSTReadRawDVD); if(mediaTest.SupportsHLDTSTReadRawDVD == true) mediaTest.SupportsHLDTSTReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); - if(mediaTest.SupportsHLDTSTReadRawDVD == true) - mediaTest.HLDTSTReadRawDVDData = buffer; + if(mediaTest.SupportsHLDTSTReadRawDVD == true) mediaTest.HLDTSTReadRawDVDData = buffer; } if(tryMediaTekF106) @@ -2021,8 +2768,22 @@ public sealed partial class DeviceReport if(mediaType == "Audio CD" && mediaTest.SupportsReadCd == true) { - _dev.ReadCd(out _, out _, 0, 2352, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _); + _dev.ReadCd(out _, + out _, + 0, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); triedLba0 = true; } @@ -2030,9 +2791,22 @@ public sealed partial class DeviceReport mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") && mediaTest.SupportsReadCdRaw == true) { - _dev.ReadCd(out _, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + _dev.ReadCd(out _, + out _, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); triedLba0 = true; } @@ -2040,8 +2814,21 @@ public sealed partial class DeviceReport mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") && mediaTest.SupportsReadCd == true) { - _dev.ReadCd(out _, out _, 0, 2048, 1, MmcSectorTypes.AllTypes, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + _dev.ReadCd(out _, + out _, + 0, + 2048, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, out _); triedLba0 = true; @@ -2068,8 +2855,7 @@ public sealed partial class DeviceReport triedLba0 = true; } - if(!triedLba0) - return; + if(!triedLba0) return; mediaTest.CanReadF1_06 = !_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _); @@ -2083,14 +2869,26 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_MediaTek_READ_DRAM_command_for_Lead_Out).IsIndeterminate(); - if(!(mediaTest.Blocks > 0)) - return; + if(!(mediaTest.Blocks > 0)) return; if(mediaType == "Audio CD" && mediaTest.SupportsReadCd == true) { - _dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + _dev.ReadCd(out _, + out _, + (uint)(mediaTest.Blocks + 1), + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); triedLeadOut = true; } @@ -2098,9 +2896,22 @@ public sealed partial class DeviceReport mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") && mediaTest.SupportsReadCdRaw == true) { - _dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false, - false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + _dev.ReadCd(out _, + out _, + (uint)(mediaTest.Blocks + 1), + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); triedLeadOut = true; } @@ -2108,9 +2919,22 @@ public sealed partial class DeviceReport mediaType == "Enhanced CD (aka E-CD, CD-Plus or CD+)") && mediaTest.SupportsReadCd == true) { - _dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2048, 1, MmcSectorTypes.AllTypes, false, - false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + _dev.ReadCd(out _, + out _, + (uint)(mediaTest.Blocks + 1), + 2048, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); triedLeadOut = true; } @@ -2121,28 +2945,61 @@ public sealed partial class DeviceReport } else if(mediaTest.SupportsRead10 == true) { - _dev.Read10(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0, 1, - _dev.Timeout, out _); + _dev.Read10(out _, + out _, + 0, + false, + true, + false, + false, + (uint)(mediaTest.Blocks + 1), + 2048, + 0, + 1, + _dev.Timeout, + out _); triedLeadOut = true; } else if(mediaTest.SupportsRead12 == true) { - _dev.Read12(out _, out _, 0, false, true, false, false, (uint)(mediaTest.Blocks + 1), 2048, 0, 1, - false, _dev.Timeout, out _); + _dev.Read12(out _, + out _, + 0, + false, + true, + false, + false, + (uint)(mediaTest.Blocks + 1), + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); triedLeadOut = true; } else if(mediaTest.SupportsRead16 == true) { - _dev.Read16(out _, out _, 0, false, true, false, (ulong)(mediaTest.Blocks + 1), 2048, 0, 1, false, - _dev.Timeout, out _); + _dev.Read16(out _, + out _, + 0, + false, + true, + false, + (ulong)(mediaTest.Blocks + 1), + 2048, + 0, + 1, + false, + _dev.Timeout, + out _); triedLeadOut = true; } - if(!triedLeadOut) - return; + if(!triedLeadOut) return; mediaTest.CanReadF1_06LeadOut = !_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _); @@ -2158,7 +3015,8 @@ public sealed partial class DeviceReport mediaTest.ReadF1_06LeadOutData = senseBuffer; } - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadF1_06LeadOut); }); } @@ -2188,8 +3046,8 @@ public sealed partial class DeviceReport if(!decodedToc.TrackDescriptors.Any(t => t.SessionNumber > 1)) { - AaruConsole.ErrorWriteLine(Localization.Core. - Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); + AaruConsole.ErrorWriteLine(Localization.Core + .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); return null; } @@ -2202,19 +3060,22 @@ public sealed partial class DeviceReport if(firstSessionLeadOutTrack.SessionNumber == 0 || secondSessionFirstTrack.SessionNumber == 0) { - AaruConsole.ErrorWriteLine(Localization.Core. - Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); + AaruConsole.ErrorWriteLine(Localization.Core + .Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc); return null; } AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.First_session_Lead_Out_starts_at_0_1_2, - firstSessionLeadOutTrack.PMIN, firstSessionLeadOutTrack.PSEC, + firstSessionLeadOutTrack.PMIN, + firstSessionLeadOutTrack.PSEC, firstSessionLeadOutTrack.PFRAME); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Second_session_starts_at_0_1_2, - secondSessionFirstTrack.PMIN, secondSessionFirstTrack.PSEC, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Second_session_starts_at_0_1_2, + secondSessionFirstTrack.PMIN, + secondSessionFirstTrack.PSEC, secondSessionFirstTrack.PFRAME); // Skip Lead-Out pre-gap @@ -2233,35 +3094,65 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_in_first_session_Lead_Out).IsIndeterminate(); - mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - firstSessionLeadOutLba, 2448, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, + out senseBuffer, + firstSessionLeadOutLba, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); - if(mediaTest.CanReadingIntersessionLeadOut != false) - return; + if(mediaTest.CanReadingIntersessionLeadOut != false) return; - mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - firstSessionLeadOutLba, 2368, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, + out senseBuffer, + firstSessionLeadOutLba, + 2368, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); if(mediaTest.CanReadingIntersessionLeadOut == false) { - mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, - firstSessionLeadOutLba, 2352, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, + out senseBuffer, + firstSessionLeadOutLba, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadingIntersessionLeadOut); mediaTest.IntersessionLeadOutData = buffer; @@ -2270,35 +3161,65 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_CD_in_second_session_Lead_In).IsIndeterminate(); - mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer, - secondSessionLeadInLba, 2448, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, + out senseBuffer, + secondSessionLeadInLba, + 2448, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + _dev.Timeout, + out _); - if(mediaTest.CanReadingIntersessionLeadIn != false) - return; + if(mediaTest.CanReadingIntersessionLeadIn != false) return; - mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer, - secondSessionLeadInLba, 2368, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, + out senseBuffer, + secondSessionLeadInLba, + 2368, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.Q16, + _dev.Timeout, + out _); if(mediaTest.CanReadingIntersessionLeadIn == false) { - mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, out senseBuffer, - secondSessionLeadInLba, 2352, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.AllHeaders, true, - false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + mediaTest.CanReadingIntersessionLeadIn = !_dev.ReadCd(out buffer, + out senseBuffer, + secondSessionLeadInLba, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.AllHeaders, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); } }); - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.Core.Sense_equals_0, !mediaTest.CanReadingIntersessionLeadIn); mediaTest.IntersessionLeadInData = buffer; diff --git a/Aaru.Core/Devices/Report/PCMCIA.cs b/Aaru.Core/Devices/Report/PCMCIA.cs index 9db186a85..d89dc3fef 100644 --- a/Aaru.Core/Devices/Report/PCMCIA.cs +++ b/Aaru.Core/Devices/Report/PCMCIA.cs @@ -48,8 +48,7 @@ public sealed partial class DeviceReport Tuple[] tuples = CIS.GetTuples(_dev.Cis); - if(tuples == null) - return pcmciaReport; + if(tuples == null) return pcmciaReport; foreach(Tuple tuple in tuples) { diff --git a/Aaru.Core/Devices/Report/SSC.cs b/Aaru.Core/Devices/Report/SSC.cs index afcb823f6..d8db85029 100644 --- a/Aaru.Core/Devices/Report/SSC.cs +++ b/Aaru.Core/Devices/Report/SSC.cs @@ -60,14 +60,11 @@ public sealed partial class DeviceReport { BlockLimits.BlockLimitsData? decBl = BlockLimits.Decode(buffer); - if(decBl?.granularity > 0) - report.BlockSizeGranularity = decBl.Value.granularity; + if(decBl?.granularity > 0) report.BlockSizeGranularity = decBl.Value.granularity; - if(decBl?.maxBlockLen > 0) - report.MaxBlockLength = decBl.Value.maxBlockLen; + if(decBl?.maxBlockLen > 0) report.MaxBlockLength = decBl.Value.maxBlockLen; - if(decBl?.minBlockLen > 0) - report.MinBlockLength = decBl.Value.minBlockLen; + if(decBl?.minBlockLen > 0) report.MinBlockLength = decBl.Value.minBlockLen; } Spectre.ProgressSingleSpinner(ctx => @@ -113,13 +110,11 @@ public sealed partial class DeviceReport sense = _dev.ReportDensitySupport(out buffer, out _, true, false, _dev.Timeout, out _); }); - if(sense) - return report; + if(sense) return report; DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer); - if(!mtsh.HasValue) - return report; + if(!mtsh.HasValue) return report; var array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length]; @@ -135,8 +130,7 @@ public sealed partial class DeviceReport Width = mtsh.Value.descriptors[i].width }; - if(mtsh.Value.descriptors[i].densityCodes == null) - continue; + if(mtsh.Value.descriptors[i].densityCodes == null) continue; var array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; @@ -170,8 +164,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_SCSI_MODE_SENSE_10).IsIndeterminate(); - sense = _dev.ModeSense10(out buffer, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out buffer, + out _, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); }); if(!sense && !_dev.Error) @@ -240,8 +241,8 @@ public sealed partial class DeviceReport Spectre.ProgressSingleSpinner(ctx => { - ctx.AddTask(Localization.Core.Querying_SCSI_REPORT_DENSITY_SUPPORT_for_medium_types_for_current_media). - IsIndeterminate(); + ctx.AddTask(Localization.Core.Querying_SCSI_REPORT_DENSITY_SUPPORT_for_medium_types_for_current_media) + .IsIndeterminate(); sense = _dev.ReportDensitySupport(out buffer, out _, true, true, _dev.Timeout, out _); }); @@ -266,8 +267,7 @@ public sealed partial class DeviceReport Width = mtsh.Value.descriptors[i].width }; - if(mtsh.Value.descriptors[i].densityCodes == null) - continue; + if(mtsh.Value.descriptors[i].densityCodes == null) continue; var array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; diff --git a/Aaru.Core/Devices/Report/Scsi.cs b/Aaru.Core/Devices/Report/Scsi.cs index 3d341b537..15f55fc03 100644 --- a/Aaru.Core/Devices/Report/Scsi.cs +++ b/Aaru.Core/Devices/Report/Scsi.cs @@ -61,13 +61,11 @@ public sealed partial class DeviceReport var report = new Scsi(); - if(sense) - return null; + if(sense) return null; Inquiry? decodedNullable = Inquiry.Decode(buffer); - if(!decodedNullable.HasValue) - return null; + if(!decodedNullable.HasValue) return null; report.InquiryData = ClearInquiry(buffer); @@ -78,8 +76,7 @@ public sealed partial class DeviceReport { Inquiry? decodedNullable = Inquiry.Decode(inquiry); - if(!decodedNullable.HasValue) - return inquiry; + if(!decodedNullable.HasValue) return inquiry; Inquiry decoded = decodedNullable.Value; @@ -88,8 +85,7 @@ public sealed partial class DeviceReport return inquiry; // Clear Seagate serial number - for(var i = 36; i <= 43; i++) - inquiry[i] = 0; + for(var i = 36; i <= 43; i++) inquiry[i] = 0; return inquiry; } @@ -108,21 +104,19 @@ public sealed partial class DeviceReport sense = _dev.ScsiInquiry(out buffer, out _, 0x00); }); - if(sense) - return null; + if(sense) return null; byte[] evpdPages = EVPD.DecodePage00(buffer); - if(evpdPages is not { Length: > 0 }) - return null; + if(evpdPages is not { Length: > 0 }) return null; List evpds = new(); Spectre.ProgressSingleSpinner(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Querying_SCSI_EVPD_pages, - maxValue: evpdPages.Count(page => page != 0x80)). - IsIndeterminate(); + maxValue: evpdPages.Count(page => page != 0x80)) + .IsIndeterminate(); foreach(byte page in evpdPages.Where(page => page != 0x80)) { @@ -130,8 +124,7 @@ public sealed partial class DeviceReport task.Increment(1); sense = _dev.ScsiInquiry(out buffer, out _, page); - if(sense) - continue; + if(sense) continue; byte[] empty; @@ -185,14 +178,11 @@ public sealed partial class DeviceReport static byte[] ClearPage83(byte[] pageResponse) { - if(pageResponse?[1] != 0x83) - return null; + if(pageResponse?[1] != 0x83) return null; - if(pageResponse[3] + 4 != pageResponse.Length) - return null; + if(pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 6) - return null; + if(pageResponse.Length < 6) return null; var position = 4; @@ -200,8 +190,7 @@ public sealed partial class DeviceReport { byte length = pageResponse[position + 3]; - if(length + position + 4 >= pageResponse.Length) - length = (byte)(pageResponse.Length - position - 4); + if(length + position + 4 >= pageResponse.Length) length = (byte)(pageResponse.Length - position - 4); var empty = new byte[length]; Array.Copy(empty, 0, pageResponse, position + 4, length); @@ -228,34 +217,62 @@ public sealed partial class DeviceReport Spectre.ProgressSingleSpinner(ctx => { - ctx.AddTask(Localization.Core.Querying_all_mode_pages_and_subpages_using_SCSI_MODE_SENSE_10). - IsIndeterminate(); + ctx.AddTask(Localization.Core.Querying_all_mode_pages_and_subpages_using_SCSI_MODE_SENSE_10) + .IsIndeterminate(); foreach(ScsiModeSensePageControl pageControl in new[] - { - ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current, - ScsiModeSensePageControl.Changeable - }) + { + ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current, + ScsiModeSensePageControl.Changeable + }) { var saveBuffer = false; - sense = _dev.ModeSense10(out byte[] mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out byte[] mode10Buffer, + out _, + false, + true, + pageControl, + 0x3F, + 0xFF, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out mode10Buffer, out _, false, false, pageControl, 0x3F, 0xFF, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out mode10Buffer, + out _, + false, + false, + pageControl, + 0x3F, + 0xFF, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out mode10Buffer, out _, false, true, pageControl, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out mode10Buffer, + out _, + false, + true, + pageControl, + 0x3F, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense10(out mode10Buffer, out _, false, false, pageControl, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out mode10Buffer, + out _, + false, + false, + pageControl, + 0x3F, + 0x00, + _dev.Timeout, + out _); if(!sense && !_dev.Error) { @@ -287,8 +304,7 @@ public sealed partial class DeviceReport saveBuffer = true; } - if(!saveBuffer) - continue; + if(!saveBuffer) continue; switch(pageControl) { @@ -310,44 +326,80 @@ public sealed partial class DeviceReport Spectre.ProgressSingleSpinner(ctx => { - ctx.AddTask(Localization.Core.Querying_all_mode_pages_and_subpages_using_SCSI_MODE_SENSE_6). - IsIndeterminate(); + ctx.AddTask(Localization.Core.Querying_all_mode_pages_and_subpages_using_SCSI_MODE_SENSE_6) + .IsIndeterminate(); foreach(ScsiModeSensePageControl pageControl in new[] - { - ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current, - ScsiModeSensePageControl.Changeable - }) + { + ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current, + ScsiModeSensePageControl.Changeable + }) { var saveBuffer = false; - sense = _dev.ModeSense6(out byte[] mode6Buffer, out _, true, pageControl, 0x3F, 0xFF, _dev.Timeout, + sense = _dev.ModeSense6(out byte[] mode6Buffer, + out _, + true, + pageControl, + 0x3F, + 0xFF, + _dev.Timeout, out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out mode6Buffer, out _, false, pageControl, 0x3F, 0xFF, _dev.Timeout, + sense = _dev.ModeSense6(out mode6Buffer, + out _, + false, + pageControl, + 0x3F, + 0xFF, + _dev.Timeout, out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out mode6Buffer, out _, true, pageControl, 0x3F, 0x00, _dev.Timeout, + sense = _dev.ModeSense6(out mode6Buffer, + out _, + true, + pageControl, + 0x3F, + 0x00, + _dev.Timeout, out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out mode6Buffer, out _, false, pageControl, 0x3F, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out mode6Buffer, + out _, + false, + pageControl, + 0x3F, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out mode6Buffer, out _, true, pageControl, 0x00, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out mode6Buffer, + out _, + true, + pageControl, + 0x00, + 0x00, + _dev.Timeout, + out _); if(sense || _dev.Error) { - sense = _dev.ModeSense6(out mode6Buffer, out _, false, pageControl, 0x00, 0x00, - _dev.Timeout, out _); + sense = _dev.ModeSense6(out mode6Buffer, + out _, + false, + pageControl, + 0x00, + 0x00, + _dev.Timeout, + out _); if(!sense && !_dev.Error) { @@ -393,8 +445,7 @@ public sealed partial class DeviceReport saveBuffer = true; } - if(!saveBuffer) - continue; + if(!saveBuffer) continue; switch(pageControl) { @@ -418,8 +469,7 @@ public sealed partial class DeviceReport cdromMode = null; - if(decMode == null) - return; + if(decMode == null) return; mediumType = decMode.Value.Header.MediumType; @@ -433,11 +483,9 @@ public sealed partial class DeviceReport if(decMode.Value.Header.BufferedMode > 0) report.SCSI.ModeSense.BufferedMode = decMode.Value.Header.BufferedMode; - if(decMode.Value.Header.Speed > 0) - report.SCSI.ModeSense.Speed = decMode.Value.Header.Speed; + if(decMode.Value.Header.Speed > 0) report.SCSI.ModeSense.Speed = decMode.Value.Header.Speed; - if(decMode.Value.Pages == null) - return; + if(decMode.Value.Pages == null) return; List modePages = new(); @@ -452,12 +500,10 @@ public sealed partial class DeviceReport modePages.Add(modePage); - if(modePage.page == 0x2A && modePage.subpage == 0x00) - cdromMode = page.PageResponse; + if(modePage.page == 0x2A && modePage.subpage == 0x00) cdromMode = page.PageResponse; } - if(modePages.Count > 0) - report.SCSI.ModeSense.ModePages = modePages; + if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages; } /// Creates a report for media inserted into a SCSI device @@ -508,8 +554,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_SCSI_MODE_SENSE_10).IsIndeterminate(); - sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0x00, _dev.Timeout, out _); + sense = _dev.ModeSense10(out buffer, + out senseBuffer, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); }); if(!sense && !_dev.Error) @@ -543,8 +596,8 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_6).IsIndeterminate(); - mediaTest.SupportsRead6 = !_dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize ?? 512, - _dev.Timeout, out _); + mediaTest.SupportsRead6 = + !_dev.Read6(out buffer, out senseBuffer, 0, mediaTest.BlockSize ?? 512, _dev.Timeout, out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead6); @@ -554,8 +607,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_10).IsIndeterminate(); - mediaTest.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, false, false, false, 0, - mediaTest.BlockSize ?? 512, 0, 1, _dev.Timeout, out _); + mediaTest.SupportsRead10 = !_dev.Read10(out buffer, + out senseBuffer, + 0, + false, + false, + false, + false, + 0, + mediaTest.BlockSize ?? 512, + 0, + 1, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead10); @@ -565,8 +629,20 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_12).IsIndeterminate(); - mediaTest.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, false, false, false, 0, - mediaTest.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead12 = !_dev.Read12(out buffer, + out senseBuffer, + 0, + false, + false, + false, + false, + 0, + mediaTest.BlockSize ?? 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead12); @@ -576,8 +652,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_16).IsIndeterminate(); - mediaTest.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, false, false, 0, - mediaTest.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _); + mediaTest.SupportsRead16 = !_dev.Read16(out buffer, + out senseBuffer, + 0, + false, + false, + false, + 0, + mediaTest.BlockSize ?? 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !mediaTest.SupportsRead16); @@ -611,8 +698,7 @@ public sealed partial class DeviceReport information = (uint)Sense.DecodeDescriptor00(desc00); } - if(valid && ili) - mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); + if(valid && ili) mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); } } @@ -641,8 +727,7 @@ public sealed partial class DeviceReport information = (uint)Sense.DecodeDescriptor00(desc00); } - if(valid && ili) - mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); + if(valid && ili) mediaTest.LongBlockSize = 0xFFFF - (information & 0xFFFF); } } @@ -655,25 +740,35 @@ public sealed partial class DeviceReport case 512: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 514, + { + // Long sector sizes for floppies + 514, - // Long sector sizes for SuperDisk - 536, 558, + // Long sector sizes for SuperDisk + 536, 558, - // Long sector sizes for 512-byte magneto-opticals - 600, 610, 630 - }) + // Long sector sizes for 512-byte magneto-opticals + 600, 610, 630 + }) { sense = mediaTest.SupportsReadLong16 == true - ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + ? _dev.ReadLong16(out buffer, + out senseBuffer, + false, + 0, + testSize, + _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, - _dev.Timeout, out _); + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + testSize, + _dev.Timeout, + out _); - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; mediaTest.LongBlockSize = testSize; @@ -685,22 +780,32 @@ public sealed partial class DeviceReport case 1024: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 1026, + { + // Long sector sizes for floppies + 1026, - // Long sector sizes for 1024-byte magneto-opticals - 1200 - }) + // Long sector sizes for 1024-byte magneto-opticals + 1200 + }) { sense = mediaTest.SupportsReadLong16 == true - ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + ? _dev.ReadLong16(out buffer, + out senseBuffer, + false, + 0, + testSize, + _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, - _dev.Timeout, out _); + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + testSize, + _dev.Timeout, + out _); - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; mediaTest.LongBlockSize = testSize; @@ -713,11 +818,16 @@ public sealed partial class DeviceReport { sense = mediaTest.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 2380, + _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTest.LongBlockSize = 2380; + if(!sense && !_dev.Error) mediaTest.LongBlockSize = 2380; break; } @@ -725,11 +835,16 @@ public sealed partial class DeviceReport { sense = mediaTest.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 4760, + _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTest.LongBlockSize = 4760; + if(!sense && !_dev.Error) mediaTest.LongBlockSize = 4760; break; } @@ -737,11 +852,16 @@ public sealed partial class DeviceReport { sense = mediaTest.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 9424, + _dev.Timeout, out _); - if(!sense && !_dev.Error) - mediaTest.LongBlockSize = 9424; + if(!sense && !_dev.Error) mediaTest.LongBlockSize = 9424; break; } @@ -811,8 +931,15 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Querying_SCSI_MODE_SENSE_10).IsIndeterminate(); - sense = _dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0x00, _dev.Timeout, out _); + sense = _dev.ModeSense10(out buffer, + out senseBuffer, + false, + true, + ScsiModeSensePageControl.Current, + 0x3F, + 0x00, + _dev.Timeout, + out _); }); if(!sense && !_dev.Error) @@ -846,8 +973,12 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_6).IsIndeterminate(); - capabilities.SupportsRead6 = !_dev.Read6(out buffer, out senseBuffer, 0, capabilities.BlockSize ?? 512, - _dev.Timeout, out _); + capabilities.SupportsRead6 = !_dev.Read6(out buffer, + out senseBuffer, + 0, + capabilities.BlockSize ?? 512, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !capabilities.SupportsRead6); @@ -857,8 +988,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_10).IsIndeterminate(); - capabilities.SupportsRead10 = !_dev.Read10(out buffer, out senseBuffer, 0, false, false, false, false, 0, - capabilities.BlockSize ?? 512, 0, 1, _dev.Timeout, out _); + capabilities.SupportsRead10 = !_dev.Read10(out buffer, + out senseBuffer, + 0, + false, + false, + false, + false, + 0, + capabilities.BlockSize ?? 512, + 0, + 1, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !capabilities.SupportsRead10); @@ -868,8 +1010,20 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_12).IsIndeterminate(); - capabilities.SupportsRead12 = !_dev.Read12(out buffer, out senseBuffer, 0, false, false, false, false, 0, - capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _); + capabilities.SupportsRead12 = !_dev.Read12(out buffer, + out senseBuffer, + 0, + false, + false, + false, + false, + 0, + capabilities.BlockSize ?? 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !capabilities.SupportsRead12); @@ -879,8 +1033,19 @@ public sealed partial class DeviceReport { ctx.AddTask(Localization.Core.Trying_SCSI_READ_16).IsIndeterminate(); - capabilities.SupportsRead16 = !_dev.Read16(out buffer, out senseBuffer, 0, false, false, false, 0, - capabilities.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _); + capabilities.SupportsRead16 = !_dev.Read16(out buffer, + out senseBuffer, + 0, + false, + false, + false, + 0, + capabilities.BlockSize ?? 512, + 0, + 1, + false, + _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.Core.Sense_equals_0, !capabilities.SupportsRead16); @@ -914,8 +1079,7 @@ public sealed partial class DeviceReport information = (uint)Sense.DecodeDescriptor00(desc00); } - if(valid && ili) - capabilities.LongBlockSize = 0xFFFF - (information & 0xFFFF); + if(valid && ili) capabilities.LongBlockSize = 0xFFFF - (information & 0xFFFF); } } @@ -946,8 +1110,7 @@ public sealed partial class DeviceReport information = (uint)Sense.DecodeDescriptor00(desc00); } - if(valid && ili) - capabilities.LongBlockSize = 0xFFFF - (information & 0xFFFF); + if(valid && ili) capabilities.LongBlockSize = 0xFFFF - (information & 0xFFFF); } } @@ -959,33 +1122,43 @@ public sealed partial class DeviceReport { ctx.AddTask(capabilities.SupportsReadLong16 == true ? Localization.Core.Trying_SCSI_READ_LONG_16 - : Localization.Core.Trying_SCSI_READ_LONG_10). - IsIndeterminate(); + : Localization.Core.Trying_SCSI_READ_LONG_10) + .IsIndeterminate(); switch(capabilities.BlockSize) { case 512: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 514, + { + // Long sector sizes for floppies + 514, - // Long sector sizes for SuperDisk - 536, 558, + // Long sector sizes for SuperDisk + 536, 558, - // Long sector sizes for 512-byte magneto-opticals - 600, 610, 630 - }) + // Long sector sizes for 512-byte magneto-opticals + 600, 610, 630 + }) { sense = capabilities.SupportsReadLong16 == true - ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + ? _dev.ReadLong16(out buffer, + out senseBuffer, + false, + 0, + testSize, + _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, - _dev.Timeout, out _); + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + testSize, + _dev.Timeout, + out _); - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; capabilities.SupportsReadLong = true; capabilities.LongBlockSize = testSize; @@ -998,22 +1171,32 @@ public sealed partial class DeviceReport case 1024: { foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 1026, + { + // Long sector sizes for floppies + 1026, - // Long sector sizes for 1024-byte magneto-opticals - 1200 - }) + // Long sector sizes for 1024-byte magneto-opticals + 1200 + }) { sense = capabilities.SupportsReadLong16 == true - ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + ? _dev.ReadLong16(out buffer, + out senseBuffer, + false, + 0, + testSize, + _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize, - _dev.Timeout, out _); + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + testSize, + _dev.Timeout, + out _); - if(sense || _dev.Error) - continue; + if(sense || _dev.Error) continue; capabilities.SupportsReadLong = true; capabilities.LongBlockSize = testSize; @@ -1027,11 +1210,16 @@ public sealed partial class DeviceReport { sense = capabilities.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 2380, + _dev.Timeout, out _); - if(sense || _dev.Error) - return; + if(sense || _dev.Error) return; capabilities.SupportsReadLong = true; capabilities.LongBlockSize = 2380; @@ -1042,11 +1230,16 @@ public sealed partial class DeviceReport { sense = capabilities.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 4760, + _dev.Timeout, out _); - if(sense || _dev.Error) - return; + if(sense || _dev.Error) return; capabilities.SupportsReadLong = true; capabilities.LongBlockSize = 4760; @@ -1057,11 +1250,16 @@ public sealed partial class DeviceReport { sense = capabilities.SupportsReadLong16 == true ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _) - : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout, + : _dev.ReadLong10(out buffer, + out senseBuffer, + false, + false, + 0, + 9424, + _dev.Timeout, out _); - if(sense || _dev.Error) - return; + if(sense || _dev.Error) return; capabilities.SupportsReadLong = true; capabilities.LongBlockSize = 9424; diff --git a/Aaru.Core/Devices/Scanning/ATA.cs b/Aaru.Core/Devices/Scanning/ATA.cs index 5b0ea7c6c..df09f661b 100644 --- a/Aaru.Core/Devices/Scanning/ATA.cs +++ b/Aaru.Core/Devices/Scanning/ATA.cs @@ -134,21 +134,22 @@ public sealed partial class MediaScan for(ulong i = 0; i < results.Blocks; i += blocksToRead) { - if(_aborted) - break; + if(_aborted) break; - if(results.Blocks - i < blocksToRead) - blocksToRead = (byte)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (byte)(results.Blocks - i); - if(currentSpeed > results.MaxSpeed && currentSpeed > 0) - results.MaxSpeed = currentSpeed; + if(currentSpeed > results.MaxSpeed && currentSpeed > 0) results.MaxSpeed = currentSpeed; - if(currentSpeed < results.MinSpeed && currentSpeed > 0) - results.MinSpeed = currentSpeed; + if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize()), + (long)i, + (long)results.Blocks); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); @@ -191,8 +192,7 @@ public sealed partial class MediaScan ScanUnreadable?.Invoke(i); results.Errored += blocksToRead; - for(ulong b = i; b < i + blocksToRead; b++) - results.UnreadableSectors.Add(b); + for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); mhddLog.Write(i, duration < 500 ? 65535 : duration); @@ -203,8 +203,7 @@ public sealed partial class MediaScan double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); ScanSpeed?.Invoke(i, currentSpeed * 1024); @@ -217,7 +216,11 @@ public sealed partial class MediaScan EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, + ibgLog.Close(_dev, + results.Blocks, + blockSize, + _scanStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); @@ -227,8 +230,7 @@ public sealed partial class MediaScan { for(var i = 0; i < seekTimes; i++) { - if(_aborted) - break; + if(_aborted) break; var seekPos = (uint)rnd.Next((int)results.Blocks); @@ -236,11 +238,9 @@ public sealed partial class MediaScan ataReader.Seek(seekPos, out seekCur); - if(seekCur > results.SeekMax && seekCur > 0) - results.SeekMax = seekCur; + if(seekCur > results.SeekMax && seekCur > 0) results.SeekMax = seekCur; - if(seekCur < results.SeekMin && seekCur > 0) - results.SeekMin = seekCur; + if(seekCur < results.SeekMin && seekCur > 0) results.SeekMin = seekCur; results.SeekTotal += seekCur; GC.Collect(); @@ -268,20 +268,19 @@ public sealed partial class MediaScan { for(byte sc = 1; sc < sectors; sc++) { - if(_aborted) - break; + if(_aborted) break; - if(currentSpeed > results.MaxSpeed && currentSpeed > 0) - results.MaxSpeed = currentSpeed; + if(currentSpeed > results.MaxSpeed && currentSpeed > 0) results.MaxSpeed = currentSpeed; - if(currentSpeed < results.MinSpeed && currentSpeed > 0) - results.MinSpeed = currentSpeed; + if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; PulseProgress?.Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, - cy, hd, sc, - ByteSize.FromMegabytes(currentSpeed). - Per(_oneSecond). - Humanize())); + cy, + hd, + sc, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize())); bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out _); @@ -334,8 +333,7 @@ public sealed partial class MediaScan double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); ScanSpeed?.Invoke(currentBlock, currentSpeed * 1024); @@ -350,7 +348,11 @@ public sealed partial class MediaScan EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, + ibgLog.Close(_dev, + results.Blocks, + blockSize, + _scanStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); @@ -360,23 +362,22 @@ public sealed partial class MediaScan { for(var i = 0; i < seekTimes; i++) { - if(_aborted) - break; + if(_aborted) break; var seekCy = (ushort)rnd.Next(cylinders); var seekHd = (byte)rnd.Next(heads); var seekSc = (byte)rnd.Next(sectors); PulseProgress?.Invoke(string.Format(Localization.Core.Seeking_to_cylinder_0_head_1_sector_2, - seekCy, seekHd, seekSc)); + seekCy, + seekHd, + seekSc)); ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur); - if(seekCur > results.SeekMax && seekCur > 0) - results.SeekMax = seekCur; + if(seekCur > results.SeekMax && seekCur > 0) results.SeekMax = seekCur; - if(seekCur < results.SeekMin && seekCur > 0) - results.SeekMin = seekCur; + if(seekCur < results.SeekMin && seekCur > 0) results.SeekMin = seekCur; results.SeekTotal += seekCur; GC.Collect(); diff --git a/Aaru.Core/Devices/Scanning/SCSI.cs b/Aaru.Core/Devices/Scanning/SCSI.cs index 74d670a69..bc3d5f5ad 100644 --- a/Aaru.Core/Devices/Scanning/SCSI.cs +++ b/Aaru.Core/Devices/Scanning/SCSI.cs @@ -85,8 +85,7 @@ public sealed partial class MediaScan Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; leftRetries--; } @@ -110,17 +109,16 @@ public sealed partial class MediaScan Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; leftRetries--; } if(sense) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Error_testing_unit_was_ready_0, - Sense.PrettifySense(senseBuf))); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Error_testing_unit_was_ready_0, + Sense.PrettifySense(senseBuf))); return results; } @@ -139,17 +137,16 @@ public sealed partial class MediaScan Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; leftRetries--; } if(sense) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Error_testing_unit_was_ready_0, - Sense.PrettifySense(senseBuf))); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Error_testing_unit_was_ready_0, + Sense.PrettifySense(senseBuf))); return results; } @@ -201,10 +198,12 @@ public sealed partial class MediaScan { results.Blocks++; - UpdateStatus?. - Invoke(string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - results.Blocks, blockSize, - ByteSize.FromBytes(results.Blocks * blockSize).ToString("0.000"))); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, + results.Blocks, + blockSize, + ByteSize.FromBytes(results.Blocks * blockSize) + .ToString("0.000"))); } break; @@ -226,8 +225,12 @@ public sealed partial class MediaScan if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) { - sense = _dev.GetConfiguration(out byte[] cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, - _dev.Timeout, out _); + sense = _dev.GetConfiguration(out byte[] cmdBuf, + out senseBuf, + 0, + MmcGetConfigurationRt.Current, + _dev.Timeout, + out _); if(!sense) { @@ -260,8 +263,7 @@ public sealed partial class MediaScan // No TOC, no CD (or an empty one) bool tocSense = _dev.ReadRawToc(out cmdBuf, out senseBuf, 1, _dev.Timeout, out _); - if(!tocSense) - toc = FullTOC.Decode(cmdBuf); + if(!tocSense) toc = FullTOC.Decode(cmdBuf); } } else @@ -295,9 +297,22 @@ public sealed partial class MediaScan return results; } - readcd = !_dev.ReadCd(out _, out senseBuf, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + readcd = !_dev.ReadCd(out _, + out senseBuf, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); if(readcd) UpdateStatus?.Invoke(Localization.Core.Using_MMC_READ_CD_command); @@ -314,23 +329,34 @@ public sealed partial class MediaScan { while(true) { - sense = _dev.ReadCd(out _, out senseBuf, 0, 2352, blocksToRead, MmcSectorTypes.AllTypes, false, - false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out _); + sense = _dev.ReadCd(out _, + out senseBuf, + 0, + 2352, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out _); - if(_dev.Error || sense) - blocksToRead /= 2; + if(_dev.Error || sense) blocksToRead /= 2; - if(!_dev.Error || blocksToRead == 1) - break; + if(!_dev.Error || blocksToRead == 1) break; } } if(_dev.Error) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); return results; } @@ -347,29 +373,41 @@ public sealed partial class MediaScan for(ulong i = 0; i < results.Blocks; i += blocksToRead) { - if(_aborted) - break; + if(_aborted) break; double cmdDuration; - if(results.Blocks - i < blocksToRead) - blocksToRead = (uint)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i); - if(currentSpeed > results.MaxSpeed && currentSpeed > 0) - results.MaxSpeed = currentSpeed; + if(currentSpeed > results.MaxSpeed && currentSpeed > 0) results.MaxSpeed = currentSpeed; - if(currentSpeed < results.MinSpeed && currentSpeed > 0) - results.MinSpeed = currentSpeed; + if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)results.Blocks); if(readcd) { - sense = _dev.ReadCd(out _, out senseBuf, (uint)i, 2352, blocksToRead, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, out cmdDuration); + sense = _dev.ReadCd(out _, + out senseBuf, + (uint)i, + 2352, + blocksToRead, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, + out cmdDuration); } else sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out cmdDuration, out _, out _); @@ -416,7 +454,8 @@ public sealed partial class MediaScan if(readcd) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_CD_error_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_CD_error_0, Sense.PrettifySense(senseBuf)); senseDecoded = Sense.Decode(senseBuf); @@ -434,8 +473,7 @@ public sealed partial class MediaScan { results.Errored += blocksToRead; - for(ulong b = i; b < i + blocksToRead; b++) - results.UnreadableSectors.Add(b); + for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); ScanUnreadable?.Invoke(i); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration); @@ -450,8 +488,7 @@ public sealed partial class MediaScan ScanUnreadable?.Invoke(i); results.Errored += blocksToRead; - for(ulong b = i; b < i + blocksToRead; b++) - results.UnreadableSectors.Add(b); + for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration); @@ -463,8 +500,7 @@ public sealed partial class MediaScan double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); ScanSpeed?.Invoke(i, currentSpeed * 1024); @@ -480,14 +516,16 @@ public sealed partial class MediaScan currentSpeed = sectorSpeedStart * blockSize / (1048576 * _speedStopwatch.Elapsed.TotalSeconds); // ReSharper disable once CompareOfFloatsByEqualityOperator - if(results.MaxSpeed == double.MinValue) - results.MaxSpeed = currentSpeed; + if(results.MaxSpeed == double.MinValue) results.MaxSpeed = currentSpeed; // ReSharper disable once CompareOfFloatsByEqualityOperator - if(results.MinSpeed == double.MaxValue) - results.MinSpeed = currentSpeed; + if(results.MinSpeed == double.MaxValue) results.MinSpeed = currentSpeed; - ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, + ibgLog.Close(_dev, + results.Blocks, + blockSize, + _scanStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); } @@ -507,23 +545,22 @@ public sealed partial class MediaScan for(ulong i = 0; i < results.Blocks; i += scsiReader.BlocksToRead) { - if(_aborted) - break; + if(_aborted) break; blocksToRead = scsiReader.BlocksToRead; - if(results.Blocks - i < blocksToRead) - blocksToRead = (uint)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (uint)(results.Blocks - i); - if(currentSpeed > results.MaxSpeed && currentSpeed > 0) - results.MaxSpeed = currentSpeed; + if(currentSpeed > results.MaxSpeed && currentSpeed > 0) results.MaxSpeed = currentSpeed; - if(currentSpeed < results.MinSpeed && currentSpeed > 0) - results.MinSpeed = currentSpeed; + if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)results.Blocks); sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration, out _, out _); results.ProcessingTime += cmdDuration; @@ -569,8 +606,7 @@ public sealed partial class MediaScan ScanUnreadable?.Invoke(i); results.Errored += blocksToRead; - for(ulong b = i; b < i + blocksToRead; b++) - results.UnreadableSectors.Add(b); + for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration); ibgLog.Write(i, 0); @@ -580,8 +616,7 @@ public sealed partial class MediaScan double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); ScanSpeed?.Invoke(i, currentSpeed * 1024); @@ -594,7 +629,11 @@ public sealed partial class MediaScan EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, + ibgLog.Close(_dev, + results.Blocks, + blockSize, + _scanStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); } @@ -610,8 +649,7 @@ public sealed partial class MediaScan for(var i = 0; i < seekTimes; i++) { - if(_aborted || !_seekTest) - break; + if(_aborted || !_seekTest) break; var seekPos = (uint)rnd.Next((int)results.Blocks); @@ -623,18 +661,29 @@ public sealed partial class MediaScan scsiReader.Seek(seekPos, out seekCur); else if(readcd) { - _dev.ReadCd(out _, out _, seekPos, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + _dev.ReadCd(out _, + out _, + seekPos, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + _dev.Timeout, out seekCur); } else scsiReader.ReadBlock(out _, seekPos, out seekCur, out _, out _); - if(seekCur > results.SeekMax && seekCur > 0) - results.SeekMax = seekCur; + if(seekCur > results.SeekMax && seekCur > 0) results.SeekMax = seekCur; - if(seekCur < results.SeekMin && seekCur > 0) - results.SeekMin = seekCur; + if(seekCur < results.SeekMin && seekCur > 0) results.SeekMin = seekCur; results.SeekTotal += seekCur; GC.Collect(); diff --git a/Aaru.Core/Devices/Scanning/SecureDigital.cs b/Aaru.Core/Devices/Scanning/SecureDigital.cs index e5e7e3c66..70cafed94 100644 --- a/Aaru.Core/Devices/Scanning/SecureDigital.cs +++ b/Aaru.Core/Devices/Scanning/SecureDigital.cs @@ -88,8 +88,7 @@ public sealed partial class MediaScan blocksToRead = (ushort)(ecsd.OptimalReadSize * 4096 / blockSize); - if(blocksToRead == 0) - blocksToRead = 128; + if(blocksToRead == 0) blocksToRead = 128; // Supposing it's high-capacity MMC if it has Extended CSD... byteAddressed = false; @@ -128,8 +127,8 @@ public sealed partial class MediaScan if(!sense) { - supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?. - CommandSupport.HasFlag(CommandSupport.SetBlockCount) ?? + supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf) + ?.CommandSupport.HasFlag(CommandSupport.SetBlockCount) ?? false; } } @@ -151,8 +150,8 @@ public sealed partial class MediaScan if(sense || _dev.Error) { - UpdateStatus?.Invoke(Localization.Core. - Environment_does_not_support_setting_block_count_downgrading_to_OS_reading); + UpdateStatus?.Invoke(Localization.Core + .Environment_does_not_support_setting_block_count_downgrading_to_OS_reading); supportsCmd23 = false; } @@ -172,21 +171,25 @@ public sealed partial class MediaScan { while(true) { - sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, + sense = _dev.ReadWithBlockCount(out cmdBuf, + out _, + 0, + blockSize, + blocksToRead, + byteAddressed, + timeout, out duration); - if(sense) - blocksToRead /= 2; + if(sense) blocksToRead /= 2; - if(!sense || blocksToRead == 1) - break; + if(!sense || blocksToRead == 1) break; } if(sense) { - StoppingErrorMessage?. - Invoke(string.Format(Localization.Core.Device_error_0_trying_to_guess_ideal_transfer_length, - _dev.LastError)); + StoppingErrorMessage?.Invoke(string.Format(Localization.Core + .Device_error_0_trying_to_guess_ideal_transfer_length, + _dev.LastError)); return results; } @@ -235,40 +238,56 @@ public sealed partial class MediaScan for(ulong i = 0; i < results.Blocks; i += blocksToRead) { - if(_aborted) - break; + if(_aborted) break; - if(results.Blocks - i < blocksToRead) - blocksToRead = (byte)(results.Blocks - i); + if(results.Blocks - i < blocksToRead) blocksToRead = (byte)(results.Blocks - i); - if(currentSpeed > results.MaxSpeed && currentSpeed > 0) - results.MaxSpeed = currentSpeed; + if(currentSpeed > results.MaxSpeed && currentSpeed > 0) results.MaxSpeed = currentSpeed; - if(currentSpeed < results.MinSpeed && currentSpeed > 0) - results.MinSpeed = currentSpeed; + if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()), - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()), + (long)i, + (long)results.Blocks); bool error; if(blocksToRead == 1) { - error = _dev.ReadSingleBlock(out cmdBuf, out _, (uint)i, blockSize, byteAddressed, timeout, + error = _dev.ReadSingleBlock(out cmdBuf, + out _, + (uint)i, + blockSize, + byteAddressed, + timeout, out duration); } else if(supportsCmd23) { - error = _dev.ReadWithBlockCount(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadWithBlockCount(out cmdBuf, + out _, + (uint)i, + blockSize, + blocksToRead, + byteAddressed, + timeout, + out duration); } else if(_useBufferedReads) error = _dev.BufferedOsRead(out cmdBuf, (long)(i * blockSize), blockSize * blocksToRead, out duration); else { - error = _dev.ReadMultipleUsingSingle(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadMultipleUsingSingle(out cmdBuf, + out _, + (uint)i, + blockSize, + blocksToRead, + byteAddressed, + timeout, + out duration); } if(!error) @@ -310,8 +329,7 @@ public sealed partial class MediaScan ScanUnreadable?.Invoke(i); results.Errored += blocksToRead; - for(ulong b = i; b < i + blocksToRead; b++) - results.UnreadableSectors.Add(b); + for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); mhddLog.Write(i, duration < 500 ? 65535 : duration); @@ -322,8 +340,7 @@ public sealed partial class MediaScan double elapsed = _speedStopwatch.Elapsed.TotalSeconds; - if(elapsed <= 0) - continue; + if(elapsed <= 0) continue; currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); ScanSpeed?.Invoke(i, currentSpeed * 1024); @@ -336,15 +353,19 @@ public sealed partial class MediaScan EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024, - blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); + ibgLog.Close(_dev, + results.Blocks, + blockSize, + _scanStopwatch.Elapsed.TotalSeconds, + currentSpeed * 1024, + blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), + _devicePath); InitProgress?.Invoke(); for(var i = 0; i < seekTimes; i++) { - if(_aborted || !_seekTest) - break; + if(_aborted || !_seekTest) break; var seekPos = (uint)rnd.Next((int)results.Blocks); @@ -352,11 +373,9 @@ public sealed partial class MediaScan _dev.ReadSingleBlock(out cmdBuf, out _, seekPos, blockSize, byteAddressed, timeout, out double seekCur); - if(seekCur > results.SeekMax && seekCur > 0) - results.SeekMax = seekCur; + if(seekCur > results.SeekMax && seekCur > 0) results.SeekMax = seekCur; - if(seekCur < results.SeekMin && seekCur > 0) - results.SeekMin = seekCur; + if(seekCur < results.SeekMin && seekCur > 0) results.SeekMin = seekCur; results.SeekTotal += seekCur; GC.Collect(); diff --git a/Aaru.Core/Entropy.cs b/Aaru.Core/Entropy.cs index 3584ab9fb..5ee87852b 100644 --- a/Aaru.Core/Entropy.cs +++ b/Aaru.Core/Entropy.cs @@ -103,9 +103,11 @@ public sealed class Entropy Entropy = 0 }; - UpdateProgressEvent?. - Invoke(string.Format(Localization.Core.Entropying_track_0_of_1, currentTrack.Sequence, inputTracks.Max(t => t.Sequence)), - currentTrack.Sequence, inputTracks.Max(t => t.Sequence)); + UpdateProgressEvent?.Invoke(string.Format(Localization.Core.Entropying_track_0_of_1, + currentTrack.Sequence, + inputTracks.Max(t => t.Sequence)), + currentTrack.Sequence, + inputTracks.Max(t => t.Sequence)); var entTable = new ulong[256]; ulong trackSize = 0; @@ -113,24 +115,28 @@ public sealed class Entropy trackEntropy.Sectors = currentTrack.EndSector - currentTrack.StartSector + 1; - AaruConsole.VerboseWriteLine(Localization.Core.Track_0_has_1_sectors, currentTrack.Sequence, + AaruConsole.VerboseWriteLine(Localization.Core.Track_0_has_1_sectors, + currentTrack.Sequence, trackEntropy.Sectors); InitProgress2Event?.Invoke(); for(ulong i = 0; i < trackEntropy.Sectors; i++) { - UpdateProgress2Event?. - Invoke(string.Format(Localization.Core.Entropying_sector_0_of_track_1, i + 1, currentTrack.Sequence), - (long)(i + 1), (long)currentTrack.EndSector); + UpdateProgress2Event?.Invoke(string.Format(Localization.Core.Entropying_sector_0_of_track_1, + i + 1, + currentTrack.Sequence), + (long)(i + 1), + (long)currentTrack.EndSector); ErrorNumber errno = opticalMediaImage.ReadSector(i, currentTrack.Sequence, out byte[] sector); if(errno != ErrorNumber.NoError) { - AaruConsole. - ErrorWriteLine(string.Format(Localization.Core.Error_0_while_reading_sector_1_continuing, - errno, i)); + AaruConsole.ErrorWriteLine(string.Format(Localization.Core + .Error_0_while_reading_sector_1_continuing, + errno, + i)); continue; } @@ -139,24 +145,21 @@ public sealed class Entropy { string sectorHash = Sha1Context.Data(sector, out _); - if(!uniqueSectorsPerTrack.Contains(sectorHash)) - uniqueSectorsPerTrack.Add(sectorHash); + if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash); } - foreach(byte b in sector) - entTable[b]++; + foreach(byte b in sector) entTable[b]++; trackSize += (ulong)sector.LongLength; } EndProgress2Event?.Invoke(); - trackEntropy.Entropy += entTable.Select(l => l / (double)trackSize). - Select(frequency => -(frequency * Math.Log(frequency, 2))). - Sum(); + trackEntropy.Entropy += entTable.Select(l => l / (double)trackSize) + .Select(frequency => -(frequency * Math.Log(frequency, 2))) + .Sum(); - if(duplicatedSectors) - trackEntropy.UniqueSectors = uniqueSectorsPerTrack.Count; + if(duplicatedSectors) trackEntropy.UniqueSectors = uniqueSectorsPerTrack.Count; entropyResults.Add(trackEntropy); } @@ -172,8 +175,8 @@ public sealed class Entropy } else { - AaruConsole.ErrorWriteLine(Localization.Core. - Unable_to_get_separate_tracks_not_calculating_their_entropy); + AaruConsole.ErrorWriteLine(Localization.Core + .Unable_to_get_separate_tracks_not_calculating_their_entropy); } } @@ -190,8 +193,7 @@ public sealed class Entropy Entropy = 0 }; - if(_inputFormat is not IMediaImage mediaImage) - return entropy; + if(_inputFormat is not IMediaImage mediaImage) return entropy; var entTable = new ulong[256]; ulong diskSize = 0; @@ -203,7 +205,8 @@ public sealed class Entropy for(ulong i = 0; i < entropy.Sectors; i++) { - UpdateProgressEvent?.Invoke(string.Format(Localization.Core.Entropying_sector_0, i + 1), (long)(i + 1), + UpdateProgressEvent?.Invoke(string.Format(Localization.Core.Entropying_sector_0, i + 1), + (long)(i + 1), (long)entropy.Sectors); ErrorNumber errno = mediaImage.ReadSector(i, out byte[] sector); @@ -211,7 +214,8 @@ public sealed class Entropy if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_while_reading_sector_1_continuing, - errno, i)); + errno, + i)); continue; } @@ -220,24 +224,21 @@ public sealed class Entropy { string sectorHash = Sha1Context.Data(sector, out _); - if(!uniqueSectors.Contains(sectorHash)) - uniqueSectors.Add(sectorHash); + if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash); } - foreach(byte b in sector) - entTable[b]++; + foreach(byte b in sector) entTable[b]++; diskSize += (ulong)sector.LongLength; } EndProgressEvent?.Invoke(); - entropy.Entropy += entTable.Select(l => l / (double)diskSize). - Select(frequency => -(frequency * Math.Log(frequency, 2))). - Sum(); + entropy.Entropy += entTable.Select(l => l / (double)diskSize) + .Select(frequency => -(frequency * Math.Log(frequency, 2))) + .Sum(); - if(duplicatedSectors) - entropy.UniqueSectors = uniqueSectors.Count; + if(duplicatedSectors) entropy.UniqueSectors = uniqueSectors.Count; return entropy; } @@ -251,8 +252,7 @@ public sealed class Entropy Entropy = 0 }; - if(_inputFormat is not IByteAddressableImage byteAddressableImage) - return entropy; + if(_inputFormat is not IByteAddressableImage byteAddressableImage) return entropy; var entTable = new ulong[256]; var data = new byte[byteAddressableImage.Info.Sectors]; @@ -278,14 +278,13 @@ public sealed class Entropy data = tmp; } - foreach(byte b in data) - entTable[b]++; + foreach(byte b in data) entTable[b]++; EndProgressEvent?.Invoke(); - entropy.Entropy += entTable.Select(l => l / (double)data.Length). - Select(frequency => -(frequency * Math.Log(frequency, 2))). - Sum(); + entropy.Entropy += entTable.Select(l => l / (double)data.Length) + .Select(frequency => -(frequency * Math.Log(frequency, 2))) + .Sum(); return entropy; } diff --git a/Aaru.Core/Filesystems.cs b/Aaru.Core/Filesystems.cs index 8027199c3..581ed62b2 100644 --- a/Aaru.Core/Filesystems.cs +++ b/Aaru.Core/Filesystems.cs @@ -66,9 +66,10 @@ public static class Filesystems } catch(Exception ex) { - AaruConsole. - ErrorWriteLine("Error identifying filesystem {0}. Please open a report with the following line in a Github issue.", + AaruConsole + .ErrorWriteLine("Error identifying filesystem {0}. Please open a report with the following line in a Github issue.", plugin.Name); + AaruConsole.WriteException(ex); } } diff --git a/Aaru.Core/Graphics/BlockMap.cs b/Aaru.Core/Graphics/BlockMap.cs index d171b26fd..ac7b7e7a2 100644 --- a/Aaru.Core/Graphics/BlockMap.cs +++ b/Aaru.Core/Graphics/BlockMap.cs @@ -90,21 +90,32 @@ public class BlockMap : IMediaGraph _canvas = new SKCanvas(_bitmap); // Paint background white - _canvas.DrawRect(0, 0, w, h, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = SKColors.White - }); + _canvas.DrawRect(0, + 0, + w, + h, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = SKColors.White + }); // Paint undumped sectors - _canvas.DrawRect(0, 0, w, h - removeRows * (_squareSize + 1) - _squareSize - 2, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = SKColors.Gray - }); + _canvas.DrawRect(0, + 0, + w, + h - removeRows * (_squareSize + 1) - _squareSize - 2, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = SKColors.Gray + }); - _canvas.DrawRect(0, h - removeRows * (_squareSize + 1) - _squareSize - 2, - (_columns - removeSquaresAtLastRow) * (_squareSize + 1), _squareSize + 2, new SKPaint + _canvas.DrawRect(0, + h - removeRows * (_squareSize + 1) - _squareSize - 2, + (_columns - removeSquaresAtLastRow) * (_squareSize + 1), + _squareSize + 2, + new SKPaint { Style = SKPaintStyle.StrokeAndFill, Color = SKColors.Gray @@ -117,19 +128,27 @@ public class BlockMap : IMediaGraph { int cw = _columns - removeSquaresAtLastRow; - _canvas.DrawLine(0f, y, cw * (_squareSize + 1), y, new SKPaint - { - StrokeWidth = 1f, - Color = SKColors.Black - }); + _canvas.DrawLine(0f, + y, + cw * (_squareSize + 1), + y, + new SKPaint + { + StrokeWidth = 1f, + Color = SKColors.Black + }); } else { - _canvas.DrawLine(0f, y, w, y, new SKPaint - { - StrokeWidth = 1f, - Color = SKColors.Black - }); + _canvas.DrawLine(0f, + y, + w, + y, + new SKPaint + { + StrokeWidth = 1f, + Color = SKColors.Black + }); } } @@ -139,19 +158,27 @@ public class BlockMap : IMediaGraph if(_columns - currentColumn + 1 > removeSquaresAtLastRow) { - _canvas.DrawLine(x, 0, x, h - removeRows * (_squareSize + 1), new SKPaint - { - StrokeWidth = 1f, - Color = SKColors.Black - }); + _canvas.DrawLine(x, + 0, + x, + h - removeRows * (_squareSize + 1), + new SKPaint + { + StrokeWidth = 1f, + Color = SKColors.Black + }); } else { - _canvas.DrawLine(x, 0, x, h - removeRows * (_squareSize + 1) - _squareSize - 2, new SKPaint - { - StrokeWidth = 1f, - Color = SKColors.Black - }); + _canvas.DrawLine(x, + 0, + x, + h - removeRows * (_squareSize + 1) - _squareSize - 2, + new SKPaint + { + StrokeWidth = 1f, + Color = SKColors.Black + }); } } } @@ -239,11 +266,12 @@ public class BlockMap : IMediaGraph SKRect rect = GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); - _canvas.DrawRect(rect, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); } void PaintSectors(ulong startingSector, uint length, SKColor color) @@ -253,11 +281,12 @@ public class BlockMap : IMediaGraph SKRect rect = GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); - _canvas.DrawRect(rect, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); } } @@ -268,11 +297,12 @@ public class BlockMap : IMediaGraph : (int)(sector / (ulong)_sectorsPerSquare)))) { - _canvas.DrawRect(rect, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); } } diff --git a/Aaru.Core/Graphics/Spiral.cs b/Aaru.Core/Graphics/Spiral.cs index c35b0cc6c..994ebfe4b 100644 --- a/Aaru.Core/Graphics/Spiral.cs +++ b/Aaru.Core/Graphics/Spiral.cs @@ -103,8 +103,7 @@ public sealed class Spiral : IMediaGraph /// Last sector that will be drawn into the spiral public Spiral(int width, int height, DiscParameters parameters, ulong lastSector) { - if(parameters == _gdParameters || parameters == _gdRecordableParameters) - _gdrom = true; + if(parameters == _gdParameters || parameters == _gdRecordableParameters) _gdrom = true; // GD-ROM LD area ends at 29mm, HD area starts at 30mm radius @@ -135,8 +134,7 @@ public sealed class Spiral : IMediaGraph var lastSector1 = (long)lastSector; // If the dumped media is overburnt - if(lastSector1 > _maxSector) - _maxSector = lastSector1; + if(lastSector1 > _maxSector) _maxSector = lastSector1; // Ensure the disc hole is not painted over var clipPath = new SKPath(); @@ -144,62 +142,74 @@ public sealed class Spiral : IMediaGraph _canvas.ClipPath(clipPath, SKClipOperation.Difference); // Paint CD - _canvas.DrawCircle(center, smallerDimension / 2f, new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = parameters.DiscColor - }); + _canvas.DrawCircle(center, + smallerDimension / 2f, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = parameters.DiscColor + }); // Draw out border of disc - _canvas.DrawCircle(center, smallerDimension / 2f, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Black, - StrokeWidth = 4 - }); + _canvas.DrawCircle(center, + smallerDimension / 2f, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Black, + StrokeWidth = 4 + }); // Draw disc hole border - _canvas.DrawCircle(center, centerHoleDiameter / 2f, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Black, - StrokeWidth = 4 - }); + _canvas.DrawCircle(center, + centerHoleDiameter / 2f, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Black, + StrokeWidth = 4 + }); // Draw clamping area - _canvas.DrawCircle(center, clampingDiameter / 2f, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Gray, - StrokeWidth = 4 - }); + _canvas.DrawCircle(center, + clampingDiameter / 2f, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Gray, + StrokeWidth = 4 + }); // Some trigonometry thing I do not understand fully but it controls the space between the spiral turns const float a = 1f; // Draw the Lead-In - _leadInPoints = GetSpiralPoints(center, informationAreaStartDiameter / 2, leadInEndDiameter / 2, + _leadInPoints = GetSpiralPoints(center, + informationAreaStartDiameter / 2, + leadInEndDiameter / 2, _gdrom ? a : a * 1.5f); var path = new SKPath(); path.MoveTo(_leadInPoints[0]); - foreach(SKPoint point in _leadInPoints) - path.LineTo(point); + foreach(SKPoint point in _leadInPoints) path.LineTo(point); - _canvas.DrawPath(path, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.LightGray, - StrokeWidth = 2 - }); + _canvas.DrawPath(path, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.LightGray, + StrokeWidth = 2 + }); // If there's a recordable information area, get its points if(recordableAreaEndDiameter > 0 && recordableAreaStartDiameter > 0) { - _recordableInformationPoints = GetSpiralPoints(center, recordableAreaStartDiameter / 2, - recordableAreaEndDiameter / 2, _gdrom ? a : a * 1.5f); + _recordableInformationPoints = GetSpiralPoints(center, + recordableAreaStartDiameter / 2, + recordableAreaEndDiameter / 2, + _gdrom ? a : a * 1.5f); } if(_gdrom) @@ -219,15 +229,15 @@ public sealed class Spiral : IMediaGraph { path.MoveTo(_pointsLowDensity[0]); - foreach(SKPoint point in _pointsLowDensity) - path.LineTo(point); + foreach(SKPoint point in _pointsLowDensity) path.LineTo(point); - _canvas.DrawPath(path, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Gray, - StrokeWidth = 2 - }); + _canvas.DrawPath(path, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Gray, + StrokeWidth = 2 + }); } path.MoveTo(_points[0]); @@ -240,22 +250,19 @@ public sealed class Spiral : IMediaGraph pointsPerSector = _points.Count / (_maxSector - 45000); sectorsPerPoint = (_maxSector - 45000) / _points.Count; - if((_maxSector - 45000) % _points.Count > 0) - sectorsPerPoint++; + if((_maxSector - 45000) % _points.Count > 0) sectorsPerPoint++; } else { pointsPerSector = _points.Count / _maxSector; sectorsPerPoint = _maxSector / _points.Count; - if(_maxSector % _points.Count > 0) - sectorsPerPoint++; + if(_maxSector % _points.Count > 0) sectorsPerPoint++; } long lastPoint; - if(_gdrom) - lastSector1 -= 45000; + if(_gdrom) lastSector1 -= 45000; if(pointsPerSector > 0) lastPoint = lastSector1 * pointsPerSector; @@ -268,12 +275,13 @@ public sealed class Spiral : IMediaGraph path.LineTo(point); } - _canvas.DrawPath(path, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Gray, - StrokeWidth = 2 - }); + _canvas.DrawPath(path, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Gray, + StrokeWidth = 2 + }); } public SKBitmap Bitmap { get; } @@ -344,22 +352,21 @@ public sealed class Spiral : IMediaGraph /// Paints the segment of the spiral that corresponds to the information specific to recordable discs in green public void PaintRecordableInformationGood() { - if(_recordableInformationPoints is null) - return; + if(_recordableInformationPoints is null) return; var path = new SKPath(); path.MoveTo(_recordableInformationPoints[0]); - foreach(SKPoint point in _recordableInformationPoints) - path.LineTo(point); + foreach(SKPoint point in _recordableInformationPoints) path.LineTo(point); - _canvas.DrawPath(path, new SKPaint - { - Style = SKPaintStyle.Stroke, - Color = SKColors.Green, - StrokeWidth = 2 - }); + _canvas.DrawPath(path, + new SKPaint + { + Style = SKPaintStyle.Stroke, + Color = SKColors.Green, + StrokeWidth = 2 + }); } /// @@ -465,14 +472,12 @@ public sealed class Spiral : IMediaGraph void PaintSectors(ulong startingSector, uint length, SKColor color) { - for(uint i = 0; i < length; i++) - PaintSector(startingSector + i, color); + for(uint i = 0; i < length; i++) PaintSector(startingSector + i, color); } void PaintSectors(IEnumerable sectors, SKColor color) { - foreach(ulong sector in sectors) - PaintSector(sector, color); + foreach(ulong sector in sectors) PaintSector(sector, color); } /// Paints the segment of the spiral that corresponds to the specified sector in the specified color @@ -491,8 +496,7 @@ public sealed class Spiral : IMediaGraph pointsPerSector = points.Count / 45000; sectorsPerPoint = 45000 / points.Count; - if(45000 % points.Count > 0) - sectorsPerPoint++; + if(45000 % points.Count > 0) sectorsPerPoint++; } else { @@ -500,8 +504,7 @@ public sealed class Spiral : IMediaGraph pointsPerSector = points.Count / (_maxSector - 45000); sectorsPerPoint = (_maxSector - 45000) / points.Count; - if((_maxSector - 45000) % points.Count > 0) - sectorsPerPoint++; + if((_maxSector - 45000) % points.Count > 0) sectorsPerPoint++; } } else @@ -509,8 +512,7 @@ public sealed class Spiral : IMediaGraph pointsPerSector = points.Count / _maxSector; sectorsPerPoint = _maxSector / points.Count; - if(_maxSector % points.Count > 0) - sectorsPerPoint++; + if(_maxSector % points.Count > 0) sectorsPerPoint++; } var paint = new SKPaint @@ -528,8 +530,7 @@ public sealed class Spiral : IMediaGraph path.MoveTo(points[(int)firstPoint]); - for(var i = (int)firstPoint; i < firstPoint + pointsPerSector; i++) - path.LineTo(points[i]); + for(var i = (int)firstPoint; i < firstPoint + pointsPerSector; i++) path.LineTo(points[i]); _canvas.DrawPath(path, paint); @@ -569,8 +570,7 @@ public sealed class Spiral : IMediaGraph long pointsPerSector = _leadInPoints.Count / leadInSize; long sectorsPerPoint = leadInSize / _leadInPoints.Count; - if(leadInSize % _leadInPoints.Count > 0) - sectorsPerPoint++; + if(leadInSize % _leadInPoints.Count > 0) sectorsPerPoint++; var paint = new SKPaint { @@ -587,8 +587,7 @@ public sealed class Spiral : IMediaGraph path.MoveTo(_leadInPoints[(int)firstPoint]); - for(var i = (int)firstPoint; i < firstPoint + pointsPerSector; i++) - path.LineTo(_leadInPoints[i]); + for(var i = (int)firstPoint; i < firstPoint + pointsPerSector; i++) path.LineTo(_leadInPoints[i]); _canvas.DrawPath(path, paint); @@ -633,8 +632,7 @@ public sealed class Spiral : IMediaGraph // Calculate r. float r = a * theta; - if(r < minRadius) - continue; + if(r < minRadius) continue; // Converts polar coordinates (r,theta) to Cartesian (x,y) var x = (float)(r * Math.Cos(theta)); @@ -648,8 +646,7 @@ public sealed class Spiral : IMediaGraph points.Add(new SKPoint(x, y)); // Terminate the loop if we have reached the end of the spiral - if(r > maxRadius) - break; + if(r > maxRadius) break; } return points; @@ -668,10 +665,19 @@ public sealed class Spiral : IMediaGraph /// Diameter at which the information specific to recordable media starts /// Number of maximum sectors, for discs following the specifications /// Typical disc color - public sealed record DiscParameters(float DiscDiameter, float CenterHole, float ClampingMinimum, - float InformationAreaStart, float LeadInEnd, float InformationAreaEnd, - float RecordableInformationStart, float RecordableInformationEnd, - int NominalMaxSectors, SKColor DiscColor); + public sealed record DiscParameters + ( + float DiscDiameter, + float CenterHole, + float ClampingMinimum, + float InformationAreaStart, + float LeadInEnd, + float InformationAreaEnd, + float RecordableInformationStart, + float RecordableInformationEnd, + int NominalMaxSectors, + SKColor DiscColor + ); #endregion } \ No newline at end of file diff --git a/Aaru.Core/ImageFormat.cs b/Aaru.Core/ImageFormat.cs index 5d33c9bc8..e60696638 100644 --- a/Aaru.Core/ImageFormat.cs +++ b/Aaru.Core/ImageFormat.cs @@ -56,84 +56,73 @@ public static class ImageFormat // Check all but RAW plugin foreach(IMediaImage imagePlugin in plugins.MediaImages.Values) { - if(imagePlugin is null) - continue; + if(imagePlugin is null) continue; - if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - continue; + if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) continue; try { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Trying_plugin_0, imagePlugin.Name); - if(!imagePlugin.Identify(imageFilter)) - continue; + if(!imagePlugin.Identify(imageFilter)) continue; imageFormat = imagePlugin; break; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored } } - if(imageFormat != null) - return imageFormat; + if(imageFormat != null) return imageFormat; // Check all but RAW plugin foreach(IByteAddressableImage imagePlugin in plugins.ByteAddressableImages.Values) { try { - if(imagePlugin is null) - continue; + if(imagePlugin is null) continue; - if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - continue; + if(imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) continue; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Trying_plugin_0, imagePlugin.Name); - if(!imagePlugin.Identify(imageFilter)) - continue; + if(!imagePlugin.Identify(imageFilter)) continue; imageFormat = imagePlugin; break; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored } } - if(imageFormat != null) - return imageFormat; + if(imageFormat != null) return imageFormat; // Check only RAW plugin foreach(IMediaImage imagePlugin in plugins.MediaImages.Values) { - if(imagePlugin is null) - continue; + if(imagePlugin is null) continue; - if(imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - continue; + if(imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) continue; try { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Trying_plugin_0, imagePlugin.Name); - if(!imagePlugin.Identify(imageFilter)) - continue; + if(!imagePlugin.Identify(imageFilter)) continue; imageFormat = imagePlugin; break; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index 18b77738a..6560d01f9 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -75,7 +75,8 @@ public static class ImageInfo if(!string.IsNullOrWhiteSpace(imageFormat.Info.Version)) { - AaruConsole.WriteLine(Localization.Core.Format_0_version_1_WithMarkup, Markup.Escape(imageFormat.Format), + AaruConsole.WriteLine(Localization.Core.Format_0_version_1_WithMarkup, + Markup.Escape(imageFormat.Format), Markup.Escape(imageFormat.Info.Version)); } else @@ -99,7 +100,8 @@ public static class ImageInfo AaruConsole.WriteLine(Localization.Core.Image_without_headers_is_0_bytes_long, imageFormat.Info.ImageSize); AaruConsole.WriteLine(Localization.Core.Contains_a_media_of_0_sectors_with_a_maximum_sector_size_of_1_bytes_etc, - imageFormat.Info.Sectors, imageFormat.Info.SectorSize, + imageFormat.Info.Sectors, + imageFormat.Info.SectorSize, ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize).Humanize()); if(!string.IsNullOrWhiteSpace(imageFormat.Info.Creator)) @@ -112,7 +114,8 @@ public static class ImageInfo AaruConsole.WriteLine(Localization.Core.Last_modified_on_0, imageFormat.Info.LastModificationTime); AaruConsole.WriteLine(Localization.Core.Contains_a_media_of_type_0_and_XML_type_1_WithMarkup, - imageFormat.Info.MediaType, imageFormat.Info.MetadataMediaType); + imageFormat.Info.MediaType, + imageFormat.Info.MetadataMediaType); AaruConsole.WriteLine(imageFormat.Info.HasPartitions ? Localization.Core.Has_partitions @@ -128,7 +131,8 @@ public static class ImageInfo if(imageFormat.Info.MediaSequence != 0 && imageFormat.Info.LastMediaSequence != 0) { AaruConsole.WriteLine(Localization.Core.Media_is_number_0_on_a_set_of_1_medias, - imageFormat.Info.MediaSequence, imageFormat.Info.LastMediaSequence); + imageFormat.Info.MediaSequence, + imageFormat.Info.LastMediaSequence); } if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle)) @@ -197,7 +201,9 @@ public static class ImageInfo imageFormat is not ITapeImage { IsTape: true }) { AaruConsole.WriteLine(Localization.Core.Media_geometry_0_cylinders_1_heads_2_sectors_per_track_WithMarkup, - imageFormat.Info.Cylinders, imageFormat.Info.Heads, imageFormat.Info.SectorsPerTrack); + imageFormat.Info.Cylinders, + imageFormat.Info.Heads, + imageFormat.Info.SectorsPerTrack); } if(imageFormat.Info.ReadableMediaTags is { Count: > 0 }) @@ -229,8 +235,7 @@ public static class ImageInfo else PrintBlockImageInfo(imageFormat as IMediaImage); - if(imageFormat.DumpHardware == null) - return; + if(imageFormat.DumpHardware == null) return; int manufacturerLen = Localization.Core.Title_Manufacturer.Length; int modelLen = Localization.Core.Title_Model.Length; @@ -242,31 +247,23 @@ public static class ImageInfo foreach(DumpHardware dump in imageFormat.DumpHardware) { - if(dump.Manufacturer?.Length > manufacturerLen) - manufacturerLen = dump.Manufacturer.Length; + if(dump.Manufacturer?.Length > manufacturerLen) manufacturerLen = dump.Manufacturer.Length; - if(dump.Model?.Length > modelLen) - modelLen = dump.Model.Length; + if(dump.Model?.Length > modelLen) modelLen = dump.Model.Length; - if(dump.Serial?.Length > serialLen) - serialLen = dump.Serial.Length; + if(dump.Serial?.Length > serialLen) serialLen = dump.Serial.Length; - if(dump.Software?.Name?.Length > softwareLen) - softwareLen = dump.Software.Name.Length; + if(dump.Software?.Name?.Length > softwareLen) softwareLen = dump.Software.Name.Length; - if(dump.Software?.Version?.Length > versionLen) - versionLen = dump.Software.Version.Length; + if(dump.Software?.Version?.Length > versionLen) versionLen = dump.Software.Version.Length; - if(dump.Software?.OperatingSystem?.Length > osLen) - osLen = dump.Software.OperatingSystem.Length; + if(dump.Software?.OperatingSystem?.Length > osLen) osLen = dump.Software.OperatingSystem.Length; foreach(Extent extent in dump.Extents) { - if($"{extent.Start}".Length > sectorLen) - sectorLen = $"{extent.Start}".Length; + if($"{extent.Start}".Length > sectorLen) sectorLen = $"{extent.Start}".Length; - if($"{extent.End}".Length > sectorLen) - sectorLen = $"{extent.End}".Length; + if($"{extent.End}".Length > sectorLen) sectorLen = $"{extent.End}".Length; } } @@ -288,10 +285,13 @@ public static class ImageInfo { foreach(Extent extent in dump.Extents) { - table.AddRow(Markup.Escape(dump.Manufacturer ?? ""), Markup.Escape(dump.Model ?? ""), - Markup.Escape(dump.Serial ?? ""), Markup.Escape(dump.Software.Name ?? ""), - Markup.Escape(dump.Software.Version ?? ""), - Markup.Escape(dump.Software.OperatingSystem ?? ""), extent.Start.ToString(), + table.AddRow(Markup.Escape(dump.Manufacturer ?? ""), + Markup.Escape(dump.Model ?? ""), + Markup.Escape(dump.Serial ?? ""), + Markup.Escape(dump.Software.Name ?? ""), + Markup.Escape(dump.Software.Version ?? ""), + Markup.Escape(dump.Software.OperatingSystem ?? ""), + extent.Start.ToString(), extent.End.ToString()); } } @@ -303,20 +303,22 @@ public static class ImageInfo { ErrorNumber errno = imageFormat.GetMappings(out LinearMemoryMap mappings); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; AaruConsole.WriteLine(Localization.Core.Mapping_WithMarkup); - AaruConsole.WriteLine("{0}", Markup.Escape(JsonSerializer.Serialize(mappings, new JsonSerializerOptions - { - WriteIndented = true, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - Converters = - { - new JsonStringEnumConverter() - } - }))); + AaruConsole.WriteLine("{0}", + Markup.Escape(JsonSerializer.Serialize(mappings, + new JsonSerializerOptions + { + WriteIndented = true, + DefaultIgnoreCondition = + JsonIgnoreCondition.WhenWritingNull, + Converters = + { + new JsonStringEnumConverter() + } + }))); } static void PrintBlockImageInfo(IMediaImage imageFormat) @@ -455,8 +457,8 @@ public static class ImageInfo pma = tmp; } - AaruConsole.WriteLine(Localization.Core. - CompactDisc_Power_Management_Area_contained_in_image_WithMarkup); + AaruConsole.WriteLine(Localization.Core + .CompactDisc_Power_Management_Area_contained_in_image_WithMarkup); AaruConsole.Write("{0}", PMA.Prettify(pma)); AaruConsole.WriteLine(); @@ -482,8 +484,8 @@ public static class ImageInfo atip = tmp; } - AaruConsole.WriteLine(Localization.Core. - CompactDisc_Absolute_Time_In_Pregroove_ATIP_contained_in_image_WithMarkup); + AaruConsole.WriteLine(Localization.Core + .CompactDisc_Absolute_Time_In_Pregroove_ATIP_contained_in_image_WithMarkup); AaruConsole.Write("{0}", ATIP.Prettify(atip)); AaruConsole.WriteLine(); @@ -521,9 +523,9 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { - AaruConsole. - WriteLine(Localization.Core.CompactDisc_Media_Catalogue_Number_contained_in_image_0_WithMarkup, - Encoding.UTF8.GetString(mcn)); + AaruConsole.WriteLine(Localization.Core + .CompactDisc_Media_Catalogue_Number_contained_in_image_0_WithMarkup, + Encoding.UTF8.GetString(mcn)); AaruConsole.WriteLine(); } @@ -559,8 +561,8 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { - AaruConsole.WriteLine(Localization.Core. - DVD_RAM_Disc_Definition_Structure_contained_in_image_WithMarkup); + AaruConsole.WriteLine(Localization.Core + .DVD_RAM_Disc_Definition_Structure_contained_in_image_WithMarkup); AaruConsole.Write("{0}", DDS.Prettify(dds)); AaruConsole.WriteLine(); @@ -573,8 +575,8 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { - AaruConsole.WriteLine(Localization.Core. - DVD_R_Physical_Format_Information_contained_in_image_WithMarkup); + AaruConsole.WriteLine(Localization.Core + .DVD_R_Physical_Format_Information_contained_in_image_WithMarkup); AaruConsole.Write("{0}", PFI.Prettify(pfi, imageFormat.Info.MediaType)); AaruConsole.WriteLine(); @@ -676,7 +678,8 @@ public static class ImageInfo break; default: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_unknown_tuple_ID_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Found_unknown_tuple_ID_0, (byte)tuple.Code); break; @@ -840,11 +843,9 @@ public static class ImageInfo } } - if(imageFormat is IFluxImage fluxImage) - AaruConsole.WriteLine(Localization.Core.Image_flux_captures); + if(imageFormat is IFluxImage fluxImage) AaruConsole.WriteLine(Localization.Core.Image_flux_captures); - if(imageFormat is not IOpticalMediaImage opticalImage) - return; + if(imageFormat is not IOpticalMediaImage opticalImage) return; try { @@ -863,8 +864,10 @@ public static class ImageInfo foreach(Session session in opticalImage.Sessions) { - table.AddRow(session.Sequence.ToString(), session.StartTrack.ToString(), - session.EndTrack.ToString(), session.StartSector.ToString(), + table.AddRow(session.Sequence.ToString(), + session.StartTrack.ToString(), + session.EndTrack.ToString(), + session.StartSector.ToString(), session.EndSector.ToString()); } @@ -879,8 +882,7 @@ public static class ImageInfo try { - if(opticalImage.Tracks is not { Count: > 0 }) - return; + if(opticalImage.Tracks is not { Count: > 0 }) return; var table = new Table { @@ -898,15 +900,19 @@ public static class ImageInfo foreach(Track track in opticalImage.Tracks) { - table.AddRow(track.Sequence.ToString(), track.Type.ToString(), track.BytesPerSector.ToString(), - track.RawBytesPerSector.ToString(), track.SubchannelType.ToString(), - track.Pregap.ToString(), track.StartSector.ToString(), track.EndSector.ToString()); + table.AddRow(track.Sequence.ToString(), + track.Type.ToString(), + track.BytesPerSector.ToString(), + track.RawBytesPerSector.ToString(), + track.SubchannelType.ToString(), + track.Pregap.ToString(), + track.StartSector.ToString(), + track.EndSector.ToString()); } AnsiConsole.Write(table); - if(!opticalImage.Tracks.Any(t => t.Indexes.Any())) - return; + if(!opticalImage.Tracks.Any(t => t.Indexes.Any())) return; AaruConsole.WriteLine(); @@ -920,8 +926,10 @@ public static class ImageInfo table.AddColumn(Localization.Core.Title_Start); foreach(Track track in opticalImage.Tracks) - foreach(KeyValuePair index in track.Indexes) - table.AddRow(track.Sequence.ToString(), index.Key.ToString(), index.Value.ToString()); + { + foreach(KeyValuePair index in track.Indexes) + table.AddRow(track.Sequence.ToString(), index.Key.ToString(), index.Value.ToString()); + } AnsiConsole.Write(table); } diff --git a/Aaru.Core/Logging/DumpLog.cs b/Aaru.Core/Logging/DumpLog.cs index ef1211349..8c49ddd83 100644 --- a/Aaru.Core/Logging/DumpLog.cs +++ b/Aaru.Core/Logging/DumpLog.cs @@ -52,8 +52,7 @@ public sealed class DumpLog /// Disable saving paths or serial numbers in log public DumpLog(string outputFile, Device dev, bool @private) { - if(string.IsNullOrEmpty(outputFile)) - return; + if(string.IsNullOrEmpty(outputFile)) return; _logSw = new StreamWriter(outputFile, true); @@ -68,7 +67,9 @@ public sealed class DumpLog _logSw.WriteLine(Localization.Core.System_information); - _logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, + _logSw.WriteLine("{0} {1} ({2}-bit)", + DetectOS.GetPlatformName(platId, platVer), + platVer, Environment.Is64BitOperatingSystem ? 64 : 32); if(DetectOS.IsMono) @@ -87,9 +88,9 @@ public sealed class DumpLog _logSw.WriteLine(DetectOS.IsAdmin ? Localization.Core.Running_as_superuser_Yes : Localization.Core.Running_as_superuser_No); - #if DEBUG +#if DEBUG _logSw.WriteLine(Localization.Core.DEBUG_version); - #endif +#endif if(@private) { string[] args = Environment.GetCommandLineArgs(); @@ -123,7 +124,8 @@ public sealed class DumpLog _logSw.WriteLine(Localization.Core.Server_0, remoteDev.RemoteApplication); _logSw.WriteLine(Localization.Core.Version_0, remoteDev.RemoteVersion); - _logSw.WriteLine(Localization.Core.Operating_system_0_1, remoteDev.RemoteOperatingSystem, + _logSw.WriteLine(Localization.Core.Operating_system_0_1, + remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion); _logSw.WriteLine(Localization.Core.Architecture_0, remoteDev.RemoteArchitecture); @@ -141,8 +143,7 @@ public sealed class DumpLog _logSw.WriteLine(Localization.Core.Model_0, dev.Model); _logSw.WriteLine(Localization.Core.Firmware_revision_0, dev.FirmwareRevision); - if(!@private) - _logSw.WriteLine(Localization.Core.Serial_number_0, dev.Serial); + if(!@private) _logSw.WriteLine(Localization.Core.Serial_number_0, dev.Serial); _logSw.WriteLine(Localization.Core.Removable_device_0, dev.IsRemovable); _logSw.WriteLine(Localization.Core.Device_type_0, dev.Type); @@ -155,8 +156,7 @@ public sealed class DumpLog _logSw.WriteLine(Localization.Core.USB_manufacturer_0, dev.UsbManufacturerString); _logSw.WriteLine(Localization.Core.USB_product_0, dev.UsbProductString); - if(!@private) - _logSw.WriteLine(Localization.Core.USB_serial_0, dev.UsbSerialString); + if(!@private) _logSw.WriteLine(Localization.Core.USB_serial_0, dev.UsbSerialString); _logSw.WriteLine(Localization.Core.USB_vendor_ID_0, dev.UsbVendorId); _logSw.WriteLine(Localization.Core.USB_product_ID_0, dev.UsbProductId); @@ -169,8 +169,7 @@ public sealed class DumpLog _logSw.WriteLine(Localization.Core.FireWire_vendor_0, dev.FireWireVendorName); _logSw.WriteLine(Localization.Core.FireWire_model_0, dev.FireWireModelName); - if(!@private) - _logSw.WriteLine(Localization.Core.FireWire_GUID_0, dev.FireWireGuid); + if(!@private) _logSw.WriteLine(Localization.Core.FireWire_GUID_0, dev.FireWireGuid); _logSw.WriteLine(Localization.Core.FireWire_vendor_ID_0, dev.FireWireVendor); _logSw.WriteLine(Localization.Core.FireWire_product_ID_0, dev.FireWireModel); @@ -188,8 +187,7 @@ public sealed class DumpLog /// Arguments public void WriteLine(string format, params object[] args) { - if(_logSw == null) - return; + if(_logSw == null) return; var text = string.Format(format, args); _logSw.WriteLine("{0:s} {1}", DateTime.Now, text); diff --git a/Aaru.Core/Logging/ErrorLog.cs b/Aaru.Core/Logging/ErrorLog.cs index 169d4a683..0a055b1c3 100644 --- a/Aaru.Core/Logging/ErrorLog.cs +++ b/Aaru.Core/Logging/ErrorLog.cs @@ -44,8 +44,7 @@ public sealed class ErrorLog /// Output log file public ErrorLog(string outputFile) { - if(string.IsNullOrEmpty(outputFile)) - return; + if(string.IsNullOrEmpty(outputFile)) return; _logSw = new StreamWriter(outputFile, true); @@ -79,56 +78,42 @@ public sealed class ErrorLog List error = new(); List status = new(); - if((registers.Status & 0x01) == 0x01) - status.Add("ERR"); + if((registers.Status & 0x01) == 0x01) status.Add("ERR"); - if((registers.Status & 0x02) == 0x02) - status.Add("IDX"); + if((registers.Status & 0x02) == 0x02) status.Add("IDX"); - if((registers.Status & 0x04) == 0x04) - status.Add("CORR"); + if((registers.Status & 0x04) == 0x04) status.Add("CORR"); - if((registers.Status & 0x08) == 0x08) - status.Add("DRQ"); + if((registers.Status & 0x08) == 0x08) status.Add("DRQ"); - if((registers.Status & 0x10) == 0x10) - status.Add("SRV"); + if((registers.Status & 0x10) == 0x10) status.Add("SRV"); - if((registers.Status & 0x20) == 0x20) - status.Add("DF"); + if((registers.Status & 0x20) == 0x20) status.Add("DF"); - if((registers.Status & 0x40) == 0x40) - status.Add("RDY"); + if((registers.Status & 0x40) == 0x40) status.Add("RDY"); - if((registers.Status & 0x80) == 0x80) - status.Add("BSY"); + if((registers.Status & 0x80) == 0x80) status.Add("BSY"); - if((registers.Error & 0x01) == 0x01) - error.Add("AMNF"); + if((registers.Error & 0x01) == 0x01) error.Add("AMNF"); - if((registers.Error & 0x02) == 0x02) - error.Add("T0NF"); + if((registers.Error & 0x02) == 0x02) error.Add("T0NF"); - if((registers.Error & 0x04) == 0x04) - error.Add("ABRT"); + if((registers.Error & 0x04) == 0x04) error.Add("ABRT"); - if((registers.Error & 0x08) == 0x08) - error.Add("MCR"); + if((registers.Error & 0x08) == 0x08) error.Add("MCR"); - if((registers.Error & 0x10) == 0x10) - error.Add("IDNF"); + if((registers.Error & 0x10) == 0x10) error.Add("IDNF"); - if((registers.Error & 0x20) == 0x20) - error.Add("MC"); + if((registers.Error & 0x20) == 0x20) error.Add("MC"); - if((registers.Error & 0x40) == 0x40) - error.Add("UNC"); + if((registers.Error & 0x40) == 0x40) error.Add("UNC"); - if((registers.Error & 0x80) == 0x80) - error.Add("BBK"); + if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine(Localization.Core.ATA_command_0_error_status_1_error_2, command, string.Join(' ', status), - string.Join(' ', error)); + _logSw.WriteLine(Localization.Core.ATA_command_0_error_status_1_error_2, + command, + string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -146,7 +131,10 @@ public sealed class ErrorLog { if(osError) { - _logSw.WriteLine(Localization.Core.ATA_reading_CHS_0_1_2_operating_system_error_3, cylinder, head, sector, + _logSw.WriteLine(Localization.Core.ATA_reading_CHS_0_1_2_operating_system_error_3, + cylinder, + head, + sector, errno); _logSw.Flush(); @@ -156,56 +144,44 @@ public sealed class ErrorLog List error = new(); List status = new(); - if((registers.Status & 0x01) == 0x01) - status.Add("ERR"); + if((registers.Status & 0x01) == 0x01) status.Add("ERR"); - if((registers.Status & 0x02) == 0x02) - status.Add("IDX"); + if((registers.Status & 0x02) == 0x02) status.Add("IDX"); - if((registers.Status & 0x04) == 0x04) - status.Add("CORR"); + if((registers.Status & 0x04) == 0x04) status.Add("CORR"); - if((registers.Status & 0x08) == 0x08) - status.Add("DRQ"); + if((registers.Status & 0x08) == 0x08) status.Add("DRQ"); - if((registers.Status & 0x10) == 0x10) - status.Add("SRV"); + if((registers.Status & 0x10) == 0x10) status.Add("SRV"); - if((registers.Status & 0x20) == 0x20) - status.Add("DF"); + if((registers.Status & 0x20) == 0x20) status.Add("DF"); - if((registers.Status & 0x40) == 0x40) - status.Add("RDY"); + if((registers.Status & 0x40) == 0x40) status.Add("RDY"); - if((registers.Status & 0x80) == 0x80) - status.Add("BSY"); + if((registers.Status & 0x80) == 0x80) status.Add("BSY"); - if((registers.Error & 0x01) == 0x01) - error.Add("AMNF"); + if((registers.Error & 0x01) == 0x01) error.Add("AMNF"); - if((registers.Error & 0x02) == 0x02) - error.Add("T0NF"); + if((registers.Error & 0x02) == 0x02) error.Add("T0NF"); - if((registers.Error & 0x04) == 0x04) - error.Add("ABRT"); + if((registers.Error & 0x04) == 0x04) error.Add("ABRT"); - if((registers.Error & 0x08) == 0x08) - error.Add("MCR"); + if((registers.Error & 0x08) == 0x08) error.Add("MCR"); - if((registers.Error & 0x10) == 0x10) - error.Add("IDNF"); + if((registers.Error & 0x10) == 0x10) error.Add("IDNF"); - if((registers.Error & 0x20) == 0x20) - error.Add("MC"); + if((registers.Error & 0x20) == 0x20) error.Add("MC"); - if((registers.Error & 0x40) == 0x40) - error.Add("UNC"); + if((registers.Error & 0x40) == 0x40) error.Add("UNC"); - if((registers.Error & 0x80) == 0x80) - error.Add("BBK"); + if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine(Localization.Core.ATA_reading_CHS_0_1_2_error_status_3_error_4, cylinder, head, sector, - string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine(Localization.Core.ATA_reading_CHS_0_1_2_error_status_3_error_4, + cylinder, + head, + sector, + string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -228,56 +204,42 @@ public sealed class ErrorLog List error = new(); List status = new(); - if((registers.Status & 0x01) == 0x01) - status.Add("ERR"); + if((registers.Status & 0x01) == 0x01) status.Add("ERR"); - if((registers.Status & 0x02) == 0x02) - status.Add("IDX"); + if((registers.Status & 0x02) == 0x02) status.Add("IDX"); - if((registers.Status & 0x04) == 0x04) - status.Add("CORR"); + if((registers.Status & 0x04) == 0x04) status.Add("CORR"); - if((registers.Status & 0x08) == 0x08) - status.Add("DRQ"); + if((registers.Status & 0x08) == 0x08) status.Add("DRQ"); - if((registers.Status & 0x10) == 0x10) - status.Add("SRV"); + if((registers.Status & 0x10) == 0x10) status.Add("SRV"); - if((registers.Status & 0x20) == 0x20) - status.Add("DF"); + if((registers.Status & 0x20) == 0x20) status.Add("DF"); - if((registers.Status & 0x40) == 0x40) - status.Add("RDY"); + if((registers.Status & 0x40) == 0x40) status.Add("RDY"); - if((registers.Status & 0x80) == 0x80) - status.Add("BSY"); + if((registers.Status & 0x80) == 0x80) status.Add("BSY"); - if((registers.Error & 0x01) == 0x01) - error.Add("AMNF"); + if((registers.Error & 0x01) == 0x01) error.Add("AMNF"); - if((registers.Error & 0x02) == 0x02) - error.Add("T0NF"); + if((registers.Error & 0x02) == 0x02) error.Add("T0NF"); - if((registers.Error & 0x04) == 0x04) - error.Add("ABRT"); + if((registers.Error & 0x04) == 0x04) error.Add("ABRT"); - if((registers.Error & 0x08) == 0x08) - error.Add("MCR"); + if((registers.Error & 0x08) == 0x08) error.Add("MCR"); - if((registers.Error & 0x10) == 0x10) - error.Add("IDNF"); + if((registers.Error & 0x10) == 0x10) error.Add("IDNF"); - if((registers.Error & 0x20) == 0x20) - error.Add("MC"); + if((registers.Error & 0x20) == 0x20) error.Add("MC"); - if((registers.Error & 0x40) == 0x40) - error.Add("UNC"); + if((registers.Error & 0x40) == 0x40) error.Add("UNC"); - if((registers.Error & 0x80) == 0x80) - error.Add("BBK"); + if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine(Localization.Core.ATA_reading_LBA_0_error_status_1_error_2, block, - string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine(Localization.Core.ATA_reading_LBA_0_error_status_1_error_2, + block, + string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -300,56 +262,42 @@ public sealed class ErrorLog List error = new(); List status = new(); - if((registers.Status & 0x01) == 0x01) - status.Add("ERR"); + if((registers.Status & 0x01) == 0x01) status.Add("ERR"); - if((registers.Status & 0x02) == 0x02) - status.Add("IDX"); + if((registers.Status & 0x02) == 0x02) status.Add("IDX"); - if((registers.Status & 0x04) == 0x04) - status.Add("CORR"); + if((registers.Status & 0x04) == 0x04) status.Add("CORR"); - if((registers.Status & 0x08) == 0x08) - status.Add("DRQ"); + if((registers.Status & 0x08) == 0x08) status.Add("DRQ"); - if((registers.Status & 0x10) == 0x10) - status.Add("SRV"); + if((registers.Status & 0x10) == 0x10) status.Add("SRV"); - if((registers.Status & 0x20) == 0x20) - status.Add("DF"); + if((registers.Status & 0x20) == 0x20) status.Add("DF"); - if((registers.Status & 0x40) == 0x40) - status.Add("RDY"); + if((registers.Status & 0x40) == 0x40) status.Add("RDY"); - if((registers.Status & 0x80) == 0x80) - status.Add("BSY"); + if((registers.Status & 0x80) == 0x80) status.Add("BSY"); - if((registers.Error & 0x01) == 0x01) - error.Add("AMNF"); + if((registers.Error & 0x01) == 0x01) error.Add("AMNF"); - if((registers.Error & 0x02) == 0x02) - error.Add("T0NF"); + if((registers.Error & 0x02) == 0x02) error.Add("T0NF"); - if((registers.Error & 0x04) == 0x04) - error.Add("ABRT"); + if((registers.Error & 0x04) == 0x04) error.Add("ABRT"); - if((registers.Error & 0x08) == 0x08) - error.Add("MCR"); + if((registers.Error & 0x08) == 0x08) error.Add("MCR"); - if((registers.Error & 0x10) == 0x10) - error.Add("IDNF"); + if((registers.Error & 0x10) == 0x10) error.Add("IDNF"); - if((registers.Error & 0x20) == 0x20) - error.Add("MC"); + if((registers.Error & 0x20) == 0x20) error.Add("MC"); - if((registers.Error & 0x40) == 0x40) - error.Add("UNC"); + if((registers.Error & 0x40) == 0x40) error.Add("UNC"); - if((registers.Error & 0x80) == 0x80) - error.Add("BBK"); + if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine(Localization.Core.ATA_reading_LBA_0_error_status_1_error_2, block, - string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine(Localization.Core.ATA_reading_LBA_0_error_status_1_error_2, + block, + string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -378,22 +326,27 @@ public sealed class ErrorLog { if(prettySense != null) { - if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) - prettySense = prettySense[12..]; + if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) prettySense = prettySense[12..]; - if(prettySense.EndsWith('\n')) - prettySense = prettySense[..^1]; + if(prettySense.EndsWith('\n')) prettySense = prettySense[..^1]; prettySense = prettySense.Replace("\n", " - "); - _logSw.WriteLine(Localization.Core.SCSI_command_0_error_SENSE_1_ASC_2_ASCQ_3_4_5, command, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense, + _logSw.WriteLine(Localization.Core.SCSI_command_0_error_SENSE_1_ASC_2_ASCQ_3_4_5, + command, + decodedSense.Value.SenseKey, + decodedSense.Value.ASC, + decodedSense.Value.ASCQ, + hexSense, prettySense); } else { - _logSw.WriteLine(Localization.Core.SCSI_command_0_error_SENSE_1_ASC_2_ASCQ_3_4, command, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, + _logSw.WriteLine(Localization.Core.SCSI_command_0_error_SENSE_1_ASC_2_ASCQ_3_4, + command, + decodedSense.Value.SenseKey, + decodedSense.Value.ASC, + decodedSense.Value.ASCQ, hexSense); } } @@ -401,11 +354,9 @@ public sealed class ErrorLog { if(prettySense != null) { - if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) - prettySense = prettySense[12..]; + if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) prettySense = prettySense[12..]; - if(prettySense.EndsWith('\n')) - prettySense = prettySense[..^1]; + if(prettySense.EndsWith('\n')) prettySense = prettySense[..^1]; prettySense = prettySense.Replace("\n", " - "); @@ -430,8 +381,7 @@ public sealed class ErrorLog _logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_operating_system_error_1, block, errno); _logSw.Flush(); - if(senseBuffer is null || senseBuffer.Length == 0 || senseBuffer.All(s => s == 0)) - return; + if(senseBuffer is null || senseBuffer.Length == 0 || senseBuffer.All(s => s == 0)) return; } DecodedSense? decodedSense = Sense.Decode(senseBuffer); @@ -442,22 +392,27 @@ public sealed class ErrorLog { if(prettySense != null) { - if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) - prettySense = prettySense[12..]; + if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) prettySense = prettySense[12..]; - if(prettySense.EndsWith('\n')) - prettySense = prettySense[..^1]; + if(prettySense.EndsWith('\n')) prettySense = prettySense[..^1]; prettySense = prettySense.Replace("\n", " - "); - _logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_error_SENSE_1_ASC_2_ASCQ_3_4_5, block, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense, + _logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_error_SENSE_1_ASC_2_ASCQ_3_4_5, + block, + decodedSense.Value.SenseKey, + decodedSense.Value.ASC, + decodedSense.Value.ASCQ, + hexSense, prettySense); } else { - _logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_error_SENSE_1_ASC_2_ASCQ_3_4, block, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, + _logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_error_SENSE_1_ASC_2_ASCQ_3_4, + block, + decodedSense.Value.SenseKey, + decodedSense.Value.ASC, + decodedSense.Value.ASCQ, hexSense); } } @@ -465,11 +420,9 @@ public sealed class ErrorLog { if(prettySense != null) { - if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) - prettySense = prettySense[12..]; + if(prettySense.StartsWith("SCSI SENSE: ", StringComparison.Ordinal)) prettySense = prettySense[12..]; - if(prettySense.EndsWith('\n')) - prettySense = prettySense[..^1]; + if(prettySense.EndsWith('\n')) prettySense = prettySense[..^1]; prettySense = prettySense.Replace("\n", " - "); @@ -498,7 +451,8 @@ public sealed class ErrorLog } // TODO: Decode response - _logSw.WriteLine(Localization.Core.SD_MMC_command_0_error_1, command, + _logSw.WriteLine(Localization.Core.SD_MMC_command_0_error_1, + command, string.Join(" - ", response.Select(r => $"0x{r:X8}"))); _logSw.Flush(); @@ -515,16 +469,22 @@ public sealed class ErrorLog { if(osError) { - _logSw.WriteLine(byteAddressed ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_operating_system_error_1 : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_operating_system_error_1, - block, errno); + _logSw.WriteLine(byteAddressed + ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_operating_system_error_1 + : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_operating_system_error_1, + block, + errno); _logSw.Flush(); return; } - _logSw.WriteLine(byteAddressed ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_error_1 : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_error_1, - block, string.Join(" - ", response.Select(r => $"0x{r:X8}"))); + _logSw.WriteLine(byteAddressed + ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_error_1 + : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_error_1, + block, + string.Join(" - ", response.Select(r => $"0x{r:X8}"))); throw new NotImplementedException(); } diff --git a/Aaru.Core/Logging/IBGLog.cs b/Aaru.Core/Logging/IBGLog.cs index 2dabbaefc..f2ec88450 100644 --- a/Aaru.Core/Logging/IBGLog.cs +++ b/Aaru.Core/Logging/IBGLog.cs @@ -61,8 +61,7 @@ sealed class IbgLog /// Profile as defined by SCSI MultiMedia Commands specification internal IbgLog(string outputFile, ushort currentProfile) { - if(string.IsNullOrEmpty(outputFile)) - return; + if(string.IsNullOrEmpty(outputFile)) return; _logFile = outputFile; _ibgSb = new StringBuilder(); @@ -239,15 +238,13 @@ sealed class IbgLog /// Current speed at the snapshot internal void Write(ulong sector, double currentSpeed) { - if(_logFile == null) - return; + if(_logFile == null) return; _ibgIntSpeed += currentSpeed; _ibgSampleRate += (int)Math.Floor(_ibgStopwatch.Elapsed.TotalMilliseconds); _ibgSnaps++; - if(_ibgSampleRate < 100) - return; + if(_ibgSampleRate < 100) return; if(_ibgIntSpeed > 0 && !_ibgStartSet) { @@ -255,11 +252,10 @@ sealed class IbgLog _ibgStartSet = true; } - _ibgSb.Append($"{_ibgIntSpeed / _ibgSnaps / _ibgDivider:0.00},{_ibgIntSector},{_ibgSampleRate:0},0"). - AppendLine(); + _ibgSb.Append($"{_ibgIntSpeed / _ibgSnaps / _ibgDivider:0.00},{_ibgIntSector},{_ibgSampleRate:0},0") + .AppendLine(); - if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed) - _ibgMaxSpeed = _ibgIntSpeed / _ibgDivider; + if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed) _ibgMaxSpeed = _ibgIntSpeed / _ibgDivider; _ibgStopwatch.Restart(); _ibgIntSpeed = 0; @@ -279,8 +275,7 @@ sealed class IbgLog internal void Close(Device dev, ulong blocks, ulong blockSize, double totalSeconds, double currentSpeed, double averageSpeed, string devicePath) { - if(_logFile == null) - return; + if(_logFile == null) return; _ibgStopwatch.Stop(); diff --git a/Aaru.Core/Logging/MHDDLog.cs b/Aaru.Core/Logging/MHDDLog.cs index 169fc6227..88bee085f 100644 --- a/Aaru.Core/Logging/MHDDLog.cs +++ b/Aaru.Core/Logging/MHDDLog.cs @@ -60,8 +60,7 @@ sealed class MhddLog internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead, bool @private, uint mediaGraphDimensions = 0) { - if(dev == null || string.IsNullOrEmpty(outputFile)) - return; + if(dev == null || string.IsNullOrEmpty(outputFile)) return; if(mediaGraphDimensions > 0) _mediaGraph = new BlockMap((int)mediaGraphDimensions, (int)mediaGraphDimensions, blocks); @@ -158,8 +157,7 @@ sealed class MhddLog /// How many sectors where read at once internal void Write(ulong sector, double duration, uint length = 1) { - if(_logFile == null) - return; + if(_logFile == null) return; byte[] sectorBytes = BitConverter.GetBytes(sector); byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000)); @@ -199,8 +197,7 @@ sealed class MhddLog /// Closes and writes to file the MHDD log internal void Close() { - if(_logFile == null) - return; + if(_logFile == null) return; var fs = new FileStream(_logFile, FileMode.Create); _mhddFs.WriteTo(fs); diff --git a/Aaru.Core/Logging/SubchannelLog.cs b/Aaru.Core/Logging/SubchannelLog.cs index b14161b23..35f0b045f 100644 --- a/Aaru.Core/Logging/SubchannelLog.cs +++ b/Aaru.Core/Logging/SubchannelLog.cs @@ -44,8 +44,7 @@ public class SubchannelLog /// Drive returns subchannel in BCD format public SubchannelLog(string outputFile, bool bcd) { - if(string.IsNullOrEmpty(outputFile)) - return; + if(string.IsNullOrEmpty(outputFile)) return; _bcd = bcd; @@ -188,16 +187,14 @@ public class SubchannelLog for(var i = 0; i < 12; i++) { - if(p[i] == 0 || p[i] == 0xFF) - continue; + if(p[i] == 0 || p[i] == 0xFF) continue; corruptedPause = true; break; } - if(!corruptedPause) - pause = p[0] == 1; + if(!corruptedPause) pause = p[0] == 1; var subBuf = new byte[12]; subBuf[0] = (byte)q[0 + block * 12]; @@ -213,13 +210,16 @@ public class SubchannelLog subBuf[10] = (byte)q[10 + block * 12]; subBuf[11] = (byte)q[11 + block * 12]; - string prettyQ = Subchannel.PrettifyQ(subBuf, generated || _bcd, startingLba + block, corruptedPause, pause, + string prettyQ = Subchannel.PrettifyQ(subBuf, + generated || _bcd, + startingLba + block, + corruptedPause, + pause, rwEmpty); if(generated) - prettyQ += Localization.Core._GENERATED; - else if(@fixed) - prettyQ += Localization.Core._FIXED; + prettyQ += Localization.Core._GENERATED; + else if(@fixed) prettyQ += Localization.Core._FIXED; _logSw.WriteLine(prettyQ); } diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index be0c7ccd9..045d2bf24 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -80,8 +80,7 @@ public static class CompactDisc out List newPregapSectors) { // We need to work in PW raw subchannels - if(supportedSubchannel == MmcSubchannel.Q16) - sub = Subchannel.ConvertQToRaw(sub); + if(supportedSubchannel == MmcSubchannel.Q16) sub = Subchannel.ConvertQToRaw(sub); // If not desired to fix, or to save, the subchannel, just save as is (or none) if(!fixSubchannelPosition && desiredSubchannel != MmcSubchannel.None) @@ -91,12 +90,19 @@ public static class CompactDisc byte[] deSub = Subchannel.Deinterleave(sub); - bool indexesChanged = CheckIndexesFromSubchannel(deSub, isrcs, currentTrack, ref mcn, tracks, dumpLog, - updateStatus, smallestPregapLbaPerTrack, dumping, - out newPregapSectors, sectorAddress); + bool indexesChanged = CheckIndexesFromSubchannel(deSub, + isrcs, + currentTrack, + ref mcn, + tracks, + dumpLog, + updateStatus, + smallestPregapLbaPerTrack, + dumping, + out newPregapSectors, + sectorAddress); - if(!fixSubchannelPosition || desiredSubchannel == MmcSubchannel.None) - return indexesChanged; + if(!fixSubchannelPosition || desiredSubchannel == MmcSubchannel.None) return indexesChanged; int prePos = int.MinValue; @@ -123,13 +129,11 @@ public static class CompactDisc // Check P and weight for(int p = subPos; p < subPos + 12; p++) { - if(deSub[p] != 0 && deSub[p] != 255) - pOk = false; + if(deSub[p] != 0 && deSub[p] != 255) pOk = false; for(var w = 0; w < 8; w++) { - if((deSub[p] >> w & 1) > 0) - pWeight++; + if((deSub[p] >> w & 1) > 0) pWeight++; } } @@ -165,11 +169,9 @@ public static class CompactDisc DetectRwPackets(sectorSub, out _, out rwPacket, out cdtextPacket); // TODO: CD+G reed solomon - if(rwPacket && !cdtextPacket) - rwOk = true; + if(rwPacket && !cdtextPacket) rwOk = true; - if(cdtextPacket) - rwOk = CheckCdTextPackets(sectorSub); + if(cdtextPacket) rwOk = CheckCdTextPackets(sectorSub); } // Fix P @@ -177,13 +179,11 @@ public static class CompactDisc { if(pWeight >= 48) { - for(int p = subPos; p < subPos + 12; p++) - deSub[p] = 255; + for(int p = subPos; p < subPos + 12; p++) deSub[p] = 255; } else { - for(int p = subPos; p < subPos + 12; p++) - deSub[p] = 0; + for(int p = subPos; p < subPos + 12; p++) deSub[p] = 0; } pOk = true; @@ -195,8 +195,7 @@ public static class CompactDisc // RW is not a known pattern or packet, fix it if(!rwOk && !rwPacket && !cdtextPacket && fixSubchannel) { - for(int rw = subPos + 24; rw < subPos + 96; rw++) - deSub[rw] = 0; + for(int rw = subPos + 24; rw < subPos + 96; rw++) deSub[rw] = 0; rwOk = true; @fixed = true; @@ -211,9 +210,21 @@ public static class CompactDisc { isrcs.TryGetValue(currentTrack, out string knownGoodIsrc); - crcOk = FixQSubchannel(deSub, q, subPos, mcn, knownGoodIsrc, fixSubchannelCrc, out bool fixedAdr, - out bool controlFix, out bool fixedZero, out bool fixedTno, out bool fixedIndex, - out bool fixedRelPos, out bool fixedAbsPos, out bool fixedCrc, out bool fixedMcn, + crcOk = FixQSubchannel(deSub, + q, + subPos, + mcn, + knownGoodIsrc, + fixSubchannelCrc, + out bool fixedAdr, + out bool controlFix, + out bool fixedZero, + out bool fixedTno, + out bool fixedIndex, + out bool fixedRelPos, + out bool fixedAbsPos, + out bool fixedCrc, + out bool fixedMcn, out bool fixedIsrc); if(crcOk) @@ -221,40 +232,29 @@ public static class CompactDisc Array.Copy(q, 0, deSub, subPos + 12, 12); @fixed = true; - if(fixedAdr) - subLog?.WriteQAdrFix(lba); + if(fixedAdr) subLog?.WriteQAdrFix(lba); - if(controlFix) - subLog?.WriteQCtrlFix(lba); + if(controlFix) subLog?.WriteQCtrlFix(lba); - if(fixedZero) - subLog?.WriteQZeroFix(lba); + if(fixedZero) subLog?.WriteQZeroFix(lba); - if(fixedTno) - subLog?.WriteQTnoFix(lba); + if(fixedTno) subLog?.WriteQTnoFix(lba); - if(fixedIndex) - subLog?.WriteQIndexFix(lba); + if(fixedIndex) subLog?.WriteQIndexFix(lba); - if(fixedRelPos) - subLog?.WriteQRelPosFix(lba); + if(fixedRelPos) subLog?.WriteQRelPosFix(lba); - if(fixedAbsPos) - subLog?.WriteQAbsPosFix(lba); + if(fixedAbsPos) subLog?.WriteQAbsPosFix(lba); - if(fixedCrc) - subLog?.WriteQCrcFix(lba); + if(fixedCrc) subLog?.WriteQCrcFix(lba); - if(fixedMcn) - subLog?.WriteQMcnFix(lba); + if(fixedMcn) subLog?.WriteQMcnFix(lba); - if(fixedIsrc) - subLog?.WriteQIsrcFix(lba); + if(fixedIsrc) subLog?.WriteQIsrcFix(lba); } } - if(!pOk || !crcOk || !rwOk) - continue; + if(!pOk || !crcOk || !rwOk) continue; var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); @@ -274,13 +274,11 @@ public static class CompactDisc aPos = smin * 60 * 75 + ssec * 75 + aframe - 150; // Next second - if(aPos < prePos) - aPos += 75; + if(aPos < prePos) aPos += 75; } // TODO: Negative sectors - if(aPos < 0) - continue; + if(aPos < 0) continue; prePos = aPos; @@ -291,8 +289,7 @@ public static class CompactDisc subchannelExtents.Remove(aPos); - if(@fixed) - subLog?.WriteEntry(posSub, supportedSubchannel == MmcSubchannel.Raw, lba, 1, false, true); + if(@fixed) subLog?.WriteEntry(posSub, supportedSubchannel == MmcSubchannel.Raw, lba, 1, false, true); } return indexesChanged; @@ -339,18 +336,18 @@ public static class CompactDisc { string isrc = Subchannel.DecodeIsrc(q); - if(isrc is null or "000000000000") - continue; + if(isrc is null or "000000000000") continue; - if(!crcOk) - continue; + if(!crcOk) continue; if(!isrcs.ContainsKey(currentTrackNumber)) { - dumpLog?.WriteLine(string.Format(Localization.Core.Found_new_ISRC_0_for_track_1, isrc, + dumpLog?.WriteLine(string.Format(Localization.Core.Found_new_ISRC_0_for_track_1, + isrc, currentTrackNumber)); - updateStatus?.Invoke(string.Format(Localization.Core.Found_new_ISRC_0_for_track_1, isrc, + updateStatus?.Invoke(string.Format(Localization.Core.Found_new_ISRC_0_for_track_1, + isrc, currentTrackNumber)); isrcs[currentTrackNumber] = isrc; @@ -363,10 +360,14 @@ public static class CompactDisc if(currentTrack?.Sequence == currentTrackNumber) { dumpLog?.WriteLine(string.Format(Localization.Core.ISRC_for_track_0_changed_from_1_to_2, - currentTrackNumber, isrcs[currentTrackNumber], isrc)); + currentTrackNumber, + isrcs[currentTrackNumber], + isrc)); updateStatus?.Invoke(string.Format(Localization.Core.ISRC_for_track_0_changed_from_1_to_2, - currentTrackNumber, isrcs[currentTrackNumber], isrc)); + currentTrackNumber, + isrcs[currentTrackNumber], + isrc)); isrcs[currentTrackNumber] = isrc; } @@ -380,11 +381,9 @@ public static class CompactDisc { string newMcn = Subchannel.DecodeMcn(q); - if(newMcn is null or "0000000000000") - continue; + if(newMcn is null or "0000000000000") continue; - if(!crcOk) - continue; + if(!crcOk) continue; if(mcn is null) { @@ -411,8 +410,7 @@ public static class CompactDisc for(var i = 0; i < tracks.Length; i++) { - if(tracks[i].Sequence != trackNo) - continue; + if(tracks[i].Sequence != trackNo) continue; // Pregap if(q[2] == 0 && trackNo > 1) @@ -426,12 +424,10 @@ public static class CompactDisc // When we are not, we go from index 0. smallestPregapLbaPerTrack.TryAdd(trackNo, dumping ? 1 : 0); - uint firstTrackNumberInSameSession = tracks. - Where(t => t.Session == tracks[i].Session). - Min(t => t.Sequence); + uint firstTrackNumberInSameSession = + tracks.Where(t => t.Session == tracks[i].Session).Min(t => t.Sequence); - if(tracks[i].Sequence == firstTrackNumberInSameSession) - continue; + if(tracks[i].Sequence == firstTrackNumberInSameSession) continue; if(qPos < smallestPregapLbaPerTrack[trackNo]) { @@ -444,20 +440,20 @@ public static class CompactDisc tracks[i - 1].EndSector = tracks[i].StartSector - 1; dumpLog?.WriteLine(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors, - trackNo, tracks[i].Pregap)); + trackNo, + tracks[i].Pregap)); - updateStatus?. - Invoke(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors, trackNo, - tracks[i].Pregap)); + updateStatus?.Invoke(string.Format(Localization.Core + .Pregap_for_track_0_set_to_1_sectors, + trackNo, + tracks[i].Pregap)); - for(var p = 0; p < dif; p++) - newPregapSectors.Add(tracks[i].StartSector + (ulong)p); + for(var p = 0; p < dif; p++) newPregapSectors.Add(tracks[i].StartSector + (ulong)p); status = true; } - if(tracks[i].Pregap >= (ulong)qPos) - continue; + if(tracks[i].Pregap >= (ulong)qPos) continue; ulong oldPregap = tracks[i].Pregap; @@ -468,10 +464,12 @@ public static class CompactDisc tracks[i - 1].EndSector = tracks[i].StartSector - 1; dumpLog?.WriteLine(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors, - trackNo, tracks[i].Pregap)); + trackNo, + tracks[i].Pregap)); updateStatus?.Invoke(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors, - trackNo, tracks[i].Pregap)); + trackNo, + tracks[i].Pregap)); for(var p = 0; p < (int)(tracks[i].Pregap - oldPregap); p++) newPregapSectors.Add(tracks[i].StartSector + (ulong)p); @@ -481,8 +479,7 @@ public static class CompactDisc continue; } - if(q[2] == 0) - continue; + if(q[2] == 0) continue; var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); @@ -490,17 +487,19 @@ public static class CompactDisc int aPos = amin * 60 * 75 + asec * 75 + aframe - 150; // Do not set INDEX 1 to a value higher than what the TOC already said. - if(q[2] == 1 && aPos > (int)tracks[i].StartSector) - continue; + if(q[2] == 1 && aPos > (int)tracks[i].StartSector) continue; - if(tracks[i].Indexes.ContainsKey(q[2]) && aPos >= tracks[i].Indexes[q[2]]) - continue; + if(tracks[i].Indexes.ContainsKey(q[2]) && aPos >= tracks[i].Indexes[q[2]]) continue; - dumpLog?.WriteLine(string.Format(Localization.Core.Setting_index_0_for_track_1_to_LBA_2, q[2], - trackNo, aPos)); + dumpLog?.WriteLine(string.Format(Localization.Core.Setting_index_0_for_track_1_to_LBA_2, + q[2], + trackNo, + aPos)); - updateStatus?.Invoke(string.Format(Localization.Core.Setting_index_0_for_track_1_to_LBA_2, q[2], - trackNo, aPos)); + updateStatus?.Invoke(string.Format(Localization.Core.Setting_index_0_for_track_1_to_LBA_2, + q[2], + trackNo, + aPos)); tracks[i].Indexes[q[2]] = aPos; @@ -543,17 +542,13 @@ public static class CompactDisc cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -562,17 +557,13 @@ public static class CompactDisc cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -581,17 +572,13 @@ public static class CompactDisc cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -600,32 +587,24 @@ public static class CompactDisc cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | subchannel[i++] & 0x3F); } i = 0; - for(var j = 0; j < 24; j++) - cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) { @@ -707,17 +686,13 @@ public static class CompactDisc break; } - if((cdTextPack1[0] & 0x80) == 0x80) - cdtextPacket = true; + if((cdTextPack1[0] & 0x80) == 0x80) cdtextPacket = true; - if((cdTextPack2[0] & 0x80) == 0x80) - cdtextPacket = true; + if((cdTextPack2[0] & 0x80) == 0x80) cdtextPacket = true; - if((cdTextPack3[0] & 0x80) == 0x80) - cdtextPacket = true; + if((cdTextPack3[0] & 0x80) == 0x80) cdtextPacket = true; - if((cdTextPack4[0] & 0x80) == 0x80) - cdtextPacket = true; + if((cdTextPack4[0] & 0x80) == 0x80) cdtextPacket = true; } /// Checks if subchannel contains a TEXT packet @@ -738,17 +713,13 @@ public static class CompactDisc cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -757,17 +728,13 @@ public static class CompactDisc cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -776,17 +743,13 @@ public static class CompactDisc cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); } for(var j = 0; j < 18; j++) @@ -795,17 +758,13 @@ public static class CompactDisc cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0xC0) >> 4); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x0F) << 4); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x0F) << 4); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j++] | (subchannel[i] & 0x3C) >> 2); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x03) << 6); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x03) << 6); - if(j < 18) - cdTextPack4[j] = (byte)(cdTextPack4[j] | subchannel[i++] & 0x3F); + if(j < 18) cdTextPack4[j] = (byte)(cdTextPack4[j] | subchannel[i++] & 0x3F); } var status = true; @@ -817,8 +776,7 @@ public static class CompactDisc Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16); ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc); - if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0) - status = false; + if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0) status = false; } if((cdTextPack2[0] & 0x80) == 0x80) @@ -828,8 +786,7 @@ public static class CompactDisc Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc); - if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0) - status = false; + if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0) status = false; } if((cdTextPack3[0] & 0x80) == 0x80) @@ -839,20 +796,17 @@ public static class CompactDisc Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc); - if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0) - status = false; + if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0) status = false; } - if((cdTextPack4[0] & 0x80) != 0x80) - return status; + if((cdTextPack4[0] & 0x80) != 0x80) return status; var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); var cdTextPack4ForCrc = new byte[16]; Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc); - if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) - return status; + if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status; return false; } @@ -915,8 +869,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out byte[] qCrc); bool status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(fixedAdr && status) - return true; + if(fixedAdr && status) return true; int oldAdr = q[0] & 0x3; @@ -1017,8 +970,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } if(preCrcOk && nextCrcOk) @@ -1031,8 +983,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1046,8 +997,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1123,8 +1073,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1182,8 +1131,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } } @@ -1238,8 +1186,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1297,8 +1244,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1306,8 +1252,7 @@ public static class CompactDisc status = qCrc[0] == q[10] && qCrc[1] == q[11]; // Game Over - if(!fixCrc || status) - return false; + if(!fixCrc || status) return false; // Previous Q's CRC is correct if(preCrcOk) @@ -1397,16 +1342,14 @@ public static class CompactDisc else q[9]++; - if(q[9] >= 0x74) - q[9] = 0; + if(q[9] >= 0x74) q[9] = 0; fixedAbsPos = true; CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1432,8 +1375,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1454,12 +1396,10 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } - if(!fixCrc || !nextCrcOk || !preCrcOk) - return false; + if(!fixCrc || !nextCrcOk || !preCrcOk) return false; CRC16CcittContext.Data(q, 10, out qCrc); q[10] = qCrc[0]; @@ -1488,16 +1428,14 @@ public static class CompactDisc else q[9]++; - if(q[9] >= 0x74) - q[9] = 0; + if(q[9] >= 0x74) q[9] = 0; fixedAbsPos = true; CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1523,8 +1461,7 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } } @@ -1551,12 +1488,10 @@ public static class CompactDisc CRC16CcittContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + if(status) return true; } - if(!fixCrc || !nextCrcOk || !preCrcOk) - return false; + if(!fixCrc || !nextCrcOk || !preCrcOk) return false; CRC16CcittContext.Data(q, 10, out qCrc); q[10] = qCrc[0]; @@ -1597,8 +1532,7 @@ public static class CompactDisc ulong trackStart; ulong pregap; - if(track == null) - continue; + if(track == null) continue; // Hidden track if(track.Sequence == 0) @@ -1626,7 +1560,8 @@ public static class CompactDisc else index = 0; - updateProgress?.Invoke(string.Format(Localization.Core.Generating_subchannel_for_sector_0, sector), sector, + updateProgress?.Invoke(string.Format(Localization.Core.Generating_subchannel_for_sector_0, sector), + sector, (long)blocks); dumpLog?.WriteLine($"Generating subchannel for sector {sector}."); diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index 4c923bf66..cf6f3017f 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -128,8 +128,7 @@ public static class MMC static bool IsData(byte[] sector) { - if(sector?.Length != 2352) - return false; + if(sector?.Length != 2352) return false; byte[] syncMark = { @@ -146,8 +145,7 @@ public static class MMC { offset = 0; - if(sector?.Length != 2352) - return false; + if(sector?.Length != 2352) return false; byte[] syncMark = { @@ -205,8 +203,7 @@ public static class MMC /// true if it corresponds to a CD-i, falseotherwise. static bool IsCdi(byte[] sector0, byte[] sector16) { - if(sector16?.Length != 2352) - return false; + if(sector16?.Length != 2352) return false; byte[] cdiMark = { @@ -215,8 +212,7 @@ public static class MMC bool isData = IsData(sector0); - if(!isData || sector0[0xF] != 2 && sector0[0xF] != 1) - return false; + if(!isData || sector0[0xF] != 2 && sector0[0xF] != 1) return false; var testMark = new byte[4]; Array.Copy(sector16, 24, testMark, 0, 4); @@ -226,8 +222,7 @@ public static class MMC static bool IsVideoNowColor(byte[] videoFrame) { - if(videoFrame is null || videoFrame.Length < _videoNowColorFrameMarker.Length) - return false; + if(videoFrame is null || videoFrame.Length < _videoNowColorFrameMarker.Length) return false; var buffer = new byte[_videoNowColorFrameMarker.Length]; @@ -235,11 +230,9 @@ public static class MMC { Array.Copy(videoFrame, framePosition, buffer, 0, buffer.Length); - for(var ab = 9; ab < buffer.Length; ab += 10) - buffer[ab] = 0; + for(var ab = 9; ab < buffer.Length; ab += 10) buffer[ab] = 0; - if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) - continue; + if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) continue; return true; } @@ -255,11 +248,9 @@ public static class MMC { Array.Copy(data, framePosition, buffer, 0, buffer.Length); - for(var ab = 9; ab < buffer.Length; ab += 10) - buffer[ab] = 0; + for(var ab = 9; ab < buffer.Length; ab += 10) buffer[ab] = 0; - if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) - continue; + if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) continue; return 18032 - framePosition; } @@ -294,7 +285,8 @@ public static class MMC { Features.SeparatedFeatures ftr = Features.Separate(cmdBuf); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.GET_CONFIGURATION_current_profile_is_0, ftr.CurrentProfile); switch(ftr.CurrentProfile) @@ -419,8 +411,8 @@ public static class MMC if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == 2) == true) { - secondSessionFirstTrack = decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == 2). - Min(t => t.POINT); + secondSessionFirstTrack = + decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == 2).Min(t => t.POINT); } if(mediaType is MediaType.CD or MediaType.CDROMXA or MediaType.CDI) @@ -469,7 +461,7 @@ public static class MMC } foreach(FullTOC.TrackDataDescriptor track in - decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99)) + decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99)) { if(track.TNO == 1 && ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || @@ -485,8 +477,7 @@ public static class MMC track.PFRAME - 150); - if(startAddress < startOfFirstDataTrack) - startOfFirstDataTrack = startAddress; + if(startAddress < startOfFirstDataTrack) startOfFirstDataTrack = startAddress; hasDataTrack = true; allFirstSessionTracksAreAudio &= track.POINT >= firstTrackLastSession; @@ -504,8 +495,8 @@ public static class MMC { case true when hasAudioTrack && allFirstSessionTracksAreAudio && sessions == 2: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.Core. - Disc_has_audio_and_data_two_sessions_all_data_second_CD_Plus); + Localization.Core + .Disc_has_audio_and_data_two_sessions_all_data_second_CD_Plus); mediaType = MediaType.CDPLUS; @@ -536,25 +527,37 @@ public static class MMC if(mediaType is MediaType.CD or MediaType.CDROM && hasDataTrack) { - foreach(uint startAddress in decodedToc.Value.TrackDescriptors. - Where(t => t.POINT is > 0 and <= 0x99 && + foreach(uint startAddress in decodedToc.Value.TrackDescriptors + .Where(t => t.POINT is > 0 and <= 0x99 && ((TocControl)(t.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(t.CONTROL & 0x0D) == - TocControl.DataTrackIncremental)). - Select(track => (uint)(track.PHOUR * 3600 * 75 + + TocControl.DataTrackIncremental)) + .Select(track => (uint)(track.PHOUR * 3600 * 75 + track.PMIN * 60 * 75 + track.PSEC * 75 + track.PFRAME - 150) + 16)) { - sense = dev.ReadCd(out cmdBuf, out _, startAddress, 2352, 1, MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startAddress, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(sense || dev.Error) - continue; + if(sense || dev.Error) continue; if(cmdBuf[0] != 0x00 || cmdBuf[1] != 0xFF || @@ -592,36 +595,86 @@ public static class MMC secondSessionFirstTrackTrack.PFRAME - 150); - sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + firstSectorSecondSessionFirstTrack, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) firstTrackSecondSession = cmdBuf; else { - sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.Cdda, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + firstSectorSecondSessionFirstTrack, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - firstTrackSecondSession = cmdBuf; + if(!sense && !dev.Error) firstTrackSecondSession = cmdBuf; } - sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + firstSectorSecondSessionFirstTrack - 1, + 2352, + 3, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) firstTrackSecondSessionAudio = cmdBuf; else { - sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3, - MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + firstSectorSecondSessionFirstTrack - 1, + 2352, + 3, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - firstTrackSecondSessionAudio = cmdBuf; + if(!sense && !dev.Error) firstTrackSecondSessionAudio = cmdBuf; } } @@ -629,15 +682,41 @@ public static class MMC for(var i = 0; i < 9; i++) { - sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + (uint)i, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(sense || dev.Error) { - sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + (uint)i, + 2352, + 1, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(sense || !dev.Error) { @@ -665,9 +744,22 @@ public static class MMC // Check for hidden data before start of track 1 if(firstTrackSector > 0) { - sense = dev.ReadCd(out sector0, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out sector0, + out _, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!dev.Error && !sense) { @@ -677,9 +769,22 @@ public static class MMC if(hiddenData) { - sense = dev.ReadCd(out byte[] sector16, out _, 16, 2352, 1, MmcSectorTypes.AllTypes, false, - false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out byte[] sector16, + out _, + 16, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && IsCdi(sector0, sector16)) { @@ -699,11 +804,9 @@ public static class MMC { int sectorsForOffset = combinedOffset / 2352; - if(sectorsForOffset < 0) - sectorsForOffset *= -1; + if(sectorsForOffset < 0) sectorsForOffset *= -1; - if(combinedOffset % 2352 != 0) - sectorsForOffset++; + if(combinedOffset % 2352 != 0) sectorsForOffset++; var lba0 = 0; var lba16 = 16; @@ -714,25 +817,64 @@ public static class MMC lba16 -= sectorsForOffset; } - sense = dev.ReadCd(out sector0, out _, (uint)lba0, 2352, (uint)sectorsForOffset + 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, - true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out sector0, + out _, + (uint)lba0, + 2352, + (uint)sectorsForOffset + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); // Drive does not support reading negative sectors? if(sense && lba0 < 0) { - dev.ReadCd(out sector0, out _, 0, 2352, 2, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + dev.ReadCd(out sector0, + out _, + 0, + 2352, + 2, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); sector0 = DescrambleAndFixOffset(sector0, combinedOffset, sectorsForOffset); } else sector0 = DescrambleAndFixOffset(sector0, combinedOffset, sectorsForOffset); - dev.ReadCd(out byte[] sector16, out _, (uint)lba16, 2352, (uint)sectorsForOffset + 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + dev.ReadCd(out byte[] sector16, + out _, + (uint)lba16, + 2352, + (uint)sectorsForOffset + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); sector16 = DescrambleAndFixOffset(sector16, combinedOffset, sectorsForOffset); @@ -761,18 +903,44 @@ public static class MMC case MediaType.CDROM: case MediaType.CDROMXA: { - sense = dev.ReadCd(out cmdBuf, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { sector0 = new byte[2048]; Array.Copy(cmdBuf, 16, sector0, 0, 2048); - sense = dev.ReadCd(out cmdBuf, out _, 1, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 1, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -780,9 +948,22 @@ public static class MMC Array.Copy(cmdBuf, 16, sector1, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, 4200, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 4200, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -790,9 +971,22 @@ public static class MMC Array.Copy(cmdBuf, 24, playdia1, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, 4201, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 4201, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -802,9 +996,22 @@ public static class MMC if(startOfFirstDataTrack != uint.MaxValue) { - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2352, 1, MmcSectorTypes.AllTypes, - false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -812,9 +1019,22 @@ public static class MMC Array.Copy(cmdBuf, 16, firstDataSectorNotZero, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2352, 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack + 1, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -827,33 +1047,70 @@ public static class MMC for(uint p = 0; p < 12; p++) { - sense = dev.ReadCd(out cmdBuf, out _, p, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + p, + 2352, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(sense || dev.Error) - break; + if(sense || dev.Error) break; ps2Ms.Write(cmdBuf, cmdBuf[0x0F] == 0x02 ? 24 : 16, 2048); } - if(ps2Ms.Length == 0x6000) - ps2BootSectors = ps2Ms.ToArray(); + if(ps2Ms.Length == 0x6000) ps2BootSectors = ps2Ms.ToArray(); } else { - sense = dev.ReadCd(out cmdBuf, out _, 0, 2324, 1, MmcSectorTypes.Mode2, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { sector0 = new byte[2048]; Array.Copy(cmdBuf, 0, sector0, 0, 2048); - sense = dev.ReadCd(out cmdBuf, out _, 1, 2324, 1, MmcSectorTypes.Mode2, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 1, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -861,9 +1118,22 @@ public static class MMC Array.Copy(cmdBuf, 1, sector0, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, 4200, 2324, 1, MmcSectorTypes.Mode2, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 4200, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -871,9 +1141,22 @@ public static class MMC Array.Copy(cmdBuf, 0, playdia1, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, 4201, 2324, 1, MmcSectorTypes.Mode2, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 4201, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -883,9 +1166,22 @@ public static class MMC if(startOfFirstDataTrack != uint.MaxValue) { - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2324, 1, MmcSectorTypes.Mode2, - false, false, false, MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -893,9 +1189,22 @@ public static class MMC Array.Copy(cmdBuf, 0, firstDataSectorNotZero, 0, 2048); } - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2324, 1, - MmcSectorTypes.Mode2, false, false, false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack + 1, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -908,58 +1217,130 @@ public static class MMC for(uint p = 0; p < 12; p++) { - sense = dev.ReadCd(out cmdBuf, out _, p, 2324, 1, MmcSectorTypes.Mode2, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + p, + 2324, + 1, + MmcSectorTypes.Mode2, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(sense || dev.Error) - break; + if(sense || dev.Error) break; ps2Ms.Write(cmdBuf, 0, 2048); } - if(ps2Ms.Length == 0x6000) - ps2BootSectors = ps2Ms.ToArray(); + if(ps2Ms.Length == 0x6000) ps2BootSectors = ps2Ms.ToArray(); } else { - sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + 2048, + 1, + MmcSectorTypes.Mode1, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { sector0 = cmdBuf; - sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false, false, - MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + 2048, + 1, + MmcSectorTypes.Mode1, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - sector1 = cmdBuf; + if(!sense && !dev.Error) sector1 = cmdBuf; - sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 12, MmcSectorTypes.Mode1, false, false, - false, MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + 2048, + 12, + MmcSectorTypes.Mode1, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - ps2BootSectors = cmdBuf; + if(!sense && !dev.Error) ps2BootSectors = cmdBuf; if(startOfFirstDataTrack != uint.MaxValue) { - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2048, 1, - MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack, + 2048, + 1, + MmcSectorTypes.Mode1, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - firstDataSectorNotZero = cmdBuf; + if(!sense && !dev.Error) firstDataSectorNotZero = cmdBuf; - sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2048, 1, - MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true, - false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + startOfFirstDataTrack + 1, + 2048, + 1, + MmcSectorTypes.Mode1, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(!sense && !dev.Error) - secondDataSectorNotZero = cmdBuf; + if(!sense && !dev.Error) secondDataSectorNotZero = cmdBuf; } } else @@ -980,11 +1361,17 @@ public static class MMC case MediaType.Unknown: if(mediaType is MediaType.BDROM or MediaType.UHDBD) { - sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.DiscInformation, + 0, + dev.Timeout, + out _); - if(!sense) - blurayDi = DI.Decode(cmdBuf); + if(!sense) blurayDi = DI.Decode(cmdBuf); } sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout, out _); @@ -993,59 +1380,144 @@ public static class MMC { sector0 = cmdBuf; - sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 1, 2048, 0, 1, false, dev.Timeout, + sense = dev.Read16(out cmdBuf, + out _, + 0, + false, + false, + false, + 1, + 2048, + 0, + 1, + false, + dev.Timeout, out _); - if(!sense && !dev.Error) - sector1 = cmdBuf; + if(!sense && !dev.Error) sector1 = cmdBuf; - sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false, dev.Timeout, + sense = dev.Read16(out cmdBuf, + out _, + 0, + false, + false, + false, + 0, + 2048, + 0, + 12, + false, + dev.Timeout, out _); - if(!sense && !dev.Error && cmdBuf.Length == 0x6000) - ps2BootSectors = cmdBuf; + if(!sense && !dev.Error && cmdBuf.Length == 0x6000) ps2BootSectors = cmdBuf; } else { - sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, false, - dev.Timeout, out _); + sense = dev.Read12(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 0, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); if(!sense && !dev.Error) { sector0 = cmdBuf; - sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 1, 2048, 0, 1, false, - dev.Timeout, out _); + sense = dev.Read12(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 1, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(!sense && !dev.Error) - sector1 = cmdBuf; + if(!sense && !dev.Error) sector1 = cmdBuf; - sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 12, false, - dev.Timeout, out _); + sense = dev.Read12(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 0, + 2048, + 0, + 12, + false, + dev.Timeout, + out _); - if(!sense && !dev.Error && cmdBuf.Length == 0x6000) - ps2BootSectors = cmdBuf; + if(!sense && !dev.Error && cmdBuf.Length == 0x6000) ps2BootSectors = cmdBuf; } else { - sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, dev.Timeout, + sense = dev.Read10(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 0, + 2048, + 0, + 1, + dev.Timeout, out _); if(!sense && !dev.Error) { sector0 = cmdBuf; - sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 1, 2048, 0, 1, - dev.Timeout, out _); + sense = dev.Read10(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 1, + 2048, + 0, + 1, + dev.Timeout, + out _); - if(!sense && !dev.Error) - sector1 = cmdBuf; + if(!sense && !dev.Error) sector1 = cmdBuf; - sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 12, - dev.Timeout, out _); + sense = dev.Read10(out cmdBuf, + out _, + 0, + false, + false, + false, + false, + 0, + 2048, + 0, + 12, + dev.Timeout, + out _); - if(!sense && !dev.Error && cmdBuf.Length == 0x6000) - ps2BootSectors = cmdBuf; + if(!sense && !dev.Error && cmdBuf.Length == 0x6000) ps2BootSectors = cmdBuf; } else { @@ -1057,13 +1529,11 @@ public static class MMC sense = dev.Read6(out cmdBuf, out _, 1, 2048, 1, dev.Timeout, out _); - if(!sense && !dev.Error) - sector1 = cmdBuf; + if(!sense && !dev.Error) sector1 = cmdBuf; sense = dev.Read6(out cmdBuf, out _, 0, 2048, 12, dev.Timeout, out _); - if(!sense && !dev.Error && cmdBuf.Length == 0x6000) - ps2BootSectors = cmdBuf; + if(!sense && !dev.Error && cmdBuf.Length == 0x6000) ps2BootSectors = cmdBuf; } } } @@ -1071,8 +1541,15 @@ public static class MMC if(mediaType == MediaType.DVDROM) { - sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + dev.Timeout, + out _); if(!sense) { @@ -1106,8 +1583,14 @@ public static class MMC } } - sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out _, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + dev.Timeout, out _); if(!sense) @@ -1150,8 +1633,20 @@ public static class MMC // Recordables will be checked for PhotoCD only case MediaType.CDR: // Check if ISO9660 - sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1, false, - dev.Timeout, out _); + sense = dev.Read12(out byte[] isoSector, + out _, + 0, + false, + false, + false, + false, + 16, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); // Sector 16 reads, and contains "CD001" magic? if(sense || @@ -1167,12 +1662,23 @@ public static class MMC while(isoSectorPosition < 32) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048, 0, - 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + isoSectorPosition, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); // If sector cannot be read, break here - if(sense) - break; + if(sense) break; // If sector does not contain "CD001" magic, break if(isoSector[1] != 0x43 || @@ -1183,8 +1689,7 @@ public static class MMC break; // If it is PVD or end of descriptor chain, break - if(isoSector[0] == 1 || isoSector[0] == 255) - break; + if(isoSector[0] == 1 || isoSector[0] == 255) break; isoSectorPosition++; } @@ -1201,8 +1706,7 @@ public static class MMC var rootStart = BitConverter.ToUInt32(isoSector, 158); var rootLength = BitConverter.ToUInt32(isoSector, 166); - if(rootStart == 0 || rootLength == 0) - return; + if(rootStart == 0 || rootLength == 0) return; rootLength /= 2048; @@ -1212,11 +1716,22 @@ public static class MMC for(uint i = 0; i < rootLength; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048, 0, - 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + rootStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; rootMs.Write(isoSector, 0, 2048); } @@ -1228,8 +1743,7 @@ public static class MMC return; } - if(isoSector.Length < 2048) - return; + if(isoSector.Length < 2048) return; var rootPos = 0; uint pcdStart = 0; @@ -1244,8 +1758,7 @@ public static class MMC Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); - if(name.EndsWith(";1", StringComparison.InvariantCulture)) - name = name[..^2]; + if(name.EndsWith(";1", StringComparison.InvariantCulture)) name = name[..^2]; if(name == "PHOTO_CD" && (isoSector[rootPos + 25] & 0x02) == 0x02) { @@ -1264,11 +1777,22 @@ public static class MMC for(uint i = 0; i < pcdLength; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i, 2048, - 0, 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + pcdStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; pcdMs.Write(isoSector, 0, 2048); } @@ -1280,8 +1804,7 @@ public static class MMC return; } - if(isoSector.Length < 2048) - return; + if(isoSector.Length < 2048) return; for(var pi = 0; pi < pcdLength; pi++) { @@ -1297,8 +1820,7 @@ public static class MMC Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); - if(name.EndsWith(";1", StringComparison.InvariantCulture)) - name = name[..^2]; + if(name.EndsWith(";1", StringComparison.InvariantCulture)) name = name[..^2]; if(name == "INFO.PCD") { @@ -1312,11 +1834,22 @@ public static class MMC if(infoPos > 0) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, infoPos, 2048, 0, 1, - false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + infoPos, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); @@ -1366,8 +1899,7 @@ public static class MMC return; } - if(sector0 == null) - return; + if(sector0 == null) return; switch(mediaType) { @@ -1411,12 +1943,12 @@ public static class MMC // The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :) byte decryptByte = ps2BootSectors[0]; - for(var i = 0; i < 0x6000; i++) - ps2BootSectors[i] ^= decryptByte; + for(var i = 0; i < 0x6000; i++) ps2BootSectors[i] ^= decryptByte; string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.PlayStation_2_boot_sectors_SHA256_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.PlayStation_2_boot_sectors_SHA256_0, ps2BootSectorsHash); if(ps2BootSectorsHash is PS2_PAL_HASH or PS2_NTSC_HASH or PS2_JAPANESE_HASH) @@ -1510,8 +2042,7 @@ public static class MMC { Array.Copy(firstTrackSecondSessionAudio, i, jaguar, 0, jaguar.Length); - if(!_atariSignature.SequenceEqual(jaguar)) - continue; + if(!_atariSignature.SequenceEqual(jaguar)) continue; mediaType = MediaType.JaguarCD; @@ -1551,9 +2082,22 @@ public static class MMC // Check CD+G, CD+EG and CD+MIDI if(mediaType == MediaType.CDDA) { - sense = dev.ReadCd(out byte[] subBuf, out _, 150, 96, 8, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, false, false, MmcErrorField.None, MmcSubchannel.Raw, - dev.Timeout, out _); + sense = dev.ReadCd(out byte[] subBuf, + out _, + 150, + 96, + 8, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + false, + false, + MmcErrorField.None, + MmcSubchannel.Raw, + dev.Timeout, + out _); if(!sense) { @@ -1567,14 +2111,11 @@ public static class MMC Array.Copy(subBuf, i * 96, tmpSub, 0, 96); DetectRwPackets(tmpSub, out bool cdgPacket, out bool cdegPacket, out bool cdmidiPacket); - if(cdgPacket) - cdg = true; + if(cdgPacket) cdg = true; - if(cdegPacket) - cdeg = true; + if(cdegPacket) cdeg = true; - if(cdmidiPacket) - cdmidi = true; + if(cdmidiPacket) cdmidi = true; } if(cdeg) @@ -1611,8 +2152,20 @@ public static class MMC hasPs2CdBoot: // Check if ISO9660 - sense = dev.Read12(out byte[] isoSector, out _, 0, false, false, false, false, 16, 2048, 0, 1, false, - dev.Timeout, out _); + sense = dev.Read12(out byte[] isoSector, + out _, + 0, + false, + false, + false, + false, + 16, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); // Sector 16 reads, and contains "CD001" magic? if(sense || @@ -1628,12 +2181,23 @@ public static class MMC while(isoSectorPosition < 32) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, isoSectorPosition, 2048, 0, - 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + isoSectorPosition, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); // If sector cannot be read, break here - if(sense) - break; + if(sense) break; // If sector does not contain "CD001" magic, break if(isoSector[1] != 0x43 || @@ -1644,8 +2208,7 @@ public static class MMC break; // If it is PVD or end of descriptor chain, break - if(isoSector[0] == 1 || isoSector[0] == 255) - break; + if(isoSector[0] == 1 || isoSector[0] == 255) break; isoSectorPosition++; } @@ -1662,8 +2225,7 @@ public static class MMC var rootStart = BitConverter.ToUInt32(isoSector, 158); var rootLength = BitConverter.ToUInt32(isoSector, 166); - if(rootStart == 0 || rootLength == 0) - return; + if(rootStart == 0 || rootLength == 0) return; rootLength /= 2048; @@ -1673,11 +2235,22 @@ public static class MMC for(uint i = 0; i < rootLength; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, rootStart + i, 2048, 0, - 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + rootStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; rootMs.Write(isoSector, 0, 2048); } @@ -1689,8 +2262,7 @@ public static class MMC return; } - if(isoSector.Length < 2048) - return; + if(isoSector.Length < 2048) return; List rootEntries = new(); uint ngcdIplStart = 0; @@ -1715,8 +2287,7 @@ public static class MMC Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); - if(name.EndsWith(";1", StringComparison.InvariantCulture)) - name = name[..^2]; + if(name.EndsWith(";1", StringComparison.InvariantCulture)) name = name[..^2]; rootEntries.Add(name); @@ -1751,8 +2322,7 @@ public static class MMC } } - if(rootEntries.Count == 0) - return; + if(rootEntries.Count == 0) return; if(rootEntries.Contains("CD32.TM")) { @@ -1777,8 +2347,7 @@ public static class MMC { uint ngcdSectors = ngcdIplLength / 2048; - if(ngcdIplLength % 2048 > 0) - ngcdSectors++; + if(ngcdIplLength % 2048 > 0) ngcdSectors++; string iplTxt; @@ -1789,11 +2358,22 @@ public static class MMC for(uint i = 0; i < ngcdSectors; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, ngcdIplStart + i, - 2048, 0, 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + ngcdIplStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; ngcdMs.Write(isoSector, 0, 2048); } @@ -1821,8 +2401,7 @@ public static class MMC // End of file if(line is null || line.Length == 0) { - if(lineNumber == 0) - correctNeoGeoCd = false; + if(lineNumber == 0) correctNeoGeoCd = false; break; } @@ -1831,14 +2410,12 @@ public static class MMC string[] split = line.Split(','); // Empty line - if(split.Length == 0) - continue; + if(split.Length == 0) continue; // More than 3 entries if(split.Length != 3) { - if(line[0] < 0x20) - break; + if(line[0] < 0x20) break; correctNeoGeoCd = false; @@ -1922,11 +2499,22 @@ public static class MMC for(uint i = 0; i < vcdLength; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, vcdStart + i, 2048, - 0, 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + vcdStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; vcdMs.Write(isoSector, 0, 2048); } @@ -1938,8 +2526,7 @@ public static class MMC return; } - if(isoSector.Length < 2048) - return; + if(isoSector.Length < 2048) return; uint infoPos = 0; @@ -1956,8 +2543,7 @@ public static class MMC Array.Copy(isoSector, vcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); - if(name.EndsWith(";1", StringComparison.InvariantCulture)) - name = name[..^2]; + if(name.EndsWith(";1", StringComparison.InvariantCulture)) name = name[..^2]; if(name is "INFO.VCD" or "INFO.SVD") { @@ -1972,11 +2558,22 @@ public static class MMC if(infoPos > 0) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, infoPos, 2048, 0, 1, - false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + infoPos, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); @@ -2018,11 +2615,22 @@ public static class MMC for(uint i = 0; i < pcdLength; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, pcdStart + i, 2048, - 0, 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + pcdStart + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; pcdMs.Write(isoSector, 0, 2048); } @@ -2034,8 +2642,7 @@ public static class MMC return; } - if(isoSector.Length < 2048) - return; + if(isoSector.Length < 2048) return; uint infoPos = 0; @@ -2052,8 +2659,7 @@ public static class MMC Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); - if(name.EndsWith(";1", StringComparison.InvariantCulture)) - name = name[..^2]; + if(name.EndsWith(";1", StringComparison.InvariantCulture)) name = name[..^2]; if(name == "INFO.PCD") { @@ -2068,11 +2674,22 @@ public static class MMC if(infoPos > 0) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, infoPos, 2048, 0, 1, - false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + infoPos, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); @@ -2097,8 +2714,7 @@ public static class MMC { uint ps1Sectors = ps1Length / 2048; - if(ps1Length % 2048 > 0) - ps1Sectors++; + if(ps1Length % 2048 > 0) ps1Sectors++; string ps1Txt; @@ -2109,11 +2725,22 @@ public static class MMC for(uint i = 0; i < ps1Sectors; i++) { - sense = dev.Read12(out isoSector, out _, 0, false, false, false, false, ps1Start + i, 2048, - 0, 1, false, dev.Timeout, out _); + sense = dev.Read12(out isoSector, + out _, + 0, + false, + false, + false, + false, + ps1Start + i, + 2048, + 0, + 1, + false, + dev.Timeout, + out _); - if(sense) - break; + if(sense) break; ps1Ms.Write(isoSector, 0, 2048); } @@ -2139,8 +2766,7 @@ public static class MMC string line = sr.ReadLine(); // End of file - if(line is null || line.Length == 0) - break; + if(line is null || line.Length == 0) break; line = line.Replace(" ", ""); @@ -2148,8 +2774,7 @@ public static class MMC { ps1BootFile = line[11..]; - if(ps1BootFile.StartsWith('\\')) - ps1BootFile = ps1BootFile[1..]; + if(ps1BootFile.StartsWith('\\')) ps1BootFile = ps1BootFile[1..]; if(ps1BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase)) ps1BootFile = ps1BootFile[..^2]; @@ -2157,13 +2782,11 @@ public static class MMC break; } - if(!line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase)) - continue; + if(!line.StartsWith("BOOT2=cdrom0:", StringComparison.InvariantCultureIgnoreCase)) continue; ps2BootFile = line[13..]; - if(ps2BootFile.StartsWith('\\')) - ps2BootFile = ps2BootFile[1..]; + if(ps2BootFile.StartsWith('\\')) ps2BootFile = ps2BootFile[1..]; if(ps2BootFile.EndsWith(";1", StringComparison.InvariantCultureIgnoreCase)) ps2BootFile = ps2BootFile[..^2]; @@ -2206,12 +2829,12 @@ public static class MMC // The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :) byte decryptByte = ps2BootSectors[0]; - for(var i = 0; i < 0x6000; i++) - ps2BootSectors[i] ^= decryptByte; + for(var i = 0; i < 0x6000; i++) ps2BootSectors[i] ^= decryptByte; string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.PlayStation_2_boot_sectors_SHA256_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.PlayStation_2_boot_sectors_SHA256_0, ps2BootSectorsHash); if(ps2BootSectorsHash is PS2_PAL_HASH or PS2_NTSC_HASH or PS2_JAPANESE_HASH) @@ -2319,17 +2942,13 @@ public static class MMC var i = 0; - for(var j = 0; j < 24; j++) - cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(var j = 0; j < 24; j++) - cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); + for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) { diff --git a/Aaru.Core/Media/Info/CompactDisc.cs b/Aaru.Core/Media/Info/CompactDisc.cs index 611dee3cb..eaee0be78 100644 --- a/Aaru.Core/Media/Info/CompactDisc.cs +++ b/Aaru.Core/Media/Info/CompactDisc.cs @@ -107,8 +107,14 @@ public static class CompactDisc dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true || dev.Manufacturer.Equals("plextor", StringComparison.InvariantCultureIgnoreCase)) { - sense = dev.PlextorReadCdDa(out cmdBuf, out _, wantedLba, sectorSize, 3, PlextorSubchannel.None, - dev.Timeout, out _); + sense = dev.PlextorReadCdDa(out cmdBuf, + out _, + wantedLba, + sectorSize, + 3, + PlextorSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { @@ -118,8 +124,7 @@ public static class CompactDisc { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); - if(!tmpBuf.SequenceEqual(sectorSync)) - continue; + if(!tmpBuf.SequenceEqual(sectorSync)) continue; // De-scramble M and S minute = cmdBuf[i + 12] ^ 0x01; @@ -152,34 +157,70 @@ public static class CompactDisc dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) == true || dev.Manufacturer.Equals("hl-dt-st", StringComparison.InvariantCultureIgnoreCase))) { - sense = dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false, - false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + wantedLba, + sectorSize, + 3, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(!sense && !dev.Error) { // Clear cache for(var i = 0; i < 63; i++) { - sense = dev.ReadCd(out _, out _, (uint)(wantedLba + 3 + 16 * i), sectorSize, 16, - MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, + sense = dev.ReadCd(out _, + out _, + (uint)(wantedLba + 3 + 16 * i), + sectorSize, + 16, + MmcSectorTypes.AllTypes, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, out _); - if(sense || dev.Error) - break; + if(sense || dev.Error) break; } - dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false, false, - false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + dev.ReadCd(out cmdBuf, + out _, + wantedLba, + sectorSize, + 3, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++) { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); - if(!tmpBuf.SequenceEqual(sectorSync)) - continue; + if(!tmpBuf.SequenceEqual(sectorSync)) continue; // De-scramble M and S minute = cmdBuf[i + 12] ^ 0x01; @@ -207,15 +248,13 @@ public static class CompactDisc } } - if(offsetFound) - return; + if(offsetFound) return; // Try to get another the offset some other way, we need an audio track just after a data track, same session for(var i = 1; i < tracks.Length; i++) { - if(tracks[i - 1].Type == TrackType.Audio || tracks[i].Type != TrackType.Audio) - continue; + if(tracks[i - 1].Type == TrackType.Audio || tracks[i].Type != TrackType.Audio) continue; dataTrack = tracks[i - 1]; audioTrack = tracks[i]; @@ -223,16 +262,27 @@ public static class CompactDisc break; } - if(dataTrack is null || audioTrack is null) - return; + if(dataTrack is null || audioTrack is null) return; // Found them - sense = dev.ReadCd(out cmdBuf, out _, (uint)audioTrack.StartSector, sectorSize, 3, MmcSectorTypes.Cdda, - false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, - MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + (uint)audioTrack.StartSector, + sectorSize, + 3, + MmcSectorTypes.Cdda, + false, + false, + false, + MmcHeaderCodes.None, + true, + false, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(sense || dev.Error) - return; + if(sense || dev.Error) return; dataTrack.EndSector += 150; @@ -265,8 +315,7 @@ public static class CompactDisc { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); - if(!tmpBuf.SequenceEqual(sectorSync)) - continue; + if(!tmpBuf.SequenceEqual(sectorSync)) continue; combinedOffset = i + 2352; offsetFound = true; @@ -274,18 +323,28 @@ public static class CompactDisc break; } - if(offsetFound || audioTrack.Pregap <= 0) - return; + if(offsetFound || audioTrack.Pregap <= 0) return; - sense = dev.ReadCd(out byte[] dataBuf, out _, (uint)dataTrack.EndSector, sectorSize, 1, - MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); + sense = dev.ReadCd(out byte[] dataBuf, + out _, + (uint)dataTrack.EndSector, + sectorSize, + 1, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); - if(sense || dev.Error) - return; + if(sense || dev.Error) return; - for(var i = 0; i < dataBuf.Length; i++) - dataBuf[i] ^= Sector.ScrambleTable[i]; + for(var i = 0; i < dataBuf.Length; i++) dataBuf[i] ^= Sector.ScrambleTable[i]; for(var i = 0; i < 2352; i++) { @@ -295,8 +354,7 @@ public static class CompactDisc Array.Copy(dataBuf, i, dataSide, 0, dataSide.Length); Array.Copy(cmdBuf, 0, audioSide, 0, audioSide.Length); - if(!dataSide.SequenceEqual(audioSide)) - continue; + if(!dataSide.SequenceEqual(audioSide)) continue; combinedOffset = audioSide.Length; @@ -307,18 +365,43 @@ public static class CompactDisc { var videoNowColorFrame = new byte[9 * sectorSize]; - sense = dev.ReadCd(out cmdBuf, out _, 0, sectorSize, 9, MmcSectorTypes.AllTypes, false, false, true, - MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, - dev.Timeout, out _); + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + sectorSize, + 9, + MmcSectorTypes.AllTypes, + false, + false, + true, + MmcHeaderCodes.AllHeaders, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, + out _); if(sense || dev.Error) { - sense = dev.ReadCd(out cmdBuf, out _, 0, sectorSize, 9, MmcSectorTypes.Cdda, false, false, true, - MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, + sense = dev.ReadCd(out cmdBuf, + out _, + 0, + sectorSize, + 9, + MmcSectorTypes.Cdda, + false, + false, + true, + MmcHeaderCodes.None, + true, + true, + MmcErrorField.None, + MmcSubchannel.None, + dev.Timeout, out _); - if(sense || dev.Error) - videoNowColorFrame = null; + if(sense || dev.Error) videoNowColorFrame = null; } if(videoNowColorFrame is null) diff --git a/Aaru.Core/Media/Info/ScsiInfo.cs b/Aaru.Core/Media/Info/ScsiInfo.cs index 0ae451981..fa0ff7cce 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -62,8 +62,7 @@ public sealed class ScsiInfo /// Device public ScsiInfo(Device dev) { - if(dev.Type != DeviceType.SCSI && dev.Type != DeviceType.ATAPI) - return; + if(dev.Type != DeviceType.SCSI && dev.Type != DeviceType.ATAPI) return; MediaType = MediaType.Unknown; MediaInserted = false; @@ -91,8 +90,7 @@ public sealed class ScsiInfo { resets++; - if(resets < 5) - goto deviceGotReset; + if(resets < 5) goto deviceGotReset; } switch(decSense?.ASC) @@ -107,8 +105,7 @@ public sealed class ScsiInfo Thread.Sleep(2000); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; leftRetries--; } @@ -132,8 +129,7 @@ public sealed class ScsiInfo Thread.Sleep(2000); sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _); - if(!sense) - break; + if(!sense) break; leftRetries--; } @@ -206,8 +202,7 @@ public sealed class ScsiInfo sense = dev.ReadCapacity16(out cmdBuf, out senseBuf, dev.Timeout, out _); - if(!sense) - ReadCapacity16 = cmdBuf; + if(!sense) ReadCapacity16 = cmdBuf; if(ReadCapacity == null || Blocks is 0xFFFFFFFF or 0) { @@ -231,8 +226,7 @@ public sealed class ScsiInfo } } - if(Blocks != 0 && BlockSize != 0) - Blocks++; + if(Blocks != 0 && BlockSize != 0) Blocks++; break; case PeripheralDeviceTypes.SequentialAccess: @@ -293,22 +287,26 @@ public sealed class ScsiInfo if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) { - sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, + sense = dev.GetConfiguration(out cmdBuf, + out senseBuf, + 0, + MmcGetConfigurationRt.Current, + dev.Timeout, out _); if(sense) { AaruConsole.DebugWriteLine(MODULE_NAME, "READ GET CONFIGURATION:\n{0}", Sense.PrettifySense(senseBuf)); - if(dev.IsUsb && scsiMediumType is 0x40 or 0x41 or 0x42) - MediaType = MediaType.FlashDrive; + if(dev.IsUsb && scsiMediumType is 0x40 or 0x41 or 0x42) MediaType = MediaType.FlashDrive; } else { MmcConfiguration = cmdBuf; Features.SeparatedFeatures ftr = Features.Separate(cmdBuf); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.GET_CONFIGURATION_current_profile_is_0, ftr.CurrentProfile); switch(ftr.CurrentProfile) @@ -446,11 +444,17 @@ public sealed class ScsiInfo } } - if(MediaType == MediaType.PD650 && Blocks == 1281856) - MediaType = MediaType.PD650_WORM; + if(MediaType == MediaType.PD650 && Blocks == 1281856) MediaType = MediaType.PD650_WORM; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.RecognizedFormatLayers, + 0, + dev.Timeout, + out _); if(sense) { @@ -461,12 +465,20 @@ public sealed class ScsiInfo else RecognizedFormatLayers = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.WriteProtectionStatus, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Write_Protection_Status_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Write_Protection_Status_0, Sense.PrettifySense(senseBuf)); } else @@ -481,20 +493,40 @@ public sealed class ScsiInfo DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_capabilitylist.bin", "SCSI READ DISC STRUCTURE", cmdBuf); */ - #region All DVD and HD DVD types +#region All DVD and HD DVD types - if(MediaType is MediaType.DVDDownload or MediaType.DVDPR or MediaType.DVDPRDL or MediaType.DVDPRW - or MediaType.DVDPRWDL or MediaType.DVDR or MediaType.DVDRAM or MediaType.DVDRDL - or MediaType.DVDROM or MediaType.DVDRW or MediaType.DVDRWDL or MediaType.HDDVDR - or MediaType.HDDVDRAM or MediaType.HDDVDRDL or MediaType.HDDVDROM or MediaType.HDDVDRW + if(MediaType is MediaType.DVDDownload + or MediaType.DVDPR + or MediaType.DVDPRDL + or MediaType.DVDPRW + or MediaType.DVDPRWDL + or MediaType.DVDR + or MediaType.DVDRAM + or MediaType.DVDRDL + or MediaType.DVDROM + or MediaType.DVDRW + or MediaType.DVDRWDL + or MediaType.HDDVDR + or MediaType.HDDVDRAM + or MediaType.HDDVDRDL + or MediaType.HDDVDROM + or MediaType.HDDVDRW or MediaType.HDDVDRWDL) { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_PFI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_PFI_0, Sense.PrettifySense(senseBuf)); } else @@ -533,13 +565,20 @@ public sealed class ScsiInfo } } - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DMI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DMI_0, Sense.PrettifySense(senseBuf)); } else @@ -559,50 +598,74 @@ public sealed class ScsiInfo } } - #endregion All DVD and HD DVD types +#endregion All DVD and HD DVD types - #region DVD-ROM +#region DVD-ROM if(MediaType is MediaType.DVDDownload or MediaType.DVDROM) { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.CopyrightInformation, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_CMI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_CMI_0, Sense.PrettifySense(senseBuf)); } else DvdCmi = cmdBuf; } - #endregion DVD-ROM +#endregion DVD-ROM switch(MediaType) { - #region DVD-ROM and HD DVD-ROM +#region DVD-ROM and HD DVD-ROM case MediaType.DVDDownload: case MediaType.DVDROM: case MediaType.HDDVDROM: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.BurstCuttingArea, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_BCA_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_BCA_0, Sense.PrettifySense(senseBuf)); } else DvdBca = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdAacs, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdAacs, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_AACS_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DVD_AACS_0, Sense.PrettifySense(senseBuf)); } else @@ -610,41 +673,64 @@ public sealed class ScsiInfo break; - #endregion DVD-ROM and HD DVD-ROM +#endregion DVD-ROM and HD DVD-ROM - #region DVD-RAM and HD DVD-RAM +#region DVD-RAM and HD DVD-RAM case MediaType.DVDRAM: case MediaType.HDDVDRAM: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramDds, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DDS_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DDS_0, Sense.PrettifySense(senseBuf)); } else DvdRamDds = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramMediumStatus, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramMediumStatus, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Medium_Status_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Medium_Status_0, Sense.PrettifySense(senseBuf)); } else DvdRamCartridgeStatus = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdramSpareAreaInformation, + 0, + dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_SAI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_SAI_0, Sense.PrettifySense(senseBuf)); } else @@ -652,14 +738,21 @@ public sealed class ScsiInfo break; - #endregion DVD-RAM and HD DVD-RAM +#endregion DVD-RAM and HD DVD-RAM - #region DVD-R and HD DVD-R +#region DVD-R and HD DVD-R case MediaType.DVDR: case MediaType.HDDVDR: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.LastBorderOutRmd, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.LastBorderOutRmd, + 0, + dev.Timeout, + out _); if(sense) { @@ -672,7 +765,7 @@ public sealed class ScsiInfo break; - #endregion DVD-R and HD DVD-R +#endregion DVD-R and HD DVD-R } var dvdDecrypt = new DVDDecryption(dev); @@ -680,31 +773,46 @@ public sealed class ScsiInfo if(!sense) { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscKey, dvdDecrypt.Agid, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscKey, + dvdDecrypt.Agid, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Disc_Key_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Disc_Key_0, Sense.PrettifySense(senseBuf)); } else DvdDiscKey = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.SectorCopyrightInformation, dvdDecrypt.Agid, - dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.SectorCopyrightInformation, + dvdDecrypt.Agid, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Sector_CMI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Sector_CMI_0, Sense.PrettifySense(senseBuf)); } else DvdSectorCmi = cmdBuf; } - #region Require drive authentication, won't work +#region Require drive authentication, won't work /* sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.MediaIdentifier, 0, dev.Timeout, out _); @@ -754,18 +862,26 @@ public sealed class ScsiInfo DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_aacsdatakeys.bin", "SCSI READ DISC STRUCTURE", cmdBuf); */ - #endregion Require drive authentication, won't work +#endregion Require drive authentication, won't work - #region DVD-R and DVD-RW +#region DVD-R and DVD-RW if(MediaType is MediaType.DVDR or MediaType.DVDRW or MediaType.DVDRDL or MediaType.DVDRWDL) { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PreRecordedInfo, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Pre_Recorded_Info_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Pre_Recorded_Info_0, Sense.PrettifySense(senseBuf)); } else @@ -776,35 +892,50 @@ public sealed class ScsiInfo } } - #endregion DVD-R and DVD-RW +#endregion DVD-R and DVD-RW switch(MediaType) { - #region DVD-R, DVD-RW and HD DVD-R +#region DVD-R, DVD-RW and HD DVD-R case MediaType.DVDR: case MediaType.DVDRW: case MediaType.DVDRDL: case MediaType.DVDRWDL: case MediaType.HDDVDR: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrMediaIdentifier, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_R_Media_ID_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DVD_R_Media_ID_0, Sense.PrettifySense(senseBuf)); } else DvdrMediaIdentifier = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrPhysicalInformation, + 0, + dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_R_PFI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DVD_R_PFI_0, Sense.PrettifySense(senseBuf)); } else @@ -816,31 +947,47 @@ public sealed class ScsiInfo break; - #endregion DVD-R, DVD-RW and HD DVD-R +#endregion DVD-R, DVD-RW and HD DVD-R - #region All DVD+ +#region All DVD+ case MediaType.DVDPR: case MediaType.DVDPRDL: case MediaType.DVDPRW: case MediaType.DVDPRWDL: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Adip, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Adip, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_ADIP_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_ADIP_0, Sense.PrettifySense(senseBuf)); } else DvdPlusAdip = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.Dcb, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DCB_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DCB_0, Sense.PrettifySense(senseBuf)); } else @@ -848,18 +995,25 @@ public sealed class ScsiInfo break; - #endregion All DVD+ +#endregion All DVD+ - #region HD DVD-ROM +#region HD DVD-ROM case MediaType.HDDVDROM: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.HddvdCopyrightInformation, + 0, + dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_HD_DVD_CMI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_HD_DVD_CMI_0, Sense.PrettifySense(senseBuf)); } else @@ -867,17 +1021,24 @@ public sealed class ScsiInfo break; - #endregion HD DVD-ROM +#endregion HD DVD-ROM } switch(MediaType) { - #region HD DVD-R +#region HD DVD-R case MediaType.HDDVDR: { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.HddvdrMediumStatus, + 0, + dev.Timeout, + out _); if(sense) { @@ -888,12 +1049,20 @@ public sealed class ScsiInfo else HddvdrMediumStatus = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdrLastRmd, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.HddvdrLastRmd, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Last_RMD_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Last_RMD_0, Sense.PrettifySense(senseBuf)); } else @@ -902,18 +1071,26 @@ public sealed class ScsiInfo break; } - #endregion HD DVD-R +#endregion HD DVD-R - #region DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL +#region DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL case MediaType.DVDPRDL or MediaType.DVDRDL or MediaType.DVDRWDL or MediaType.DVDPRWDL: { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrLayerCapacity, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DvdrLayerCapacity, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Layer_Capacity_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Layer_Capacity_0, Sense.PrettifySense(senseBuf)); } else @@ -922,16 +1099,23 @@ public sealed class ScsiInfo break; } - #endregion DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL +#endregion DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL } switch(MediaType) { - #region DVD-R DL +#region DVD-R DL case MediaType.DVDRDL: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.MiddleZoneStart, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.MiddleZoneStart, + 0, + dev.Timeout, + out _); if(sense) { @@ -942,8 +1126,15 @@ public sealed class ScsiInfo else DvdrDlMiddleZoneStart = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.JumpIntervalSize, + 0, + dev.Timeout, + out _); if(sense) { @@ -954,8 +1145,14 @@ public sealed class ScsiInfo else DvdrDlJumpIntervalSize = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.ManualLayerJumpStartLba, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.ManualLayerJumpStartLba, + 0, + dev.Timeout, out _); if(sense) @@ -967,8 +1164,15 @@ public sealed class ScsiInfo else DvdrDlManualLayerJumpStartLba = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.RemapAnchorPoint, + 0, + dev.Timeout, + out _); if(sense) { @@ -981,9 +1185,9 @@ public sealed class ScsiInfo break; - #endregion DVD-R DL +#endregion DVD-R DL - #region All Blu-ray +#region All Blu-ray case MediaType.BDR: case MediaType.BDRE: @@ -991,23 +1195,39 @@ public sealed class ScsiInfo case MediaType.UHDBD: case MediaType.BDRXL: case MediaType.BDREXL: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.DiscInformation, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DI_0, Sense.PrettifySense(senseBuf)); } else BlurayDiscInformation = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.Pac, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.Pac, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_PAC_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_PAC_0, Sense.PrettifySense(senseBuf)); } else @@ -1015,21 +1235,29 @@ public sealed class ScsiInfo break; - #endregion All Blu-ray +#endregion All Blu-ray } switch(MediaType) { - #region BD-ROM only +#region BD-ROM only case MediaType.BDROM: case MediaType.UHDBD: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdBurstCuttingArea, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_BCA_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_BCA_0, Sense.PrettifySense(senseBuf)); } else @@ -1037,27 +1265,42 @@ public sealed class ScsiInfo break; - #endregion BD-ROM only +#endregion BD-ROM only - #region Writable Blu-ray only +#region Writable Blu-ray only case MediaType.BDR: case MediaType.BDRE: case MediaType.BDRXL: case MediaType.BDREXL: - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdDds, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DDS_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DDS_0, Sense.PrettifySense(senseBuf)); } else BlurayDds = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.CartridgeStatus, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.CartridgeStatus, + 0, + dev.Timeout, + out _); if(sense) { @@ -1068,45 +1311,69 @@ public sealed class ScsiInfo else BlurayCartridgeStatus = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.BdSpareAreaInformation, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, "READ DISC STRUCTURE: Spare Area Information\n{0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "READ DISC STRUCTURE: Spare Area Information\n{0}", Sense.PrettifySense(senseBuf)); } else BluraySpareAreaInformation = cmdBuf; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.RawDfl, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Bd, + 0, + 0, + MmcDiscStructureFormat.RawDfl, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Raw_DFL_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_Raw_DFL_0, Sense.PrettifySense(senseBuf)); } else BlurayRawDfl = cmdBuf; - sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, - MmcDiscInformationDataTypes.TrackResources, dev.Timeout, out _); + sense = dev.ReadDiscInformation(out cmdBuf, + out senseBuf, + MmcDiscInformationDataTypes.TrackResources, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_001b_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_001b_0, Sense.PrettifySense(senseBuf)); } else BlurayTrackResources = cmdBuf; - sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.PowResources, - dev.Timeout, out _); + sense = dev.ReadDiscInformation(out cmdBuf, + out senseBuf, + MmcDiscInformationDataTypes.PowResources, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_010b_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_010b_0, Sense.PrettifySense(senseBuf)); } else @@ -1114,9 +1381,9 @@ public sealed class ScsiInfo break; - #endregion Writable Blu-ray only +#endregion Writable Blu-ray only - #region CDs +#region CDs case MediaType.CD: case MediaType.CDR: @@ -1129,7 +1396,8 @@ public sealed class ScsiInfo if(tocSense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_TOC_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_TOC_0, Sense.PrettifySense(senseBuf)); } else @@ -1138,8 +1406,7 @@ public sealed class ScsiInfo DecodedToc = TOC.Decode(cmdBuf); // As we have a TOC we know it is a CD - if(MediaType == MediaType.Unknown) - MediaType = MediaType.CD; + if(MediaType == MediaType.Unknown) MediaType = MediaType.CD; } // ATIP exists on blank CDs @@ -1147,7 +1414,8 @@ public sealed class ScsiInfo if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_ATIP_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_ATIP_0, Sense.PrettifySense(senseBuf)); } else @@ -1170,7 +1438,8 @@ public sealed class ScsiInfo if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_Session_Info_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_Session_Info_0, Sense.PrettifySense(senseBuf)); } else if(cmdBuf.Length > 4) @@ -1189,7 +1458,8 @@ public sealed class ScsiInfo if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_Raw_TOC_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_Raw_TOC_0, Sense.PrettifySense(senseBuf)); } else if(cmdBuf.Length > 4) @@ -1203,17 +1473,18 @@ public sealed class ScsiInfo if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_PMA_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_PMA_0, Sense.PrettifySense(senseBuf)); } - else if(cmdBuf.Length > 4) - Pma = cmdBuf; + else if(cmdBuf.Length > 4) Pma = cmdBuf; sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_CD_TEXT_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_TOC_PMA_ATIP_CD_TEXT_0, Sense.PrettifySense(senseBuf)); } else if(cmdBuf.Length > 4) @@ -1224,8 +1495,7 @@ public sealed class ScsiInfo sense = dev.ReadMcn(out string mcn, out _, out _, dev.Timeout, out _); - if(!sense && mcn != null && mcn != "0000000000000") - Mcn = mcn; + if(!sense && mcn != null && mcn != "0000000000000") Mcn = mcn; Isrcs = new Dictionary(); @@ -1233,29 +1503,35 @@ public sealed class ScsiInfo { sense = dev.ReadIsrc(i, out string isrc, out _, out _, dev.Timeout, out _); - if(!sense && isrc != null && isrc != "000000000000") - Isrcs.Add(i, isrc); + if(!sense && isrc != null && isrc != "000000000000") Isrcs.Add(i, isrc); } - if(Isrcs.Count == 0) - Isrcs = null; + if(Isrcs.Count == 0) Isrcs = null; } break; - #endregion CDs +#endregion CDs } - #region Nintendo +#region Nintendo if(MediaType == MediaType.Unknown && Blocks > 0) { - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_PFI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_PFI_0, Sense.PrettifySense(senseBuf)); } else @@ -1279,38 +1555,45 @@ public sealed class ScsiInfo } } - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.DiscManufacturingInformation, + 0, + dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DMI_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_STRUCTURE_DMI_0, Sense.PrettifySense(senseBuf)); } else DvdDmi = cmdBuf; } - #endregion Nintendo +#endregion Nintendo } sense = dev.ReadMediaSerialNumber(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_MEDIA_SERIAL_NUMBER_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_MEDIA_SERIAL_NUMBER_0, Sense.PrettifySense(senseBuf)); } else { - if(cmdBuf.Length >= 4) - MediaSerialNumber = cmdBuf; + if(cmdBuf.Length >= 4) MediaSerialNumber = cmdBuf; } switch(MediaType) { - #region Xbox +#region Xbox case MediaType.XGD: case MediaType.XGD2: @@ -1328,7 +1611,8 @@ public sealed class ScsiInfo if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.KREON_EXTRACT_SS_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.KREON_EXTRACT_SS_0, Sense.PrettifySense(senseBuf)); } else @@ -1360,8 +1644,15 @@ public sealed class ScsiInfo ulong totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + 0, + out _); if(sense) { @@ -1370,7 +1661,8 @@ public sealed class ScsiInfo break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Video_partition_total_size_0_sectors, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Video_partition_total_size_0_sectors, totalSize); ulong l0Video = PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN - @@ -1404,7 +1696,8 @@ public sealed class ScsiInfo 0xFFFFFFFF) + 1; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Game_partition_total_size_0_sectors, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Game_partition_total_size_0_sectors, gameSize); // Get middle zone size @@ -1430,8 +1723,15 @@ public sealed class ScsiInfo totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF; - sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _); + sense = dev.ReadDiscStructure(out cmdBuf, + out senseBuf, + MmcDiscStructureMediaType.Dvd, + 0, + 0, + MmcDiscStructureFormat.PhysicalInformation, + 0, + 0, + out _); if(sense) { @@ -1440,7 +1740,8 @@ public sealed class ScsiInfo break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Unlocked_total_size_0_sectors, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Unlocked_total_size_0_sectors, totalSize); ulong middleZone = totalSize - @@ -1467,32 +1768,40 @@ public sealed class ScsiInfo break; - #endregion Xbox +#endregion Xbox case MediaType.Unknown: - MediaType = MediaTypeFromDevice.GetFromScsi((byte)dev.ScsiType, dev.Manufacturer, dev.Model, - scsiMediumType, scsiDensityCode, Blocks, BlockSize, - dev.IsUsb, true); + MediaType = MediaTypeFromDevice.GetFromScsi((byte)dev.ScsiType, + dev.Manufacturer, + dev.Model, + scsiMediumType, + scsiDensityCode, + Blocks, + BlockSize, + dev.IsUsb, + true); break; } - if(MediaType == MediaType.Unknown && dev.IsUsb && containsFloppyPage) - MediaType = MediaType.FlashDrive; + if(MediaType == MediaType.Unknown && dev.IsUsb && containsFloppyPage) MediaType = MediaType.FlashDrive; - if(MediaType == MediaType.Unknown && !dev.IsRemovable) - MediaType = MediaType.GENERIC_HDD; + if(MediaType == MediaType.Unknown && !dev.IsRemovable) MediaType = MediaType.GENERIC_HDD; if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice || dev.IsUsb && scsiMediumType is 0x40 or 0x41 or 0x42) return; - sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.DiscInformation, - dev.Timeout, out _); + sense = dev.ReadDiscInformation(out cmdBuf, + out senseBuf, + MmcDiscInformationDataTypes.DiscInformation, + dev.Timeout, + out _); if(sense) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_INFORMATION_000b_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.READ_DISC_INFORMATION_000b_0, Sense.PrettifySense(senseBuf)); } else diff --git a/Aaru.Core/Options.cs b/Aaru.Core/Options.cs index 9355477fa..9e6cc9091 100644 --- a/Aaru.Core/Options.cs +++ b/Aaru.Core/Options.cs @@ -52,8 +52,7 @@ public static class Options string value; var sb = new StringBuilder(); - if(options == null) - return parsed; + if(options == null) return parsed; for(var index = 0; index < options.Length; index++) { @@ -88,11 +87,9 @@ public static class Options sb = new StringBuilder(); inValue = false; - if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) - continue; + if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) continue; - if(parsed.ContainsKey(name)) - parsed.Remove(name); + if(parsed.ContainsKey(name)) parsed.Remove(name); parsed.Add(name, value); @@ -185,16 +182,13 @@ public static class Options } } - if(!inValue) - return parsed; + if(!inValue) return parsed; value = sb.ToString(); - if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) - return parsed; + if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) return parsed; - if(parsed.ContainsKey(name)) - parsed.Remove(name); + if(parsed.ContainsKey(name)) parsed.Remove(name); parsed.Add(name, value); diff --git a/Aaru.Core/Partitions.cs b/Aaru.Core/Partitions.cs index 0a7bb5897..7435baa5f 100644 --- a/Aaru.Core/Partitions.cs +++ b/Aaru.Core/Partitions.cs @@ -64,15 +64,15 @@ public static class Partitions { foreach(IPartition plugin in plugins.Partitions.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; - if(!plugin.GetInformation(image, out List partitions, tapeFile.FirstBlock)) - continue; + if(!plugin.GetInformation(image, out List partitions, tapeFile.FirstBlock)) continue; foundPartitions.AddRange(partitions); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_0_at_1, plugin.Name, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Found_0_at_1, + plugin.Name, tapeFile.FirstBlock); } @@ -87,15 +87,15 @@ public static class Partitions { foreach(IPartition plugin in plugins.Partitions.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; - if(!plugin.GetInformation(image, out List partitions, imagePartition.Start)) - continue; + if(!plugin.GetInformation(image, out List partitions, imagePartition.Start)) continue; foundPartitions.AddRange(partitions); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_0_at_1, plugin.Name, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Found_0_at_1, + plugin.Name, imagePartition.Start); } @@ -108,11 +108,9 @@ public static class Partitions { foreach(IPartition plugin in plugins.Partitions.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; - if(!plugin.GetInformation(image, out List partitions, 0)) - continue; + if(!plugin.GetInformation(image, out List partitions, 0)) continue; foundPartitions.AddRange(partitions); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_0_at_zero, plugin.Name); @@ -135,16 +133,18 @@ public static class Partitions foreach(IPartition plugin in plugins.Partitions.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Trying_0_at_1, plugin.Name, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Trying_0_at_1, + plugin.Name, foundPartitions[0].Start); - if(!plugin.GetInformation(image, out List partitions, foundPartitions[0].Start)) - continue; + if(!plugin.GetInformation(image, out List partitions, foundPartitions[0].Start)) continue; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_0_at_1, plugin.Name, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Found_0_at_1, + plugin.Name, foundPartitions[0].Start); children.AddRange(partitions); @@ -183,8 +183,8 @@ public static class Partitions if(tapeImage.Files != null) { - childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock)). - Select(tapeFile => new Partition + childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock)) + .Select(tapeFile => new Partition { Start = tapeFile.FirstBlock, Length = tapeFile.LastBlock - tapeFile.FirstBlock + 1, @@ -200,18 +200,17 @@ public static class Partitions if(partitionableImage.Partitions != null) { childPartitions.AddRange(partitionableImage.Partitions.Where(imagePartition => - !startLocations. - Contains(imagePartition.Start))); + !startLocations.Contains(imagePartition + .Start))); } } - Partition[] childArray = childPartitions.OrderBy(part => part.Start). - ThenBy(part => part.Length). - ThenBy(part => part.Scheme). - ToArray(); + Partition[] childArray = childPartitions.OrderBy(part => part.Start) + .ThenBy(part => part.Length) + .ThenBy(part => part.Scheme) + .ToArray(); - for(long i = 0; i < childArray.LongLength; i++) - childArray[i].Sequence = (ulong)i; + for(long i = 0; i < childArray.LongLength; i++) childArray[i].Sequence = (ulong)i; return childArray.ToList(); } @@ -220,15 +219,12 @@ public static class Partitions /// List of partitions public static void AddSchemesToStats(List partitions) { - if(partitions == null || partitions.Count == 0) - return; + if(partitions == null || partitions.Count == 0) return; List schemes = new(); - foreach(Partition part in partitions.Where(part => !schemes.Contains(part.Scheme))) - schemes.Add(part.Scheme); + foreach(Partition part in partitions.Where(part => !schemes.Contains(part.Scheme))) schemes.Add(part.Scheme); - foreach(string scheme in schemes) - Statistics.AddPartition(scheme); + foreach(string scheme in schemes) Statistics.AddPartition(scheme); } } \ No newline at end of file diff --git a/Aaru.Core/PrintScsiModePages.cs b/Aaru.Core/PrintScsiModePages.cs index 17e769a12..4724945fb 100644 --- a/Aaru.Core/PrintScsiModePages.cs +++ b/Aaru.Core/PrintScsiModePages.cs @@ -48,8 +48,7 @@ public static class PrintScsiModePages { AaruConsole.WriteLine(Modes.PrettifyModeHeader(decMode.Header, devType)); - if(decMode.Pages == null) - return; + if(decMode.Pages == null) return; foreach(Modes.ModePage page in decMode.Pages) @@ -66,7 +65,8 @@ public static class PrintScsiModePages if(page.Subpage != 0) { AaruConsole.WriteLine(Localization.Core.Found_unknown_vendor_mode_page_0_subpage_1, - page.Page, page.Subpage); + page.Page, + page.Subpage); } else AaruConsole.WriteLine(Localization.Core.Found_unknown_vendor_mode_page_0, page.Page); @@ -376,7 +376,8 @@ public static class PrintScsiModePages { if(page.Subpage != 0) { - AaruConsole.WriteLine(Localization.Core.Found_unknown_mode_page_0_subpage_1, page.Page, + AaruConsole.WriteLine(Localization.Core.Found_unknown_mode_page_0_subpage_1, + page.Page, page.Subpage); } else diff --git a/Aaru.Core/Remote.cs b/Aaru.Core/Remote.cs index f135f6e34..840159aa5 100644 --- a/Aaru.Core/Remote.cs +++ b/Aaru.Core/Remote.cs @@ -76,15 +76,13 @@ public static class Remote httpClient.BaseAddress = new Uri("https://www.aaru.app"); - HttpResponseMessage response = httpClient. - PostAsync("/api/uploadreportv2", - new StringContent(json, Encoding.UTF8, - "application/json")). - GetAwaiter(). - GetResult(); + HttpResponseMessage response = httpClient + .PostAsync("/api/uploadreportv2", + new StringContent(json, Encoding.UTF8, "application/json")) + .GetAwaiter() + .GetResult(); - if(!response.IsSuccessStatusCode) - return; + if(!response.IsSuccessStatusCode) return; Stream data = response.Content.ReadAsStream(); var reader = new StreamReader(data); @@ -100,10 +98,9 @@ public static class Remote // ReSharper disable once RedundantCatchClause catch { - #if DEBUG - if(Debugger.IsAttached) - throw; - #endif +#if DEBUG + if(Debugger.IsAttached) throw; +#endif } }); }); @@ -121,14 +118,14 @@ public static class Remote { mctx.Database.EnsureCreated(); - mctx.Database. - ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); + mctx.Database + .ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); foreach(string migration in mctx.Database.GetPendingMigrations()) { - mctx.Database. - ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ - migration}', '0.0.0')"); + mctx.Database + .ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ + migration}', '0.0.0')"); } } else @@ -145,17 +142,13 @@ public static class Remote { List latestAll = new(); - if(mctx.UsbVendors.Any()) - latestAll.Add(mctx.UsbVendors.Max(v => v.ModifiedWhen)); + if(mctx.UsbVendors.Any()) latestAll.Add(mctx.UsbVendors.Max(v => v.ModifiedWhen)); - if(mctx.UsbProducts.Any()) - latestAll.Add(mctx.UsbProducts.Max(p => p.ModifiedWhen)); + if(mctx.UsbProducts.Any()) latestAll.Add(mctx.UsbProducts.Max(p => p.ModifiedWhen)); - if(mctx.CdOffsets.Any()) - latestAll.Add(mctx.CdOffsets.Max(o => o.ModifiedWhen)); + if(mctx.CdOffsets.Any()) latestAll.Add(mctx.CdOffsets.Max(o => o.ModifiedWhen)); - if(mctx.Devices.Any()) - latestAll.Add(mctx.Devices.Max(d => d.LastSynchronized)); + if(mctx.Devices.Any()) latestAll.Add(mctx.Devices.Max(d => d.LastSynchronized)); if(latestAll.Any()) { @@ -198,11 +191,11 @@ public static class Remote if(create) { - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Adding_USB_vendors); task.MaxValue = sync.UsbVendors.Count; @@ -216,11 +209,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_usb_vendors, sync.UsbVendors.Count); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Adding_USB_products); task.MaxValue = sync.UsbProducts.Count; @@ -229,18 +222,19 @@ public static class Remote { task.Increment(1); - mctx.UsbProducts.Add(new UsbProduct(product.VendorId, product.ProductId, + mctx.UsbProducts.Add(new UsbProduct(product.VendorId, + product.ProductId, product.Product)); } }); AaruConsole.WriteLine(Localization.Core.Added_0_usb_products, sync.UsbProducts.Count); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Adding_CompactDisc_read_offsets); task.MaxValue = sync.Offsets.Count; @@ -258,11 +252,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_CompactDisc_read_offsets, sync.Offsets.Count); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Adding_known_devices); task.MaxValue = sync.Devices.Count; @@ -281,11 +275,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_known_devices, sync.Devices.Count); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Adding_known_iNES_NES_2_0_headers); task.MaxValue = sync.NesHeaders?.Count ?? 0; @@ -331,11 +325,11 @@ public static class Remote long modifiedDevices = 0; long modifiedNesHeaders = 0; - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Updating_USB_vendors); task.MaxValue = sync.UsbVendors.Count; @@ -364,11 +358,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_usb_vendors, addedVendors); AaruConsole.WriteLine(Localization.Core.Modified_0_USB_vendors, modifiedVendors); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Updating_USB_products); task.MaxValue = sync.UsbVendors.Count; @@ -392,7 +386,8 @@ public static class Remote { addedProducts++; - mctx.UsbProducts.Add(new UsbProduct(product.VendorId, product.ProductId, + mctx.UsbProducts.Add(new UsbProduct(product.VendorId, + product.ProductId, product.Product)); } } @@ -401,11 +396,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_usb_products, addedProducts); AaruConsole.WriteLine(Localization.Core.Modified_0_USB_products, modifiedProducts); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Updating_CompactDisc_read_offsets); task.MaxValue = sync.Offsets.Count; @@ -441,11 +436,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_CompactDisc_read_offsets, addedOffsets); AaruConsole.WriteLine(Localization.Core.Modified_0_CompactDisc_read_offsets, modifiedOffsets); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Updating_known_devices); task.MaxValue = sync.Offsets.Count; @@ -487,11 +482,11 @@ public static class Remote AaruConsole.WriteLine(Localization.Core.Added_0_known_devices, addedDevices); AaruConsole.WriteLine(Localization.Core.Modified_0_known_devices, modifiedDevices); - AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). - Start(ctx => + AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()) + .Start(ctx => { ProgressTask task = ctx.AddTask(Localization.Core.Updating_known_iNES_NES_2_0_headers); task.MaxValue = sync.Offsets.Count; diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index 65ada4242..4ce1ba1e8 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -67,8 +67,7 @@ public sealed partial class Sidecar void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins, List imgChecksums, ref Metadata sidecar, Encoding encoding) { - if(_aborted) - return; + if(_aborted) return; sidecar.BlockMedias = new List { @@ -106,16 +105,14 @@ public sealed partial class Sidecar foreach(MediaTagType tagType in image.Info.ReadableMediaTags) { - if(_aborted) - return; + if(_aborted) return; switch(tagType) { case MediaTagType.ATAPI_IDENTIFY: errno = image.ReadMediaTag(MediaTagType.ATAPI_IDENTIFY, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].ATA = new ATA { @@ -130,8 +127,7 @@ public sealed partial class Sidecar case MediaTagType.ATA_IDENTIFY: errno = image.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].ATA = new ATA { @@ -146,8 +142,7 @@ public sealed partial class Sidecar case MediaTagType.PCMCIA_CIS: errno = image.ReadMediaTag(MediaTagType.PCMCIA_CIS, out byte[] cis); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].Pcmcia = new Pcmcia { @@ -202,8 +197,7 @@ public sealed partial class Sidecar case MediaTagType.SCSI_INQUIRY: errno = image.ReadMediaTag(MediaTagType.SCSI_INQUIRY, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SCSI = new SCSI { @@ -218,8 +212,7 @@ public sealed partial class Sidecar case MediaTagType.SD_CID: errno = image.ReadMediaTag(MediaTagType.SD_CID, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital(); @@ -233,8 +226,7 @@ public sealed partial class Sidecar case MediaTagType.SD_CSD: errno = image.ReadMediaTag(MediaTagType.SD_CSD, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital(); @@ -248,8 +240,7 @@ public sealed partial class Sidecar case MediaTagType.SD_SCR: errno = image.ReadMediaTag(MediaTagType.SD_SCR, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital(); @@ -263,8 +254,7 @@ public sealed partial class Sidecar case MediaTagType.SD_OCR: errno = image.ReadMediaTag(MediaTagType.SD_OCR, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SecureDigital ??= new SecureDigital(); @@ -278,8 +268,7 @@ public sealed partial class Sidecar case MediaTagType.MMC_CID: errno = image.ReadMediaTag(MediaTagType.MMC_CID, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard(); @@ -293,8 +282,7 @@ public sealed partial class Sidecar case MediaTagType.MMC_CSD: errno = image.ReadMediaTag(MediaTagType.MMC_CSD, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard(); @@ -308,8 +296,7 @@ public sealed partial class Sidecar case MediaTagType.MMC_OCR: errno = image.ReadMediaTag(MediaTagType.MMC_OCR, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard(); @@ -323,8 +310,7 @@ public sealed partial class Sidecar case MediaTagType.MMC_ExtendedCSD: errno = image.ReadMediaTag(MediaTagType.MMC_ExtendedCSD, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].MultiMediaCard ??= new MultiMediaCard(); @@ -338,8 +324,7 @@ public sealed partial class Sidecar case MediaTagType.USB_Descriptors: errno = image.ReadMediaTag(MediaTagType.USB_Descriptors, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].Usb ??= new Usb(); @@ -353,8 +338,7 @@ public sealed partial class Sidecar case MediaTagType.SCSI_MODESENSE_6: errno = image.ReadMediaTag(MediaTagType.SCSI_MODESENSE_6, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SCSI ??= new SCSI(); @@ -368,8 +352,7 @@ public sealed partial class Sidecar case MediaTagType.SCSI_MODESENSE_10: errno = image.ReadMediaTag(MediaTagType.SCSI_MODESENSE_10, out buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; sidecar.BlockMedias[0].SCSI ??= new SCSI(); @@ -488,8 +471,7 @@ public sealed partial class Sidecar { UpdateStatus(string.Format(Localization.Core.Hashing_partition_0, tapePartition.Number)); - if(_aborted) - return; + if(_aborted) return; var tapePartitionChk = new Checksum(); @@ -515,7 +497,8 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { - errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors, sectorsToRead, + errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors, + sectorsToRead, out sector); if(errno != ErrorNumber.NoError) @@ -535,7 +518,8 @@ public sealed partial class Sidecar else { errno = image.ReadSectors(tapePartition.FirstBlock + doneSectors, - (uint)(sectors - doneSectors), out sector); + (uint)(sectors - doneSectors), + out sector); if(errno != ErrorNumber.NoError) { @@ -568,7 +552,7 @@ public sealed partial class Sidecar List filesInPartition = new(); foreach(CommonTypes.Structs.TapeFile tapeFile in - tapeImage.Files.Where(f => f.Partition == tapePartition.Number)) + tapeImage.Files.Where(f => f.Partition == tapePartition.Number)) { var thisFile = new TapeFile { @@ -589,8 +573,7 @@ public sealed partial class Sidecar { UpdateStatus(string.Format(Localization.Core.Hashing_file_0, tapeFile.File)); - if(_aborted) - return; + if(_aborted) return; var tapeFileChk = new Checksum(); @@ -621,14 +604,16 @@ public sealed partial class Sidecar if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, tapeFile.FirstBlock + doneSectors)); + errno, + tapeFile.FirstBlock + doneSectors)); EndProgress2(); return; } - UpdateProgress2(Localization.Core.Hashing_blocks_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_blocks_0_of_1, + (long)doneSectors, (long)sectors); doneSectors += sectorsToRead; @@ -636,19 +621,22 @@ public sealed partial class Sidecar else { errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, - (uint)(sectors - doneSectors), out sector); + (uint)(sectors - doneSectors), + out sector); if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, tapeFile.FirstBlock + doneSectors)); + errno, + tapeFile.FirstBlock + doneSectors)); EndProgress2(); return; } - UpdateProgress2(Localization.Core.Hashing_blocks_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_blocks_0_of_1, + (long)doneSectors, (long)sectors); doneSectors += sectors - doneSectors; @@ -682,8 +670,7 @@ public sealed partial class Sidecar UpdateStatus(Localization.Core.Checking_filesystems); - if(_aborted) - return; + if(_aborted) return; List partitions = Partitions.GetAll(image); Partitions.AddSchemesToStats(partitions); @@ -694,8 +681,7 @@ public sealed partial class Sidecar { foreach(Partition partition in partitions) { - if(_aborted) - return; + if(_aborted) return; var fsInfo = new CommonTypes.AaruMetadata.Partition { @@ -713,14 +699,11 @@ public sealed partial class Sidecar { try { - if(_aborted) - return; + if(_aborted) return; - if(fs is null) - continue; + if(fs is null) continue; - if(!fs.Identify(image, partition)) - continue; + if(!fs.Identify(image, partition)) continue; if(fs is IReadOnlyFilesystem rofs && rofs.Mount(image, partition, encoding, null, null) == ErrorNumber.NoError) @@ -742,24 +725,22 @@ public sealed partial class Sidecar Statistics.AddFilesystem(fsMetadata.Type); } } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); } } - if(lstFs.Count > 0) - fsInfo.FileSystems = lstFs; + if(lstFs.Count > 0) fsInfo.FileSystems = lstFs; sidecar.BlockMedias[0].FileSystemInformation.Add(fsInfo); } } else { - if(_aborted) - return; + if(_aborted) return; var fsInfo = new CommonTypes.AaruMetadata.Partition { @@ -780,14 +761,11 @@ public sealed partial class Sidecar { try { - if(_aborted) - return; + if(_aborted) return; - if(fs is null) - continue; + if(fs is null) continue; - if(!fs.Identify(image, wholePart)) - continue; + if(!fs.Identify(image, wholePart)) continue; if(fs is IReadOnlyFilesystem rofs && rofs.Mount(image, wholePart, encoding, null, null) == ErrorNumber.NoError) @@ -809,16 +787,15 @@ public sealed partial class Sidecar Statistics.AddFilesystem(fsMetadata.Type); } } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); } } - if(lstFs.Count > 0) - fsInfo.FileSystems = lstFs; + if(lstFs.Count > 0) fsInfo.FileSystems = lstFs; sidecar.BlockMedias[0].FileSystemInformation.Add(fsInfo); } @@ -837,8 +814,7 @@ public sealed partial class Sidecar Identify.IdentifyDevice? ataId = null; errno = image.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out buffer); - if(errno == ErrorNumber.NoError) - ataId = Identify.Decode(buffer); + if(errno == ErrorNumber.NoError) ataId = Identify.Decode(buffer); switch(ataId) { @@ -846,11 +822,13 @@ public sealed partial class Sidecar sidecar.BlockMedias[0].Cylinders = ataId.Value.CurrentCylinders; sidecar.BlockMedias[0].Heads = ataId.Value.CurrentHeads; sidecar.BlockMedias[0].SectorsPerTrack = ataId.Value.CurrentSectorsPerTrack; + break; case { Cylinders: > 0, Heads: > 0, SectorsPerTrack: > 0 }: sidecar.BlockMedias[0].Cylinders = ataId.Value.Cylinders; sidecar.BlockMedias[0].Heads = ataId.Value.Heads; sidecar.BlockMedias[0].SectorsPerTrack = ataId.Value.SectorsPerTrack; + break; } } @@ -987,13 +965,12 @@ public sealed partial class Sidecar break; } - #region SuperCardPro +#region SuperCardPro string scpFilePath = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath) + ".scp"); - if(_aborted) - return; + if(_aborted) return; if(File.Exists(scpFilePath)) { @@ -1021,8 +998,7 @@ public sealed partial class Sidecar for(byte t = scpImage.Header.start; t <= scpImage.Header.end; t++) { - if(_aborted) - return; + if(_aborted) return; var scpBlockTrackType = new BlockTrack { @@ -1063,29 +1039,30 @@ public sealed partial class Sidecar scpBlockTrackTypes.Add(scpBlockTrackType); } - sidecar.BlockMedias[0].Track = scpBlockTrackTypes.OrderBy(t => t.Cylinder). - ThenBy(t => t.Head). - ToList(); + sidecar.BlockMedias[0].Track = + scpBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToList(); } else { - AaruConsole. - ErrorWriteLine(Localization.Core.SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - scpImage.Header.end + 1, image.Info.Cylinders); + AaruConsole.ErrorWriteLine(Localization.Core + .SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + scpImage.Header.end + 1, + image.Info.Cylinders); } } else { - AaruConsole. - ErrorWriteLine(Localization.Core.SCP_image_do_not_same_number_heads_0_disk_image_1_ignoring, 2, - image.Info.Heads); + AaruConsole.ErrorWriteLine(Localization.Core + .SCP_image_do_not_same_number_heads_0_disk_image_1_ignoring, + 2, + image.Info.Heads); } } } - #endregion +#endregion - #region KryoFlux +#region KryoFlux string kfFile = null; @@ -1093,8 +1070,7 @@ public sealed partial class Sidecar var kfDir = false; - if(_aborted) - return; + if(_aborted) return; if(Directory.Exists(basename)) { @@ -1107,9 +1083,8 @@ public sealed partial class Sidecar } } else if(File.Exists(basename + "00.0.raw")) - kfFile = basename + "00.0.raw"; - else if(File.Exists(basename + "00.1.raw")) - kfFile = basename + "00.1.raw"; + kfFile = basename + "00.0.raw"; + else if(File.Exists(basename + "00.1.raw")) kfFile = basename + "00.1.raw"; if(kfFile != null) { @@ -1137,8 +1112,7 @@ public sealed partial class Sidecar foreach(KeyValuePair kvp in kfImage.tracks) { - if(_aborted) - return; + if(_aborted) return; var kfBlockTrackType = new BlockTrack { @@ -1148,9 +1122,9 @@ public sealed partial class Sidecar { Format = kfImage.Format, Value = kfDir - ? Path. - Combine(Path.GetFileName(Path.GetDirectoryName(kvp.Value.BasePath)), - kvp.Value.Filename) + ? Path.Combine(Path.GetFileName(Path.GetDirectoryName(kvp.Value + .BasePath)), + kvp.Value.Filename) : kvp.Value.Filename, Offset = 0 } @@ -1176,45 +1150,43 @@ public sealed partial class Sidecar kfBlockTrackTypes.Add(kfBlockTrackType); } - sidecar.BlockMedias[0].Track = kfBlockTrackTypes.OrderBy(t => t.Cylinder). - ThenBy(t => t.Head). - ToList(); + sidecar.BlockMedias[0].Track = + kfBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToList(); } else { - AaruConsole. - ErrorWriteLine(Localization.Core.KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - kfImage.Info.Cylinders, image.Info.Cylinders); + AaruConsole.ErrorWriteLine(Localization.Core + .KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + kfImage.Info.Cylinders, + image.Info.Cylinders); } } else { - AaruConsole. - ErrorWriteLine(Localization.Core.KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring, - kfImage.Info.Heads, image.Info.Heads); + AaruConsole.ErrorWriteLine(Localization.Core + .KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring, + kfImage.Info.Heads, + image.Info.Heads); } } } - #endregion +#endregion - #region DiscFerret +#region DiscFerret string dfiFilePath = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath) + ".dfi"); - if(_aborted) - return; + if(_aborted) return; - if(!File.Exists(dfiFilePath)) - return; + if(!File.Exists(dfiFilePath)) return; var dfiImage = new DiscFerret(); var dfiFilter = new ZZZNoFilter(); dfiFilter.Open(dfiFilePath); - if(!dfiImage.Identify(dfiFilter)) - return; + if(!dfiImage.Identify(dfiFilter)) return; try { @@ -1234,8 +1206,7 @@ public sealed partial class Sidecar foreach(int t in dfiImage.TrackOffsets.Keys) { - if(_aborted) - return; + if(_aborted) return; var dfiBlockTrackType = new BlockTrack { @@ -1276,19 +1247,21 @@ public sealed partial class Sidecar } else { - AaruConsole. - ErrorWriteLine(Localization.Core.DiscFerret_image_do_not_same_number_tracks_0_disk_image_1_ignoring, - dfiImage.Info.Cylinders, image.Info.Cylinders); + AaruConsole.ErrorWriteLine(Localization.Core + .DiscFerret_image_do_not_same_number_tracks_0_disk_image_1_ignoring, + dfiImage.Info.Cylinders, + image.Info.Cylinders); } } else { - AaruConsole. - ErrorWriteLine(Localization.Core.DiscFerret_image_do_not_same_number_heads_0_disk_image_1_ignoring, - dfiImage.Info.Heads, image.Info.Heads); + AaruConsole.ErrorWriteLine(Localization.Core + .DiscFerret_image_do_not_same_number_heads_0_disk_image_1_ignoring, + dfiImage.Info.Heads, + image.Info.Heads); } - #endregion +#endregion // TODO: Implement support for getting CHS from SCSI mode pages } diff --git a/Aaru.Core/Sidecar/BlockTape.cs b/Aaru.Core/Sidecar/BlockTape.cs index b4b9ec7c9..b830f92c1 100644 --- a/Aaru.Core/Sidecar/BlockTape.cs +++ b/Aaru.Core/Sidecar/BlockTape.cs @@ -80,8 +80,7 @@ public sealed partial class Sidecar } }; - if(_aborted) - return _sidecar; + if(_aborted) return _sidecar; ulong currentBlock = 0; ulong totalSize = 0; @@ -92,8 +91,7 @@ public sealed partial class Sidecar for(var i = 0; i < files.Count; i++) { - if(_aborted) - return _sidecar; + if(_aborted) return _sidecar; _fs = new FileStream(files[i], FileMode.Open, FileAccess.Read); var fileWorker = new Checksum(); @@ -135,7 +133,8 @@ public sealed partial class Sidecar _fs.EnsureRead(sector, 0, sector.Length); UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}", - (long)doneSectors, (long)sectors); + (long)doneSectors, + (long)sectors); doneSectors += sectorsToRead; } @@ -145,7 +144,8 @@ public sealed partial class Sidecar _fs.EnsureRead(sector, 0, sector.Length); UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}", - (long)doneSectors, (long)sectors); + (long)doneSectors, + (long)sectors); doneSectors += sectors - doneSectors; } diff --git a/Aaru.Core/Sidecar/Files.cs b/Aaru.Core/Sidecar/Files.cs index afb1d0aaa..77d4e351b 100644 --- a/Aaru.Core/Sidecar/Files.cs +++ b/Aaru.Core/Sidecar/Files.cs @@ -49,8 +49,7 @@ public sealed partial class Sidecar ErrorNumber ret = filesystem.OpenDir("/", out IDirNode node); - if(ret != ErrorNumber.NoError) - return null; + if(ret != ErrorNumber.NoError) return null; List directories = new(); List files = new(); @@ -78,11 +77,9 @@ public sealed partial class Sidecar filesystem.CloseDir(node); - if(files.Count > 0) - contents.Files = files.OrderBy(f => f.Name).ToList(); + if(files.Count > 0) contents.Files = files.OrderBy(f => f.Name).ToList(); - if(directories.Count > 0) - contents.Directories = directories.OrderBy(d => d.Name).ToList(); + if(directories.Count > 0) contents.Directories = directories.OrderBy(d => d.Name).ToList(); return contents; } @@ -108,8 +105,7 @@ public sealed partial class Sidecar ErrorNumber ret = filesystem.OpenDir(path + "/" + filename, out IDirNode node); - if(ret != ErrorNumber.NoError) - return null; + if(ret != ErrorNumber.NoError) return null; List directories = new(); List files = new(); @@ -135,11 +131,9 @@ public sealed partial class Sidecar files.Add(SidecarFile(filesystem, path + "/" + filename, dirent, entryStat)); } - if(files.Count > 0) - directory.Files = files.OrderBy(f => f.Name).ToList(); + if(files.Count > 0) directory.Files = files.OrderBy(f => f.Name).ToList(); - if(directories.Count > 0) - directory.Directories = directories.OrderBy(d => d.Name).ToList(); + if(directories.Count > 0) directory.Directories = directories.OrderBy(d => d.Name).ToList(); return directory; } @@ -182,8 +176,7 @@ public sealed partial class Sidecar while(position < stat.Length - 1048576) { - if(_aborted) - return file; + if(_aborted) return file; // TODO: Better error handling filesystem.ReadFile(fileNode, 1048576, data, out _); @@ -213,8 +206,7 @@ public sealed partial class Sidecar ErrorNumber ret = filesystem.ListXAttr(path + "/" + filename, out List xattrs); - if(ret != ErrorNumber.NoError) - return file; + if(ret != ErrorNumber.NoError) return file; List xattrTypes = new(); @@ -222,8 +214,7 @@ public sealed partial class Sidecar { ret = filesystem.GetXattr(path + "/" + filename, xattr, ref data); - if(ret != ErrorNumber.NoError) - continue; + if(ret != ErrorNumber.NoError) continue; var xattrChkWorker = new Checksum(); xattrChkWorker.Update(data); @@ -236,8 +227,7 @@ public sealed partial class Sidecar }); } - if(xattrTypes.Count > 0) - file.ExtendedAttributes = xattrTypes.OrderBy(x => x.Name).ToList(); + if(xattrTypes.Count > 0) file.ExtendedAttributes = xattrTypes.OrderBy(x => x.Name).ToList(); return file; } diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 1ba5efa05..6d0a8e113 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -64,8 +64,7 @@ public sealed partial class Sidecar void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins, List imgChecksums, ref Metadata sidecar, Encoding encoding) { - if(_aborted) - return; + if(_aborted) return; sidecar.OpticalDiscs = new List { @@ -104,13 +103,11 @@ public sealed partial class Sidecar foreach(MediaTagType tagType in image.Info.ReadableMediaTags) { - if(_aborted) - return; + if(_aborted) return; errno = image.ReadMediaTag(tagType, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; Dump.AddMediaTagToSidecar(imagePath, tagType, tag, ref sidecar); @@ -182,11 +179,9 @@ public sealed partial class Sidecar _ => dskType }; - if(dskType == MediaType.DVDR && pfi.Value.PartVersion >= 6) - dskType = MediaType.DVDRDL; + if(dskType == MediaType.DVDR && pfi.Value.PartVersion >= 6) dskType = MediaType.DVDRDL; - if(dskType == MediaType.DVDRW && pfi.Value.PartVersion >= 15) - dskType = MediaType.DVDRWDL; + if(dskType == MediaType.DVDRW && pfi.Value.PartVersion >= 15) dskType = MediaType.DVDRWDL; if(dskType == MediaType.GOD && pfi.Value.DiscSize == DVDSize.OneTwenty) dskType = MediaType.WOD; @@ -245,8 +240,7 @@ public sealed partial class Sidecar if(sidecar.OpticalDiscs[0].Dimensions == null && image.Info.MediaType != MediaType.Unknown) sidecar.OpticalDiscs[0].Dimensions = Dimensions.FromMediaType(image.Info.MediaType); - if(_aborted) - return; + if(_aborted) return; InitProgress(); @@ -294,8 +288,7 @@ public sealed partial class Sidecar xmlTrk.StartSector = trk.StartSector; xmlTrk.EndSector = trk.EndSector; - if(trk.Indexes?.TryGetValue(0, out int idx0) == true && idx0 >= 0) - xmlTrk.StartSector = (ulong)idx0; + if(trk.Indexes?.TryGetValue(0, out int idx0) == true && idx0 >= 0) xmlTrk.StartSector = (ulong)idx0; switch(sidecar.OpticalDiscs[0].DiscType) { @@ -318,8 +311,7 @@ public sealed partial class Sidecar Format = trk.FileType }; - if(trk.FileOffset > 0) - xmlTrk.Image.Offset = trk.FileOffset; + if(trk.FileOffset > 0) xmlTrk.Image.Offset = trk.FileOffset; xmlTrk.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * (ulong)trk.RawBytesPerSector; @@ -365,7 +357,8 @@ public sealed partial class Sidecar { errno = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.Number, out sector); - UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, + (long)doneSectors, (long)(trk.EndSector - trk.StartSector + 1)); if(errno != ErrorNumber.NoError) @@ -380,10 +373,13 @@ public sealed partial class Sidecar } else { - errno = image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors), - xmlTrk.Sequence.Number, out sector); + errno = image.ReadSectorsLong(doneSectors, + (uint)(sectors - doneSectors), + xmlTrk.Sequence.Number, + out sector); - UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, + (long)doneSectors, (long)(trk.EndSector - trk.StartSector + 1)); if(errno != ErrorNumber.NoError) @@ -437,8 +433,7 @@ public sealed partial class Sidecar break; } - if(trk.FileOffset > 0) - xmlTrk.SubChannel.Image.Offset = trk.SubchannelOffset; + if(trk.FileOffset > 0) xmlTrk.SubChannel.Image.Offset = trk.SubchannelOffset; var subChkWorker = new Checksum(); @@ -461,10 +456,14 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { - errno = image.ReadSectorsTag(doneSectors, sectorsToRead, xmlTrk.Sequence.Number, - SectorTagType.CdSectorSubchannel, out sector); + errno = image.ReadSectorsTag(doneSectors, + sectorsToRead, + xmlTrk.Sequence.Number, + SectorTagType.CdSectorSubchannel, + out sector); - UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, + (long)doneSectors, (long)(trk.EndSector - trk.StartSector + 1)); if(errno != ErrorNumber.NoError) @@ -479,10 +478,14 @@ public sealed partial class Sidecar } else { - errno = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors), xmlTrk.Sequence.Number, - SectorTagType.CdSectorSubchannel, out sector); + errno = image.ReadSectorsTag(doneSectors, + (uint)(sectors - doneSectors), + xmlTrk.Sequence.Number, + SectorTagType.CdSectorSubchannel, + out sector); - UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors, + UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, + (long)doneSectors, (long)(trk.EndSector - trk.StartSector + 1)); if(errno != ErrorNumber.NoError) @@ -538,11 +541,9 @@ public sealed partial class Sidecar return; } - if(fs is null) - continue; + if(fs is null) continue; - if(!fs.Identify(image, partition)) - continue; + if(!fs.Identify(image, partition)) continue; fs.GetInformation(image, partition, encoding, out _, out FileSystem fsMetadata); lstFs.Add(fsMetadata); @@ -557,16 +558,15 @@ public sealed partial class Sidecar _ => dskType }; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); } } - if(lstFs.Count > 0) - metadataPartition.FileSystems = lstFs; + if(lstFs.Count > 0) metadataPartition.FileSystems = lstFs; xmlTrk.FileSystemInformation.Add(metadataPartition); } @@ -601,11 +601,9 @@ public sealed partial class Sidecar return; } - if(fs is null) - continue; + if(fs is null) continue; - if(!fs.Identify(image, xmlPart)) - continue; + if(!fs.Identify(image, xmlPart)) continue; fs.GetInformation(image, xmlPart, encoding, out _, out FileSystem fsMetadata); lstFs.Add(fsMetadata); @@ -620,24 +618,22 @@ public sealed partial class Sidecar _ => dskType }; } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name); } } - if(lstFs.Count > 0) - metadataPartition.FileSystems = lstFs; + if(lstFs.Count > 0) metadataPartition.FileSystems = lstFs; xmlTrk.FileSystemInformation.Add(metadataPartition); } errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcData); - if(errno == ErrorNumber.NoError) - xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData); + if(errno == ErrorNumber.NoError) xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData); errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackFlags, out byte[] flagsData); @@ -656,13 +652,13 @@ public sealed partial class Sidecar if(trk.Indexes?.Count > 0) { - xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key). - Select(i => new TrackIndex + xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key) + .Select(i => new TrackIndex { Index = i.Key, Value = i.Value - }). - ToList(); + }) + .ToList(); } trksLst.Add(xmlTrk); @@ -670,8 +666,7 @@ public sealed partial class Sidecar EndProgress(); - if(trksLst != null) - sidecar.OpticalDiscs[0].Track = trksLst; + if(trksLst != null) sidecar.OpticalDiscs[0].Track = trksLst; // All XGD3 all have the same number of blocks if(dskType == MediaType.XGD2 && sidecar.OpticalDiscs[0].Track.Count == 1) diff --git a/Aaru.Core/Sidecar/Sidecar.cs b/Aaru.Core/Sidecar/Sidecar.cs index 89239155c..afea50e5c 100644 --- a/Aaru.Core/Sidecar/Sidecar.cs +++ b/Aaru.Core/Sidecar/Sidecar.cs @@ -102,8 +102,7 @@ public sealed partial class Sidecar while(position < _fi.Length - 1048576) { - if(_aborted) - return _sidecar; + if(_aborted) return _sidecar; data = new byte[1048576]; _fs.EnsureRead(data, 0, 1048576); @@ -130,21 +129,26 @@ public sealed partial class Sidecar List imgChecksums = _imgChkWorker.End(); - if(_aborted) - return _sidecar; + if(_aborted) return _sidecar; switch(_image.Info.MetadataMediaType) { case MetadataMediaType.OpticalDisc: if(_image is IOpticalMediaImage opticalImage) { - OpticalDisc(opticalImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, + OpticalDisc(opticalImage, + _filterId, + _imagePath, + _fi, + _plugins, + imgChecksums, + ref _sidecar, _encoding); } else { - AaruConsole.ErrorWriteLine(Localization.Core. - The_specified_image_says_it_contains_an_optical_media_but_at_the_same_time_says_it_does_not_support_them); + AaruConsole.ErrorWriteLine(Localization.Core + .The_specified_image_says_it_contains_an_optical_media_but_at_the_same_time_says_it_does_not_support_them); AaruConsole.ErrorWriteLine(Localization.Core.Please_open_an_issue_at_Github); } @@ -155,8 +159,8 @@ public sealed partial class Sidecar BlockMedia(blockImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding); else { - AaruConsole.ErrorWriteLine(Localization.Core. - The_specified_image_says_it_contains_a_block_addressable_media_but_at_the_same_time_says_it_does_not_support_them); + AaruConsole.ErrorWriteLine(Localization.Core + .The_specified_image_says_it_contains_a_block_addressable_media_but_at_the_same_time_says_it_does_not_support_them); AaruConsole.ErrorWriteLine(Localization.Core.Please_open_an_issue_at_Github); } @@ -165,13 +169,19 @@ public sealed partial class Sidecar case MetadataMediaType.LinearMedia: if(_image is IByteAddressableImage byteAddressableImage) { - LinearMedia(byteAddressableImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, + LinearMedia(byteAddressableImage, + _filterId, + _imagePath, + _fi, + _plugins, + imgChecksums, + ref _sidecar, _encoding); } else { - AaruConsole.ErrorWriteLine(Localization.Core. - The_specified_image_says_it_contains_a_byte_addressable_media_but_at_the_same_time_says_it_does_not_support_them); + AaruConsole.ErrorWriteLine(Localization.Core + .The_specified_image_says_it_contains_a_byte_addressable_media_but_at_the_same_time_says_it_does_not_support_them); AaruConsole.ErrorWriteLine(Localization.Core.Please_open_an_issue_at_Github); } diff --git a/Aaru.Core/Spectre.cs b/Aaru.Core/Spectre.cs index 66b1903a8..8f85a174d 100644 --- a/Aaru.Core/Spectre.cs +++ b/Aaru.Core/Spectre.cs @@ -8,9 +8,9 @@ public static class Spectre { /// Initializes a progress bar with a single spinner /// Action to execute in the progress bar - public static void ProgressSingleSpinner(Action action) => AnsiConsole.Progress(). - AutoClear(true). - HideCompleted(true). - Columns(new TaskDescriptionColumn(), new SpinnerColumn()). - Start(action); + public static void ProgressSingleSpinner(Action action) => AnsiConsole.Progress() + .AutoClear(true) + .HideCompleted(true) + .Columns(new TaskDescriptionColumn(), new SpinnerColumn()) + .Start(action); } \ No newline at end of file diff --git a/Aaru.Core/Statistics.cs b/Aaru.Core/Statistics.cs index e13c6cca1..50833db95 100644 --- a/Aaru.Core/Statistics.cs +++ b/Aaru.Core/Statistics.cs @@ -67,8 +67,7 @@ public static class Statistics { using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); - if(Settings.Settings.Current.Stats == null) - return; + if(Settings.Settings.Current.Stats == null) return; ctx.OperatingSystems.Add(new OperatingSystem { @@ -109,8 +108,7 @@ public static class Statistics AaruConsole.WriteException(ex); } - if(Settings.Settings.Current.Stats is { ShareStats: true }) - SubmitStats(); + if(Settings.Settings.Current.Stats is { ShareStats: true }) SubmitStats(); } /// Submits statistics to Aaru.Server @@ -122,8 +120,7 @@ public static class Statistics try { - if(_submitStatsLock) - return; + if(_submitStatsLock) return; _submitStatsLock = true; @@ -160,9 +157,9 @@ public static class Statistics { dto.Filesystems = new List(); - foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { dto.Filesystems.Add(new NameValueStats { @@ -190,9 +187,9 @@ public static class Statistics { dto.MediaFormats = new List(); - foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { dto.MediaFormats.Add(new NameValueStats { @@ -279,14 +276,14 @@ public static class Statistics { dto.OperatingSystems = new List(); - foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string osVersion in ctx.OperatingSystems. - Where(c => !c.Synchronized && c.Name == osName). - Select(c => c.Version). - Distinct()) + foreach(string osVersion in ctx.OperatingSystems + .Where(c => !c.Synchronized && c.Name == osName) + .Select(c => c.Version) + .Distinct()) { dto.OperatingSystems.Add(new OsStats { @@ -304,15 +301,15 @@ public static class Statistics { dto.RemoteApplications = new List(); - foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string remoteAppVersion in ctx.RemoteApplications. - Where(c => !c.Synchronized && - c.Name == remoteAppName). - Select(c => c.Version). - Distinct()) + foreach(string remoteAppVersion in ctx.RemoteApplications + .Where(c => !c.Synchronized && + c.Name == remoteAppName) + .Select(c => c.Version) + .Distinct()) { dto.RemoteApplications.Add(new OsStats { @@ -330,9 +327,9 @@ public static class Statistics { dto.RemoteArchitectures = new List(); - foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { dto.RemoteArchitectures.Add(new NameValueStats { @@ -346,14 +343,14 @@ public static class Statistics { dto.RemoteOperatingSystems = new List(); - foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string remoteOsVersion in ctx.RemoteOperatingSystems. - Where(c => !c.Synchronized && c.Name == remoteOsName). - Select(c => c.Version). - Distinct()) + foreach(string remoteOsVersion in ctx.RemoteOperatingSystems + .Where(c => !c.Synchronized && c.Name == remoteOsName) + .Select(c => c.Version) + .Distinct()) { dto.RemoteOperatingSystems.Add(new OsStats { @@ -367,11 +364,11 @@ public static class Statistics } } - #if DEBUG +#if DEBUG System.Console.WriteLine(Localization.Core.Uploading_statistics); - #else - Aaru.Console.AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Uploading_statistics); - #endif +#else + Aaru.Console.AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Uploading_statistics); +#endif string json = JsonSerializer.Serialize(dto, typeof(StatsDto), StatsDtoContext.Default); byte[] jsonBytes = Encoding.UTF8.GetBytes(json); @@ -389,8 +386,7 @@ public static class Statistics reqStream.Close(); WebResponse response = request.GetResponse(); - if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK) - return; + if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK) return; Stream data = response.GetResponseStream(); var reader = new StreamReader(data ?? throw new InvalidOperationException()); @@ -399,8 +395,7 @@ public static class Statistics data.Close(); response.Close(); - if(result != "ok") - return; + if(result != "ok") return; if(ctx.Commands.Any(c => !c.Synchronized)) { @@ -421,9 +416,9 @@ public static class Statistics if(ctx.Filesystems.Any(c => !c.Synchronized)) { - foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { Filesystem existing = ctx.Filesystems.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? @@ -460,9 +455,9 @@ public static class Statistics if(ctx.MediaFormats.Any(c => !c.Synchronized)) { - foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { MediaFormat existing = ctx.MediaFormats.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? @@ -540,8 +535,7 @@ public static class Statistics c.Real)); } - if(!ctx.Medias.Any(c => !c.Synchronized && c.Type == media && !c.Real)) - continue; + if(!ctx.Medias.Any(c => !c.Synchronized && c.Type == media && !c.Real)) continue; { Database.Models.Media existing = @@ -576,14 +570,14 @@ public static class Statistics if(ctx.OperatingSystems.Any(c => !c.Synchronized)) { - foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string osVersion in ctx.OperatingSystems. - Where(c => !c.Synchronized && c.Name == osName). - Select(c => c.Version). - Distinct()) + foreach(string osVersion in ctx.OperatingSystems + .Where(c => !c.Synchronized && c.Name == osName) + .Select(c => c.Version) + .Distinct()) { OperatingSystem existing = ctx.OperatingSystems.FirstOrDefault(c => c.Synchronized && @@ -612,15 +606,15 @@ public static class Statistics if(ctx.RemoteApplications.Any(c => !c.Synchronized)) { - foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string remoteAppVersion in ctx.RemoteApplications. - Where(c => !c.Synchronized && - c.Name == remoteAppName). - Select(c => c.Version). - Distinct()) + foreach(string remoteAppVersion in ctx.RemoteApplications + .Where(c => !c.Synchronized && + c.Name == remoteAppName) + .Select(c => c.Version) + .Distinct()) { RemoteApplication existing = ctx.RemoteApplications.FirstOrDefault(c => c.Synchronized && @@ -649,9 +643,9 @@ public static class Statistics if(ctx.RemoteArchitectures.Any(c => !c.Synchronized)) { - foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { RemoteArchitecture existing = ctx.RemoteArchitectures.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? @@ -671,14 +665,14 @@ public static class Statistics } } - foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name). - Distinct()) + foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized) + .Select(c => c.Name) + .Distinct()) { - foreach(string remoteOsVersion in ctx.RemoteOperatingSystems. - Where(c => !c.Synchronized && c.Name == remoteOsName). - Select(c => c.Version). - Distinct()) + foreach(string remoteOsVersion in ctx.RemoteOperatingSystems + .Where(c => !c.Synchronized && c.Name == remoteOsName) + .Select(c => c.Version) + .Distinct()) { RemoteOperatingSystem existing = ctx.RemoteOperatingSystems.FirstOrDefault(c => c.Synchronized && @@ -720,12 +714,11 @@ public static class Statistics // ReSharper disable once RedundantCatchClause catch { - #if DEBUG +#if DEBUG _submitStatsLock = false; - if(Debugger.IsAttached) - throw; - #endif + if(Debugger.IsAttached) throw; +#endif } _submitStatsLock = false; @@ -738,11 +731,9 @@ public static class Statistics /// Command public static void AddCommand(string command) { - if(string.IsNullOrWhiteSpace(command)) - return; + if(string.IsNullOrWhiteSpace(command)) return; - if(Settings.Settings.Current.Stats is not { DeviceStats: true }) - return; + if(Settings.Settings.Current.Stats is not { DeviceStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -768,11 +759,9 @@ public static class Statistics /// Filesystem name public static void AddFilesystem(string filesystem) { - if(string.IsNullOrWhiteSpace(filesystem)) - return; + if(string.IsNullOrWhiteSpace(filesystem)) return; - if(Settings.Settings.Current.Stats is not { FilesystemStats: true }) - return; + if(Settings.Settings.Current.Stats is not { FilesystemStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -798,11 +787,9 @@ public static class Statistics /// Partition scheme name internal static void AddPartition(string partition) { - if(string.IsNullOrWhiteSpace(partition)) - return; + if(string.IsNullOrWhiteSpace(partition)) return; - if(Settings.Settings.Current.Stats is not { PartitionStats: true }) - return; + if(Settings.Settings.Current.Stats is not { PartitionStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -828,11 +815,9 @@ public static class Statistics /// Filter name public static void AddFilter(string filter) { - if(string.IsNullOrWhiteSpace(filter)) - return; + if(string.IsNullOrWhiteSpace(filter)) return; - if(Settings.Settings.Current.Stats is not { FilterStats: true }) - return; + if(Settings.Settings.Current.Stats is not { FilterStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -858,11 +843,9 @@ public static class Statistics /// Media image name public static void AddMediaFormat(string format) { - if(string.IsNullOrWhiteSpace(format)) - return; + if(string.IsNullOrWhiteSpace(format)) return; - if(Settings.Settings.Current.Stats is not { MediaImageStats: true }) - return; + if(Settings.Settings.Current.Stats is not { MediaImageStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -888,8 +871,7 @@ public static class Statistics /// Device public static void AddDevice(Device dev) { - if(Settings.Settings.Current.Stats is not { DeviceStats: true }) - return; + if(Settings.Settings.Current.Stats is not { DeviceStats: true }) return; string deviceBus; @@ -933,8 +915,7 @@ public static class Statistics /// Set if media was found on a real device, otherwise found on a media image public static void AddMedia(MediaType type, bool real) { - if(Settings.Settings.Current.Stats is not { MediaStats: true }) - return; + if(Settings.Settings.Current.Stats is not { MediaStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -961,8 +942,7 @@ public static class Statistics public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem, string serverOperatingSystemVersion, string serverArchitecture) { - if(Settings.Settings.Current.Stats is not { MediaStats: true }) - return; + if(Settings.Settings.Current.Stats is not { MediaStats: true }) return; using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); diff --git a/Aaru.Database/Context.cs b/Aaru.Database/Context.cs index 7e5562fcd..8f141e79d 100644 --- a/Aaru.Database/Context.cs +++ b/Aaru.Database/Context.cs @@ -108,8 +108,8 @@ public sealed class AaruContext : DbContext { var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseLazyLoadingProxies(). - UseSqlite(!pooling ? $"Data Source={dbPath};Pooling=False" : $"Data Source={dbPath}"); + optionsBuilder.UseLazyLoadingProxies() + .UseSqlite(!pooling ? $"Data Source={dbPath};Pooling=False" : $"Data Source={dbPath}"); return new AaruContext(optionsBuilder.Options); } @@ -120,210 +120,217 @@ public sealed class AaruContext : DbContext base.OnModelCreating(modelBuilder); modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", - b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities"). - WithMany(). - HasForeignKey("ReadCapabilitiesId"). - OnDelete(DeleteBehavior.SetNull)); + b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities") + .WithMany() + .HasForeignKey("ReadCapabilitiesId") + .OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", - b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null). - WithMany("BlockDescriptors"). - HasForeignKey("ScsiModeId"). - OnDelete(DeleteBehavior.Cascade)); + b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null) + .WithMany("BlockDescriptors") + .HasForeignKey("ScsiModeId") + .OnDelete(DeleteBehavior.Cascade)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", - b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null). - WithMany("DensityCodes"). - HasForeignKey("SscSupportedMediaId"). - OnDelete(DeleteBehavior.Cascade)); + b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null) + .WithMany("DensityCodes") + .HasForeignKey("SscSupportedMediaId") + .OnDelete(DeleteBehavior.Cascade)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", - b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features"). - WithMany(). - HasForeignKey("FeaturesId"). - OnDelete(DeleteBehavior.SetNull)); + b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features") + .WithMany() + .HasForeignKey("FeaturesId") + .OnDelete(DeleteBehavior.SetNull)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense"). - WithMany(). - HasForeignKey("ModeSenseId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense") + .WithMany() + .HasForeignKey("ModeSenseId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Mmc", "MultiMediaDevice"). - WithMany(). - HasForeignKey("MultiMediaDeviceId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Mmc", "MultiMediaDevice") + .WithMany() + .HasForeignKey("MultiMediaDeviceId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities"). - WithMany(). - HasForeignKey("ReadCapabilitiesId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities") + .WithMany() + .HasForeignKey("ReadCapabilitiesId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Ssc", "SequentialDevice"). - WithMany(). - HasForeignKey("SequentialDeviceId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.Ssc", "SequentialDevice") + .WithMany() + .HasForeignKey("SequentialDeviceId") + .OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.ScsiPage", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null). - WithMany("EVPDPages"). - HasForeignKey("ScsiId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.ScsiPage", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null) + .WithMany("EVPDPages") + .HasForeignKey("ScsiId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null). - WithMany("ModePages"). - HasForeignKey("ScsiModeId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null) + .WithMany("ModePages") + .HasForeignKey("ScsiModeId") + .OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.SscSupportedMedia", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null). - WithMany("SupportedMediaTypes"). - HasForeignKey("SscId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.SscSupportedMedia", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null) + .WithMany("SupportedMediaTypes") + .HasForeignKey("SscId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null). - WithMany("SupportedMediaTypes"). - HasForeignKey("TestedSequentialMediaId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null) + .WithMany("SupportedMediaTypes") + .HasForeignKey("TestedSequentialMediaId") + .OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.SupportedDensity", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null). - WithMany("SupportedDensities"). - HasForeignKey("SscId"). - OnDelete(DeleteBehavior.Cascade); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.SupportedDensity", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null) + .WithMany("SupportedDensities") + .HasForeignKey("SscId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null). - WithMany("SupportedDensities"). - HasForeignKey("TestedSequentialMediaId"). - OnDelete(DeleteBehavior.Cascade); - }); + b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null) + .WithMany("SupportedDensities") + .HasForeignKey("TestedSequentialMediaId") + .OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedMedia", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ata", null). - WithMany("RemovableMedias"). - HasForeignKey("AtaId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedMedia", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Ata", null) + .WithMany("RemovableMedias") + .HasForeignKey("AtaId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CHS"). - WithMany(). - HasForeignKey("CHSId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CHS") + .WithMany() + .HasForeignKey("CHSId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS"). - WithMany(). - HasForeignKey("CurrentCHSId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS") + .WithMany() + .HasForeignKey("CurrentCHSId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Mmc", null). - WithMany("TestedMedia"). - HasForeignKey("MmcId"). - OnDelete(DeleteBehavior.Cascade); + b.HasOne("Aaru.CommonTypes.Metadata.Mmc", null) + .WithMany("TestedMedia") + .HasForeignKey("MmcId") + .OnDelete(DeleteBehavior.Cascade); - b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null). - WithMany("RemovableMedias"). - HasForeignKey("ScsiId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null) + .WithMany("RemovableMedias") + .HasForeignKey("ScsiId") + .OnDelete(DeleteBehavior.SetNull); + }); modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", - b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null). - WithMany("TestedMedia"). - HasForeignKey("SscId"). - OnDelete(DeleteBehavior.SetNull)); + b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null) + .WithMany("TestedMedia") + .HasForeignKey("SscId") + .OnDelete(DeleteBehavior.SetNull)); - modelBuilder.Entity("Aaru.Database.Models.Device", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA"). - WithMany(). - HasForeignKey("ATAId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.Database.Models.Device", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA") + .WithMany() + .HasForeignKey("ATAId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI"). - WithMany(). - HasForeignKey("ATAPIId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI") + .WithMany() + .HasForeignKey("ATAPIId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire"). - WithMany(). - HasForeignKey("FireWireId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire") + .WithMany() + .HasForeignKey("FireWireId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard"). - WithMany(). - HasForeignKey("MultiMediaCardId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard") + .WithMany() + .HasForeignKey("MultiMediaCardId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA"). - WithMany(). - HasForeignKey("PCMCIAId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA") + .WithMany() + .HasForeignKey("PCMCIAId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI"). - WithMany(). - HasForeignKey("SCSIId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI") + .WithMany() + .HasForeignKey("SCSIId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital"). - WithMany(). - HasForeignKey("SecureDigitalId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital") + .WithMany() + .HasForeignKey("SecureDigitalId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB"). - WithMany(). - HasForeignKey("USBId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB") + .WithMany() + .HasForeignKey("USBId") + .OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity("Aaru.Database.Models.Report", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA"). - WithMany(). - HasForeignKey("ATAId"). - OnDelete(DeleteBehavior.SetNull); + modelBuilder.Entity("Aaru.Database.Models.Report", + b => + { + b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA") + .WithMany() + .HasForeignKey("ATAId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI"). - WithMany(). - HasForeignKey("ATAPIId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI") + .WithMany() + .HasForeignKey("ATAPIId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire"). - WithMany(). - HasForeignKey("FireWireId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire") + .WithMany() + .HasForeignKey("FireWireId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard"). - WithMany(). - HasForeignKey("MultiMediaCardId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard") + .WithMany() + .HasForeignKey("MultiMediaCardId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA"). - WithMany(). - HasForeignKey("PCMCIAId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA") + .WithMany() + .HasForeignKey("PCMCIAId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI"). - WithMany(). - HasForeignKey("SCSIId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI") + .WithMany() + .HasForeignKey("SCSIId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital"). - WithMany(). - HasForeignKey("SecureDigitalId"). - OnDelete(DeleteBehavior.SetNull); + b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital") + .WithMany() + .HasForeignKey("SecureDigitalId") + .OnDelete(DeleteBehavior.SetNull); - b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB"). - WithMany(). - HasForeignKey("USBId"). - OnDelete(DeleteBehavior.SetNull); - }); + b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB") + .WithMany() + .HasForeignKey("USBId") + .OnDelete(DeleteBehavior.SetNull); + }); modelBuilder.Entity().HasIndex(b => b.ModifiedWhen); diff --git a/Aaru.Decoders/ATA/Identify.cs b/Aaru.Decoders/ATA/Identify.cs index 7514b4c2f..6bcf32592 100644 --- a/Aaru.Decoders/ATA/Identify.cs +++ b/Aaru.Decoders/ATA/Identify.cs @@ -57,8 +57,7 @@ public static class Identify { public static string Prettify(byte[] IdentifyDeviceResponse) { - if(IdentifyDeviceResponse.Length != 512) - return null; + if(IdentifyDeviceResponse.Length != 512) return null; CommonTypes.Structs.Devices.ATA.Identify.IdentifyDevice? decoded = CommonTypes.Structs.Devices.ATA.Identify.Decode(IdentifyDeviceResponse); @@ -68,8 +67,7 @@ public static class Identify public static string Prettify(CommonTypes.Structs.Devices.ATA.Identify.IdentifyDevice? IdentifyDeviceResponse) { - if(IdentifyDeviceResponse == null) - return null; + if(IdentifyDeviceResponse == null) return null; var sb = new StringBuilder(); @@ -78,8 +76,8 @@ public static class Identify CommonTypes.Structs.Devices.ATA.Identify.IdentifyDevice ATAID = IdentifyDeviceResponse.Value; - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - NonMagnetic)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .NonMagnetic)) { if((ushort)ATAID.GeneralConfiguration != 0x848A) atapi = true; @@ -94,14 +92,11 @@ public static class Identify else sb.AppendLine(Localization.ATA_device); - if(ATAID.Model != "") - sb.AppendFormat(Core.Model_0, ATAID.Model).AppendLine(); + if(ATAID.Model != "") sb.AppendFormat(Core.Model_0, ATAID.Model).AppendLine(); - if(ATAID.FirmwareRevision != "") - sb.AppendFormat(Core.Firmware_revision_0, ATAID.FirmwareRevision).AppendLine(); + if(ATAID.FirmwareRevision != "") sb.AppendFormat(Core.Firmware_revision_0, ATAID.FirmwareRevision).AppendLine(); - if(ATAID.SerialNumber != "") - sb.AppendFormat(Core.Serial_number_0, ATAID.SerialNumber).AppendLine(); + if(ATAID.SerialNumber != "") sb.AppendFormat(Core.Serial_number_0, ATAID.SerialNumber).AppendLine(); if(ATAID.AdditionalPID != "") sb.AppendFormat(Localization.Additional_product_ID_0, ATAID.AdditionalPID).AppendLine(); @@ -114,8 +109,7 @@ public static class Identify if(ATAID.MediaManufacturer != "") sb.AppendFormat(Core.Media_manufacturer_0, ATAID.MediaManufacturer).AppendLine(); - if(ATAID.MediaSerial != "") - sb.AppendFormat(Core.Media_serial_number_0, ATAID.MediaSerial).AppendLine(); + if(ATAID.MediaSerial != "") sb.AppendFormat(Core.Media_serial_number_0, ATAID.MediaSerial).AppendLine(); } if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.WWN)) @@ -138,27 +132,24 @@ public static class Identify { // Obsolete in ATA-2, if present, device supports ATA-1 ata1 |= - ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - FastIDE) || - ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - SlowIDE) || - ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - UltraFastIDE); + ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .FastIDE) || + ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .SlowIDE) || + ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .UltraFastIDE); - ata2 |= ATAID.ExtendedIdentify.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.ExtendedIdentifyBit. - Words64to70Valid); + ata2 |= ATAID.ExtendedIdentify.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.ExtendedIdentifyBit + .Words64to70Valid); - if(!ata1 && !ata2 && !atapi && !cfa) - ata2 = true; + if(!ata1 && !ata2 && !atapi && !cfa) ata2 = true; ata4 |= atapi; ata3 |= cfa; - if(cfa && ata1) - ata1 = false; + if(cfa && ata1) ata1 = false; - if(cfa && ata2) - ata2 = false; + if(cfa && ata2) ata2 = false; ata5 |= ATAID.Signature == 0xA5; } @@ -193,8 +184,7 @@ public static class Identify sb.Append("ATA-2 "); maxatalevel = 2; - if(minatalevel > 2) - minatalevel = 2; + if(minatalevel > 2) minatalevel = 2; } if(ata3) @@ -202,8 +192,7 @@ public static class Identify sb.Append("ATA-3 "); maxatalevel = 3; - if(minatalevel > 3) - minatalevel = 3; + if(minatalevel > 3) minatalevel = 3; } if(ata4) @@ -211,8 +200,7 @@ public static class Identify sb.Append("ATA/ATAPI-4 "); maxatalevel = 4; - if(minatalevel > 4) - minatalevel = 4; + if(minatalevel > 4) minatalevel = 4; } if(ata5) @@ -220,8 +208,7 @@ public static class Identify sb.Append("ATA/ATAPI-5 "); maxatalevel = 5; - if(minatalevel > 5) - minatalevel = 5; + if(minatalevel > 5) minatalevel = 5; } if(ata6) @@ -229,8 +216,7 @@ public static class Identify sb.Append("ATA/ATAPI-6 "); maxatalevel = 6; - if(minatalevel > 6) - minatalevel = 6; + if(minatalevel > 6) minatalevel = 6; } if(ata7) @@ -238,8 +224,7 @@ public static class Identify sb.Append("ATA/ATAPI-7 "); maxatalevel = 7; - if(minatalevel > 7) - minatalevel = 7; + if(minatalevel > 7) minatalevel = 7; } if(acs) @@ -247,8 +232,7 @@ public static class Identify sb.Append("ATA8-ACS "); maxatalevel = 8; - if(minatalevel > 8) - minatalevel = 8; + if(minatalevel > 8) minatalevel = 8; } if(acs2) @@ -256,8 +240,7 @@ public static class Identify sb.Append("ATA8-ACS2 "); maxatalevel = 9; - if(minatalevel > 9) - minatalevel = 9; + if(minatalevel > 9) minatalevel = 9; } if(acs3) @@ -265,8 +248,7 @@ public static class Identify sb.Append("ATA8-ACS3 "); maxatalevel = 10; - if(minatalevel > 10) - minatalevel = 10; + if(minatalevel > 10) minatalevel = 10; } if(acs4) @@ -274,8 +256,7 @@ public static class Identify sb.Append("ATA8-ACS4 "); maxatalevel = 11; - if(minatalevel > 11) - minatalevel = 11; + if(minatalevel > 11) minatalevel = 11; } sb.AppendLine(); @@ -487,11 +468,9 @@ public static class Identify case 0x0: sb.Append(Localization.Parallel_ATA_device); - if((ATAID.TransportMajorVersion & 0x0002) == 0x0002) - sb.Append("ATA/ATAPI-7 "); + if((ATAID.TransportMajorVersion & 0x0002) == 0x0002) sb.Append("ATA/ATAPI-7 "); - if((ATAID.TransportMajorVersion & 0x0001) == 0x0001) - sb.Append("ATA8-APT "); + if((ATAID.TransportMajorVersion & 0x0001) == 0x0001) sb.Append("ATA8-APT "); sb.AppendLine(); @@ -499,26 +478,19 @@ public static class Identify case 0x1: sb.Append(Localization.Serial_ATA_device); - if((ATAID.TransportMajorVersion & 0x0001) == 0x0001) - sb.Append("ATA8-AST "); + if((ATAID.TransportMajorVersion & 0x0001) == 0x0001) sb.Append("ATA8-AST "); - if((ATAID.TransportMajorVersion & 0x0002) == 0x0002) - sb.Append("SATA 1.0a "); + if((ATAID.TransportMajorVersion & 0x0002) == 0x0002) sb.Append("SATA 1.0a "); - if((ATAID.TransportMajorVersion & 0x0004) == 0x0004) - sb.Append("SATA II Extensions "); + if((ATAID.TransportMajorVersion & 0x0004) == 0x0004) sb.Append("SATA II Extensions "); - if((ATAID.TransportMajorVersion & 0x0008) == 0x0008) - sb.Append("SATA 2.5 "); + if((ATAID.TransportMajorVersion & 0x0008) == 0x0008) sb.Append("SATA 2.5 "); - if((ATAID.TransportMajorVersion & 0x0010) == 0x0010) - sb.Append("SATA 2.6 "); + if((ATAID.TransportMajorVersion & 0x0010) == 0x0010) sb.Append("SATA 2.6 "); - if((ATAID.TransportMajorVersion & 0x0020) == 0x0020) - sb.Append("SATA 3.0 "); + if((ATAID.TransportMajorVersion & 0x0020) == 0x0020) sb.Append("SATA 3.0 "); - if((ATAID.TransportMajorVersion & 0x0040) == 0x0040) - sb.Append("SATA 3.1 "); + if((ATAID.TransportMajorVersion & 0x0040) == 0x0040) sb.Append("SATA 3.1 "); sb.AppendLine(); @@ -528,8 +500,8 @@ public static class Identify break; default: - sb.AppendFormat(Localization.Unknown_transport_type_0, (ATAID.TransportMajorVersion & 0xF000) >> 12). - AppendLine(); + sb.AppendFormat(Localization.Unknown_transport_type_0, (ATAID.TransportMajorVersion & 0xF000) >> 12) + .AppendLine(); break; } @@ -625,8 +597,8 @@ public static class Identify break; default: sb.AppendFormat(Localization.ATAPI_Unknown_device_type_field_value_0, - ((ushort)ATAID.GeneralConfiguration & 0x1F00) >> 8). - AppendLine(); + ((ushort)ATAID.GeneralConfiguration & 0x1F00) >> 8) + .AppendLine(); break; } @@ -648,8 +620,8 @@ public static class Identify break; default: sb.AppendFormat(Localization.Unknown_ATAPI_DRQ_behaviour_code_0, - ((ushort)ATAID.GeneralConfiguration & 0x60) >> 5). - AppendLine(); + ((ushort)ATAID.GeneralConfiguration & 0x60) >> 5) + .AppendLine(); break; } @@ -667,8 +639,8 @@ public static class Identify break; default: sb.AppendFormat(Localization.Unknown_ATAPI_packet_size_code_0, - (ushort)ATAID.GeneralConfiguration & 0x03). - AppendLine(); + (ushort)ATAID.GeneralConfiguration & 0x03) + .AppendLine(); break; } @@ -677,74 +649,74 @@ public static class Identify { if(minatalevel >= 5) { - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - IncompleteResponse)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .IncompleteResponse)) sb.AppendLine(Localization.Incomplete_identify_response); } - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - NonMagnetic)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .NonMagnetic)) sb.AppendLine(Localization.Device_uses_non_magnetic_media); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - Removable)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .Removable)) sb.AppendLine(Localization.Device_is_removable); if(minatalevel <= 5) { - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - Fixed)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .Fixed)) sb.AppendLine(Localization.Device_is_fixed); } if(ata1) { - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - SlowIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .SlowIDE)) sb.AppendLine(Localization.Device_transfer_rate_less_than_5_Mbs); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - FastIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .FastIDE)) sb.AppendLine(Localization.Device_transfer_rate_is_more_5_Mbs_less_10_Mbs); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - UltraFastIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .UltraFastIDE)) sb.AppendLine(Localization.Device_transfer_rate_more_than_10_Mbs); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - SoftSector)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .SoftSector)) sb.AppendLine(Localization.Device_is_soft_sectored); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - HardSector)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .HardSector)) sb.AppendLine(Localization.Device_is_hard_sectored); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - NotMFM)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .NotMFM)) sb.AppendLine(Localization.Device_is_not_MFM_encoded); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - FormatGapReq)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .FormatGapReq)) sb.AppendLine(Localization.Format_speed_tolerance_gap_is_required); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - TrackOffset)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .TrackOffset)) sb.AppendLine(Localization.Track_offset_option_is_available); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - DataStrobeOffset)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .DataStrobeOffset)) sb.AppendLine(Localization.Data_strobe_offset_option_is_available); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - RotationalSpeedTolerance)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .RotationalSpeedTolerance)) sb.AppendLine(Localization.Rotational_speed_tolerance_is_higher_than_0_5_percent); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - SpindleControl)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .SpindleControl)) sb.AppendLine(Localization.Spindle_motor_control_is_implemented); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. - HighHeadSwitch)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit + .HighHeadSwitch)) sb.AppendLine(Localization.Head_switch_time_is_bigger_than_15_µs); } } @@ -794,26 +766,28 @@ public static class Identify (ATAID.LogicalAlignment & 0x4000) == 0x4000) { sb.AppendFormat(Localization.Logical_sector_starts_at_offset_0_from_physical_sector, - ATAID.LogicalAlignment & 0x3FFF). - AppendLine(); + ATAID.LogicalAlignment & 0x3FFF) + .AppendLine(); } if(minatalevel <= 5) { if(ATAID.CurrentCylinders > 0 && ATAID is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 }) { - sb.AppendFormat(Localization.Cylinders_0_max_1_current, ATAID.Cylinders, ATAID.CurrentCylinders). - AppendLine(); + sb.AppendFormat(Localization.Cylinders_0_max_1_current, ATAID.Cylinders, ATAID.CurrentCylinders) + .AppendLine(); sb.AppendFormat(Localization.Heads_0_max_1_current, ATAID.Heads, ATAID.CurrentHeads).AppendLine(); - sb.AppendFormat(Localization.Sectors_per_track_0_max_1_current, ATAID.SectorsPerTrack, - ATAID.CurrentSectorsPerTrack). - AppendLine(); + sb.AppendFormat(Localization.Sectors_per_track_0_max_1_current, + ATAID.SectorsPerTrack, + ATAID.CurrentSectorsPerTrack) + .AppendLine(); sb.AppendFormat(Localization.Sectors_addressable_in_CHS_mode_0_max_1_current, - ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack, ATAID.CurrentSectors). - AppendLine(); + ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack, + ATAID.CurrentSectors) + .AppendLine(); } else { @@ -822,8 +796,8 @@ public static class Identify sb.AppendFormat(Localization.Sectors_per_track_0, ATAID.SectorsPerTrack).AppendLine(); sb.AppendFormat(Localization.Sectors_addressable_in_CHS_mode_0, - ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack). - AppendLine(); + ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack) + .AppendLine(); } } @@ -840,8 +814,8 @@ public static class Identify sb.AppendFormat(Localization.Device_size_in_CHS_mode_0_bytes_1_Mb_2_MiB, (ulong)ATAID.CurrentSectors * logicalSectorSize, (ulong)ATAID.CurrentSectors * logicalSectorSize / 1000 / 1000, - (ulong)ATAID.CurrentSectors * 512 / 1024 / 1024). - AppendLine(); + (ulong)ATAID.CurrentSectors * 512 / 1024 / 1024) + .AppendLine(); } else { @@ -850,8 +824,8 @@ public static class Identify sb.AppendFormat(Localization.Device_size_in_CHS_mode_0_bytes_1_Mb_2_MiB, currentSectors * logicalSectorSize, currentSectors * logicalSectorSize / 1000 / 1000, - currentSectors * 512 / 1024 / 1024). - AppendLine(); + currentSectors * 512 / 1024 / 1024) + .AppendLine(); } } @@ -863,24 +837,24 @@ public static class Identify sb.AppendFormat(Localization.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(); + (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024 / 1024) + .AppendLine(); break; case > 1000: sb.AppendFormat(Localization.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(); + (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024) + .AppendLine(); break; default: sb.AppendFormat(Localization.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(); + (ulong)ATAID.LBASectors * 512 / 1024 / 1024) + .AppendLine(); break; } @@ -896,24 +870,24 @@ public static class Identify sb.AppendFormat(Localization.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(); + ATAID.ExtendedUserSectors * logicalSectorSize / 1024 / 1024 / 1024 / 1024) + .AppendLine(); break; case > 1000: sb.AppendFormat(Localization.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(); + ATAID.ExtendedUserSectors * logicalSectorSize / 1024 / 1024 / 1024) + .AppendLine(); break; default: sb.AppendFormat(Localization.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(); + ATAID.ExtendedUserSectors * logicalSectorSize / 1024 / 1024) + .AppendLine(); break; } @@ -926,24 +900,24 @@ public static class Identify sb.AppendFormat(Localization.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(); + ATAID.LBA48Sectors * logicalSectorSize / 1024 / 1024 / 1024 / 1024) + .AppendLine(); break; case > 1000: sb.AppendFormat(Localization.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(); + ATAID.LBA48Sectors * logicalSectorSize / 1024 / 1024 / 1024) + .AppendLine(); break; default: sb.AppendFormat(Localization.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(); + ATAID.LBA48Sectors * logicalSectorSize / 1024 / 1024) + .AppendLine(); break; } @@ -952,8 +926,7 @@ public static class Identify if(ata1 || cfa) { - if(cfa) - sb.AppendFormat(Localization._0_sectors_in_card, ATAID.SectorsPerCard).AppendLine(); + if(cfa) sb.AppendFormat(Localization._0_sectors_in_card, ATAID.SectorsPerCard).AppendLine(); if(ATAID.UnformattedBPT > 0) sb.AppendFormat(Localization._0_bytes_per_unformatted_track, ATAID.UnformattedBPT).AppendLine(); @@ -968,30 +941,30 @@ public static class Identify switch(ATAID.SpecificConfiguration) { case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum.RequiresSetIncompleteResponse: - sb.AppendLine(Localization. - Device_requires_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_incomplete); + sb.AppendLine(Localization + .Device_requires_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_incomplete); break; case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum.RequiresSetCompleteResponse: - sb.AppendLine(Localization. - Device_requires_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_complete); + sb.AppendLine(Localization + .Device_requires_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_complete); break; - case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum. - NotRequiresSetIncompleteResponse: - sb.AppendLine(Localization. - Device_does_not_require_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_incomplete); + case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum + .NotRequiresSetIncompleteResponse: + sb.AppendLine(Localization + .Device_does_not_require_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_incomplete); break; case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum.NotRequiresSetCompleteResponse: - sb.AppendLine(Localization. - Device_does_not_require_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_complete); + sb.AppendLine(Localization + .Device_does_not_require_SET_FEATURES_to_spin_up_and_IDENTIFY_DEVICE_response_is_complete); break; default: sb.AppendFormat(Localization.Unknown_device_specific_configuration_0, - (ushort)ATAID.SpecificConfiguration). - AppendLine(); + (ushort)ATAID.SpecificConfiguration) + .AppendLine(); break; } @@ -1007,26 +980,27 @@ public static class Identify { case 1: sb.AppendFormat(Localization._0_KiB_of_single_ported_single_sector_buffer, - ATAID.BufferSize * 512 / 1024). - AppendLine(); + ATAID.BufferSize * 512 / 1024) + .AppendLine(); break; case 2: sb.AppendFormat(Localization._0_KiB_of_dual_ported_multi_sector_buffer, - ATAID.BufferSize * 512 / 1024). - AppendLine(); + ATAID.BufferSize * 512 / 1024) + .AppendLine(); break; case 3: sb.AppendFormat(Localization._0_KiB_of_dual_ported_multi_sector_buffer_with_read_caching, - ATAID.BufferSize * 512 / 1024). - AppendLine(); + ATAID.BufferSize * 512 / 1024) + .AppendLine(); break; default: - sb.AppendFormat(Localization._0_KiB_of_unknown_type_1_buffer, ATAID.BufferSize * 512 / 1024, - ATAID.BufferType). - AppendLine(); + sb.AppendFormat(Localization._0_KiB_of_unknown_type_1_buffer, + ATAID.BufferSize * 512 / 1024, + ATAID.BufferType) + .AppendLine(); break; } @@ -1044,9 +1018,9 @@ public static class Identify if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY)) { - sb.AppendLine(). - Append(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. - CanDisableIORDY) + sb.AppendLine() + .Append(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit + .CanDisableIORDY) ? Localization.IORDY_is_supported_and_can_be_disabled : Localization.IORDY_is_supported); } @@ -1057,32 +1031,32 @@ public static class Identify if(ATAID.Capabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit2.MustBeSet) && !ATAID.Capabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit2.MustBeClear)) { - if(ATAID.Capabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit2. - SpecificStandbyTimer)) + if(ATAID.Capabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit2 + .SpecificStandbyTimer)) sb.AppendLine().Append(Localization.Device_indicates_a_specific_minimum_standby_timer_value); } if(ATAID.Capabilities3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit3.MultipleValid)) { - sb.AppendLine(). - AppendFormat(Localization.A_maximum_of_0_sectors_can_be_transferred_per_interrupt_on_READ_WRITE_MULTIPLE, + sb.AppendLine() + .AppendFormat(Localization.A_maximum_of_0_sectors_can_be_transferred_per_interrupt_on_READ_WRITE_MULTIPLE, ATAID.MultipleSectorNumber); - sb.AppendLine(). - AppendFormat(Localization.Device_supports_setting_a_maximum_of_0_sectors, ATAID.MultipleMaxSectors); + sb.AppendLine() + .AppendFormat(Localization.Device_supports_setting_a_maximum_of_0_sectors, ATAID.MultipleMaxSectors); } if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.PhysicalAlignment1) || ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.PhysicalAlignment0)) { - sb.AppendLine(). - AppendFormat(Localization.Long_Physical_Alignment_setting_is_0, (ushort)ATAID.Capabilities & 0x03); + sb.AppendLine() + .AppendFormat(Localization.Long_Physical_Alignment_setting_is_0, (ushort)ATAID.Capabilities & 0x03); } if(ata1) { - if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit. - TrustedComputing)) + if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit + .TrustedComputing)) sb.AppendLine().Append(Localization.Device_supports_doubleword_IO); } @@ -1097,8 +1071,8 @@ public static class Identify if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.OverlapOperation)) sb.AppendLine().Append(Localization.ATAPI_device_supports_overlapped_operations); - if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. - RequiresATASoftReset)) + if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit + .RequiresATASoftReset)) sb.AppendLine().Append(Localization.ATAPI_device_requires_ATA_software_reset); } @@ -1110,29 +1084,21 @@ public static class Identify sb.AppendLine().Append(Localization.Advanced_PIO); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode0)) - sb.Append("PIO0 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode0)) sb.Append("PIO0 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode1)) - sb.Append("PIO1 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode1)) sb.Append("PIO1 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode2)) - sb.Append("PIO2 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode2)) sb.Append("PIO2 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode3)) - sb.Append("PIO3 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode3)) sb.Append("PIO3 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode4)) - sb.Append("PIO4 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode4)) sb.Append("PIO4 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode5)) - sb.Append("PIO5 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode5)) sb.Append("PIO5 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode6)) - sb.Append("PIO6 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode6)) sb.Append("PIO6 "); - if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode7)) - sb.Append("PIO7 "); + if(ATAID.APIOSupported.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode7)) sb.Append("PIO7 "); if(minatalevel <= 3 && !atapi) { @@ -1337,22 +1303,23 @@ public static class Identify if(ATAID.MinMDMACycleTime != 0 && ATAID.RecMDMACycleTime != 0) { - sb.AppendLine(). - AppendFormat(Localization.At_minimum_0_ns_transfer_cycle_time_per_word_in_MDMA_1_ns_recommended, - ATAID.MinMDMACycleTime, ATAID.RecMDMACycleTime); + sb.AppendLine() + .AppendFormat(Localization.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(Localization.At_minimum_0_ns_transfer_cycle_time_per_word_in_PIO_without_flow_control, + sb.AppendLine() + .AppendFormat(Localization.At_minimum_0_ns_transfer_cycle_time_per_word_in_PIO_without_flow_control, ATAID.MinPIOCycleTimeNoFlow); } if(ATAID.MinPIOCycleTimeFlow != 0) { - sb.AppendLine(). - AppendFormat(Localization.At_minimum_0_ns_transfer_cycle_time_per_word_in_PIO_with_IORDY_flow_control, + sb.AppendLine() + .AppendFormat(Localization.At_minimum_0_ns_transfer_cycle_time_per_word_in_PIO_with_IORDY_flow_control, ATAID.MinPIOCycleTimeFlow); } @@ -1363,15 +1330,15 @@ public static class Identify { if(ATAID.PacketBusRelease != 0) { - sb.AppendLine(). - AppendFormat(Localization._0_ns_typical_to_release_bus_from_receipt_of_PACKET, + sb.AppendLine() + .AppendFormat(Localization._0_ns_typical_to_release_bus_from_receipt_of_PACKET, ATAID.PacketBusRelease); } if(ATAID.ServiceBusyClear != 0) { - sb.AppendLine(). - AppendFormat(Localization._0_ns_typical_to_clear_BSY_bit_from_receipt_of_SERVICE, + sb.AppendLine() + .AppendFormat(Localization._0_ns_typical_to_clear_BSY_bit_from_receipt_of_SERVICE, ATAID.ServiceBusyClear); } } @@ -1380,83 +1347,83 @@ public static class Identify { if(!ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit.Clear)) { - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - Gen1Speed)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .Gen1Speed)) sb.AppendLine().Append(Localization.SATA_1_5Gbs_is_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - Gen2Speed)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .Gen2Speed)) sb.AppendLine().Append(Localization.SATA_3_0Gbs_is_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - Gen3Speed)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .Gen3Speed)) sb.AppendLine().Append(Localization.SATA_6_0Gbs_is_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - PowerReceipt)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .PowerReceipt)) { - sb.AppendLine(). - Append(Localization.Receipt_of_host_initiated_power_management_requests_is_supported); + sb.AppendLine() + .Append(Localization.Receipt_of_host_initiated_power_management_requests_is_supported); } - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - PHYEventCounter)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .PHYEventCounter)) sb.AppendLine().Append(Localization.PHY_Event_counters_are_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - HostSlumbTrans)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .HostSlumbTrans)) { - sb.AppendLine(). - Append(Localization.Supports_host_automatic_partial_to_slumber_transitions_is_supported); + sb.AppendLine() + .Append(Localization.Supports_host_automatic_partial_to_slumber_transitions_is_supported); } - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - DevSlumbTrans)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .DevSlumbTrans)) { - sb.AppendLine(). - Append(Localization.Supports_device_automatic_partial_to_slumber_transitions_is_supported); + sb.AppendLine() + .Append(Localization.Supports_device_automatic_partial_to_slumber_transitions_is_supported); } if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit.NCQ)) { sb.AppendLine().Append(Localization.NCQ_is_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - NCQPriority)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .NCQPriority)) sb.AppendLine().Append(Localization.NCQ_priority_is_supported); - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - UnloadNCQ)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .UnloadNCQ)) sb.AppendLine().Append(Localization.Unload_is_supported_with_outstanding_NCQ_commands); } } if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2.Clear)) { - if(!ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - Clear) && + if(!ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .Clear) && ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit.NCQ)) { - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - NCQMgmt)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2 + .NCQMgmt)) sb.AppendLine().Append(Localization.NCQ_queue_management_is_supported); - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - NCQStream)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2 + .NCQStream)) sb.AppendLine().Append(Localization.NCQ_streaming_is_supported); } if(atapi) { - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - HostEnvDetect)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2 + .HostEnvDetect)) sb.AppendLine().Append(Localization.ATAPI_device_supports_host_environment_detection); - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - DevAttSlimline)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2 + .DevAttSlimline)) { - sb.AppendLine(). - Append(Localization.ATAPI_device_supports_attention_on_slimline_connected_devices); + sb.AppendLine() + .Append(Localization.ATAPI_device_supports_attention_on_slimline_connected_devices); } } @@ -1466,8 +1433,8 @@ public static class Identify if(ATAID.InterseekDelay != 0x0000 && ATAID.InterseekDelay != 0xFFFF) { - sb.AppendLine(). - AppendFormat(Localization._0_microseconds_of_interseek_delay_for_ISO_7779_acoustic_testing, + sb.AppendLine() + .AppendFormat(Localization._0_microseconds_of_interseek_delay_for_ISO_7779_acoustic_testing, ATAID.InterseekDelay); } @@ -1496,8 +1463,8 @@ public static class Identify break; default: - sb.AppendLine(). - AppendFormat(Localization.Device_nominal_size_field_value_0_is_unknown, ATAID.DeviceFormFactor); + sb.AppendLine() + .AppendFormat(Localization.Device_nominal_size_field_value_0_is_unknown, ATAID.DeviceFormFactor); break; } @@ -1521,8 +1488,8 @@ public static class Identify if((ATAID.CFAPowerMode & 0x1000) == 0x1000) sb.AppendLine().Append(Localization.CompactFlash_power_mode_1_is_disabled); - sb.AppendLine(). - AppendFormat(Localization.CompactFlash_device_uses_a_maximum_of_0_mA, ATAID.CFAPowerMode & 0x0FFF); + sb.AppendLine() + .AppendFormat(Localization.CompactFlash_device_uses_a_maximum_of_0_mA, ATAID.CFAPowerMode & 0x0FFF); } } @@ -1532,109 +1499,109 @@ public static class Identify if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Nop)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Nop) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Nop) ? Localization.NOP_is_supported_and_enabled : Localization.NOP_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.ReadBuffer)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.ReadBuffer) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.ReadBuffer) ? Localization.READ_BUFFER_is_supported_and_enabled : Localization.READ_BUFFER_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.WriteBuffer)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - WriteBuffer) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit + .WriteBuffer) ? Localization.WRITE_BUFFER_is_supported_and_enabled : Localization.WRITE_BUFFER_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.HPA)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.HPA) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.HPA) ? Localization.Host_Protected_Area_is_supported_and_enabled : Localization.Host_Protected_Area_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.DeviceReset)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - DeviceReset) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit + .DeviceReset) ? Localization.DEVICE_RESET_is_supported_and_enabled : Localization._); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Service)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Service) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Service) ? Localization.SERVICE_interrupt_is_supported_and_enabled : Localization.SERVICE_interrupt_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Release)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Release) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Release) ? Localization.Release_is_supported_and_enabled : Localization.Release_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.LookAhead)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.LookAhead) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.LookAhead) ? Localization.Look_ahead_read_is_supported_and_enabled : Localization.Look_ahead_read_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.WriteCache)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.WriteCache) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.WriteCache) ? Localization.Write_cache_is_supported_and_enabled : Localization.Write_cache_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Packet)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Packet) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.Packet) ? Localization.PACKET_is_supported_and_enabled : Localization.PACKET_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.PowerManagement)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - PowerManagement) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit + .PowerManagement) ? Localization.Power_management_is_supported_and_enabled : Localization.Power_management_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.RemovableMedia)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - RemovableMedia) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit + .RemovableMedia) ? Localization.Removable_media_feature_set_is_supported_and_enabled : Localization.Removable_media_feature_set_is_supported); } if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.SecurityMode)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - SecurityMode) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit + .SecurityMode) ? Localization.Security_mode_is_supported_and_enabled : Localization.Security_mode_is_supported); } @@ -1647,35 +1614,35 @@ public static class Identify { if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.LBA48)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - LBA48) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .LBA48) ? Localization._48_bit_LBA_is_supported_and_enabled : Localization._48_bit_LBA_is_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.FlushCache)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - FlushCache) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .FlushCache) ? Localization.FLUSH_CACHE_is_supported_and_enabled : Localization.FLUSH_CACHE_is_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.FlushCacheExt)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - FlushCacheExt) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .FlushCacheExt) ? Localization.FLUSH_CACHE_EXT_is_supported_and_enabled : Localization.FLUSH_CACHE_EXT_is_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.DCO)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.DCO) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.DCO) ? Localization.Device_Configuration_Overlay_feature_set_is_supported_and_enabled : Localization.Device_Configuration_Overlay_feature_set_is_supported); } @@ -1684,9 +1651,11 @@ public static class Identify { if(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.AAM)) { - sb.AppendLine(). - AppendFormat(Localization.Automatic_Acoustic_Management_is_supported_and_enabled_with_value_0_vendor_recommends_1, - ATAID.CurrentAAM, ATAID.RecommendedAAM); + sb.AppendLine() + .AppendFormat(Localization + .Automatic_Acoustic_Management_is_supported_and_enabled_with_value_0_vendor_recommends_1, + ATAID.CurrentAAM, + ATAID.RecommendedAAM); } else sb.AppendLine().Append(Localization.Automatic_Acoustic_Management_is_supported); @@ -1694,19 +1663,19 @@ public static class Identify if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.SetMax)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - SetMax) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .SetMax) ? Localization.SET_MAX_security_extension_is_supported_and_enabled : Localization.SET_MAX_security_extension_is_supported); } - if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - AddressOffsetReservedAreaBoot)) + if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .AddressOffsetReservedAreaBoot)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - AddressOffsetReservedAreaBoot) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .AddressOffsetReservedAreaBoot) ? Localization.Address_Offset_Reserved_Area_Boot_is_supported_and_enabled : Localization.Address_Offset_Reserved_Area_Boot_is_supported); } @@ -1716,18 +1685,18 @@ public static class Identify if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.PowerUpInStandby)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - PowerUpInStandby) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .PowerUpInStandby) ? Localization.Power_up_in_standby_is_supported_and_enabled : Localization.Power_up_in_standby_is_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.RemovableNotification)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - RemovableNotification) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .RemovableNotification) ? Localization.Removable_Media_Status_Notification_is_supported_and_enabled : Localization.Removable_Media_Status_Notification_is_supported); } @@ -1736,8 +1705,8 @@ public static class Identify { if(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.APM)) { - sb.AppendLine(). - AppendFormat(Localization.Advanced_Power_Management_is_supported_and_enabled_with_value_0, + sb.AppendLine() + .AppendFormat(Localization.Advanced_Power_Management_is_supported_and_enabled_with_value_0, ATAID.CurrentAPM); } else @@ -1746,27 +1715,27 @@ public static class Identify if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.CompactFlash)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - CompactFlash) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .CompactFlash) ? Localization.CompactFlash_feature_set_is_supported_and_enabled : Localization.CompactFlash_feature_set_is_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.RWQueuedDMA)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - RWQueuedDMA) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .RWQueuedDMA) ? Localization.READ_DMA_QUEUED_and_WRITE_DMA_QUEUED_are_supported_and_enabled : Localization.READ_DMA_QUEUED_and_WRITE_DMA_QUEUED_are_supported); } if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.DownloadMicrocode)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - DownloadMicrocode) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2 + .DownloadMicrocode) ? Localization.DOWNLOAD_MICROCODE_is_supported_and_enabled : Localization.DOWNLOAD_MICROCODE_is_supported); } @@ -1774,8 +1743,8 @@ public static class Identify if(ATAID.CommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.SMART)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.SMART) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.SMART) ? Localization.SMART_is_supported_and_enabled : Localization.SMART_is_supported); } @@ -1788,27 +1757,27 @@ public static class Identify { if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.SMARTSelfTest)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - SMARTSelfTest) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .SMARTSelfTest) ? Localization.SMART_self_testing_is_supported_and_enabled : Localization.SMART_self_testing_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.SMARTLog)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - SMARTLog) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .SMARTLog) ? Localization.SMART_error_logging_is_supported_and_enabled : Localization.SMART_error_logging_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.IdleImmediate)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - IdleImmediate) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .IdleImmediate) ? Localization.IDLE_IMMEDIATE_with_UNLOAD_FEATURE_is_supported_and_enabled : Localization.IDLE_IMMEDIATE_with_UNLOAD_FEATURE_is_supported); } @@ -1824,51 +1793,51 @@ public static class Identify if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.FUAWriteQ)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - FUAWriteQ) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .FUAWriteQ) ? Localization.WRITE_DMA_QUEUED_FUA_EXT_is_supported_and_enabled : Localization.WRITE_DMA_QUEUED_FUA_EXT_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.FUAWrite)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - FUAWrite) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .FUAWrite) ? Localization.WRITE_DMA_FUA_EXT_and_WRITE_MULTIPLE_FUA_EXT_are_supported_and_enabled : Localization.WRITE_DMA_FUA_EXT_and_WRITE_MULTIPLE_FUA_EXT_are_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.GPL)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.GPL) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.GPL) ? Localization.General_Purpose_Logging_is_supported_and_enabled : Localization.General_Purpose_Logging_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.Streaming)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - Streaming) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .Streaming) ? Localization.Streaming_feature_set_is_supported_and_enabled : Localization.Streaming_feature_set_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MCPT)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MCPT) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MCPT) ? Localization.Media_Card_Pass_Through_command_set_is_supported_and_enabled : Localization.Media_Card_Pass_Through_command_set_is_supported); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MediaSerial)) { - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - MediaSerial)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3 + .MediaSerial)) sb.AppendLine().Append(Localization.Media_Serial_is_supported_and_valid); sb.AppendLine().Append(Localization.Media_Serial_is_supported); @@ -1880,87 +1849,87 @@ public static class Identify { if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.DSN)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.DSN) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.DSN) ? Localization.DSN_feature_set_is_supported_and_enabled : Localization.DSN_feature_set_is_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.AMAC)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.AMAC) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.AMAC) ? Localization.Accessible_Max_Address_Configuration_is_supported_and_enabled : Localization.Accessible_Max_Address_Configuration_is_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.ExtPowerCond)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - ExtPowerCond) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .ExtPowerCond) ? Localization.Extended_Power_Conditions_are_supported_and_enabled : Localization.Extended_Power_Conditions_are_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.ExtStatusReport)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - ExtStatusReport) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .ExtStatusReport) ? Localization.Extended_Status_Reporting_is_supported_and_enabled : Localization.Extended_Status_Reporting_is_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.FreeFallControl)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - FreeFallControl) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .FreeFallControl) ? Localization.Free_fall_control_feature_set_is_supported_and_enabled : Localization.Free_fall_control_feature_set_is_supported); } - if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - SegmentedDownloadMicrocode)) + if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .SegmentedDownloadMicrocode)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - SegmentedDownloadMicrocode) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .SegmentedDownloadMicrocode) ? Localization.Segmented_feature_in_DOWNLOAD_MICROCODE_is_supported_and_enabled : Localization.Segmented_feature_in_DOWNLOAD_MICROCODE_is_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.RWDMAExtGpl)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - RWDMAExtGpl) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .RWDMAExtGpl) ? Localization.READ_WRITE_DMA_EXT_GPL_are_supported_and_enabled : Localization.READ_WRITE_DMA_EXT_GPL_are_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WriteUnc)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - WriteUnc) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .WriteUnc) ? Localization.WRITE_UNCORRECTABLE_is_supported_and_enabled : Localization.WRITE_UNCORRECTABLE_is_supported); } if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WRV)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WRV) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WRV) ? Localization.Write_Read_Verify_is_supported_and_enabled : Localization.Write_Read_Verify_is_supported); - sb.AppendLine(). - AppendFormat(Localization._0_sectors_for_Write_Read_Verify_mode_two, ATAID.WRVSectorCountMode2); + sb.AppendLine() + .AppendFormat(Localization._0_sectors_for_Write_Read_Verify_mode_two, ATAID.WRVSectorCountMode2); - sb.AppendLine(). - AppendFormat(Localization._0_sectors_for_Write_Read_Verify_mode_three, ATAID.WRVSectorCountMode3); + sb.AppendLine() + .AppendFormat(Localization._0_sectors_for_Write_Read_Verify_mode_three, ATAID.WRVSectorCountMode3); if(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WRV)) sb.AppendLine().AppendFormat(Localization.Current_Write_Read_Verify_mode_0, ATAID.WRVMode); @@ -1968,9 +1937,9 @@ public static class Identify if(ATAID.CommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.DT1825)) { - sb.AppendLine(). - Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - DT1825) + sb.AppendLine() + .Append(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4 + .DT1825) ? Localization.DT1825_is_supported_and_enabled : Localization.DT1825_is_supported); } @@ -1987,8 +1956,8 @@ public static class Identify if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.DeviceConfDMA)) { - sb.AppendLine(). - Append(Localization.DEVICE_CONFIGURATION_IDENTIFY_DMA_and_DEVICE_CONFIGURATION_SET_DMA_are_supported); + sb.AppendLine() + .Append(Localization.DEVICE_CONFIGURATION_IDENTIFY_DMA_and_DEVICE_CONFIGURATION_SET_DMA_are_supported); } if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.ReadBufferDMA)) @@ -2037,14 +2006,14 @@ public static class Identify { sb.AppendLine().Append(Localization.Sanitize_feature_set_is_supported); - sb.AppendLine(). - Append(ATAID.Capabilities3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit3. - SanitizeCommands) + sb.AppendLine() + .Append(ATAID.Capabilities3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit3 + .SanitizeCommands) ? Localization.Sanitize_commands_are_specified_by_ACS_3_or_higher : Localization.Sanitize_commands_are_specified_by_ACS_2); - if(ATAID.Capabilities3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit3. - SanitizeAntifreeze)) + if(ATAID.Capabilities3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit3 + .SanitizeAntifreeze)) sb.AppendLine().Append(Localization.SANITIZE_ANTIFREEZE_LOCK_EXT_is_supported); } @@ -2052,8 +2021,8 @@ public static class Identify { if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit.Set) && !ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit.Clear) && - ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit. - TrustedComputing)) + ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit + .TrustedComputing)) sb.AppendLine().Append(Localization.Trusted_Computing_feature_set_is_supported); } @@ -2061,53 +2030,53 @@ public static class Identify { if(!ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit.Clear)) { - if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. - ReadLogDMAExt)) + if(ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit + .ReadLogDMAExt)) sb.AppendLine().Append(Localization.READ_LOG_DMA_EXT_is_supported); } if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2.Clear)) { - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - FPDMAQ)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2 + .FPDMAQ)) sb.AppendLine().Append(Localization.RECEIVE_FPDMA_QUEUED_and_SEND_FPDMA_QUEUED_are_supported); } if(!ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.Clear)) { - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - NonZeroBufferOffset)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .NonZeroBufferOffset)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.NonZeroBufferOffset) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .NonZeroBufferOffset) ? Localization.Non_zero_buffer_offsets_are_supported_and_enabled : Localization.Non_zero_buffer_offsets_are_supported); } if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.DMASetup)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.DMASetup) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .DMASetup) ? Localization.DMA_Setup_auto_activation_is_supported_and_enabled : Localization.DMA_Setup_auto_activation_is_supported); } if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.InitPowerMgmt)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.InitPowerMgmt) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .InitPowerMgmt) ? Localization.Device_initiated_power_management_is_supported_and_enabled : Localization.Device_initiated_power_management_is_supported); } if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.InOrderData)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.InOrderData) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .InOrderData) ? Localization.In_order_data_delivery_is_supported_and_enabled : Localization.In_order_data_delivery_is_supported); } @@ -2116,12 +2085,12 @@ public static class Identify { case false: { - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - HardwareFeatureControl)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .HardwareFeatureControl)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.HardwareFeatureControl) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify + .SATAFeaturesBit.HardwareFeatureControl) ? Localization.Hardware_Feature_Control_is_supported_and_enabled : Localization.Hardware_Feature_Control_is_supported); } @@ -2130,12 +2099,12 @@ public static class Identify } case true: { - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - AsyncNotification)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .AsyncNotification)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.AsyncNotification) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify + .SATAFeaturesBit.AsyncNotification) ? Localization.Asynchronous_notification_is_supported_and_enabled : Localization.Asynchronous_notification_is_supported); } @@ -2144,12 +2113,12 @@ public static class Identify } } - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - SettingsPreserve)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .SettingsPreserve)) { - sb.AppendLine(). - Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.SettingsPreserve) + sb.AppendLine() + .Append(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .SettingsPreserve) ? Localization.Software_Settings_Preservation_is_supported_and_enabled : Localization.Software_Settings_Preservation_is_supported); } @@ -2157,8 +2126,8 @@ public static class Identify if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.NCQAutoSense)) sb.AppendLine().Append(Localization.NCQ_Autosense_is_supported); - if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - EnabledSlumber)) + if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit + .EnabledSlumber)) sb.AppendLine().Append(Localization.Automatic_Partial_to_Slumber_transitions_are_enabled); } } @@ -2174,8 +2143,8 @@ public static class Identify if(ATAID.DataSetMgmtSize > 0) { - sb.AppendLine(). - AppendFormat(Localization.DATA_SET_MANAGEMENT_can_receive_a_maximum_of_0_blocks_of_512_bytes, + sb.AppendLine() + .AppendFormat(Localization.DATA_SET_MANAGEMENT_can_receive_a_maximum_of_0_blocks_of_512_bytes, ATAID.DataSetMgmtSize); } @@ -2189,23 +2158,23 @@ public static class Identify { sb.AppendLine(Localization.Security_is_enabled); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. - Locked) + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit + .Locked) ? Localization.Security_is_locked : Localization.Security_is_not_locked); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. - Frozen) + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit + .Frozen) ? Localization.Security_is_frozen : Localization.Security_is_not_frozen); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. - Expired) + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit + .Expired) ? Localization.Security_count_has_expired : Localization.Security_count_has_not_expired); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. - Maximum) + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit + .Maximum) ? Localization.Security_level_is_maximum : Localization.Security_level_is_high); } @@ -2220,12 +2189,12 @@ public static class Identify if(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit.Enhanced)) { sb.AppendFormat(Localization._0_minutes_to_complete_enhanced_secure_erase, - ATAID.EnhancedSecurityEraseTime * 2). - AppendLine(); + ATAID.EnhancedSecurityEraseTime * 2) + .AppendLine(); } - sb.AppendFormat(Localization.Master_password_revision_code_0, ATAID.MasterPasswordRevisionCode). - AppendLine(); + sb.AppendFormat(Localization.Master_password_revision_code_0, ATAID.MasterPasswordRevisionCode) + .AppendLine(); } if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MustBeSet) && @@ -2244,24 +2213,24 @@ public static class Identify { sb.AppendLine().AppendLine(Localization.SMART_Command_Transport_SCT); - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - LongSectorAccess)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit + .LongSectorAccess)) sb.AppendLine(Localization.SCT_Long_Sector_Address_is_supported); - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - WriteSame)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit + .WriteSame)) sb.AppendLine(Localization.SCT_Write_Same_is_supported); - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - ErrorRecoveryControl)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit + .ErrorRecoveryControl)) sb.AppendLine(Localization.SCT_Error_Recovery_Control_is_supported); - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - FeaturesControl)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit + .FeaturesControl)) sb.AppendLine(Localization.SCT_Features_Control_is_supported); - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - DataTables)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit + .DataTables)) sb.AppendLine(Localization.SCT_Data_Tables_are_supported); } @@ -2281,12 +2250,12 @@ public static class Identify sb.AppendLine().AppendFormat(Localization.Version_0, (ATAID.NVCacheCaps & 0x0F00) >> 8).AppendLine(); } - sb.AppendLine(). - AppendFormat(Localization.Non_Volatile_Cache_is_0_bytes, ATAID.NVCacheSize * logicalSectorSize). - AppendLine(); + sb.AppendLine() + .AppendFormat(Localization.Non_Volatile_Cache_is_0_bytes, ATAID.NVCacheSize * logicalSectorSize) + .AppendLine(); } - #if DEBUG +#if DEBUG sb.AppendLine(); if(ATAID.VendorWord9 != 0x0000 && ATAID.VendorWord9 != 0xFFFF) @@ -2366,7 +2335,7 @@ public static class Identify if(ATAID.ReservedWords[i] != 0x0000 && ATAID.ReservedWords[i] != 0xFFFF) sb.AppendFormat(Localization.Word_1_0, ATAID.ReservedWords[i], 236 + i).AppendLine(); } - #endif +#endif return sb.ToString(); } } \ No newline at end of file diff --git a/Aaru.Decoders/Bluray/BCA.cs b/Aaru.Decoders/Bluray/BCA.cs index a27a9e895..59d012832 100644 --- a/Aaru.Decoders/Bluray/BCA.cs +++ b/Aaru.Decoders/Bluray/BCA.cs @@ -83,12 +83,12 @@ public static class BCA public static BurstCuttingArea? Decode(byte[] BCAResponse) { - if(BCAResponse == null) - return null; + if(BCAResponse == null) return null; if(BCAResponse.Length != 68) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes, BCAResponse.Length); return null; @@ -109,20 +109,19 @@ public static class BCA public static string Prettify(BurstCuttingArea? BCAResponse) { - if(BCAResponse == null) - return null; + if(BCAResponse == null) return null; BurstCuttingArea response = BCAResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif sb.AppendFormat(Localization.Blu_ray_Burst_Cutting_Area_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.BCA, 80)); diff --git a/Aaru.Decoders/Bluray/Cartridge.cs b/Aaru.Decoders/Bluray/Cartridge.cs index 6aaf80580..bcec2c93b 100644 --- a/Aaru.Decoders/Bluray/Cartridge.cs +++ b/Aaru.Decoders/Bluray/Cartridge.cs @@ -98,12 +98,12 @@ public static class Cartridge public static CartridgeStatus? Decode(byte[] CSResponse) { - if(CSResponse == null) - return null; + if(CSResponse == null) return null; if(CSResponse.Length != 8) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_incorrect_Blu_ray_Cartridge_Status_size_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_incorrect_Blu_ray_Cartridge_Status_size_0_bytes, CSResponse.Length); return null; @@ -129,14 +129,13 @@ public static class Cartridge public static string Prettify(CartridgeStatus? CSResponse) { - if(CSResponse == null) - return null; + if(CSResponse == null) return null; CartridgeStatus response = CSResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); @@ -157,29 +156,25 @@ public static class Cartridge if(response.Reserved7 != 0) sb.AppendFormat(Localization.Reserved7_equals_0_X8, response.Reserved7).AppendLine(); - #endif +#endif if(response.Cartridge) { sb.AppendLine(Localization.Media_is_inserted_in_a_cartridge); - if(response.OUT) - sb.AppendLine(Localization.Media_has_been_taken_out_or_inserted_in_the_cartridge); + if(response.OUT) sb.AppendLine(Localization.Media_has_been_taken_out_or_inserted_in_the_cartridge); - if(response.CWP) - sb.AppendLine(Localization.Media_is_write_protected); + if(response.CWP) sb.AppendLine(Localization.Media_is_write_protected); } else { sb.AppendLine(Localization.Media_is_not_in_a_cartridge); - #if DEBUG - if(response.OUT) - sb.AppendLine(Localization.Media_has_out_bit_marked_shouldnt); +#if DEBUG + if(response.OUT) sb.AppendLine(Localization.Media_has_out_bit_marked_shouldnt); - if(response.CWP) - sb.AppendLine(Localization.Media_has_write_protection_bit_marked_shouldnt); - #endif + if(response.CWP) sb.AppendLine(Localization.Media_has_write_protection_bit_marked_shouldnt); +#endif } return sb.ToString(); diff --git a/Aaru.Decoders/Bluray/DDS.cs b/Aaru.Decoders/Bluray/DDS.cs index dc9346279..d77a03a60 100644 --- a/Aaru.Decoders/Bluray/DDS.cs +++ b/Aaru.Decoders/Bluray/DDS.cs @@ -131,8 +131,7 @@ public static class DDS public static DiscDefinitionStructure? Decode(byte[] DDSResponse) { - if(DDSResponse == null) - return null; + if(DDSResponse == null) return null; var decoded = new DiscDefinitionStructure { @@ -178,8 +177,7 @@ public static class DDS public static string Prettify(DiscDefinitionStructure? DDSResponse) { - if(DDSResponse == null) - return null; + if(DDSResponse == null) return null; DiscDefinitionStructure response = DDSResponse.Value; @@ -202,7 +200,7 @@ public static class DDS sb.AppendFormat(Localization.Blu_ray_DDS_Disc_Type_Specific_Data_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DiscTypeSpecificData, 80)); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); @@ -229,7 +227,7 @@ public static class DDS if(response.Reserved9 != 0) sb.AppendFormat(Localization.Reserved9_equals_0_X8, response.Reserved9).AppendLine(); - #endif +#endif return sb.ToString(); } diff --git a/Aaru.Decoders/Bluray/DI.cs b/Aaru.Decoders/Bluray/DI.cs index 94a740092..79b265499 100644 --- a/Aaru.Decoders/Bluray/DI.cs +++ b/Aaru.Decoders/Bluray/DI.cs @@ -115,12 +115,12 @@ public static class DI public static DiscInformation? Decode(byte[] DIResponse) { - if(DIResponse == null) - return null; + if(DIResponse == null) return null; if(DIResponse.Length != 4100) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_incorrect_Blu_ray_Disc_Information_size_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_incorrect_Blu_ray_Disc_Information_size_0_bytes, DIResponse.Length); return null; @@ -138,16 +138,14 @@ public static class DI while(true) { - if(offset >= 4100) - break; + if(offset >= 4100) break; var unit = new DiscInformationUnits { Signature = BigEndianBitConverter.ToUInt16(DIResponse, 0 + offset) }; - if(unit.Signature != DIUIdentifier) - break; + if(unit.Signature != DIUIdentifier) break; unit.Format = DIResponse[2 + offset]; unit.UnitsPerBlock = (byte)((DIResponse[3 + offset] & 0xF8) >> 3); @@ -216,7 +214,8 @@ public static class DI default: { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_unknown_disc_type_identifier_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_unknown_disc_type_identifier_0, Encoding.ASCII.GetString(unit.DiscTypeIdentifier)); break; @@ -228,21 +227,18 @@ public static class DI offset += unit.Length; } - if(units.Count <= 0) - return decoded; + if(units.Count <= 0) return decoded; decoded.Units = new DiscInformationUnits[units.Count]; - for(var i = 0; i < units.Count; i++) - decoded.Units[i] = units[i]; + for(var i = 0; i < units.Count; i++) decoded.Units[i] = units[i]; return decoded; } public static string Prettify(DiscInformation? DIResponse) { - if(DIResponse == null) - return null; + if(DIResponse == null) return null; DiscInformation response = DIResponse.Value; @@ -264,8 +260,8 @@ public static class DI sb.AppendFormat(Localization.DI_Unit_is_0_bytes, unit.Length).AppendLine(); - sb.AppendFormat(Localization.Disc_type_identifier_0, Encoding.ASCII.GetString(unit.DiscTypeIdentifier)). - AppendLine(); + sb.AppendFormat(Localization.Disc_type_identifier_0, Encoding.ASCII.GetString(unit.DiscTypeIdentifier)) + .AppendLine(); switch(unit.DiscSize) { @@ -338,9 +334,8 @@ public static class DI break; default: - sb.AppendFormat(Localization.Disc_uses_unknown_channel_length_with_code_0, - (byte)unit.ChannelLength). - AppendLine(); + sb.AppendFormat(Localization.Disc_uses_unknown_channel_length_with_code_0, (byte)unit.ChannelLength) + .AppendLine(); break; } @@ -366,19 +361,19 @@ public static class DI switch(unit.RecordedPolarity) { case 0: - sb.AppendLine(Localization. - Recorded_marks_have_a_lower_reflectivity_than_unrecorded_ones_HTL_disc); + sb.AppendLine(Localization + .Recorded_marks_have_a_lower_reflectivity_than_unrecorded_ones_HTL_disc); break; case 1: - sb.AppendLine(Localization. - Recorded_marks_have_a_higher_reflectivity_than_unrecorded_ones_LTH_disc); + sb.AppendLine(Localization + .Recorded_marks_have_a_higher_reflectivity_than_unrecorded_ones_LTH_disc); break; default: sb.AppendFormat(Localization.Disc_uses_unknown_recorded_reflectivity_polarity_with_code_0, - unit.RecordedPolarity). - AppendLine(); + unit.RecordedPolarity) + .AppendLine(); break; } @@ -402,28 +397,28 @@ public static class DI if(unit.MaxTransfer > 0) { - sb.AppendFormat(Localization.Disc_has_a_maximum_transfer_rate_of_0_Mbit_sec, unit.MaxTransfer). - AppendLine(); + sb.AppendFormat(Localization.Disc_has_a_maximum_transfer_rate_of_0_Mbit_sec, unit.MaxTransfer) + .AppendLine(); } else sb.AppendLine(Localization.Disc_does_not_specify_a_maximum_transfer_rate); sb.AppendFormat(Localization.Last_user_data_PSN_for_disc_0, unit.LastPsn).AppendLine(); - sb.AppendFormat(Localization.First_address_unit_number_of_data_zone_in_this_layer_0, unit.FirstAun). - AppendLine(); + sb.AppendFormat(Localization.First_address_unit_number_of_data_zone_in_this_layer_0, unit.FirstAun) + .AppendLine(); - sb.AppendFormat(Localization.Last_address_unit_number_of_data_zone_in_this_layer_0, unit.LastAun). - AppendLine(); + sb.AppendFormat(Localization.Last_address_unit_number_of_data_zone_in_this_layer_0, unit.LastAun) + .AppendLine(); if(Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDR || Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDRE) { - sb.AppendFormat(Localization.Disc_manufacturer_ID_0, Encoding.ASCII.GetString(unit.ManufacturerID)). - AppendLine(); + sb.AppendFormat(Localization.Disc_manufacturer_ID_0, Encoding.ASCII.GetString(unit.ManufacturerID)) + .AppendLine(); - sb.AppendFormat(Localization.Disc_media_type_ID_0, Encoding.ASCII.GetString(unit.MediaTypeID)). - AppendLine(); + sb.AppendFormat(Localization.Disc_media_type_ID_0, Encoding.ASCII.GetString(unit.MediaTypeID)) + .AppendLine(); sb.AppendFormat(Localization.Disc_timestamp_0, unit.TimeStamp).AppendLine(); sb.AppendFormat(Localization.Disc_product_revision_number_0, unit.ProductRevisionNumber).AppendLine(); diff --git a/Aaru.Decoders/Bluray/Spare.cs b/Aaru.Decoders/Bluray/Spare.cs index 6bddf5282..dc87632e7 100644 --- a/Aaru.Decoders/Bluray/Spare.cs +++ b/Aaru.Decoders/Bluray/Spare.cs @@ -86,14 +86,13 @@ public static class Spare public static SpareAreaInformation? Decode(byte[] SAIResponse) { - if(SAIResponse == null) - return null; + if(SAIResponse == null) return null; if(SAIResponse.Length != 16) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes, + Localization + .Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes, SAIResponse.Length); return null; @@ -114,14 +113,13 @@ public static class Spare public static string Prettify(SpareAreaInformation? SAIResponse) { - if(SAIResponse == null) - return null; + if(SAIResponse == null) return null; SpareAreaInformation response = SAIResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); @@ -130,7 +128,7 @@ public static class Spare if(response.Reserved3 != 0) sb.AppendFormat(Localization.Reserved3_equals_0_X8, response.Reserved3).AppendLine(); - #endif +#endif sb.AppendFormat(Localization._0_free_spare_blocks, response.FreeSpareBlocks).AppendLine(); sb.AppendFormat(Localization._0_allocated_spare_blocks, response.AllocatedSpareBlocks).AppendLine(); diff --git a/Aaru.Decoders/CD/ATIP.cs b/Aaru.Decoders/CD/ATIP.cs index 749ed2e0b..c864f2c69 100644 --- a/Aaru.Decoders/CD/ATIP.cs +++ b/Aaru.Decoders/CD/ATIP.cs @@ -61,16 +61,15 @@ public static class ATIP public static CDATIP Decode(byte[] CDATIPResponse) { - if(CDATIPResponse is not { Length: > 4 }) - return null; + if(CDATIPResponse is not { Length: > 4 }) return null; var decoded = new CDATIP(); if(CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding, + Localization + .Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding, CDATIPResponse.Length); return null; @@ -115,8 +114,7 @@ public static class ATIP decoded.Reserved8 = CDATIPResponse[23]; decoded.Reserved9 = CDATIPResponse[27]; - if(CDATIPResponse.Length < 32) - return decoded.AlwaysOne ? decoded : null; + if(CDATIPResponse.Length < 32) return decoded.AlwaysOne ? decoded : null; decoded.S4Values = new byte[3]; Array.Copy(CDATIPResponse, 28, decoded.S4Values, 0, 3); @@ -127,8 +125,7 @@ public static class ATIP public static string Prettify(CDATIP response) { - if(response == null) - return null; + if(response == null) return null; var sb = new StringBuilder(); @@ -148,8 +145,8 @@ public static class ATIP break; default: - sb.AppendFormat(Localization.Reference_speed_set_is_unknown_0, response.ReferenceSpeed). - AppendLine(); + sb.AppendFormat(Localization.Reference_speed_set_is_unknown_0, response.ReferenceSpeed) + .AppendLine(); break; } @@ -157,18 +154,18 @@ public static class ATIP sb.AppendFormat(Localization.ATIP_Start_time_of_Lead_in_0, (response.LeadInStartMin << 16) + (response.LeadInStartSec << 8) + - response.LeadInStartFrame). - AppendLine(); + response.LeadInStartFrame) + .AppendLine(); sb.AppendFormat(Localization.ATIP_Last_possible_start_time_of_Lead_out_0, (response.LeadOutStartMin << 16) + (response.LeadOutStartSec << 8) + - response.LeadOutStartFrame). - AppendLine(); + response.LeadOutStartFrame) + .AppendLine(); sb.AppendFormat(Localization.S4_value_0, - (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2]). - AppendLine(); + (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2]) + .AppendLine(); } else { @@ -223,8 +220,8 @@ public static class ATIP break; default: - sb.AppendFormat(Localization.Reference_speed_set_is_unknown_0, response.ReferenceSpeed). - AppendLine(); + sb.AppendFormat(Localization.Reference_speed_set_is_unknown_0, response.ReferenceSpeed) + .AppendLine(); break; } @@ -276,45 +273,48 @@ public static class ATIP sb.AppendLine(response.URU ? Localization.Disc_use_is_unrestricted : Localization.Disc_use_is_restricted); - sb.AppendFormat(Localization.ATIP_Start_time_of_Lead_in_0_1_2, response.LeadInStartMin, - response.LeadInStartSec, response.LeadInStartFrame). - AppendLine(); + sb.AppendFormat(Localization.ATIP_Start_time_of_Lead_in_0_1_2, + response.LeadInStartMin, + response.LeadInStartSec, + response.LeadInStartFrame) + .AppendLine(); - sb.AppendFormat(Localization.ATIP_Last_possible_start_time_of_Lead_out_0_1_2, response.LeadOutStartMin, - response.LeadOutStartSec, response.LeadOutStartFrame). - AppendLine(); + sb.AppendFormat(Localization.ATIP_Last_possible_start_time_of_Lead_out_0_1_2, + response.LeadOutStartMin, + response.LeadOutStartSec, + response.LeadOutStartFrame) + .AppendLine(); if(response.A1Valid) { sb.AppendFormat(Localization.A1_value_0, - (response.A1Values[0] << 16) + (response.A1Values[1] << 8) + response.A1Values[2]). - AppendLine(); + (response.A1Values[0] << 16) + (response.A1Values[1] << 8) + response.A1Values[2]) + .AppendLine(); } if(response.A2Valid) { sb.AppendFormat(Localization.A2_value_0, - (response.A2Values[0] << 16) + (response.A2Values[1] << 8) + response.A2Values[2]). - AppendLine(); + (response.A2Values[0] << 16) + (response.A2Values[1] << 8) + response.A2Values[2]) + .AppendLine(); } if(response.A3Valid) { sb.AppendFormat(Localization.A3_value_0, - (response.A3Values[0] << 16) + (response.A3Values[1] << 8) + response.A3Values[2]). - AppendLine(); + (response.A3Values[0] << 16) + (response.A3Values[1] << 8) + response.A3Values[2]) + .AppendLine(); } if(response.S4Values != null) { sb.AppendFormat(Localization.S4_value_0, - (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2]). - AppendLine(); + (response.S4Values[0] << 16) + (response.S4Values[1] << 8) + response.S4Values[2]) + .AppendLine(); } } - if(response.LeadInStartMin != 97) - return sb.ToString(); + if(response.LeadInStartMin != 97) return sb.ToString(); int type = response.LeadInStartFrame % 10; int frm = response.LeadInStartFrame - type; @@ -330,8 +330,7 @@ public static class ATIP string manufacturer = ManufacturerFromATIP(response.LeadInStartSec, frm); - if(manufacturer != "") - sb.AppendFormat(Localization.Disc_manufactured_by_0, manufacturer).AppendLine(); + if(manufacturer != "") sb.AppendFormat(Localization.Disc_manufactured_by_0, manufacturer).AppendLine(); return sb.ToString(); } @@ -381,8 +380,7 @@ public static class ATIP break; case 17: - if(frm == 00) - return "Moser Baer India Ltd."; + if(frm == 00) return "Moser Baer India Ltd."; break; case 18: @@ -396,8 +394,7 @@ public static class ATIP break; case 20: - if(frm == 10) - return "CDA Datenträger Albrechts GmbH"; + if(frm == 10) return "CDA Datenträger Albrechts GmbH"; break; case 21: @@ -573,8 +570,7 @@ public static class ATIP break; case 30: - if(frm == 10) - return "CDA Datenträger Albrechts GmbH"; + if(frm == 10) return "CDA Datenträger Albrechts GmbH"; break; case 31: @@ -615,8 +611,7 @@ public static class ATIP break; case 42: - if(frm == 20) - return "Advanced Digital Media"; + if(frm == 20) return "Advanced Digital Media"; break; case 45: diff --git a/Aaru.Decoders/CD/CDTextOnLeadIn.cs b/Aaru.Decoders/CD/CDTextOnLeadIn.cs index 0358246d4..0d24ef314 100644 --- a/Aaru.Decoders/CD/CDTextOnLeadIn.cs +++ b/Aaru.Decoders/CD/CDTextOnLeadIn.cs @@ -103,8 +103,7 @@ public static class CDTextOnLeadIn public static CDText? Decode(byte[] CDTextResponse) { - if(CDTextResponse is not { Length: > 4 }) - return null; + if(CDTextResponse is not { Length: > 4 }) return null; var decoded = new CDText { @@ -115,15 +114,15 @@ public static class CDTextOnLeadIn decoded.DataPacks = new CDTextPack[(decoded.DataLength - 2) / 18]; - if(decoded.DataLength == 2) - return null; + if(decoded.DataLength == 2) return null; if(decoded.DataLength + 2 != CDTextResponse.Length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding, - decoded.DataLength + 2, CDTextResponse.Length); + Localization + .Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding, + decoded.DataLength + 2, + CDTextResponse.Length); return null; } @@ -146,19 +145,18 @@ public static class CDTextOnLeadIn public static string Prettify(CDText? CDTextResponse) { - if(CDTextResponse == null) - return null; + if(CDTextResponse == null) return null; CDText response = CDTextResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif foreach(CDTextPack descriptor in response.DataPacks) { @@ -167,8 +165,8 @@ public static class CDTextOnLeadIn // Ignore NOPs if((descriptor.HeaderID1 & 0x80) != 0) { - sb.AppendFormat(Localization.Incorrect_CD_Text_pack_type_0_not_decoding, descriptor.HeaderID1). - AppendLine(); + sb.AppendFormat(Localization.Incorrect_CD_Text_pack_type_0_not_decoding, descriptor.HeaderID1) + .AppendLine(); } } else @@ -181,8 +179,8 @@ public static class CDTextOnLeadIn sb.AppendLine(Localization.CD_Text_pack_contains_title_for_album); else { - sb.AppendFormat(Localization.CD_Text_pack_contains_title_for_track_0, descriptor.HeaderID2). - AppendLine(); + sb.AppendFormat(Localization.CD_Text_pack_contains_title_for_track_0, descriptor.HeaderID2) + .AppendLine(); } break; @@ -195,8 +193,8 @@ public static class CDTextOnLeadIn else { sb.AppendFormat(Localization.CD_Text_pack_contains_performer_for_track_0, - descriptor.HeaderID2). - AppendLine(); + descriptor.HeaderID2) + .AppendLine(); } break; @@ -209,8 +207,8 @@ public static class CDTextOnLeadIn else { sb.AppendFormat(Localization.CD_Text_pack_contains_songwriter_for_track_0, - descriptor.HeaderID2). - AppendLine(); + descriptor.HeaderID2) + .AppendLine(); } break; @@ -233,8 +231,8 @@ public static class CDTextOnLeadIn else { sb.AppendFormat(Localization.CD_Text_pack_contains_arranger_for_track_0, - descriptor.HeaderID2). - AppendLine(); + descriptor.HeaderID2) + .AppendLine(); } break; @@ -247,8 +245,8 @@ public static class CDTextOnLeadIn else { sb.AppendFormat(Localization.CD_Text_pack_contains_content_provider_message_for_track_0, - descriptor.HeaderID2). - AppendLine(); + descriptor.HeaderID2) + .AppendLine(); } break; @@ -328,16 +326,15 @@ public static class CDTextOnLeadIn case 0x87: case 0x8E: { - if(descriptor.DBCC) - sb.AppendLine(Localization.Double_Byte_Character_Code_is_used); + if(descriptor.DBCC) sb.AppendLine(Localization.Double_Byte_Character_Code_is_used); sb.AppendFormat(Localization.Block_number_0, descriptor.BlockNumber).AppendLine(); sb.AppendFormat(Localization.Character_position_0, descriptor.CharacterPosition).AppendLine(); sb.AppendFormat(Localization.Text_field_0, StringHandlers.CToString(descriptor.TextDataField, - Encoding.GetEncoding("iso-8859-1"))). - AppendLine(); + Encoding.GetEncoding("iso-8859-1"))) + .AppendLine(); break; } @@ -345,8 +342,8 @@ public static class CDTextOnLeadIn default: { sb.AppendFormat(Localization.Binary_contents_0, - PrintHex.ByteArrayToHexArrayString(descriptor.TextDataField, 28)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(descriptor.TextDataField, 28)) + .AppendLine(); break; } diff --git a/Aaru.Decoders/CD/FullTOC.cs b/Aaru.Decoders/CD/FullTOC.cs index c342b15fc..031061473 100644 --- a/Aaru.Decoders/CD/FullTOC.cs +++ b/Aaru.Decoders/CD/FullTOC.cs @@ -65,8 +65,7 @@ public static class FullTOC public static CDFullTOC? Decode(byte[] CDFullTOCResponse) { - if(CDFullTOCResponse is not { Length: > 4 }) - return null; + if(CDFullTOCResponse is not { Length: > 4 }) return null; var decoded = new CDFullTOC { @@ -80,9 +79,10 @@ public static class FullTOC if(decoded.DataLength + 2 != CDFullTOCResponse.Length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CDFullTOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding, - decoded.DataLength + 2, CDFullTOCResponse.Length); + Localization + .Expected_CDFullTOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding, + decoded.DataLength + 2, + CDFullTOCResponse.Length); return null; } @@ -110,8 +110,7 @@ public static class FullTOC public static string Prettify(CDFullTOC? CDFullTOCResponse) { - if(CDFullTOCResponse == null) - return null; + if(CDFullTOCResponse == null) return null; CDFullTOC response = CDFullTOCResponse.Value; @@ -165,13 +164,13 @@ public static class FullTOC switch(descriptor.PSEC) { case 0x10: - sb.AppendLine(Localization. - CD_V_single_in_NTSC_format_with_digital_stereo_sound); + sb.AppendLine(Localization + .CD_V_single_in_NTSC_format_with_digital_stereo_sound); break; case 0x11: - sb.AppendLine(Localization. - CD_V_single_in_NTSC_format_with_digital_bilingual_sound); + sb.AppendLine(Localization + .CD_V_single_in_NTSC_format_with_digital_bilingual_sound); break; case 0x12: @@ -179,8 +178,8 @@ public static class FullTOC break; case 0x13: - sb.AppendLine(Localization. - CD_V_disc_in_NTSC_format_with_digital_bilingual_sound); + sb.AppendLine(Localization + .CD_V_disc_in_NTSC_format_with_digital_bilingual_sound); break; case 0x20: @@ -188,8 +187,8 @@ public static class FullTOC break; case 0x21: - sb.AppendLine(Localization. - CD_V_single_in_PAL_format_with_digital_bilingual_sound); + sb.AppendLine(Localization + .CD_V_single_in_PAL_format_with_digital_bilingual_sound); break; case 0x22: @@ -197,8 +196,8 @@ public static class FullTOC break; case 0x23: - sb.AppendLine(Localization. - CD_V_disc_in_PAL_format_with_digital_bilingual_sound); + sb.AppendLine(Localization + .CD_V_disc_in_PAL_format_with_digital_bilingual_sound); break; } @@ -291,15 +290,20 @@ public static class FullTOC { if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Lead_out_start_position_3_0_1_2, descriptor.PMIN, - descriptor.PSEC, descriptor.PFRAME, descriptor.PHOUR). - AppendLine(); + sb.AppendFormat(Localization.Lead_out_start_position_3_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR) + .AppendLine(); } else { - sb.AppendFormat(Localization.Lead_out_start_position_0_1_2, descriptor.PMIN, - descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + sb.AppendFormat(Localization.Lead_out_start_position_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME) + .AppendLine(); } //sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine(); @@ -331,15 +335,20 @@ public static class FullTOC if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Absolute_time_3_0_1_2, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR). - AppendLine(); + sb.AppendFormat(Localization.Absolute_time_3_0_1_2, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR) + .AppendLine(); } else { - sb.AppendFormat(Localization.Absolute_time_0_1_2, descriptor.Min, descriptor.Sec, - descriptor.Frame). - AppendLine(); + sb.AppendFormat(Localization.Absolute_time_0_1_2, + descriptor.Min, + descriptor.Sec, + descriptor.Frame) + .AppendLine(); } break; @@ -351,9 +360,12 @@ public static class FullTOC { if(descriptor.ADR == 4) { - sb.AppendFormat(Localization.Video_track_3_starts_at_0_1_2, descriptor.PMIN, - descriptor.PSEC, descriptor.PFRAME, descriptor.POINT). - AppendLine(); + sb.AppendFormat(Localization.Video_track_3_starts_at_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.POINT) + .AppendLine(); } else { @@ -363,15 +375,28 @@ public static class FullTOC if(descriptor.PHOUR > 0) { - sb.AppendFormat(data ? Localization.Data_track_3_starts_at_4_0_1_2_open_parenthesis : Localization.Audio_track_3_starts_at_4_0_1_2_open_parenthesis, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.POINT, descriptor.PHOUR); + sb.AppendFormat(data + ? Localization + .Data_track_3_starts_at_4_0_1_2_open_parenthesis + : Localization + .Audio_track_3_starts_at_4_0_1_2_open_parenthesis, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.POINT, + descriptor.PHOUR); } else { - sb.AppendFormat(data ? Localization.Data_track_3_starts_at_0_1_2_open_parenthesis : Localization.Audio_track_3_starts_at_0_1_2_open_parenthesis, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, + sb.AppendFormat(data + ? Localization + .Data_track_3_starts_at_0_1_2_open_parenthesis + : Localization + .Audio_track_3_starts_at_0_1_2_open_parenthesis, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, descriptor.POINT); } @@ -390,8 +415,8 @@ public static class FullTOC break; case TocControl.FourChanPreEmph: - sb.Append(Localization. - Quadraphonic_audio_track_with_50_15_us_pre_emphasis); + sb.Append(Localization + .Quadraphonic_audio_track_with_50_15_us_pre_emphasis); break; case TocControl.DataTrack: @@ -438,28 +463,37 @@ public static class FullTOC { if(descriptor.PHOUR > 0) { - sb. - AppendFormat(Localization.Start_of_next_possible_program_in_the_recordable_area_of_the_disc_3_0_1_2, - descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR). - AppendLine(); + sb.AppendFormat(Localization + .Start_of_next_possible_program_in_the_recordable_area_of_the_disc_3_0_1_2, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR) + .AppendLine(); - sb. - AppendFormat(Localization.Maximum_start_of_outermost_Lead_out_in_the_recordable_area_of_the_disc_3_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.PHOUR). - AppendLine(); + sb.AppendFormat(Localization + .Maximum_start_of_outermost_Lead_out_in_the_recordable_area_of_the_disc_3_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR) + .AppendLine(); } else { - sb. - AppendFormat(Localization.Start_of_next_possible_program_in_the_recordable_area_of_the_disc_0_1_2, - descriptor.Min, descriptor.Sec, descriptor.Frame). - AppendLine(); + sb.AppendFormat(Localization + .Start_of_next_possible_program_in_the_recordable_area_of_the_disc_0_1_2, + descriptor.Min, + descriptor.Sec, + descriptor.Frame) + .AppendLine(); - sb. - AppendFormat(Localization.Maximum_start_of_outermost_Lead_out_in_the_recordable_area_of_the_disc_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + sb.AppendFormat(Localization + .Maximum_start_of_outermost_Lead_out_in_the_recordable_area_of_the_disc_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME) + .AppendLine(); } break; @@ -467,11 +501,11 @@ public static class FullTOC case 0xB1: { - sb.AppendFormat(Localization.Number_of_skip_interval_pointers_0, descriptor.PMIN). - AppendLine(); + sb.AppendFormat(Localization.Number_of_skip_interval_pointers_0, descriptor.PMIN) + .AppendLine(); - sb.AppendFormat(Localization.Number_of_skip_track_pointers_0, descriptor.PSEC). - AppendLine(); + sb.AppendFormat(Localization.Number_of_skip_track_pointers_0, descriptor.PSEC) + .AppendLine(); break; } @@ -497,17 +531,21 @@ public static class FullTOC if(descriptor.PHOUR > 0) { - sb. - AppendFormat(Localization.Start_time_of_the_first_Lead_in_area_in_the_disc_3_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.PHOUR). - AppendLine(); + sb.AppendFormat(Localization + .Start_time_of_the_first_Lead_in_area_in_the_disc_3_0_1_2, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR) + .AppendLine(); } else { sb.AppendFormat(Localization.Start_time_of_the_first_Lead_in_area_in_the_disc_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME) + .AppendLine(); } break; @@ -532,23 +570,32 @@ public static class FullTOC if(descriptor.PHOUR > 0) { sb.AppendFormat(Localization.Start_position_of_outer_part_lead_in_area_3_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.PHOUR). - AppendLine(); + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR) + .AppendLine(); sb.AppendFormat(Localization.Stop_position_of_inner_part_lead_out_area_3_0_1_2, - descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR). - AppendLine(); + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR) + .AppendLine(); } else { sb.AppendFormat(Localization.Start_position_of_outer_part_lead_in_area_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME) + .AppendLine(); sb.AppendFormat(Localization.Stop_position_of_inner_part_lead_out_area_0_1_2, - descriptor.Min, descriptor.Sec, descriptor.Frame). - AppendLine(); + descriptor.Min, + descriptor.Sec, + descriptor.Frame) + .AppendLine(); } break; @@ -559,12 +606,16 @@ public static class FullTOC if(descriptor.POINT is >= 0x01 and <= 0x40) { sb.AppendFormat(Localization.Start_time_for_interval_that_should_be_skipped_0_1_2, - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME) + .AppendLine(); sb.AppendFormat(Localization.Ending_time_for_interval_that_should_be_skipped_0_1_2, - descriptor.Min, descriptor.Sec, descriptor.Frame). - AppendLine(); + descriptor.Min, + descriptor.Sec, + descriptor.Frame) + .AppendLine(); } else { @@ -621,8 +672,7 @@ public static class FullTOC foreach(Track track in tracks.OrderBy(t => t.Session).ThenBy(t => t.Sequence)) { - if(track.Session < toc.FirstCompleteSession) - toc.FirstCompleteSession = (byte)track.Session; + if(track.Session < toc.FirstCompleteSession) toc.FirstCompleteSession = (byte)track.Session; if(track.Session <= toc.LastCompleteSession) { @@ -631,8 +681,7 @@ public static class FullTOC continue; } - if(toc.LastCompleteSession > 0) - sessionEndingTrack.Add(toc.LastCompleteSession, currentTrack); + if(toc.LastCompleteSession > 0) sessionEndingTrack.Add(toc.LastCompleteSession, currentTrack); toc.LastCompleteSession = (byte)track.Session; } @@ -646,8 +695,7 @@ public static class FullTOC { trackFlags.TryGetValue((byte)track.Sequence, out byte trackControl); - if(trackControl == 0 && track.Type != TrackType.Audio) - trackControl = (byte)CdFlags.DataTrack; + if(trackControl == 0 && track.Type != TrackType.Audio) trackControl = (byte)CdFlags.DataTrack; // Lead-Out if(track.Session > currentSession && currentSession != 0) diff --git a/Aaru.Decoders/CD/PMA.cs b/Aaru.Decoders/CD/PMA.cs index 11f79b51d..ffeb4301d 100644 --- a/Aaru.Decoders/CD/PMA.cs +++ b/Aaru.Decoders/CD/PMA.cs @@ -60,8 +60,7 @@ public static class PMA public static CDPMA? Decode(byte[] CDPMAResponse) { - if(CDPMAResponse is not { Length: > 4 }) - return null; + if(CDPMAResponse is not { Length: > 4 }) return null; var decoded = new CDPMA { @@ -72,15 +71,15 @@ public static class PMA decoded.PMADescriptors = new CDPMADescriptors[(decoded.DataLength - 2) / 11]; - if(decoded.PMADescriptors.Length == 0) - return null; + if(decoded.PMADescriptors.Length == 0) return null; if(decoded.DataLength + 2 != CDPMAResponse.Length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CD_PMA_size_0_bytes_is_not_received_size_1_bytes_not_decoding, - decoded.DataLength + 2, CDPMAResponse.Length); + Localization + .Expected_CD_PMA_size_0_bytes_is_not_received_size_1_bytes_not_decoding, + decoded.DataLength + 2, + CDPMAResponse.Length); return null; } @@ -107,29 +106,29 @@ public static class PMA public static string Prettify(CDPMA? CDPMAResponse) { - if(CDPMAResponse == null) - return null; + if(CDPMAResponse == null) return null; CDPMA response = CDPMAResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif foreach(CDPMADescriptors descriptor in response.PMADescriptors) { - #if DEBUG +#if DEBUG if(descriptor.Reserved != 0) sb.AppendFormat(Localization.Reserved_equals_0_X2, descriptor.Reserved).AppendLine(); - #endif +#endif List tracks; + switch(descriptor.ADR) { case 1: @@ -140,16 +139,28 @@ public static class PMA case TocControl.TwoChanNoPreEmph: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Stereo_audio_track_with_no_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Stereo_audio_track_with_no_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Stereo_audio_track_with_no_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Stereo_audio_track_with_no_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -157,16 +168,28 @@ public static class PMA case TocControl.TwoChanPreEmph: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Stereo_audio_track_with_50_15_s_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Stereo_audio_track_with_50_15_s_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Stereo_audio_track_with_50_15_us_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Stereo_audio_track_with_50_15_us_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -174,16 +197,28 @@ public static class PMA case TocControl.FourChanNoPreEmph: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Quadraphonic_audio_track_with_no_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Quadraphonic_audio_track_with_no_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Quadraphonic_audio_track_with_no_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Quadraphonic_audio_track_with_no_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -191,16 +226,28 @@ public static class PMA case TocControl.FourChanPreEmph: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Quadraphonic_audio_track_with_50_15_us_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Quadraphonic_audio_track_with_50_15_us_pre_emphasis_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Quadraphonic_audio_track_with_50_15_us_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Quadraphonic_audio_track_with_50_15_us_pre_emphasis_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -208,16 +255,28 @@ public static class PMA case TocControl.DataTrack: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Data_track_recorded_uninterrupted_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Data_track_recorded_uninterrupted_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Data_track_recorded_uninterrupted_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Data_track_recorded_uninterrupted_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -225,16 +284,28 @@ public static class PMA case TocControl.DataTrackIncremental: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Track_0_Data_track_recorded_incrementally_starts_at_4_1_2_3_and_ends_at_8_5_6_7, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.PHOUR, descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat(Localization + .Track_0_Data_track_recorded_incrementally_starts_at_4_1_2_3_and_ends_at_8_5_6_7, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, + descriptor.HOUR); } else { - sb.AppendFormat(Localization.Track_0_Data_track_recorded_incrementally_starts_at_1_2_3_and_ends_at_4_5_6, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, - descriptor.PFRAME, descriptor.Min, descriptor.Sec, + sb.AppendFormat(Localization + .Track_0_Data_track_recorded_incrementally_starts_at_1_2_3_and_ends_at_4_5_6, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, descriptor.Frame); } @@ -255,82 +326,98 @@ public static class PMA case 3: tracks = new List(); - if(descriptor.Min > 0) - tracks.Add($"{descriptor.Min}"); + if(descriptor.Min > 0) tracks.Add($"{descriptor.Min}"); - if(descriptor.Sec > 0) - tracks.Add($"{descriptor.Sec}"); + if(descriptor.Sec > 0) tracks.Add($"{descriptor.Sec}"); - if(descriptor.Frame > 0) - tracks.Add($"{descriptor.Frame}"); + if(descriptor.Frame > 0) tracks.Add($"{descriptor.Frame}"); - if(descriptor.PMIN > 0) - tracks.Add($"{descriptor.PMIN}"); + if(descriptor.PMIN > 0) tracks.Add($"{descriptor.PMIN}"); - if(descriptor.PSEC > 0) - tracks.Add($"{descriptor.PSEC}"); + if(descriptor.PSEC > 0) tracks.Add($"{descriptor.PSEC}"); - if(descriptor.PFRAME > 0) - tracks.Add($"{descriptor.PFRAME}"); + if(descriptor.PFRAME > 0) tracks.Add($"{descriptor.PFRAME}"); sb.AppendFormat(Localization.Skip_track_assignment_0_says_that_tracks_1_should_be_skipped, - descriptor.POINT, string.Join(' ', tracks)); + descriptor.POINT, + string.Join(' ', tracks)); break; case 4: tracks = new List(); - if(descriptor.Min > 0) - tracks.Add($"{descriptor.Min}"); + if(descriptor.Min > 0) tracks.Add($"{descriptor.Min}"); - if(descriptor.Sec > 0) - tracks.Add($"{descriptor.Sec}"); + if(descriptor.Sec > 0) tracks.Add($"{descriptor.Sec}"); - if(descriptor.Frame > 0) - tracks.Add($"{descriptor.Frame}"); + if(descriptor.Frame > 0) tracks.Add($"{descriptor.Frame}"); - if(descriptor.PMIN > 0) - tracks.Add($"{descriptor.PMIN}"); + if(descriptor.PMIN > 0) tracks.Add($"{descriptor.PMIN}"); - if(descriptor.PSEC > 0) - tracks.Add($"{descriptor.PSEC}"); + if(descriptor.PSEC > 0) tracks.Add($"{descriptor.PSEC}"); - if(descriptor.PFRAME > 0) - tracks.Add($"{descriptor.PFRAME}"); + if(descriptor.PFRAME > 0) tracks.Add($"{descriptor.PFRAME}"); sb.AppendFormat(Localization.Unskip_track_assignment_0_says_that_tracks_1_should_not_be_skipped, - descriptor.POINT, string.Join(' ', tracks)); + descriptor.POINT, + string.Join(' ', tracks)); break; case 5: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Skip_time_interval_assignment_0_says_that_from_4_1_2_3_to_8_5_6_7_should_be_skipped, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.PHOUR, descriptor.Min, descriptor.Sec, descriptor.Frame, + sb.AppendFormat(Localization + .Skip_time_interval_assignment_0_says_that_from_4_1_2_3_to_8_5_6_7_should_be_skipped, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, descriptor.HOUR); } else { - sb.AppendFormat(Localization.Skip_time_interval_assignment_0_says_that_from_1_2_3_to_4_5_6_should_be_skipped, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.Min, descriptor.Sec, descriptor.Frame); + sb.AppendFormat(Localization + .Skip_time_interval_assignment_0_says_that_from_1_2_3_to_4_5_6_should_be_skipped, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, + descriptor.Frame); } break; case 6: if(descriptor.PHOUR > 0) { - sb.AppendFormat(Localization.Unskip_time_interval_assignment_0_says_that_from_4_1_2_3_to_8_5_6_7_should_not_be_skipped, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.PHOUR, descriptor.Min, descriptor.Sec, descriptor.Frame, + sb.AppendFormat(Localization + .Unskip_time_interval_assignment_0_says_that_from_4_1_2_3_to_8_5_6_7_should_not_be_skipped, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.PHOUR, + descriptor.Min, + descriptor.Sec, + descriptor.Frame, descriptor.HOUR); } else { - sb.AppendFormat(Localization.Unskip_time_interval_assignment_0_says_that_from_1_2_3_to_4_5_6_should_not_be_skipped, - descriptor.POINT, descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, - descriptor.Min, descriptor.Sec, descriptor.Frame); + sb.AppendFormat(Localization + .Unskip_time_interval_assignment_0_says_that_from_1_2_3_to_4_5_6_should_not_be_skipped, + descriptor.POINT, + descriptor.PMIN, + descriptor.PSEC, + descriptor.PFRAME, + descriptor.Min, + descriptor.Sec, + descriptor.Frame); } break; diff --git a/Aaru.Decoders/CD/Sector.cs b/Aaru.Decoders/CD/Sector.cs index 1aa029379..d20c9e3e3 100644 --- a/Aaru.Decoders/CD/Sector.cs +++ b/Aaru.Decoders/CD/Sector.cs @@ -187,25 +187,20 @@ public static class Sector public static byte[] Scramble(byte[] sector) { - if(sector == null || sector.Length < 2352) - return sector; + if(sector == null || sector.Length < 2352) return sector; var sync = new byte[12]; Array.Copy(sector, 0, sync, 0, 12); - if(!SyncMark.SequenceEqual(sync)) - return sector; + if(!SyncMark.SequenceEqual(sync)) return sector; var scrambled = new byte[sector.Length]; - for(var i = 0; i < 2352; i++) - scrambled[i] = (byte)(sector[i] ^ ScrambleTable[i]); + for(var i = 0; i < 2352; i++) scrambled[i] = (byte)(sector[i] ^ ScrambleTable[i]); - if(sector.Length <= 2352) - return scrambled; + if(sector.Length <= 2352) return scrambled; - for(var i = 2352; i < sector.Length; i++) - scrambled[i] = sector[i]; + for(var i = 2352; i < sector.Length; i++) scrambled[i] = sector[i]; return scrambled; } @@ -253,8 +248,7 @@ public static class Sector [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] GetUserDataFromMode2(byte[] data, bool interleaved = false, byte fileNumber = 0) { - if(data.Length != 2352 && data.Length != 2336) - return data; + if(data.Length != 2352 && data.Length != 2336) return data; var pos = 0; @@ -279,8 +273,7 @@ public static class Sector } // This is not the sector you are looking for - if(interleaved && data[pos] != fileNumber) - return null; + if(interleaved && data[pos] != fileNumber) return null; int len = (data[pos + 2] & 0x20) == 0x20 ? 2324 : 2048; pos += 8; @@ -293,8 +286,7 @@ public static class Sector public static string Prettify(byte[] buffer) { - if(buffer is null || buffer.Length <= 0) - return null; + if(buffer is null || buffer.Length <= 0) return null; if(buffer[0] != 0x00 || buffer[1] != 0xFF || @@ -332,8 +324,7 @@ public static class Sector lba += (frame >> 4) * 10 + (frame & 0x0F); lba -= 150; - if(moreThan90) - min += 0x90; + if(moreThan90) min += 0x90; sb.AppendFormat(Localization.Position_0_1_2_LBA_3, min, sec, frame, lba).AppendLine(); @@ -403,8 +394,7 @@ public static class Sector for(var i = 16; i < 2352; i++) { - if(buffer[i] == 0x00) - continue; + if(buffer[i] == 0x00) continue; empty = false; @@ -421,8 +411,7 @@ public static class Sector for(var i = 2068; i < 2076; i++) { - if(buffer[i] == 0x00) - continue; + if(buffer[i] == 0x00) continue; empty = false; @@ -450,28 +439,21 @@ public static class Sector sb.AppendFormat(Localization.Channel_number_0, buffer[17]).AppendLine(); sb.AppendFormat(Localization.Coding_information_number_0, buffer[19]).AppendLine(); - if((buffer[18] & 0x80) == 0x80) - sb.AppendLine(Localization.End_of_file); + if((buffer[18] & 0x80) == 0x80) sb.AppendLine(Localization.End_of_file); - if((buffer[18] & 0x40) == 0x40) - sb.AppendLine(Localization.Real_time_block); + if((buffer[18] & 0x40) == 0x40) sb.AppendLine(Localization.Real_time_block); sb.AppendLine((buffer[18] & 0x20) == 0x20 ? Localization.Form_2 : Localization.Form_1); - if((buffer[18] & 0x10) == 0x10) - sb.AppendLine(Localization.Trigger_block); + if((buffer[18] & 0x10) == 0x10) sb.AppendLine(Localization.Trigger_block); - if((buffer[18] & 0x08) == 0x08) - sb.AppendLine(Localization.Data_block); + if((buffer[18] & 0x08) == 0x08) sb.AppendLine(Localization.Data_block); - if((buffer[18] & 0x04) == 0x04) - sb.AppendLine(Localization.Audio_block); + if((buffer[18] & 0x04) == 0x04) sb.AppendLine(Localization.Audio_block); - if((buffer[18] & 0x02) == 0x02) - sb.AppendLine(Localization.Video_block); + if((buffer[18] & 0x02) == 0x02) sb.AppendLine(Localization.Video_block); - if((buffer[18] & 0x01) == 0x01) - sb.AppendLine(Localization.End_of_record); + if((buffer[18] & 0x01) == 0x01) sb.AppendLine(Localization.End_of_record); if((buffer[18] & 0x20) != 0x20) { diff --git a/Aaru.Decoders/CD/SectorBuilder.cs b/Aaru.Decoders/CD/SectorBuilder.cs index 3cdf3bb2d..869d7e3e8 100644 --- a/Aaru.Decoders/CD/SectorBuilder.cs +++ b/Aaru.Decoders/CD/SectorBuilder.cs @@ -50,8 +50,7 @@ public class SectorBuilder _eccFTable[i] = (byte)j; _eccBTable[i ^ j] = (byte)i; - for(j = 0; j < 8; j++) - edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); + for(j = 0; j < 8; j++) edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); _edcTable[i] = edc; } @@ -120,8 +119,7 @@ public class SectorBuilder { int pos = srcOffset; - for(; size > 0; size--) - edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; + for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; return edc; } @@ -223,8 +221,7 @@ public class SectorBuilder byte temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; - if(idx >= size) - idx -= size; + if(idx >= size) idx -= size; eccA ^= temp; eccB ^= temp; diff --git a/Aaru.Decoders/CD/Session.cs b/Aaru.Decoders/CD/Session.cs index 8ce02683c..73373dad4 100644 --- a/Aaru.Decoders/CD/Session.cs +++ b/Aaru.Decoders/CD/Session.cs @@ -58,8 +58,7 @@ public static class Session public static CDSessionInfo? Decode(byte[] CDSessionInfoResponse) { - if(CDSessionInfoResponse is not { Length: > 4 }) - return null; + if(CDSessionInfoResponse is not { Length: > 4 }) return null; var decoded = new CDSessionInfo { @@ -73,9 +72,10 @@ public static class Session if(decoded.DataLength + 2 != CDSessionInfoResponse.Length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CDSessionInfo_size_0_bytes_is_not_received_size_1_bytes_not_decoding, - decoded.DataLength + 2, CDSessionInfoResponse.Length); + Localization + .Expected_CDSessionInfo_size_0_bytes_is_not_received_size_1_bytes_not_decoding, + decoded.DataLength + 2, + CDSessionInfoResponse.Length); return null; } @@ -97,8 +97,7 @@ public static class Session public static string Prettify(CDSessionInfo? CDSessionInfoResponse) { - if(CDSessionInfoResponse == null) - return null; + if(CDSessionInfoResponse == null) return null; CDSessionInfo response = CDSessionInfoResponse.Value; @@ -109,14 +108,15 @@ public static class Session foreach(TrackDataDescriptor descriptor in response.TrackDescriptors) { - sb.AppendFormat(Localization.First_track_number_in_last_complete_session_0, descriptor.TrackNumber). - AppendLine(); + sb.AppendFormat(Localization.First_track_number_in_last_complete_session_0, descriptor.TrackNumber) + .AppendLine(); - sb.AppendFormat(Localization.Track_starts_at_LBA_0_or_MSF_2_3, descriptor.TrackStartAddress, + sb.AppendFormat(Localization.Track_starts_at_LBA_0_or_MSF_2_3, + descriptor.TrackStartAddress, (descriptor.TrackStartAddress & 0x0000FF00) >> 8, (descriptor.TrackStartAddress & 0x00FF0000) >> 16, - (descriptor.TrackStartAddress & 0xFF000000) >> 24). - AppendLine(); + (descriptor.TrackStartAddress & 0xFF000000) >> 24) + .AppendLine(); switch((TocAdr)descriptor.ADR) { @@ -175,13 +175,13 @@ public static class Session ? Localization.Digital_copy_of_track_is_permitted : Localization.Digital_copy_of_track_is_prohibited); - #if DEBUG +#if DEBUG if(descriptor.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, descriptor.Reserved1).AppendLine(); if(descriptor.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, descriptor.Reserved2).AppendLine(); - #endif +#endif sb.AppendLine(); } diff --git a/Aaru.Decoders/CD/Subchannel.cs b/Aaru.Decoders/CD/Subchannel.cs index 24e679e4a..03490565f 100644 --- a/Aaru.Decoders/CD/Subchannel.cs +++ b/Aaru.Decoders/CD/Subchannel.cs @@ -352,8 +352,7 @@ public static class Subchannel ? Localization.Subchannel_PrettifyQ_copy_permitted : Localization.Subchannel_PrettifyQ_copy_prohibited; - if(bcd) - BcdToBinaryQ(subBuf); + if(bcd) BcdToBinaryQ(subBuf); int qPos = subBuf[3] * 60 * 75 + subBuf[4] * 75 + subBuf[5] - 150; byte pmin = subBuf[7]; @@ -374,23 +373,38 @@ public static class Subchannel switch(adr) { case 1 when subBuf[2] < 0xA0: - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_starts_at_14_15_16_LBA_17_Q_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - subBuf[3], subBuf[4], subBuf[5], qPos, subBuf[2], subBuf[7], subBuf[8], subBuf[9], - qStart, subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_starts_at_14_15_16_LBA_17_Q_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + qPos, + subBuf[2], + subBuf[7], + subBuf[8], + subBuf[9], + qStart, + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); case 1 when subBuf[2] == 0xA0: { string format = subBuf[8] switch @@ -401,141 +415,92 @@ public static class Subchannel _ => string.Format(Localization.Subchannel_PrettifyQ_unknown_0, subBuf[0]) }; - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_is_first_program_area_track_in_14_format_Q_CRC_15_16_17_R_W_18, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - subBuf[3], subBuf[4], subBuf[5], qPos, subBuf[2], format, subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_is_first_program_area_track_in_14_format_Q_CRC_15_16_17_R_W_18, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + qPos, + subBuf[2], + format, + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); } case 1 when subBuf[2] == 0xA1: - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_is_last_program_area_track_Q_CRC_14_15_16_R_W_17, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - subBuf[3], subBuf[4], subBuf[5], qPos, subBuf[2], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_is_last_program_area_track_Q_CRC_14_15_16_R_W_17, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + qPos, + subBuf[2], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); case 1: return subBuf[2] == 0xA2 - ? string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_starts_at_14_15_16_LBA_17_Q_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, - controlInfo, copy, - adr, subBuf[3], subBuf[4], subBuf[5], qPos, subBuf[2], subBuf[7], - subBuf[8], subBuf[9], qStart, subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty) - : string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, - controlInfo, copy, - subBuf[0], subBuf[1], subBuf[2], subBuf[3], subBuf[4], subBuf[5], - subBuf[6], subBuf[7], subBuf[8], subBuf[9], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); - case 2: - return - string.Format(Localization.Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_MCN_9_frame_10_CRC_11_12_13_R_W_14, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - DecodeMcn(subBuf), subBuf[9], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); - } - - if(adr != 5) - { - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - subBuf[0], - subBuf[1], subBuf[2], subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], - subBuf[8], subBuf[9], subBuf[10], subBuf[11], - crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); - } - - switch(subBuf[2]) - { - case <= 0x40: - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_skip_interval_start_time_9_10_11_skip_interval_stop_time_12_13_14_CRC_15_16_17_R_W_18, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - subBuf[7], subBuf[8], subBuf[9], subBuf[3], subBuf[4], subBuf[5], subBuf[10], - subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); - case 0xB0: - return final - ? string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_next_program_area_can_start_at_9_10_11_LBA_12_last_session_13_mode_5_pointers_CRC_14_15_16_R_W_17, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, - controlInfo, copy, - adr, subBuf[3], subBuf[4], subBuf[5], nextPos, zero, subBuf[10], + ? string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_9_10_11_LBA_12_track_13_starts_at_14_15_16_LBA_17_Q_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + qPos, + subBuf[2], + subBuf[7], + subBuf[8], + subBuf[9], + qStart, + subBuf[10], subBuf[11], crcOk ? Localization.Subchannel_PrettifyQ_OK @@ -543,16 +508,190 @@ public static class Subchannel rwEmpty ? Localization.Subchannel_PrettifyQ_empty : Localization.Subchannel_PrettifyQ_not_empty) - : string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_next_program_area_can_start_at_9_10_11_LBA_12_maximum_Lead_out_at_13_14_15_LBA_16_17_mode_5_pointers_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, - controlInfo, copy, - adr, subBuf[3], subBuf[4], subBuf[5], nextPos, subBuf[7], subBuf[8], - subBuf[9], maxOut, zero, subBuf[10], subBuf[11], + : string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); + case 2: + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_MCN_9_frame_10_CRC_11_12_13_R_W_14, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + DecodeMcn(subBuf), + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); + } + + if(adr != 5) + { + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); + } + + switch(subBuf[2]) + { + case <= 0x40: + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_skip_interval_start_time_9_10_11_skip_interval_stop_time_12_13_14_CRC_15_16_17_R_W_18, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); + case 0xB0: + return final + ? string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_next_program_area_can_start_at_9_10_11_LBA_12_last_session_13_mode_5_pointers_CRC_14_15_16_R_W_17, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + nextPos, + zero, + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty) + : string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_next_program_area_can_start_at_9_10_11_LBA_12_maximum_Lead_out_at_13_14_15_LBA_16_17_mode_5_pointers_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + nextPos, + subBuf[7], + subBuf[8], + subBuf[9], + maxOut, + zero, + subBuf[10], + subBuf[11], crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, @@ -560,53 +699,92 @@ public static class Subchannel ? Localization.Subchannel_PrettifyQ_empty : Localization.Subchannel_PrettifyQ_not_empty); case 0xB1: - return - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_9_skip_interval_pointers_10_skip_track_assignments_CRC_11_12_13_R_W_14, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, pmin, - psec, subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_9_skip_interval_pointers_10_skip_track_assignments_CRC_11_12_13_R_W_14, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + pmin, + psec, + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); } if(subBuf[2] != 0xB2 && subBuf[2] != 0xB3 && subBuf[2] != 0xB4) { return subBuf[2] == 0xC0 - ? string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_ATIP_values_9_10_11_first_disc_Lead_in_starts_at_12_13_14_LBA_15_CRC_16_17_18_R_W_19, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, - copy, adr, - subBuf[3], subBuf[4], subBuf[5], subBuf[7], subBuf[8], subBuf[9], qStart, - subBuf[10], subBuf[11], + ? string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_ATIP_values_9_10_11_first_disc_Lead_in_starts_at_12_13_14_LBA_15_CRC_16_17_18_R_W_19, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[7], + subBuf[8], + subBuf[9], + qStart, + subBuf[10], + subBuf[11], crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, rwEmpty ? Localization.Subchannel_PrettifyQ_empty : Localization.Subchannel_PrettifyQ_not_empty) - : string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, + : string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, copy, - subBuf[0], subBuf[1], subBuf[2], subBuf[3], subBuf[4], subBuf[5], subBuf[6], - subBuf[7], subBuf[8], subBuf[9], subBuf[10], subBuf[11], + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, @@ -617,33 +795,38 @@ public static class Subchannel var skipTracks = $"{subBuf[3]:X2}"; - if(subBuf[4] > 0) - skipTracks += $", {subBuf[4]:X2}"; + if(subBuf[4] > 0) skipTracks += $", {subBuf[4]:X2}"; - if(subBuf[5] > 0) - skipTracks += $", {subBuf[4]:X2}"; + if(subBuf[5] > 0) skipTracks += $", {subBuf[4]:X2}"; - if(subBuf[7] > 0) - skipTracks += $", {subBuf[4]:X2}"; + if(subBuf[7] > 0) skipTracks += $", {subBuf[4]:X2}"; - if(subBuf[8] > 0) - skipTracks += $", {subBuf[4]:X2}"; + if(subBuf[8] > 0) skipTracks += $", {subBuf[4]:X2}"; - if(subBuf[9] > 0) - skipTracks += $", {subBuf[4]:X2}"; + if(subBuf[9] > 0) skipTracks += $", {subBuf[4]:X2}"; - return - string.Format(Localization.Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_tracks_9_to_be_skipped_CRC_10_11_12_R_W_13, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, adr, - skipTracks, - subBuf[10], subBuf[11], - crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty); + return string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_tracks_9_to_be_skipped_CRC_10_11_12_R_W_13, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + skipTracks, + subBuf[10], + subBuf[11], + crcOk ? Localization.Subchannel_PrettifyQ_OK : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty); } area = subBuf[1] == 0xAA @@ -652,68 +835,121 @@ public static class Subchannel return adr switch { - 1 => - string.Format( - Localization. - Subchannel_PrettifyQ_0_D2_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_track_9_index_10_relative_position_11_12_13_LBA_14_absolute_position_15_16_17_LBA_18_Q_CRC_19_20_21_R_W_22, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - subBuf[1], subBuf[2], subBuf[3], subBuf[4], subBuf[5], qPos + 150, subBuf[7], - subBuf[8], subBuf[9], qStart, subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty), - 2 => - string.Format(Localization.Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_MCN_9_frame_10_CRC_11_12_13_R_W_14, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - DecodeMcn(subBuf), subBuf[9], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty), - 3 => - string.Format(Localization.Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_ISRC_9_frame_10_CRC_11_12_13_R_W_14, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - adr, - DecodeIsrc(subBuf), subBuf[9], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty), - _ => - string.Format( - Localization. - Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, - minute, second, frame, lba, area, - corruptedPause ? Localization.Subchannel_PrettifyQ_corrupted_pause : - pause ? Localization.Subchannel_PrettifyQ_pause : - Localization.Subchannel_PrettifyQ_not_pause, controlInfo, copy, - subBuf[0], - subBuf[1], subBuf[2], subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], - subBuf[8], subBuf[9], subBuf[10], subBuf[11], - crcOk - ? Localization.Subchannel_PrettifyQ_OK - : Localization.Subchannel_PrettifyQ_BAD, - rwEmpty - ? Localization.Subchannel_PrettifyQ_empty - : Localization.Subchannel_PrettifyQ_not_empty) + 1 => string.Format(Localization + .Subchannel_PrettifyQ_0_D2_1_2_LBA_3_4_area_5_6_7_Q_mode_8_position_track_9_index_10_relative_position_11_12_13_LBA_14_absolute_position_15_16_17_LBA_18_Q_CRC_19_20_21_R_W_22, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + qPos + 150, + subBuf[7], + subBuf[8], + subBuf[9], + qStart, + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty), + 2 => string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_MCN_9_frame_10_CRC_11_12_13_R_W_14, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + DecodeMcn(subBuf), + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty), + 3 => string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_mode_8_ISRC_9_frame_10_CRC_11_12_13_R_W_14, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + adr, + DecodeIsrc(subBuf), + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty), + _ => string.Format(Localization + .Subchannel_PrettifyQ_0_1_2_LBA_3_4_area_5_6_7_Q_8_9_10_11_12_13_14_15_16_17_CRC_18_19_20_R_W_21, + minute, + second, + frame, + lba, + area, + corruptedPause + ? Localization.Subchannel_PrettifyQ_corrupted_pause + : pause + ? Localization.Subchannel_PrettifyQ_pause + : Localization.Subchannel_PrettifyQ_not_pause, + controlInfo, + copy, + subBuf[0], + subBuf[1], + subBuf[2], + subBuf[3], + subBuf[4], + subBuf[5], + subBuf[6], + subBuf[7], + subBuf[8], + subBuf[9], + subBuf[10], + subBuf[11], + crcOk + ? Localization.Subchannel_PrettifyQ_OK + : Localization.Subchannel_PrettifyQ_BAD, + rwEmpty + ? Localization.Subchannel_PrettifyQ_empty + : Localization.Subchannel_PrettifyQ_not_empty) }; } @@ -767,8 +1003,7 @@ public static class Subchannel { bool isPregap = sector < 0 || sector <= trackStart + pregap; - if(index == 0) - index = (byte)(isPregap ? 0 : 1); + if(index == 0) index = (byte)(isPregap ? 0 : 1); var sub = new byte[96]; diff --git a/Aaru.Decoders/CD/TOC.cs b/Aaru.Decoders/CD/TOC.cs index 3fc61060a..5be62be66 100644 --- a/Aaru.Decoders/CD/TOC.cs +++ b/Aaru.Decoders/CD/TOC.cs @@ -61,8 +61,7 @@ public static class TOC public static CDTOC? Decode(byte[] CDTOCResponse) { - if(CDTOCResponse is not { Length: > 4 }) - return null; + if(CDTOCResponse is not { Length: > 4 }) return null; var decoded = new CDTOC { @@ -76,9 +75,10 @@ public static class TOC if(decoded.DataLength + 2 != CDTOCResponse.Length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding, - decoded.DataLength + 2, CDTOCResponse.Length); + Localization + .Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding, + decoded.DataLength + 2, + CDTOCResponse.Length); return null; } @@ -100,8 +100,7 @@ public static class TOC public static string Prettify(CDTOC? CDTOCResponse) { - if(CDTOCResponse == null) - return null; + if(CDTOCResponse == null) return null; CDTOC response = CDTOCResponse.Value; @@ -117,11 +116,12 @@ public static class TOC else sb.AppendFormat(Localization.Track_number_0, descriptor.TrackNumber).AppendLine(); - sb.AppendFormat(Localization.Track_starts_at_LBA_0_or_MSF_2_3, descriptor.TrackStartAddress, + sb.AppendFormat(Localization.Track_starts_at_LBA_0_or_MSF_2_3, + descriptor.TrackStartAddress, (descriptor.TrackStartAddress & 0x0000FF00) >> 8, (descriptor.TrackStartAddress & 0x00FF0000) >> 16, - (descriptor.TrackStartAddress & 0xFF000000) >> 24). - AppendLine(); + (descriptor.TrackStartAddress & 0xFF000000) >> 24) + .AppendLine(); switch((TocAdr)descriptor.ADR) { @@ -188,13 +188,13 @@ public static class TOC ? Localization.Digital_copy_of_track_is_permitted : Localization.Digital_copy_of_track_is_prohibited); - #if DEBUG +#if DEBUG if(descriptor.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, descriptor.Reserved1).AppendLine(); if(descriptor.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, descriptor.Reserved2).AppendLine(); - #endif +#endif sb.AppendLine(); } diff --git a/Aaru.Decoders/DVD/CSS&CPRM.cs b/Aaru.Decoders/DVD/CSS&CPRM.cs index 29d081304..cb0e0ad4c 100644 --- a/Aaru.Decoders/DVD/CSS&CPRM.cs +++ b/Aaru.Decoders/DVD/CSS&CPRM.cs @@ -60,8 +60,7 @@ public static class CSS_CPRM { public static LeadInCopyright? DecodeLeadInCopyright(byte[] response) { - if(response?.Length != 8) - return null; + if(response?.Length != 8) return null; return new LeadInCopyright { @@ -77,8 +76,7 @@ public static class CSS_CPRM public static RegionalPlaybackControlState? DecodeRegionalPlaybackControlState(byte[] response) { - if(response?.Length != 8) - return null; + if(response?.Length != 8) return null; return new RegionalPlaybackControlState { @@ -94,8 +92,7 @@ public static class CSS_CPRM public static string PrettifyRegionalPlaybackControlState(RegionalPlaybackControlState? rpc) { - if(rpc == null) - return null; + if(rpc == null) return null; RegionalPlaybackControlState decoded = rpc.Value; var sb = new StringBuilder(); @@ -121,8 +118,8 @@ public static class CSS_CPRM break; case TypeCode.Perm: - sb.AppendLine(Localization. - Drive_region_has_been_set_permanently_but_may_be_reset_by_the_vendor_if_necessary); + sb.AppendLine(Localization + .Drive_region_has_been_set_permanently_but_may_be_reset_by_the_vendor_if_necessary); break; } @@ -144,29 +141,21 @@ public static class CSS_CPRM { sb.Append(Localization.Drive_has_the_following_regions_set); - if((decoded.RegionMask & 0x01) != 0x01) - sb.Append(" 1"); + if((decoded.RegionMask & 0x01) != 0x01) sb.Append(" 1"); - if((decoded.RegionMask & 0x02) != 0x02) - sb.Append(" 2"); + if((decoded.RegionMask & 0x02) != 0x02) sb.Append(" 2"); - if((decoded.RegionMask & 0x04) != 0x04) - sb.Append(" 3"); + if((decoded.RegionMask & 0x04) != 0x04) sb.Append(" 3"); - if((decoded.RegionMask & 0x08) != 0x08) - sb.Append(" 4"); + if((decoded.RegionMask & 0x08) != 0x08) sb.Append(" 4"); - if((decoded.RegionMask & 0x10) != 0x10) - sb.Append(" 5"); + if((decoded.RegionMask & 0x10) != 0x10) sb.Append(" 5"); - if((decoded.RegionMask & 0x20) != 0x20) - sb.Append(" 6"); + if((decoded.RegionMask & 0x20) != 0x20) sb.Append(" 6"); - if((decoded.RegionMask & 0x40) != 0x40) - sb.Append(" 7"); + if((decoded.RegionMask & 0x40) != 0x40) sb.Append(" 7"); - if((decoded.RegionMask & 0x80) != 0x80) - sb.Append(" 8"); + if((decoded.RegionMask & 0x80) != 0x80) sb.Append(" 8"); break; } @@ -181,8 +170,8 @@ public static class CSS_CPRM break; case 0x01: - sb.AppendLine(Localization. - The_Logical_Unit_shall_adhere_to_the_specification_and_all_requirements_of_the_CSS_license_agreement_concerning_RPC); + sb.AppendLine(Localization + .The_Logical_Unit_shall_adhere_to_the_specification_and_all_requirements_of_the_CSS_license_agreement_concerning_RPC); break; default: @@ -199,8 +188,7 @@ public static class CSS_CPRM public static string PrettifyLeadInCopyright(LeadInCopyright? cmi) { - if(cmi == null) - return null; + if(cmi == null) return null; LeadInCopyright decoded = cmi.Value; var sb = new StringBuilder(); @@ -230,8 +218,7 @@ public static class CSS_CPRM break; } - if(decoded.CopyrightType == 0) - return sb.ToString(); + if(decoded.CopyrightType == 0) return sb.ToString(); switch(decoded.RegionInformation) { @@ -247,29 +234,21 @@ public static class CSS_CPRM { sb.Append(Localization.Disc_can_be_played_in_the_following_regions); - if((decoded.RegionInformation & 0x01) != 0x01) - sb.Append(" 1"); + if((decoded.RegionInformation & 0x01) != 0x01) sb.Append(" 1"); - if((decoded.RegionInformation & 0x02) != 0x02) - sb.Append(" 2"); + if((decoded.RegionInformation & 0x02) != 0x02) sb.Append(" 2"); - if((decoded.RegionInformation & 0x04) != 0x04) - sb.Append(" 3"); + if((decoded.RegionInformation & 0x04) != 0x04) sb.Append(" 3"); - if((decoded.RegionInformation & 0x08) != 0x08) - sb.Append(" 4"); + if((decoded.RegionInformation & 0x08) != 0x08) sb.Append(" 4"); - if((decoded.RegionInformation & 0x10) != 0x10) - sb.Append(" 5"); + if((decoded.RegionInformation & 0x10) != 0x10) sb.Append(" 5"); - if((decoded.RegionInformation & 0x20) != 0x20) - sb.Append(" 6"); + if((decoded.RegionInformation & 0x20) != 0x20) sb.Append(" 6"); - if((decoded.RegionInformation & 0x40) != 0x40) - sb.Append(" 7"); + if((decoded.RegionInformation & 0x40) != 0x40) sb.Append(" 7"); - if((decoded.RegionInformation & 0x80) != 0x80) - sb.Append(" 8"); + if((decoded.RegionInformation & 0x80) != 0x80) sb.Append(" 8"); break; } diff --git a/Aaru.Decoders/DVD/Cartridge.cs b/Aaru.Decoders/DVD/Cartridge.cs index 4e66e4704..456fc26bc 100644 --- a/Aaru.Decoders/DVD/Cartridge.cs +++ b/Aaru.Decoders/DVD/Cartridge.cs @@ -57,8 +57,7 @@ public static class Cartridge { public static MediumStatus? Decode(byte[] response) { - if(response?.Length != 8) - return null; + if(response?.Length != 8) return null; return new MediumStatus { @@ -80,24 +79,20 @@ public static class Cartridge public static string Prettify(MediumStatus? status) { - if(status == null) - return null; + if(status == null) return null; MediumStatus decoded = status.Value; var sb = new StringBuilder(); - if(decoded.PWP) - sb.AppendLine(Localization.Disc_surface_is_set_to_write_protected_status); + if(decoded.PWP) sb.AppendLine(Localization.Disc_surface_is_set_to_write_protected_status); if(decoded.Cartridge) { sb.AppendLine(Localization.Disc_comes_in_a_cartridge); - if(decoded.OUT) - sb.AppendLine(Localization.Disc_has_been_extracted_from_the_cartridge); + if(decoded.OUT) sb.AppendLine(Localization.Disc_has_been_extracted_from_the_cartridge); - if(decoded.CWP) - sb.AppendLine(Localization.Cartridge_is_set_to_write_protected); + if(decoded.CWP) sb.AppendLine(Localization.Cartridge_is_set_to_write_protected); } switch(decoded.DiscType) @@ -116,8 +111,7 @@ public static class Cartridge break; } - if(!decoded.MSWI) - return sb.ToString(); + if(!decoded.MSWI) return sb.ToString(); switch(decoded.RAMSWI) { @@ -132,8 +126,8 @@ public static class Cartridge break; default: - sb.AppendFormat(Localization.Disc_has_unknown_reason_0_for_write_inhibition, decoded.RAMSWI). - AppendLine(); + sb.AppendFormat(Localization.Disc_has_unknown_reason_0_for_write_inhibition, decoded.RAMSWI) + .AppendLine(); break; } diff --git a/Aaru.Decoders/DVD/DDS.cs b/Aaru.Decoders/DVD/DDS.cs index 0936f09dd..4cf962ce0 100644 --- a/Aaru.Decoders/DVD/DDS.cs +++ b/Aaru.Decoders/DVD/DDS.cs @@ -59,16 +59,14 @@ public static class DDS { public static DiscDefinitionStructure? Decode(byte[] response) { - if(response?.Length != 2052) - return null; + if(response?.Length != 2052) return null; var dds = new DiscDefinitionStructure { Identifier = (ushort)((response[4] << 8) + response[5]) }; - if(dds.Identifier != 0x0A0A) - return null; + if(dds.Identifier != 0x0A0A) return null; // Common to both DVD-RAM versions dds.DataLength = (ushort)((response[0] << 8) + response[1]); @@ -104,8 +102,7 @@ public static class DDS } // ECMA-330 - if(dds.Groups != 1) - return dds; + if(dds.Groups != 1) return dds; { dds.Reserved4 = (byte)((response[7] & 0x7C) >> 2); @@ -130,8 +127,7 @@ public static class DDS public static string Prettify(DiscDefinitionStructure? dds) { - if(dds == null) - return null; + if(dds == null) return null; DiscDefinitionStructure decoded = dds.Value; var sb = new StringBuilder(); @@ -145,16 +141,13 @@ public static class DDS if(decoded.PartialCertification) sb.AppendLine(Localization.Formatting_is_only_using_partial_certification); - if(decoded.FormattingOnlyAGroup) - sb.AppendLine(Localization.Only_a_group_is_being_formatted); + if(decoded.FormattingOnlyAGroup) sb.AppendLine(Localization.Only_a_group_is_being_formatted); } } - if(decoded.UserCertification) - sb.AppendLine(Localization.Disc_has_been_certified_by_a_user); + if(decoded.UserCertification) sb.AppendLine(Localization.Disc_has_been_certified_by_a_user); - if(decoded.ManufacturerCertification) - sb.AppendLine(Localization.Disc_has_been_certified_by_a_manufacturer); + if(decoded.ManufacturerCertification) sb.AppendLine(Localization.Disc_has_been_certified_by_a_manufacturer); sb.AppendFormat(Localization.DDS_has_been_updated_0_times, decoded.UpdateCount).AppendLine(); @@ -175,15 +168,15 @@ public static class DDS } } - if(decoded.Groups != 1) - return sb.ToString(); + if(decoded.Groups != 1) return sb.ToString(); { sb.AppendFormat(Localization.Disc_has_0_zones, decoded.Zones).AppendLine(); sb.AppendFormat(Localization.Primary_Spare_Area_stats_at_PSN_0_and_ends_at_PSN_1_inclusively, - decoded.SpareAreaFirstPSN, decoded.SpareAreaLastPSN). - AppendLine(); + decoded.SpareAreaFirstPSN, + decoded.SpareAreaLastPSN) + .AppendLine(); sb.AppendFormat(Localization.LSN_zero_is_at_PSN_0, decoded.LSN0Location).AppendLine(); diff --git a/Aaru.Decoders/DVD/PFI.cs b/Aaru.Decoders/DVD/PFI.cs index a43220d7c..f4982829c 100644 --- a/Aaru.Decoders/DVD/PFI.cs +++ b/Aaru.Decoders/DVD/PFI.cs @@ -76,8 +76,7 @@ public static class PFI { public static PhysicalFormatInformation? Decode(byte[] response, MediaType mediaType) { - if(response == null) - return null; + if(response == null) return null; if(response.Length == 2048) { @@ -86,8 +85,7 @@ public static class PFI response = tmp2; } - if(response.Length < 2052) - return null; + if(response.Length < 2052) return null; var pfi = new PhysicalFormatInformation(); byte[] tmp; @@ -141,15 +139,13 @@ public static class PFI case MediaType.DVDRDL: pfi.DiskCategory = DiskCategory.DVDR; - if(pfi.PartVersion < 6) - pfi.PartVersion = 6; + if(pfi.PartVersion < 6) pfi.PartVersion = 6; break; case MediaType.DVDR: pfi.DiskCategory = DiskCategory.DVDR; - if(pfi.PartVersion > 5) - pfi.PartVersion = 5; + if(pfi.PartVersion > 5) pfi.PartVersion = 5; break; case MediaType.DVDRAM: @@ -159,15 +155,13 @@ public static class PFI case MediaType.DVDRWDL: pfi.DiskCategory = DiskCategory.DVDRW; - if(pfi.PartVersion < 15) - pfi.PartVersion = 15; + if(pfi.PartVersion < 15) pfi.PartVersion = 15; break; case MediaType.DVDRW: pfi.DiskCategory = DiskCategory.DVDRW; - if(pfi.PartVersion > 14) - pfi.PartVersion = 14; + if(pfi.PartVersion > 14) pfi.PartVersion = 14; break; @@ -349,7 +343,9 @@ public static class PFI } // DVD+R, DVD+RW, DVD+R DL and DVD+RW DL - if(pfi.DiskCategory is DiskCategory.DVDPR or DiskCategory.DVDPRW or DiskCategory.DVDPRDL + if(pfi.DiskCategory is DiskCategory.DVDPR + or DiskCategory.DVDPRW + or DiskCategory.DVDPRDL or DiskCategory.DVDPRWDL) { pfi.VCPS |= (response[20] & 0x40) == 0x40; @@ -476,8 +472,7 @@ public static class PFI public static string Prettify(PhysicalFormatInformation? pfi) { - if(pfi == null) - return null; + if(pfi == null) return null; PhysicalFormatInformation decoded = pfi.Value; var sb = new StringBuilder(); @@ -492,8 +487,8 @@ public static class PFI switch(decoded.DiskCategory) { case DiskCategory.DVDROM: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-ROM", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-ROM", decoded.PartVersion) + .AppendLine(); switch(decoded.DiscSize) { @@ -509,8 +504,8 @@ public static class PFI break; case DiskCategory.DVDRAM: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RAM", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RAM", decoded.PartVersion) + .AppendLine(); switch(decoded.PartVersion) { @@ -528,13 +523,13 @@ public static class PFI case DiskCategory.DVDR: if(decoded.PartVersion >= 6) { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-R DL", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-R DL", decoded.PartVersion) + .AppendLine(); } else { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-R", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-R", decoded.PartVersion) + .AppendLine(); } switch(decoded.PartVersion) @@ -557,13 +552,13 @@ public static class PFI case DiskCategory.DVDRW: if(decoded.PartVersion >= 15) { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RW DL", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RW DL", decoded.PartVersion) + .AppendLine(); } else { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RW", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD-RW", decoded.PartVersion) + .AppendLine(); } switch(decoded.PartVersion) @@ -582,15 +577,19 @@ public static class PFI case DiskCategory.UMD: if(decoded.DiscSize == DVDSize.OneTwenty) { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, Localization._60mm, "UMD", - decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, + Localization._60mm, + "UMD", + decoded.PartVersion) + .AppendLine(); } else { - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, Localization.invalid_size, "UMD", - decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, + Localization.invalid_size, + "UMD", + decoded.PartVersion) + .AppendLine(); } switch(decoded.PartVersion) @@ -603,8 +602,8 @@ public static class PFI break; case DiskCategory.DVDPRW: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+RW", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+RW", decoded.PartVersion) + .AppendLine(); switch(decoded.PartVersion) { @@ -624,8 +623,8 @@ public static class PFI break; case DiskCategory.DVDPR: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+R", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+R", decoded.PartVersion) + .AppendLine(); switch(decoded.PartVersion) { @@ -637,8 +636,8 @@ public static class PFI break; case DiskCategory.DVDPRWDL: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+RW DL", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+RW DL", decoded.PartVersion) + .AppendLine(); switch(decoded.PartVersion) { @@ -650,8 +649,8 @@ public static class PFI break; case DiskCategory.DVDPRDL: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+R DL", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "DVD+R DL", decoded.PartVersion) + .AppendLine(); switch(decoded.PartVersion) { @@ -677,29 +676,31 @@ public static class PFI break; case DiskCategory.HDDVDROM: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-ROM", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-ROM", decoded.PartVersion) + .AppendLine(); break; case DiskCategory.HDDVDRAM: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-RAM", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-RAM", decoded.PartVersion) + .AppendLine(); break; case DiskCategory.HDDVDR: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-R", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-R", decoded.PartVersion) + .AppendLine(); break; case DiskCategory.HDDVDRW: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-RW", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, "HD DVD-RW", decoded.PartVersion) + .AppendLine(); break; default: - sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, sizeString, Localization.unknown_disc_type, - decoded.PartVersion). - AppendLine(); + sb.AppendFormat(Localization.Disc_is_a_0_1_version_2, + sizeString, + Localization.unknown_disc_type, + decoded.PartVersion) + .AppendLine(); break; } @@ -801,8 +802,8 @@ public static class PFI break; default: sb.AppendFormat(Localization.Disc_maximum_transfer_rate_is_specified_by_unknown_key_0, - decoded.MaximumRate). - AppendLine(); + decoded.MaximumRate) + .AppendLine(); break; } @@ -901,8 +902,7 @@ public static class PFI else sb.AppendLine(Localization.Disc_is_empty); - if(decoded.BCA) - sb.AppendLine(Localization.Disc_has_a_BCA); + if(decoded.BCA) sb.AppendLine(Localization.Disc_has_a_BCA); switch(decoded.DiskCategory) { @@ -930,36 +930,35 @@ public static class PFI if(decoded.PartVersion == 6) { sb.AppendFormat(Localization.Disc_manufacturer_is_0, - ManufacturerFromDVDRAM(decoded.DiskManufacturer)). - AppendLine(); + ManufacturerFromDVDRAM(decoded.DiskManufacturer)) + .AppendLine(); sb.AppendFormat(Localization.Disc_manufacturer_supplementary_information_is_0, - decoded.DiskManufacturerSupplementary). - AppendLine(); + decoded.DiskManufacturerSupplementary) + .AppendLine(); } break; case DiskCategory.DVDR when decoded.PartVersion < 6: case DiskCategory.DVDRW when decoded.PartVersion < 15: - sb.AppendFormat(Localization.Current_Border_Out_first_sector_is_PSN_0, decoded.CurrentBorderOutSector). - AppendLine(); + sb.AppendFormat(Localization.Current_Border_Out_first_sector_is_PSN_0, decoded.CurrentBorderOutSector) + .AppendLine(); - sb.AppendFormat(Localization.Next_Border_In_first_sector_is_PSN_0, decoded.NextBorderInSector). - AppendLine(); + sb.AppendFormat(Localization.Next_Border_In_first_sector_is_PSN_0, decoded.NextBorderInSector) + .AppendLine(); break; case DiskCategory.DVDPR: case DiskCategory.DVDPRW: case DiskCategory.DVDPRDL: case DiskCategory.DVDPRWDL: - if(decoded.VCPS) - sb.AppendLine(Localization.Disc_contains_extended_information_for_VCPS); + if(decoded.VCPS) sb.AppendLine(Localization.Disc_contains_extended_information_for_VCPS); sb.AppendFormat(Localization.Disc_application_code_0, decoded.ApplicationCode).AppendLine(); sb.AppendFormat(Localization.Disc_manufacturer_is_0, - ManufacturerFromDVDPlusID(decoded.DiskManufacturerID)). - AppendLine(); + ManufacturerFromDVDPlusID(decoded.DiskManufacturerID)) + .AppendLine(); sb.AppendFormat(Localization.Disc_media_type_is_0, decoded.MediaTypeID).AppendLine(); sb.AppendFormat(Localization.Disc_product_revision_is_0, decoded.ProductRevision).AppendLine(); @@ -971,20 +970,16 @@ public static class PFI (decoded.DiskCategory != DiskCategory.DVDRW || decoded.PartVersion < 15)) return sb.ToString(); - sb.AppendFormat(Localization.Current_RMD_in_extra_Border_zone_starts_at_PSN_0, - decoded.CurrentRMDExtraBorderPSN). - AppendLine(); + sb.AppendFormat(Localization.Current_RMD_in_extra_Border_zone_starts_at_PSN_0, decoded.CurrentRMDExtraBorderPSN) + .AppendLine(); sb.AppendFormat(Localization.PFI_in_extra_Border_zone_starts_at_PSN_0, decoded.PFIExtraBorderPSN).AppendLine(); - if(!decoded.PreRecordedControlDataInv) - sb.AppendLine(Localization.Control_Data_Zone_is_pre_recorded); + if(!decoded.PreRecordedControlDataInv) sb.AppendLine(Localization.Control_Data_Zone_is_pre_recorded); - if(decoded.PreRecordedLeadIn) - sb.AppendLine(Localization.Lead_In_is_pre_recorded); + if(decoded.PreRecordedLeadIn) sb.AppendLine(Localization.Lead_In_is_pre_recorded); - if(decoded.PreRecordedLeadOut) - sb.AppendLine(Localization.Lead_Out_is_pre_recorded); + if(decoded.PreRecordedLeadOut) sb.AppendLine(Localization.Lead_Out_is_pre_recorded); return sb.ToString(); } @@ -1182,7 +1177,7 @@ public static class PFI /// Byte 3 Reserved public byte Reserved2; - #region PFI common to all +#region PFI common to all /// Byte 4, bits 7 to 4 Disk category field public DiskCategory DiskCategory; @@ -1218,23 +1213,23 @@ public static class PFI /// Byte 20, bits 6 to 0 Reserved public byte Reserved4; - #endregion PFI common to all +#endregion PFI common to all - #region UMD PFI +#region UMD PFI /// Bytes 21 to 22 UMD only, media attribute, application-defined, part of media specific in rest of discs public ushort MediaAttribute; - #endregion UMD PFI +#endregion UMD PFI - #region DVD-RAM PFI +#region DVD-RAM PFI /// Byte 36 Disc type, respecting case recordability public DVDRAMDiscType DiscType; - #endregion DVD-RAM PFI +#endregion DVD-RAM PFI - #region DVD-RAM PFI, Version 0001b +#region DVD-RAM PFI, Version 0001b /// Byte 52 Byte 504 in Version 0110b Linear velocity, in tenths of m/s public byte Velocity; @@ -1273,18 +1268,18 @@ public static class PFI /// Byte 69 Bias power duration for recording on groove tracks public byte BiasPowerDurationGroove; - #endregion DVD-RAM PFI, Version 0001b +#endregion DVD-RAM PFI, Version 0001b - #region DVD-R PFI, DVD-RW PFI +#region DVD-R PFI, DVD-RW PFI /// Bytes 36 to 39 Sector number of the first sector of the current Border Out public uint CurrentBorderOutSector; /// Bytes 40 to 43 Sector number of the first sector of the next Border In public uint NextBorderInSector; - #endregion DVD-R PFI, DVD-RW PFI +#endregion DVD-R PFI, DVD-RW PFI - #region DVD+RW PFI +#region DVD+RW PFI /// Byte 36 Linear velocities 0 = CLV from 4,90 m/s to 6,25 m/s 1 = CAV from 3,02 m/s to 7,35 m/s public byte RecordingVelocity; @@ -1325,9 +1320,9 @@ public static class PFI /// Byte 54 Target value for γ, γtarget at the minimum velocity public byte YTargetMinVelocity; - #endregion DVD+RW PFI +#endregion DVD+RW PFI - #region DVD-RAM PFI, version 0110b +#region DVD-RAM PFI, version 0110b /// Byte 506, bit 7 Mode of adaptative write pulse control public bool AdaptativeWritePulseControlFlag; @@ -1436,9 +1431,9 @@ public static class PFI /// Byte 627 Ratio of peak power for groove tracks to threshold 6T peak power for groove tracks public byte PowerRatioGrooveThreshold6T; - #endregion DVD-RAM PFI, version 0110b +#endregion DVD-RAM PFI, version 0110b - #region DVD+RW PFI, DVD+R PFI, DVD+R DL PFI and DVD+RW DL PFI +#region DVD+RW PFI, DVD+R PFI, DVD+R DL PFI and DVD+RW DL PFI /// Byte 20, bit 6 If set indicates data zone contains extended information for VCPS public bool VCPS; @@ -1455,9 +1450,9 @@ public static class PFI /// Byte 35 Indicates how many bytes, up to 63, are used in ADIP's PFI public byte PFIUsedInADIP; - #endregion DVD+RW PFI, DVD+R PFI, DVD+R DL PFI and DVD+RW DL PFI +#endregion DVD+RW PFI, DVD+R PFI, DVD+R DL PFI and DVD+RW DL PFI - #region DVD+RW PFI, version 0010b +#region DVD+RW PFI, version 0010b /// Byte 55 Ttop first pulse duration public byte TopFirstPulseDuration; @@ -1470,9 +1465,9 @@ public static class PFI /// Byte 59 dTera erase lead time at upper velocity public byte EraseLeadTimeUppVelocity; - #endregion DVD+RW PFI, version 0010b +#endregion DVD+RW PFI, version 0010b - #region DVD+R PFI version 0001b and DVD+R DL PFI version 0001b +#region DVD+R PFI version 0001b and DVD+R DL PFI version 0001b /// Byte 36 Primary recording velocity for the basic write strategy public byte PrimaryVelocity; @@ -1523,16 +1518,16 @@ public static class PFI /// Byte 59 dTle first pulse leading edge shift for ps∗ =3T at Upper velocity public byte FirstPulseLeadingEdgeUpperVelocity; - #endregion DVD+R PFI version 0001b and DVD+R DL PFI version 0001b +#endregion DVD+R PFI version 0001b and DVD+R DL PFI version 0001b - #region DVD+R DL PFI version 0001b +#region DVD+R DL PFI version 0001b /// Byte 34, bits 7 to 6 public DVDLayerStructure LayerStructure; - #endregion DVD+R DL PFI version 0001b +#endregion DVD+R DL PFI version 0001b - #region DVD+RW DL PFI +#region DVD+RW DL PFI /// Byte 36 Primary recording velocity for the basic write strategy public byte BasicPrimaryVelocity; @@ -1571,9 +1566,9 @@ public static class PFI /// Byte 55 dTera,4 erase lead/lag time when preceding mark length = 4T public byte ErasePulseLeadTime4T; - #endregion DVD+RW DL PFI +#endregion DVD+RW DL PFI - #region DVD-R DL PFI and DVD-RW DL PFI +#region DVD-R DL PFI and DVD-RW DL PFI /// Byte 21 Maximum recording speed public DVDRecordingSpeed MaxRecordingSpeed; @@ -1612,7 +1607,7 @@ public static class PFI /// Byte 45 bits 4 to 7 Tracking polarity on Layer 1 public byte TrackPolarityLayer1; - #endregion DVD-R DL PFI and DVD-RW DL PFI +#endregion DVD-R DL PFI and DVD-RW DL PFI public DiskCategory RecordedBookType; } diff --git a/Aaru.Decoders/DVD/PRI.cs b/Aaru.Decoders/DVD/PRI.cs index 8285d1caa..0e6840312 100644 --- a/Aaru.Decoders/DVD/PRI.cs +++ b/Aaru.Decoders/DVD/PRI.cs @@ -58,11 +58,9 @@ public static class PRI { public static PreRecordedInformation? Decode(byte[] response) { - if(response == null) - return null; + if(response == null) return null; - if(response.Length < 67) - return null; + if(response.Length < 67) return null; var pri = new PreRecordedInformation { @@ -126,8 +124,7 @@ public static class PRI public static string Prettify(PreRecordedInformation? pri) { - if(pri == null) - return null; + if(pri == null) return null; PreRecordedInformation decoded = pri.Value; var sb = new StringBuilder(); @@ -138,8 +135,8 @@ public static class PRI if((decoded.DiscApplicationCode & 0x3F) > 0) { - sb.AppendFormat(Localization.Invalid_purpose_field_with_value_0, decoded.DiscApplicationCode & 0x3F). - AppendLine(); + sb.AppendFormat(Localization.Invalid_purpose_field_with_value_0, decoded.DiscApplicationCode & 0x3F) + .AppendLine(); } else sb.AppendLine(Localization.Consumer_purpose_disc_for_use_in_consumer_purpose_drives); @@ -151,8 +148,8 @@ public static class PRI if((decoded.DiscApplicationCode & 0x3F) > 0) { sb.AppendFormat(Localization.Disc_for_use_in_special_drives_according_with_purpose_value_0, - decoded.DiscApplicationCode & 0x3F). - AppendLine(); + decoded.DiscApplicationCode & 0x3F) + .AppendLine(); } else sb.AppendLine(Localization.General_purpose_disc_for_use_in_general_purpose_drives); @@ -186,11 +183,10 @@ public static class PRI ? Localization.Wavelength_is_650nm : Localization.Unknown_wavelength); - sb.AppendFormat(Localization.Last_writable_ECC_block_address_0_X6_, decoded.LastAddressOfDataRecordableArea). - AppendLine(); + sb.AppendFormat(Localization.Last_writable_ECC_block_address_0_X6_, decoded.LastAddressOfDataRecordableArea) + .AppendLine(); - if(decoded.PartVersion > 0) - sb.AppendFormat(Localization.Part_version_0, decoded.PartVersion).AppendLine(); + if(decoded.PartVersion > 0) sb.AppendFormat(Localization.Part_version_0, decoded.PartVersion).AppendLine(); bool rw = (decoded.DiscPhysicalCode & 0x02) > 0; @@ -302,8 +298,8 @@ public static class PRI } } - sb.AppendFormat(Localization.Disc_manufacturer_is_0, ManufacturerFromPrePit(decoded.ManufacturerId)). - AppendLine(); + sb.AppendFormat(Localization.Disc_manufacturer_is_0, ManufacturerFromPrePit(decoded.ManufacturerId)) + .AppendLine(); return sb.ToString(); } @@ -387,9 +383,8 @@ public static class PRI manufacturer = "Megan Media Holdings Berhad"; else if(manufacturerId.StartsWith("DKM", StringComparison.Ordinal) || manufacturerId.StartsWith("EDMA", StringComparison.Ordinal)) - manufacturer = "E-TOP Mediatek Inc."; - else if(manufacturerId.StartsWith("BeAll", StringComparison.Ordinal)) - manufacturer = "BeALL Developers, Inc."; + manufacturer = "E-TOP Mediatek Inc."; + else if(manufacturerId.StartsWith("BeAll", StringComparison.Ordinal)) manufacturer = "BeALL Developers, Inc."; return manufacturer != "" ? $"{manufacturer} (\"{manufacturerId}\")" : $"\"{manufacturerId}\""; } diff --git a/Aaru.Decoders/DVD/Sector.cs b/Aaru.Decoders/DVD/Sector.cs index a7b4c749b..3e98922dc 100644 --- a/Aaru.Decoders/DVD/Sector.cs +++ b/Aaru.Decoders/DVD/Sector.cs @@ -104,8 +104,7 @@ public sealed class Sector { byte ret = 0; - for(var i = 0; i < 8; i++) - ret = (byte)(ret << 1 | LfsrTick()); + for(var i = 0; i < 8; i++) ret = (byte)(ret << 1 | LfsrTick()); return ret; } @@ -122,8 +121,7 @@ public sealed class Sector LfsrInit(seed); - for(i = 0; i < 2048; i++) - cypher[i] = LfsrByte(); + for(i = 0; i < 2048; i++) cypher[i] = LfsrByte(); _seeds.Add(seed, cypher); @@ -134,8 +132,7 @@ public sealed class Sector { var pos = 0; - for(; size > 0; size--) - edc = _edcTable[(edc >> 24 ^ src[pos++]) & 0xFF] ^ edc << 8; + for(; size > 0; size--) edc = _edcTable[(edc >> 24 ^ src[pos++]) & 0xFF] ^ edc << 8; return edc; } @@ -153,8 +150,7 @@ public sealed class Sector LfsrInit(seed); - for(var i = 12; i < 2060; i++) - tmp[i] ^= LfsrByte(); + for(var i = 12; i < 2060; i++) tmp[i] ^= LfsrByte(); return ComputeEdc(0, tmp, 2060) == BigEndianBitConverter.ToUInt32(sector, 2060); } @@ -167,8 +163,7 @@ public sealed class Sector byte[]? GetSeed(byte[] sector) { // Try the last used key - if(TestSeed(sector, _lastSeed)) - return _seeds[_lastSeed]; + if(TestSeed(sector, _lastSeed)) return _seeds[_lastSeed]; // Try the cached keys foreach(ushort seedsKey in _seeds.Keys.Where(seedsKey => TestSeed(sector, seedsKey))) @@ -189,8 +184,7 @@ public sealed class Sector // Brute force all other keys for(ushort i = 0; i < 0x7FFF; i++) { - if(!TestSeed(sector, i)) - continue; + if(!TestSeed(sector, i)) continue; _lastSeed = i; @@ -212,8 +206,7 @@ public sealed class Sector scrambled = new byte[sector.Length]; Array.Copy(sector, 0, scrambled, 0, sector.Length); - for(var i = 0; i < 2048; i++) - scrambled[i + 12] = (byte)(sector[i + 12] ^ cipher[i]); + for(var i = 0; i < 2048; i++) scrambled[i + 12] = (byte)(sector[i + 12] ^ cipher[i]); return ComputeEdc(0, scrambled, 2060) != BigEndianBitConverter.ToUInt32(sector, 2060) ? ErrorNumber.NotVerifiable @@ -224,8 +217,7 @@ public sealed class Sector { scrambled = new byte[sector.Length]; - if(sector is not { Length: 2064 }) - return ErrorNumber.NotSupported; + if(sector is not { Length: 2064 }) return ErrorNumber.NotSupported; byte[]? cipher = GetSeed(sector); @@ -236,15 +228,13 @@ public sealed class Sector { scrambled = new byte[sector.Length]; - if(sector.Length % 2064 != 0 || sector.Length / 2064 != transferLength) - return ErrorNumber.NotSupported; + if(sector.Length % 2064 != 0 || sector.Length / 2064 != transferLength) return ErrorNumber.NotSupported; for(uint i = 0; i < transferLength; i++) { ErrorNumber error = Scramble(sector.Skip((int)(i * 2064)).Take(2064).ToArray(), out byte[]? currentSector); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; Array.Copy(currentSector, 0, scrambled, i * 2064, 2064); } diff --git a/Aaru.Decoders/DVD/Spare.cs b/Aaru.Decoders/DVD/Spare.cs index 74e64cb05..d1dcf6225 100644 --- a/Aaru.Decoders/DVD/Spare.cs +++ b/Aaru.Decoders/DVD/Spare.cs @@ -56,8 +56,7 @@ public static class Spare { public static SpareAreaInformation? Decode(byte[] response) { - if(response?.Length != 16) - return null; + if(response?.Length != 16) return null; return new SpareAreaInformation { @@ -74,19 +73,18 @@ public static class Spare public static string Prettify(SpareAreaInformation? sai) { - if(sai == null) - return null; + if(sai == null) return null; SpareAreaInformation decoded = sai.Value; var sb = new StringBuilder(); sb.AppendFormat(Localization._0_unused_primary_spare_blocks, decoded.UnusedPrimaryBlocks).AppendLine(); - sb.AppendFormat(Localization._0_unused_supplementary_spare_blocks, decoded.UnusedSupplementaryBlocks). - AppendLine(); + sb.AppendFormat(Localization._0_unused_supplementary_spare_blocks, decoded.UnusedSupplementaryBlocks) + .AppendLine(); - sb.AppendFormat(Localization._0_allocated_supplementary_spare_blocks, decoded.AllocatedSupplementaryBlocks). - AppendLine(); + sb.AppendFormat(Localization._0_allocated_supplementary_spare_blocks, decoded.AllocatedSupplementaryBlocks) + .AppendLine(); return sb.ToString(); } diff --git a/Aaru.Decoders/Floppy/Apple2.cs b/Aaru.Decoders/Floppy/Apple2.cs index d81a6435d..7126075d2 100644 --- a/Aaru.Decoders/Floppy/Apple2.cs +++ b/Aaru.Decoders/Floppy/Apple2.cs @@ -156,8 +156,7 @@ public static class Apple2 /// 5and3 encoded data. public static byte[] Decode5and3(byte[] data) { - if(data is not { Length: 410 }) - return null; + if(data is not { Length: 410 }) return null; var buffer = new byte[data.Length]; byte carry = 0; @@ -193,8 +192,7 @@ public static class Apple2 /// 6and2 encoded data. public static byte[] Decode6and2(byte[] data) { - if(data is not { Length: 342 }) - return null; + if(data is not { Length: 342 }) return null; var buffer = new byte[data.Length]; byte carry = 0; @@ -236,12 +234,10 @@ public static class Apple2 public static byte[] DecodeSector(RawSector sector) { - if(sector.addressField.prologue[0] != 0xD5 || sector.addressField.prologue[1] != 0xAA) - return null; + if(sector.addressField.prologue[0] != 0xD5 || sector.addressField.prologue[1] != 0xAA) return null; // Pre DOS 3.3 - if(sector.addressField.prologue[2] == 0xB5) - return Decode5and3(sector.dataField.data); + if(sector.addressField.prologue[2] == 0xB5) return Decode5and3(sector.dataField.data); // DOS 3.3 return sector.addressField.prologue[2] == 0x96 ? Decode6and2(sector.dataField.data) : null; @@ -258,8 +254,7 @@ public static class Apple2 endOffset = offset; // Not an Apple ][ GCR sector - if(data == null || data.Length < 363) - return null; + if(data == null || data.Length < 363) return null; int position = offset; @@ -273,8 +268,7 @@ public static class Apple2 AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Prologue_found_at_0, position); // Epilogue not in correct position - if(data[position + 11] != 0xDE || data[position + 12] != 0xAA) - return null; + if(data[position + 11] != 0xDE || data[position + 12] != 0xAA) return null; var sector = new RawSector { @@ -307,28 +301,34 @@ public static class Apple2 } }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Volume_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Volume_0, ((sector.addressField.volume[0] & 0x55) << 1 | sector.addressField.volume[1] & 0x55) & 0xFF); - AaruConsole.DebugWriteLine(MODULE_NAME, Core.Track_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Core.Track_0, ((sector.addressField.track[0] & 0x55) << 1 | sector.addressField.track[1] & 0x55) & 0xFF); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Sector_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Sector_0, ((sector.addressField.sector[0] & 0x55) << 1 | sector.addressField.sector[1] & 0x55) & 0xFF); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Checksum_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Checksum_0, ((sector.addressField.checksum[0] & 0x55) << 1 | sector.addressField.checksum[1] & 0x55) & 0xFF); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Epilogue_0_1_2, - sector.addressField.epilogue[0], sector.addressField.epilogue[1], + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Epilogue_0_1_2, + sector.addressField.epilogue[0], + sector.addressField.epilogue[1], sector.addressField.epilogue[2]); position += 14; @@ -345,12 +345,10 @@ public static class Apple2 } // Lost sync - if(!onSync) - return null; + if(!onSync) return null; // Prologue not found - if(data[position] != 0xD5 || data[position + 1] != 0xAA) - return null; + if(data[position] != 0xD5 || data[position + 1] != 0xAA) return null; sector.innerGap = gaps.ToArray(); sector.dataField = new RawDataField(); @@ -373,13 +371,13 @@ public static class Apple2 position++; // No space left for epilogue - if(position + 4 > data.Length) - return null; + if(position + 4 > data.Length) return null; } sector.dataField.data = gaps.ToArray(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Data_has_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Data_has_0_bytes, sector.dataField.data.Length); sector.dataField.checksum = data[position]; @@ -435,8 +433,7 @@ public static class Apple2 public static byte[] MarshalAddressField(RawAddressField addressField) { - if(addressField == null) - return null; + if(addressField == null) return null; var raw = new MemoryStream(); raw.Write(addressField.prologue, 0, addressField.prologue.Length); @@ -451,8 +448,7 @@ public static class Apple2 public static byte[] MarshalSector(RawSector sector) { - if(sector == null) - return null; + if(sector == null) return null; var raw = new MemoryStream(); raw.Write(sector.addressField.prologue, 0, sector.addressField.prologue.Length); @@ -492,19 +488,16 @@ public static class Apple2 onSync = count >= 5; } - if(position >= data.Length) - return null; + if(position >= data.Length) return null; - if(!onSync) - return null; + if(!onSync) return null; while(position < data.Length) { int oldPosition = position; RawSector sector = MarshalSector(data, out position, position); - if(sector == null) - break; + if(sector == null) break; if(firstSector) { @@ -520,7 +513,8 @@ public static class Apple2 break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Adding_sector_0_of_track_1, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Adding_sector_0_of_track_1, ((sector.addressField.sector[0] & 0x55) << 1 | sector.addressField.sector[1] & 0x55) & 0xFF, @@ -531,8 +525,7 @@ public static class Apple2 sectors.Add(sector); } - if(sectors.Count == 0) - return null; + if(sectors.Count == 0) return null; var track = new RawTrack { @@ -547,14 +540,12 @@ public static class Apple2 public static byte[] MarshalTrack(RawTrack track) { - if(track == null) - return null; + if(track == null) return null; var raw = new MemoryStream(); raw.Write(track.gap, 0, track.gap.Length); - foreach(byte[] rawSector in track.sectors.Select(MarshalSector)) - raw.Write(rawSector, 0, rawSector.Length); + foreach(byte[] rawSector in track.sectors.Select(MarshalSector)) raw.Write(rawSector, 0, rawSector.Length); return raw.ToArray(); } @@ -576,8 +567,7 @@ public static class Apple2 track = MarshalTrack(data, out position, position); } - if(tracks.Count == 0) - return null; + if(tracks.Count == 0) return null; endOffset = position; @@ -588,13 +578,11 @@ public static class Apple2 public static byte[] MarshalDisk(RawTrack[] disk) { - if(disk == null) - return null; + if(disk == null) return null; var raw = new MemoryStream(); - foreach(byte[] rawTrack in disk.Select(MarshalTrack)) - raw.Write(rawTrack, 0, rawTrack.Length); + foreach(byte[] rawTrack in disk.Select(MarshalTrack)) raw.Write(rawTrack, 0, rawTrack.Length); return raw.ToArray(); } diff --git a/Aaru.Decoders/Floppy/AppleSony.cs b/Aaru.Decoders/Floppy/AppleSony.cs index 9fd83edf0..f2a09ecd0 100644 --- a/Aaru.Decoders/Floppy/AppleSony.cs +++ b/Aaru.Decoders/Floppy/AppleSony.cs @@ -74,8 +74,7 @@ public static class AppleSony byte w1 = nib_data[j++]; byte w2 = nib_data[j++]; - if(i != 174) - w3 = nib_data[j++]; + if(i != 174) w3 = nib_data[j++]; bf1[i] = (byte)((w1 & 0x3F | w4 << 2 & 0xC0) & 0x0F); bf2[i] = (byte)((w2 & 0x3F | w4 << 4 & 0xC0) & 0x0F); @@ -91,8 +90,7 @@ public static class AppleSony { ck1 = (ck1 & 0xFF) << 1; - if((ck1 & 0x0100) > 0) - ck1++; + if((ck1 & 0x0100) > 0) ck1++; var carry = (byte)((bf1[j] ^ ck1) & 0xFF); ck3 += carry; @@ -116,8 +114,7 @@ public static class AppleSony ms.WriteByte(carry); - if(ms.Length == 524) - break; + if(ms.Length == 524) break; carry = (byte)((bf3[j] ^ ck2) & 0xFF); ck1 += carry; @@ -144,8 +141,7 @@ public static class AppleSony endOffset = offset; // Not an Apple ][ GCR sector - if(data == null || data.Length < 363) - return null; + if(data == null || data.Length < 363) return null; int position = offset; @@ -157,8 +153,7 @@ public static class AppleSony if(data[position] == 0xD5 && data[position + 1] == 0xAA && data[position + 2] == 0x96) { // Epilogue not in correct position - if(data[position + 8] != 0xDE || data[position + 9] != 0xAA) - return null; + if(data[position + 8] != 0xDE || data[position + 9] != 0xAA) return null; var sector = new RawSector { @@ -194,12 +189,10 @@ public static class AppleSony } // Lost sync - if(!onSync) - return null; + if(!onSync) return null; // Prologue not found - if(data[position] != 0xDE || data[position + 1] != 0xAA || data[position + 2] != 0xAD) - return null; + if(data[position] != 0xDE || data[position + 1] != 0xAA || data[position + 2] != 0xAD) return null; sector.innerGap = gaps.ToArray(); @@ -223,8 +216,7 @@ public static class AppleSony position++; // No space left for epilogue - if(position + 7 > data.Length) - return null; + if(position + 7 > data.Length) return null; } sector.dataField.data = gaps.ToArray(); @@ -280,8 +272,7 @@ public static class AppleSony public static byte[] MarshalAddressField(RawAddressField addressField) { - if(addressField == null) - return null; + if(addressField == null) return null; var raw = new MemoryStream(); raw.Write(addressField.prologue, 0, addressField.prologue.Length); @@ -296,8 +287,7 @@ public static class AppleSony public static byte[] MarshalSector(RawSector sector) { - if(sector == null) - return null; + if(sector == null) return null; var raw = new MemoryStream(); raw.Write(sector.addressField.prologue, 0, sector.addressField.prologue.Length); @@ -339,19 +329,16 @@ public static class AppleSony onSync = count >= 5; } - if(position >= data.Length) - return null; + if(position >= data.Length) return null; - if(!onSync) - return null; + if(!onSync) return null; while(position < data.Length) { int oldPosition = position; RawSector sector = MarshalSector(data, out position, position); - if(sector == null) - break; + if(sector == null) break; if(firstSector) { @@ -370,8 +357,7 @@ public static class AppleSony sectors.Add(sector); } - if(sectors.Count == 0) - return null; + if(sectors.Count == 0) return null; var track = new RawTrack { @@ -386,14 +372,12 @@ public static class AppleSony public static byte[] MarshalTrack(RawTrack track) { - if(track == null) - return null; + if(track == null) return null; var raw = new MemoryStream(); raw.Write(track.gap, 0, track.gap.Length); - foreach(byte[] rawSector in track.sectors.Select(MarshalSector)) - raw.Write(rawSector, 0, rawSector.Length); + foreach(byte[] rawSector in track.sectors.Select(MarshalSector)) raw.Write(rawSector, 0, rawSector.Length); return raw.ToArray(); } @@ -414,8 +398,7 @@ public static class AppleSony track = MarshalTrack(data, out position, position); } - if(tracks.Count == 0) - return null; + if(tracks.Count == 0) return null; endOffset = position; @@ -426,13 +409,11 @@ public static class AppleSony public static byte[] MarshalDisk(RawTrack[] disk) { - if(disk == null) - return null; + if(disk == null) return null; var raw = new MemoryStream(); - foreach(byte[] rawTrack in disk.Select(MarshalTrack)) - raw.Write(rawTrack, 0, rawTrack.Length); + foreach(byte[] rawTrack in disk.Select(MarshalTrack)) raw.Write(rawTrack, 0, rawTrack.Length); return raw.ToArray(); } diff --git a/Aaru.Decoders/LisaTag.cs b/Aaru.Decoders/LisaTag.cs index e27920950..eedd76eb2 100644 --- a/Aaru.Decoders/LisaTag.cs +++ b/Aaru.Decoders/LisaTag.cs @@ -48,8 +48,7 @@ public static class LisaTag /// Decoded tag in Sony's format public static SonyTag? DecodeSonyTag(byte[] tag) { - if(tag is not { Length: 12 }) - return null; + if(tag is not { Length: 12 }) return null; var snTag = new SonyTag { @@ -74,8 +73,7 @@ public static class LisaTag /// Decoded tag in Profile's format public static ProfileTag? DecodeProfileTag(byte[] tag) { - if(tag is not { Length: 20 }) - return null; + if(tag is not { Length: 20 }) return null; var phTag = new ProfileTag(); @@ -121,8 +119,7 @@ public static class LisaTag /// Decoded tag in Priam's format public static PriamTag? DecodePriamTag(byte[] tag) { - if(tag is not { Length: 24 }) - return null; + if(tag is not { Length: 24 }) return null; var pmTag = new PriamTag(); @@ -170,8 +167,7 @@ public static class LisaTag /// Decoded tag in Priam's format public static PriamTag? DecodeTag(byte[] tag) { - if(tag == null) - return null; + if(tag == null) return null; PriamTag pmTag; @@ -180,8 +176,7 @@ public static class LisaTag case 12: SonyTag? snTag = DecodeSonyTag(tag); - if(snTag == null) - return null; + if(snTag == null) return null; pmTag = new PriamTag { @@ -206,8 +201,7 @@ public static class LisaTag case 20: ProfileTag? phTag = DecodeProfileTag(tag); - if(phTag == null) - return null; + if(phTag == null) return null; pmTag = new PriamTag { @@ -319,8 +313,7 @@ public static class LisaTag tmp = BigEndianBitConverter.GetBytes((ushort)(UsedBytes & 0x7FFF)); Array.Copy(tmp, 0, tagBytes, 6, 2); - if(ValidChk) - tagBytes[6] += 0x80; + if(ValidChk) tagBytes[6] += 0x80; tmp = BigEndianBitConverter.GetBytes(AbsPage); Array.Copy(tmp, 1, tagBytes, 8, 3); @@ -421,8 +414,7 @@ public static class LisaTag tmp = BigEndianBitConverter.GetBytes((ushort)(UsedBytes & 0x7FFF)); Array.Copy(tmp, 0, tagBytes, 6, 2); - if(ValidChk) - tagBytes[6] += 0x80; + if(ValidChk) tagBytes[6] += 0x80; tmp = BigEndianBitConverter.GetBytes(AbsPage); Array.Copy(tmp, 1, tagBytes, 8, 3); diff --git a/Aaru.Decoders/MMC/CID.cs b/Aaru.Decoders/MMC/CID.cs index 202ae8286..d2afa4397 100644 --- a/Aaru.Decoders/MMC/CID.cs +++ b/Aaru.Decoders/MMC/CID.cs @@ -61,8 +61,7 @@ public static partial class Decoders { public static CID DecodeCID(uint[] response) { - if(response?.Length != 4) - return null; + if(response?.Length != 4) return null; var data = new byte[16]; @@ -80,8 +79,7 @@ public static partial class Decoders public static CID DecodeCID(byte[] response) { - if(response?.Length != 16) - return null; + if(response?.Length != 16) return null; var cid = new CID { @@ -102,8 +100,7 @@ public static partial class Decoders public static string PrettifyCID(CID cid) { - if(cid == null) - return null; + if(cid == null) return null; var sb = new StringBuilder(); @@ -129,9 +126,10 @@ public static partial class Decoders sb.AppendFormat("\t" + Localization.Application_ID_0, cid.ApplicationID).AppendLine(); sb.AppendFormat("\t" + Localization.Product_name_0, cid.ProductName).AppendLine(); - sb.AppendFormat("\t" + Localization.Product_revision_0_1, (cid.ProductRevision & 0xF0) >> 4, - cid.ProductRevision & 0x0F). - AppendLine(); + sb.AppendFormat("\t" + Localization.Product_revision_0_1, + (cid.ProductRevision & 0xF0) >> 4, + cid.ProductRevision & 0x0F) + .AppendLine(); sb.AppendFormat("\t" + Localization.Product_serial_number_0, cid.ProductSerialNumber).AppendLine(); @@ -156,9 +154,8 @@ public static partial class Decoders _ => "" }; - sb.AppendFormat("\t" + Localization.Device_manufactured_month_0_of_1, (cid.ManufacturingDate & 0xF0) >> 4, - year). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_manufactured_month_0_of_1, (cid.ManufacturingDate & 0xF0) >> 4, year) + .AppendLine(); sb.AppendFormat("\t" + Localization.CID_CRC_0, cid.CRC).AppendLine(); diff --git a/Aaru.Decoders/MMC/CSD.cs b/Aaru.Decoders/MMC/CSD.cs index 1fa11e48f..427de67c1 100644 --- a/Aaru.Decoders/MMC/CSD.cs +++ b/Aaru.Decoders/MMC/CSD.cs @@ -85,8 +85,7 @@ public static partial class Decoders { public static CSD DecodeCSD(uint[] response) { - if(response?.Length != 4) - return null; + if(response?.Length != 4) return null; var data = new byte[16]; @@ -104,8 +103,7 @@ public static partial class Decoders public static CSD DecodeCSD(byte[] response) { - if(response?.Length != 16) - return null; + if(response?.Length != 16) return null; return new CSD { @@ -147,8 +145,7 @@ public static partial class Decoders public static string PrettifyCSD(CSD csd) { - if(csd == null) - return null; + if(csd == null) return null; double unitFactor = 0; double multiplier = 0; @@ -246,8 +243,8 @@ public static partial class Decoders double result = unitFactor * multiplier; sb.AppendFormat("\t" + Localization.Asynchronous_data_access_time_is_0_1, result, unit).AppendLine(); - sb.AppendFormat("\t" + Localization.Clock_dependent_part_of_data_access_is_0_clock_cycles, csd.NSAC * 100). - AppendLine(); + sb.AppendFormat("\t" + Localization.Clock_dependent_part_of_data_access_is_0_clock_cycles, csd.NSAC * 100) + .AppendLine(); unit = Localization.unit_MHz; @@ -304,8 +301,7 @@ public static partial class Decoders for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) { - if((csd.Classes & mask) == mask) - unit += $" {cl}"; + if((csd.Classes & mask) == mask) unit += $" {cl}"; } sb.AppendFormat("\t" + Localization.Device_support_command_classes_0, unit).AppendLine(); @@ -314,27 +310,23 @@ public static partial class Decoders sb.AppendLine("\t" + Localization.Read_block_length_size_is_defined_in_extended_CSD); else { - sb.AppendFormat("\t" + Localization.Read_block_length_is_0_bytes, Math.Pow(2, csd.ReadBlockLength)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Read_block_length_is_0_bytes, Math.Pow(2, csd.ReadBlockLength)) + .AppendLine(); } - if(csd.ReadsPartialBlocks) - sb.AppendLine("\t" + Localization.Device_allows_reading_partial_blocks); + if(csd.ReadsPartialBlocks) sb.AppendLine("\t" + Localization.Device_allows_reading_partial_blocks); - if(csd.WriteMisalignment) - sb.AppendLine("\t" + Localization.Write_commands_can_cross_physical_block_boundaries); + if(csd.WriteMisalignment) sb.AppendLine("\t" + Localization.Write_commands_can_cross_physical_block_boundaries); - if(csd.ReadMisalignment) - sb.AppendLine("\t" + Localization.Read_commands_can_cross_physical_block_boundaries); + if(csd.ReadMisalignment) sb.AppendLine("\t" + Localization.Read_commands_can_cross_physical_block_boundaries); - if(csd.DSRImplemented) - sb.AppendLine("\t" + Localization.Device_implements_configurable_driver_stage); + if(csd.DSRImplemented) sb.AppendLine("\t" + Localization.Device_implements_configurable_driver_stage); if(csd.Size == 0xFFF) { sb.AppendLine("\t" + - Localization. - Device_may_be_bigger_than_2GiB_and_have_its_real_size_defined_in_the_extended_CSD); + Localization + .Device_may_be_bigger_than_2GiB_and_have_its_real_size_defined_in_the_extended_CSD); } result = (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2); @@ -520,8 +512,8 @@ public static partial class Decoders // unitFactor = Convert.ToDouble(csd.WriteProtectGroupSize); sb.AppendFormat("\t" + Localization.Device_can_write_protect_a_minimum_of_0_blocks_at_a_time, - (int)(result + 1)). - AppendLine(); + (int)(result + 1)) + .AppendLine(); } else sb.AppendLine("\t" + Localization.Device_cant_write_protect_regions); @@ -537,37 +529,32 @@ public static partial class Decoders break; case 2: - sb.AppendFormat("\t" + Localization.Device_uses_unknown_ECC_code_0_by_default, csd.DefaultECC). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_uses_unknown_ECC_code_0_by_default, csd.DefaultECC) + .AppendLine(); break; } - sb.AppendFormat("\t" + Localization.Writing_is_0_times_slower_than_reading, Math.Pow(2, csd.WriteSpeedFactor)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Writing_is_0_times_slower_than_reading, Math.Pow(2, csd.WriteSpeedFactor)) + .AppendLine(); if(csd.WriteBlockLength == 15) sb.AppendLine("\t" + Localization.Write_block_length_size_is_defined_in_extended_CSD); else { - sb.AppendFormat("\t" + Localization.Write_block_length_is_0_bytes, Math.Pow(2, csd.WriteBlockLength)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_block_length_is_0_bytes, Math.Pow(2, csd.WriteBlockLength)) + .AppendLine(); } - if(csd.WritesPartialBlocks) - sb.AppendLine("\t" + Localization.Device_allows_writing_partial_blocks); + if(csd.WritesPartialBlocks) sb.AppendLine("\t" + Localization.Device_allows_writing_partial_blocks); - if(csd.ContentProtection) - sb.AppendLine("\t" + Localization.Device_supports_content_protection); + if(csd.ContentProtection) sb.AppendLine("\t" + Localization.Device_supports_content_protection); - if(!csd.Copy) - sb.AppendLine("\t" + Localization.Device_contents_are_original); + if(!csd.Copy) sb.AppendLine("\t" + Localization.Device_contents_are_original); - if(csd.PermanentWriteProtect) - sb.AppendLine("\t" + Localization.Device_is_permanently_write_protected); + if(csd.PermanentWriteProtect) sb.AppendLine("\t" + Localization.Device_is_permanently_write_protected); - if(csd.TemporaryWriteProtect) - sb.AppendLine("\t" + Localization.Device_is_temporarily_write_protected); + if(csd.TemporaryWriteProtect) sb.AppendLine("\t" + Localization.Device_is_temporarily_write_protected); if(!csd.FileFormatGroup) { @@ -586,8 +573,8 @@ public static partial class Decoders break; default: - sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0, csd.FileFormat). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0, csd.FileFormat) + .AppendLine(); break; } @@ -595,8 +582,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0_and_file_format_group_1, - csd.FileFormat). - AppendLine(); + csd.FileFormat) + .AppendLine(); } switch(csd.ECC) @@ -610,8 +597,8 @@ public static partial class Decoders break; case 2: - sb.AppendFormat("\t" + Localization.Device_currently_uses_unknown_ECC_code_0, csd.DefaultECC). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_currently_uses_unknown_ECC_code_0, csd.DefaultECC) + .AppendLine(); break; } diff --git a/Aaru.Decoders/MMC/ExtendedCSD.cs b/Aaru.Decoders/MMC/ExtendedCSD.cs index 1b5338809..6af47879e 100644 --- a/Aaru.Decoders/MMC/ExtendedCSD.cs +++ b/Aaru.Decoders/MMC/ExtendedCSD.cs @@ -370,8 +370,7 @@ public static partial class Decoders { public static ExtendedCSD DecodeExtendedCSD(byte[] response) { - if(response?.Length != 512) - return null; + if(response?.Length != 512) return null; var handle = GCHandle.Alloc(response, GCHandleType.Pinned); var csd = (ExtendedCSD)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(ExtendedCSD)); @@ -382,8 +381,7 @@ public static partial class Decoders public static string PrettifyExtendedCSD(ExtendedCSD csd) { - if(csd == null) - return null; + if(csd == null) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.MultiMediaCard_Extended_Device_Specific_Data_Register); @@ -392,8 +390,8 @@ public static partial class Decoders if(csd.ExtendedSecurityCommandsError != 0) { - sb.AppendFormat("\t" + Localization.Last_extended_security_error_was_0, csd.ExtendedSecurityCommandsError). - AppendLine(); + sb.AppendFormat("\t" + Localization.Last_extended_security_error_was_0, csd.ExtendedSecurityCommandsError) + .AppendLine(); } if(csd.SupportedCommandSets.HasFlag(DeviceSupportedCommandSets.Standard)) @@ -413,15 +411,16 @@ public static partial class Decoders sb.AppendLine("\t" + Localization.Device_supports_background_operations); sb.AppendFormat("\t" + Localization.Device_supports_a_maximum_of_0_packed_reads_and_1_packed_writes, - csd.MaxPackedReadCommands, csd.MaxPackedWriteCommands). - AppendLine(); + csd.MaxPackedReadCommands, + csd.MaxPackedWriteCommands) + .AppendLine(); if(csd.DataTagSupport.HasFlag(DataTagSupport.Supported)) { sb.AppendLine("\t" + Localization.Device_supports_Data_Tag); - sb.AppendFormat("\t" + Localization.Tags_must_be_in_units_of_0_sectors, Math.Pow(2, csd.TagUnitSize)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Tags_must_be_in_units_of_0_sectors, Math.Pow(2, csd.TagUnitSize)) + .AppendLine(); sb.AppendFormat("\t" + Localization.Tag_resources_size_is_0, csd.TagResourcesSize).AppendLine(); } @@ -431,8 +430,8 @@ public static partial class Decoders sb.AppendFormat("\t" + Localization.Max_context_ID_is_0, csd.ContextManagementCaps & 0xF).AppendLine(); sb.AppendFormat("\t" + Localization.Large_unit_maximum_multiplier_is_0, - ((csd.ContextManagementCaps & 0x70) >> 4) + 1). - AppendLine(); + ((csd.ContextManagementCaps & 0x70) >> 4) + 1) + .AppendLine(); } sb.AppendFormat("\t" + Localization.Large_unit_size_is_0_MiB, csd.LargeUnitSize + 1).AppendLine(); @@ -459,24 +458,27 @@ public static partial class Decoders switch(unit) { case > 1000000: - sb. - AppendFormat("\t" + Localization.Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_s, - unit / 1000000). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_s, + unit / 1000000) + .AppendLine(); break; case > 1000: - sb. - AppendFormat("\t" + Localization.Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_ms, - unit / 1000). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_ms, + unit / 1000) + .AppendLine(); break; default: - sb. - AppendFormat("\t" + Localization.Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_µs, - unit). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Maximum_timeout_for_switch_command_when_setting_a_value_to_the_mode_operation_codes_field_is_0_µs, + unit) + .AppendLine(); break; } @@ -487,19 +489,18 @@ public static partial class Decoders if(csd.SupportedModes.HasFlag(SupportedModes.VendorSpecific)) sb.AppendLine("\t" + Localization.Device_supports_Vendor_Specific_Mode); - if(csd.BarrierSupport == 0x01) - sb.AppendLine("\t" + Localization.Device_supports_the_barrier_command); + if(csd.BarrierSupport == 0x01) sb.AppendLine("\t" + Localization.Device_supports_the_barrier_command); if(csd.CMDQueuingSupport.HasFlag(CMDQueuingSupport.Supported)) { sb.AppendFormat("\t" + Localization.Device_supports_command_queuing_with_a_depth_of_0, - csd.CMDQueuingDepth + 1). - AppendLine(); + csd.CMDQueuingDepth + 1) + .AppendLine(); } sb.AppendFormat("\t" + Localization._0_firmware_sectors_correctly_programmed, - csd.NumberOfFWSectorsCorrectlyProgrammed). - AppendLine(); + csd.NumberOfFWSectorsCorrectlyProgrammed) + .AppendLine(); switch(csd.DeviceLifeEstimationTypeB) { @@ -628,8 +629,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Optimal_trim_size_is_0_KiB, - 4 * Math.Pow(2, csd.OptimalTrimUnitSize - 1)). - AppendLine(); + 4 * Math.Pow(2, csd.OptimalTrimUnitSize - 1)) + .AppendLine(); } sb.AppendFormat("\t" + Localization.Device_version_0, csd.DeviceVersion).AppendLine(); @@ -643,16 +644,17 @@ public static partial class Decoders if(csd.GenericCMD6Timeout > 0) { sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_by_default_for_a_SWITCH_command, - csd.GenericCMD6Timeout * 10). - AppendLine(); + csd.GenericCMD6Timeout * 10) + .AppendLine(); } if(csd.PowerOffNotificationTimeout > 0) { - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_by_default_to_power_off_from_a_SWITCH_command_notification, - csd.PowerOffNotificationTimeout * 10). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_takes_a_maximum_of_0_by_default_to_power_off_from_a_SWITCH_command_notification, + csd.PowerOffNotificationTimeout * 10) + .AppendLine(); } switch(csd.BackgroundOperationsStatus & 0x03) @@ -676,14 +678,14 @@ public static partial class Decoders } sb.AppendFormat("\t" + Localization.Last_WRITE_MULTIPLE_command_correctly_programmed_0_sectors, - csd.CorrectlyProgrammedSectors). - AppendLine(); + csd.CorrectlyProgrammedSectors) + .AppendLine(); if(csd.InitializationTimeAfterPartition > 0) { sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_for_initialization_after_partition, - csd.InitializationTimeAfterPartition * 100). - AppendLine(); + csd.InitializationTimeAfterPartition * 100) + .AppendLine(); } if(csd.CacheFlushingPolicy.HasFlag(CacheFlushingPolicy.FIFO)) @@ -692,8 +694,8 @@ public static partial class Decoders if(csd.TRIMMultiplier > 0) { sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_for_trimming_a_single_erase_group, - csd.TRIMMultiplier * 300). - AppendLine(); + csd.TRIMMultiplier * 300) + .AppendLine(); } if(csd.SecureFeatureSupport.HasFlag(SecureFeatureSupport.Sanitize)) @@ -710,18 +712,18 @@ public static partial class Decoders if(csd.SecureEraseMultiplier > 0) { - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_for_securely_erasing_a_single_erase_group, - csd.SecureEraseMultiplier * 300). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Device_takes_a_maximum_of_0_ms_for_securely_erasing_a_single_erase_group, + csd.SecureEraseMultiplier * 300) + .AppendLine(); } if(csd.SecureTRIMMultiplier > 0) { - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_for_securely_trimming_a_single_erase_group, - csd.SecureTRIMMultiplier * 300). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Device_takes_a_maximum_of_0_ms_for_securely_trimming_a_single_erase_group, + csd.SecureTRIMMultiplier * 300) + .AppendLine(); } if(csd.BootInformation.HasFlag(BootInformation.HighSpeed)) @@ -735,35 +737,35 @@ public static partial class Decoders if(csd.BootPartitionSize > 0) { - sb.AppendFormat("\t" + Localization.Device_has_a_0_KiB_boot_partition, csd.BootPartitionSize * 128). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_has_a_0_KiB_boot_partition, csd.BootPartitionSize * 128) + .AppendLine(); } if((csd.AccessSize & 0x0F) > 0) { sb.AppendFormat("\t" + Localization.Device_has_a_page_size_of_0_KiB, - 512 * Math.Pow(2, (csd.AccessSize & 0x0F) - 1) / 1024.0). - AppendLine(); + 512 * Math.Pow(2, (csd.AccessSize & 0x0F) - 1) / 1024.0) + .AppendLine(); } if(csd.HighCapacityEraseUnitSize > 0) { - sb.AppendFormat("\t" + Localization.Device_erase_groups_are_0_KiB, csd.HighCapacityEraseUnitSize * 512). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_erase_groups_are_0_KiB, csd.HighCapacityEraseUnitSize * 512) + .AppendLine(); } if(csd.HighCapacityEraseTimeout > 0) { sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_for_erasing_a_single_erase_group, - csd.HighCapacityEraseTimeout * 300). - AppendLine(); + csd.HighCapacityEraseTimeout * 300) + .AppendLine(); } if(csd.HighCapacityWriteProtectGroupSize > 0) { sb.AppendFormat("\t" + Localization.Device_smallest_write_protect_group_is_made_of_0_erase_groups, - csd.HighCapacityWriteProtectGroupSize). - AppendLine(); + csd.HighCapacityWriteProtectGroupSize) + .AppendLine(); } if(csd.SleepCurrentVcc > 0) @@ -793,24 +795,24 @@ public static partial class Decoders switch(unit) { case > 1000000: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_s_to_switch_production_state_awareness, - unit / 1000000). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Device_takes_a_maximum_of_0_s_to_switch_production_state_awareness, + unit / 1000000) + .AppendLine(); break; case > 1000: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_to_switch_production_state_awareness, - unit / 1000). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Device_takes_a_maximum_of_0_ms_to_switch_production_state_awareness, + unit / 1000) + .AppendLine(); break; default: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_μs_to_switch_production_state_awareness, - unit). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Device_takes_a_maximum_of_0_μs_to_switch_production_state_awareness, + unit) + .AppendLine(); break; } @@ -823,24 +825,27 @@ public static partial class Decoders switch(unit) { case > 1000000: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_to_transition_between_sleep_and_standby_states, - unit / 1000000). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_takes_a_maximum_of_0_ms_to_transition_between_sleep_and_standby_states, + unit / 1000000) + .AppendLine(); break; case > 1000: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_μs_to_transition_between_sleep_and_standby_states, - unit / 1000). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_takes_a_maximum_of_0_μs_to_transition_between_sleep_and_standby_states, + unit / 1000) + .AppendLine(); break; default: - sb. - AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ns_to_transition_between_sleep_and_standby_states, - unit). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_takes_a_maximum_of_0_ns_to_transition_between_sleep_and_standby_states, + unit) + .AppendLine(); break; } @@ -854,19 +859,19 @@ public static partial class Decoders { case > 1000000: sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_s_to_move_to_sleep_state, - unit / 1000000). - AppendLine(); + unit / 1000000) + .AppendLine(); break; case > 1000: sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_ms_to_move_to_sleep_state, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); break; default: - sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_μs_to_move_to_sleep_state, unit). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_takes_a_maximum_of_0_μs_to_move_to_sleep_state, unit) + .AppendLine(); break; } @@ -889,8 +894,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_reading_in_SDR_26Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumReadPerformance26_4 * 300; @@ -900,8 +905,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_reading_in_SDR_26Mhz_4_bit_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumReadPerformance52 * 300; @@ -911,8 +916,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_reading_in_SDR_52Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumReadPerformanceDDR52 * 600; @@ -922,8 +927,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_reading_in_DDR_52Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumWritePerformance26 * 300; @@ -933,8 +938,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_writing_in_SDR_26Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumWritePerformance26_4 * 300; @@ -944,8 +949,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_writing_in_SDR_26Mhz_4_bit_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumWritePerformance52 * 300; @@ -955,8 +960,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_writing_in_SDR_52Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } unit = csd.MinimumWritePerformanceDDR52 * 600; @@ -966,22 +971,22 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_can_achieve_a_minimum_of_0_MB_s_writing_in_DDR_52Mhz_mode, - unit / 1000). - AppendLine(); + unit / 1000) + .AppendLine(); } if(csd.PartitionSwitchingTime > 0) { sb.AppendFormat("\t" + Localization.Device_can_take_a_maximum_of_0_ms_when_switching_partitions, - csd.PartitionSwitchingTime * 10). - AppendLine(); + csd.PartitionSwitchingTime * 10) + .AppendLine(); } if(csd.OutOfInterruptBusyTiming > 0) { sb.AppendFormat("\t" + Localization.Device_can_take_a_maximum_of_0_ms_when_releasing_from_an_interrupt, - csd.OutOfInterruptBusyTiming * 10). - AppendLine(); + csd.OutOfInterruptBusyTiming * 10) + .AppendLine(); } if(csd.DriverStrength.HasFlag(DriverStrength.Type0)) @@ -999,11 +1004,9 @@ public static partial class Decoders if(csd.DriverStrength.HasFlag(DriverStrength.Type4)) sb.AppendLine("\t" + Localization.Device_supports_IO_driver_strength_type_four); - if(csd.DeviceType.HasFlag(DeviceType.HS_26)) - sb.AppendLine("\t" + Localization.Device_supports_26_Mhz_mode); + if(csd.DeviceType.HasFlag(DeviceType.HS_26)) sb.AppendLine("\t" + Localization.Device_supports_26_Mhz_mode); - if(csd.DeviceType.HasFlag(DeviceType.HS_52)) - sb.AppendLine("\t" + Localization.Device_supports_52_Mhz_mode); + if(csd.DeviceType.HasFlag(DeviceType.HS_52)) sb.AppendLine("\t" + Localization.Device_supports_52_Mhz_mode); if(csd.DeviceType.HasFlag(DeviceType.HS_DDR_52)) sb.AppendLine("\t" + Localization.Device_supports_DDR_52_Mhz_mode_at_1_8V_or_3V); @@ -1039,10 +1042,11 @@ public static partial class Decoders break; default: - sb. - AppendFormat("\t" + Localization.Device_follows_standard_MMC_command_set_with_unknown_version_code_0, - csd.CommandSetRevision). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_follows_standard_MMC_command_set_with_unknown_version_code_0, + csd.CommandSetRevision) + .AppendLine(); break; } @@ -1050,8 +1054,9 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Device_follows_unknown_MMC_command_set_code_0_with_revision_code_1, - csd.CommandSet, csd.CommandSetRevision). - AppendLine(); + csd.CommandSet, + csd.CommandSetRevision) + .AppendLine(); break; } @@ -1074,15 +1079,15 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Device_has_unknown_timing_mode_0, - csd.HighSpeedInterfaceTiming & 0x0F). - AppendLine(); + csd.HighSpeedInterfaceTiming & 0x0F) + .AppendLine(); break; } sb.AppendFormat("\t" + Localization.Selected_driver_strength_is_type_0, - (csd.HighSpeedInterfaceTiming & 0xF0) >> 4). - AppendLine(); + (csd.HighSpeedInterfaceTiming & 0xF0) >> 4) + .AppendLine(); if((csd.StrobeSupport & 0x01) == 0x01) { @@ -1116,8 +1121,8 @@ public static partial class Decoders break; default: - sb.AppendFormat("\t" + Localization.Device_is_using_unknown_data_bus_code_0, csd.BusWidth & 0x0F). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_is_using_unknown_data_bus_code_0, csd.BusWidth & 0x0F) + .AppendLine(); break; } @@ -1126,13 +1131,13 @@ public static partial class Decoders { case 0: case 1: - sb.AppendFormat("\t" + Localization.Erased_memory_range_shall_be_0, csd.ErasedMemoryContent). - AppendLine(); + sb.AppendFormat("\t" + Localization.Erased_memory_range_shall_be_0, csd.ErasedMemoryContent) + .AppendLine(); break; default: - sb.AppendFormat("\t" + Localization.Unknown_erased_memory_content_code_0, csd.ErasedMemoryContent). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_erased_memory_content_code_0, csd.ErasedMemoryContent) + .AppendLine(); break; } @@ -1160,8 +1165,8 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Unknown_enabled_boot_partition_code_0, - (csd.PartitionConfiguration & 0x38) >> 3). - AppendLine(); + (csd.PartitionConfiguration & 0x38) >> 3) + .AppendLine(); break; } @@ -1186,8 +1191,8 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.There_is_access_to_general_purpose_partition_0, - (csd.PartitionConfiguration & 0x07) - 3). - AppendLine(); + (csd.PartitionConfiguration & 0x07) - 3) + .AppendLine(); break; } @@ -1197,8 +1202,8 @@ public static partial class Decoders else if(csd.BootConfigProtection.HasFlag(BootConfigProtection.PowerCycle)) { sb.AppendLine("\t" + - Localization. - Change_of_the_boot_configuration_register_bits_is_disabled_until_the_next_power_cycle); + Localization + .Change_of_the_boot_configuration_register_bits_is_disabled_until_the_next_power_cycle); } switch(csd.BootBusConditions & 0x03) @@ -1251,8 +1256,8 @@ public static partial class Decoders if(csd.HighCapacityEraseGroupDefinition.HasFlag(HighCapacityEraseGroupDefinition.Enabled)) { sb.AppendLine("\t" + - Localization. - Device_will_use_high_capacity_erase_unit_size__timeout_and_write_protect_group_size_definitions); + Localization + .Device_will_use_high_capacity_erase_unit_size__timeout_and_write_protect_group_size_definitions); } switch(csd.BootWriteProtectionStatus & 0x03) @@ -1291,8 +1296,8 @@ public static partial class Decoders { if(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.Selected)) { - sb.AppendLine(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister. - PermanentArea2) + sb.AppendLine(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister + .PermanentArea2) ? "\t" + Localization.Boot_area_two_is_permanently_write_protected : "\t" + Localization.Boot_area_one_is_permanently_write_protected); } @@ -1340,8 +1345,8 @@ public static partial class Decoders if(csd.RPMBSize > 0) { - sb.AppendFormat("\t" + Localization.Device_has_a_0_KiB_replay_protected_memory_block, csd.RPMBSize * 128). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_has_a_0_KiB_replay_protected_memory_block, csd.RPMBSize * 128) + .AppendLine(); } if(csd.PartitioningSupport.HasFlag(PartitioningSupport.Supported)) @@ -1351,8 +1356,8 @@ public static partial class Decoders if(csd.PartitioningSupport.HasFlag(PartitioningSupport.Enhanced)) { sb.AppendLine("\t" + - Localization. - Device_can_have_enhanced_technological_features_in_partitions_and_user_data_area); + Localization + .Device_can_have_enhanced_technological_features_in_partitions_and_user_data_area); } if(csd.PartitioningSupport.HasFlag(PartitioningSupport.Extended)) @@ -1371,8 +1376,8 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Device_natively_uses_unknown_sector_size_indicated_by_code_0, - csd.NativeSectorSize). - AppendLine(); + csd.NativeSectorSize) + .AppendLine(); break; } @@ -1389,8 +1394,8 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Device_emulates_unknown_sector_size_indicated_by_code_0, - csd.NativeSectorSize). - AppendLine(); + csd.NativeSectorSize) + .AppendLine(); break; } @@ -1407,14 +1412,13 @@ public static partial class Decoders break; default: sb.AppendFormat("\t" + Localization.Device_currently_addresses_unknown_sector_size_indicated_by_code_0, - csd.NativeSectorSize). - AppendLine(); + csd.NativeSectorSize) + .AppendLine(); break; } - if((csd.CacheControl & 0x01) == 0x01) - sb.AppendLine("\t" + Localization.Devices_cache_is_enabled); + if((csd.CacheControl & 0x01) == 0x01) sb.AppendLine("\t" + Localization.Devices_cache_is_enabled); if((csd.CommandQueueModeEnable & 0x01) == 0x01) sb.AppendLine("\t" + Localization.Device_has_enabled_command_queuing); diff --git a/Aaru.Decoders/MMC/OCR.cs b/Aaru.Decoders/MMC/OCR.cs index 26a2605f0..5977ffad4 100644 --- a/Aaru.Decoders/MMC/OCR.cs +++ b/Aaru.Decoders/MMC/OCR.cs @@ -103,14 +103,12 @@ public static partial class Decoders public static string PrettifyOCR(OCR ocr) { - if(ocr == null) - return null; + if(ocr == null) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.MultiMediaCard_Operation_Conditions_Register); - if(!ocr.PowerUp) - sb.AppendLine("\t" + Localization.Device_is_powering_up); + if(!ocr.PowerUp) sb.AppendLine("\t" + Localization.Device_is_powering_up); switch(ocr.AccessMode) { @@ -128,53 +126,37 @@ public static partial class Decoders break; } - if(ocr.ThreeFive) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_5_3_6V); + if(ocr.ThreeFive) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_5_3_6V); - if(ocr.ThreeFour) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_4_3_5V); + if(ocr.ThreeFour) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_4_3_5V); - if(ocr.ThreeThree) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_3_3_4V); + if(ocr.ThreeThree) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_3_3_4V); - if(ocr.ThreeTwo) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_2_3_3V); + if(ocr.ThreeTwo) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_2_3_3V); - if(ocr.ThreeOne) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_1_3_2V); + if(ocr.ThreeOne) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_1_3_2V); - if(ocr.TwoNine) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_9_3_0V); + if(ocr.TwoNine) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_9_3_0V); - if(ocr.TwoEight) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_8_2_9V); + if(ocr.TwoEight) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_8_2_9V); - if(ocr.TwoSeven) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_7_2_8V); + if(ocr.TwoSeven) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_7_2_8V); - if(ocr.TwoSix) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_6_2_7V); + if(ocr.TwoSix) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_6_2_7V); - if(ocr.TwoFive) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_5_2_6V); + if(ocr.TwoFive) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_5_2_6V); - if(ocr.TwoFour) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_4_2_5V); + if(ocr.TwoFour) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_4_2_5V); - if(ocr.TwoThree) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_3_2_4V); + if(ocr.TwoThree) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_3_2_4V); - if(ocr.TwoTwo) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_2_2_3V); + if(ocr.TwoTwo) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_2_2_3V); - if(ocr.TwoOne) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_1_2_2V); + if(ocr.TwoOne) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_1_2_2V); - if(ocr.TwoZero) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_0_2_1V); + if(ocr.TwoZero) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_0_2_1V); - if(ocr.OneSix) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_1_65_1_95V); + if(ocr.OneSix) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_1_65_1_95V); return sb.ToString(); } diff --git a/Aaru.Decoders/PCMCIA/CIS.cs b/Aaru.Decoders/PCMCIA/CIS.cs index 718ebc72f..54d84e14e 100644 --- a/Aaru.Decoders/PCMCIA/CIS.cs +++ b/Aaru.Decoders/PCMCIA/CIS.cs @@ -58,16 +58,13 @@ public static class CIS Code = (TupleCodes)data[position] }; - if(tuple.Code == TupleCodes.CISTPL_NULL) - continue; + if(tuple.Code == TupleCodes.CISTPL_NULL) continue; - if(tuple.Code == TupleCodes.CISTPL_END) - break; + if(tuple.Code == TupleCodes.CISTPL_END) break; tuple.Link = data[position + 1]; - if(position + 2 + tuple.Link > data.Length) - break; + if(position + 2 + tuple.Link > data.Length) break; tuple.Data = new byte[tuple.Link + 2]; Array.Copy(data, position, tuple.Data, 0, tuple.Link + 2); @@ -81,19 +78,16 @@ public static class CIS public static DeviceGeometryTuple DecodeDeviceGeometryTuple(Tuple tuple) { - if(tuple == null) - return null; + if(tuple == null) return null; - if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) - return null; + if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) return null; return tuple.Data == null ? null : DecodeDeviceGeometryTuple(tuple.Data); } public static DeviceGeometryTuple DecodeDeviceGeometryTuple(byte[] data) { - if((data?.Length - 2) % 6 != 0) - return null; + if((data?.Length - 2) % 6 != 0) return null; var tuple = new DeviceGeometryTuple(); List geometries = new(); @@ -122,11 +116,9 @@ public static class CIS public static string PrettifyDeviceGeometryTuple(DeviceGeometryTuple tuple) { - if(tuple == null) - return null; + if(tuple == null) return null; - if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) - return null; + if(tuple.Code != TupleCodes.CISTPL_DEVICEGEO && tuple.Code != TupleCodes.CISTPL_DEVICEGEO_A) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.PCMCIA_Device_Geometry_Tuples); @@ -135,26 +127,26 @@ public static class CIS { sb.AppendLine("\t" + Localization.Geometry); - sb.AppendFormat("\t\t" + Localization.Device_width_0_bits, (1 << geometry.CardInterface - 1) * 8). - AppendLine(); + sb.AppendFormat("\t\t" + Localization.Device_width_0_bits, (1 << geometry.CardInterface - 1) * 8) + .AppendLine(); sb.AppendFormat("\t\t" + Localization.Erase_block_0_bytes, - (1 << geometry.EraseBlockSize - 1) * (1 << geometry.Interleaving - 1)). - AppendLine(); + (1 << geometry.EraseBlockSize - 1) * (1 << geometry.Interleaving - 1)) + .AppendLine(); sb.AppendFormat("\t\t" + Localization.Read_block_0_bytes, - (1 << geometry.ReadBlockSize - 1) * (1 << geometry.Interleaving - 1)). - AppendLine(); + (1 << geometry.ReadBlockSize - 1) * (1 << geometry.Interleaving - 1)) + .AppendLine(); sb.AppendFormat("\t\t" + Localization.Write_block_0_bytes, - (1 << geometry.WriteBlockSize - 1) * (1 << geometry.Interleaving - 1)). - AppendLine(); + (1 << geometry.WriteBlockSize - 1) * (1 << geometry.Interleaving - 1)) + .AppendLine(); sb.AppendFormat("\t\t" + Localization.Partition_alignment_0_bytes, (1 << geometry.EraseBlockSize - 1) * (1 << geometry.Interleaving - 1) * - (1 << geometry.Partitions - 1)). - AppendLine(); + (1 << geometry.Partitions - 1)) + .AppendLine(); } return sb.ToString(); @@ -168,19 +160,16 @@ public static class CIS public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(Tuple tuple) { - if(tuple?.Code != TupleCodes.CISTPL_MANFID) - return null; + if(tuple?.Code != TupleCodes.CISTPL_MANFID) return null; return tuple.Data == null ? null : DecodeManufacturerIdentificationTuple(tuple.Data); } public static ManufacturerIdentificationTuple DecodeManufacturerIdentificationTuple(byte[] data) { - if(data == null) - return null; + if(data == null) return null; - if(data.Length < 6) - return null; + if(data.Length < 6) return null; return new ManufacturerIdentificationTuple { @@ -193,8 +182,7 @@ public static class CIS public static string PrettifyManufacturerIdentificationTuple(ManufacturerIdentificationTuple tuple) { - if(tuple?.Code != TupleCodes.CISTPL_MANFID) - return null; + if(tuple?.Code != TupleCodes.CISTPL_MANFID) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.Manufacturer_Identification_Tuple); @@ -212,19 +200,16 @@ public static class CIS public static Level1VersionTuple DecodeLevel1VersionTuple(Tuple tuple) { - if(tuple?.Code != TupleCodes.CISTPL_VERS_1) - return null; + if(tuple?.Code != TupleCodes.CISTPL_VERS_1) return null; return tuple.Data == null ? null : DecodeLevel1VersionTuple(tuple.Data); } public static Level1VersionTuple DecodeLevel1VersionTuple(byte[] data) { - if(data == null) - return null; + if(data == null) return null; - if(data.Length < 4) - return null; + if(data.Length < 4) return null; List buffer = new(); List strings = null; @@ -241,13 +226,11 @@ public static class CIS for(var position = 4; position < data.Length; position++) { - if(data[position] == 0xFF) - break; + if(data[position] == 0xFF) break; buffer.Add(data[position]); - if(data[position] != 0x00) - continue; + if(data[position] != 0x00) continue; if(!firstString) { @@ -268,30 +251,28 @@ public static class CIS continue; } - if(strings == null) - strings = new List(); + if(strings == null) strings = new List(); strings.Add(StringHandlers.CToString(buffer.ToArray())); buffer = new List(); } - if(strings != null) - tuple.AdditionalInformation = strings.ToArray(); + if(strings != null) tuple.AdditionalInformation = strings.ToArray(); return tuple; } public static string PrettifyLevel1VersionTuple(Level1VersionTuple tuple) { - if(tuple?.Code != TupleCodes.CISTPL_VERS_1) - return null; + if(tuple?.Code != TupleCodes.CISTPL_VERS_1) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.PCMCIA_Level_1_Version_Product_Information_Tuple); sb.AppendFormat("\t" + Localization.Card_indicates_compliance_with_PC_Card_Standard_Release_0_1, - tuple.MajorVersion, tuple.MinorVersion). - AppendLine(); + tuple.MajorVersion, + tuple.MinorVersion) + .AppendLine(); if(string.IsNullOrEmpty(tuple.Manufacturer)) sb.AppendLine("\t" + Localization.No_manufacturer_information_string); diff --git a/Aaru.Decoders/PCMCIA/VendorCode.cs b/Aaru.Decoders/PCMCIA/VendorCode.cs index dc8960ec4..5762abaa6 100644 --- a/Aaru.Decoders/PCMCIA/VendorCode.cs +++ b/Aaru.Decoders/PCMCIA/VendorCode.cs @@ -42,7 +42,7 @@ public static class VendorCode { switch(id) { - #region JEDEC +#region JEDEC case 0x01: return "AMD"; @@ -545,7 +545,7 @@ public static class VendorCode case 0x7FFE: return "3COM"; - #endregion JEDEC +#endregion JEDEC case 0x0100: return "Digital Equipment Corporation"; diff --git a/Aaru.Decoders/SCSI/DiscStructureCapabilities.cs b/Aaru.Decoders/SCSI/DiscStructureCapabilities.cs index 85fefd1f6..9dbac363e 100644 --- a/Aaru.Decoders/SCSI/DiscStructureCapabilities.cs +++ b/Aaru.Decoders/SCSI/DiscStructureCapabilities.cs @@ -47,8 +47,7 @@ public static class DiscStructureCapabilities { var len = (ushort)((response[0] << 8) + response[1]); - if(len + 2 != response.Length) - return null; + if(len + 2 != response.Length) return null; List caps = new(); diff --git a/Aaru.Decoders/SCSI/EVPD.cs b/Aaru.Decoders/SCSI/EVPD.cs index d8d6fe368..e8a45741c 100644 --- a/Aaru.Decoders/SCSI/EVPD.cs +++ b/Aaru.Decoders/SCSI/EVPD.cs @@ -55,11 +55,9 @@ public static class EVPD /// Page 0x00. public static byte[] DecodePage00(byte[] page) { - if(page?[1] != 0) - return null; + if(page?[1] != 0) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var decoded = new byte[page.Length - 4]; @@ -73,14 +71,11 @@ public static class EVPD /// Page 0x01-0x7F. public static string DecodeASCIIPage(byte[] page) { - if(page == null) - return null; + if(page == null) return null; - if(page[1] == 0 || page[1] > 0x7F) - return null; + if(page[1] == 0 || page[1] > 0x7F) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var ascii = new byte[page[4]]; @@ -94,11 +89,9 @@ public static class EVPD /// Page 0x80. public static string DecodePage80(byte[] page) { - if(page?[1] != 0x80) - return null; + if(page?[1] != 0x80) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var ascii = new byte[page.Length - 4]; @@ -106,8 +99,7 @@ public static class EVPD for(var i = 0; i < ascii.Length - 1; i++) { - if(ascii[i] < 0x20) - return null; + if(ascii[i] < 0x20) return null; } return StringHandlers.CToString(ascii); @@ -118,11 +110,9 @@ public static class EVPD /// Page 0x82. public static string DecodePage82(byte[] page) { - if(page?[1] != 0x82) - return null; + if(page?[1] != 0x82) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var ascii = new byte[page.Length - 4]; @@ -135,11 +125,9 @@ public static class EVPD public static string DecodePageB1(byte[] page) { - if(page?[1] != 0xB1) - return null; + if(page?[1] != 0xB1) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var ascii = new byte[page.Length - 4]; @@ -154,11 +142,9 @@ public static class EVPD public static ulong DecodePageB2(byte[] page) { - if(page?[1] != 0xB2) - return 0; + if(page?[1] != 0xB2) return 0; - if(page.Length != 12) - return 0; + if(page.Length != 12) return 0; var bitmap = new byte[8]; @@ -173,11 +159,9 @@ public static class EVPD public static string DecodePageB3(byte[] page) { - if(page?[1] != 0xB3) - return null; + if(page?[1] != 0xB3) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var ascii = new byte[page.Length - 4]; @@ -192,17 +176,14 @@ public static class EVPD public static string DecodePageB4(byte[] page) { - if(page?[1] != 0xB3) - return null; + if(page?[1] != 0xB3) return null; - if(page.Length != page[3] + 4) - return null; + if(page.Length != page[3] + 4) return null; var element = new byte[page.Length - 4]; var sb = new StringBuilder(); - foreach(byte b in element) - sb.Append($"{b:X2}"); + foreach(byte b in element) sb.Append($"{b:X2}"); return sb.ToString(); } @@ -232,14 +213,11 @@ public static class EVPD public static Page_81? DecodePage_81(byte[] pageResponse) { - if(pageResponse?[1] != 0x81) - return null; + if(pageResponse?[1] != 0x81) return null; - if(pageResponse[3] + 4 != pageResponse.Length) - return null; + if(pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 6) - return null; + if(pageResponse.Length < 6) return null; var decoded = new Page_81 { @@ -280,19 +258,18 @@ public static class EVPD public static string PrettifyPage_81(Page_81? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_81 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Implemented_operating_definitions); - sb.AppendFormat("\t" + Localization.Default_operating_definition_0, DefinitionToString(page.Current)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Default_operating_definition_0, DefinitionToString(page.Current)) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Current_operating_definition_0, DefinitionToString(page.Current)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Current_operating_definition_0, DefinitionToString(page.Current)) + .AppendLine(); if(page.Supported.Length == 0) { @@ -394,14 +371,11 @@ public static class EVPD public static Page_83? DecodePage_83(byte[] pageResponse) { - if(pageResponse?[1] != 0x83) - return null; + if(pageResponse?[1] != 0x83) return null; - if(pageResponse[3] + 4 != pageResponse.Length) - return null; + if(pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 6) - return null; + if(pageResponse.Length < 6) return null; var decoded = new Page_83 { @@ -452,8 +426,7 @@ public static class EVPD public static string PrettifyPage_83(Page_83? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_83 page = modePage.Value; var sb = new StringBuilder(); @@ -481,14 +454,14 @@ public static class EVPD break; case IdentificationAssociation.TargetDevice: sb.AppendLine("\t" + - Localization. - Identifier_belongs_to_target_device_that_contains_the_addressed_logical_unit); + Localization + .Identifier_belongs_to_target_device_that_contains_the_addressed_logical_unit); break; default: sb.AppendFormat("\t" + Localization.Identifier_has_unknown_association_with_code_0, - (byte)descriptor.Association). - AppendLine(); + (byte)descriptor.Association) + .AppendLine(); break; } @@ -524,21 +497,21 @@ public static class EVPD { case IdentificationCodeSet.ASCII: case IdentificationCodeSet.UTF8: - sb.AppendFormat("\t" + Localization.Vendor_descriptor_contains_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.Vendor_descriptor_contains_0, descriptor.ASCII) + .AppendLine(); break; case IdentificationCodeSet.Binary: sb.AppendFormat("\t" + Localization.Vendor_descriptor_contains_binary_data_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; default: sb.AppendFormat("\t" + Localization.Vendor_descriptor_contains_unknown_kind_1_of_data_hex_0, PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), - (byte)descriptor.CodeSet). - AppendLine(); + (byte)descriptor.CodeSet) + .AppendLine(); break; } @@ -549,22 +522,22 @@ public static class EVPD { case IdentificationCodeSet.ASCII: case IdentificationCodeSet.UTF8: - sb.AppendFormat("\t" + Localization.Inquiry_descriptor_contains_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.Inquiry_descriptor_contains_0, descriptor.ASCII) + .AppendLine(); break; case IdentificationCodeSet.Binary: sb.AppendFormat("\t" + Localization.Inquiry_descriptor_contains_binary_data_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; default: - sb. - AppendFormat("\t" + Localization.Inquiry_descriptor_contains_unknown_kind_1_of_data_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), - (byte)descriptor.CodeSet). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Inquiry_descriptor_contains_unknown_kind_1_of_data_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), + (byte)descriptor.CodeSet) + .AppendLine(); break; } @@ -577,8 +550,7 @@ public static class EVPD { sb.AppendFormat("\t" + Localization.IEEE_EUI_64_0_X2, descriptor.Binary[0]); - for(var i = 1; i < descriptor.Binary.Length; i++) - sb.Append($":{descriptor.Binary[i]:X2}"); + for(var i = 1; i < descriptor.Binary.Length; i++) sb.Append($":{descriptor.Binary[i]:X2}"); sb.AppendLine(); } @@ -591,8 +563,7 @@ public static class EVPD { sb.AppendFormat("\t" + Localization.NAA_0_X2, descriptor.Binary[0]); - for(var i = 1; i < descriptor.Binary.Length; i++) - sb.Append($":{descriptor.Binary[i]:X2}"); + for(var i = 1; i < descriptor.Binary.Length; i++) sb.Append($":{descriptor.Binary[i]:X2}"); sb.AppendLine(); } @@ -601,14 +572,14 @@ public static class EVPD case IdentificationTypes.Relative: if(descriptor.CodeSet is IdentificationCodeSet.ASCII or IdentificationCodeSet.UTF8) { - sb.AppendFormat("\t" + Localization.Relative_target_port_identifier_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.Relative_target_port_identifier_0, descriptor.ASCII) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.Relative_target_port_identifier_0, - (descriptor.Binary[2] << 8) + descriptor.Binary[3]). - AppendLine(); + (descriptor.Binary[2] << 8) + descriptor.Binary[3]) + .AppendLine(); } break; @@ -618,37 +589,36 @@ public static class EVPD else { sb.AppendFormat("\t" + Localization.Target_group_identifier_0, - (descriptor.Binary[2] << 8) + descriptor.Binary[3]). - AppendLine(); + (descriptor.Binary[2] << 8) + descriptor.Binary[3]) + .AppendLine(); } break; case IdentificationTypes.LogicalUnitGroup: if(descriptor.CodeSet is IdentificationCodeSet.ASCII or IdentificationCodeSet.UTF8) { - sb.AppendFormat("\t" + Localization.Logical_unit_group_identifier_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.Logical_unit_group_identifier_0, descriptor.ASCII) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.Logical_unit_group_identifier_0, - (descriptor.Binary[2] << 8) + descriptor.Binary[3]). - AppendLine(); + (descriptor.Binary[2] << 8) + descriptor.Binary[3]) + .AppendLine(); } break; case IdentificationTypes.MD5: if(descriptor.CodeSet is IdentificationCodeSet.ASCII or IdentificationCodeSet.UTF8) { - sb.AppendFormat("\t" + Localization.MD5_logical_unit_identifier_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.MD5_logical_unit_identifier_0, descriptor.ASCII) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.MD5_logical_unit_identifier_0_x2, descriptor.Binary[0]); - for(var i = 1; i < descriptor.Binary.Length; i++) - sb.Append($"{descriptor.Binary[i]:x2}"); + for(var i = 1; i < descriptor.Binary.Length; i++) sb.Append($"{descriptor.Binary[i]:x2}"); sb.AppendLine(); } @@ -657,14 +627,14 @@ public static class EVPD case IdentificationTypes.SCSI: if(descriptor.CodeSet is IdentificationCodeSet.ASCII or IdentificationCodeSet.UTF8) { - sb.AppendFormat("\t" + Localization.SCSI_name_string_identifier_0, descriptor.ASCII). - AppendLine(); + sb.AppendFormat("\t" + Localization.SCSI_name_string_identifier_0, descriptor.ASCII) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.SCSI_name_string_identifier_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); } break; @@ -675,101 +645,113 @@ public static class EVPD switch(descriptor.ProtocolIdentifier) { case ProtocolIdentifiers.ADT: - sb. - AppendFormat("\t" + Localization.Protocol_Automation_Drive_Interface_Transport_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_Automation_Drive_Interface_Transport_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.ATA: - sb. - AppendFormat("\t" + Localization.Protocol_ATA_ATAPI_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_ATA_ATAPI_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.FibreChannel: - sb. - AppendFormat("\t" + Localization.Protocol_Fibre_Channel_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_Fibre_Channel_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.Firewire: - sb. - AppendFormat("\t" + Localization.Protocol_IEEE_1394_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_IEEE_1394_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.iSCSI: - sb. - AppendFormat("\t" + Localization.Protocol_Internet_SCSI_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_Internet_SCSI_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.NoProtocol: - sb. - AppendFormat("\t" + Localization.Protocol_unknown_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_unknown_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.PCIe: - sb. - AppendFormat("\t" + Localization.Protocol_PCI_Express_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_PCI_Express_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.RDMAP: - sb. - AppendFormat("\t" + Localization.Protocol_SCSI_Remote_Direct_Memory_Access_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_SCSI_Remote_Direct_Memory_Access_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.SAS: - sb. - AppendFormat("\t" + Localization.Protocol_Serial_Attachment_SCSI_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_Serial_Attachment_SCSI_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.SCSI: - sb. - AppendFormat("\t" + Localization.Protocol_Parallel_SCSI_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_Parallel_SCSI_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.SSA: - sb. - AppendFormat("\t" + Localization.Protocol_SSA_specific_descriptor_with_unknown_format_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Protocol_SSA_specific_descriptor_with_unknown_format_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; case ProtocolIdentifiers.SCSIe: sb.AppendFormat("\t" + Localization.Protocol_SCSIe_specific_descriptor_Routing_ID_is_0, - (descriptor.Binary[0] << 8) + descriptor.Binary[1]). - AppendLine(); + (descriptor.Binary[0] << 8) + descriptor.Binary[1]) + .AppendLine(); break; case ProtocolIdentifiers.UAS: - sb. - AppendFormat("\t" + Localization.Protocol_UAS_specific_descriptor_USB_address_0_interface_1, - descriptor.Binary[0] & 0x7F, descriptor.Binary[2]). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Protocol_UAS_specific_descriptor_USB_address_0_interface_1, + descriptor.Binary[0] & 0x7F, + descriptor.Binary[2]) + .AppendLine(); break; default: - sb. - AppendFormat("\t" + Localization.Protocol_unknown_code_0_specific_descriptor_with_unknown_format_hex_1, - (byte)descriptor.ProtocolIdentifier, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Protocol_unknown_code_0_specific_descriptor_with_unknown_format_hex_1, + (byte)descriptor.ProtocolIdentifier, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)) + .AppendLine(); break; } @@ -782,24 +764,26 @@ public static class EVPD { case IdentificationCodeSet.ASCII: case IdentificationCodeSet.UTF8: - sb.AppendFormat("\t" + Localization.Unknown_descriptor_type_1_contains_0, descriptor.ASCII, - (byte)descriptor.Type). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_descriptor_type_1_contains_0, + descriptor.ASCII, + (byte)descriptor.Type) + .AppendLine(); break; case IdentificationCodeSet.Binary: sb.AppendFormat("\t" + Localization.Unknown_descriptor_type_1_contains_binary_data_hex_0, PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), - (byte)descriptor.Type). - AppendLine(); + (byte)descriptor.Type) + .AppendLine(); break; default: - sb. - AppendFormat(Localization.Inquiry_descriptor_type_2_contains_unknown_kind_1_of_data_hex_0, - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), - (byte)descriptor.CodeSet, (byte)descriptor.Type). - AppendLine(); + sb.AppendFormat(Localization + .Inquiry_descriptor_type_2_contains_unknown_kind_1_of_data_hex_0, + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), + (byte)descriptor.CodeSet, + (byte)descriptor.Type) + .AppendLine(); break; } @@ -838,14 +822,11 @@ public static class EVPD public static Page_84? DecodePage_84(byte[] pageResponse) { - if(pageResponse?[1] != 0x84) - return null; + if(pageResponse?[1] != 0x84) return null; - if(pageResponse[3] + 4 != pageResponse.Length) - return null; + if(pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 10) - return null; + if(pageResponse.Length < 10) return null; var decoded = new Page_84 { @@ -878,8 +859,7 @@ public static class EVPD public static string PrettifyPage_84(Page_84? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_84 page = modePage.Value; var sb = new StringBuilder(); @@ -897,8 +877,7 @@ public static class EVPD { sb.AppendFormat("\t" + "{0:X2}", identifier.Identifier[0]); - for(var i = 1; i < identifier.Identifier.Length; i++) - sb.Append($":{identifier.Identifier[i]:X2}"); + for(var i = 1; i < identifier.Identifier.Length; i++) sb.Append($":{identifier.Identifier[i]:X2}"); sb.AppendLine(); } @@ -951,14 +930,11 @@ public static class EVPD public static Page_85? DecodePage_85(byte[] pageResponse) { - if(pageResponse?[1] != 0x85) - return null; + if(pageResponse?[1] != 0x85) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 4) - return null; + if(pageResponse.Length < 4) return null; var decoded = new Page_85 { @@ -995,8 +971,7 @@ public static class EVPD public static string PrettifyPage_85(Page_85? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_85 page = modePage.Value; var sb = new StringBuilder(); @@ -1024,14 +999,14 @@ public static class EVPD break; case IdentificationAssociation.TargetDevice: sb.AppendLine("\t" + - Localization. - Identifier_belongs_to_target_device_that_contains_the_addressed_logical_unit); + Localization + .Identifier_belongs_to_target_device_that_contains_the_addressed_logical_unit); break; default: sb.AppendFormat("\t" + Localization.Identifier_has_unknown_association_with_code_0, - (byte)descriptor.Association). - AppendLine(); + (byte)descriptor.Association) + .AppendLine(); break; } @@ -1040,53 +1015,54 @@ public static class EVPD { case NetworkServiceTypes.CodeDownload: sb.AppendFormat(Localization.Address_for_code_download_0, - StringHandlers.CToString(descriptor.Address)). - AppendLine(); + StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.Diagnostics: sb.AppendFormat(Localization.Address_for_diagnostics_0, - StringHandlers.CToString(descriptor.Address)). - AppendLine(); + StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.Logging: - sb.AppendFormat(Localization.Address_for_logging_0, StringHandlers.CToString(descriptor.Address)). - AppendLine(); + sb.AppendFormat(Localization.Address_for_logging_0, StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.Status: - sb.AppendFormat(Localization.Address_for_status_0, StringHandlers.CToString(descriptor.Address)). - AppendLine(); + sb.AppendFormat(Localization.Address_for_status_0, StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.StorageConf: sb.AppendFormat(Localization.Address_for_storage_configuration_service_0, - StringHandlers.CToString(descriptor.Address)). - AppendLine(); + StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.Unspecified: - sb.AppendFormat(Localization.Unspecified_address_0, StringHandlers.CToString(descriptor.Address)). - AppendLine(); + sb.AppendFormat(Localization.Unspecified_address_0, StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.CopyService: sb.AppendFormat(Localization.Address_for_copy_service_0, - StringHandlers.CToString(descriptor.Address)). - AppendLine(); + StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; case NetworkServiceTypes.Administrative: sb.AppendFormat(Localization.Address_for_administrative_configuration_service_0, - StringHandlers.CToString(descriptor.Address)). - AppendLine(); + StringHandlers.CToString(descriptor.Address)) + .AppendLine(); break; default: sb.AppendFormat(Localization.Address_of_unknown_type_1_0, - StringHandlers.CToString(descriptor.Address), (byte)descriptor.Type). - AppendLine(); + StringHandlers.CToString(descriptor.Address), + (byte)descriptor.Type) + .AppendLine(); break; } @@ -1168,14 +1144,11 @@ public static class EVPD public static Page_86? DecodePage_86(byte[] pageResponse) { - if(pageResponse?[1] != 0x86) - return null; + if(pageResponse?[1] != 0x86) return null; - if(pageResponse[3] + 4 != pageResponse.Length) - return null; + if(pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 64) - return null; + if(pageResponse.Length < 64) return null; return new Page_86 { @@ -1216,8 +1189,7 @@ public static class EVPD public static string PrettifyPage_86(Page_86? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_86 page = modePage.Value; var sb = new StringBuilder(); @@ -1260,8 +1232,8 @@ public static class EVPD break; default: sb.AppendFormat(Localization.Logical_unit_supports_unknown_protection_defined_by_code_0, - page.SPT). - AppendLine(); + page.SPT) + .AppendLine(); break; } @@ -1273,86 +1245,65 @@ public static class EVPD break; } - if(page.GRD_CHK) - sb.AppendLine(Localization.Device_checks_the_logical_block_guard); + if(page.GRD_CHK) sb.AppendLine(Localization.Device_checks_the_logical_block_guard); - if(page.APP_CHK) - sb.AppendLine(Localization.Device_checks_the_logical_block_application_tag); + if(page.APP_CHK) sb.AppendLine(Localization.Device_checks_the_logical_block_application_tag); - if(page.REF_CHK) - sb.AppendLine(Localization.Device_checks_the_logical_block_reference_tag); + if(page.REF_CHK) sb.AppendLine(Localization.Device_checks_the_logical_block_reference_tag); - if(page.UASK_SUP) - sb.AppendLine(Localization.Device_supports_unit_attention_condition_sense_key_specific_data); + if(page.UASK_SUP) sb.AppendLine(Localization.Device_supports_unit_attention_condition_sense_key_specific_data); - if(page.GROUP_SUP) - sb.AppendLine(Localization.Device_supports_grouping); + if(page.GROUP_SUP) sb.AppendLine(Localization.Device_supports_grouping); - if(page.PRIOR_SUP) - sb.AppendLine(Localization.Device_supports_priority); + if(page.PRIOR_SUP) sb.AppendLine(Localization.Device_supports_priority); - if(page.HEADSUP) - sb.AppendLine(Localization.Device_supports_head_of_queue); + if(page.HEADSUP) sb.AppendLine(Localization.Device_supports_head_of_queue); - if(page.ORDSUP) - sb.AppendLine(Localization.Device_supports_the_ORDERED_task_attribute); + if(page.ORDSUP) sb.AppendLine(Localization.Device_supports_the_ORDERED_task_attribute); - if(page.SIMPSUP) - sb.AppendLine(Localization.Device_supports_the_SIMPLE_task_attribute); + if(page.SIMPSUP) sb.AppendLine(Localization.Device_supports_the_SIMPLE_task_attribute); - if(page.WU_SUP) - sb.AppendLine(Localization.Device_supports_marking_a_block_as_uncorrectable_with_WRITE_LONG); + if(page.WU_SUP) sb.AppendLine(Localization.Device_supports_marking_a_block_as_uncorrectable_with_WRITE_LONG); - if(page.CRD_SUP) - sb.AppendLine(Localization.Device_supports_disabling_correction_with_WRITE_LONG); + if(page.CRD_SUP) sb.AppendLine(Localization.Device_supports_disabling_correction_with_WRITE_LONG); - if(page.NV_SUP) - sb.AppendLine(Localization.Device_has_a_non_volatile_cache); + if(page.NV_SUP) sb.AppendLine(Localization.Device_has_a_non_volatile_cache); - if(page.V_SUP) - sb.AppendLine(Localization.Device_has_a_volatile_cache); + if(page.V_SUP) sb.AppendLine(Localization.Device_has_a_volatile_cache); - if(page.NO_PI_CHK) - sb.AppendLine(Localization.Device_has_disabled_protection_information_checks); + if(page.NO_PI_CHK) sb.AppendLine(Localization.Device_has_disabled_protection_information_checks); - if(page.P_I_I_SUP) - sb.AppendLine(Localization.Device_supports_protection_information_intervals); + if(page.P_I_I_SUP) sb.AppendLine(Localization.Device_supports_protection_information_intervals); if(page.LUICLR) { - sb.AppendLine(Localization. - Device_clears_any_unit_attention_condition_in_all_LUNs_after_reporting_for_any_LUN); + sb.AppendLine(Localization + .Device_clears_any_unit_attention_condition_in_all_LUNs_after_reporting_for_any_LUN); } - if(page.R_SUP) - sb.AppendLine(Localization.Device_supports_referrals); + if(page.R_SUP) sb.AppendLine(Localization.Device_supports_referrals); - if(page.HSSRELEF) - sb.AppendLine(Localization.Device_implements_alternate_reset_handling); + if(page.HSSRELEF) sb.AppendLine(Localization.Device_implements_alternate_reset_handling); - if(page.CBCS) - sb.AppendLine(Localization.Device_supports_capability_based_command_security); + if(page.CBCS) sb.AppendLine(Localization.Device_supports_capability_based_command_security); - if(page.POA_SUP) - sb.AppendLine(Localization.Device_supports_power_on_activation_for_new_microcode); + if(page.POA_SUP) sb.AppendLine(Localization.Device_supports_power_on_activation_for_new_microcode); - if(page.HRA_SUP) - sb.AppendLine(Localization.Device_supports_hard_reset_activation_for_new_microcode); + if(page.HRA_SUP) sb.AppendLine(Localization.Device_supports_hard_reset_activation_for_new_microcode); - if(page.VSA_SUP) - sb.AppendLine(Localization.Device_supports_vendor_specific_activation_for_new_microcode); + if(page.VSA_SUP) sb.AppendLine(Localization.Device_supports_vendor_specific_activation_for_new_microcode); if(page.ExtendedTestMinutes > 0) { sb.AppendFormat(Localization.Extended_self_test_takes_0_to_complete, - TimeSpan.FromMinutes(page.ExtendedTestMinutes)). - AppendLine(); + TimeSpan.FromMinutes(page.ExtendedTestMinutes)) + .AppendLine(); } if(page.MaximumSenseLength > 0) { - sb.AppendFormat(Localization.Device_supports_a_maximum_of_0_bytes_for_sense_data, page.MaximumSenseLength). - AppendLine(); + sb.AppendFormat(Localization.Device_supports_a_maximum_of_0_bytes_for_sense_data, page.MaximumSenseLength) + .AppendLine(); } return sb.ToString(); @@ -1389,14 +1340,11 @@ public static class EVPD public static Page_89? DecodePage_89(byte[] pageResponse) { - if(pageResponse?[1] != 0x89) - return null; + if(pageResponse?[1] != 0x89) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 572) - return null; + if(pageResponse.Length < 572) return null; var decoded = new Page_89 { @@ -1425,8 +1373,7 @@ public static class EVPD // TODO: Decode ATA signature? public static string PrettifyPage_89(Page_89? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_89 page = modePage.Value; var sb = new StringBuilder(); @@ -1434,16 +1381,16 @@ public static class EVPD sb.AppendLine(Localization.SCSI_to_ATA_Translation_Layer_Data); sb.AppendFormat("\t" + Localization.Translation_layer_vendor_0, - VendorString.Prettify(StringHandlers.CToString(page.VendorIdentification).Trim())). - AppendLine(); + VendorString.Prettify(StringHandlers.CToString(page.VendorIdentification).Trim())) + .AppendLine(); sb.AppendFormat("\t" + Localization.Translation_layer_name_0, - StringHandlers.CToString(page.ProductIdentification).Trim()). - AppendLine(); + StringHandlers.CToString(page.ProductIdentification).Trim()) + .AppendLine(); sb.AppendFormat("\t" + Localization.Translation_layer_release_level_0, - StringHandlers.CToString(page.ProductRevisionLevel).Trim()). - AppendLine(); + StringHandlers.CToString(page.ProductRevisionLevel).Trim()) + .AppendLine(); switch(page.CommandCode) { @@ -1472,8 +1419,8 @@ public static class EVPD break; default: - sb.AppendFormat("\t" + Localization.Device_uses_unknown_transport_with_code_0, page.Signature[0]). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_uses_unknown_transport_with_code_0, page.Signature[0]) + .AppendLine(); break; } @@ -1518,14 +1465,11 @@ public static class EVPD public static Page_C0_Quantum? DecodePage_C0_Quantum(byte[] pageResponse) { - if(pageResponse?[1] != 0xC0) - return null; + if(pageResponse?[1] != 0xC0) return null; - if(pageResponse[3] != 20) - return null; + if(pageResponse[3] != 20) return null; - if(pageResponse.Length != 36) - return null; + if(pageResponse.Length != 36) return null; var decoded = new Page_C0_Quantum { @@ -1551,8 +1495,7 @@ public static class EVPD public static string PrettifyPage_C0_Quantum(Page_C0_Quantum? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C0_Quantum page = modePage.Value; var sb = new StringBuilder(); @@ -1562,12 +1505,12 @@ public static class EVPD sb.AppendFormat("\t" + Localization.Quantum_Servo_firmware_checksum_0, page.ServoFirmwareChecksum).AppendLine(); sb.AppendFormat("\t" + Localization.Quantum_EEPROM_firmware_checksum_0, page.ServoEEPROMChecksum).AppendLine(); - sb.AppendFormat("\t" + Localization.Quantum_Read_write_firmware_checksum_0, page.ReadWriteFirmwareChecksum). - AppendLine(); + sb.AppendFormat("\t" + Localization.Quantum_Read_write_firmware_checksum_0, page.ReadWriteFirmwareChecksum) + .AppendLine(); sb.AppendFormat("\t" + Localization.Quantum_Read_write_firmware_build_date_0, - StringHandlers.CToString(page.ReadWriteFirmwareBuildData)). - AppendLine(); + StringHandlers.CToString(page.ReadWriteFirmwareBuildData)) + .AppendLine(); return sb.ToString(); } @@ -1595,17 +1538,13 @@ public static class EVPD public static Page_C0_C1_Certance? DecodePage_C0_C1_Certance(byte[] pageResponse) { - if(pageResponse == null) - return null; + if(pageResponse == null) return null; - if(pageResponse[1] != 0xC0 && pageResponse[1] != 0xC1) - return null; + if(pageResponse[1] != 0xC0 && pageResponse[1] != 0xC1) return null; - if(pageResponse[3] != 92) - return null; + if(pageResponse[3] != 92) return null; - if(pageResponse.Length != 96) - return null; + if(pageResponse.Length != 96) return null; var decoded = new Page_C0_C1_Certance { @@ -1631,16 +1570,15 @@ public static class EVPD public static string PrettifyPage_C0_C1_Certance(Page_C0_C1_Certance? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C0_C1_Certance page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Certance_Certance_Drive_Component_Revision_Levels_page); - sb.AppendFormat("\t" + Localization.Certance_Component_0, StringHandlers.CToString(page.Component)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Certance_Component_0, StringHandlers.CToString(page.Component)) + .AppendLine(); sb.AppendFormat("\t" + Localization.Certance_Version_0, StringHandlers.CToString(page.Version)).AppendLine(); sb.AppendFormat("\t" + Localization.Certance_Date_0, StringHandlers.CToString(page.Date)).AppendLine(); @@ -1669,8 +1607,7 @@ public static class EVPD public static Page_C2_C3_C4_C5_C6_Certance? DecodePage_C2_C3_C4_C5_C6_Certance(byte[] pageResponse) { - if(pageResponse == null) - return null; + if(pageResponse == null) return null; if(pageResponse[1] != 0xC2 && pageResponse[1] != 0xC3 && @@ -1679,11 +1616,9 @@ public static class EVPD pageResponse[1] != 0xC6) return null; - if(pageResponse[3] != 12) - return null; + if(pageResponse[3] != 12) return null; - if(pageResponse.Length != 16) - return null; + if(pageResponse.Length != 16) return null; var decoded = new Page_C2_C3_C4_C5_C6_Certance { @@ -1703,8 +1638,7 @@ public static class EVPD public static string PrettifyPage_C2_C3_C4_C5_C6_Certance(Page_C2_C3_C4_C5_C6_Certance? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C2_C3_C4_C5_C6_Certance page = modePage.Value; var sb = new StringBuilder(); @@ -1715,32 +1649,32 @@ public static class EVPD { case 0xC2: sb.AppendFormat("\t" + Localization.Certance_Head_Assembly_Serial_Number_0, - StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + StringHandlers.CToString(page.SerialNumber)) + .AppendLine(); break; case 0xC3: sb.AppendFormat("\t" + Localization.Certance_Reel_Motor_1_Serial_Number_0, - StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + StringHandlers.CToString(page.SerialNumber)) + .AppendLine(); break; case 0xC4: sb.AppendFormat("\t" + Localization.Certance_Reel_Motor_2_Serial_Number_0, - StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + StringHandlers.CToString(page.SerialNumber)) + .AppendLine(); break; case 0xC5: sb.AppendFormat("\t" + Localization.Certance_Board_Serial_Number_0, - StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + StringHandlers.CToString(page.SerialNumber)) + .AppendLine(); break; case 0xC6: sb.AppendFormat("\t" + Localization.Certance_Base_Mechanical_Serial_Number_0, - StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + StringHandlers.CToString(page.SerialNumber)) + .AppendLine(); break; } @@ -1799,14 +1733,11 @@ public static class EVPD public static Page_DF_Certance? DecodePage_DF_Certance(byte[] pageResponse) { - if(pageResponse?[1] != 0xDF) - return null; + if(pageResponse?[1] != 0xDF) return null; - if(pageResponse[3] != 60) - return null; + if(pageResponse[3] != 60) return null; - if(pageResponse.Length != 64) - return null; + if(pageResponse.Length != 64) return null; var decoded = new Page_DF_Certance { @@ -1846,8 +1777,7 @@ public static class EVPD public static string PrettifyPage_DF_Certance(Page_DF_Certance? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_DF_Certance page = modePage.Value; var sb = new StringBuilder(); @@ -1870,23 +1800,18 @@ public static class EVPD break; } - if(page.Alerts) - sb.AppendLine("\t" + Localization.Alerts_are_enabled); + if(page.Alerts) sb.AppendLine("\t" + Localization.Alerts_are_enabled); - if(page.NoRemov) - sb.AppendLine("\t" + Localization.Cartridge_removable_is_prevented); + if(page.NoRemov) sb.AppendLine("\t" + Localization.Cartridge_removable_is_prevented); if(page.UnitRsvd) sb.AppendFormat("\t" + Localization.Unit_is_reserved_by_initiator_ID_0, page.InitiatorID).AppendLine(); - if(page.Clean) - sb.AppendLine("\t" + Localization.Device_needs_cleaning_cartridge); + if(page.Clean) sb.AppendLine("\t" + Localization.Device_needs_cleaning_cartridge); - if(page.Threaded) - sb.AppendLine("\t" + Localization.Cartridge_tape_is_threaded); + if(page.Threaded) sb.AppendLine("\t" + Localization.Cartridge_tape_is_threaded); - if(page.Lun1Cmd) - sb.AppendLine("\t" + Localization.There_are_commands_pending_to_be_forwarded); + if(page.Lun1Cmd) sb.AppendLine("\t" + Localization.There_are_commands_pending_to_be_forwarded); switch(page.AutoloadMode) { @@ -1919,8 +1844,8 @@ public static class EVPD break; default: - sb.AppendFormat("\t" + Localization.Unknown_port_A_transport_type_code_0, page.PortATransportType). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_port_A_transport_type_code_0, page.PortATransportType) + .AppendLine(); break; } @@ -1928,8 +1853,8 @@ public static class EVPD if(page.PortATransportType > 0) sb.AppendFormat("\t" + Localization.Drive_responds_to_SCSI_ID_0, page.PortASelectionID).AppendLine(); - sb.AppendFormat("\t" + Localization.Drive_has_been_operating_0, TimeSpan.FromHours(page.OperatingHours)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_has_been_operating_0, TimeSpan.FromHours(page.OperatingHours)) + .AppendLine(); if(page.CartridgeType > 0) { @@ -1940,8 +1865,8 @@ public static class EVPD break; default: - sb.AppendFormat("\t" + Localization.Unknown_cartridge_format_code_0, page.CartridgeType). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_cartridge_format_code_0, page.CartridgeType) + .AppendLine(); break; } @@ -1991,12 +1916,12 @@ public static class EVPD } sb.AppendFormat("\t" + Localization.Cartridge_has_an_uncompressed_capability_of_0_gigabytes, - page.CartridgeCapacity). - AppendLine(); + page.CartridgeCapacity) + .AppendLine(); sb.AppendFormat("\t" + Localization.Cartridge_serial_number_0, - StringHandlers.SpacePaddedToString(page.CartridgeSerialNumber)). - AppendLine(); + StringHandlers.SpacePaddedToString(page.CartridgeSerialNumber)) + .AppendLine(); } else sb.AppendLine("\t" + Localization.There_is_no_cartridge_inserted); @@ -2025,14 +1950,11 @@ public static class EVPD public static Page_C0_IBM? DecodePage_C0_IBM(byte[] pageResponse) { - if(pageResponse?[1] != 0xC0) - return null; + if(pageResponse?[1] != 0xC0) return null; - if(pageResponse[3] != 39) - return null; + if(pageResponse[3] != 39) return null; - if(pageResponse.Length != 43) - return null; + if(pageResponse.Length != 43) return null; var decoded = new Page_C0_IBM { @@ -2054,8 +1976,7 @@ public static class EVPD public static string PrettifyPage_C0_IBM(Page_C0_IBM? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C0_IBM page = modePage.Value; var sb = new StringBuilder(); @@ -2089,14 +2010,11 @@ public static class EVPD public static Page_C1_IBM? DecodePage_C1_IBM(byte[] pageResponse) { - if(pageResponse?[1] != 0xC1) - return null; + if(pageResponse?[1] != 0xC1) return null; - if(pageResponse[3] != 24) - return null; + if(pageResponse[3] != 24) return null; - if(pageResponse.Length != 28) - return null; + if(pageResponse.Length != 28) return null; var decoded = new Page_C1_IBM { @@ -2118,8 +2036,7 @@ public static class EVPD public static string PrettifyPage_C1_IBM(Page_C1_IBM? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C1_IBM page = modePage.Value; var sb = new StringBuilder(); @@ -2127,11 +2044,11 @@ public static class EVPD sb.AppendLine(Localization.IBM_Drive_Serial_Numbers_page); sb.AppendFormat("\t" + Localization.Manufacturing_serial_number_0, - StringHandlers.CToString(page.ManufacturingSerial)). - AppendLine(); + StringHandlers.CToString(page.ManufacturingSerial)) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Reported_serial_number_0, StringHandlers.CToString(page.ReportedSerial)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Reported_serial_number_0, StringHandlers.CToString(page.ReportedSerial)) + .AppendLine(); return sb.ToString(); } @@ -2157,14 +2074,11 @@ public static class EVPD public static Page_B0? DecodePage_B0(byte[] pageResponse) { - if(pageResponse?[1] != 0xB0) - return null; + if(pageResponse?[1] != 0xB0) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 5) - return null; + if(pageResponse.Length < 5) return null; var decoded = new Page_B0 { @@ -2182,19 +2096,16 @@ public static class EVPD public static string PrettifyPage_B0(Page_B0? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_B0 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Sequential_access_Device_Capabilities); - if(page.WORM) - sb.AppendLine("\t" + Localization.Device_supports_WORM_media); + if(page.WORM) sb.AppendLine("\t" + Localization.Device_supports_WORM_media); - if(page.TSMC) - sb.AppendLine("\t" + Localization.Device_supports_Tape_Stream_Mirroring); + if(page.TSMC) sb.AppendLine("\t" + Localization.Device_supports_Tape_Stream_Mirroring); return sb.ToString(); } @@ -2223,8 +2134,7 @@ public static class EVPD public static Page_C0_to_C5_HP? DecodePage_C0_to_C5_HP(byte[] pageResponse) { - if(pageResponse == null) - return null; + if(pageResponse == null) return null; if(pageResponse[1] != 0xC0 && pageResponse[1] != 0xC1 && @@ -2234,8 +2144,7 @@ public static class EVPD pageResponse[1] != 0xC5) return null; - if(pageResponse.Length < 4) - return null; + if(pageResponse.Length < 4) return null; var decoded = new Page_C0_to_C5_HP { @@ -2260,8 +2169,7 @@ public static class EVPD return decoded; } - if(pageResponse[4] != pageResponse[3] - 1) - return null; + if(pageResponse[4] != pageResponse[3] - 1) return null; List array = new(); @@ -2312,8 +2220,7 @@ public static class EVPD public static string PrettifyPage_C0_to_C5_HP(Page_C0_to_C5_HP? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C0_to_C5_HP page = modePage.Value; var sb = new StringBuilder(); @@ -2348,14 +2255,14 @@ public static class EVPD if(page.Component is { Length: > 0 }) { - sb.AppendFormat("\t" + Localization.Certance_Component_0, StringHandlers.CToString(page.Component)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Certance_Component_0, StringHandlers.CToString(page.Component)) + .AppendLine(); } if(page.Version is { Length: > 0 }) { - sb.AppendFormat("\t" + Localization.Certance_Version_0, StringHandlers.CToString(page.Version)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Certance_Version_0, StringHandlers.CToString(page.Version)) + .AppendLine(); } if(page.Date is { Length: > 0 }) @@ -2363,8 +2270,8 @@ public static class EVPD if(page.Variant is { Length: > 0 }) { - sb.AppendFormat("\t" + Localization.Certance_Variant_0, StringHandlers.CToString(page.Variant)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Certance_Variant_0, StringHandlers.CToString(page.Variant)) + .AppendLine(); } if(page.Copyright is { Length: > 0 }) @@ -2395,14 +2302,11 @@ public static class EVPD public static Page_C0_Seagate? DecodePage_C0_Seagate(byte[] pageResponse) { - if(pageResponse?[1] != 0xC0) - return null; + if(pageResponse?[1] != 0xC0) return null; - if(pageResponse[3] != 12) - return null; + if(pageResponse[3] != 12) return null; - if(pageResponse.Length != 16) - return null; + if(pageResponse.Length != 16) return null; var decoded = new Page_C0_Seagate { @@ -2427,8 +2331,7 @@ public static class EVPD public static string PrettifyPage_C0_Seagate(Page_C0_Seagate? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Page_C0_Seagate page = modePage.Value; var sb = new StringBuilder(); @@ -2436,14 +2339,14 @@ public static class EVPD sb.AppendLine(Localization.Seagate_Firmware_Numbers_page); sb.AppendFormat("\t" + Localization.Controller_firmware_version_0, - StringHandlers.CToString(page.ControllerFirmware)). - AppendLine(); + StringHandlers.CToString(page.ControllerFirmware)) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Boot_firmware_version_0, StringHandlers.CToString(page.BootFirmware)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Boot_firmware_version_0, StringHandlers.CToString(page.BootFirmware)) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Servo_firmware_version_0, StringHandlers.CToString(page.ServoFirmware)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Servo_firmware_version_0, StringHandlers.CToString(page.ServoFirmware)) + .AppendLine(); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Inquiry.cs b/Aaru.Decoders/SCSI/Inquiry.cs index 9ce7e2d60..866749882 100644 --- a/Aaru.Decoders/SCSI/Inquiry.cs +++ b/Aaru.Decoders/SCSI/Inquiry.cs @@ -56,23 +56,22 @@ public static class Inquiry { public static string Prettify(CommonTypes.Structs.Devices.SCSI.Inquiry? SCSIInquiryResponse) { - if(SCSIInquiryResponse == null) - return null; + if(SCSIInquiryResponse == null) return null; CommonTypes.Structs.Devices.SCSI.Inquiry response = SCSIInquiryResponse.Value; var sb = new StringBuilder(); sb.AppendFormat(Localization.Device_vendor_0, - VendorString.Prettify(StringHandlers.CToString(response.VendorIdentification).Trim())). - AppendLine(); + VendorString.Prettify(StringHandlers.CToString(response.VendorIdentification).Trim())) + .AppendLine(); - sb.AppendFormat(Localization.Device_name_0, StringHandlers.CToString(response.ProductIdentification).Trim()). - AppendLine(); + sb.AppendFormat(Localization.Device_name_0, StringHandlers.CToString(response.ProductIdentification).Trim()) + .AppendLine(); sb.AppendFormat(Localization.Device_release_level_0, - StringHandlers.CToString(response.ProductRevisionLevel).Trim()). - AppendLine(); + StringHandlers.CToString(response.ProductRevisionLevel).Trim()) + .AppendLine(); switch((PeripheralQualifiers)response.PeripheralQualifier) { @@ -94,8 +93,8 @@ public static class Inquiry break; default: sb.AppendFormat(Localization.Vendor_value_0_set_in_Peripheral_Qualifier_field, - response.PeripheralQualifier). - AppendLine(); + response.PeripheralQualifier) + .AppendLine(); break; } @@ -195,8 +194,8 @@ public static class Inquiry break; default: - sb.AppendFormat(Localization.Unknown_device_type_field_value_0, response.PeripheralDeviceType). - AppendLine(); + sb.AppendFormat(Localization.Unknown_device_type_field_value_0, response.PeripheralDeviceType) + .AppendLine(); break; } @@ -233,8 +232,8 @@ public static class Inquiry break; default: sb.AppendFormat(Localization.Device_claims_to_comply_with_unknown_SCSI_ANSI_standard_value_0, - response.ANSIVersion). - AppendLine(); + response.ANSIVersion) + .AppendLine(); break; } @@ -251,8 +250,8 @@ public static class Inquiry break; default: sb.AppendFormat(Localization.Device_claims_to_comply_with_unknown_SCSI_ECMA_standard_value_0, - response.ECMAVersion). - AppendLine(); + response.ECMAVersion) + .AppendLine(); break; } @@ -269,93 +268,67 @@ public static class Inquiry break; default: sb.AppendFormat(Localization.Device_claims_to_comply_with_unknown_SCSI_ISO_IEC_standard_value_0, - response.ISOVersion). - AppendLine(); + response.ISOVersion) + .AppendLine(); break; } - if(response.RMB) - sb.AppendLine(Localization.Device_is_removable); + if(response.RMB) sb.AppendLine(Localization.Device_is_removable); - if(response.AERC) - sb.AppendLine(Localization.Device_supports_Asynchronous_Event_Reporting_Capability); + if(response.AERC) sb.AppendLine(Localization.Device_supports_Asynchronous_Event_Reporting_Capability); - if(response.TrmTsk) - sb.AppendLine(Localization.Device_supports_TERMINATE_TASK_command); + if(response.TrmTsk) sb.AppendLine(Localization.Device_supports_TERMINATE_TASK_command); - if(response.NormACA) - sb.AppendLine(Localization.Device_supports_setting_Normal_ACA); + if(response.NormACA) sb.AppendLine(Localization.Device_supports_setting_Normal_ACA); - if(response.HiSup) - sb.AppendLine(Localization.Device_supports_LUN_hierarchical_addressing); + if(response.HiSup) sb.AppendLine(Localization.Device_supports_LUN_hierarchical_addressing); - if(response.SCCS) - sb.AppendLine(Localization.Device_contains_an_embedded_storage_array_controller); + if(response.SCCS) sb.AppendLine(Localization.Device_contains_an_embedded_storage_array_controller); - if(response.ACC) - sb.AppendLine(Localization.Device_contains_an_Access_Control_Coordinator); + if(response.ACC) sb.AppendLine(Localization.Device_contains_an_Access_Control_Coordinator); - if(response.ThreePC) - sb.AppendLine(Localization.Device_supports_third_party_copy_commands); + if(response.ThreePC) sb.AppendLine(Localization.Device_supports_third_party_copy_commands); - if(response.Protect) - sb.AppendLine(Localization.Device_supports_protection_information); + if(response.Protect) sb.AppendLine(Localization.Device_supports_protection_information); - if(response.BQue) - sb.AppendLine(Localization.Device_supports_basic_queueing); + if(response.BQue) sb.AppendLine(Localization.Device_supports_basic_queueing); - if(response.EncServ) - sb.AppendLine(Localization.Device_contains_an_embedded_enclosure_services_component); + if(response.EncServ) sb.AppendLine(Localization.Device_contains_an_embedded_enclosure_services_component); - if(response.MultiP) - sb.AppendLine(Localization.Multi_port_device); + if(response.MultiP) sb.AppendLine(Localization.Multi_port_device); - if(response.MChngr) - sb.AppendLine(Localization.Device_contains_or_is_attached_to_a_medium_changer); + if(response.MChngr) sb.AppendLine(Localization.Device_contains_or_is_attached_to_a_medium_changer); - if(response.ACKREQQ) - sb.AppendLine(Localization.Device_supports_request_and_acknowledge_handshakes); + if(response.ACKREQQ) sb.AppendLine(Localization.Device_supports_request_and_acknowledge_handshakes); - if(response.Addr32) - sb.AppendLine(Localization.Device_supports_32_bit_wide_SCSI_addresses); + if(response.Addr32) sb.AppendLine(Localization.Device_supports_32_bit_wide_SCSI_addresses); - if(response.Addr16) - sb.AppendLine(Localization.Device_supports_16_bit_wide_SCSI_addresses); + if(response.Addr16) sb.AppendLine(Localization.Device_supports_16_bit_wide_SCSI_addresses); - if(response.RelAddr) - sb.AppendLine(Localization.Device_supports_relative_addressing); + if(response.RelAddr) sb.AppendLine(Localization.Device_supports_relative_addressing); - if(response.WBus32) - sb.AppendLine(Localization.Device_supports_32_bit_wide_data_transfers); + if(response.WBus32) sb.AppendLine(Localization.Device_supports_32_bit_wide_data_transfers); - if(response.WBus16) - sb.AppendLine(Localization.Device_supports_16_bit_wide_data_transfers); + if(response.WBus16) sb.AppendLine(Localization.Device_supports_16_bit_wide_data_transfers); - if(response.Sync) - sb.AppendLine(Localization.Device_supports_synchronous_data_transfer); + if(response.Sync) sb.AppendLine(Localization.Device_supports_synchronous_data_transfer); - if(response.Linked) - sb.AppendLine(Localization.Device_supports_linked_commands); + if(response.Linked) sb.AppendLine(Localization.Device_supports_linked_commands); if(response.TranDis) sb.AppendLine(Localization.Device_supports_CONTINUE_TASK_and_TARGET_TRANSFER_DISABLE_commands); - if(response.QAS) - sb.AppendLine(Localization.Device_supports_Quick_Arbitration_and_Selection); + if(response.QAS) sb.AppendLine(Localization.Device_supports_Quick_Arbitration_and_Selection); - if(response.CmdQue) - sb.AppendLine(Localization.Device_supports_TCQ_queue); + if(response.CmdQue) sb.AppendLine(Localization.Device_supports_TCQ_queue); - if(response.IUS) - sb.AppendLine(Localization.Device_supports_information_unit_transfers); + if(response.IUS) sb.AppendLine(Localization.Device_supports_information_unit_transfers); - if(response.SftRe) - sb.AppendLine(Localization.Device_implements_RESET_as_a_soft_reset); - #if DEBUG - if(response.VS1) - sb.AppendLine(Localization.Vendor_specific_bit_5_on_byte_6_of_INQUIRY_response_is_set); - #endif + if(response.SftRe) sb.AppendLine(Localization.Device_implements_RESET_as_a_soft_reset); +#if DEBUG + if(response.VS1) sb.AppendLine(Localization.Vendor_specific_bit_5_on_byte_6_of_INQUIRY_response_is_set); +#endif switch((TGPSValues)response.TPGS) { @@ -583,13 +556,13 @@ public static class Inquiry break; case 0x01DD: - sb.AppendLine(Localization. - Device_complies_with_SES_T10_1212_revision_08b_Amendment_ANSI_INCITS_305_AM1_2000); + sb.AppendLine(Localization + .Device_complies_with_SES_T10_1212_revision_08b_Amendment_ANSI_INCITS_305_AM1_2000); break; case 0x01DE: - sb.AppendLine(Localization. - Device_complies_with_SES_ANSI_INCITS_305_1998_Amendment_ANSI_INCITS_305_AM1_2000); + sb.AppendLine(Localization + .Device_complies_with_SES_ANSI_INCITS_305_1998_Amendment_ANSI_INCITS_305_AM1_2000); break; case 0x01E0: @@ -1037,8 +1010,8 @@ public static class Inquiry break; case 0x04E7: - sb.AppendLine(Localization. - Device_complies_with_MMC_6_ANSI_INCITS_468_2010_MMC_6_AM1_ANSI_INCITS_468_2010_AM_1); + sb.AppendLine(Localization + .Device_complies_with_MMC_6_ANSI_INCITS_468_2010_MMC_6_AM1_ANSI_INCITS_468_2010_AM_1); break; case 0x0500: @@ -1284,8 +1257,8 @@ public static class Inquiry case 0x097D: case 0x097E: case 0x097F: - sb.AppendFormat(Localization.Device_complies_with_iSCSI_revision_0, VersionDescriptor & 0x1F). - AppendLine(); + sb.AppendFormat(Localization.Device_complies_with_iSCSI_revision_0, VersionDescriptor & 0x1F) + .AppendLine(); break; case 0x0980: @@ -1409,13 +1382,13 @@ public static class Inquiry break; case 0x0ABB: - sb.AppendLine(Localization. - Device_complies_with_SPI_T10_0855_D_revision_15a_with_SPI_Amnd_revision_3a); + sb.AppendLine(Localization + .Device_complies_with_SPI_T10_0855_D_revision_15a_with_SPI_Amnd_revision_3a); break; case 0x0ABC: - sb.AppendLine(Localization. - Device_complies_with_SPI_ANSI_INCITS_253_1995_with_SPI_Amnd_ANSI_INCITS_253_AM1_1998); + sb.AppendLine(Localization + .Device_complies_with_SPI_ANSI_INCITS_253_1995_with_SPI_Amnd_ANSI_INCITS_253_AM1_1998); break; case 0x0AC0: @@ -1603,8 +1576,8 @@ public static class Inquiry break; case 0x0C4F: - sb.AppendLine(Localization. - Device_complies_with_SAS_2_1_ANSI_INCITS_478_2011_w__Amnd_1_ANSI_INCITS_478_AM1_2014); + sb.AppendLine(Localization + .Device_complies_with_SAS_2_1_ANSI_INCITS_478_2011_w__Amnd_1_ANSI_INCITS_478_AM1_2014); break; case 0x0C52: @@ -1640,8 +1613,8 @@ public static class Inquiry break; case 0x0D3C: - sb.AppendLine(Localization. - Device_complies_with_FC_PH_ANSI_INCITS_230_1994_with_Amnd_1_ANSI_INCITS_230_AM1_1996); + sb.AppendLine(Localization + .Device_complies_with_FC_PH_ANSI_INCITS_230_1994_with_Amnd_1_ANSI_INCITS_230_AM1_1996); break; case 0x0D40: @@ -1661,13 +1634,13 @@ public static class Inquiry break; case 0x0D63: - sb.AppendLine(Localization. - Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_AM1_2003___AM2_2006); + sb.AppendLine(Localization + .Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_AM1_2003___AM2_2006); break; case 0x0D64: - sb.AppendLine(Localization. - Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_Amnd_2_AM2_2006); + sb.AppendLine(Localization + .Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_Amnd_2_AM2_2006); break; case 0x0D65: @@ -1679,8 +1652,8 @@ public static class Inquiry break; case 0x0D7D: - sb.AppendLine(Localization. - Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_Amnd_1_AM1_2003); + sb.AppendLine(Localization + .Device_complies_with_FC_AL_2_ANSI_INCITS_332_1999_with_Amnd_1_AM1_2003); break; case 0x0D80: @@ -1740,8 +1713,8 @@ public static class Inquiry break; case 0x0E03: - sb.AppendLine(Localization. - Device_complies_with_FC_FS_2_ANSI_INCITS_242_2007_with_AM1_ANSI_INCITS_242_AM1_2007); + sb.AppendLine(Localization + .Device_complies_with_FC_FS_2_ANSI_INCITS_242_2007_with_AM1_ANSI_INCITS_242_AM1_2007); break; case 0x0E20: @@ -1817,8 +1790,8 @@ public static class Inquiry break; case 0x0EA6: - sb.AppendLine(Localization. - Device_complies_with_FC_10GFC_ANSI_INCITS_364_2003_with_AM1_ANSI_INCITS_364_AM1_2007); + sb.AppendLine(Localization + .Device_complies_with_FC_10GFC_ANSI_INCITS_364_2003_with_AM1_ANSI_INCITS_364_AM1_2007); break; case 0x0EC0: @@ -2058,18 +2031,18 @@ public static class Inquiry break; case 0x1621: - sb.AppendLine(Localization. - Device_complies_with_ATA_ATAPI_8_ATA8_APT_Parallel_Transport_no_version_claimed); + sb.AppendLine(Localization + .Device_complies_with_ATA_ATAPI_8_ATA8_APT_Parallel_Transport_no_version_claimed); break; case 0x1622: - sb.AppendLine(Localization. - Device_complies_with_ATA_ATAPI_8_ATA8_AST_Serial_Transport_no_version_claimed); + sb.AppendLine(Localization + .Device_complies_with_ATA_ATAPI_8_ATA8_AST_Serial_Transport_no_version_claimed); break; case 0x1623: - sb.AppendLine(Localization. - Device_complies_with_ATA_ATAPI_8_ATA8_ACS_ATA_ATAPI_Command_Set_no_version_claimed); + sb.AppendLine(Localization + .Device_complies_with_ATA_ATAPI_8_ATA8_ACS_ATA_ATAPI_Command_Set_no_version_claimed); break; case 0x1628: @@ -2077,23 +2050,23 @@ public static class Inquiry break; case 0x162A: - sb.AppendLine(Localization. - Device_complies_with_ATA_ATAPI_8_ATA8_ACS_ANSI_INCITS_452_2009_w__Amendment_1); + sb.AppendLine(Localization + .Device_complies_with_ATA_ATAPI_8_ATA8_ACS_ANSI_INCITS_452_2009_w__Amendment_1); break; case 0x1728: - sb.AppendLine(Localization. - Device_complies_with_Universal_Serial_Bus_Specification__Revision_1_1); + sb.AppendLine(Localization + .Device_complies_with_Universal_Serial_Bus_Specification__Revision_1_1); break; case 0x1729: - sb.AppendLine(Localization. - Device_complies_with_Universal_Serial_Bus_Specification__Revision_2_0); + sb.AppendLine(Localization + .Device_complies_with_Universal_Serial_Bus_Specification__Revision_2_0); break; case 0x1730: - sb.AppendLine(Localization. - Device_complies_with_USB_Mass_Storage_Class_Bulk_Only_Transport__Revision_1_0); + sb.AppendLine(Localization + .Device_complies_with_USB_Mass_Storage_Class_Bulk_Only_Transport__Revision_1_0); break; case 0x1740: @@ -2201,8 +2174,8 @@ public static class Inquiry break; case 0x20A8: - sb.AppendLine(Localization. - Device_complies_with_SPL_ANSI_INCITS_476_2011_SPL_AM1_INCITS_476_AM1_2012); + sb.AppendLine(Localization + .Device_complies_with_SPL_ANSI_INCITS_476_2011_SPL_AM1_INCITS_476_AM1_2012); break; case 0x20AA: @@ -2298,15 +2271,15 @@ public static class Inquiry break; default: - sb.AppendFormat(Localization.Device_complies_with_unknown_standard_code_0, VersionDescriptor). - AppendLine(); + sb.AppendFormat(Localization.Device_complies_with_unknown_standard_code_0, VersionDescriptor) + .AppendLine(); break; } } } - #region Quantum vendor prettifying +#region Quantum vendor prettifying if(response.QuantumPresent && StringHandlers.CToString(response.VendorIdentification).ToLowerInvariant().Trim() == "quantum") @@ -2347,48 +2320,48 @@ public static class Inquiry sb.AppendFormat(Localization.Release_firmware_0, response.Qt_ReleasedFirmware).AppendLine(); - sb.AppendFormat(Localization.Firmware_version_0_1, response.Qt_FirmwareMajorVersion, - response.Qt_FirmwareMinorVersion). - AppendLine(); + sb.AppendFormat(Localization.Firmware_version_0_1, + response.Qt_FirmwareMajorVersion, + response.Qt_FirmwareMinorVersion) + .AppendLine(); - sb.AppendFormat(Localization.EEPROM_format_version_0_1, response.Qt_EEPROMFormatMajorVersion, - response.Qt_EEPROMFormatMinorVersion). - AppendLine(); + sb.AppendFormat(Localization.EEPROM_format_version_0_1, + response.Qt_EEPROMFormatMajorVersion, + response.Qt_EEPROMFormatMinorVersion) + .AppendLine(); sb.AppendFormat(Localization.Firmware_personality_0, response.Qt_FirmwarePersonality).AppendLine(); sb.AppendFormat(Localization.Firmware_sub_personality_0, response.Qt_FirmwareSubPersonality).AppendLine(); - sb.AppendFormat(Localization.Tape_directory_format_version_0, response.Qt_TapeDirectoryFormatVersion). - AppendLine(); + sb.AppendFormat(Localization.Tape_directory_format_version_0, response.Qt_TapeDirectoryFormatVersion) + .AppendLine(); - sb.AppendFormat(Localization.Controller_hardware_version_0, response.Qt_ControllerHardwareVersion). - AppendLine(); + sb.AppendFormat(Localization.Controller_hardware_version_0, response.Qt_ControllerHardwareVersion) + .AppendLine(); sb.AppendFormat(Localization.Drive_EEPROM_version_0, response.Qt_DriveEEPROMVersion).AppendLine(); sb.AppendFormat(Localization.Drive_hardware_version_0, response.Qt_DriveHardwareVersion).AppendLine(); - sb.AppendFormat(Localization.Media_loader_firmware_version_0, response.Qt_MediaLoaderFirmwareVersion). - AppendLine(); + sb.AppendFormat(Localization.Media_loader_firmware_version_0, response.Qt_MediaLoaderFirmwareVersion) + .AppendLine(); - sb.AppendFormat(Localization.Media_loader_hardware_version_0, response.Qt_MediaLoaderHardwareVersion). - AppendLine(); + sb.AppendFormat(Localization.Media_loader_hardware_version_0, response.Qt_MediaLoaderHardwareVersion) + .AppendLine(); - sb.AppendFormat(Localization.Media_loader_mechanical_version_0, response.Qt_MediaLoaderMechanicalVersion). - AppendLine(); + sb.AppendFormat(Localization.Media_loader_mechanical_version_0, response.Qt_MediaLoaderMechanicalVersion) + .AppendLine(); - if(response.Qt_LibraryPresent) - sb.AppendLine(Localization.Library_is_present); + if(response.Qt_LibraryPresent) sb.AppendLine(Localization.Library_is_present); - if(response.Qt_MediaLoaderPresent) - sb.AppendLine(Localization.Media_loader_is_present); + if(response.Qt_MediaLoaderPresent) sb.AppendLine(Localization.Media_loader_is_present); - sb.AppendFormat(Localization.Module_revision_0, StringHandlers.CToString(response.Qt_ModuleRevision)). - AppendLine(); + sb.AppendFormat(Localization.Module_revision_0, StringHandlers.CToString(response.Qt_ModuleRevision)) + .AppendLine(); } - #endregion Quantum vendor prettifying +#endregion Quantum vendor prettifying - #region IBM vendor prettifying +#region IBM vendor prettifying if(response.IBMPresent && StringHandlers.CToString(response.VendorIdentification).ToLowerInvariant().Trim() == "ibm") @@ -2400,15 +2373,14 @@ public static class Inquiry else sb.AppendFormat(Localization.Performance_is_limited_using_factor_0, response.IBM_PerformanceLimit); - if(response.IBM_AutDis) - sb.AppendLine(Localization.Automation_is_disabled); + if(response.IBM_AutDis) sb.AppendLine(Localization.Automation_is_disabled); sb.AppendFormat(Localization.IBM_OEM_Specific_Field_0, response.IBM_OEMSpecific).AppendLine(); } - #endregion IBM vendor prettifying +#endregion IBM vendor prettifying - #region HP vendor prettifying +#region HP vendor prettifying if(response.HPPresent && StringHandlers.CToString(response.VendorIdentification).ToLowerInvariant().Trim() == "hp") @@ -2424,9 +2396,9 @@ public static class Inquiry sb.AppendLine(Localization.Device_supports_Tape_Disaster_Recovery); } - #endregion HP vendor prettifying +#endregion HP vendor prettifying - #region Seagate vendor prettifying +#region Seagate vendor prettifying if((response.SeagatePresent || response.Seagate2Present || response.Seagate3Present) && StringHandlers.CToString(response.VendorIdentification).ToLowerInvariant().Trim() == "seagate") @@ -2436,38 +2408,38 @@ public static class Inquiry if(response.SeagatePresent) { sb.AppendFormat(Core.Drive_serial_number_0, - StringHandlers.CToString(response.Seagate_DriveSerialNumber)). - AppendLine(); + StringHandlers.CToString(response.Seagate_DriveSerialNumber)) + .AppendLine(); } if(response.Seagate2Present) { - sb.AppendFormat(Localization.Drive_copyright_0, StringHandlers.CToString(response.Seagate_Copyright)). - AppendLine(); + sb.AppendFormat(Localization.Drive_copyright_0, StringHandlers.CToString(response.Seagate_Copyright)) + .AppendLine(); } if(response.Seagate3Present) { sb.AppendFormat(Localization.Drive_servo_part_number_0, - PrintHex.ByteArrayToHexArrayString(response.Seagate_ServoPROMPartNo, 40)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(response.Seagate_ServoPROMPartNo, 40)) + .AppendLine(); } } - #endregion Seagate vendor prettifying +#endregion Seagate vendor prettifying - #region Kreon vendor prettifying +#region Kreon vendor prettifying if(response.KreonPresent) { sb.AppendFormat(Localization.Drive_is_flashed_with_Kreon_firmware_0, - StringHandlers.CToString(response.KreonVersion)). - AppendLine(); + StringHandlers.CToString(response.KreonVersion)) + .AppendLine(); } - #endregion Kreon vendor prettifying +#endregion Kreon vendor prettifying - #if DEBUG +#if DEBUG if(response.DeviceTypeModifier != 0) sb.AppendFormat(Localization.Vendor_device_type_modifier_0, response.DeviceTypeModifier).AppendLine(); @@ -2477,8 +2449,7 @@ public static class Inquiry if(response.Reserved3 != 0) sb.AppendFormat(Localization.Reserved_byte_56_bits_seven_to_four_0, response.Reserved3).AppendLine(); - if(response.Reserved4 != 0) - sb.AppendFormat(Localization.Reserved_byte_57, response.Reserved4).AppendLine(); + if(response.Reserved4 != 0) sb.AppendFormat(Localization.Reserved_byte_57, response.Reserved4).AppendLine(); if(response.Reserved5 != null) { @@ -2521,14 +2492,13 @@ public static class Inquiry } } - if(response.VendorSpecific2 == null) - return sb.ToString(); + if(response.VendorSpecific2 == null) return sb.ToString(); sb.AppendFormat(Localization.Vendor_specific_bytes_96_to_0, response.AdditionalLength + 4).AppendLine(); sb.AppendLine("============================================================"); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VendorSpecific2, 60)); sb.AppendLine("============================================================"); - #endif +#endif return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/MMC/AACS.cs b/Aaru.Decoders/SCSI/MMC/AACS.cs index ee89d3e1e..68402c6d5 100644 --- a/Aaru.Decoders/SCSI/MMC/AACS.cs +++ b/Aaru.Decoders/SCSI/MMC/AACS.cs @@ -60,8 +60,7 @@ public static class AACS { public static AACSVolumeIdentifier? DecodeAACSVolumeIdentifier(byte[] AACSVIResponse) { - if(AACSVIResponse == null) - return null; + if(AACSVIResponse == null) return null; var decoded = new AACSVolumeIdentifier { @@ -78,20 +77,19 @@ public static class AACS public static string PrettifyAACSVolumeIdentifier(AACSVolumeIdentifier? AACSVIResponse) { - if(AACSVIResponse == null) - return null; + if(AACSVIResponse == null) return null; AACSVolumeIdentifier response = AACSVIResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif sb.AppendFormat(Localization.AACS_Volume_Identifier_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VolumeIdentifier, 80)); @@ -107,8 +105,7 @@ public static class AACS public static AACSMediaSerialNumber? DecodeAACSMediaSerialNumber(byte[] AACSMSNResponse) { - if(AACSMSNResponse == null) - return null; + if(AACSMSNResponse == null) return null; var decoded = new AACSMediaSerialNumber { @@ -125,20 +122,19 @@ public static class AACS public static string PrettifyAACSMediaSerialNumber(AACSMediaSerialNumber? AACSMSNResponse) { - if(AACSMSNResponse == null) - return null; + if(AACSMSNResponse == null) return null; AACSMediaSerialNumber response = AACSMSNResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif sb.AppendFormat(Localization.AACS_Media_Serial_Number_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MediaSerialNumber, 80)); @@ -154,8 +150,7 @@ public static class AACS public static AACSMediaIdentifier? DecodeAACSMediaIdentifier(byte[] AACSMIResponse) { - if(AACSMIResponse == null) - return null; + if(AACSMIResponse == null) return null; var decoded = new AACSMediaIdentifier { @@ -172,20 +167,19 @@ public static class AACS public static string PrettifyAACSMediaIdentifier(AACSMediaIdentifier? AACSMIResponse) { - if(AACSMIResponse == null) - return null; + if(AACSMIResponse == null) return null; AACSMediaIdentifier response = AACSMIResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif sb.AppendFormat(Localization.AACS_Media_Identifier_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MediaIdentifier, 80)); @@ -201,8 +195,7 @@ public static class AACS public static AACSMediaKeyBlock? DecodeAACSMediaKeyBlock(byte[] AACSMKBResponse) { - if(AACSMKBResponse == null) - return null; + if(AACSMKBResponse == null) return null; var decoded = new AACSMediaKeyBlock { @@ -219,19 +212,17 @@ public static class AACS public static string PrettifyAACSMediaKeyBlock(AACSMediaKeyBlock? AACSMKBResponse) { - if(AACSMKBResponse == null) - return null; + if(AACSMKBResponse == null) return null; AACSMediaKeyBlock response = AACSMKBResponse.Value; var sb = new StringBuilder(); - #if DEBUG - if(response.Reserved != 0) - sb.AppendFormat(Localization.Reserved_equals_0_X2, response.Reserved).AppendLine(); - #endif - sb.AppendFormat(Localization.Total_number_of_media_key_blocks_available_to_transfer_0, response.TotalPacks). - AppendLine(); +#if DEBUG + if(response.Reserved != 0) sb.AppendFormat(Localization.Reserved_equals_0_X2, response.Reserved).AppendLine(); +#endif + sb.AppendFormat(Localization.Total_number_of_media_key_blocks_available_to_transfer_0, response.TotalPacks) + .AppendLine(); sb.AppendFormat(Localization.AACS_Media_Key_Blocks_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MediaKeyBlockPacks, 80)); @@ -248,8 +239,7 @@ public static class AACS public static AACSDataKeys? DecodeAACSDataKeys(byte[] AACSDKResponse) { - if(AACSDKResponse == null) - return null; + if(AACSDKResponse == null) return null; var decoded = new AACSDataKeys { @@ -266,20 +256,19 @@ public static class AACS public static string PrettifyAACSDataKeys(AACSDataKeys? AACSDKResponse) { - if(AACSDKResponse == null) - return null; + if(AACSDKResponse == null) return null; AACSDataKeys response = AACSDKResponse.Value; var sb = new StringBuilder(); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); if(response.Reserved2 != 0) sb.AppendFormat(Localization.Reserved2_equals_0_X8, response.Reserved2).AppendLine(); - #endif +#endif sb.AppendFormat(Localization.AACS_Data_Keys_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DataKeys, 80)); @@ -295,8 +284,7 @@ public static class AACS public static AACSLBAExtentsResponse? DecodeAACSLBAExtents(byte[] AACSLBAExtsResponse) { - if(AACSLBAExtsResponse == null) - return null; + if(AACSLBAExtsResponse == null) return null; var decoded = new AACSLBAExtentsResponse { @@ -305,8 +293,7 @@ public static class AACS MaxLBAExtents = AACSLBAExtsResponse[3] }; - if((AACSLBAExtsResponse.Length - 4) % 16 != 0) - return decoded; + if((AACSLBAExtsResponse.Length - 4) % 16 != 0) return decoded; decoded.Extents = new AACSLBAExtent[(AACSLBAExtsResponse.Length - 4) / 16]; @@ -323,8 +310,7 @@ public static class AACS public static string PrettifyAACSLBAExtents(AACSLBAExtentsResponse? AACSLBAExtsResponse) { - if(AACSLBAExtsResponse == null) - return null; + if(AACSLBAExtsResponse == null) return null; AACSLBAExtentsResponse response = AACSLBAExtsResponse.Value; @@ -341,8 +327,10 @@ public static class AACS for(var i = 0; i < response.Extents.Length; i++) { - sb.AppendFormat(Localization.LBA_Extent_0_starts_at_LBA_1_and_goes_for_2_sectors, i, - response.Extents[i].StartLBA, response.Extents[i].LBACount); + sb.AppendFormat(Localization.LBA_Extent_0_starts_at_LBA_1_and_goes_for_2_sectors, + i, + response.Extents[i].StartLBA, + response.Extents[i].LBACount); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/MMC/CPRM.cs b/Aaru.Decoders/SCSI/MMC/CPRM.cs index 1b0b8e8cf..333f28d82 100644 --- a/Aaru.Decoders/SCSI/MMC/CPRM.cs +++ b/Aaru.Decoders/SCSI/MMC/CPRM.cs @@ -60,8 +60,7 @@ public static class CPRM { public static CPRMMediaKeyBlock? DecodeCPRMMediaKeyBlock(byte[] CPRMMKBResponse) { - if(CPRMMKBResponse == null) - return null; + if(CPRMMKBResponse == null) return null; var decoded = new CPRMMediaKeyBlock { @@ -78,20 +77,17 @@ public static class CPRM public static string PrettifyCPRMMediaKeyBlock(CPRMMediaKeyBlock? CPRMMKBResponse) { - if(CPRMMKBResponse == null) - return null; + if(CPRMMKBResponse == null) return null; CPRMMediaKeyBlock response = CPRMMKBResponse.Value; var sb = new StringBuilder(); - #if DEBUG - if(response.Reserved != 0) - sb.AppendFormat(Localization.Reserved_equals_0_X2, response.Reserved).AppendLine(); - #endif - sb.AppendFormat(Localization.Total_number_of_CPRM_Media_Key_Blocks_available_to_transfer_0, - response.TotalPacks). - AppendLine(); +#if DEBUG + if(response.Reserved != 0) sb.AppendFormat(Localization.Reserved_equals_0_X2, response.Reserved).AppendLine(); +#endif + sb.AppendFormat(Localization.Total_number_of_CPRM_Media_Key_Blocks_available_to_transfer_0, response.TotalPacks) + .AppendLine(); sb.AppendFormat(Localization.CPRM_Media_Key_Blocks_in_hex_follows); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MKBPackData, 80)); diff --git a/Aaru.Decoders/SCSI/MMC/DiscInformation.cs b/Aaru.Decoders/SCSI/MMC/DiscInformation.cs index 93b4553f9..e4123fb07 100644 --- a/Aaru.Decoders/SCSI/MMC/DiscInformation.cs +++ b/Aaru.Decoders/SCSI/MMC/DiscInformation.cs @@ -57,19 +57,16 @@ public static class DiscInformation { public static StandardDiscInformation? Decode000b(byte[] response) { - if(response.Length < 32) - return null; + if(response.Length < 32) return null; - if((response[2] & 0xE0) != 0) - return null; + if((response[2] & 0xE0) != 0) return null; var decoded = new StandardDiscInformation { DataLength = (ushort)((response[0] << 8) + response[1]) }; - if(decoded.DataLength + 2 != response.Length) - return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); decoded.Erasable |= (response[2] & 0x10) == 0x10; @@ -102,14 +99,12 @@ public static class DiscInformation Array.Reverse(temp); decoded.DiscBarcode = BitConverter.ToUInt64(temp, 0); - if(response.Length < 34) - return null; + if(response.Length < 34) return null; decoded.DiscApplicationCode = response[32]; decoded.OPCTablesNumber = response[33]; - if(decoded.OPCTablesNumber <= 0 || response.Length != decoded.OPCTablesNumber * 8 + 34) - return decoded; + if(decoded.OPCTablesNumber <= 0 || response.Length != decoded.OPCTablesNumber * 8 + 34) return decoded; decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber]; @@ -126,8 +121,7 @@ public static class DiscInformation public static string Prettify000b(StandardDiscInformation? information) { - if(information?.DataType != 0) - return null; + if(information?.DataType != 0) return null; var sb = new StringBuilder(); @@ -171,8 +165,7 @@ public static class DiscInformation break; } - if(information.Value.Erasable) - sb.AppendLine(Localization.Disc_is_erasable); + if(information.Value.Erasable) sb.AppendLine(Localization.Disc_is_erasable); switch(information.Value.LastSessionStatus) { @@ -197,8 +190,8 @@ public static class DiscInformation switch(information.Value.BGFormatStatus) { case 1: - sb.AppendLine(Localization. - Media_was_being_formatted_in_the_background_but_it_is_stopped_and_incomplete); + sb.AppendLine(Localization + .Media_was_being_formatted_in_the_background_but_it_is_stopped_and_incomplete); break; case 2: @@ -211,31 +204,30 @@ public static class DiscInformation break; } - if(information.Value.Dbit) - sb.AppendLine(Localization.MRW_is_dirty); + if(information.Value.Dbit) sb.AppendLine(Localization.MRW_is_dirty); sb.AppendFormat(Localization.First_track_on_disc_is_track_0, information.Value.FirstTrackNumber).AppendLine(); sb.AppendFormat(Localization.Disc_has_0_sessions, information.Value.Sessions).AppendLine(); - sb.AppendFormat(Localization.First_track_in_last_session_is_track_0, information.Value.FirstTrackLastSession). - AppendLine(); + sb.AppendFormat(Localization.First_track_in_last_session_is_track_0, information.Value.FirstTrackLastSession) + .AppendLine(); - sb.AppendFormat(Localization.Last_track_in_last_session_is_track_0, information.Value.LastTrackLastSession). - AppendLine(); + sb.AppendFormat(Localization.Last_track_in_last_session_is_track_0, information.Value.LastTrackLastSession) + .AppendLine(); sb.AppendFormat(Localization.Last_session_Lead_In_address_is_0_as_LBA_or_1_2_3, information.Value.LastSessionLeadInStartLBA, (information.Value.LastSessionLeadInStartLBA & 0xFF0000) >> 16, (information.Value.LastSessionLeadInStartLBA & 0xFF00) >> 8, - information.Value.LastSessionLeadInStartLBA & 0xFF). - AppendLine(); + information.Value.LastSessionLeadInStartLBA & 0xFF) + .AppendLine(); sb.AppendFormat(Localization.Last_possible_Lead_Out_address_is_0_as_LBA_or_1_2_3, information.Value.LastPossibleLeadOutStartLBA, (information.Value.LastPossibleLeadOutStartLBA & 0xFF0000) >> 16, (information.Value.LastPossibleLeadOutStartLBA & 0xFF00) >> 8, - information.Value.LastPossibleLeadOutStartLBA & 0xFF). - AppendLine(); + information.Value.LastPossibleLeadOutStartLBA & 0xFF) + .AppendLine(); sb.AppendLine(information.Value.URU ? Localization.Disc_is_defined_for_unrestricted_use @@ -250,15 +242,19 @@ public static class DiscInformation if(information.Value.DAC_V) sb.AppendFormat(Localization.Disc_application_code_0, information.Value.DiscApplicationCode).AppendLine(); - if(information.Value.OPCTables == null) - return sb.ToString(); + if(information.Value.OPCTables == null) return sb.ToString(); foreach(OPCTable table in information.Value.OPCTables) { - sb.AppendFormat(Localization.OPC_values_for_0_Kbit_sec_1_2_3_4_5_6, table.Speed, table.OPCValues[0], - table.OPCValues[1], table.OPCValues[2], table.OPCValues[3], table.OPCValues[4], - table.OPCValues[5]). - AppendLine(); + sb.AppendFormat(Localization.OPC_values_for_0_Kbit_sec_1_2_3_4_5_6, + table.Speed, + table.OPCValues[0], + table.OPCValues[1], + table.OPCValues[2], + table.OPCValues[3], + table.OPCValues[4], + table.OPCValues[5]) + .AppendLine(); } return sb.ToString(); @@ -266,19 +262,16 @@ public static class DiscInformation public static TrackResourcesInformation? Decode001b(byte[] response) { - if(response.Length != 12) - return null; + if(response.Length != 12) return null; - if((response[2] & 0xE0) != 0x20) - return null; + if((response[2] & 0xE0) != 0x20) return null; var decoded = new TrackResourcesInformation { DataLength = (ushort)((response[0] << 8) + response[1]) }; - if(decoded.DataLength + 2 != response.Length) - return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); decoded.MaxTracks = (ushort)((response[4] << 8) + response[5]); @@ -291,8 +284,7 @@ public static class DiscInformation public static string Prettify001b(TrackResourcesInformation? information) { - if(information?.DataType != 1) - return null; + if(information?.DataType != 1) return null; var sb = new StringBuilder(); @@ -300,30 +292,27 @@ public static class DiscInformation sb.AppendFormat(Localization._0_assigned_tracks_on_the_disc, information.Value.AssignedTracks).AppendLine(); sb.AppendFormat(Localization._0_maximum_possible_appendable_tracks_on_the_disc, - information.Value.AppendableTracks). - AppendLine(); + information.Value.AppendableTracks) + .AppendLine(); - sb.AppendFormat(Localization._0_current_appendable_tracks_on_the_disc, information.Value.MaxAppendableTracks). - AppendLine(); + sb.AppendFormat(Localization._0_current_appendable_tracks_on_the_disc, information.Value.MaxAppendableTracks) + .AppendLine(); return sb.ToString(); } public static POWResourcesInformation? Decode010b(byte[] response) { - if(response.Length != 16) - return null; + if(response.Length != 16) return null; - if((response[2] & 0xE0) != 0x40) - return null; + if((response[2] & 0xE0) != 0x40) return null; var decoded = new POWResourcesInformation { DataLength = (ushort)((response[0] << 8) + response[1]) }; - if(decoded.DataLength + 2 != response.Length) - return null; + if(decoded.DataLength + 2 != response.Length) return null; decoded.DataType = (byte)((response[2] & 0xE0) >> 5); @@ -341,17 +330,16 @@ public static class DiscInformation public static string Prettify010b(POWResourcesInformation? information) { - if(information?.DataType != 1) - return null; + if(information?.DataType != 1) return null; var sb = new StringBuilder(); - sb.AppendFormat(Localization._0_remaining_POW_replacements, information.Value.RemainingPOWReplacements). - AppendLine(); + sb.AppendFormat(Localization._0_remaining_POW_replacements, information.Value.RemainingPOWReplacements) + .AppendLine(); sb.AppendFormat(Localization._0_remaining_POW_reallocation_map_entries, - information.Value.RemainingPOWReallocation). - AppendLine(); + information.Value.RemainingPOWReallocation) + .AppendLine(); sb.AppendFormat(Localization._0_remaining_POW_updates, information.Value.RemainingPOWUpdates).AppendLine(); @@ -360,11 +348,9 @@ public static class DiscInformation public static string Prettify(byte[] response) { - if(response == null) - return null; + if(response == null) return null; - if(response.Length < 12) - return null; + if(response.Length < 12) return null; return (response[2] & 0xE0) switch { diff --git a/Aaru.Decoders/SCSI/MMC/Features.cs b/Aaru.Decoders/SCSI/MMC/Features.cs index 50a8232f8..9cb7a686c 100644 --- a/Aaru.Decoders/SCSI/MMC/Features.cs +++ b/Aaru.Decoders/SCSI/MMC/Features.cs @@ -1188,19 +1188,15 @@ public static class Features { public static Feature_0000? Decode_0000(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0000) - return null; + if(number != 0x0000) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0000(); @@ -1230,19 +1226,15 @@ public static class Features public static Feature_0001? Decode_0001(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0001) - return null; + if(number != 0x0001) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0001(); @@ -1253,30 +1245,24 @@ public static class Features decoded.PhysicalInterfaceStandard = (PhysicalInterfaces)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]); - if(decoded.Version >= 1 && feature.Length >= 12) - decoded.DBE |= (feature[8] & 0x01) == 0x01; + if(decoded.Version >= 1 && feature.Length >= 12) decoded.DBE |= (feature[8] & 0x01) == 0x01; - if(decoded.Version >= 2 && feature.Length >= 12) - decoded.INQ2 |= (feature[8] & 0x02) == 0x02; + if(decoded.Version >= 2 && feature.Length >= 12) decoded.INQ2 |= (feature[8] & 0x02) == 0x02; return decoded; } public static Feature_0002? Decode_0002(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0002) - return null; + if(number != 0x0002) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0002(); @@ -1286,27 +1272,22 @@ public static class Features decoded.Async |= (feature[4] & 0x01) == 0x01; - if(decoded.Version >= 1) - decoded.OCEvent |= (feature[4] & 0x02) == 0x02; + if(decoded.Version >= 1) decoded.OCEvent |= (feature[4] & 0x02) == 0x02; return decoded; } public static Feature_0003? Decode_0003(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0003) - return null; + if(number != 0x0003) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0003(); @@ -1319,8 +1300,7 @@ public static class Features decoded.PreventJumper |= (feature[4] & 0x04) == 0x04; decoded.Lock |= (feature[4] & 0x01) == 0x01; - if(decoded.Version < 2) - return decoded; + if(decoded.Version < 2) return decoded; decoded.Load |= (feature[4] & 0x10) == 0x10; decoded.DBML |= (feature[4] & 0x02) == 0x02; @@ -1330,19 +1310,15 @@ public static class Features public static Feature_0004? Decode_0004(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0004) - return null; + if(number != 0x0004) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0004(); @@ -1353,30 +1329,24 @@ public static class Features decoded.SPWP |= (feature[4] & 0x02) == 0x02; decoded.SSWPP |= (feature[4] & 0x01) == 0x01; - if(decoded.Version >= 1) - decoded.WDCB |= (feature[4] & 0x04) == 0x04; + if(decoded.Version >= 1) decoded.WDCB |= (feature[4] & 0x04) == 0x04; - if(decoded.Version >= 2) - decoded.DWP |= (feature[4] & 0x08) == 0x08; + if(decoded.Version >= 2) decoded.DWP |= (feature[4] & 0x08) == 0x08; return decoded; } public static Feature_0010? Decode_0010(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 12) - return null; + if(feature.Length < 12) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0010) - return null; + if(number != 0x0010) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0010(); @@ -1395,19 +1365,15 @@ public static class Features public static Feature_001D? Decode_001D(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x001D) - return null; + if(number != 0x001D) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_001D(); @@ -1420,19 +1386,15 @@ public static class Features public static Feature_001E? Decode_001E(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x001E) - return null; + if(number != 0x001E) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_001E(); @@ -1446,27 +1408,22 @@ public static class Features decoded.CDText |= (feature[4] & 0x01) == 0x01; } - if(decoded.Version >= 2) - decoded.DAP |= (feature[4] & 0x80) == 0x80; + if(decoded.Version >= 2) decoded.DAP |= (feature[4] & 0x80) == 0x80; return decoded; } public static Feature_001F? Decode_001F(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x001F) - return null; + if(number != 0x001F) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_001F(); @@ -1481,27 +1438,22 @@ public static class Features } // TODO: Check this - if(decoded.Version >= 2 && feature.Length >= 8) - decoded.DualRW |= (feature[6] & 0x02) == 0x02; + if(decoded.Version >= 2 && feature.Length >= 8) decoded.DualRW |= (feature[6] & 0x02) == 0x02; return decoded; } public static Feature_0020? Decode_0020(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 16) - return null; + if(feature.Length < 16) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0020) - return null; + if(number != 0x0020) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0020(); @@ -1509,8 +1461,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(decoded.Version < 1) - return decoded; + if(decoded.Version < 1) return decoded; decoded.LastLBA = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]); @@ -1524,19 +1475,15 @@ public static class Features public static Feature_0021? Decode_0021(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0021) - return null; + if(number != 0x0021) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0021(); @@ -1550,12 +1497,10 @@ public static class Features decoded.BUF |= (feature[6] & 0x01) == 0x01; decoded.LinkSizes = new byte[feature[7]]; - if(feature.Length > feature[7] + 8) - Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); + if(feature.Length > feature[7] + 8) Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); } - if(decoded.Version < 3) - return decoded; + if(decoded.Version < 3) return decoded; decoded.TRIO |= (feature[6] & 0x04) == 0x04; decoded.ARSV |= (feature[6] & 0x02) == 0x02; @@ -1565,19 +1510,15 @@ public static class Features public static Feature_0022? Decode_0022(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0022) - return null; + if(number != 0x0022) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0022(); @@ -1590,19 +1531,15 @@ public static class Features public static Feature_0023? Decode_0023(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0023) - return null; + if(number != 0x0023) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0023(); @@ -1619,27 +1556,22 @@ public static class Features decoded.RRM |= (feature[8] & 0x01) == 0x01; } - if(decoded.Version >= 2 && feature.Length >= 12) - decoded.FRF |= (feature[4] & 0x80) == 0x80; + if(decoded.Version >= 2 && feature.Length >= 12) decoded.FRF |= (feature[4] & 0x80) == 0x80; return decoded; } public static Feature_0024? Decode_0024(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0024) - return null; + if(number != 0x0024) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0024(); @@ -1647,27 +1579,22 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(decoded.Version >= 1 && feature.Length >= 8) - decoded.SSA |= (feature[4] & 0x80) == 0x80; + if(decoded.Version >= 1 && feature.Length >= 8) decoded.SSA |= (feature[4] & 0x80) == 0x80; return decoded; } public static Feature_0025? Decode_0025(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 12) - return null; + if(feature.Length < 12) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0025) - return null; + if(number != 0x0025) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0025(); @@ -1686,19 +1613,15 @@ public static class Features public static Feature_0026? Decode_0026(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0026) - return null; + if(number != 0x0026) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0026(); @@ -1711,19 +1634,15 @@ public static class Features public static Feature_0027? Decode_0027(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0027) - return null; + if(number != 0x0027) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0027(); @@ -1736,19 +1655,15 @@ public static class Features public static Feature_0028? Decode_0028(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0028) - return null; + if(number != 0x0028) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0028(); @@ -1758,8 +1673,7 @@ public static class Features decoded.Write |= (feature[4] & 0x01) == 0x01; - if(decoded.Version < 1) - return decoded; + if(decoded.Version < 1) return decoded; decoded.DVDPWrite |= (feature[4] & 0x04) == 0x04; decoded.DVDPRead |= (feature[4] & 0x02) == 0x02; @@ -1769,19 +1683,15 @@ public static class Features public static Feature_0029? Decode_0029(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0029) - return null; + if(number != 0x0029) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0029(); @@ -1798,19 +1708,15 @@ public static class Features public static Feature_002A? Decode_002A(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002A) - return null; + if(number != 0x002A) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002A(); @@ -1821,27 +1727,22 @@ public static class Features decoded.Write |= (feature[4] & 0x01) == 0x01; decoded.CloseOnly |= (feature[5] & 0x01) == 0x01; - if(decoded.Version >= 1) - decoded.QuickStart |= (feature[5] & 0x02) == 0x02; + if(decoded.Version >= 1) decoded.QuickStart |= (feature[5] & 0x02) == 0x02; return decoded; } public static Feature_002B? Decode_002B(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002B) - return null; + if(number != 0x002B) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002B(); @@ -1856,19 +1757,15 @@ public static class Features public static Feature_002C? Decode_002C(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002C) - return null; + if(number != 0x002C) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002C(); @@ -1886,19 +1783,15 @@ public static class Features public static Feature_002D? Decode_002D(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002D) - return null; + if(number != 0x002D) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002D(); @@ -1911,8 +1804,7 @@ public static class Features decoded.RWSubchannel |= (feature[4] & 0x01) == 0x01; decoded.DataTypeSupported = (ushort)((feature[6] << 8) + feature[7]); - if(decoded.Version < 2) - return decoded; + if(decoded.Version < 2) return decoded; decoded.BUF |= (feature[4] & 0x40) == 0x40; decoded.RWRaw |= (feature[4] & 0x10) == 0x10; @@ -1923,19 +1815,15 @@ public static class Features public static Feature_002E? Decode_002E(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002E) - return null; + if(number != 0x002E) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002E(); @@ -1951,27 +1839,22 @@ public static class Features decoded.RW |= (feature[4] & 0x01) == 0x01; decoded.MaxCueSheet = (uint)((feature[5] << 16) + (feature[6] << 8) + feature[7]); - if(decoded.Version >= 1) - decoded.BUF |= (feature[4] & 0x40) == 0x40; + if(decoded.Version >= 1) decoded.BUF |= (feature[4] & 0x40) == 0x40; return decoded; } public static Feature_002F? Decode_002F(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x002F) - return null; + if(number != 0x002F) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_002F(); @@ -1982,30 +1865,24 @@ public static class Features decoded.BUF |= (feature[4] & 0x40) == 0x40; decoded.TestWrite |= (feature[4] & 0x04) == 0x04; - if(decoded.Version >= 1) - decoded.DVDRW |= (feature[4] & 0x02) == 0x02; + if(decoded.Version >= 1) decoded.DVDRW |= (feature[4] & 0x02) == 0x02; - if(decoded.Version >= 2) - decoded.RDL |= (feature[4] & 0x08) == 0x08; + if(decoded.Version >= 2) decoded.RDL |= (feature[4] & 0x08) == 0x08; return decoded; } public static Feature_0030? Decode_0030(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0030) - return null; + if(number != 0x0030) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0030(); @@ -2018,19 +1895,15 @@ public static class Features public static Feature_0031? Decode_0031(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0031) - return null; + if(number != 0x0031) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0031(); @@ -2045,19 +1918,15 @@ public static class Features public static Feature_0032? Decode_0032(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0032) - return null; + if(number != 0x0032) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0032(); @@ -2073,19 +1942,15 @@ public static class Features public static Feature_0033? Decode_0033(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0033) - return null; + if(number != 0x0033) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0033(); @@ -2093,8 +1958,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(feature[7] <= 0 || feature.Length <= feature[7] + 8) - return decoded; + if(feature[7] <= 0 || feature.Length <= feature[7] + 8) return decoded; decoded.LinkSizes = new byte[feature[7]]; Array.Copy(feature, 8, decoded.LinkSizes, 0, feature[7]); @@ -2104,19 +1968,15 @@ public static class Features public static Feature_0035? Decode_0035(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0035) - return null; + if(number != 0x0035) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0035(); @@ -2129,19 +1989,15 @@ public static class Features public static Feature_0037? Decode_0037(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0037) - return null; + if(number != 0x0037) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0037(); @@ -2156,19 +2012,15 @@ public static class Features public static Feature_0038? Decode_0038(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0038) - return null; + if(number != 0x0038) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0038(); @@ -2181,19 +2033,15 @@ public static class Features public static Feature_003A? Decode_003A(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x003A) - return null; + if(number != 0x003A) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_003A(); @@ -2210,19 +2058,15 @@ public static class Features public static Feature_003B? Decode_003B(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x003B) - return null; + if(number != 0x003B) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_003B(); @@ -2237,19 +2081,15 @@ public static class Features public static Feature_0040? Decode_0040(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 32) - return null; + if(feature.Length < 32) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0040) - return null; + if(number != 0x0040) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0040(); @@ -2261,8 +2101,7 @@ public static class Features decoded.OldR |= (feature[17] & 0x01) == 0x01; decoded.OldROM |= (feature[25] & 0x01) == 0x01; - if(decoded.Version < 1) - return decoded; + if(decoded.Version < 1) return decoded; decoded.BCA |= (feature[4] & 0x01) == 0x01; decoded.RE2 |= (feature[9] & 0x04) == 0x04; @@ -2275,19 +2114,15 @@ public static class Features public static Feature_0041? Decode_0041(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 24) - return null; + if(feature.Length < 24) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0041) - return null; + if(number != 0x0041) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0041(); @@ -2299,8 +2134,7 @@ public static class Features decoded.OldRE |= (feature[9] & 0x01) == 0x01; decoded.OldR |= (feature[17] & 0x01) == 0x01; - if(decoded.Version < 1) - return decoded; + if(decoded.Version < 1) return decoded; decoded.RE2 |= (feature[9] & 0x04) == 0x04; decoded.RE1 |= (feature[9] & 0x02) == 0x02; @@ -2311,19 +2145,15 @@ public static class Features public static Feature_0042? Decode_0042(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0042) - return null; + if(number != 0x0042) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0042(); @@ -2336,19 +2166,15 @@ public static class Features public static Feature_0050? Decode_0050(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0050) - return null; + if(number != 0x0050) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0050(); @@ -2364,19 +2190,15 @@ public static class Features public static Feature_0051? Decode_0051(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0051) - return null; + if(number != 0x0051) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0051(); @@ -2392,19 +2214,15 @@ public static class Features public static Feature_0080? Decode_0080(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0080) - return null; + if(number != 0x0080) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0080(); @@ -2419,19 +2237,15 @@ public static class Features public static Feature_0100? Decode_0100(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0100) - return null; + if(number != 0x0100) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0100(); @@ -2444,19 +2258,15 @@ public static class Features public static Feature_0101? Decode_0101(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0101) - return null; + if(number != 0x0101) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0101(); @@ -2471,19 +2281,15 @@ public static class Features public static Feature_0102? Decode_0102(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0102) - return null; + if(number != 0x0102) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0102(); @@ -2500,19 +2306,15 @@ public static class Features public static Feature_0103? Decode_0103(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0103) - return null; + if(number != 0x0103) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0103(); @@ -2530,19 +2332,15 @@ public static class Features public static Feature_0104? Decode_0104(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0104) - return null; + if(number != 0x0104) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0104(); @@ -2550,27 +2348,22 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(decoded.Version >= 1 && feature.Length >= 8) - decoded.M5 |= (feature[4] & 0x01) == 0x01; + if(decoded.Version >= 1 && feature.Length >= 8) decoded.M5 |= (feature[4] & 0x01) == 0x01; return decoded; } public static Feature_0105? Decode_0105(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0105) - return null; + if(number != 0x0105) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0105(); @@ -2578,8 +2371,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - if(decoded.Version < 1 || feature.Length < 8) - return decoded; + if(decoded.Version < 1 || feature.Length < 8) return decoded; decoded.Group3 |= (feature[4] & 0x01) == 0x01; decoded.UnitLength = (ushort)((feature[6] << 8) + feature[7]); @@ -2589,19 +2381,15 @@ public static class Features public static Feature_0106? Decode_0106(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0106) - return null; + if(number != 0x0106) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0106(); @@ -2616,19 +2404,15 @@ public static class Features public static Feature_0107? Decode_0107(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0107) - return null; + if(number != 0x0107) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0107(); @@ -2645,8 +2429,7 @@ public static class Features decoded.SW |= (feature[4] & 0x01) == 0x01; } - if(decoded.Version < 5 || feature.Length < 8) - return decoded; + if(decoded.Version < 5 || feature.Length < 8) return decoded; decoded.SMP |= (feature[4] & 0x20) == 0x20; decoded.RBCB |= (feature[4] & 0x10) == 0x10; @@ -2656,19 +2439,15 @@ public static class Features public static Feature_0108? Decode_0108(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0108) - return null; + if(number != 0x0108) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0108(); @@ -2685,19 +2464,15 @@ public static class Features public static Feature_0109? Decode_0109(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0109) - return null; + if(number != 0x0109) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0109(); @@ -2710,19 +2485,15 @@ public static class Features public static Feature_010A? Decode_010A(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x010A) - return null; + if(number != 0x010A) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_010A(); @@ -2745,19 +2516,15 @@ public static class Features public static Feature_010B? Decode_010B(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x010B) - return null; + if(number != 0x010B) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_010B(); @@ -2772,19 +2539,15 @@ public static class Features public static Feature_010C? Decode_010C(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 20) - return null; + if(feature.Length < 20) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x010C) - return null; + if(number != 0x010C) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_010C(); @@ -2805,19 +2568,15 @@ public static class Features public static Feature_010D? Decode_010D(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x010D) - return null; + if(number != 0x010D) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_010D(); @@ -2830,8 +2589,7 @@ public static class Features decoded.AGIDs = (byte)(feature[6] & 0x0F); decoded.AACSVersion = feature[7]; - if(decoded.Version < 2) - return decoded; + if(decoded.Version < 2) return decoded; decoded.RDC |= (feature[4] & 0x10) == 0x10; decoded.RMC |= (feature[4] & 0x08) == 0x08; @@ -2843,19 +2601,15 @@ public static class Features public static Feature_010E? Decode_010E(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x010E) - return null; + if(number != 0x010E) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_010E(); @@ -2870,19 +2624,15 @@ public static class Features public static Feature_0110? Decode_0110(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 8) - return null; + if(feature.Length < 8) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0110) - return null; + if(number != 0x0110) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0110(); @@ -2895,19 +2645,15 @@ public static class Features public static Feature_0113? Decode_0113(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 4) - return null; + if(feature.Length < 4) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0113) - return null; + if(number != 0x0113) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0113(); @@ -2920,19 +2666,15 @@ public static class Features public static Feature_0142? Decode_0142(byte[] feature) { - if(feature == null) - return null; + if(feature == null) return null; - if(feature.Length < 6) - return null; + if(feature.Length < 6) return null; var number = (ushort)((feature[0] << 8) + feature[1]); - if(number != 0x0142) - return null; + if(number != 0x0142) return null; - if(feature[3] + 4 != feature.Length) - return null; + if(feature[3] + 4 != feature.Length) return null; var decoded = new Feature_0142(); @@ -2945,8 +2687,7 @@ public static class Features decoded.ME |= (feature[4] & 0x01) == 0x01; decoded.Profiles = new ushort[feature[5]]; - if(feature[5] * 2 + 6 != feature.Length) - return decoded; + if(feature[5] * 2 + 6 != feature.Length) return decoded; for(var i = 0; i < feature[5]; i++) decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]); @@ -2956,16 +2697,14 @@ public static class Features public static string Prettify_0000(Feature_0000? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0000 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.MMC_Supported_Profiles); - if(ftr.Profiles == null) - return sb.ToString(); + if(ftr.Profiles == null) return sb.ToString(); foreach(Profile prof in ftr.Profiles) { @@ -3144,8 +2883,7 @@ public static class Features public static string Prettify_0001(Feature_0001? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0001 ftr = feature.Value; var sb = new StringBuilder(); @@ -3197,20 +2935,19 @@ public static class Features break; default: sb.AppendFormat(Localization.Drive_uses_an_unknown_interface_with_code_0, - (uint)ftr.PhysicalInterfaceStandard). - AppendLine(); + (uint)ftr.PhysicalInterfaceStandard) + .AppendLine(); break; } - if(ftr.DBE) - sb.AppendLine("\t" + Localization.Drive_supports_Device_Busy_events); + if(ftr.DBE) sb.AppendLine("\t" + Localization.Drive_supports_Device_Busy_events); if(ftr.INQ2) { sb.AppendLine("\t" + - Localization. - Drive_supports_EVPD_Page_Code_and_16_bit_Allocation_Length_as_described_in_SPC_3); + Localization + .Drive_supports_EVPD_Page_Code_and_16_bit_Allocation_Length_as_described_in_SPC_3); } return sb.ToString(); @@ -3218,8 +2955,7 @@ public static class Features public static string Prettify_0002(Feature_0002? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0002 ftr = feature.Value; var sb = new StringBuilder(); @@ -3238,8 +2974,7 @@ public static class Features public static string Prettify_0003(Feature_0003? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0003 ftr = feature.Value; var sb = new StringBuilder(); @@ -3262,8 +2997,8 @@ public static class Features break; case 4: sb.AppendLine("\t" + - Localization. - Features_Prettify_0003_Drive_is_a_changer_with_individually_changeable_discs); + Localization + .Features_Prettify_0003_Drive_is_a_changer_with_individually_changeable_discs); break; case 5: @@ -3272,29 +3007,25 @@ public static class Features break; default: sb.AppendFormat("\t" + Localization.Features_Prettify_0003_Drive_uses_unknown_loading_mechanism_type_0, - ftr.LoadingMechanismType). - AppendLine(); + ftr.LoadingMechanismType) + .AppendLine(); break; } - if(ftr.Lock) - sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_lock_media); + if(ftr.Lock) sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_lock_media); - if(ftr.PreventJumper) - sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_power_ups_locked); + if(ftr.PreventJumper) sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_power_ups_locked); - if(ftr.Eject) - sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_eject_media); + if(ftr.Eject) sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_eject_media); - if(ftr.Load) - sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_load_media); + if(ftr.Load) sb.AppendLine("\t" + Localization.Features_Prettify_0003_Drive_can_load_media); if(ftr.DBML) { sb.AppendLine("\t" + - Localization. - Features_Prettify_0003_Drive_reports_Device_Busy_Class_events_during_medium_loading_unloading); + Localization + .Features_Prettify_0003_Drive_reports_Device_Busy_Class_events_during_medium_loading_unloading); } return sb.ToString(); @@ -3302,8 +3033,7 @@ public static class Features public static string Prettify_0004(Feature_0004? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0004 ftr = feature.Value; var sb = new StringBuilder(); @@ -3316,11 +3046,9 @@ public static class Features Localization.Drive_supports_reading_writing_the_Disc_Write_Protect_PAC_on_BD_R_RE_media); } - if(ftr.WDCB) - sb.AppendLine("\t" + Localization.Drive_supports_writing_the_Write_Inhibit_DCB_on_DVD_RW_media); + if(ftr.WDCB) sb.AppendLine("\t" + Localization.Drive_supports_writing_the_Write_Inhibit_DCB_on_DVD_RW_media); - if(ftr.SPWP) - sb.AppendLine("\t" + Localization.Drive_supports_set_release_of_PWP_status); + if(ftr.SPWP) sb.AppendLine("\t" + Localization.Drive_supports_set_release_of_PWP_status); if(ftr.SSWPP) sb.AppendLine("\t" + Localization.Drive_supports_the_SWPP_bit_of_the_Timeout_and_Protect_mode_page); @@ -3330,21 +3058,18 @@ public static class Features public static string Prettify_0010(Feature_0010? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0010 ftr = feature.Value; var sb = new StringBuilder(); sb.Append(Localization.MMC_Random_Readable); - if(ftr.Current) - sb.Append(Localization.current); + if(ftr.Current) sb.Append(Localization.current); sb.AppendLine(":"); - if(ftr.PP) - sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); + if(ftr.PP) sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); if(ftr.LogicalBlockSize > 0) sb.AppendFormat("\t" + Localization._0_bytes_per_logical_block, ftr.LogicalBlockSize).AppendLine(); @@ -3363,76 +3088,64 @@ public static class Features public static string Prettify_001E(Feature_001E? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_001E ftr = feature.Value; var sb = new StringBuilder(); sb.Append(Localization.MMC_CD_Read); - if(ftr.Current) - sb.Append(Localization.current); + if(ftr.Current) sb.Append(Localization.current); sb.AppendLine(":"); if(ftr.DAP) sb.AppendLine("\t" + Localization.Drive_supports_the_DAP_bit_in_the_READ_CD_and_READ_CD_MSF_commands); - if(ftr.C2) - sb.AppendLine("\t" + Localization.Drive_supports_C2_Error_Pointers); + if(ftr.C2) sb.AppendLine("\t" + Localization.Drive_supports_C2_Error_Pointers); - if(ftr.CDText) - sb.AppendLine("\t" + Localization.Drive_can_return_CD_Text_from_Lead_In); + if(ftr.CDText) sb.AppendLine("\t" + Localization.Drive_can_return_CD_Text_from_Lead_In); return sb.ToString(); } public static string Prettify_001F(Feature_001F? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_001F ftr = feature.Value; var sb = new StringBuilder(); sb.Append(Localization.MMC_DVD_Read); - if(ftr.Current) - sb.Append(Localization.current); + if(ftr.Current) sb.Append(Localization.current); sb.AppendLine(":"); sb.AppendLine("\t" + Localization.Drive_can_read_DVD_media); - if(ftr.DualR) - sb.AppendLine("\t" + Localization.Drive_can_read_DVD_R_DL_from_all_recording_modes); + if(ftr.DualR) sb.AppendLine("\t" + Localization.Drive_can_read_DVD_R_DL_from_all_recording_modes); - if(ftr.DualRW) - sb.AppendLine("\t" + Localization.Drive_can_read_DVD_RW_DL_from_all_recording_modes); + if(ftr.DualRW) sb.AppendLine("\t" + Localization.Drive_can_read_DVD_RW_DL_from_all_recording_modes); - if(ftr.MULTI110) - sb.AppendLine("\t" + Localization.Drive_conforms_to_DVD_Multi_Drive_Read_only_Specifications); + if(ftr.MULTI110) sb.AppendLine("\t" + Localization.Drive_conforms_to_DVD_Multi_Drive_Read_only_Specifications); return sb.ToString(); } public static string Prettify_0020(Feature_0020? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0020 ftr = feature.Value; var sb = new StringBuilder(); sb.Append(Localization.MMC_Random_Writable); - if(ftr.Current) - sb.Append(Localization.current); + if(ftr.Current) sb.Append(Localization.current); sb.AppendLine(":"); - if(ftr.PP) - sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); + if(ftr.PP) sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); if(ftr.LogicalBlockSize > 0) sb.AppendFormat("\t" + Localization._0_bytes_per_logical_block, ftr.LogicalBlockSize).AppendLine(); @@ -3448,8 +3161,7 @@ public static class Features public static string Prettify_0021(Feature_0021? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0021 ftr = feature.Value; var sb = new StringBuilder(); @@ -3460,65 +3172,47 @@ public static class Features { sb.Append("\t" + Localization.Drive_supports_data_block_types); - if((ftr.DataTypeSupported & 0x0001) == 0x0001) - sb.Append(" 0"); + if((ftr.DataTypeSupported & 0x0001) == 0x0001) sb.Append(" 0"); - if((ftr.DataTypeSupported & 0x0002) == 0x0002) - sb.Append(" 1"); + if((ftr.DataTypeSupported & 0x0002) == 0x0002) sb.Append(" 1"); - if((ftr.DataTypeSupported & 0x0004) == 0x0004) - sb.Append(" 2"); + if((ftr.DataTypeSupported & 0x0004) == 0x0004) sb.Append(" 2"); - if((ftr.DataTypeSupported & 0x0008) == 0x0008) - sb.Append(" 3"); + if((ftr.DataTypeSupported & 0x0008) == 0x0008) sb.Append(" 3"); - if((ftr.DataTypeSupported & 0x0010) == 0x0010) - sb.Append(" 4"); + if((ftr.DataTypeSupported & 0x0010) == 0x0010) sb.Append(" 4"); - if((ftr.DataTypeSupported & 0x0020) == 0x0020) - sb.Append(" 5"); + if((ftr.DataTypeSupported & 0x0020) == 0x0020) sb.Append(" 5"); - if((ftr.DataTypeSupported & 0x0040) == 0x0040) - sb.Append(" 6"); + if((ftr.DataTypeSupported & 0x0040) == 0x0040) sb.Append(" 6"); - if((ftr.DataTypeSupported & 0x0080) == 0x0080) - sb.Append(" 7"); + if((ftr.DataTypeSupported & 0x0080) == 0x0080) sb.Append(" 7"); - if((ftr.DataTypeSupported & 0x0100) == 0x0100) - sb.Append(" 8"); + if((ftr.DataTypeSupported & 0x0100) == 0x0100) sb.Append(" 8"); - if((ftr.DataTypeSupported & 0x0200) == 0x0200) - sb.Append(" 9"); + if((ftr.DataTypeSupported & 0x0200) == 0x0200) sb.Append(" 9"); - if((ftr.DataTypeSupported & 0x0400) == 0x0400) - sb.Append(" 10"); + if((ftr.DataTypeSupported & 0x0400) == 0x0400) sb.Append(" 10"); - if((ftr.DataTypeSupported & 0x0800) == 0x0800) - sb.Append(" 11"); + if((ftr.DataTypeSupported & 0x0800) == 0x0800) sb.Append(" 11"); - if((ftr.DataTypeSupported & 0x1000) == 0x1000) - sb.Append(" 12"); + if((ftr.DataTypeSupported & 0x1000) == 0x1000) sb.Append(" 12"); - if((ftr.DataTypeSupported & 0x2000) == 0x2000) - sb.Append(" 13"); + if((ftr.DataTypeSupported & 0x2000) == 0x2000) sb.Append(" 13"); - if((ftr.DataTypeSupported & 0x4000) == 0x4000) - sb.Append(" 14"); + if((ftr.DataTypeSupported & 0x4000) == 0x4000) sb.Append(" 14"); - if((ftr.DataTypeSupported & 0x8000) == 0x8000) - sb.Append(" 15"); + if((ftr.DataTypeSupported & 0x8000) == 0x8000) sb.Append(" 15"); sb.AppendLine(); } - if(ftr.TRIO) - sb.AppendLine("\t" + Localization.Drive_claims_support_to_report_Track_Resources_Information); + if(ftr.TRIO) sb.AppendLine("\t" + Localization.Drive_claims_support_to_report_Track_Resources_Information); if(ftr.ARSV) sb.AppendLine("\t" + Localization.Drive_supports_address_mode_reservation_on_the_RESERVE_TRACK_command); - if(ftr.BUF) - sb.AppendLine("\t" + Localization.Drive_is_capable_of_zero_loss_linking); + if(ftr.BUF) sb.AppendLine("\t" + Localization.Drive_is_capable_of_zero_loss_linking); return sb.ToString(); } @@ -3528,8 +3222,7 @@ public static class Features public static string Prettify_0023(Feature_0023? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0023 ftr = feature.Value; var sb = new StringBuilder(); @@ -3537,31 +3230,24 @@ public static class Features sb.AppendLine(Localization.MMC_Formattable); sb.AppendLine("\t" + Localization.Drive_can_format_media_into_logical_blocks); - if(ftr.RENoSA) - sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_with_no_spares_allocated); + if(ftr.RENoSA) sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_with_no_spares_allocated); - if(ftr.Expand) - sb.AppendLine("\t" + Localization.Drive_can_expand_the_spare_area_on_a_formatted_BD_RE_disc); + if(ftr.Expand) sb.AppendLine("\t" + Localization.Drive_can_expand_the_spare_area_on_a_formatted_BD_RE_disc); - if(ftr.QCert) - sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_discs_with_quick_certification); + if(ftr.QCert) sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_discs_with_quick_certification); - if(ftr.Cert) - sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_discs_with_full_certification); + if(ftr.Cert) sb.AppendLine("\t" + Localization.Drive_can_format_BD_RE_discs_with_full_certification); - if(ftr.FRF) - sb.AppendLine("\t" + Localization.Drive_can_fast_re_format_BD_RE_discs); + if(ftr.FRF) sb.AppendLine("\t" + Localization.Drive_can_fast_re_format_BD_RE_discs); - if(ftr.RRM) - sb.AppendLine("\t" + Localization.Drive_can_format_BD_R_discs_with_RRM_format); + if(ftr.RRM) sb.AppendLine("\t" + Localization.Drive_can_format_BD_R_discs_with_RRM_format); return sb.ToString(); } public static string Prettify_0024(Feature_0024? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0024 ftr = feature.Value; var sb = new StringBuilder(); @@ -3569,29 +3255,25 @@ public static class Features sb.AppendLine(Localization.MMC_Hardware_Defect_Management); sb.AppendLine("\t" + Localization.Drive_shall_be_able_to_provide_a_defect_free_contiguous_address_space); - if(ftr.SSA) - sb.AppendLine("\t" + Localization.Drive_can_return_Spare_Area_Information); + if(ftr.SSA) sb.AppendLine("\t" + Localization.Drive_can_return_Spare_Area_Information); return sb.ToString(); } public static string Prettify_0025(Feature_0025? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0025 ftr = feature.Value; var sb = new StringBuilder(); sb.Append(Localization.MMC_Write_Once); - if(ftr.Current) - sb.Append(Localization.current); + if(ftr.Current) sb.Append(Localization.current); sb.AppendLine(":"); - if(ftr.PP) - sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); + if(ftr.PP) sb.AppendLine("\t" + Localization.Drive_shall_report_Read_Write_Error_Recovery_mode_page); if(ftr.LogicalBlockSize > 0) sb.AppendFormat("\t" + Localization._0_bytes_per_logical_block, ftr.LogicalBlockSize).AppendLine(); @@ -3609,8 +3291,7 @@ public static class Features public static string Prettify_0027(Feature_0027? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0027 ftr = feature.Value; var sb = new StringBuilder(); @@ -3627,8 +3308,7 @@ public static class Features public static string Prettify_0028(Feature_0028? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0028 ftr = feature.Value; var sb = new StringBuilder(); @@ -3670,8 +3350,7 @@ public static class Features public static string Prettify_0029(Feature_0029? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0029 ftr = feature.Value; var sb = new StringBuilder(); @@ -3685,16 +3364,14 @@ public static class Features if(ftr.DBICacheZones > 0) sb.AppendFormat("\t" + Localization.Drive_has_0_DBI_cache_zones, ftr.DBICacheZones).AppendLine(); - if(ftr.Entries > 0) - sb.AppendFormat("\t" + Localization.Drive_has_0_DBI_entries, ftr.Entries).AppendLine(); + if(ftr.Entries > 0) sb.AppendFormat("\t" + Localization.Drive_has_0_DBI_entries, ftr.Entries).AppendLine(); return sb.ToString(); } public static string Prettify_002A(Feature_002A? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002A ftr = feature.Value; var sb = new StringBuilder(); @@ -3712,8 +3389,7 @@ public static class Features ? "\t" + Localization.Drive_supports_only_the_read_compatibility_stop : "\t" + Localization.Drive_supports_both_forms_of_background_format_stopping); - if(ftr.QuickStart) - sb.AppendLine("\t" + Localization.Drive_can_do_a_quick_start_formatting); + if(ftr.QuickStart) sb.AppendLine("\t" + Localization.Drive_can_do_a_quick_start_formatting); } else { @@ -3730,8 +3406,7 @@ public static class Features public static string Prettify_002B(Feature_002B? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002B ftr = feature.Value; var sb = new StringBuilder(); @@ -3760,8 +3435,7 @@ public static class Features public static string Prettify_002C(Feature_002C? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002C ftr = feature.Value; var sb = new StringBuilder(); @@ -3769,8 +3443,7 @@ public static class Features sb.Append(Localization.MMC_Rigid_Restricted_Overwrite); sb.AppendLine(ftr.Current ? $"{Localization.current}:" : ":"); - if(ftr.Blank) - sb.AppendLine("\t" + Localization.Drive_supports_the_BLANK_command); + if(ftr.Blank) sb.AppendLine("\t" + Localization.Drive_supports_the_BLANK_command); if(ftr.Intermediate) { @@ -3778,19 +3451,16 @@ public static class Features Localization.Drive_supports_writing_on_an_intermediate_state_session_and_quick_formatting); } - if(ftr.DSDR) - sb.AppendLine("\t" + Localization.Drive_can_read_Defect_Status_data_recorded_on_the_medium); + if(ftr.DSDR) sb.AppendLine("\t" + Localization.Drive_can_read_Defect_Status_data_recorded_on_the_medium); - if(ftr.DSDG) - sb.AppendLine("\t" + Localization.Drive_can_generate_Defect_Status_data_during_formatting); + if(ftr.DSDG) sb.AppendLine("\t" + Localization.Drive_can_generate_Defect_Status_data_during_formatting); return sb.ToString(); } public static string Prettify_002D(Feature_002D? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002D ftr = feature.Value; var sb = new StringBuilder(); @@ -3801,74 +3471,52 @@ public static class Features { sb.AppendLine("\t" + Localization.Drive_can_write_user_provided_data_in_the_R_W_subchannels); - if(ftr.RWRaw) - sb.AppendLine("\t" + Localization.Drive_accepts_RAW_R_W_subchannel_data); + if(ftr.RWRaw) sb.AppendLine("\t" + Localization.Drive_accepts_RAW_R_W_subchannel_data); - if(ftr.RWPack) - sb.AppendLine("\t" + Localization.Drive_accepts_Packed_R_W_subchannel_data); + if(ftr.RWPack) sb.AppendLine("\t" + Localization.Drive_accepts_Packed_R_W_subchannel_data); } - if(ftr.CDRW) - sb.AppendLine("\t" + Localization.Drive_can_overwrite_a_TAO_track_with_another_in_CD_RWs); + if(ftr.CDRW) sb.AppendLine("\t" + Localization.Drive_can_overwrite_a_TAO_track_with_another_in_CD_RWs); - if(ftr.TestWrite) - sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); + if(ftr.TestWrite) sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); - if(ftr.BUF) - sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); + if(ftr.BUF) sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); - if(ftr.DataTypeSupported <= 0) - return sb.ToString(); + if(ftr.DataTypeSupported <= 0) return sb.ToString(); sb.Append("\t" + Localization.Drive_supports_data_block_types); - if((ftr.DataTypeSupported & 0x0001) == 0x0001) - sb.Append(" 0"); + if((ftr.DataTypeSupported & 0x0001) == 0x0001) sb.Append(" 0"); - if((ftr.DataTypeSupported & 0x0002) == 0x0002) - sb.Append(" 1"); + if((ftr.DataTypeSupported & 0x0002) == 0x0002) sb.Append(" 1"); - if((ftr.DataTypeSupported & 0x0004) == 0x0004) - sb.Append(" 2"); + if((ftr.DataTypeSupported & 0x0004) == 0x0004) sb.Append(" 2"); - if((ftr.DataTypeSupported & 0x0008) == 0x0008) - sb.Append(" 3"); + if((ftr.DataTypeSupported & 0x0008) == 0x0008) sb.Append(" 3"); - if((ftr.DataTypeSupported & 0x0010) == 0x0010) - sb.Append(" 4"); + if((ftr.DataTypeSupported & 0x0010) == 0x0010) sb.Append(" 4"); - if((ftr.DataTypeSupported & 0x0020) == 0x0020) - sb.Append(" 5"); + if((ftr.DataTypeSupported & 0x0020) == 0x0020) sb.Append(" 5"); - if((ftr.DataTypeSupported & 0x0040) == 0x0040) - sb.Append(" 6"); + if((ftr.DataTypeSupported & 0x0040) == 0x0040) sb.Append(" 6"); - if((ftr.DataTypeSupported & 0x0080) == 0x0080) - sb.Append(" 7"); + if((ftr.DataTypeSupported & 0x0080) == 0x0080) sb.Append(" 7"); - if((ftr.DataTypeSupported & 0x0100) == 0x0100) - sb.Append(" 8"); + if((ftr.DataTypeSupported & 0x0100) == 0x0100) sb.Append(" 8"); - if((ftr.DataTypeSupported & 0x0200) == 0x0200) - sb.Append(" 9"); + if((ftr.DataTypeSupported & 0x0200) == 0x0200) sb.Append(" 9"); - if((ftr.DataTypeSupported & 0x0400) == 0x0400) - sb.Append(" 10"); + if((ftr.DataTypeSupported & 0x0400) == 0x0400) sb.Append(" 10"); - if((ftr.DataTypeSupported & 0x0800) == 0x0800) - sb.Append(" 11"); + if((ftr.DataTypeSupported & 0x0800) == 0x0800) sb.Append(" 11"); - if((ftr.DataTypeSupported & 0x1000) == 0x1000) - sb.Append(" 12"); + if((ftr.DataTypeSupported & 0x1000) == 0x1000) sb.Append(" 12"); - if((ftr.DataTypeSupported & 0x2000) == 0x2000) - sb.Append(" 13"); + if((ftr.DataTypeSupported & 0x2000) == 0x2000) sb.Append(" 13"); - if((ftr.DataTypeSupported & 0x4000) == 0x4000) - sb.Append(" 14"); + if((ftr.DataTypeSupported & 0x4000) == 0x4000) sb.Append(" 14"); - if((ftr.DataTypeSupported & 0x8000) == 0x8000) - sb.Append(" 15"); + if((ftr.DataTypeSupported & 0x8000) == 0x8000) sb.Append(" 15"); sb.AppendLine(); @@ -3877,8 +3525,7 @@ public static class Features public static string Prettify_002E(Feature_002E? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002E ftr = feature.Value; var sb = new StringBuilder(); @@ -3902,23 +3549,19 @@ public static class Features if(ftr is { RAW: true, RAWMS: true }) sb.AppendLine("\t" + Localization.Drive_can_write_multi_session_CDs_in_raw_mode); - if(ftr.RW) - sb.AppendLine("\t" + Localization.Drive_can_write_user_provided_data_in_the_R_W_subchannels); + if(ftr.RW) sb.AppendLine("\t" + Localization.Drive_can_write_user_provided_data_in_the_R_W_subchannels); - if(ftr.CDRW) - sb.AppendLine("\t" + Localization.Drive_can_write_CD_RW); + if(ftr.CDRW) sb.AppendLine("\t" + Localization.Drive_can_write_CD_RW); - if(ftr.TestWrite) - sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); + if(ftr.TestWrite) sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); - if(ftr.BUF) - sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); + if(ftr.BUF) sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); if(ftr.MaxCueSheet > 0) { sb.AppendFormat("\t" + Localization.Drive_supports_a_maximum_of_0_bytes_in_a_single_cue_sheet, - ftr.MaxCueSheet). - AppendLine(); + ftr.MaxCueSheet) + .AppendLine(); } return sb.ToString(); @@ -3926,8 +3569,7 @@ public static class Features public static string Prettify_002F(Feature_002F? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_002F ftr = feature.Value; var sb = new StringBuilder(); @@ -3941,11 +3583,9 @@ public static class Features else sb.AppendLine(Localization.Drive_supports_writing_DVD_R); - if(ftr.TestWrite) - sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); + if(ftr.TestWrite) sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); - if(ftr.BUF) - sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); + if(ftr.BUF) sb.AppendLine("\t" + Localization.Drive_supports_zero_loss_linking); return sb.ToString(); } @@ -3955,51 +3595,44 @@ public static class Features public static string Prettify_0031(Feature_0031? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0031 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_supports_writing_DDCD_R); - if(ftr.TestWrite) - sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); + if(ftr.TestWrite) sb.AppendLine("\t" + Localization.Drive_can_do_a_test_writing); return sb.ToString(); } public static string Prettify_0032(Feature_0032? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0032 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_supports_writing_DDCD_RW); - if(ftr.Blank) - sb.AppendLine("\t" + Localization.Drive_supports_the_BLANK_command); + if(ftr.Blank) sb.AppendLine("\t" + Localization.Drive_supports_the_BLANK_command); - if(ftr.Intermediate) - sb.AppendLine("\t" + Localization.Drive_supports_quick_formatting); + if(ftr.Intermediate) sb.AppendLine("\t" + Localization.Drive_supports_quick_formatting); return sb.ToString(); } public static string Prettify_0033(Feature_0033? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0033 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.MMC_Layer_Jump_Recording); - if(ftr.LinkSizes == null) - return sb.ToString(); + if(ftr.LinkSizes == null) return sb.ToString(); foreach(byte link in ftr.LinkSizes) sb.AppendFormat("\t" + Localization.Current_media_has_a_0_bytes_link_available, link).AppendLine(); @@ -4012,42 +3645,32 @@ public static class Features public static string Prettify_0037(Feature_0037? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0037 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_can_write_CD_RW); - if(ftr.SubtypeSupport <= 0) - return sb.ToString(); + if(ftr.SubtypeSupport <= 0) return sb.ToString(); sb.Append("\t" + Localization.Drive_supports_CD_RW_subtypes); - if((ftr.SubtypeSupport & 0x01) == 0x01) - sb.Append(" 0"); + if((ftr.SubtypeSupport & 0x01) == 0x01) sb.Append(" 0"); - if((ftr.SubtypeSupport & 0x02) == 0x02) - sb.Append(" 1"); + if((ftr.SubtypeSupport & 0x02) == 0x02) sb.Append(" 1"); - if((ftr.SubtypeSupport & 0x04) == 0x04) - sb.Append(" 2"); + if((ftr.SubtypeSupport & 0x04) == 0x04) sb.Append(" 2"); - if((ftr.SubtypeSupport & 0x08) == 0x08) - sb.Append(" 3"); + if((ftr.SubtypeSupport & 0x08) == 0x08) sb.Append(" 3"); - if((ftr.SubtypeSupport & 0x10) == 0x10) - sb.Append(" 4"); + if((ftr.SubtypeSupport & 0x10) == 0x10) sb.Append(" 4"); - if((ftr.SubtypeSupport & 0x20) == 0x20) - sb.Append(" 5"); + if((ftr.SubtypeSupport & 0x20) == 0x20) sb.Append(" 5"); - if((ftr.SubtypeSupport & 0x40) == 0x40) - sb.Append(" 6"); + if((ftr.SubtypeSupport & 0x40) == 0x40) sb.Append(" 6"); - if((ftr.SubtypeSupport & 0x80) == 0x80) - sb.Append(" 7"); + if((ftr.SubtypeSupport & 0x80) == 0x80) sb.Append(" 7"); sb.AppendLine(); @@ -4059,8 +3682,7 @@ public static class Features public static string Prettify_003A(Feature_003A? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_003A ftr = feature.Value; var sb = new StringBuilder(); @@ -4078,8 +3700,7 @@ public static class Features ? "\t" + Localization.Drive_supports_only_the_read_compatibility_stop : "\t" + Localization.Drive_supports_both_forms_of_background_format_stopping); - if(ftr.QuickStart) - sb.AppendLine("\t" + Localization.Drive_can_do_a_quick_start_formatting); + if(ftr.QuickStart) sb.AppendLine("\t" + Localization.Drive_can_do_a_quick_start_formatting); } else { @@ -4096,8 +3717,7 @@ public static class Features public static string Prettify_003B(Feature_003B? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_003B ftr = feature.Value; var sb = new StringBuilder(); @@ -4126,8 +3746,7 @@ public static class Features public static string Prettify_0040(Feature_0040? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0040 ftr = feature.Value; var sb = new StringBuilder(); @@ -4135,37 +3754,28 @@ public static class Features sb.Append(Localization.MMC_BD_Read); sb.AppendLine(ftr.Current ? $"{Localization.current}:" : ":"); - if(ftr.OldROM) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_ROM_pre_1_0); + if(ftr.OldROM) sb.AppendLine("\t" + Localization.Drive_can_read_BD_ROM_pre_1_0); - if(ftr.ROM) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_ROM_Ver_1); + if(ftr.ROM) sb.AppendLine("\t" + Localization.Drive_can_read_BD_ROM_Ver_1); - if(ftr.OldR) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_R_pre_1_0); + if(ftr.OldR) sb.AppendLine("\t" + Localization.Drive_can_read_BD_R_pre_1_0); - if(ftr.R) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_R_Ver_1); + if(ftr.R) sb.AppendLine("\t" + Localization.Drive_can_read_BD_R_Ver_1); - if(ftr.OldRE) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_pre_1_0); + if(ftr.OldRE) sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_pre_1_0); - if(ftr.RE1) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_Ver_1); + if(ftr.RE1) sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_Ver_1); - if(ftr.RE2) - sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_Ver_2); + if(ftr.RE2) sb.AppendLine("\t" + Localization.Drive_can_read_BD_RE_Ver_2); - if(ftr.BCA) - sb.AppendLine("\t" + Localization.Drive_can_read_BDs_Burst_Cutting_Area); + if(ftr.BCA) sb.AppendLine("\t" + Localization.Drive_can_read_BDs_Burst_Cutting_Area); return sb.ToString(); } public static string Prettify_0041(Feature_0041? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0041 ftr = feature.Value; var sb = new StringBuilder(); @@ -4173,23 +3783,17 @@ public static class Features sb.Append(Localization.MMC_BD_Write); sb.AppendLine(ftr.Current ? $"{Localization.current}:" : ":"); - if(ftr.OldR) - sb.AppendLine("\t" + Localization.Drive_can_write_BD_R_pre_1_0); + if(ftr.OldR) sb.AppendLine("\t" + Localization.Drive_can_write_BD_R_pre_1_0); - if(ftr.R) - sb.AppendLine("\t" + Localization.Drive_can_write_BD_R_Ver_1); + if(ftr.R) sb.AppendLine("\t" + Localization.Drive_can_write_BD_R_Ver_1); - if(ftr.OldRE) - sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_pre_1_0); + if(ftr.OldRE) sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_pre_1_0); - if(ftr.RE1) - sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_Ver_1); + if(ftr.RE1) sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_Ver_1); - if(ftr.RE2) - sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_Ver_2); + if(ftr.RE2) sb.AppendLine("\t" + Localization.Drive_can_write_BD_RE_Ver_2); - if(ftr.SVNR) - sb.AppendLine("\t" + Localization.Drive_supports_write_without_verify_requirement); + if(ftr.SVNR) sb.AppendLine("\t" + Localization.Drive_supports_write_without_verify_requirement); return sb.ToString(); } @@ -4197,14 +3801,13 @@ public static class Features public static string Prettify_0042(Feature_0042? feature) => !feature.HasValue ? null - : Localization. - Features_Prettify_0042_Drive_is_able_to_detect_and_report_defective_writable_unit_and_behave_accordingly + + : Localization + .Features_Prettify_0042_Drive_is_able_to_detect_and_report_defective_writable_unit_and_behave_accordingly + "\n"; public static string Prettify_0050(Feature_0050? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0050 ftr = feature.Value; var sb = new StringBuilder(); @@ -4239,8 +3842,7 @@ public static class Features public static string Prettify_0051(Feature_0051? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0051 ftr = feature.Value; var sb = new StringBuilder(); @@ -4275,8 +3877,7 @@ public static class Features public static string Prettify_0080(Feature_0080? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0080 ftr = feature.Value; var sb = new StringBuilder(); @@ -4291,8 +3892,8 @@ public static class Features if(ftr.RI) { sb.AppendLine("\t" + - Localization. - Drive_is_able_to_maintain_the_online_format_layer_through_reset_and_power_cycling); + Localization + .Drive_is_able_to_maintain_the_online_format_layer_through_reset_and_power_cycling); } return sb.ToString(); @@ -4305,35 +3906,30 @@ public static class Features public static string Prettify_0101(Feature_0101? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0101 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_supports_SMART); - if(ftr.PP) - sb.AppendLine("\t" + Localization.Drive_supports_the_Informational_Exceptions_Control_mode_page_1Ch); + if(ftr.PP) sb.AppendLine("\t" + Localization.Drive_supports_the_Informational_Exceptions_Control_mode_page_1Ch); return sb.ToString(); } public static string Prettify_0102(Feature_0102? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0102 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.MMC_Embedded_Changer); - if(ftr.SCC) - sb.AppendLine("\t" + Localization.Drive_can_change_disc_side); + if(ftr.SCC) sb.AppendLine("\t" + Localization.Drive_can_change_disc_side); - if(ftr.SDP) - sb.AppendLine("\t" + Localization.Drive_is_able_to_report_slots_contents_after_a_reset_or_change); + if(ftr.SDP) sb.AppendLine("\t" + Localization.Drive_is_able_to_report_slots_contents_after_a_reset_or_change); sb.AppendFormat("\t" + Localization.Drive_has_0_slots, ftr.HighestSlotNumber + 1).AppendLine(); @@ -4342,22 +3938,18 @@ public static class Features public static string Prettify_0103(Feature_0103? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0103 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_has_an_analogue_audio_output); - if(ftr.Scan) - sb.AppendLine("\t" + Localization.Drive_supports_the_SCAN_command); + if(ftr.Scan) sb.AppendLine("\t" + Localization.Drive_supports_the_SCAN_command); - if(ftr.SCM) - sb.AppendLine("\t" + Localization.Drive_is_able_to_mute_channels_separately); + if(ftr.SCM) sb.AppendLine("\t" + Localization.Drive_is_able_to_mute_channels_separately); - if(ftr.SV) - sb.AppendLine("\t" + Localization.Drive_supports_separate_volume_per_channel); + if(ftr.SV) sb.AppendLine("\t" + Localization.Drive_supports_separate_volume_per_channel); sb.AppendFormat("\t" + Localization.Drive_has_0_volume_levels, ftr.VolumeLevels + 1).AppendLine(); @@ -4366,8 +3958,7 @@ public static class Features public static string Prettify_0104(Feature_0104? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0104 ftr = feature.Value; var sb = new StringBuilder(); @@ -4376,8 +3967,8 @@ public static class Features if(ftr.M5) { - sb.AppendLine(Localization. - Drive_supports_validating_the_5_bit_Mode_of_the_READ_BUFFER_and_WRITE_BUFFER_commands); + sb.AppendLine(Localization + .Drive_supports_validating_the_5_bit_Mode_of_the_READ_BUFFER_and_WRITE_BUFFER_commands); } return sb.ToString(); @@ -4385,16 +3976,14 @@ public static class Features public static string Prettify_0105(Feature_0105? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0105 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_supports_Timeout_Protect_mode_page_1Dh); - if(!ftr.Group3) - return sb.ToString(); + if(!ftr.Group3) return sb.ToString(); sb.AppendLine("\t" + Localization.Drive_supports_the_Group3_in_Timeout_Protect_mode_page_1Dh); @@ -4406,8 +3995,7 @@ public static class Features public static string Prettify_0106(Feature_0106? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0106 ftr = feature.Value; var sb = new StringBuilder(); @@ -4415,8 +4003,8 @@ public static class Features if(ftr.Current) { sb.AppendFormat(Localization.Drive_supports_DVD_CSS_CPPM_version_0_and_current_disc_is_encrypted, - ftr.CSSVersion). - AppendLine(); + ftr.CSSVersion) + .AppendLine(); } else sb.AppendFormat(Localization.Drive_supports_DVD_CSS_CPPM_version_0, ftr.CSSVersion).AppendLine(); @@ -4426,8 +4014,7 @@ public static class Features public static string Prettify_0107(Feature_0107? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0107 ftr = feature.Value; var sb = new StringBuilder(); @@ -4440,33 +4027,30 @@ public static class Features if(ftr.RBCB) sb.AppendLine("\t" + Localization.Drive_supports_the_block_bit_in_the_READ_BUFFER_CAPACITY_command); - if(ftr.SCS) - sb.AppendLine("\t" + Localization.Drive_supports_the_SET_CD_SPEED_command); + if(ftr.SCS) sb.AppendLine("\t" + Localization.Drive_supports_the_SET_CD_SPEED_command); if(ftr.MP2A) { sb.AppendLine("\t" + - Localization. - Drive_supports_the_Write_Speed_Performance_Descriptor_Blocks_in_the_MMC_mode_page_2Ah); + Localization + .Drive_supports_the_Write_Speed_Performance_Descriptor_Blocks_in_the_MMC_mode_page_2Ah); } if(ftr.WSPD) { sb.AppendLine("\t" + - Localization. - Drive_supports_the_Write_Speed_data_of_GET_PERFORMANCE_and_the_WRC_field_of_SET_STREAMING); + Localization + .Drive_supports_the_Write_Speed_data_of_GET_PERFORMANCE_and_the_WRC_field_of_SET_STREAMING); } - if(ftr.SW) - sb.AppendLine("\t" + Localization.Drive_supports_stream_recording); + if(ftr.SW) sb.AppendLine("\t" + Localization.Drive_supports_stream_recording); return sb.ToString(); } public static string Prettify_0108(Feature_0108? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0108 ftr = feature.Value; var sb = new StringBuilder(); @@ -4481,25 +4065,21 @@ public static class Features public static string Prettify_010A(Feature_010A? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_010A ftr = feature.Value; var sb = new StringBuilder(); - if(ftr.DCBs == null) - return sb.ToString(); + if(ftr.DCBs == null) return sb.ToString(); - foreach(uint dcb in ftr.DCBs) - sb.AppendFormat(Localization.Drive_supports_DCB_0, dcb).AppendLine(); + foreach(uint dcb in ftr.DCBs) sb.AppendFormat(Localization.Drive_supports_DCB_0, dcb).AppendLine(); return sb.ToString(); } public static string Prettify_010B(Feature_010B? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_010B ftr = feature.Value; var sb = new StringBuilder(); @@ -4507,8 +4087,8 @@ public static class Features if(ftr.Current) { sb.AppendFormat(Localization.Drive_supports_DVD_CPRM_version_0_and_current_disc_is_or_can_be_encrypted, - ftr.CPRMVersion). - AppendLine(); + ftr.CPRMVersion) + .AppendLine(); } else sb.AppendFormat(Localization.Drive_supports_DVD_CPRM_version_0, ftr.CPRMVersion).AppendLine(); @@ -4518,8 +4098,7 @@ public static class Features public static string Prettify_010C(Feature_010C? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_010C ftr = feature.Value; var sb = new StringBuilder(); @@ -4553,48 +4132,48 @@ public static class Features try { - var fwDate = new DateTime(int.Parse(syear), int.Parse(smonth), int.Parse(sday), int.Parse(shour), - int.Parse(sminute), int.Parse(ssecond), DateTimeKind.Utc); + var fwDate = new DateTime(int.Parse(syear), + int.Parse(smonth), + int.Parse(sday), + int.Parse(shour), + int.Parse(sminute), + int.Parse(ssecond), + DateTimeKind.Utc); sb.AppendFormat(Localization.Drive_firmware_is_dated_0, fwDate).AppendLine(); } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored } - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body return sb.ToString(); } public static string Prettify_010D(Feature_010D? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_010D ftr = feature.Value; var sb = new StringBuilder(); if(ftr.Current) { - sb.AppendFormat(Localization.Drive_supports_AACS_version_0_and_current_disc_is_encrypted, ftr.AACSVersion). - AppendLine(); + sb.AppendFormat(Localization.Drive_supports_AACS_version_0_and_current_disc_is_encrypted, ftr.AACSVersion) + .AppendLine(); } else sb.AppendFormat(Localization.Drive_supports_AACS_version_0, ftr.AACSVersion).AppendLine(); - if(ftr.RDC) - sb.AppendLine("\t" + Localization.Drive_supports_reading_the_Drive_Certificate); + if(ftr.RDC) sb.AppendLine("\t" + Localization.Drive_supports_reading_the_Drive_Certificate); - if(ftr.RMC) - sb.AppendLine("\t" + Localization.Drive_supports_reading_Media_Key_Block_of_CPRM); + if(ftr.RMC) sb.AppendLine("\t" + Localization.Drive_supports_reading_Media_Key_Block_of_CPRM); - if(ftr.WBE) - sb.AppendLine("\t" + Localization.Drive_supports_writing_with_bus_encryption); + if(ftr.WBE) sb.AppendLine("\t" + Localization.Drive_supports_writing_with_bus_encryption); - if(ftr.BEC) - sb.AppendLine("\t" + Localization.Drive_supports_bus_encryption); + if(ftr.BEC) sb.AppendLine("\t" + Localization.Drive_supports_bus_encryption); if(ftr.BNG) { @@ -4603,8 +4182,8 @@ public static class Features if(ftr.BindNonceBlocks > 0) { sb.AppendFormat("\t" + Localization._0_media_blocks_are_required_for_the_binding_nonce, - ftr.BindNonceBlocks). - AppendLine(); + ftr.BindNonceBlocks) + .AppendLine(); } } @@ -4616,8 +4195,7 @@ public static class Features public static string Prettify_010E(Feature_010E? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_010E ftr = feature.Value; var sb = new StringBuilder(); @@ -4631,8 +4209,8 @@ public static class Features if(ftr.MaxScrambleExtent > 0) { - sb.AppendFormat("\t" + Localization.Maximum_0_scramble_extent_information_entries, ftr.MaxScrambleExtent). - AppendLine(); + sb.AppendFormat("\t" + Localization.Maximum_0_scramble_extent_information_entries, ftr.MaxScrambleExtent) + .AppendLine(); } return sb.ToString(); @@ -4640,8 +4218,7 @@ public static class Features public static string Prettify_0110(Feature_0110? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0110 ftr = feature.Value; var sb = new StringBuilder(); @@ -4655,8 +4232,7 @@ public static class Features public static string Prettify_0113(Feature_0113? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0113 ftr = feature.Value; var sb = new StringBuilder(); @@ -4670,28 +4246,22 @@ public static class Features public static string Prettify_0142(Feature_0142? feature) { - if(!feature.HasValue) - return null; + if(!feature.HasValue) return null; Feature_0142 ftr = feature.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Drive_supports_the_Trusted_Computing_Group_Optical_Security_Subsystem_Class); - if(ftr.Current) - sb.AppendLine("\t" + Localization.Current_media_is_initialized_with_TCG_OSSC); + if(ftr.Current) sb.AppendLine("\t" + Localization.Current_media_is_initialized_with_TCG_OSSC); - if(ftr.PSAU) - sb.AppendLine("\t" + Localization.Drive_supports_PSA_updates_on_write_once_media); + if(ftr.PSAU) sb.AppendLine("\t" + Localization.Drive_supports_PSA_updates_on_write_once_media); - if(ftr.LOSPB) - sb.AppendLine("\t" + Localization.Drive_supports_linked_OSPBs); + if(ftr.LOSPB) sb.AppendLine("\t" + Localization.Drive_supports_linked_OSPBs); - if(ftr.ME) - sb.AppendLine("\t" + Localization.Drive_will_only_record_on_the_OSSC_Disc_Format); + if(ftr.ME) sb.AppendLine("\t" + Localization.Drive_will_only_record_on_the_OSSC_Disc_Format); - if(ftr.Profiles == null) - return sb.ToString(); + if(ftr.Profiles == null) return sb.ToString(); for(var i = 0; i < ftr.Profiles.Length; i++) sb.AppendFormat("\t" + Localization.Profile_0_1, i, ftr.Profiles[i]).AppendLine(); @@ -4834,8 +4404,7 @@ public static class Features Data = new byte[response[offset + 3] + 4] }; - if(desc.Data.Length + offset > response.Length) - desc.Data = new byte[response.Length - offset]; + if(desc.Data.Length + offset > response.Length) desc.Data = new byte[response.Length - offset]; Array.Copy(response, offset, desc.Data, 0, desc.Data.Length); offset += (uint)desc.Data.Length; diff --git a/Aaru.Decoders/SCSI/MMC/Hybrid.cs b/Aaru.Decoders/SCSI/MMC/Hybrid.cs index adcb44f06..7ba562e1e 100644 --- a/Aaru.Decoders/SCSI/MMC/Hybrid.cs +++ b/Aaru.Decoders/SCSI/MMC/Hybrid.cs @@ -59,11 +59,9 @@ public static class Hybrid { public static RecognizedFormatLayers? DecodeFormatLayers(byte[] FormatLayersResponse) { - if(FormatLayersResponse == null) - return null; + if(FormatLayersResponse == null) return null; - if(FormatLayersResponse.Length < 8) - return null; + if(FormatLayersResponse.Length < 8) return null; var decoded = new RecognizedFormatLayers { @@ -86,8 +84,7 @@ public static class Hybrid public static string PrettifyFormatLayers(RecognizedFormatLayers? FormatLayersResponse) { - if(FormatLayersResponse == null) - return null; + if(FormatLayersResponse == null) return null; RecognizedFormatLayers response = FormatLayersResponse.Value; @@ -103,11 +100,9 @@ public static class Hybrid { sb.AppendFormat(Localization.Layer_0_is_of_type_Blu_ray, i).AppendLine(); - if(response.DefaultFormatLayer == i) - sb.AppendLine(Localization.This_is_the_default_layer); + if(response.DefaultFormatLayer == i) sb.AppendLine(Localization.This_is_the_default_layer); - if(response.OnlineFormatLayer == i) - sb.AppendLine(Localization.This_is_the_layer_actually_in_use); + if(response.OnlineFormatLayer == i) sb.AppendLine(Localization.This_is_the_layer_actually_in_use); break; } @@ -116,11 +111,9 @@ public static class Hybrid { sb.AppendFormat(Localization.Layer_0_is_of_type_CD, i).AppendLine(); - if(response.DefaultFormatLayer == i) - sb.AppendLine(Localization.This_is_the_default_layer); + if(response.DefaultFormatLayer == i) sb.AppendLine(Localization.This_is_the_default_layer); - if(response.OnlineFormatLayer == i) - sb.AppendLine(Localization.This_is_the_layer_actually_in_use); + if(response.OnlineFormatLayer == i) sb.AppendLine(Localization.This_is_the_layer_actually_in_use); break; } @@ -129,11 +122,9 @@ public static class Hybrid { sb.AppendFormat(Localization.Layer_0_is_of_type_DVD, i).AppendLine(); - if(response.DefaultFormatLayer == i) - sb.AppendLine(Localization.This_is_the_default_layer); + if(response.DefaultFormatLayer == i) sb.AppendLine(Localization.This_is_the_default_layer); - if(response.OnlineFormatLayer == i) - sb.AppendLine(Localization.This_is_the_layer_actually_in_use); + if(response.OnlineFormatLayer == i) sb.AppendLine(Localization.This_is_the_layer_actually_in_use); break; } @@ -142,25 +133,21 @@ public static class Hybrid { sb.AppendFormat(Localization.Layer_0_is_of_type_HD_DVD, i).AppendLine(); - if(response.DefaultFormatLayer == i) - sb.AppendLine(Localization.This_is_the_default_layer); + if(response.DefaultFormatLayer == i) sb.AppendLine(Localization.This_is_the_default_layer); - if(response.OnlineFormatLayer == i) - sb.AppendLine(Localization.This_is_the_layer_actually_in_use); + if(response.OnlineFormatLayer == i) sb.AppendLine(Localization.This_is_the_layer_actually_in_use); break; } default: { - sb.AppendFormat(Localization.Layer_0_is_of_unknown_type_1, i, response.FormatLayers[i]). - AppendLine(); + sb.AppendFormat(Localization.Layer_0_is_of_unknown_type_1, i, response.FormatLayers[i]) + .AppendLine(); - if(response.DefaultFormatLayer == i) - sb.AppendLine(Localization.This_is_the_default_layer); + if(response.DefaultFormatLayer == i) sb.AppendLine(Localization.This_is_the_default_layer); - if(response.OnlineFormatLayer == i) - sb.AppendLine(Localization.This_is_the_layer_actually_in_use); + if(response.OnlineFormatLayer == i) sb.AppendLine(Localization.This_is_the_layer_actually_in_use); break; } diff --git a/Aaru.Decoders/SCSI/MMC/TrackInformation.cs b/Aaru.Decoders/SCSI/MMC/TrackInformation.cs index e04eec01e..31e837c0e 100644 --- a/Aaru.Decoders/SCSI/MMC/TrackInformation.cs +++ b/Aaru.Decoders/SCSI/MMC/TrackInformation.cs @@ -59,8 +59,7 @@ public class TrackInformation public static TrackInformation Decode(byte[] response) { - if(response.Length < 32) - return null; + if(response.Length < 32) return null; var decoded = new TrackInformation { @@ -89,8 +88,7 @@ public class TrackInformation (uint)((response[28] << 24) + (response[29] << 16) + (response[30] << 8) + response[31]) }; - if(response.Length < 48) - return decoded; + if(response.Length < 48) return decoded; decoded.LogicalTrackNumber += (ushort)(response[32] << 8); diff --git a/Aaru.Decoders/SCSI/MMC/WriteProtect.cs b/Aaru.Decoders/SCSI/MMC/WriteProtect.cs index 545bfc274..77bacc7fe 100644 --- a/Aaru.Decoders/SCSI/MMC/WriteProtect.cs +++ b/Aaru.Decoders/SCSI/MMC/WriteProtect.cs @@ -58,8 +58,7 @@ public static class WriteProtect { public static WriteProtectionStatus? DecodeWriteProtectionStatus(byte[] WPSResponse) { - if(WPSResponse == null) - return null; + if(WPSResponse == null) return null; var decoded = new WriteProtectionStatus { @@ -81,26 +80,21 @@ public static class WriteProtect public static string PrettifyWriteProtectionStatus(WriteProtectionStatus? WPSResponse) { - if(WPSResponse == null) - return null; + if(WPSResponse == null) return null; WriteProtectionStatus response = WPSResponse.Value; var sb = new StringBuilder(); - if(response.MSWI) - sb.AppendLine(Localization.Writing_inhibited_by_media_specific_reason); + if(response.MSWI) sb.AppendLine(Localization.Writing_inhibited_by_media_specific_reason); - if(response.CWP) - sb.AppendLine(Localization.Cartridge_sets_write_protection); + if(response.CWP) sb.AppendLine(Localization.Cartridge_sets_write_protection); - if(response.PWP) - sb.AppendLine(Localization.Media_surface_sets_write_protection); + if(response.PWP) sb.AppendLine(Localization.Media_surface_sets_write_protection); - if(response.SWPP) - sb.AppendLine(Localization.Software_write_protection_is_set_until_power_down); + if(response.SWPP) sb.AppendLine(Localization.Software_write_protection_is_set_until_power_down); - #if DEBUG +#if DEBUG if(response.Reserved1 != 0) sb.AppendFormat(Localization.Reserved1_equals_0_X8, response.Reserved1).AppendLine(); @@ -118,7 +112,7 @@ public static class WriteProtect if(response.Reserved6 != 0) sb.AppendFormat(Localization.Reserved_6_equals_0_X2, response.Reserved6).AppendLine(); - #endif +#endif return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/00_SFF.cs b/Aaru.Decoders/SCSI/Modes/00_SFF.cs index 8bc2c7fa3..a42ddebe4 100644 --- a/Aaru.Decoders/SCSI/Modes/00_SFF.cs +++ b/Aaru.Decoders/SCSI/Modes/00_SFF.cs @@ -59,17 +59,13 @@ public static partial class Modes public static ModePage_00_SFF? DecodeModePage_00_SFF(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x00) - return null; + if((pageResponse?[0] & 0x3F) != 0x00) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 4) - return null; + if(pageResponse.Length < 4) return null; var decoded = new ModePage_00_SFF(); @@ -89,25 +85,20 @@ public static partial class Modes public static string PrettifyModePage_00_SFF(ModePage_00_SFF? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_00_SFF page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Drive_Operation_Mode_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.DVW) - sb.AppendLine("\t" + Localization.Verifying_after_writing_is_disabled); + if(page.DVW) sb.AppendLine("\t" + Localization.Verifying_after_writing_is_disabled); - if(page.DDE) - sb.AppendLine("\t" + Localization.Drive_will_abort_when_a_writing_error_is_detected); + if(page.DDE) sb.AppendLine("\t" + Localization.Drive_will_abort_when_a_writing_error_is_detected); - if(!page.SLM) - return sb.ToString(); + if(!page.SLM) return sb.ToString(); sb.Append("\t" + Localization.Drive_has_two_LUNs_with_rewritable_being); sb.AppendLine(page.SLR ? "LUN 1" : "LUN 0"); diff --git a/Aaru.Decoders/SCSI/Modes/01.cs b/Aaru.Decoders/SCSI/Modes/01.cs index 57c370f1e..8f572fa22 100644 --- a/Aaru.Decoders/SCSI/Modes/01.cs +++ b/Aaru.Decoders/SCSI/Modes/01.cs @@ -47,32 +47,23 @@ public static partial class Modes pg[0] = 0x01; pg[1] = 6; - if(page.PS) - pg[0] += 0x80; + if(page.PS) pg[0] += 0x80; - if(page.AWRE) - pg[2] += 0x80; + if(page.AWRE) pg[2] += 0x80; - if(page.ARRE) - pg[2] += 0x40; + if(page.ARRE) pg[2] += 0x40; - if(page.TB) - pg[2] += 0x20; + if(page.TB) pg[2] += 0x20; - if(page.RC) - pg[2] += 0x10; + if(page.RC) pg[2] += 0x10; - if(page.EER) - pg[2] += 0x08; + if(page.EER) pg[2] += 0x08; - if(page.PER) - pg[2] += 0x04; + if(page.PER) pg[2] += 0x04; - if(page.DTE) - pg[2] += 0x02; + if(page.DTE) pg[2] += 0x02; - if(page.DCR) - pg[2] += 0x01; + if(page.DCR) pg[2] += 0x01; pg[3] = page.ReadRetryCount; pg[4] = page.CorrectionSpan; @@ -132,17 +123,13 @@ public static partial class Modes public static ModePage_01? DecodeModePage_01(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x01) - return null; + if((pageResponse?[0] & 0x3F) != 0x01) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_01(); @@ -161,8 +148,7 @@ public static partial class Modes decoded.HeadOffsetCount = (sbyte)pageResponse[5]; decoded.DataStrobeOffsetCount = (sbyte)pageResponse[6]; - if(pageResponse.Length < 12) - return decoded; + if(pageResponse.Length < 12) return decoded; decoded.WriteRetryCount = pageResponse[8]; decoded.RecoveryTimeLimit = (ushort)((pageResponse[10] << 8) + pageResponse[11]); @@ -176,70 +162,61 @@ public static partial class Modes public static string PrettifyModePage_01(ModePage_01? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_01 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Read_write_error_recovery_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.AWRE) - sb.AppendLine("\t" + Localization.Automatic_write_reallocation_is_enabled); + if(page.AWRE) sb.AppendLine("\t" + Localization.Automatic_write_reallocation_is_enabled); - if(page.ARRE) - sb.AppendLine("\t" + Localization.Automatic_read_reallocation_is_enabled); + if(page.ARRE) sb.AppendLine("\t" + Localization.Automatic_read_reallocation_is_enabled); if(page.TB) { sb.AppendLine("\t" + - Localization. - Data_not_recovered_within_limits_shall_be_transferred_back_before_a_CHECK_CONDITION); + Localization + .Data_not_recovered_within_limits_shall_be_transferred_back_before_a_CHECK_CONDITION); } if(page.RC) { sb.AppendLine("\t" + - Localization. - Drive_will_transfer_the_entire_requested_length_without_delaying_to_perform_error_recovery); + Localization + .Drive_will_transfer_the_entire_requested_length_without_delaying_to_perform_error_recovery); } - if(page.EER) - sb.AppendLine("\t" + Localization.Drive_will_use_the_most_expedient_form_of_error_recovery_first); + if(page.EER) sb.AppendLine("\t" + Localization.Drive_will_use_the_most_expedient_form_of_error_recovery_first); - if(page.PER) - sb.AppendLine("\t" + Localization.Drive_shall_report_recovered_errors); + if(page.PER) sb.AppendLine("\t" + Localization.Drive_shall_report_recovered_errors); - if(page.DTE) - sb.AppendLine("\t" + Localization.Transfer_will_be_terminated_upon_error_detection); + if(page.DTE) sb.AppendLine("\t" + Localization.Transfer_will_be_terminated_upon_error_detection); - if(page.DCR) - sb.AppendLine("\t" + Localization.Error_correction_is_disabled); + if(page.DCR) sb.AppendLine("\t" + Localization.Error_correction_is_disabled); if(page.ReadRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_read_operations_0_times, page.ReadRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_read_operations_0_times, page.ReadRetryCount) + .AppendLine(); } if(page.WriteRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_write_operations_0_times, page.WriteRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_write_operations_0_times, page.WriteRetryCount) + .AppendLine(); } if(page.RecoveryTimeLimit > 0) { sb.AppendFormat("\t" + Localization.Drive_will_employ_a_maximum_of_0_ms_to_recover_data, - page.RecoveryTimeLimit). - AppendLine(); + page.RecoveryTimeLimit) + .AppendLine(); } - if(page.LBPERE) - sb.AppendLine(Localization.Logical_block_provisioning_error_reporting_is_enabled); + if(page.LBPERE) sb.AppendLine(Localization.Logical_block_provisioning_error_reporting_is_enabled); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/01_MMC.cs b/Aaru.Decoders/SCSI/Modes/01_MMC.cs index 6bc9d83b0..3196f1ead 100644 --- a/Aaru.Decoders/SCSI/Modes/01_MMC.cs +++ b/Aaru.Decoders/SCSI/Modes/01_MMC.cs @@ -47,8 +47,7 @@ public static partial class Modes pg[0] = 0x01; pg[1] = 10; - if(page.PS) - pg[0] += 0x80; + if(page.PS) pg[0] += 0x80; pg[2] = page.Parameter; pg[3] = page.ReadRetryCount; @@ -84,17 +83,13 @@ public static partial class Modes public static ModePage_01_MMC? DecodeModePage_01_MMC(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x01) - return null; + if((pageResponse?[0] & 0x3F) != 0x01) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_01_MMC(); @@ -102,8 +97,7 @@ public static partial class Modes decoded.Parameter = pageResponse[2]; decoded.ReadRetryCount = pageResponse[3]; - if(pageResponse.Length < 12) - return decoded; + if(pageResponse.Length < 12) return decoded; decoded.WriteRetryCount = pageResponse[8]; decoded.RecoveryTimeLimit = (ushort)((pageResponse[10] << 8) + pageResponse[11]); @@ -116,21 +110,19 @@ public static partial class Modes public static string PrettifyModePage_01_MMC(ModePage_01_MMC? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_01_MMC page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Read_error_recovery_page_for_MultiMedia_Devices); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.ReadRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_read_operations_0_times, page.ReadRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_read_operations_0_times, page.ReadRetryCount) + .AppendLine(); } string AllUsed = "\t" + Localization.All_available_recovery_procedures_will_be_used + "\n"; @@ -235,15 +227,15 @@ public static partial class Modes if(page.WriteRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_write_operations_0_times, page.WriteRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_write_operations_0_times, page.WriteRetryCount) + .AppendLine(); } if(page.RecoveryTimeLimit > 0) { sb.AppendFormat("\t" + Localization.Drive_will_employ_a_maximum_of_0_ms_to_recover_data, - page.RecoveryTimeLimit). - AppendLine(); + page.RecoveryTimeLimit) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/02.cs b/Aaru.Decoders/SCSI/Modes/02.cs index e39c98303..483d5e19e 100644 --- a/Aaru.Decoders/SCSI/Modes/02.cs +++ b/Aaru.Decoders/SCSI/Modes/02.cs @@ -77,17 +77,13 @@ public static partial class Modes public static ModePage_02? DecodeModePage_02(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x02) - return null; + if((pageResponse?[0] & 0x3F) != 0x02) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 12) - return null; + if(pageResponse.Length < 12) return null; var decoded = new ModePage_02(); @@ -107,8 +103,7 @@ public static partial class Modes decoded.DTDC = (byte)(pageResponse[12] & 0x07); } - if(pageResponse.Length >= 16) - decoded.FirstBurstSize = (ushort)((pageResponse[14] << 8) + pageResponse[15]); + if(pageResponse.Length >= 16) decoded.FirstBurstSize = (ushort)((pageResponse[14] << 8) + pageResponse[15]); return decoded; } @@ -118,79 +113,79 @@ public static partial class Modes public static string PrettifyModePage_02(ModePage_02? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_02 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Disconnect_Reconnect_mode_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.BufferFullRatio > 0) { sb.AppendFormat("\t" + Localization._0_ratio_of_buffer_that_shall_be_full_prior_to_attempting_a_reselection, - page.BufferFullRatio). - AppendLine(); + page.BufferFullRatio) + .AppendLine(); } if(page.BufferEmptyRatio > 0) { - sb. - AppendFormat("\t" + Localization._0_ratio_of_buffer_that_shall_be_empty_prior_to_attempting_a_reselection, - page.BufferEmptyRatio). - AppendLine(); + sb.AppendFormat("\t" + + Localization._0_ratio_of_buffer_that_shall_be_empty_prior_to_attempting_a_reselection, + page.BufferEmptyRatio) + .AppendLine(); } if(page.BusInactivityLimit > 0) { sb.AppendFormat("\t" + Localization._0_µs_maximum_permitted_to_assert_BSY_without_a_REQ_ACK_handshake, - page.BusInactivityLimit * 100). - AppendLine(); + page.BusInactivityLimit * 100) + .AppendLine(); } if(page.DisconnectTimeLimit > 0) { - sb. - AppendFormat("\t" + Localization._0_µs_maximum_permitted_wait_after_releasing_the_bus_before_attempting_reselection, - page.DisconnectTimeLimit * 100). - AppendLine(); + sb.AppendFormat("\t" + + Localization + ._0_µs_maximum_permitted_wait_after_releasing_the_bus_before_attempting_reselection, + page.DisconnectTimeLimit * 100) + .AppendLine(); } if(page.ConnectTimeLimit > 0) { - sb. - AppendFormat("\t" + Localization._0_µs_allowed_to_use_the_bus_before_disconnecting_if_granted_the_privilege_and_not_restricted, - page.ConnectTimeLimit * 100). - AppendLine(); + sb.AppendFormat("\t" + + Localization + ._0_µs_allowed_to_use_the_bus_before_disconnecting_if_granted_the_privilege_and_not_restricted, + page.ConnectTimeLimit * 100) + .AppendLine(); } if(page.MaxBurstSize > 0) { sb.AppendFormat("\t" + Localization._0_bytes_maximum_can_be_transferred_before_disconnecting, - page.MaxBurstSize * 512). - AppendLine(); + page.MaxBurstSize * 512) + .AppendLine(); } if(page.FirstBurstSize > 0) { - sb. - AppendFormat("\t" + Localization._0_bytes_maximum_can_be_transferred_for_a_command_along_with_the_disconnect_command, - page.FirstBurstSize * 512). - AppendLine(); + sb.AppendFormat("\t" + + Localization + ._0_bytes_maximum_can_be_transferred_for_a_command_along_with_the_disconnect_command, + page.FirstBurstSize * 512) + .AppendLine(); } if(page.DIMM) { sb.AppendLine("\t" + - Localization. - Target_shall_not_transfer_data_for_a_command_during_the_same_interconnect_tenancy); + Localization + .Target_shall_not_transfer_data_for_a_command_during_the_same_interconnect_tenancy); } - if(page.EMDP) - sb.AppendLine("\t" + Localization.Target_is_allowed_to_reorder_the_data_transfer); + if(page.EMDP) sb.AppendLine("\t" + Localization.Target_is_allowed_to_reorder_the_data_transfer); switch(page.DTDC) { @@ -200,19 +195,19 @@ public static partial class Modes break; case 1: sb.AppendLine("\t" + - Localization. - All_data_for_a_command_shall_be_transferred_within_a_single_interconnect_tenancy); + Localization + .All_data_for_a_command_shall_be_transferred_within_a_single_interconnect_tenancy); break; case 3: sb.AppendLine("\t" + - Localization. - All_data_and_the_response_for_a_command_shall_be_transferred_within_a_single_interconnect_tenancy); + Localization + .All_data_and_the_response_for_a_command_shall_be_transferred_within_a_single_interconnect_tenancy); break; default: - sb.AppendFormat("\t" + Localization.Reserved_data_transfer_disconnect_control_value_0, page.DTDC). - AppendLine(); + sb.AppendFormat("\t" + Localization.Reserved_data_transfer_disconnect_control_value_0, page.DTDC) + .AppendLine(); break; } diff --git a/Aaru.Decoders/SCSI/Modes/03.cs b/Aaru.Decoders/SCSI/Modes/03.cs index c9cf387c1..b4634c0b3 100644 --- a/Aaru.Decoders/SCSI/Modes/03.cs +++ b/Aaru.Decoders/SCSI/Modes/03.cs @@ -80,17 +80,13 @@ public static partial class Modes public static ModePage_03? DecodeModePage_03(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x03) - return null; + if((pageResponse?[0] & 0x3F) != 0x03) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 24) - return null; + if(pageResponse.Length < 24) return null; var decoded = new ModePage_03(); @@ -117,62 +113,58 @@ public static partial class Modes public static string PrettifyModePage_03(ModePage_03? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_03 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Format_device_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - sb. - AppendFormat("\t" + Localization._0_tracks_per_zone_to_use_in_dividing_the_capacity_for_the_purpose_of_allocating_alternate_sectors, - page.TracksPerZone). - AppendLine(); + sb.AppendFormat("\t" + + Localization + ._0_tracks_per_zone_to_use_in_dividing_the_capacity_for_the_purpose_of_allocating_alternate_sectors, + page.TracksPerZone) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_sectors_per_zone_that_shall_be_reserved_for_defect_handling, - page.AltSectorsPerZone). - AppendLine(); + page.AltSectorsPerZone) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_tracks_per_zone_that_shall_be_reserved_for_defect_handling, - page.AltTracksPerZone). - AppendLine(); + page.AltTracksPerZone) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_tracks_per_LUN_that_shall_be_reserved_for_defect_handling, - page.AltTracksPerLun). - AppendLine(); + page.AltTracksPerLun) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_physical_sectors_per_track, page.SectorsPerTrack).AppendLine(); sb.AppendFormat("\t" + Localization._0_Bytes_per_physical_sector, page.BytesPerSector).AppendLine(); sb.AppendFormat("\t" + Localization.Target_dependent_interleave_value_is_0, page.Interleave).AppendLine(); sb.AppendFormat("\t" + Localization._0_sectors_between_last_block_of_one_track_and_first_block_of_the_next, - page.TrackSkew). - AppendLine(); + page.TrackSkew) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_sectors_between_last_block_of_a_cylinder_and_first_block_of_the_next_one, - page.CylinderSkew). - AppendLine(); + page.CylinderSkew) + .AppendLine(); - if(page.SSEC) - sb.AppendLine("\t" + Localization.Drive_supports_soft_sectoring_format); + if(page.SSEC) sb.AppendLine("\t" + Localization.Drive_supports_soft_sectoring_format); - if(page.HSEC) - sb.AppendLine("\t" + Localization.Drive_supports_hard_sectoring_format); + if(page.HSEC) sb.AppendLine("\t" + Localization.Drive_supports_hard_sectoring_format); - if(page.RMB) - sb.AppendLine("\t" + Localization.Drive_media_is_removable); + if(page.RMB) sb.AppendLine("\t" + Localization.Drive_media_is_removable); sb.AppendLine(page.SURF ? "\t" + - Localization. - Sector_addressing_is_progressively_incremented_in_one_surface_before_going_to_the_next + Localization + .Sector_addressing_is_progressively_incremented_in_one_surface_before_going_to_the_next : "\t" + - Localization. - Sector_addressing_is_progressively_incremented_in_one_cylinder_before_going_to_the_next); + Localization + .Sector_addressing_is_progressively_incremented_in_one_cylinder_before_going_to_the_next); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/04.cs b/Aaru.Decoders/SCSI/Modes/04.cs index 404b307b7..d83cf122f 100644 --- a/Aaru.Decoders/SCSI/Modes/04.cs +++ b/Aaru.Decoders/SCSI/Modes/04.cs @@ -69,17 +69,13 @@ public static partial class Modes public static ModePage_04? DecodeModePage_04(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x04) - return null; + if((pageResponse?[0] & 0x3F) != 0x04) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 20) - return null; + if(pageResponse.Length < 20) return null; var decoded = new ModePage_04(); @@ -96,8 +92,7 @@ public static partial class Modes decoded.RPL = (byte)(pageResponse[17] & 0x03); decoded.RotationalOffset = pageResponse[18]; - if(pageResponse.Length >= 22) - decoded.MediumRotationRate = (ushort)((pageResponse[20] << 8) + pageResponse[21]); + if(pageResponse.Length >= 22) decoded.MediumRotationRate = (ushort)((pageResponse[20] << 8) + pageResponse[21]); return decoded; } @@ -107,30 +102,28 @@ public static partial class Modes public static string PrettifyModePage_04(ModePage_04? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_04 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Rigid_disk_drive_geometry_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization._0_heads, page.Heads).AppendLine(); sb.AppendFormat("\t" + Localization._0_cylinders, page.Cylinders).AppendLine(); if(page.WritePrecompCylinder < page.Cylinders) { - sb.AppendFormat("\t" + Localization.Write_pre_compensation_starts_at_cylinder_0, page.WritePrecompCylinder). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_pre_compensation_starts_at_cylinder_0, page.WritePrecompCylinder) + .AppendLine(); } if(page.WriteReduceCylinder < page.Cylinders) { - sb.AppendFormat("\t" + Localization.Write_current_reduction_starts_at_cylinder_0, page.WriteReduceCylinder). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_current_reduction_starts_at_cylinder_0, page.WriteReduceCylinder) + .AppendLine(); } if(page.DriveStepRate > 0) diff --git a/Aaru.Decoders/SCSI/Modes/05.cs b/Aaru.Decoders/SCSI/Modes/05.cs index 0534a0d80..b45c54501 100644 --- a/Aaru.Decoders/SCSI/Modes/05.cs +++ b/Aaru.Decoders/SCSI/Modes/05.cs @@ -105,17 +105,13 @@ public static partial class Modes public static ModePage_05? DecodeModePage_05(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x05) - return null; + if((pageResponse?[0] & 0x3F) != 0x05) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 32) - return null; + if(pageResponse.Length < 32) return null; var decoded = new ModePage_05(); @@ -153,16 +149,14 @@ public static partial class Modes public static string PrettifyModePage_05(ModePage_05? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_05 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Flexible_disk_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization.Transfer_rate_0_kbits, page.TransferRate).AppendLine(); sb.AppendFormat("\t" + Localization._0_heads, page.Heads).AppendLine(); @@ -172,14 +166,14 @@ public static partial class Modes if(page.WritePrecompCylinder < page.Cylinders) { - sb.AppendFormat("\t" + Localization.Write_pre_compensation_starts_at_cylinder_0, page.WritePrecompCylinder). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_pre_compensation_starts_at_cylinder_0, page.WritePrecompCylinder) + .AppendLine(); } if(page.WriteReduceCylinder < page.Cylinders) { - sb.AppendFormat("\t" + Localization.Write_current_reduction_starts_at_cylinder_0, page.WriteReduceCylinder). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_current_reduction_starts_at_cylinder_0, page.WriteReduceCylinder) + .AppendLine(); } if(page.DriveStepRate > 0) @@ -193,37 +187,37 @@ public static partial class Modes if(!page.TRDY) { - sb. - AppendFormat("\t" + Localization.Target_shall_wait_0_seconds_before_attempting_to_access_the_medium_after_motor_on_is_asserted, - (double)page.MotorOnDelay * 10). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Target_shall_wait_0_seconds_before_attempting_to_access_the_medium_after_motor_on_is_asserted, + (double)page.MotorOnDelay * 10) + .AppendLine(); } else { - sb. - AppendFormat("\t" + Localization.Target_shall_wait_0_seconds_after_drive_is_ready_before_aborting_medium_access_attempts, - (double)page.MotorOnDelay * 10). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Target_shall_wait_0_seconds_after_drive_is_ready_before_aborting_medium_access_attempts, + (double)page.MotorOnDelay * 10) + .AppendLine(); } if(page.MotorOffDelay != 0xFF) { - sb. - AppendFormat("\t" + Localization.Target_shall_wait_0_seconds_before_releasing_the_motor_on_signal_after_becoming_idle, - (double)page.MotorOffDelay * 10). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Target_shall_wait_0_seconds_before_releasing_the_motor_on_signal_after_becoming_idle, + (double)page.MotorOffDelay * 10) + .AppendLine(); } else sb.AppendLine("\t" + Localization.Target_shall_never_release_the_motor_on_signal); - if(page.TRDY) - sb.AppendLine("\t" + Localization.There_is_a_drive_ready_signal); + if(page.TRDY) sb.AppendLine("\t" + Localization.There_is_a_drive_ready_signal); - if(page.SSN) - sb.AppendLine("\t" + Localization.Sectors_start_at_1); + if(page.SSN) sb.AppendLine("\t" + Localization.Sectors_start_at_1); - if(page.MO) - sb.AppendLine("\t" + Localization.The_motor_on_signal_shall_remain_released); + if(page.MO) sb.AppendLine("\t" + Localization.The_motor_on_signal_shall_remain_released); sb.AppendFormat("\t" + Localization.Drive_needs_to_do_0_step_pulses_per_cylinder, page.SPC + 1).AppendLine(); @@ -260,7 +254,10 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + ((page.Pin34 & 0x08) == 0x08 ? Localization.Pin_34_indicates_unknown_function_0_when_active_high : Localization.Pin_34_indicates_unknown_function_0_when_active_low), + sb.AppendFormat("\t" + + ((page.Pin34 & 0x08) == 0x08 + ? Localization.Pin_34_indicates_unknown_function_0_when_active_high + : Localization.Pin_34_indicates_unknown_function_0_when_active_low), page.Pin34 & 0x07); break; @@ -294,7 +291,10 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + ((page.Pin4 & 0x08) == 0x08 ? Localization.Pin_4_indicates_unknown_function_0_when_active_high : Localization.Pin_4_indicates_unknown_function_0_when_active_low), + sb.AppendFormat("\t" + + ((page.Pin4 & 0x08) == 0x08 + ? Localization.Pin_4_indicates_unknown_function_0_when_active_high + : Localization.Pin_4_indicates_unknown_function_0_when_active_low), page.Pin4 & 0x07); break; @@ -307,7 +307,10 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + ((page.Pin2 & 0x08) == 0x08 ? Localization.Pin_2_indicates_unknown_function_0_when_active_high : Localization.Pin_2_indicates_unknown_function_0_when_active_low), + sb.AppendFormat("\t" + + ((page.Pin2 & 0x08) == 0x08 + ? Localization.Pin_2_indicates_unknown_function_0_when_active_high + : Localization.Pin_2_indicates_unknown_function_0_when_active_low), page.Pin2 & 0x07); break; @@ -327,7 +330,10 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + ((page.Pin1 & 0x08) == 0x08 ? Localization.Pin_1_indicates_unknown_function_0_when_active_high : Localization.Pin_1_indicates_unknown_function_0_when_active_low), + sb.AppendFormat("\t" + + ((page.Pin1 & 0x08) == 0x08 + ? Localization.Pin_1_indicates_unknown_function_0_when_active_high + : Localization.Pin_1_indicates_unknown_function_0_when_active_low), page.Pin1 & 0x07); break; diff --git a/Aaru.Decoders/SCSI/Modes/06.cs b/Aaru.Decoders/SCSI/Modes/06.cs index 484db187d..1fa4b4b35 100644 --- a/Aaru.Decoders/SCSI/Modes/06.cs +++ b/Aaru.Decoders/SCSI/Modes/06.cs @@ -53,17 +53,13 @@ public static partial class Modes public static ModePage_06? DecodeModePage_06(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x06) - return null; + if((pageResponse?[0] & 0x3F) != 0x06) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 4) - return null; + if(pageResponse.Length < 4) return null; var decoded = new ModePage_06(); @@ -78,19 +74,16 @@ public static partial class Modes public static string PrettifyModePage_06(ModePage_06? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_06 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_optical_memory); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.RUBR) - sb.AppendLine("\t" + Localization.On_reading_an_updated_block_drive_will_return_RECOVERED_ERROR); + if(page.RUBR) sb.AppendLine("\t" + Localization.On_reading_an_updated_block_drive_will_return_RECOVERED_ERROR); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/07.cs b/Aaru.Decoders/SCSI/Modes/07.cs index 7cc13f2c8..48c781b36 100644 --- a/Aaru.Decoders/SCSI/Modes/07.cs +++ b/Aaru.Decoders/SCSI/Modes/07.cs @@ -66,17 +66,13 @@ public static partial class Modes public static ModePage_07? DecodeModePage_07(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x07) - return null; + if((pageResponse?[0] & 0x3F) != 0x07) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 12) - return null; + if(pageResponse.Length < 12) return null; var decoded = new ModePage_07(); @@ -98,40 +94,34 @@ public static partial class Modes public static string PrettifyModePage_07(ModePage_07? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_07 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Verify_error_recovery_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.EER) - sb.AppendLine("\t" + Localization.Drive_will_use_the_most_expedient_form_of_error_recovery_first); + if(page.EER) sb.AppendLine("\t" + Localization.Drive_will_use_the_most_expedient_form_of_error_recovery_first); - if(page.PER) - sb.AppendLine("\t" + Localization.Drive_shall_report_recovered_errors); + if(page.PER) sb.AppendLine("\t" + Localization.Drive_shall_report_recovered_errors); - if(page.DTE) - sb.AppendLine("\t" + Localization.Transfer_will_be_terminated_upon_error_detection); + if(page.DTE) sb.AppendLine("\t" + Localization.Transfer_will_be_terminated_upon_error_detection); - if(page.DCR) - sb.AppendLine("\t" + Localization.Error_correction_is_disabled); + if(page.DCR) sb.AppendLine("\t" + Localization.Error_correction_is_disabled); if(page.VerifyRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_verify_operations_0_times, page.VerifyRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_verify_operations_0_times, page.VerifyRetryCount) + .AppendLine(); } if(page.RecoveryTimeLimit > 0) { sb.AppendFormat("\t" + Localization.Drive_will_employ_a_maximum_of_0_ms_to_recover_data, - page.RecoveryTimeLimit). - AppendLine(); + page.RecoveryTimeLimit) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/07_MMC.cs b/Aaru.Decoders/SCSI/Modes/07_MMC.cs index 037af1046..5df398b72 100644 --- a/Aaru.Decoders/SCSI/Modes/07_MMC.cs +++ b/Aaru.Decoders/SCSI/Modes/07_MMC.cs @@ -55,17 +55,13 @@ public static partial class Modes public static ModePage_07_MMC? DecodeModePage_07_MMC(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x07) - return null; + if((pageResponse?[0] & 0x3F) != 0x07) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_07_MMC(); @@ -81,21 +77,19 @@ public static partial class Modes public static string PrettifyModePage_07_MMC(ModePage_07_MMC? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_07_MMC page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Verify_error_recovery_page_for_MultiMedia_Devices); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.VerifyRetryCount > 0) { - sb.AppendFormat("\t" + Localization.Drive_will_repeat_verify_operations_0_times, page.VerifyRetryCount). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_repeat_verify_operations_0_times, page.VerifyRetryCount) + .AppendLine(); } string AllUsed = "\t" + Localization.All_available_recovery_procedures_will_be_used + "\n"; diff --git a/Aaru.Decoders/SCSI/Modes/08.cs b/Aaru.Decoders/SCSI/Modes/08.cs index 2346c9d37..041667817 100644 --- a/Aaru.Decoders/SCSI/Modes/08.cs +++ b/Aaru.Decoders/SCSI/Modes/08.cs @@ -94,17 +94,13 @@ public static partial class Modes public static ModePage_08? DecodeModePage_08(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x08) - return null; + if((pageResponse?[0] & 0x3F) != 0x08) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 12) - return null; + if(pageResponse.Length < 12) return null; var decoded = new ModePage_08(); @@ -120,8 +116,7 @@ public static partial class Modes decoded.MaximumPreFetch = (ushort)((pageResponse[8] << 8) + pageResponse[9]); decoded.MaximumPreFetchCeiling = (ushort)((pageResponse[10] << 8) + pageResponse[11]); - if(pageResponse.Length < 20) - return decoded; + if(pageResponse.Length < 20) return decoded; decoded.IC |= (pageResponse[2] & 0x80) == 0x80; decoded.ABPF |= (pageResponse[2] & 0x40) == 0x40; @@ -147,22 +142,18 @@ public static partial class Modes public static string PrettifyModePage_08(ModePage_08? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_08 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Caching_mode_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.RCD) - sb.AppendLine("\t" + Localization.Read_cache_is_enabled); + if(page.RCD) sb.AppendLine("\t" + Localization.Read_cache_is_enabled); - if(page.WCE) - sb.AppendLine("\t" + Localization.Write_cache_is_enabled); + if(page.WCE) sb.AppendLine("\t" + Localization.Write_cache_is_enabled); switch(page.DemandReadRetentionPrio) { @@ -172,20 +163,20 @@ public static partial class Modes break; case 1: sb.AppendLine("\t" + - Localization. - Data_put_by_READ_commands_should_be_evicted_from_cache_sooner_than_data_put_in_read_cache_by_other_means); + Localization + .Data_put_by_READ_commands_should_be_evicted_from_cache_sooner_than_data_put_in_read_cache_by_other_means); break; case 0xF: sb.AppendLine("\t" + - Localization. - Data_put_by_READ_commands_should_not_be_evicted_if_there_is_data_cached_by_other_means_that_can_be_evicted); + Localization + .Data_put_by_READ_commands_should_not_be_evicted_if_there_is_data_cached_by_other_means_that_can_be_evicted); break; default: sb.AppendFormat("\t" + Localization.Unknown_demand_read_retention_priority_value_0, - page.DemandReadRetentionPrio). - AppendLine(); + page.DemandReadRetentionPrio) + .AppendLine(); break; } @@ -198,20 +189,20 @@ public static partial class Modes break; case 1: sb.AppendLine("\t" + - Localization. - Data_put_by_WRITE_commands_should_be_evicted_from_cache_sooner_than_data_put_in_write_cache_by_other_means); + Localization + .Data_put_by_WRITE_commands_should_be_evicted_from_cache_sooner_than_data_put_in_write_cache_by_other_means); break; case 0xF: sb.AppendLine("\t" + - Localization. - Data_put_by_WRITE_commands_should_not_be_evicted_if_there_is_data_cached_by_other_means_that_can_be_evicted); + Localization + .Data_put_by_WRITE_commands_should_not_be_evicted_if_there_is_data_cached_by_other_means_that_can_be_evicted); break; default: sb.AppendFormat("\t" + Localization.Unknown_demand_write_retention_priority_value_0, - page.DemandReadRetentionPrio). - AppendLine(); + page.DemandReadRetentionPrio) + .AppendLine(); break; } @@ -220,56 +211,54 @@ public static partial class Modes sb.AppendLine("\t" + Localization.Read_ahead_is_disabled); else { - if(page.MF) - sb.AppendLine("\t" + Localization.Pre_fetch_values_indicate_a_block_multiplier); + if(page.MF) sb.AppendLine("\t" + Localization.Pre_fetch_values_indicate_a_block_multiplier); if(page.DisablePreFetch == 0) sb.AppendLine("\t" + Localization.No_pre_fetch_will_be_done); else { sb.AppendFormat("\t" + Localization.Pre_fetch_will_be_done_for_READ_commands_of_0_blocks_or_less, - page.DisablePreFetch). - AppendLine(); + page.DisablePreFetch) + .AppendLine(); if(page.MinimumPreFetch > 0) { - sb.AppendFormat(Localization.At_least_0_blocks_will_be_always_pre_fetched, page.MinimumPreFetch). - AppendLine(); + sb.AppendFormat(Localization.At_least_0_blocks_will_be_always_pre_fetched, page.MinimumPreFetch) + .AppendLine(); } if(page.MaximumPreFetch > 0) { - sb.AppendFormat("\t" + Localization.A_maximum_of_0_blocks_will_be_pre_fetched, - page.MaximumPreFetch). - AppendLine(); + sb.AppendFormat("\t" + Localization.A_maximum_of_0_blocks_will_be_pre_fetched, page.MaximumPreFetch) + .AppendLine(); } if(page.MaximumPreFetchCeiling > 0) { - sb. - AppendFormat("\t" + Localization.A_maximum_of_0_blocks_will_be_pre_fetched_even_if_it_is_commanded_to_pre_fetch_more, - page.MaximumPreFetchCeiling). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .A_maximum_of_0_blocks_will_be_pre_fetched_even_if_it_is_commanded_to_pre_fetch_more, + page.MaximumPreFetchCeiling) + .AppendLine(); } if(page.IC) { sb.AppendLine("\t" + - Localization. - Device_should_use_number_of_cache_segments_or_cache_segment_size_for_caching); + Localization + .Device_should_use_number_of_cache_segments_or_cache_segment_size_for_caching); } if(page.ABPF) sb.AppendLine("\t" + Localization.Pre_fetch_should_be_aborted_upon_receiving_a_new_command); - if(page.CAP) - sb.AppendLine("\t" + Localization.Caching_analysis_is_permitted); + if(page.CAP) sb.AppendLine("\t" + Localization.Caching_analysis_is_permitted); if(page.Disc) { sb.AppendLine("\t" + - Localization. - Pre_fetch_can_continue_across_discontinuities_such_as_cylinders_or_tracks); + Localization + .Pre_fetch_can_continue_across_discontinuities_such_as_cylinders_or_tracks); } } } @@ -284,14 +273,14 @@ public static partial class Modes if(page.LBCSS) { sb.AppendFormat("\t" + Localization.Drive_cache_segments_should_be_0_blocks_long, - page.CacheSegmentSize). - AppendLine(); + page.CacheSegmentSize) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.Drive_cache_segments_should_be_0_bytes_long, - page.CacheSegmentSize). - AppendLine(); + page.CacheSegmentSize) + .AppendLine(); } } } @@ -299,21 +288,21 @@ public static partial class Modes { if(page.CacheSegments > 0) { - sb.AppendFormat("\t" + Localization.Drive_should_have_0_cache_segments, page.CacheSegments). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_should_have_0_cache_segments, page.CacheSegments) + .AppendLine(); } } if(page.NonCacheSegmentSize > 0) { - sb. - AppendFormat("\t" + Localization.Drive_shall_allocate_0_bytes_to_buffer_even_when_all_cached_data_cannot_be_evicted, - page.NonCacheSegmentSize). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Drive_shall_allocate_0_bytes_to_buffer_even_when_all_cached_data_cannot_be_evicted, + page.NonCacheSegmentSize) + .AppendLine(); } - if(page.NV_DIS) - sb.AppendLine("\t" + Localization.Non_Volatile_cache_is_disabled); + if(page.NV_DIS) sb.AppendLine("\t" + Localization.Non_Volatile_cache_is_disabled); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/0A.cs b/Aaru.Decoders/SCSI/Modes/0A.cs index 2dd71587e..4a6af2c84 100644 --- a/Aaru.Decoders/SCSI/Modes/0A.cs +++ b/Aaru.Decoders/SCSI/Modes/0A.cs @@ -113,17 +113,13 @@ public static partial class Modes public static ModePage_0A? DecodeModePage_0A(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x0A) - return null; + if((pageResponse?[0] & 0x3F) != 0x0A) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_0A(); @@ -141,8 +137,7 @@ public static partial class Modes decoded.ReadyAENHoldOffPeriod = (ushort)((pageResponse[6] << 8) + pageResponse[7]); - if(pageResponse.Length < 10) - return decoded; + if(pageResponse.Length < 10) return decoded; // SPC-1 decoded.GLTSD |= (pageResponse[2] & 0x02) == 0x02; @@ -179,38 +174,33 @@ public static partial class Modes public static string PrettifyModePage_0A(ModePage_0A? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0A page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Control_mode_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.RLEC) - sb.AppendLine("\t" + Localization.If_set_target_shall_report_log_exception_conditions); + if(page.RLEC) sb.AppendLine("\t" + Localization.If_set_target_shall_report_log_exception_conditions); - if(page.DQue) - sb.AppendLine("\t" + Localization.Tagged_queuing_is_disabled); + if(page.DQue) sb.AppendLine("\t" + Localization.Tagged_queuing_is_disabled); - if(page.EECA) - sb.AppendLine("\t" + Localization.Extended_Contingent_Allegiance_is_enabled); + if(page.EECA) sb.AppendLine("\t" + Localization.Extended_Contingent_Allegiance_is_enabled); if(page.RAENP) { sb.AppendLine("\t" + - Localization. - Target_may_issue_an_asynchronous_event_notification_upon_completing_its_initialization); + Localization + .Target_may_issue_an_asynchronous_event_notification_upon_completing_its_initialization); } if(page.UAAENP) { sb.AppendLine("\t" + - Localization. - Target_may_issue_an_asynchronous_event_notification_instead_of_a_unit_attention_condition); + Localization + .Target_may_issue_an_asynchronous_event_notification_instead_of_a_unit_attention_condition); } if(page.EAENP) @@ -219,53 +209,45 @@ public static partial class Modes Localization.Target_may_issue_an_asynchronous_event_notification_instead_of_a_deferred_error); } - if(page.GLTSD) - sb.AppendLine("\t" + Localization.Global_logging_target_save_disabled); + if(page.GLTSD) sb.AppendLine("\t" + Localization.Global_logging_target_save_disabled); if(page.RAC) sb.AppendLine("\t" + Localization.CHECK_CONDITION_should_be_reported_rather_than_a_long_busy_condition); - if(page.SWP) - sb.AppendLine("\t" + Localization.Software_write_protect_is_enabled); + if(page.SWP) sb.AppendLine("\t" + Localization.Software_write_protect_is_enabled); if(page.TAS) { sb.AppendLine("\t" + - Localization. - Tasks_aborted_by_other_initiator_s_actions_should_be_terminated_with_TASK_ABORTED); + Localization + .Tasks_aborted_by_other_initiator_s_actions_should_be_terminated_with_TASK_ABORTED); } if(page.TMF_ONLY) { sb.AppendLine("\t" + - Localization. - All_tasks_received_in_nexus_with_ACA_ACTIVE_is_set_and_an_ACA_condition_is_established_shall_terminate); + Localization + .All_tasks_received_in_nexus_with_ACA_ACTIVE_is_set_and_an_ACA_condition_is_established_shall_terminate); } if(page.D_SENSE) { sb.AppendLine("\t" + - Localization. - Device_shall_return_descriptor_format_sense_data_when_returning_sense_data_in_the_same_transactions_as_a_CHECK_CONDITION); + Localization + .Device_shall_return_descriptor_format_sense_data_when_returning_sense_data_in_the_same_transactions_as_a_CHECK_CONDITION); } - if(page.ATO) - sb.AppendLine("\t" + Localization.LOGICAL_BLOCK_APPLICATION_TAG_should_not_be_modified); + if(page.ATO) sb.AppendLine("\t" + Localization.LOGICAL_BLOCK_APPLICATION_TAG_should_not_be_modified); - if(page.DPICZ) - sb.AppendLine("\t" + Localization.Protector_information_checking_is_disabled); + if(page.DPICZ) sb.AppendLine("\t" + Localization.Protector_information_checking_is_disabled); - if(page.NUAR) - sb.AppendLine("\t" + Localization.No_unit_attention_on_release); + if(page.NUAR) sb.AppendLine("\t" + Localization.No_unit_attention_on_release); - if(page.ATMPE) - sb.AppendLine("\t" + Localization.Application_Tag_mode_page_is_enabled); + if(page.ATMPE) sb.AppendLine("\t" + Localization.Application_Tag_mode_page_is_enabled); - if(page.RWWP) - sb.AppendLine("\t" + Localization.Abort_any_write_command_without_protection_information); + if(page.RWWP) sb.AppendLine("\t" + Localization.Abort_any_write_command_without_protection_information); - if(page.SBLP) - sb.AppendLine("\t" + Localization.Supports_block_lengths_and_protection_information); + if(page.SBLP) sb.AppendLine("\t" + Localization.Supports_block_lengths_and_protection_information); switch(page.TST) { @@ -294,8 +276,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_Queue_Algorithm_Modifier_0, page.QueueAlgorithm). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_Queue_Algorithm_Modifier_0, page.QueueAlgorithm) + .AppendLine(); break; } @@ -304,20 +286,20 @@ public static partial class Modes { case 0: sb.AppendLine("\t" + - Localization. - If_ACA_is_established_the_task_set_commands_shall_resume_after_it_is_cleared_otherwise_they_shall_terminate_with_CHECK_CONDITION); + Localization + .If_ACA_is_established_the_task_set_commands_shall_resume_after_it_is_cleared_otherwise_they_shall_terminate_with_CHECK_CONDITION); break; case 1: sb.AppendLine("\t" + - Localization. - All_the_affected_commands_in_the_task_set_shall_be_aborted_when_CHECK_CONDITION_is_returned); + Localization + .All_the_affected_commands_in_the_task_set_shall_be_aborted_when_CHECK_CONDITION_is_returned); break; case 3: sb.AppendLine("\t" + - Localization. - Affected_commands_in_the_task_set_belonging_with_the_CHECK_CONDITION_nexus_shall_be_aborted); + Localization + .Affected_commands_in_the_task_set_belonging_with_the_CHECK_CONDITION_nexus_shall_be_aborted); break; default: @@ -339,8 +321,8 @@ public static partial class Modes break; case 3: sb.AppendLine("\t" + - Localization. - LUN_shall_not_clear_unit_attention_condition_reported_in_the_same_nexus_and_shall_establish_a_unit_attention_condition_for_the_initiator); + Localization + .LUN_shall_not_clear_unit_attention_condition_reported_in_the_same_nexus_and_shall_establish_a_unit_attention_condition_for_the_initiator); break; default: @@ -372,10 +354,10 @@ public static partial class Modes if(page.ReadyAENHoldOffPeriod > 0) { - sb. - AppendFormat("\t" + Localization._0_ms_before_attempting_asynchronous_event_notifications_after_initialization, - page.ReadyAENHoldOffPeriod). - AppendLine(); + sb.AppendFormat("\t" + + Localization._0_ms_before_attempting_asynchronous_event_notifications_after_initialization, + page.ReadyAENHoldOffPeriod) + .AppendLine(); } if(page.BusyTimeoutPeriod > 0) @@ -385,8 +367,8 @@ public static partial class Modes else { sb.AppendFormat("\t" + Localization.A_maximum_of_0_ms_are_allowed_to_remain_busy, - page.BusyTimeoutPeriod * 100). - AppendLine(); + page.BusyTimeoutPeriod * 100) + .AppendLine(); } } @@ -425,20 +407,15 @@ public static partial class Modes public static ModePage_0A_S01? DecodeModePage_0A_S01(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) != 0x40) - return null; + if((pageResponse?[0] & 0x40) != 0x40) return null; - if((pageResponse[0] & 0x3F) != 0x0A) - return null; + if((pageResponse[0] & 0x3F) != 0x0A) return null; - if(pageResponse[1] != 0x01) - return null; + if(pageResponse[1] != 0x01) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 32) - return null; + if(pageResponse.Length < 32) return null; var decoded = new ModePage_0A_S01(); @@ -458,24 +435,22 @@ public static partial class Modes public static string PrettifyModePage_0A_S01(ModePage_0A_S01? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0A_S01 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Control_extension_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.TCMOS) { if(page.SCSIP) { sb.AppendLine("\t" + - Localization. - S01_Timestamp_can_be_initialized_by_methods_outside_of_the_SCSI_standards_but_SCSI_SET_TIMESTAMP_shall_take_precedence_over_them); + Localization + .S01_Timestamp_can_be_initialized_by_methods_outside_of_the_SCSI_standards_but_SCSI_SET_TIMESTAMP_shall_take_precedence_over_them); } else { @@ -484,18 +459,16 @@ public static partial class Modes } } - if(page.IALUAE) - sb.AppendLine("\t" + Localization.Implicit_Asymmetric_Logical_Unit_Access_is_enabled); + if(page.IALUAE) sb.AppendLine("\t" + Localization.Implicit_Asymmetric_Logical_Unit_Access_is_enabled); sb.AppendFormat("\t" + Localization.Initial_priority_is_0, page.InitialPriority).AppendLine(); - if(page.DLC) - sb.AppendLine("\t" + Localization.Device_will_not_degrade_performance_to_extend_its_life); + if(page.DLC) sb.AppendLine("\t" + Localization.Device_will_not_degrade_performance_to_extend_its_life); if(page.MaximumSenseLength > 0) { - sb.AppendFormat("\t" + Localization.Maximum_sense_data_would_be_0_bytes, page.MaximumSenseLength). - AppendLine(); + sb.AppendFormat("\t" + Localization.Maximum_sense_data_would_be_0_bytes, page.MaximumSenseLength) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/0B.cs b/Aaru.Decoders/SCSI/Modes/0B.cs index 7ede70217..a0b7bb2c0 100644 --- a/Aaru.Decoders/SCSI/Modes/0B.cs +++ b/Aaru.Decoders/SCSI/Modes/0B.cs @@ -55,17 +55,13 @@ public static partial class Modes public static ModePage_0B? DecodeModePage_0B(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x0B) - return null; + if((pageResponse?[0] & 0x3F) != 0x0B) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_0B(); @@ -83,39 +79,37 @@ public static partial class Modes public static string PrettifyModePage_0B(ModePage_0B? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0B page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Medium_types_supported_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.MediumType1 != MediumTypes.Default) { - sb.AppendFormat(Localization.Supported_medium_type_one_0, GetMediumTypeDescription(page.MediumType1)). - AppendLine(); + sb.AppendFormat(Localization.Supported_medium_type_one_0, GetMediumTypeDescription(page.MediumType1)) + .AppendLine(); } if(page.MediumType2 != MediumTypes.Default) { - sb.AppendFormat(Localization.Supported_medium_type_two_0, GetMediumTypeDescription(page.MediumType2)). - AppendLine(); + sb.AppendFormat(Localization.Supported_medium_type_two_0, GetMediumTypeDescription(page.MediumType2)) + .AppendLine(); } if(page.MediumType3 != MediumTypes.Default) { - sb.AppendFormat(Localization.Supported_medium_type_three_0, GetMediumTypeDescription(page.MediumType3)). - AppendLine(); + sb.AppendFormat(Localization.Supported_medium_type_three_0, GetMediumTypeDescription(page.MediumType3)) + .AppendLine(); } if(page.MediumType4 != MediumTypes.Default) { - sb.AppendFormat(Localization.Supported_medium_type_four_0, GetMediumTypeDescription(page.MediumType4)). - AppendLine(); + sb.AppendFormat(Localization.Supported_medium_type_four_0, GetMediumTypeDescription(page.MediumType4)) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/0D.cs b/Aaru.Decoders/SCSI/Modes/0D.cs index e1dd5b0bf..0ac63a727 100644 --- a/Aaru.Decoders/SCSI/Modes/0D.cs +++ b/Aaru.Decoders/SCSI/Modes/0D.cs @@ -57,17 +57,13 @@ public static partial class Modes public static ModePage_0D? DecodeModePage_0D(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x0D) - return null; + if((pageResponse?[0] & 0x3F) != 0x0D) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_0D(); @@ -84,23 +80,21 @@ public static partial class Modes public static string PrettifyModePage_0D(ModePage_0D? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0D page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_CD_ROM_parameters_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.InactivityTimerMultiplier) { case 0: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_track_hold_state_a_vendor_specified_time_after_a_seek_or_read); + Localization + .Drive_will_remain_in_track_hold_state_a_vendor_specified_time_after_a_seek_or_read); break; case 1: diff --git a/Aaru.Decoders/SCSI/Modes/0E.cs b/Aaru.Decoders/SCSI/Modes/0E.cs index 4fcd0835e..690da83bf 100644 --- a/Aaru.Decoders/SCSI/Modes/0E.cs +++ b/Aaru.Decoders/SCSI/Modes/0E.cs @@ -77,17 +77,13 @@ public static partial class Modes public static ModePage_0E? DecodeModePage_0E(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x0E) - return null; + if((pageResponse?[0] & 0x3F) != 0x0E) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_0E(); @@ -114,23 +110,20 @@ public static partial class Modes public static string PrettifyModePage_0E(ModePage_0E? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0E page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_CD_ROM_audio_control_parameters_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendLine(page.Immed ? "\t" + Localization.Drive_will_return_from_playback_command_immediately : "\t" + Localization.Drive_will_return_from_playback_command_when_playback_ends); - if(page.SOTC) - sb.AppendLine("\t" + Localization.Drive_will_stop_playback_on_track_end); + if(page.SOTC) sb.AppendLine("\t" + Localization.Drive_will_stop_playback_on_track_end); if(page.APRVal) { @@ -148,17 +141,13 @@ public static partial class Modes { sb.Append("\t" + Localization.Output_port_0_has_channels); - if((page.OutputPort0ChannelSelection & 0x01) == 0x01) - sb.Append("0 "); + if((page.OutputPort0ChannelSelection & 0x01) == 0x01) sb.Append("0 "); - if((page.OutputPort0ChannelSelection & 0x02) == 0x02) - sb.Append("1 "); + if((page.OutputPort0ChannelSelection & 0x02) == 0x02) sb.Append("1 "); - if((page.OutputPort0ChannelSelection & 0x04) == 0x04) - sb.Append("2 "); + if((page.OutputPort0ChannelSelection & 0x04) == 0x04) sb.Append("2 "); - if((page.OutputPort0ChannelSelection & 0x08) == 0x08) - sb.Append("3 "); + if((page.OutputPort0ChannelSelection & 0x08) == 0x08) sb.Append("3 "); switch(page.OutputPort0Volume) { @@ -181,17 +170,13 @@ public static partial class Modes { sb.Append("\t" + Localization.Output_port_1_has_channels); - if((page.OutputPort1ChannelSelection & 0x01) == 0x01) - sb.Append("0 "); + if((page.OutputPort1ChannelSelection & 0x01) == 0x01) sb.Append("0 "); - if((page.OutputPort1ChannelSelection & 0x02) == 0x02) - sb.Append("1 "); + if((page.OutputPort1ChannelSelection & 0x02) == 0x02) sb.Append("1 "); - if((page.OutputPort1ChannelSelection & 0x04) == 0x04) - sb.Append("2 "); + if((page.OutputPort1ChannelSelection & 0x04) == 0x04) sb.Append("2 "); - if((page.OutputPort1ChannelSelection & 0x08) == 0x08) - sb.Append("3 "); + if((page.OutputPort1ChannelSelection & 0x08) == 0x08) sb.Append("3 "); switch(page.OutputPort1Volume) { @@ -214,17 +199,13 @@ public static partial class Modes { sb.Append("\t" + Localization.Output_port_2_has_channels); - if((page.OutputPort2ChannelSelection & 0x01) == 0x01) - sb.Append("0 "); + if((page.OutputPort2ChannelSelection & 0x01) == 0x01) sb.Append("0 "); - if((page.OutputPort2ChannelSelection & 0x02) == 0x02) - sb.Append("1 "); + if((page.OutputPort2ChannelSelection & 0x02) == 0x02) sb.Append("1 "); - if((page.OutputPort2ChannelSelection & 0x04) == 0x04) - sb.Append("2 "); + if((page.OutputPort2ChannelSelection & 0x04) == 0x04) sb.Append("2 "); - if((page.OutputPort2ChannelSelection & 0x08) == 0x08) - sb.Append("3 "); + if((page.OutputPort2ChannelSelection & 0x08) == 0x08) sb.Append("3 "); switch(page.OutputPort2Volume) { @@ -243,22 +224,17 @@ public static partial class Modes } } - if(page.OutputPort3ChannelSelection <= 0) - return sb.ToString(); + if(page.OutputPort3ChannelSelection <= 0) return sb.ToString(); sb.Append("\t" + Localization.Output_port_3_has_channels); - if((page.OutputPort3ChannelSelection & 0x01) == 0x01) - sb.Append("0 "); + if((page.OutputPort3ChannelSelection & 0x01) == 0x01) sb.Append("0 "); - if((page.OutputPort3ChannelSelection & 0x02) == 0x02) - sb.Append("1 "); + if((page.OutputPort3ChannelSelection & 0x02) == 0x02) sb.Append("1 "); - if((page.OutputPort3ChannelSelection & 0x04) == 0x04) - sb.Append("2 "); + if((page.OutputPort3ChannelSelection & 0x04) == 0x04) sb.Append("2 "); - if((page.OutputPort3ChannelSelection & 0x08) == 0x08) - sb.Append("3 "); + if((page.OutputPort3ChannelSelection & 0x08) == 0x08) sb.Append("3 "); switch(page.OutputPort3Volume) { diff --git a/Aaru.Decoders/SCSI/Modes/0F.cs b/Aaru.Decoders/SCSI/Modes/0F.cs index 20d8cabe9..ba9c1d029 100644 --- a/Aaru.Decoders/SCSI/Modes/0F.cs +++ b/Aaru.Decoders/SCSI/Modes/0F.cs @@ -63,17 +63,13 @@ public static partial class Modes public static ModePage_0F? DecodeModePage_0F(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x0F) - return null; + if((pageResponse?[0] & 0x3F) != 0x0F) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_0F(); @@ -100,16 +96,14 @@ public static partial class Modes public static string PrettifyModePage_0F(ModePage_0F? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_0F page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Data_compression_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.DCC) { @@ -189,8 +183,8 @@ public static partial class Modes break; default: - sb.AppendFormat(Localization.an_unknown_algorithm_coded_0, page.CompressionAlgo). - AppendLine(); + sb.AppendFormat(Localization.an_unknown_algorithm_coded_0, page.CompressionAlgo) + .AppendLine(); break; } diff --git a/Aaru.Decoders/SCSI/Modes/10.cs b/Aaru.Decoders/SCSI/Modes/10.cs index 64f1a1268..26da74e7d 100644 --- a/Aaru.Decoders/SCSI/Modes/10.cs +++ b/Aaru.Decoders/SCSI/Modes/10.cs @@ -61,17 +61,13 @@ public static partial class Modes public static ModePage_10? DecodeModePage_10(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x10) - return null; + if((pageResponse?[0] & 0x3F) != 0x10) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 24) - return null; + if(pageResponse.Length < 24) return null; var decoded = new ModePage_10(); @@ -102,16 +98,14 @@ public static partial class Modes public static string PrettifyModePage_10(ModePage_10? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_10 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_XOR_control_mode_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.XORDIS) sb.AppendLine("\t" + Localization.XOR_operations_are_disabled); @@ -120,30 +114,30 @@ public static partial class Modes if(page.MaxXorWrite > 0) { sb.AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_single_XOR_WRITE_command, - page.MaxXorWrite). - AppendLine(); + page.MaxXorWrite) + .AppendLine(); } if(page.MaxRegenSize > 0) { sb.AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_REGENERATE_command, - page.MaxRegenSize). - AppendLine(); + page.MaxRegenSize) + .AppendLine(); } if(page.MaxRebuildRead > 0) { - sb. - AppendFormat("\t" + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_READ_command_during_rebuild, - page.MaxRebuildRead). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Drive_accepts_a_maximum_of_0_blocks_in_a_READ_command_during_rebuild, + page.MaxRebuildRead) + .AppendLine(); } if(page.RebuildDelay > 0) { sb.AppendFormat("\t" + Localization.Drive_needs_a_minimum_of_0_ms_between_READ_commands_during_rebuild, - page.RebuildDelay). - AppendLine(); + page.RebuildDelay) + .AppendLine(); } } diff --git a/Aaru.Decoders/SCSI/Modes/10_SSC.cs b/Aaru.Decoders/SCSI/Modes/10_SSC.cs index 8e6c60877..5e4554031 100644 --- a/Aaru.Decoders/SCSI/Modes/10_SSC.cs +++ b/Aaru.Decoders/SCSI/Modes/10_SSC.cs @@ -110,17 +110,13 @@ public static partial class Modes public static ModePage_10_SSC? DecodeModePage_10_SSC(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x10) - return null; + if((pageResponse?[0] & 0x3F) != 0x10) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_10_SSC(); @@ -167,33 +163,32 @@ public static partial class Modes public static string PrettifyModePage_10_SSC(ModePage_10_SSC? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_10_SSC page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Device_configuration_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization.Active_format_0, page.ActiveFormat).AppendLine(); sb.AppendFormat("\t" + Localization.Active_partition_0, page.ActivePartition).AppendLine(); sb.AppendFormat("\t" + Localization.Write_buffer_shall_have_a_full_ratio_of_0_before_being_flushed_to_medium, - page.WriteBufferFullRatio). - AppendLine(); + page.WriteBufferFullRatio) + .AppendLine(); - sb. - AppendFormat("\t" + Localization.Read_buffer_shall_have_an_empty_ratio_of_0_before_more_data_is_read_from_medium, - page.ReadBufferEmptyRatio). - AppendLine(); + sb.AppendFormat("\t" + + Localization.Read_buffer_shall_have_an_empty_ratio_of_0_before_more_data_is_read_from_medium, + page.ReadBufferEmptyRatio) + .AppendLine(); - sb. - AppendFormat("\t" + Localization.Drive_will_delay_0_ms_before_buffered_data_is_forcefully_written_to_the_medium_even_before_buffer_is_full, - page.WriteDelayTime * 100). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Drive_will_delay_0_ms_before_buffered_data_is_forcefully_written_to_the_medium_even_before_buffer_is_full, + page.WriteDelayTime * 100) + .AppendLine(); if(page.DBR) { @@ -204,11 +199,9 @@ public static partial class Modes : "\t" + Localization.Recovered_buffer_data_comes_in_FIFO_order); } - if(page.BIS) - sb.AppendLine("\t" + Localization.Medium_supports_block_IDs); + if(page.BIS) sb.AppendLine("\t" + Localization.Medium_supports_block_IDs); - if(page.RSmk) - sb.AppendLine("\t" + Localization.Drive_reports_setmarks); + if(page.RSmk) sb.AppendLine("\t" + Localization.Drive_reports_setmarks); switch(page.SOCF) { @@ -234,8 +227,7 @@ public static partial class Modes { sb.AppendLine("\t" + Localization.Drive_reports_early_warnings); - if(page.SEW) - sb.AppendLine("\t" + Localization.Drive_will_synchronize_buffer_to_medium_on_early_warnings); + if(page.SEW) sb.AppendLine("\t" + Localization.Drive_will_synchronize_buffer_to_medium_on_early_warnings); } switch(page.GapSize) @@ -261,8 +253,8 @@ public static partial class Modes case 14: case 15: sb.AppendFormat("\t" + Localization.Inter_block_gap_is_0_times_the_device_defined_gap_size, - page.GapSize). - AppendLine(); + page.GapSize) + .AppendLine(); break; default: @@ -271,8 +263,7 @@ public static partial class Modes break; } - if(page.EEG) - sb.AppendLine("\t" + Localization.Drive_generates_end_of_data); + if(page.EEG) sb.AppendLine("\t" + Localization.Drive_generates_end_of_data); switch(page.SelectedCompression) { @@ -285,23 +276,19 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Drive_uses_unknown_compression_0, page.SelectedCompression). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_uses_unknown_compression_0, page.SelectedCompression) + .AppendLine(); break; } - if(page.SWP) - sb.AppendLine("\t" + Localization.Software_write_protect_is_enabled); + if(page.SWP) sb.AppendLine("\t" + Localization.Software_write_protect_is_enabled); - if(page.ASOCWP) - sb.AppendLine("\t" + Localization.Associated_write_protect_is_enabled); + if(page.ASOCWP) sb.AppendLine("\t" + Localization.Associated_write_protect_is_enabled); - if(page.PERSWP) - sb.AppendLine("\t" + Localization.Persistent_write_protect_is_enabled); + if(page.PERSWP) sb.AppendLine("\t" + Localization.Persistent_write_protect_is_enabled); - if(page.PRMWP) - sb.AppendLine("\t" + Localization.Permanent_write_protect_is_enabled); + if(page.PRMWP) sb.AppendLine("\t" + Localization.Permanent_write_protect_is_enabled); if(page.BAML) { diff --git a/Aaru.Decoders/SCSI/Modes/11.cs b/Aaru.Decoders/SCSI/Modes/11.cs index 7d1e73a2c..f06d12720 100644 --- a/Aaru.Decoders/SCSI/Modes/11.cs +++ b/Aaru.Decoders/SCSI/Modes/11.cs @@ -96,17 +96,13 @@ public static partial class Modes public static ModePage_11? DecodeModePage_11(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x11) - return null; + if((pageResponse?[0] & 0x3F) != 0x11) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_11(); @@ -139,25 +135,22 @@ public static partial class Modes public static string PrettifyModePage_11(ModePage_11? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_11 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_medium_partition_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - sb.AppendFormat("\t" + Localization._0_maximum_additional_partitions, page.MaxAdditionalPartitions). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_maximum_additional_partitions, page.MaxAdditionalPartitions) + .AppendLine(); - sb.AppendFormat("\t" + Localization._0_additional_partitions_defined, page.AdditionalPartitionsDefined). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_additional_partitions_defined, page.AdditionalPartitionsDefined) + .AppendLine(); - if(page.FDP) - sb.AppendLine("\t" + Localization.Partitions_are_fixed_under_device_definitions); + if(page.FDP) sb.AppendLine("\t" + Localization.Partitions_are_fixed_under_device_definitions); if(page.SDP) { @@ -165,14 +158,13 @@ public static partial class Modes Localization.Number_of_partitions_can_be_defined_but_their_size_is_defined_by_the_device); } - if(page.IDP) - sb.AppendLine("\t" + Localization.Number_and_size_of_partitions_can_be_manually_defined); + if(page.IDP) sb.AppendLine("\t" + Localization.Number_and_size_of_partitions_can_be_manually_defined); if(page.POFM) { sb.AppendLine("\t" + - Localization. - Partition_parameters_will_not_be_applied_until_a_FORMAT_MEDIUM_command_is_received); + Localization + .Partition_parameters_will_not_be_applied_until_a_FORMAT_MEDIUM_command_is_received); } switch(page.CLEAR) @@ -192,8 +184,8 @@ public static partial class Modes break; default: sb.AppendLine("\t" + - Localization. - Device_shall_erase_all_partitions_differing_on_size_on_MODE_SELECT_for_partitioning); + Localization + .Device_shall_erase_all_partitions_differing_on_size_on_MODE_SELECT_for_partitioning); break; } @@ -219,8 +211,8 @@ public static partial class Modes break; case PartitionSizeUnitOfMeasures.Exponential: sb.AppendFormat("\t" + Localization.Partitions_are_defined_in_units_of_0_bytes, - Math.Pow(10, page.PartitionUnits)). - AppendLine(); + Math.Pow(10, page.PartitionUnits)) + .AppendLine(); measure = string.Format(Localization.units_of_0_bytes, Math.Pow(10, page.PartitionUnits)); @@ -253,8 +245,8 @@ public static partial class Modes break; default: sb.AppendFormat("\t" + Localization.Unknown_medium_recognition_code_0, - (byte)page.MediumFormatRecognition). - AppendLine(); + (byte)page.MediumFormatRecognition) + .AppendLine(); break; } @@ -272,8 +264,8 @@ public static partial class Modes } else { - sb.AppendFormat("\t" + Localization.Partition_0_is_1_2_long, i, page.PartitionSizes[i], measure). - AppendLine(); + sb.AppendFormat("\t" + Localization.Partition_0_is_1_2_long, i, page.PartitionSizes[i], measure) + .AppendLine(); } } diff --git a/Aaru.Decoders/SCSI/Modes/12_13_14.cs b/Aaru.Decoders/SCSI/Modes/12_13_14.cs index b982121e2..406f77981 100644 --- a/Aaru.Decoders/SCSI/Modes/12_13_14.cs +++ b/Aaru.Decoders/SCSI/Modes/12_13_14.cs @@ -53,20 +53,16 @@ public static partial class Modes public static ModePage_12_13_14? DecodeModePage_12_13_14(byte[] pageResponse) { - if(pageResponse == null) - return null; + if(pageResponse == null) return null; - if((pageResponse[0] & 0x40) == 0x40) - return null; + if((pageResponse[0] & 0x40) == 0x40) return null; if((pageResponse[0] & 0x3F) != 0x12 && (pageResponse[0] & 0x3F) != 0x13 && (pageResponse[0] & 0x3F) != 0x14) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 2) - return null; + if(pageResponse.Length < 2) return null; var decoded = new ModePage_12_13_14(); @@ -88,16 +84,14 @@ public static partial class Modes public static string PrettifyModePage_12_13_14(ModePage_12_13_14? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_12_13_14 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_medium_partition_page_extra); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization.Medium_has_defined_0_partitions, page.PartitionSizes.Length).AppendLine(); diff --git a/Aaru.Decoders/SCSI/Modes/1A.cs b/Aaru.Decoders/SCSI/Modes/1A.cs index 6f636b320..b428f5bd2 100644 --- a/Aaru.Decoders/SCSI/Modes/1A.cs +++ b/Aaru.Decoders/SCSI/Modes/1A.cs @@ -77,17 +77,13 @@ public static partial class Modes public static ModePage_1A? DecodeModePage_1A(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x1A) - return null; + if((pageResponse?[0] & 0x3F) != 0x1A) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 12) - return null; + if(pageResponse.Length < 12) return null; var decoded = new ModePage_1A(); @@ -106,8 +102,7 @@ public static partial class Modes (pageResponse[10] << 8) + pageResponse[11]); - if(pageResponse.Length < 40) - return decoded; + if(pageResponse.Length < 40) return decoded; decoded.PM_BG_Precedence = (byte)((pageResponse[2] & 0xC0) >> 6); decoded.Standby_Y |= (pageResponse[2] & 0x01) == 0x01; @@ -141,16 +136,14 @@ public static partial class Modes public static string PrettifyModePage_1A(ModePage_1A? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1A page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine("SCSI Power condition page:"); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page is { Standby: true, StandbyTimer: > 0 } or { Standby_Y: true, StandbyTimer_Y: > 0 }) { @@ -163,7 +156,9 @@ public static partial class Modes else sb.AppendLine("\t" + "Drive will not enter standby mode"); - if(page is { Idle: true, IdleTimer: > 0 } or { Idle_B: true, IdleTimer_B: > 0 } or { Idle_C: true, IdleTimer_C: > 0 }) + if(page is { Idle : true, IdleTimer : > 0 } + or { Idle_B: true, IdleTimer_B: > 0 } + or { Idle_C: true, IdleTimer_C: > 0 }) { if(page is { Idle: true, IdleTimer: > 0 }) sb.AppendFormat("\t" + "Idle timer A is set to {0} ms", page.IdleTimer * 100).AppendLine(); @@ -213,20 +208,15 @@ public static partial class Modes public static ModePage_1A_S01? DecodeModePage_1A_S01(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) != 0x40) - return null; + if((pageResponse?[0] & 0x40) != 0x40) return null; - if((pageResponse[0] & 0x3F) != 0x1A) - return null; + if((pageResponse[0] & 0x3F) != 0x1A) return null; - if(pageResponse[1] != 0x01) - return null; + if(pageResponse[1] != 0x01) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_1A_S01(); @@ -242,24 +232,23 @@ public static partial class Modes public static string PrettifyModePage_1A_S01(ModePage_1A_S01? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1A_S01 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Power_Consumption_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.ActiveLevel) { case 0: - sb. - AppendFormat("\t" + Localization.Device_power_consumption_is_dictated_by_identifier_0_of_Power_Consumption_VPD, - page.PowerConsumptionIdentifier). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_power_consumption_is_dictated_by_identifier_0_of_Power_Consumption_VPD, + page.PowerConsumptionIdentifier) + .AppendLine(); break; case 1: diff --git a/Aaru.Decoders/SCSI/Modes/1B.cs b/Aaru.Decoders/SCSI/Modes/1B.cs index 439249a6a..f2d41a3e6 100644 --- a/Aaru.Decoders/SCSI/Modes/1B.cs +++ b/Aaru.Decoders/SCSI/Modes/1B.cs @@ -61,17 +61,13 @@ public static partial class Modes public static ModePage_1B? DecodeModePage_1B(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x1B) - return null; + if((pageResponse?[0] & 0x3F) != 0x1B) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 12) - return null; + if(pageResponse.Length < 12) return null; var decoded = new ModePage_1B(); @@ -91,31 +87,24 @@ public static partial class Modes public static string PrettifyModePage_1B(ModePage_1B? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1B page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Removable_Block_Access_Capabilities_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.SFLP) - sb.AppendLine("\t" + Localization.Drive_can_be_used_as_a_system_floppy_device); + if(page.SFLP) sb.AppendLine("\t" + Localization.Drive_can_be_used_as_a_system_floppy_device); - if(page.SRFP) - sb.AppendLine("\t" + Localization.Drive_supports_reporting_progress_of_format); + if(page.SRFP) sb.AppendLine("\t" + Localization.Drive_supports_reporting_progress_of_format); - if(page.NCD) - sb.AppendLine("\t" + Localization.Drive_is_a_Non_CD_Optical_Device); + if(page.NCD) sb.AppendLine("\t" + Localization.Drive_is_a_Non_CD_Optical_Device); - if(page.SML) - sb.AppendLine("\t" + Localization.Device_is_a_dual_device_supporting_CD_and_Non_CD_Optical); + if(page.SML) sb.AppendLine("\t" + Localization.Device_is_a_dual_device_supporting_CD_and_Non_CD_Optical); - if(page.TLUN > 0) - sb.AppendFormat("\t" + Localization.Drive_supports_0_LUNs, page.TLUN).AppendLine(); + if(page.TLUN > 0) sb.AppendFormat("\t" + Localization.Drive_supports_0_LUNs, page.TLUN).AppendLine(); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/1C.cs b/Aaru.Decoders/SCSI/Modes/1C.cs index c60ea35e7..f6e5c274e 100644 --- a/Aaru.Decoders/SCSI/Modes/1C.cs +++ b/Aaru.Decoders/SCSI/Modes/1C.cs @@ -73,17 +73,13 @@ public static partial class Modes public static ModePage_1C? DecodeModePage_1C(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x1C) - return null; + if((pageResponse?[0] & 0x3F) != 0x1C) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_1C(); @@ -120,16 +116,14 @@ public static partial class Modes public static string PrettifyModePage_1C(ModePage_1C? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1C page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Informational_exceptions_control_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.DExcpt) sb.AppendLine("\t" + Localization.Informational_exceptions_are_disabled); @@ -181,11 +175,9 @@ public static partial class Modes Localization.Informational_exceptions_reporting_should_not_affect_drive_performance); } - if(page.Test) - sb.AppendLine("\t" + Localization.A_test_informational_exception_will_raise_on_next_timer); + if(page.Test) sb.AppendLine("\t" + Localization.A_test_informational_exception_will_raise_on_next_timer); - if(page.LogErr) - sb.AppendLine("\t" + Localization.Drive_shall_log_informational_exception_conditions); + if(page.LogErr) sb.AppendLine("\t" + Localization.Drive_shall_log_informational_exception_conditions); if(page.IntervalTimer > 0) { @@ -197,19 +189,17 @@ public static partial class Modes if(page.ReportCount > 0) { - sb.AppendFormat("\t" + Localization.Informational_exception_conditions_will_be_reported_a_maximum_of_0_times, + sb.AppendFormat("\t" + + Localization.Informational_exception_conditions_will_be_reported_a_maximum_of_0_times, page.ReportCount); } } - if(page.EWasc) - sb.AppendLine("\t" + Localization.Warning_reporting_is_enabled); + if(page.EWasc) sb.AppendLine("\t" + Localization.Warning_reporting_is_enabled); - if(page.EBF) - sb.AppendLine("\t" + Localization.Background_functions_are_enabled); + if(page.EBF) sb.AppendLine("\t" + Localization.Background_functions_are_enabled); - if(page.EBACKERR) - sb.AppendLine("\t" + Localization.Drive_will_report_background_self_test_errors); + if(page.EBACKERR) sb.AppendLine("\t" + Localization.Drive_will_report_background_self_test_errors); return sb.ToString(); } @@ -243,20 +233,15 @@ public static partial class Modes public static ModePage_1C_S01? DecodeModePage_1C_S01(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) != 0x40) - return null; + if((pageResponse?[0] & 0x40) != 0x40) return null; - if((pageResponse[0] & 0x3F) != 0x1C) - return null; + if((pageResponse[0] & 0x3F) != 0x1C) return null; - if(pageResponse[1] != 0x01) - return null; + if(pageResponse[1] != 0x01) return null; - if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) - return null; + if((pageResponse[2] << 8) + pageResponse[3] + 4 != pageResponse.Length) return null; - if(pageResponse.Length < 16) - return null; + if(pageResponse.Length < 16) return null; var decoded = new ModePage_1C_S01(); @@ -280,58 +265,56 @@ public static partial class Modes public static string PrettifyModePage_1C_S01(ModePage_1C_S01? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1C_S01 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Background_Control_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.S_L_Full) - sb.AppendLine("\t" + Localization.Background_scans_will_be_halted_if_log_is_full); + if(page.S_L_Full) sb.AppendLine("\t" + Localization.Background_scans_will_be_halted_if_log_is_full); if(page.LOWIR) sb.AppendLine("\t" + Localization.Background_scans_will_only_be_logged_if_they_require_intervention); - if(page.En_Bms) - sb.AppendLine("\t" + Localization.Background_medium_scans_are_enabled); + if(page.En_Bms) sb.AppendLine("\t" + Localization.Background_medium_scans_are_enabled); - if(page.En_Ps) - sb.AppendLine("\t" + Localization.Background_pre_scans_are_enabled); + if(page.En_Ps) sb.AppendLine("\t" + Localization.Background_pre_scans_are_enabled); if(page.BackgroundScanInterval > 0) { - sb. - AppendFormat("\t" + Localization._0__hours_shall_be_between_the_start_of_a_background_scan_operation_and_the_next, - page.BackgroundScanInterval). - AppendLine(); + sb.AppendFormat("\t" + + Localization + ._0__hours_shall_be_between_the_start_of_a_background_scan_operation_and_the_next, + page.BackgroundScanInterval) + .AppendLine(); } if(page.BackgroundPrescanTimeLimit > 0) { sb.AppendFormat("\t" + Localization.Background_pre_scan_operations_can_take_a_maximum_of_0_hours, - page.BackgroundPrescanTimeLimit). - AppendLine(); + page.BackgroundPrescanTimeLimit) + .AppendLine(); } if(page.MinIdleBeforeBgScan > 0) { - sb. - AppendFormat("\t" + Localization.At_least_0_ms_must_be_idle_before_resuming_a_suspended_background_scan_operation, - page.MinIdleBeforeBgScan). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .At_least_0_ms_must_be_idle_before_resuming_a_suspended_background_scan_operation, + page.MinIdleBeforeBgScan) + .AppendLine(); } if(page.MaxTimeSuspendBgScan > 0) { - sb. - AppendFormat("\t" + Localization.At_most_0_ms_must_be_before_suspending_a_background_scan_operation_and_processing_received_commands, - page.MaxTimeSuspendBgScan). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .At_most_0_ms_must_be_before_suspending_a_background_scan_operation_and_processing_received_commands, + page.MaxTimeSuspendBgScan) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/1C_SFF.cs b/Aaru.Decoders/SCSI/Modes/1C_SFF.cs index 71b202850..40e87ef6d 100644 --- a/Aaru.Decoders/SCSI/Modes/1C_SFF.cs +++ b/Aaru.Decoders/SCSI/Modes/1C_SFF.cs @@ -57,17 +57,13 @@ public static partial class Modes public static ModePage_1C_SFF? DecodeModePage_1C_SFF(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x1C) - return null; + if((pageResponse?[0] & 0x3F) != 0x1C) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; var decoded = new ModePage_1C_SFF(); @@ -85,119 +81,115 @@ public static partial class Modes public static string PrettifyModePage_1C_SFF(ModePage_1C_SFF? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1C_SFF page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Timer_Protect_page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.DISP) - sb.AppendLine("\t" + Localization.Drive_is_disabled_until_power_is_cycled); + if(page.DISP) sb.AppendLine("\t" + Localization.Drive_is_disabled_until_power_is_cycled); - if(page.SWPP) - sb.AppendLine("\t" + Localization.Drive_is_software_write_protected_until_powered_down); + if(page.SWPP) sb.AppendLine("\t" + Localization.Drive_is_software_write_protected_until_powered_down); switch(page.InactivityTimeMultiplier) { case 0: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_a_vendor_specified_time_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_a_vendor_specified_time_after_a_seek_read_or_write_operation); break; case 1: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_125_ms_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_125_ms_after_a_seek_read_or_write_operation); break; case 2: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_250_ms_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_250_ms_after_a_seek_read_or_write_operation); break; case 3: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_500_ms_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_500_ms_after_a_seek_read_or_write_operation); break; case 4: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_1_second_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_1_second_after_a_seek_read_or_write_operation); break; case 5: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_2_seconds_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_2_seconds_after_a_seek_read_or_write_operation); break; case 6: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_4_seconds_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_4_seconds_after_a_seek_read_or_write_operation); break; case 7: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_8_seconds_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_8_seconds_after_a_seek_read_or_write_operation); break; case 8: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_16_seconds_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_16_seconds_after_a_seek_read_or_write_operation); break; case 9: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_32_seconds_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_32_seconds_after_a_seek_read_or_write_operation); break; case 10: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_1_minute_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_1_minute_after_a_seek_read_or_write_operation); break; case 11: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_2_minutes_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_2_minutes_after_a_seek_read_or_write_operation); break; case 12: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_4_minutes_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_4_minutes_after_a_seek_read_or_write_operation); break; case 13: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_8_minutes_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_8_minutes_after_a_seek_read_or_write_operation); break; case 14: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_16_minutes_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_16_minutes_after_a_seek_read_or_write_operation); break; case 15: sb.AppendLine("\t" + - Localization. - Drive_will_remain_in_same_status_32_minutes_after_a_seek_read_or_write_operation); + Localization + .Drive_will_remain_in_same_status_32_minutes_after_a_seek_read_or_write_operation); break; } diff --git a/Aaru.Decoders/SCSI/Modes/1D.cs b/Aaru.Decoders/SCSI/Modes/1D.cs index a66c1be32..9b83180bd 100644 --- a/Aaru.Decoders/SCSI/Modes/1D.cs +++ b/Aaru.Decoders/SCSI/Modes/1D.cs @@ -53,17 +53,13 @@ public static partial class Modes public static ModePage_1D? DecodeModePage_1D(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x1D) - return null; + if((pageResponse?[0] & 0x3F) != 0x1D) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 32) - return null; + if(pageResponse.Length < 32) return null; var decoded = new ModePage_1D(); @@ -80,19 +76,16 @@ public static partial class Modes public static string PrettifyModePage_1D(ModePage_1D? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; ModePage_1D page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_Medium_Configuration_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.WORMM) - sb.AppendLine("\t" + Localization.Drive_is_operating_in_WORM_mode); + if(page.WORMM) sb.AppendLine("\t" + Localization.Drive_is_operating_in_WORM_mode); switch(page.WormModeLabelRestrictions) { @@ -110,8 +103,8 @@ public static partial class Modes break; default: sb.AppendFormat("\t" + Localization.Unknown_WORM_mode_label_restrictions_code_0, - page.WormModeLabelRestrictions). - AppendLine(); + page.WormModeLabelRestrictions) + .AppendLine(); break; } @@ -130,8 +123,8 @@ public static partial class Modes break; default: sb.AppendFormat("\t" + "Unknown WORM mode filemark restrictions code {0}", - page.WormModeLabelRestrictions). - AppendLine(); + page.WormModeLabelRestrictions) + .AppendLine(); break; } diff --git a/Aaru.Decoders/SCSI/Modes/21_Certance.cs b/Aaru.Decoders/SCSI/Modes/21_Certance.cs index 36a689ba6..c7e5156e8 100644 --- a/Aaru.Decoders/SCSI/Modes/21_Certance.cs +++ b/Aaru.Decoders/SCSI/Modes/21_Certance.cs @@ -58,17 +58,13 @@ public static partial class Modes public static Certance_ModePage_21? DecodeCertanceModePage_21(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x21) - return null; + if((pageResponse?[0] & 0x3F) != 0x21) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 9) - return null; + if(pageResponse.Length != 9) return null; var decoded = new Certance_ModePage_21(); @@ -90,16 +86,14 @@ public static partial class Modes public static string PrettifyCertanceModePage_21(Certance_ModePage_21? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Certance_ModePage_21 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Certance_Drive_Capabilities_Control_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.OperatingSystemsSupport) { @@ -109,8 +103,8 @@ public static partial class Modes break; default: sb.AppendFormat("\t" + Localization.Operating_systems_support_is_unknown_code_0, - page.OperatingSystemsSupport). - AppendLine(); + page.OperatingSystemsSupport) + .AppendLine(); break; } @@ -132,8 +126,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_factory_test_code_0, page.FirmwareTestControl). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_factory_test_code_0, page.FirmwareTestControl) + .AppendLine(); break; } @@ -150,8 +144,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_Power_On_Self_Test_code_0, page.ExtendedPOSTMode). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_Power_On_Self_Test_code_0, page.ExtendedPOSTMode) + .AppendLine(); break; } @@ -171,18 +165,17 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_compression_control_code_0, page.DataCompressionControl). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_compression_control_code_0, page.DataCompressionControl) + .AppendLine(); break; } - if(page.HostUnloadOverride) - sb.AppendLine("\t" + Localization.SCSI_UNLOAD_command_will_not_eject_the_cartridge); + if(page.HostUnloadOverride) sb.AppendLine("\t" + Localization.SCSI_UNLOAD_command_will_not_eject_the_cartridge); sb.Append("\t" + - Localization. - How_should_tapes_be_unloaded_in_a_power_cycle_tape_incompatibility_firmware_download_or_cleaning_end); + Localization + .How_should_tapes_be_unloaded_in_a_power_cycle_tape_incompatibility_firmware_download_or_cleaning_end); switch(page.AutoUnloadMode) { diff --git a/Aaru.Decoders/SCSI/Modes/22_Certance.cs b/Aaru.Decoders/SCSI/Modes/22_Certance.cs index 23c01fad6..c593784b3 100644 --- a/Aaru.Decoders/SCSI/Modes/22_Certance.cs +++ b/Aaru.Decoders/SCSI/Modes/22_Certance.cs @@ -63,17 +63,13 @@ public static partial class Modes public static Certance_ModePage_22? DecodeCertanceModePage_22(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x22) - return null; + if((pageResponse?[0] & 0x3F) != 0x22) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 16) - return null; + if(pageResponse.Length != 16) return null; var decoded = new Certance_ModePage_22(); @@ -98,16 +94,14 @@ public static partial class Modes public static string PrettifyCertanceModePage_22(Certance_ModePage_22? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Certance_ModePage_22 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Certance_Interface_Control_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.BaudRate) { @@ -134,8 +128,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_library_interface_baud_rate_code_0, page.BaudRate). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_library_interface_baud_rate_code_0, page.BaudRate) + .AppendLine(); break; } @@ -171,8 +165,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_port_A_transport_type_code_0, page.PortATransportType). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_port_A_transport_type_code_0, page.PortATransportType) + .AppendLine(); break; } @@ -180,8 +174,8 @@ public static partial class Modes if(page.PortATransportType > 0) sb.AppendFormat("\t" + Localization.Drive_responds_to_SCSI_ID_0, page.PortAPresentSelectionID).AppendLine(); - sb.AppendFormat("\t" + Localization.Drive_will_respond_to_SCSI_ID_0_on_Port_A_enabling, page.NextSelectionID). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_will_respond_to_SCSI_ID_0_on_Port_A_enabling, page.NextSelectionID) + .AppendLine(); sb.AppendFormat("\t" + Localization.Drive_jumpers_choose_SCSI_ID_0, page.JumperedSelectionID).AppendLine(); diff --git a/Aaru.Decoders/SCSI/Modes/24_IBM.cs b/Aaru.Decoders/SCSI/Modes/24_IBM.cs index dbd03f777..fbe0cbe44 100644 --- a/Aaru.Decoders/SCSI/Modes/24_IBM.cs +++ b/Aaru.Decoders/SCSI/Modes/24_IBM.cs @@ -54,17 +54,13 @@ public static partial class Modes public static IBM_ModePage_24? DecodeIBMModePage_24(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x24) - return null; + if((pageResponse?[0] & 0x3F) != 0x24) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 8) - return null; + if(pageResponse.Length != 8) return null; var decoded = new IBM_ModePage_24(); @@ -82,27 +78,23 @@ public static partial class Modes public static string PrettifyIBMModePage_24(IBM_ModePage_24? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; IBM_ModePage_24 page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.IBM_Vendor_Specific_Control_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization.Vendor_specific_mode_control_0, page.ModeControl); sb.AppendFormat("\t" + Localization.Vendor_specific_velocity_setting_0, page.VelocitySetting); - if(!page.EncryptionCapable) - return sb.ToString(); + if(!page.EncryptionCapable) return sb.ToString(); sb.AppendLine("\t" + Localization.Drive_supports_encryption); - if(page.EncryptionEnabled) - sb.AppendLine("\t" + Localization.Drive_has_encryption_enabled); + if(page.EncryptionEnabled) sb.AppendLine("\t" + Localization.Drive_has_encryption_enabled); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/2A.cs b/Aaru.Decoders/SCSI/Modes/2A.cs index 90612a17e..872464333 100644 --- a/Aaru.Decoders/SCSI/Modes/2A.cs +++ b/Aaru.Decoders/SCSI/Modes/2A.cs @@ -50,33 +50,25 @@ public static partial class Modes public static string PrettifyModePage_2A(ModePage_2A modePage) { - if(modePage is null) - return null; + if(modePage is null) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.SCSI_CD_ROM_capabilities_page); - if(modePage.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(modePage.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(modePage.AudioPlay) - sb.AppendLine("\t" + Localization.Drive_can_play_audio); + if(modePage.AudioPlay) sb.AppendLine("\t" + Localization.Drive_can_play_audio); - if(modePage.Mode2Form1) - sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_1_format); + if(modePage.Mode2Form1) sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_1_format); - if(modePage.Mode2Form2) - sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_2_format); + if(modePage.Mode2Form2) sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_2_format); - if(modePage.MultiSession) - sb.AppendLine("\t" + Localization.Drive_supports_multi_session_discs_and_or_Photo_CD); + if(modePage.MultiSession) sb.AppendLine("\t" + Localization.Drive_supports_multi_session_discs_and_or_Photo_CD); - if(modePage.CDDACommand) - sb.AppendLine("\t" + Localization.Drive_can_read_digital_audio); + if(modePage.CDDACommand) sb.AppendLine("\t" + Localization.Drive_can_read_digital_audio); - if(modePage.AccurateCDDA) - sb.AppendLine("\t" + Localization.Drive_can_continue_from_streaming_loss); + if(modePage.AccurateCDDA) sb.AppendLine("\t" + Localization.Drive_can_continue_from_streaming_loss); if(modePage.Subchannel) sb.AppendLine("\t" + Localization.Drive_can_read_uncorrected_and_interleaved_R_W_subchannels); @@ -84,14 +76,11 @@ public static partial class Modes if(modePage.DeinterlaveSubchannel) sb.AppendLine("\t" + Localization.Drive_can_read__deinterleave_and_correct_R_W_subchannels); - if(modePage.C2Pointer) - sb.AppendLine("\t" + Localization.Drive_supports_C2_pointers); + if(modePage.C2Pointer) sb.AppendLine("\t" + Localization.Drive_supports_C2_pointers); - if(modePage.UPC) - sb.AppendLine("\t" + Localization.Drive_can_read_Media_Catalogue_Number); + if(modePage.UPC) sb.AppendLine("\t" + Localization.Drive_can_read_Media_Catalogue_Number); - if(modePage.ISRC) - sb.AppendLine("\t" + Localization.Drive_can_read_ISRC); + if(modePage.ISRC) sb.AppendLine("\t" + Localization.Drive_can_read_ISRC); switch(modePage.LoadingMechanism) { @@ -117,14 +106,13 @@ public static partial class Modes break; default: sb.AppendFormat("\t" + Localization.Drive_uses_unknown_loading_mechanism_type__0_, - modePage.LoadingMechanism). - AppendLine(); + modePage.LoadingMechanism) + .AppendLine(); break; } - if(modePage.Lock) - sb.AppendLine("\t" + Localization.Drive_can_lock_media); + if(modePage.Lock) sb.AppendLine("\t" + Localization.Drive_can_lock_media); if(modePage.PreventJumper) { @@ -142,19 +130,17 @@ public static partial class Modes : "\t" + Localization.Drive_is_not_locked__media_can_be_ejected_and_inserted); } - if(modePage.Eject) - sb.AppendLine("\t" + Localization.Drive_can_eject_media); + if(modePage.Eject) sb.AppendLine("\t" + Localization.Drive_can_eject_media); - if(modePage.SeparateChannelMute) - sb.AppendLine("\t" + Localization.Each_channel_can_be_muted_independently); + if(modePage.SeparateChannelMute) sb.AppendLine("\t" + Localization.Each_channel_can_be_muted_independently); if(modePage.SeparateChannelVolume) sb.AppendLine("\t" + Localization.Each_channel_s_volume_can_be_controlled_independently); if(modePage.SupportedVolumeLevels > 0) { - sb.AppendFormat("\t" + Localization.Drive_supports_0_volume_levels, modePage.SupportedVolumeLevels). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_supports_0_volume_levels, modePage.SupportedVolumeLevels) + .AppendLine(); } if(modePage.BufferSize > 0) @@ -162,14 +148,14 @@ public static partial class Modes if(modePage.MaximumSpeed > 0) { - sb.AppendFormat("\t" + Localization.Drive_maximum_reading_speed_is_0_Kbyte_sec, modePage.MaximumSpeed). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_maximum_reading_speed_is_0_Kbyte_sec, modePage.MaximumSpeed) + .AppendLine(); } if(modePage.CurrentSpeed > 0) { - sb.AppendFormat("\t" + Localization.Drive_current_reading_speed_is_0_Kbyte_sec, modePage.CurrentSpeed). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_current_reading_speed_is_0_Kbyte_sec, modePage.CurrentSpeed) + .AppendLine(); } if(modePage.ReadCDR) @@ -178,8 +164,7 @@ public static partial class Modes ? "\t" + Localization.Drive_can_read_and_write_CD_R : "\t" + Localization.Drive_can_read_CD_R); - if(modePage.Method2) - sb.AppendLine("\t" + Localization.Drive_supports_reading_CD_R_packet_media); + if(modePage.Method2) sb.AppendLine("\t" + Localization.Drive_supports_reading_CD_R_packet_media); } if(modePage.ReadCDRW) @@ -189,8 +174,7 @@ public static partial class Modes : "\t" + Localization.Drive_can_read_CD_RW); } - if(modePage.ReadDVDROM) - sb.AppendLine("\t" + Localization.Drive_can_read_DVD_ROM); + if(modePage.ReadDVDROM) sb.AppendLine("\t" + Localization.Drive_can_read_DVD_ROM); if(modePage.ReadDVDR) { @@ -209,11 +193,9 @@ public static partial class Modes if(modePage.Composite) sb.AppendLine("\t" + Localization.Drive_can_deliver_a_composite_audio_and_video_data_stream); - if(modePage.DigitalPort1) - sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_1); + if(modePage.DigitalPort1) sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_1); - if(modePage.DigitalPort2) - sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_2); + if(modePage.DigitalPort2) sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_2); if(modePage.SDP) sb.AppendLine("\t" + Localization.Drive_contains_a_changer_that_can_report_the_exact_contents_of_the_slots); @@ -224,14 +206,14 @@ public static partial class Modes { case 0: sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec_in_CLV_mode, - modePage.CurrentWriteSpeedSelected). - AppendLine(); + modePage.CurrentWriteSpeedSelected) + .AppendLine(); break; case 1: sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec_in_pure_CAV_mode, - modePage.CurrentWriteSpeedSelected). - AppendLine(); + modePage.CurrentWriteSpeedSelected) + .AppendLine(); break; } @@ -240,58 +222,52 @@ public static partial class Modes { if(modePage.MaxWriteSpeed > 0) { - sb.AppendFormat("\t" + Localization.Drive_maximum_writing_speed_is_0_Kbyte_sec, modePage.MaxWriteSpeed). - AppendLine(); + sb.AppendFormat("\t" + Localization.Drive_maximum_writing_speed_is_0_Kbyte_sec, modePage.MaxWriteSpeed) + .AppendLine(); } if(modePage.CurrentWriteSpeed > 0) { sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec, - modePage.CurrentWriteSpeed). - AppendLine(); + modePage.CurrentWriteSpeed) + .AppendLine(); } } if(modePage.WriteSpeedPerformanceDescriptors != null) { foreach(ModePage_2A_WriteDescriptor descriptor in - modePage.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0)) + modePage.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0)) { switch(descriptor.RotationControl) { case 0: sb.AppendFormat("\t" + Localization.Drive_supports_writing_at_0_Kbyte_sec_in_CLV_mode, - descriptor.WriteSpeed). - AppendLine(); + descriptor.WriteSpeed) + .AppendLine(); break; case 1: sb.AppendFormat("\t" + Localization.Drive_supports_writing_at_is_0_Kbyte_sec_in_pure_CAV_mode, - descriptor.WriteSpeed). - AppendLine(); + descriptor.WriteSpeed) + .AppendLine(); break; } } } - if(modePage.TestWrite) - sb.AppendLine("\t" + Localization.Drive_supports_test_writing); + if(modePage.TestWrite) sb.AppendLine("\t" + Localization.Drive_supports_test_writing); - if(modePage.ReadBarcode) - sb.AppendLine("\t" + Localization.Drive_can_read_barcode); + if(modePage.ReadBarcode) sb.AppendLine("\t" + Localization.Drive_can_read_barcode); - if(modePage.SCC) - sb.AppendLine("\t" + Localization.Drive_can_read_both_sides_of_a_disc); + if(modePage.SCC) sb.AppendLine("\t" + Localization.Drive_can_read_both_sides_of_a_disc); - if(modePage.LeadInPW) - sb.AppendLine("\t" + Localization.Drive_an_read_raw_R_W_subchannel_from_the_Lead_In); + if(modePage.LeadInPW) sb.AppendLine("\t" + Localization.Drive_an_read_raw_R_W_subchannel_from_the_Lead_In); - if(modePage.CMRSupported == 1) - sb.AppendLine("\t" + Localization.Drive_supports_DVD_CSS_and_or_DVD_CPPM); + if(modePage.CMRSupported == 1) sb.AppendLine("\t" + Localization.Drive_supports_DVD_CSS_and_or_DVD_CPPM); - if(modePage.BUF) - sb.AppendLine("\t" + Localization.Drive_supports_buffer_under_run_free_recording); + if(modePage.BUF) sb.AppendLine("\t" + Localization.Drive_supports_buffer_under_run_free_recording); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/2F_IBM.cs b/Aaru.Decoders/SCSI/Modes/2F_IBM.cs index 5e5762159..e9f1821c1 100644 --- a/Aaru.Decoders/SCSI/Modes/2F_IBM.cs +++ b/Aaru.Decoders/SCSI/Modes/2F_IBM.cs @@ -62,17 +62,13 @@ public static partial class Modes public static IBM_ModePage_2F? DecodeIBMModePage_2F(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x2F) - return null; + if((pageResponse?[0] & 0x3F) != 0x2F) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length < 8) - return null; + if(pageResponse.Length < 8) return null; return new IBM_ModePage_2F { @@ -95,16 +91,14 @@ public static partial class Modes public static string PrettifyIBMModePage_2F(IBM_ModePage_2F? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; IBM_ModePage_2F page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.IBM_Behaviour_Configuration_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.FenceBehaviour) { @@ -133,8 +127,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_cleaning_behaviour_code_0, page.CleanBehaviour). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_cleaning_behaviour_code_0, page.CleanBehaviour) + .AppendLine(); break; } @@ -166,17 +160,15 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_sense_data_behaviour_code_0, page.WORMEmulation). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_sense_data_behaviour_code_0, page.WORMEmulation) + .AppendLine(); break; } - if(page.CLNCHK) - sb.AppendLine("\t" + Localization.Drive_will_set_Check_Condition_when_cleaning_is_needed); + if(page.CLNCHK) sb.AppendLine("\t" + Localization.Drive_will_set_Check_Condition_when_cleaning_is_needed); - if(page.DDEOR) - sb.AppendLine("\t" + Localization.No_deferred_error_will_be_reported_to_a_rewind_command); + if(page.DDEOR) sb.AppendLine("\t" + Localization.No_deferred_error_will_be_reported_to_a_rewind_command); if(page.CCDM) sb.AppendLine("\t" + Localization.Drive_will_set_Check_Condition_when_the_criteria_for_Dead_Media_is_met); @@ -184,14 +176,11 @@ public static partial class Modes if(page.FirmwareUpdateBehaviour > 0) sb.AppendLine("\t" + Localization.Drive_will_not_accept_downlevel_firmware_via_an_FMR_tape); - if(page.UOE_C == 1) - sb.AppendLine("\t" + Localization.Drive_will_eject_cleaning_cartridges_on_error); + if(page.UOE_C == 1) sb.AppendLine("\t" + Localization.Drive_will_eject_cleaning_cartridges_on_error); - if(page.UOE_F == 1) - sb.AppendLine("\t" + Localization.Drive_will_eject_firmware_cartridges_on_error); + if(page.UOE_F == 1) sb.AppendLine("\t" + Localization.Drive_will_eject_firmware_cartridges_on_error); - if(page.UOE_D == 1) - sb.AppendLine("\t" + Localization.Drive_will_eject_data_cartridges_on_error); + if(page.UOE_D == 1) sb.AppendLine("\t" + Localization.Drive_will_eject_data_cartridges_on_error); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/30_Apple.cs b/Aaru.Decoders/SCSI/Modes/30_Apple.cs index 5e2fd786c..4a4f6dfd2 100644 --- a/Aaru.Decoders/SCSI/Modes/30_Apple.cs +++ b/Aaru.Decoders/SCSI/Modes/30_Apple.cs @@ -47,17 +47,13 @@ public static partial class Modes public static bool IsAppleModePage_30(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return false; + if((pageResponse?[0] & 0x40) == 0x40) return false; - if((pageResponse?[0] & 0x3F) != 0x30) - return false; + if((pageResponse?[0] & 0x3F) != 0x30) return false; - if(pageResponse[1] + 2 != pageResponse.Length) - return false; + if(pageResponse[1] + 2 != pageResponse.Length) return false; - if(pageResponse.Length != 30) - return false; + if(pageResponse.Length != 30) return false; var str = new byte[20]; Array.Copy(pageResponse, 10, str, 0, 20); diff --git a/Aaru.Decoders/SCSI/Modes/3B_HP.cs b/Aaru.Decoders/SCSI/Modes/3B_HP.cs index 4e4bee5b9..bebeae534 100644 --- a/Aaru.Decoders/SCSI/Modes/3B_HP.cs +++ b/Aaru.Decoders/SCSI/Modes/3B_HP.cs @@ -54,17 +54,13 @@ public static partial class Modes public static HP_ModePage_3B? DecodeHPModePage_3B(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3B) - return null; + if((pageResponse?[0] & 0x3F) != 0x3B) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 16) - return null; + if(pageResponse.Length != 16) return null; var decoded = new HP_ModePage_3B(); @@ -81,16 +77,14 @@ public static partial class Modes public static string PrettifyHPModePage_3B(HP_ModePage_3B? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; HP_ModePage_3B page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.HP_Serial_Number_Override_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.MSN) { diff --git a/Aaru.Decoders/SCSI/Modes/3C_HP.cs b/Aaru.Decoders/SCSI/Modes/3C_HP.cs index 58a0f3097..7d96bf27f 100644 --- a/Aaru.Decoders/SCSI/Modes/3C_HP.cs +++ b/Aaru.Decoders/SCSI/Modes/3C_HP.cs @@ -64,17 +64,13 @@ public static partial class Modes public static HP_ModePage_3C? DecodeHPModePage_3C(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3C) - return null; + if((pageResponse?[0] & 0x3F) != 0x3C) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 36) - return null; + if(pageResponse.Length != 36) return null; var decoded = new HP_ModePage_3C(); @@ -114,49 +110,49 @@ public static partial class Modes public static string PrettifyHPModePage_3C(HP_ModePage_3C? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; HP_ModePage_3C page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.HP_Device_Time_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); if(page.PT) { sb.AppendFormat("\t" + Localization.Drive_has_been_powered_up_0_times, page.CurrentPowerOn); sb.AppendFormat("\t" + Localization.Drive_has_been_powered_up_since_0_seconds_ago_this_time, - TimeSpan.FromSeconds(page.PowerOnTime)). - AppendLine(); + TimeSpan.FromSeconds(page.PowerOnTime)) + .AppendLine(); sb.AppendFormat("\t" + Localization.Drive_has_been_powered_up_a_total_of_0_seconds, - TimeSpan.FromSeconds(page.CumulativePowerOn)). - AppendLine(); + TimeSpan.FromSeconds(page.CumulativePowerOn)) + .AppendLine(); } if(page.WT) { sb.AppendFormat("\t" + Localization.Drive_date_time_is_0, - DateHandlers.UnixUnsignedToDateTime(page.WorldTime)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(page.WorldTime)) + .AppendLine(); - if(page.UTC) - sb.AppendLine("\t" + Localization.Drive_time_is_UTC); + if(page.UTC) sb.AppendLine("\t" + Localization.Drive_time_is_UTC); - if(page.NTP) - sb.AppendLine("\t" + Localization.Drive_time_is_synchronized_with_a_NTP_source); + if(page.NTP) sb.AppendLine("\t" + Localization.Drive_time_is_synchronized_with_a_NTP_source); } if(page.LT) { sb.AppendFormat("\t" + Localization.Library_time_is_0, - new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, page.LibraryHours, - page.LibraryMinutes, page.LibrarySeconds)). - AppendLine(); + new DateTime(DateTime.Now.Year, + DateTime.Now.Month, + DateTime.Now.Day, + page.LibraryHours, + page.LibraryMinutes, + page.LibrarySeconds)) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/3D_HP.cs b/Aaru.Decoders/SCSI/Modes/3D_HP.cs index c76eca088..8d8277281 100644 --- a/Aaru.Decoders/SCSI/Modes/3D_HP.cs +++ b/Aaru.Decoders/SCSI/Modes/3D_HP.cs @@ -51,17 +51,13 @@ public static partial class Modes public static HP_ModePage_3D? DecodeHPModePage_3D(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3D) - return null; + if((pageResponse?[0] & 0x3F) != 0x3D) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 4) - return null; + if(pageResponse.Length != 4) return null; var decoded = new HP_ModePage_3D(); @@ -76,16 +72,14 @@ public static partial class Modes public static string PrettifyHPModePage_3D(HP_ModePage_3D? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; HP_ModePage_3D page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.HP_Extended_Reset_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); switch(page.ResetBehaviour) { diff --git a/Aaru.Decoders/SCSI/Modes/3D_IBM.cs b/Aaru.Decoders/SCSI/Modes/3D_IBM.cs index ee25c8d1d..8fdd04678 100644 --- a/Aaru.Decoders/SCSI/Modes/3D_IBM.cs +++ b/Aaru.Decoders/SCSI/Modes/3D_IBM.cs @@ -51,17 +51,13 @@ public static partial class Modes public static IBM_ModePage_3D? DecodeIBMModePage_3D(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3D) - return null; + if((pageResponse?[0] & 0x3F) != 0x3D) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 5) - return null; + if(pageResponse.Length != 5) return null; var decoded = new IBM_ModePage_3D(); @@ -76,16 +72,14 @@ public static partial class Modes public static string PrettifyIBMModePage_3D(IBM_ModePage_3D? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; IBM_ModePage_3D page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.IBM_LEOT_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendFormat("\t" + Localization._0_wraps, page.NumberOfWraps).AppendLine(); diff --git a/Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs b/Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs index f9f9f02c0..acad76837 100644 --- a/Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs +++ b/Aaru.Decoders/SCSI/Modes/3E_Fujitsu.cs @@ -76,17 +76,13 @@ public static partial class Modes public static Fujitsu_ModePage_3E? DecodeFujitsuModePage_3E(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3E) - return null; + if((pageResponse?[0] & 0x3F) != 0x3E) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 8) - return null; + if(pageResponse.Length != 8) return null; var decoded = new Fujitsu_ModePage_3E(); @@ -111,19 +107,16 @@ public static partial class Modes public static string PrettifyFujitsuModePage_3E(Fujitsu_ModePage_3E? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; Fujitsu_ModePage_3E page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.Fujitsu_Verify_Control_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); - if(page.audioVisualMode) - sb.AppendLine("\t" + Localization.Audio_Visual_data_support_mode_is_applied); + if(page.audioVisualMode) sb.AppendLine("\t" + Localization.Audio_Visual_data_support_mode_is_applied); if(page.streamingMode) sb.AppendLine("\t" + Localization.Test_write_operation_is_restricted_during_read_or_write_operations); @@ -145,8 +138,8 @@ public static partial class Modes } sb.AppendFormat("\t" + Localization.The_device_type_that_would_be_provided_in_the_INQUIRY_response_is_0, - page.devType). - AppendLine(); + page.devType) + .AppendLine(); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/3E_HP.cs b/Aaru.Decoders/SCSI/Modes/3E_HP.cs index 9797c9c0c..611e59070 100644 --- a/Aaru.Decoders/SCSI/Modes/3E_HP.cs +++ b/Aaru.Decoders/SCSI/Modes/3E_HP.cs @@ -52,17 +52,13 @@ public static partial class Modes public static HP_ModePage_3E? DecodeHPModePage_3E(byte[] pageResponse) { - if((pageResponse?[0] & 0x40) == 0x40) - return null; + if((pageResponse?[0] & 0x40) == 0x40) return null; - if((pageResponse?[0] & 0x3F) != 0x3E) - return null; + if((pageResponse?[0] & 0x3F) != 0x3E) return null; - if(pageResponse[1] + 2 != pageResponse.Length) - return null; + if(pageResponse[1] + 2 != pageResponse.Length) return null; - if(pageResponse.Length != 4) - return null; + if(pageResponse.Length != 4) return null; var decoded = new HP_ModePage_3E(); @@ -78,23 +74,20 @@ public static partial class Modes public static string PrettifyHPModePage_3E(HP_ModePage_3E? modePage) { - if(!modePage.HasValue) - return null; + if(!modePage.HasValue) return null; HP_ModePage_3E page = modePage.Value; var sb = new StringBuilder(); sb.AppendLine(Localization.HP_CD_ROM_Emulation_Disaster_Recovery_Mode_Page); - if(page.PS) - sb.AppendLine("\t" + Localization.Parameters_can_be_saved); + if(page.PS) sb.AppendLine("\t" + Localization.Parameters_can_be_saved); sb.AppendLine(page.CDmode ? "\t" + Localization.Drive_is_emulating_a_CD_ROM_drive : "\t" + Localization.Drive_is_not_emulating_a_CD_ROM_drive); - if(page.NonAuto) - sb.AppendLine("\t" + Localization.Drive_will_not_exit_emulation_automatically); + if(page.NonAuto) sb.AppendLine("\t" + Localization.Drive_will_not_exit_emulation_automatically); return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/Headers.cs b/Aaru.Decoders/SCSI/Modes/Headers.cs index 090a5abcb..49e5f5d3e 100644 --- a/Aaru.Decoders/SCSI/Modes/Headers.cs +++ b/Aaru.Decoders/SCSI/Modes/Headers.cs @@ -43,22 +43,22 @@ public static partial class Modes { public static string GetMediumTypeDescription(MediumTypes type) => type switch { - MediumTypes.ECMA54 => Localization. - GetMediumTypeDescription_ECMA_54, - MediumTypes.ECMA59 => Localization. - GetMediumTypeDescription_ECMA_59, - MediumTypes.ECMA69 => Localization. - GetMediumTypeDescription_ECMA_69, - MediumTypes.ECMA66 => Localization. - GetMediumTypeDescription_ECMA_66, - MediumTypes.ECMA70 => Localization. - GetMediumTypeDescription_ECMA_70, - MediumTypes.ECMA78 => Localization. - GetMediumTypeDescription_ECMA_78, - MediumTypes.ECMA99 => Localization. - GetMediumTypeDescription_ECMA_99, - MediumTypes.ECMA100 => Localization. - GetMediumTypeDescription_ECMA_100, + MediumTypes.ECMA54 => Localization + .GetMediumTypeDescription_ECMA_54, + MediumTypes.ECMA59 => Localization + .GetMediumTypeDescription_ECMA_59, + MediumTypes.ECMA69 => Localization + .GetMediumTypeDescription_ECMA_69, + MediumTypes.ECMA66 => Localization + .GetMediumTypeDescription_ECMA_66, + MediumTypes.ECMA70 => Localization + .GetMediumTypeDescription_ECMA_70, + MediumTypes.ECMA78 => Localization + .GetMediumTypeDescription_ECMA_78, + MediumTypes.ECMA99 => Localization + .GetMediumTypeDescription_ECMA_99, + MediumTypes.ECMA100 => Localization + .GetMediumTypeDescription_ECMA_100, // Most probably they will never appear, but magneto-opticals use these codes /* @@ -67,24 +67,24 @@ public static partial class Modes case MediumTypes.Unspecified_DS: return "Unspecified double sided flexible disk"; */ - MediumTypes.X3_73 => Localization. - GetMediumTypeDescription_X3_73, - MediumTypes.X3_73_DS => Localization. - GetMediumTypeDescription_X3_73_DS, - MediumTypes.X3_82 => Localization. - GetMediumTypeDescription_X3_82, - MediumTypes.Type3Floppy => Localization. - GetMediumTypeDescription_Type3Floppy, - MediumTypes.HDFloppy => Localization. - GetMediumTypeDescription_HDFloppy, - MediumTypes.ReadOnly => Localization. - GetMediumTypeDescription_ReadOnly, - MediumTypes.WORM => Localization. - GetMediumTypeDescription_WORM, - MediumTypes.Erasable => Localization. - GetMediumTypeDescription_Erasable, - MediumTypes.RO_WORM => Localization. - GetMediumTypeDescription_RO_WORM, + MediumTypes.X3_73 => Localization + .GetMediumTypeDescription_X3_73, + MediumTypes.X3_73_DS => Localization + .GetMediumTypeDescription_X3_73_DS, + MediumTypes.X3_82 => Localization + .GetMediumTypeDescription_X3_82, + MediumTypes.Type3Floppy => Localization + .GetMediumTypeDescription_Type3Floppy, + MediumTypes.HDFloppy => Localization + .GetMediumTypeDescription_HDFloppy, + MediumTypes.ReadOnly => Localization + .GetMediumTypeDescription_ReadOnly, + MediumTypes.WORM => Localization + .GetMediumTypeDescription_WORM, + MediumTypes.Erasable => Localization + .GetMediumTypeDescription_Erasable, + MediumTypes.RO_WORM => Localization + .GetMediumTypeDescription_RO_WORM, // These magneto-opticals were never manufactured /* @@ -94,19 +94,18 @@ public static partial class Modes case MediumTypes.WORM_RW: return "a combination of write-once and erasable optical"; */ - MediumTypes.DOW => Localization. - GetMediumTypeDescription_DOW, - MediumTypes.HiMD => Localization. - GetMediumTypeDescription_HiMD, - _ => string. - Format(Localization.Unknown_medium_type_0, - (byte)type) + MediumTypes.DOW => Localization + .GetMediumTypeDescription_DOW, + MediumTypes.HiMD => Localization + .GetMediumTypeDescription_HiMD, + _ => string.Format(Localization + .Unknown_medium_type_0, + (byte)type) }; public static string PrettifyModeHeader(ModeHeader? header, PeripheralDeviceTypes deviceType) { - if(!header.HasValue) - return null; + if(!header.HasValue) return null; var sb = new StringBuilder(); @@ -114,21 +113,19 @@ public static partial class Modes switch(deviceType) { - #region Direct access device mode header +#region Direct access device mode header case PeripheralDeviceTypes.DirectAccess: { if(header.Value.MediumType != MediumTypes.Default) { - sb.AppendFormat("\t" + Localization.Medium_is_0, GetMediumTypeDescription(header.Value.MediumType)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Medium_is_0, GetMediumTypeDescription(header.Value.MediumType)) + .AppendLine(); } - if(header.Value.WriteProtected) - sb.AppendLine("\t" + Localization.Medium_is_write_protected); + if(header.Value.WriteProtected) sb.AppendLine("\t" + Localization.Medium_is_write_protected); - if(header.Value.DPOFUA) - sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); + if(header.Value.DPOFUA) sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); if(header.Value.BlockDescriptors != null) { @@ -164,27 +161,31 @@ public static partial class Modes if(descriptor.Blocks == 0) { sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_0_and_are_1_bytes_each, - density, descriptor.BlockLength). - AppendLine(); + density, + descriptor.BlockLength) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization._0_blocks_have_1_and_are_2_bytes_each, - descriptor.Blocks, density, descriptor.BlockLength). - AppendLine(); + descriptor.Blocks, + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.Blocks == 0) { sb.AppendFormat("\t" + Localization.All_remaining_blocks_are_0_bytes_each, - descriptor.BlockLength). - AppendLine(); + descriptor.BlockLength) + .AppendLine(); } else { - sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, descriptor.Blocks, - descriptor.BlockLength). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, + descriptor.Blocks, + descriptor.BlockLength) + .AppendLine(); } } } @@ -192,9 +193,9 @@ public static partial class Modes break; } - #endregion Direct access device mode header +#endregion Direct access device mode header - #region Sequential access device mode header +#region Sequential access device mode header case PeripheralDeviceTypes.SequentialAccess: { @@ -214,8 +215,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_buffered_mode_code_0, header.Value.BufferedMode). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_buffered_mode_code_0, header.Value.BufferedMode) + .AppendLine(); break; } @@ -225,8 +226,7 @@ public static partial class Modes else sb.AppendFormat("\t" + Localization.Device_uses_speed_0, header.Value.Speed).AppendLine(); - if(header.Value.WriteProtected) - sb.AppendLine("\t" + Localization.Medium_is_write_protected); + if(header.Value.WriteProtected) sb.AppendLine("\t" + Localization.Medium_is_write_protected); string medium = header.Value.MediumType switch { @@ -1224,56 +1224,62 @@ public static partial class Modes { if(descriptor.BlockLength == 0) { - sb. - AppendFormat("\t" + Localization.All_remaining_blocks_conform_to_0_and_have_a_variable_length, - density). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .All_remaining_blocks_conform_to_0_and_have_a_variable_length, + density) + .AppendLine(); } else { - sb. - AppendFormat("\t" + Localization.All_remaining_blocks_conform_to_0_and_are_1_bytes_each, - density, descriptor.BlockLength). - AppendLine(); + sb.AppendFormat("\t" + + Localization.All_remaining_blocks_conform_to_0_and_are_1_bytes_each, + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.BlockLength == 0) { sb.AppendFormat("\t" + Localization._0_blocks_conform_to_1_and_have_a_variable_length, - descriptor.Blocks, density). - AppendLine(); + descriptor.Blocks, + density) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization._0_blocks_conform_to_1_and_are_2_bytes_each, - descriptor.Blocks, density, descriptor.BlockLength). - AppendLine(); + descriptor.Blocks, + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.Blocks == 0) { if(descriptor.BlockLength == 0) { - sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_a_variable_length). - AppendLine(); + sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_a_variable_length) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.All_remaining_blocks_are_0_bytes_each, - descriptor.BlockLength). - AppendLine(); + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.BlockLength == 0) { - sb.AppendFormat("\t" + Localization._0_blocks_have_a_variable_length, descriptor.Blocks). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_have_a_variable_length, descriptor.Blocks) + .AppendLine(); } else { - sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, descriptor.Blocks, - descriptor.BlockLength). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, + descriptor.Blocks, + descriptor.BlockLength) + .AppendLine(); } } } @@ -1281,9 +1287,9 @@ public static partial class Modes break; } - #endregion Sequential access device mode header +#endregion Sequential access device mode header - #region Printer device mode header +#region Printer device mode header case PeripheralDeviceTypes.PrinterDevice: { @@ -1298,8 +1304,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\t" + Localization.Unknown_buffered_mode_code_0, header.Value.BufferedMode). - AppendLine(); + sb.AppendFormat("\t" + Localization.Unknown_buffered_mode_code_0, header.Value.BufferedMode) + .AppendLine(); break; } @@ -1307,9 +1313,9 @@ public static partial class Modes break; } - #endregion Printer device mode header +#endregion Printer device mode header - #region Optical device mode header +#region Optical device mode header case PeripheralDeviceTypes.OpticalDevice: { @@ -1348,21 +1354,18 @@ public static partial class Modes break; default: - sb.AppendFormat(Localization.an_unknown_medium_type_0, (byte)header.Value.MediumType). - AppendLine(); + sb.AppendFormat(Localization.an_unknown_medium_type_0, (byte)header.Value.MediumType) + .AppendLine(); break; } } - if(header.Value.WriteProtected) - sb.AppendLine("\t" + Localization.Medium_is_write_protected); + if(header.Value.WriteProtected) sb.AppendLine("\t" + Localization.Medium_is_write_protected); - if(header.Value.EBC) - sb.AppendLine("\t" + Localization.Blank_checking_during_write_is_enabled); + if(header.Value.EBC) sb.AppendLine("\t" + Localization.Blank_checking_during_write_is_enabled); - if(header.Value.DPOFUA) - sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); + if(header.Value.DPOFUA) sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); if(header.Value.BlockDescriptors != null) { @@ -1422,55 +1425,60 @@ public static partial class Modes { if(descriptor.BlockLength == 0) { - sb. - AppendFormat("\t" + Localization.All_remaining_blocks_are_0_and_have_a_variable_length, - density). - AppendLine(); + sb.AppendFormat("\t" + + Localization.All_remaining_blocks_are_0_and_have_a_variable_length, + density) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.All_remaining_blocks_are_0_and_are_1_bytes_each, - density, descriptor.BlockLength). - AppendLine(); + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.BlockLength == 0) { sb.AppendFormat("\t" + Localization._0_blocks_are_1_and_have_a_variable_length, - descriptor.Blocks, density). - AppendLine(); + descriptor.Blocks, + density) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization._0_blocks_are_1_and_are_2_bytes_each, - descriptor.Blocks, density, descriptor.BlockLength). - AppendLine(); + descriptor.Blocks, + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.Blocks == 0) { if(descriptor.BlockLength == 0) { - sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_a_variable_length). - AppendLine(); + sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_a_variable_length) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization.All_remaining_blocks_are_0_bytes_each, - descriptor.BlockLength). - AppendLine(); + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.BlockLength == 0) { - sb.AppendFormat("\t" + Localization._0_blocks_have_a_variable_length, descriptor.Blocks). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_have_a_variable_length, descriptor.Blocks) + .AppendLine(); } else { - sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, descriptor.Blocks, - descriptor.BlockLength). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, + descriptor.Blocks, + descriptor.BlockLength) + .AppendLine(); } } } @@ -1478,9 +1486,9 @@ public static partial class Modes break; } - #endregion Optical device mode header +#endregion Optical device mode header - #region Multimedia device mode header +#region Multimedia device mode header case PeripheralDeviceTypes.MultiMediaDevice: { @@ -1638,11 +1646,9 @@ public static partial class Modes break; } - if(header.Value.WriteProtected) - sb.AppendLine("\t" + Localization.Medium_is_write_protected); + if(header.Value.WriteProtected) sb.AppendLine("\t" + Localization.Medium_is_write_protected); - if(header.Value.DPOFUA) - sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); + if(header.Value.DPOFUA) sb.AppendLine("\t" + Localization.Drive_supports_DPO_and_FUA_bits); if(header.Value.BlockDescriptors != null) { @@ -1698,27 +1704,31 @@ public static partial class Modes if(descriptor.Blocks == 0) { sb.AppendFormat("\t" + Localization.All_remaining_blocks_have_0_and_are_1_bytes_each, - density, descriptor.BlockLength). - AppendLine(); + density, + descriptor.BlockLength) + .AppendLine(); } else { sb.AppendFormat("\t" + Localization._0_blocks_have_1_and_are_2_bytes_each, - descriptor.Blocks, density, descriptor.BlockLength). - AppendLine(); + descriptor.Blocks, + density, + descriptor.BlockLength) + .AppendLine(); } } else if(descriptor.Blocks == 0) { sb.AppendFormat("\t" + Localization.All_remaining_blocks_are_0_bytes_each, - descriptor.BlockLength). - AppendLine(); + descriptor.BlockLength) + .AppendLine(); } else { - sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, descriptor.Blocks, - descriptor.BlockLength). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_blocks_are_1_bytes_each, + descriptor.Blocks, + descriptor.BlockLength) + .AppendLine(); } } } @@ -1726,7 +1736,7 @@ public static partial class Modes break; } - #endregion Multimedia device mode header +#endregion Multimedia device mode header } return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/Mode10.cs b/Aaru.Decoders/SCSI/Modes/Mode10.cs index cbc5fa10d..a3da3e4d7 100644 --- a/Aaru.Decoders/SCSI/Modes/Mode10.cs +++ b/Aaru.Decoders/SCSI/Modes/Mode10.cs @@ -45,14 +45,12 @@ public static partial class Modes { public static ModeHeader? DecodeModeHeader10(byte[] modeResponse, PeripheralDeviceTypes deviceType) { - if(modeResponse == null || modeResponse.Length < 8) - return null; + if(modeResponse == null || modeResponse.Length < 8) return null; var modeLength = (ushort)((modeResponse[0] << 8) + modeResponse[1]); var blockDescLength = (ushort)((modeResponse[6] << 8) + modeResponse[7]); - if(modeResponse.Length < modeLength) - return null; + if(modeResponse.Length < modeLength) return null; var header = new ModeHeader { @@ -69,8 +67,7 @@ public static partial class Modes for(var i = 0; i < header.BlockDescriptors.Length; i++) { - if(12 + i * 16 + 8 >= modeResponse.Length) - break; + if(12 + i * 16 + 8 >= modeResponse.Length) break; header.BlockDescriptors[i] = new BlockDescriptor { @@ -99,8 +96,7 @@ public static partial class Modes for(var i = 0; i < header.BlockDescriptors.Length; i++) { - if(7 + i * 8 + 8 >= modeResponse.Length) - break; + if(7 + i * 8 + 8 >= modeResponse.Length) break; header.BlockDescriptors[i] = new BlockDescriptor(); @@ -158,8 +154,7 @@ public static partial class Modes { ModeHeader? hdr = DecodeModeHeader10(modeResponse, deviceType); - if(!hdr.HasValue) - return null; + if(!hdr.HasValue) return null; var decoded = new DecodedMode { @@ -170,8 +165,7 @@ public static partial class Modes int offset; var blkDrLength = 0; - if(decoded.Header.BlockDescriptors != null) - blkDrLength = decoded.Header.BlockDescriptors.Length; + if(decoded.Header.BlockDescriptors != null) blkDrLength = decoded.Header.BlockDescriptors.Length; if(longlba) offset = 8 + blkDrLength * 16; @@ -182,8 +176,7 @@ public static partial class Modes length += modeResponse[1]; length += 2; - if(length != modeResponse.Length) - return decoded; + if(length != modeResponse.Length) return decoded; List listpages = new(); @@ -269,16 +262,13 @@ public static partial class Modes { case PeripheralDeviceTypes.DirectAccess: case PeripheralDeviceTypes.MultiMediaDevice: - if(header.WriteProtected) - hdr[3] += 0x80; + if(header.WriteProtected) hdr[3] += 0x80; - if(header.DPOFUA) - hdr[3] += 0x10; + if(header.DPOFUA) hdr[3] += 0x10; break; case PeripheralDeviceTypes.SequentialAccess: - if(header.WriteProtected) - hdr[3] += 0x80; + if(header.WriteProtected) hdr[3] += 0x80; hdr[3] += (byte)(header.Speed & 0x0F); hdr[3] += (byte)(header.BufferedMode << 4 & 0x70); @@ -289,23 +279,18 @@ public static partial class Modes break; case PeripheralDeviceTypes.OpticalDevice: - if(header.WriteProtected) - hdr[3] += 0x80; + if(header.WriteProtected) hdr[3] += 0x80; - if(header.EBC) - hdr[3] += 0x01; + if(header.EBC) hdr[3] += 0x01; - if(header.DPOFUA) - hdr[3] += 0x10; + if(header.DPOFUA) hdr[3] += 0x10; break; } - if(longLBA) - hdr[4] += 0x01; + if(longLBA) hdr[4] += 0x01; - if(header.BlockDescriptors == null) - return hdr; + if(header.BlockDescriptors == null) return hdr; if(longLBA) { @@ -351,8 +336,7 @@ public static partial class Modes { var modeSize = 0; - if(mode.Pages != null) - modeSize += mode.Pages.Sum(page => page.PageResponse.Length); + if(mode.Pages != null) modeSize += mode.Pages.Sum(page => page.PageResponse.Length); byte[] hdr = EncodeModeHeader10(mode.Header, deviceType); modeSize += hdr.Length; @@ -360,8 +344,7 @@ public static partial class Modes Array.Copy(hdr, 0, md, 0, hdr.Length); - if(mode.Pages == null) - return md; + if(mode.Pages == null) return md; { int offset = hdr.Length; diff --git a/Aaru.Decoders/SCSI/Modes/Mode6.cs b/Aaru.Decoders/SCSI/Modes/Mode6.cs index 87caa8112..8d048b68a 100644 --- a/Aaru.Decoders/SCSI/Modes/Mode6.cs +++ b/Aaru.Decoders/SCSI/Modes/Mode6.cs @@ -45,8 +45,7 @@ public static partial class Modes { public static ModeHeader? DecodeModeHeader6(byte[] modeResponse, PeripheralDeviceTypes deviceType) { - if(modeResponse == null || modeResponse.Length < 4 || modeResponse.Length < modeResponse[0] + 1) - return null; + if(modeResponse == null || modeResponse.Length < 4 || modeResponse.Length < modeResponse[0] + 1) return null; var header = new ModeHeader { @@ -57,8 +56,7 @@ public static partial class Modes { // An incorrect size field, we cannot know if the following bytes are really the pages (probably not), // so consider the MODE SENSE(6) response as invalid - if(modeResponse[3] + 4 > modeResponse.Length) - return null; + if(modeResponse[3] + 4 > modeResponse.Length) return null; header.BlockDescriptors = new BlockDescriptor[modeResponse[3] / 8]; @@ -110,8 +108,7 @@ public static partial class Modes { ModeHeader? hdr = DecodeModeHeader6(modeResponse, deviceType); - if(!hdr.HasValue) - return null; + if(!hdr.HasValue) return null; var decoded = new DecodedMode { @@ -120,14 +117,12 @@ public static partial class Modes var blkDrLength = 0; - if(decoded.Header.BlockDescriptors != null) - blkDrLength = decoded.Header.BlockDescriptors.Length; + if(decoded.Header.BlockDescriptors != null) blkDrLength = decoded.Header.BlockDescriptors.Length; int offset = 4 + blkDrLength * 8; int length = modeResponse[0] + 1; - if(length != modeResponse.Length) - return decoded; + if(length != modeResponse.Length) return decoded; List listpages = new(); @@ -149,14 +144,12 @@ public static partial class Modes { if(isSubpage) { - if(offset + 3 >= modeResponse.Length) - break; + if(offset + 3 >= modeResponse.Length) break; pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4]; int copyLen = pg.PageResponse.Length; - if(pg.PageResponse.Length + offset > modeResponse.Length) - copyLen = modeResponse.Length - offset; + if(pg.PageResponse.Length + offset > modeResponse.Length) copyLen = modeResponse.Length - offset; Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -165,14 +158,12 @@ public static partial class Modes } else { - if(offset + 1 >= modeResponse.Length) - break; + if(offset + 1 >= modeResponse.Length) break; pg.PageResponse = new byte[modeResponse[offset + 1] + 2]; int copyLen = pg.PageResponse.Length; - if(pg.PageResponse.Length + offset > modeResponse.Length) - copyLen = modeResponse.Length - offset; + if(pg.PageResponse.Length + offset > modeResponse.Length) copyLen = modeResponse.Length - offset; Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen); pg.Page = (byte)(modeResponse[offset] & 0x3F); @@ -199,16 +190,13 @@ public static partial class Modes { case PeripheralDeviceTypes.DirectAccess: case PeripheralDeviceTypes.MultiMediaDevice: - if(header.WriteProtected) - hdr[2] += 0x80; + if(header.WriteProtected) hdr[2] += 0x80; - if(header.DPOFUA) - hdr[2] += 0x10; + if(header.DPOFUA) hdr[2] += 0x10; break; case PeripheralDeviceTypes.SequentialAccess: - if(header.WriteProtected) - hdr[2] += 0x80; + if(header.WriteProtected) hdr[2] += 0x80; hdr[2] += (byte)(header.Speed & 0x0F); hdr[2] += (byte)(header.BufferedMode << 4 & 0x70); @@ -219,20 +207,16 @@ public static partial class Modes break; case PeripheralDeviceTypes.OpticalDevice: - if(header.WriteProtected) - hdr[2] += 0x80; + if(header.WriteProtected) hdr[2] += 0x80; - if(header.EBC) - hdr[2] += 0x01; + if(header.EBC) hdr[2] += 0x01; - if(header.DPOFUA) - hdr[2] += 0x10; + if(header.DPOFUA) hdr[2] += 0x10; break; } - if(header.BlockDescriptors == null) - return hdr; + if(header.BlockDescriptors == null) return hdr; hdr[3] = (byte)(header.BlockDescriptors.Length * 8); @@ -254,8 +238,7 @@ public static partial class Modes { var modeSize = 0; - if(mode.Pages != null) - modeSize += mode.Pages.Sum(page => page.PageResponse.Length); + if(mode.Pages != null) modeSize += mode.Pages.Sum(page => page.PageResponse.Length); byte[] hdr = EncodeModeHeader6(mode.Header, deviceType); modeSize += hdr.Length; @@ -263,8 +246,7 @@ public static partial class Modes Array.Copy(hdr, 0, md, 0, hdr.Length); - if(mode.Pages == null) - return md; + if(mode.Pages == null) return md; { int offset = hdr.Length; diff --git a/Aaru.Decoders/SCSI/SSC/BlockLimits.cs b/Aaru.Decoders/SCSI/SSC/BlockLimits.cs index 9e8c68f77..3306c57eb 100644 --- a/Aaru.Decoders/SCSI/SSC/BlockLimits.cs +++ b/Aaru.Decoders/SCSI/SSC/BlockLimits.cs @@ -44,8 +44,7 @@ public static class BlockLimits { public static BlockLimitsData? Decode(byte[] response) { - if(response?.Length != 6) - return null; + if(response?.Length != 6) return null; return new BlockLimitsData { @@ -57,8 +56,7 @@ public static class BlockLimits public static string Prettify(BlockLimitsData? decoded) { - if(decoded == null) - return null; + if(decoded == null) return null; var sb = new StringBuilder(); @@ -75,9 +73,10 @@ public static class BlockLimits if(decoded.Value.granularity > 0) { - sb.AppendFormat(Core.Device_needs_a_block_size_granularity_of_pow_0_1_bytes, decoded.Value.granularity, - Math.Pow(2, decoded.Value.granularity)). - AppendLine(); + sb.AppendFormat(Core.Device_needs_a_block_size_granularity_of_pow_0_1_bytes, + decoded.Value.granularity, + Math.Pow(2, decoded.Value.granularity)) + .AppendLine(); } } diff --git a/Aaru.Decoders/SCSI/SSC/DensitySupport.cs b/Aaru.Decoders/SCSI/SSC/DensitySupport.cs index e2bc9085e..ff3f098f1 100644 --- a/Aaru.Decoders/SCSI/SSC/DensitySupport.cs +++ b/Aaru.Decoders/SCSI/SSC/DensitySupport.cs @@ -46,13 +46,11 @@ public static class DensitySupport { public static DensitySupportHeader? DecodeDensity(byte[] response) { - if(response is not { Length: > 56 }) - return null; + if(response is not { Length: > 56 }) return null; var responseLen = (ushort)((response[0] << 8) + response[1] + 2); - if(response.Length != responseLen) - return null; + if(response.Length != responseLen) return null; List descriptors = new(); var offset = 4; @@ -108,8 +106,7 @@ public static class DensitySupport public static string PrettifyDensity(DensitySupportHeader? density) { - if(density == null) - return null; + if(density == null) return null; DensitySupportHeader decoded = density.Value; var sb = new StringBuilder(); @@ -123,21 +120,20 @@ public static class DensitySupport if(descriptor.primaryCode != descriptor.secondaryCode) sb.AppendFormat("\t" + Localization.Secondary_code_0, descriptor.secondaryCode).AppendLine(); - if(descriptor.writable) - sb.AppendLine("\t" + Localization.Drive_can_write_this_density); + if(descriptor.writable) sb.AppendLine("\t" + Localization.Drive_can_write_this_density); - if(descriptor.duplicate) - sb.AppendLine("\t" + Localization.This_descriptor_is_duplicated); + if(descriptor.duplicate) sb.AppendLine("\t" + Localization.This_descriptor_is_duplicated); - if(descriptor.defaultDensity) - sb.AppendLine("\t" + Localization.This_is_the_default_density_on_the_drive); + if(descriptor.defaultDensity) sb.AppendLine("\t" + Localization.This_is_the_default_density_on_the_drive); sb.AppendFormat("\t" + Localization.Density_has_0_bits_per_mm__with_1_tracks_in_a_2_mm_width_tape, - descriptor.bpmm, descriptor.tracks, descriptor.width / (double)10). - AppendLine(); + descriptor.bpmm, + descriptor.tracks, + descriptor.width / (double)10) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Density_maximum_capacity_is_0_megabytes, descriptor.capacity). - AppendLine(); + sb.AppendFormat("\t" + Localization.Density_maximum_capacity_is_0_megabytes, descriptor.capacity) + .AppendLine(); sb.AppendFormat("\t" + Localization.Density_description_0, descriptor.description).AppendLine(); sb.AppendLine(); @@ -150,13 +146,11 @@ public static class DensitySupport public static MediaTypeSupportHeader? DecodeMediumType(byte[] response) { - if(response is not { Length: > 60 }) - return null; + if(response is not { Length: > 60 }) return null; var responseLen = (ushort)((response[0] << 8) + response[1] + 2); - if(response.Length != responseLen) - return null; + if(response.Length != responseLen) return null; List descriptors = new(); var offset = 4; @@ -170,8 +164,7 @@ public static class DensitySupport len = (ushort)((response[offset + 2] << 8) + response[offset + 3]) }; - if(descriptor.len != 52) - return null; + if(descriptor.len != 52) return null; descriptor.numberOfCodes = response[offset + 4]; descriptor.densityCodes = new byte[9]; @@ -207,16 +200,15 @@ public static class DensitySupport public static string PrettifyMediumType(MediaTypeSupportHeader? mediumType) { - if(mediumType == null) - return null; + if(mediumType == null) return null; MediaTypeSupportHeader decoded = mediumType.Value; var sb = new StringBuilder(); foreach(MediaTypeSupportDescriptor descriptor in decoded.descriptors) { - sb.AppendFormat(Localization.Medium_type_0_defined_by_1, descriptor.name, descriptor.organization). - AppendLine(); + sb.AppendFormat(Localization.Medium_type_0_defined_by_1, descriptor.name, descriptor.organization) + .AppendLine(); sb.AppendFormat("\t" + Localization.Medium_type_code_0, descriptor.mediumType).AppendLine(); @@ -224,15 +216,15 @@ public static class DensitySupport { sb.AppendFormat("\t" + Localization.Medium_supports_following_density_codes); - for(var i = 0; i < descriptor.numberOfCodes; i++) - sb.Append($" {descriptor.densityCodes[i]:X2}h"); + for(var i = 0; i < descriptor.numberOfCodes; i++) sb.Append($" {descriptor.densityCodes[i]:X2}h"); sb.AppendLine(); } sb.AppendFormat("\t" + Localization.Medium_has_a_nominal_length_of_0_m_in_a_1_mm_width_tape, - descriptor.length, descriptor.width / (double)10). - AppendLine(); + descriptor.length, + descriptor.width / (double)10) + .AppendLine(); sb.AppendFormat("\t" + Localization.Medium_description_0, descriptor.description).AppendLine(); sb.AppendLine(); diff --git a/Aaru.Decoders/SCSI/Sense.cs b/Aaru.Decoders/SCSI/Sense.cs index 2587552a9..5464be981 100644 --- a/Aaru.Decoders/SCSI/Sense.cs +++ b/Aaru.Decoders/SCSI/Sense.cs @@ -189,14 +189,11 @@ public static class Sense /// Sense bytes. public static SenseType GetType(byte[] sense) { - if(sense == null) - return SenseType.Invalid; + if(sense == null) return SenseType.Invalid; - if(sense.Length < 4) - return SenseType.Invalid; + if(sense.Length < 4) return SenseType.Invalid; - if((sense[0] & 0x70) != 0x70) - return sense.Length != 4 ? SenseType.Invalid : SenseType.StandardSense; + if((sense[0] & 0x70) != 0x70) return sense.Length != 4 ? SenseType.Invalid : SenseType.StandardSense; return (sense[0] & 0x0F) switch { @@ -210,8 +207,7 @@ public static class Sense public static StandardSense? DecodeStandard(byte[] sense) { - if(GetType(sense) != SenseType.StandardSense) - return null; + if(GetType(sense) != SenseType.StandardSense) return null; var decoded = new StandardSense(); decoded.AddressValid |= (sense[0] & 0x80) == 0x80; @@ -250,14 +246,11 @@ public static class Sense { senseDescription = null; - if(sense is null || sense.Length == 0) - return null; + if(sense is null || sense.Length == 0) return null; - if((sense[0] & 0x7F) != 0x70 && (sense[0] & 0x7F) != 0x71) - return null; + if((sense[0] & 0x7F) != 0x70 && (sense[0] & 0x7F) != 0x71) return null; - if(sense.Length < 8) - return null; + if(sense.Length < 8) return null; var decoded = new FixedSense { @@ -281,14 +274,11 @@ public static class Sense senseDescription = GetSenseDescription(decoded.ASC, decoded.ASCQ); } - if(sense.Length >= 15) - decoded.FieldReplaceable = sense[14]; + if(sense.Length >= 15) decoded.FieldReplaceable = sense[14]; - if(sense.Length >= 18) - decoded.SenseKeySpecific = (uint)((sense[15] << 16) + (sense[16] << 8) + sense[17]); + if(sense.Length >= 18) decoded.SenseKeySpecific = (uint)((sense[15] << 16) + (sense[16] << 8) + sense[17]); - if(sense.Length <= 18) - return decoded; + if(sense.Length <= 18) return decoded; decoded.AdditionalSense = new byte[sense.Length - 18]; Array.Copy(sense, 18, decoded.AdditionalSense, 0, decoded.AdditionalSense.Length); @@ -302,15 +292,12 @@ public static class Sense { senseDescription = null; - if(sense == null) - return null; + if(sense == null) return null; - if(sense.Length < 8) - return null; + if(sense.Length < 8) return null; // Fixed sense - if((sense[0] & 0x7F) == 0x70 || (sense[0] & 0x7F) == 0x71) - return null; + if((sense[0] & 0x7F) == 0x70 || (sense[0] & 0x7F) == 0x71) return null; var decoded = new DescriptorSense { @@ -334,8 +321,7 @@ public static class Sense var desc = new byte[descLen]; - if(offset + descLen >= sense.Length) - descLen = sense.Length - offset; + if(offset + descLen >= sense.Length) descLen = sense.Length - offset; Array.Copy(sense, offset, desc, 0, descLen); @@ -371,20 +357,21 @@ public static class Sense public static string PrettifySense(StandardSense? sense) { - if(!sense.HasValue) - return null; + if(!sense.HasValue) return null; return sense.Value.AddressValid - ? string.Format(Localization.Error_class_0_type_1_happened_on_block_2 + "\n", sense.Value.ErrorClass, - sense.Value.ErrorType, sense.Value.LBA) - : string.Format(Localization.Error_class_0_type_1 + "\n", sense.Value.ErrorClass, + ? string.Format(Localization.Error_class_0_type_1_happened_on_block_2 + "\n", + sense.Value.ErrorClass, + sense.Value.ErrorType, + sense.Value.LBA) + : string.Format(Localization.Error_class_0_type_1 + "\n", + sense.Value.ErrorClass, sense.Value.ErrorType); } public static string PrettifySense(FixedSense? sense) { - if(!sense.HasValue) - return null; + if(!sense.HasValue) return null; FixedSense decoded = sense.Value; @@ -392,31 +379,23 @@ public static class Sense sb.AppendFormat(Localization.SCSI_SENSE_0, GetSenseKey(decoded.SenseKey)).AppendLine(); - if(decoded.SegmentNumber > 0) - sb.AppendFormat(Localization.On_segment_0, decoded.SegmentNumber).AppendLine(); + if(decoded.SegmentNumber > 0) sb.AppendFormat(Localization.On_segment_0, decoded.SegmentNumber).AppendLine(); - if(decoded.Filemark) - sb.AppendLine(Localization.Filemark_or_setmark_found); + if(decoded.Filemark) sb.AppendLine(Localization.Filemark_or_setmark_found); - if(decoded.EOM) - sb.AppendLine(Localization.End_of_medium_partition_found); + if(decoded.EOM) sb.AppendLine(Localization.End_of_medium_partition_found); - if(decoded.ILI) - sb.AppendLine(Localization.Incorrect_length_indicator); + if(decoded.ILI) sb.AppendLine(Localization.Incorrect_length_indicator); - if(decoded.InformationValid) - sb.AppendFormat(Localization.On_logical_block_0, decoded.Information).AppendLine(); + if(decoded.InformationValid) sb.AppendFormat(Localization.On_logical_block_0, decoded.Information).AppendLine(); - if(decoded.AdditionalLength < 6) - return sb.ToString(); + if(decoded.AdditionalLength < 6) return sb.ToString(); sb.AppendLine(GetSenseDescription(decoded.ASC, decoded.ASCQ)); - if(decoded.AdditionalLength < 10) - return sb.ToString(); + if(decoded.AdditionalLength < 10) return sb.ToString(); - if(!decoded.SKSV) - return sb.ToString(); + if(!decoded.SKSV) return sb.ToString(); switch(decoded.SenseKey) { @@ -429,20 +408,21 @@ public static class Sense if((decoded.SenseKeySpecific & 0x200000) == 0x200000) { sb.AppendFormat(Localization.Invalid_value_in_bit_0_in_field_1_of_CDB, - (decoded.SenseKeySpecific & 0x70000) >> 16, decoded.SenseKeySpecific & 0xFFFF). - AppendLine(); + (decoded.SenseKeySpecific & 0x70000) >> 16, + decoded.SenseKeySpecific & 0xFFFF) + .AppendLine(); } else { - sb.AppendFormat(Localization.Invalid_value_in_field_0_of_CDB, decoded.SenseKeySpecific & 0xFFFF). - AppendLine(); + sb.AppendFormat(Localization.Invalid_value_in_field_0_of_CDB, decoded.SenseKeySpecific & 0xFFFF) + .AppendLine(); } } break; case SenseKeys.NotReady: - sb.AppendFormat(Localization.Format_progress_0, (double)(decoded.SenseKeySpecific & 0xFFFF) / 65536). - AppendLine(); + sb.AppendFormat(Localization.Format_progress_0, (double)(decoded.SenseKeySpecific & 0xFFFF) / 65536) + .AppendLine(); break; case SenseKeys.RecoveredError: @@ -458,8 +438,7 @@ public static class Sense public static string PrettifySense(DescriptorSense? sense) { - if(!sense.HasValue) - return null; + if(!sense.HasValue) return null; DescriptorSense decoded = sense.Value; @@ -468,8 +447,7 @@ public static class Sense sb.AppendFormat(Localization.SCSI_SENSE_0, GetSenseKey(decoded.SenseKey)).AppendLine(); sb.AppendLine(GetSenseDescription(decoded.ASC, decoded.ASCQ)); - if(decoded.Descriptors == null || decoded.Descriptors.Count == 0) - return sb.ToString(); + if(decoded.Descriptors == null || decoded.Descriptors.Count == 0) return sb.ToString(); foreach(KeyValuePair kvp in decoded.Descriptors) { @@ -490,8 +468,7 @@ public static class Sense /// Descriptor. public static ulong DecodeDescriptor00(byte[] descriptor) { - if(descriptor.Length != 12 || descriptor[0] != 0x00) - return 0; + if(descriptor.Length != 12 || descriptor[0] != 0x00) return 0; var temp = new byte[8]; @@ -512,8 +489,7 @@ public static class Sense /// Descriptor. public static ulong DecodeDescriptor01(byte[] descriptor) { - if(descriptor.Length != 12 || descriptor[0] != 0x01) - return 0; + if(descriptor.Length != 12 || descriptor[0] != 0x01) return 0; var temp = new byte[8]; @@ -534,8 +510,7 @@ public static class Sense /// Descriptor. public static byte[] DecodeDescriptor02(byte[] descriptor) { - if(descriptor.Length != 8 || descriptor[0] != 0x02) - return null; + if(descriptor.Length != 8 || descriptor[0] != 0x02) return null; var temp = new byte[3]; Array.Copy(descriptor, 4, temp, 0, 3); @@ -548,8 +523,7 @@ public static class Sense /// Descriptor. public static byte DecodeDescriptor03(byte[] descriptor) { - if(descriptor.Length != 4 || descriptor[0] != 0x03) - return 0; + if(descriptor.Length != 4 || descriptor[0] != 0x03) return 0; return descriptor[3]; } @@ -559,8 +533,7 @@ public static class Sense /// Descriptor. public static AnotherProgressIndicationSenseDescriptor? DecodeDescriptor0A(byte[] descriptor) { - if(descriptor.Length != 8 || descriptor[0] != 0x0A) - return null; + if(descriptor.Length != 8 || descriptor[0] != 0x0A) return null; return new AnotherProgressIndicationSenseDescriptor { @@ -2729,10 +2702,9 @@ public static class Sense } return ASC >= 0x80 - ? - ASCQ >= 0x80 - ? string.Format(Localization.VENDOR_SPECIFIC_ASC_0_WITH_VENDOR_SPECIFIC_ASCQ_1, ASC, ASCQ) - : string.Format(Localization.VENDOR_SPECIFIC_ASC_0_WITH_ASCQ_1, ASC, ASCQ) + ? ASCQ >= 0x80 + ? string.Format(Localization.VENDOR_SPECIFIC_ASC_0_WITH_VENDOR_SPECIFIC_ASCQ_1, ASC, ASCQ) + : string.Format(Localization.VENDOR_SPECIFIC_ASC_0_WITH_ASCQ_1, ASC, ASCQ) : ASCQ >= 0x80 ? string.Format(Localization.ASC_0_WITH_VENDOR_SPECIFIC_ASCQ_1, ASC, ASCQ) : string.Format(Localization.ASC_0_WITH_ASCQ_1, ASC, ASCQ); diff --git a/Aaru.Decoders/SecureDigital/CID.cs b/Aaru.Decoders/SecureDigital/CID.cs index dd368aeb5..0d6c696d0 100644 --- a/Aaru.Decoders/SecureDigital/CID.cs +++ b/Aaru.Decoders/SecureDigital/CID.cs @@ -59,8 +59,7 @@ public static partial class Decoders { public static CID DecodeCID(uint[] response) { - if(response?.Length != 4) - return null; + if(response?.Length != 4) return null; var data = new byte[16]; @@ -78,8 +77,7 @@ public static partial class Decoders public static CID DecodeCID(byte[] response) { - if(response?.Length != 16) - return null; + if(response?.Length != 16) return null; var cid = new CID { @@ -102,8 +100,7 @@ public static partial class Decoders public static string PrettifyCID(CID cid) { - if(cid == null) - return null; + if(cid == null) return null; var sb = new StringBuilder(); @@ -112,15 +109,17 @@ public static partial class Decoders sb.AppendFormat(Localization.Application_ID_0, cid.ApplicationID).AppendLine(); sb.AppendFormat(Localization.Product_name_0, cid.ProductName).AppendLine(); - sb.AppendFormat(Localization.Product_revision_0_1, (cid.ProductRevision & 0xF0) >> 4, - cid.ProductRevision & 0x0F). - AppendLine(); + sb.AppendFormat(Localization.Product_revision_0_1, + (cid.ProductRevision & 0xF0) >> 4, + cid.ProductRevision & 0x0F) + .AppendLine(); sb.AppendFormat(Localization.Product_serial_number_0, cid.ProductSerialNumber).AppendLine(); - sb.AppendFormat(Localization.Device_manufactured_month_0_of_1, (cid.ManufacturingDate & 0xF00) >> 8, - (cid.ManufacturingDate & 0xFF) + 2000). - AppendLine(); + sb.AppendFormat(Localization.Device_manufactured_month_0_of_1, + (cid.ManufacturingDate & 0xF00) >> 8, + (cid.ManufacturingDate & 0xFF) + 2000) + .AppendLine(); sb.AppendFormat(Localization.CID_CRC_0, cid.CRC).AppendLine(); diff --git a/Aaru.Decoders/SecureDigital/CSD.cs b/Aaru.Decoders/SecureDigital/CSD.cs index a561245bf..e31e5df24 100644 --- a/Aaru.Decoders/SecureDigital/CSD.cs +++ b/Aaru.Decoders/SecureDigital/CSD.cs @@ -79,8 +79,7 @@ public static partial class Decoders { public static CSD DecodeCSD(uint[] response) { - if(response?.Length != 4) - return null; + if(response?.Length != 4) return null; var data = new byte[16]; @@ -98,8 +97,7 @@ public static partial class Decoders public static CSD DecodeCSD(byte[] response) { - if(response?.Length != 16) - return null; + if(response?.Length != 16) return null; var csd = new CSD { @@ -146,8 +144,7 @@ public static partial class Decoders public static string PrettifyCSD(CSD csd) { - if(csd == null) - return null; + if(csd == null) return null; double unitFactor = 0; double multiplier = 0; @@ -236,8 +233,8 @@ public static partial class Decoders double result = unitFactor * multiplier; sb.AppendFormat("\t" + Localization.Asynchronous_data_access_time_is_0_1, result, unit).AppendLine(); - sb.AppendFormat("\t" + Localization.Clock_dependent_part_of_data_access_is_0_clock_cycles, csd.NSAC * 100). - AppendLine(); + sb.AppendFormat("\t" + Localization.Clock_dependent_part_of_data_access_is_0_clock_cycles, csd.NSAC * 100) + .AppendLine(); unit = Localization.MBit_s; @@ -294,26 +291,21 @@ public static partial class Decoders for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) { - if((csd.Classes & mask) == mask) - unit += $" {cl}"; + if((csd.Classes & mask) == mask) unit += $" {cl}"; } sb.AppendFormat("\t" + Localization.Device_support_command_classes_0, unit).AppendLine(); - sb.AppendFormat("\t" + Localization.Read_block_length_is_0_bytes, Math.Pow(2, csd.ReadBlockLength)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Read_block_length_is_0_bytes, Math.Pow(2, csd.ReadBlockLength)) + .AppendLine(); - if(csd.ReadsPartialBlocks) - sb.AppendLine("\t" + Localization.Device_allows_reading_partial_blocks); + if(csd.ReadsPartialBlocks) sb.AppendLine("\t" + Localization.Device_allows_reading_partial_blocks); - if(csd.WriteMisalignment) - sb.AppendLine("\t" + Localization.Write_commands_can_cross_physical_block_boundaries); + if(csd.WriteMisalignment) sb.AppendLine("\t" + Localization.Write_commands_can_cross_physical_block_boundaries); - if(csd.ReadMisalignment) - sb.AppendLine("\t" + Localization.Read_commands_can_cross_physical_block_boundaries); + if(csd.ReadMisalignment) sb.AppendLine("\t" + Localization.Read_commands_can_cross_physical_block_boundaries); - if(csd.DSRImplemented) - sb.AppendLine("\t" + Localization.Device_implements_configurable_driver_stage); + if(csd.DSRImplemented) sb.AppendLine("\t" + Localization.Device_implements_configurable_driver_stage); if(csd.Structure == 0) { @@ -518,13 +510,12 @@ public static partial class Decoders break; } - if(csd.EraseBlockEnable) - sb.AppendLine("\t" + Localization.Device_can_erase_multiple_blocks); + if(csd.EraseBlockEnable) sb.AppendLine("\t" + Localization.Device_can_erase_multiple_blocks); // TODO: Check specification sb.AppendFormat("\t" + Localization.Device_must_erase_a_minimum_of_0_blocks_at_a_time, - Convert.ToUInt32(csd.EraseSectorSize) + 1). - AppendLine(); + Convert.ToUInt32(csd.EraseSectorSize) + 1) + .AppendLine(); if(csd.WriteProtectGroupEnable) { @@ -534,30 +525,26 @@ public static partial class Decoders // unitFactor = Convert.ToDouble(csd.WriteProtectGroupSize); sb.AppendFormat("\t" + Localization.Device_can_write_protect_a_minimum_of_0_blocks_at_a_time, - (int)(result + 1)). - AppendLine(); + (int)(result + 1)) + .AppendLine(); } else sb.AppendLine("\t" + Localization.Device_cant_write_protect_regions); } - sb.AppendFormat("\t" + Localization.Writing_is_0_times_slower_than_reading, Math.Pow(2, csd.WriteSpeedFactor)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Writing_is_0_times_slower_than_reading, Math.Pow(2, csd.WriteSpeedFactor)) + .AppendLine(); - sb.AppendFormat("\t" + Localization.Write_block_length_is_0_bytes, Math.Pow(2, csd.WriteBlockLength)). - AppendLine(); + sb.AppendFormat("\t" + Localization.Write_block_length_is_0_bytes, Math.Pow(2, csd.WriteBlockLength)) + .AppendLine(); - if(csd.WritesPartialBlocks) - sb.AppendLine("\t" + Localization.Device_allows_writing_partial_blocks); + if(csd.WritesPartialBlocks) sb.AppendLine("\t" + Localization.Device_allows_writing_partial_blocks); - if(!csd.Copy) - sb.AppendLine("\t" + Localization.Device_contents_are_original); + if(!csd.Copy) sb.AppendLine("\t" + Localization.Device_contents_are_original); - if(csd.PermanentWriteProtect) - sb.AppendLine("\t" + Localization.Device_is_permanently_write_protected); + if(csd.PermanentWriteProtect) sb.AppendLine("\t" + Localization.Device_is_permanently_write_protected); - if(csd.TemporaryWriteProtect) - sb.AppendLine("\t" + Localization.Device_is_temporarily_write_protected); + if(csd.TemporaryWriteProtect) sb.AppendLine("\t" + Localization.Device_is_temporarily_write_protected); if(!csd.FileFormatGroup) { @@ -576,8 +563,8 @@ public static partial class Decoders break; default: - sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0, csd.FileFormat). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0, csd.FileFormat) + .AppendLine(); break; } @@ -585,8 +572,8 @@ public static partial class Decoders else { sb.AppendFormat("\t" + Localization.Device_uses_unknown_file_format_code_0_and_file_format_group_1, - csd.FileFormat). - AppendLine(); + csd.FileFormat) + .AppendLine(); } sb.AppendFormat("\t" + Localization.CSD_CRC_0, csd.CRC).AppendLine(); diff --git a/Aaru.Decoders/SecureDigital/OCR.cs b/Aaru.Decoders/SecureDigital/OCR.cs index 651fe46c9..77eef1a88 100644 --- a/Aaru.Decoders/SecureDigital/OCR.cs +++ b/Aaru.Decoders/SecureDigital/OCR.cs @@ -93,50 +93,36 @@ public static partial class Decoders public static string PrettifyOCR(OCR ocr) { - if(ocr == null) - return null; + if(ocr == null) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.SecureDigital_Operation_Conditions_Register); - if(!ocr.PowerUp) - sb.AppendLine("\t" + Localization.Device_is_powering_up); + if(!ocr.PowerUp) sb.AppendLine("\t" + Localization.Device_is_powering_up); - if(ocr.CCS) - sb.AppendLine("\t" + Localization.Device_is_SDHC_SDXC_or_higher); + if(ocr.CCS) sb.AppendLine("\t" + Localization.Device_is_SDHC_SDXC_or_higher); - if(ocr.UHS) - sb.AppendLine("\t" + Localization.Device_is_UHS_II_or_higher); + if(ocr.UHS) sb.AppendLine("\t" + Localization.Device_is_UHS_II_or_higher); - if(ocr.ThreeFive) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_5_3_6V); + if(ocr.ThreeFive) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_5_3_6V); - if(ocr.ThreeFour) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_4_3_5V); + if(ocr.ThreeFour) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_4_3_5V); - if(ocr.ThreeThree) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_3_3_4V); + if(ocr.ThreeThree) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_3_3_4V); - if(ocr.ThreeTwo) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_2_3_3V); + if(ocr.ThreeTwo) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_2_3_3V); - if(ocr.ThreeOne) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_1_3_2V); + if(ocr.ThreeOne) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_3_1_3_2V); - if(ocr.TwoNine) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_9_3_0V); + if(ocr.TwoNine) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_9_3_0V); - if(ocr.TwoEight) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_8_2_9V); + if(ocr.TwoEight) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_8_2_9V); - if(ocr.TwoSeven) - sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_7_2_8V); + if(ocr.TwoSeven) sb.AppendLine("\t" + Localization.Device_can_work_with_supply_2_7_2_8V); - if(ocr.OneEight) - sb.AppendLine("\t" + Localization.Device_can_switch_to_work_with_1_8V_supply); + if(ocr.OneEight) sb.AppendLine("\t" + Localization.Device_can_switch_to_work_with_1_8V_supply); - if(ocr.LowPower) - sb.AppendLine("\t" + Localization.Device_is_in_low_power_mode); + if(ocr.LowPower) sb.AppendLine("\t" + Localization.Device_is_in_low_power_mode); return sb.ToString(); } diff --git a/Aaru.Decoders/SecureDigital/SCR.cs b/Aaru.Decoders/SecureDigital/SCR.cs index d2f832431..e6eaade08 100644 --- a/Aaru.Decoders/SecureDigital/SCR.cs +++ b/Aaru.Decoders/SecureDigital/SCR.cs @@ -78,8 +78,7 @@ public static partial class Decoders { public static SCR DecodeSCR(uint[] response) { - if(response?.Length != 2) - return null; + if(response?.Length != 2) return null; var data = new byte[8]; @@ -93,8 +92,7 @@ public static partial class Decoders public static SCR DecodeSCR(byte[] response) { - if(response?.Length != 8) - return null; + if(response?.Length != 8) return null; var scr = new SCR { @@ -118,8 +116,7 @@ public static partial class Decoders public static string PrettifySCR(SCR scr) { - if(scr == null) - return null; + if(scr == null) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.SecureDigital_Device_Configuration_Register); @@ -159,36 +156,40 @@ public static partial class Decoders { case 1: sb.AppendLine("\t" + - Localization. - Device_follows_SecureDigital_Physical_Layer_Specification_version_5_xx); + Localization + .Device_follows_SecureDigital_Physical_Layer_Specification_version_5_xx); break; case 2: sb.AppendLine("\t" + - Localization. - Device_follows_SecureDigital_Physical_Layer_Specification_version_6_xx); + Localization + .Device_follows_SecureDigital_Physical_Layer_Specification_version_6_xx); break; case 3: sb.AppendLine("\t" + - Localization. - Device_follows_SecureDigital_Physical_Layer_Specification_version_7_xx); + Localization + .Device_follows_SecureDigital_Physical_Layer_Specification_version_7_xx); break; case 4: sb.AppendLine("\t" + - Localization. - Device_follows_SecureDigital_Physical_Layer_Specification_version_8_xx); + Localization + .Device_follows_SecureDigital_Physical_Layer_Specification_version_8_xx); break; } break; default: - sb. - AppendFormat("\t" + Localization.Device_follows_SecureDigital_Physical_Layer_Specification_with_unknown_version_0_1_2_3, - scr.Spec, scr.Spec3, scr.Spec4, scr.SpecX). - AppendLine(); + sb.AppendFormat("\t" + + Localization + .Device_follows_SecureDigital_Physical_Layer_Specification_with_unknown_version_0_1_2_3, + scr.Spec, + scr.Spec3, + scr.Spec4, + scr.SpecX) + .AppendLine(); break; } @@ -216,20 +217,17 @@ public static partial class Decoders break; default: - sb.AppendFormat("\t" + Localization.Device_uses_unknown_CPRM_specification_with_code_0, scr.Security). - AppendLine(); + sb.AppendFormat("\t" + Localization.Device_uses_unknown_CPRM_specification_with_code_0, scr.Security) + .AppendLine(); break; } - if(scr.BusWidth.HasFlag(BusWidth.OneBit)) - sb.AppendLine("\t" + Localization.Device_supports_1_bit_data_bus); + if(scr.BusWidth.HasFlag(BusWidth.OneBit)) sb.AppendLine("\t" + Localization.Device_supports_1_bit_data_bus); - if(scr.BusWidth.HasFlag(BusWidth.FourBit)) - sb.AppendLine("\t" + Localization.Device_supports_4_bit_data_bus); + if(scr.BusWidth.HasFlag(BusWidth.FourBit)) sb.AppendLine("\t" + Localization.Device_supports_4_bit_data_bus); - if(scr.ExtendedSecurity != 0) - sb.AppendLine("\t" + Localization.Device_supports_extended_security); + if(scr.ExtendedSecurity != 0) sb.AppendLine("\t" + Localization.Device_supports_extended_security); if(scr.CommandSupport.HasFlag(CommandSupport.ExtensionRegisterMultiBlock)) sb.AppendLine("\t" + Localization.Device_supports_extension_register_multi_block_commands); diff --git a/Aaru.Decoders/Sega/CD.cs b/Aaru.Decoders/Sega/CD.cs index f64c76a80..51ed9fd58 100644 --- a/Aaru.Decoders/Sega/CD.cs +++ b/Aaru.Decoders/Sega/CD.cs @@ -54,18 +54,18 @@ public static class CD /// Decoded IP.BIN public static IPBin? DecodeIPBin(byte[] ipbin_sector) { - if(ipbin_sector == null) - return null; + if(ipbin_sector == null) return null; - if(ipbin_sector.Length < 512) - return null; + if(ipbin_sector.Length < 512) return null; IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.volume_name = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.volume_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.volume_name)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.system_name = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.system_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.system_name)); AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.volume_version = \"{0:X}\"", ipbin.volume_version); @@ -88,28 +88,36 @@ public static class CD AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.sp_work_ram_size = {0}", ipbin.sp_work_ram_size); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.release_date = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.release_date2 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.release_date2 = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date2)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.developer_code = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.developer_code = \"{0}\"", Encoding.ASCII.GetString(ipbin.developer_code)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.domestic_title = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.domestic_title = \"{0}\"", Encoding.ASCII.GetString(ipbin.domestic_title)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.overseas_title = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.overseas_title = \"{0}\"", Encoding.ASCII.GetString(ipbin.overseas_title)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.product_code = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.product_code = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_code)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.peripherals = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(ipbin.peripherals)); - AaruConsole.DebugWriteLine(MODULE_NAME, "segacd_ipbin.region_codes = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "segacd_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(ipbin.region_codes)); string id = Encoding.ASCII.GetString(ipbin.SegaHardwareID); @@ -122,8 +130,7 @@ public static class CD /// Description of the IP.BIN contents public static string Prettify(IPBin? decoded) { - if(decoded == null) - return null; + if(decoded == null) return null; IPBin ipbin = decoded.Value; @@ -147,12 +154,12 @@ public static class CD { ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date2), "yyyy.MMM", provider); } - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { // ignored } - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } /* @@ -174,15 +181,15 @@ public static class CD //IPBinInformation.AppendFormat("Volume version: {0}", Encoding.ASCII.GetString(ipbin.volume_version)).AppendLine(); //IPBinInformation.AppendFormat("{0}", Encoding.ASCII.GetString(ipbin.volume_type)).AppendLine(); - IPBinInformation.AppendFormat(Localization.System_name_0, Encoding.ASCII.GetString(ipbin.system_name)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.System_name_0, Encoding.ASCII.GetString(ipbin.system_name)) + .AppendLine(); //IPBinInformation.AppendFormat("System version: {0}", Encoding.ASCII.GetString(ipbin.system_version)).AppendLine(); IPBinInformation.AppendFormat(Localization.Initial_program_address_0, ipbin.ip_address).AppendLine(); IPBinInformation.AppendFormat(Localization.Initial_program_load_size_0, ipbin.ip_loadsize).AppendLine(); - IPBinInformation.AppendFormat(Localization.Initial_program_entry_address_0, ipbin.ip_entry_address). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Initial_program_entry_address_0, ipbin.ip_entry_address) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Initial_program_work_RAM_0, ipbin.ip_work_ram_size).AppendLine(); IPBinInformation.AppendFormat(Localization.System_program_address_0, ipbin.sp_address).AppendLine(); @@ -196,20 +203,20 @@ public static class CD IPBinInformation.AppendFormat(Localization.Release_date_0, ipbindate).AppendLine(); //IPBinInformation.AppendFormat("Release date (other format): {0}", Encoding.ASCII.GetString(release_date2)).AppendLine(); - IPBinInformation.AppendFormat(Localization.Hardware_ID_0, Encoding.ASCII.GetString(ipbin.hardware_id)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Hardware_ID_0, Encoding.ASCII.GetString(ipbin.hardware_id)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Developer_code_0, Encoding.ASCII.GetString(ipbin.developer_code)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Developer_code_0, Encoding.ASCII.GetString(ipbin.developer_code)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Domestic_title_0, Encoding.ASCII.GetString(ipbin.domestic_title)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Domestic_title_0, Encoding.ASCII.GetString(ipbin.domestic_title)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Overseas_title_0, Encoding.ASCII.GetString(ipbin.overseas_title)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Overseas_title_0, Encoding.ASCII.GetString(ipbin.overseas_title)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Product_code_0, Encoding.ASCII.GetString(ipbin.product_code)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Product_code_0, Encoding.ASCII.GetString(ipbin.product_code)) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Peripherals).AppendLine(); @@ -264,8 +271,8 @@ public static class CD case ' ': break; default: - IPBinInformation.AppendFormat(Localization.Game_supports_unknown_peripheral_0, peripheral). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Game_supports_unknown_peripheral_0, peripheral) + .AppendLine(); break; } diff --git a/Aaru.Decoders/Sega/Dreamcast.cs b/Aaru.Decoders/Sega/Dreamcast.cs index 2ae6abd94..0e38372bd 100644 --- a/Aaru.Decoders/Sega/Dreamcast.cs +++ b/Aaru.Decoders/Sega/Dreamcast.cs @@ -53,56 +53,66 @@ public static class Dreamcast /// Decoded IP.BIN public static IPBin? DecodeIPBin(byte[] ipbin_sector) { - if(ipbin_sector == null) - return null; + if(ipbin_sector == null) return null; - if(ipbin_sector.Length < 512) - return null; + if(ipbin_sector.Length < 512) return null; IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.maker_id = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id)); AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.spare_space1 = \"{0}\"", (char)ipbin.spare_space1); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.dreamcast_media = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.dreamcast_media = \"{0}\"", Encoding.ASCII.GetString(ipbin.dreamcast_media)); AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.disc_no_separator = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator); AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.disc_total_nos = \"{0}\"", (char)ipbin.disc_total_nos); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.spare_space2 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.spare_space2 = \"{0}\"", Encoding.ASCII.GetString(ipbin.spare_space2)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.region_codes = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(ipbin.region_codes)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.peripherals = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(ipbin.peripherals)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.product_no = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_no)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.product_version = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.product_version = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_version)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.release_date = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date)); AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.spare_space3 = \"{0}\"", (char)ipbin.spare_space3); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.boot_filename = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.boot_filename = \"{0}\"", Encoding.ASCII.GetString(ipbin.boot_filename)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.producer = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.producer = \"{0}\"", Encoding.ASCII.GetString(ipbin.producer)); - AaruConsole.DebugWriteLine(MODULE_NAME, "dreamcast_ipbin.product_name = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "dreamcast_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_name)); return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGAKATANA " ? ipbin : null; @@ -113,8 +123,7 @@ public static class Dreamcast /// Description of the IP.BIN contents public static string Prettify(IPBin? decoded) { - if(decoded == null) - return null; + if(decoded == null) return null; IPBin ipbin = decoded.Value; @@ -128,20 +137,20 @@ public static class Dreamcast CultureInfo provider = CultureInfo.InvariantCulture; var ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat(Localization.Product_name_0, Encoding.ASCII.GetString(ipbin.product_name)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Product_name_0, Encoding.ASCII.GetString(ipbin.product_name)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Product_version_0, Encoding.ASCII.GetString(ipbin.product_version)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Product_version_0, Encoding.ASCII.GetString(ipbin.product_version)) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Product_CRC_0, ipbin.dreamcast_crc).AppendLine(); IPBinInformation.AppendFormat(Localization.Producer_0, Encoding.ASCII.GetString(ipbin.producer)).AppendLine(); - IPBinInformation.AppendFormat(Localization.Disc_media_0, Encoding.ASCII.GetString(ipbin.dreamcast_media)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Disc_media_0, Encoding.ASCII.GetString(ipbin.dreamcast_media)) + .AppendLine(); - IPBinInformation.AppendFormat(Localization.Disc_number_0_of_1, (char)ipbin.disc_no, (char)ipbin.disc_total_nos). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Disc_number_0_of_1, (char)ipbin.disc_no, (char)ipbin.disc_total_nos) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Release_date_0, ipbindate).AppendLine(); @@ -157,8 +166,8 @@ public static class Dreamcast break; default: IPBinInformation.AppendFormat(Localization.Disc_boots_using_unknown_loader_0, - Encoding.ASCII.GetString(ipbin.boot_filename)). - AppendLine(); + Encoding.ASCII.GetString(ipbin.boot_filename)) + .AppendLine(); break; } @@ -192,8 +201,7 @@ public static class Dreamcast var iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber); - if((iPeripherals & 0x00000001) == 0x00000001) - IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE); + if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE); IPBinInformation.AppendFormat(Localization.Peripherals).AppendLine(); @@ -215,20 +223,15 @@ public static class Dreamcast if((iPeripherals & 0x00001000) == 0x00001000) IPBinInformation.AppendLine(Localization.Game_requires_A_B_Start_buttons_and_D_Pad); - if((iPeripherals & 0x00002000) == 0x00002000) - IPBinInformation.AppendLine(Localization.Game_requires_C_button); + if((iPeripherals & 0x00002000) == 0x00002000) IPBinInformation.AppendLine(Localization.Game_requires_C_button); - if((iPeripherals & 0x00004000) == 0x00004000) - IPBinInformation.AppendLine(Localization.Game_requires_D_button); + if((iPeripherals & 0x00004000) == 0x00004000) IPBinInformation.AppendLine(Localization.Game_requires_D_button); - if((iPeripherals & 0x00008000) == 0x00008000) - IPBinInformation.AppendLine(Localization.Game_requires_X_button); + if((iPeripherals & 0x00008000) == 0x00008000) IPBinInformation.AppendLine(Localization.Game_requires_X_button); - if((iPeripherals & 0x00010000) == 0x00010000) - IPBinInformation.AppendLine(Localization.Game_requires_Y_button); + if((iPeripherals & 0x00010000) == 0x00010000) IPBinInformation.AppendLine(Localization.Game_requires_Y_button); - if((iPeripherals & 0x00020000) == 0x00020000) - IPBinInformation.AppendLine(Localization.Game_requires_Z_button); + if((iPeripherals & 0x00020000) == 0x00020000) IPBinInformation.AppendLine(Localization.Game_requires_Z_button); if((iPeripherals & 0x00040000) == 0x00040000) IPBinInformation.AppendLine(Localization.Game_requires_expanded_direction_buttons); @@ -251,14 +254,11 @@ public static class Dreamcast if((iPeripherals & 0x01000000) == 0x01000000) IPBinInformation.AppendLine(Localization.Game_requires_expanded_analog_vertical_controller); - if((iPeripherals & 0x02000000) == 0x02000000) - IPBinInformation.AppendLine(Localization.Game_supports_Gun); + if((iPeripherals & 0x02000000) == 0x02000000) IPBinInformation.AppendLine(Localization.Game_supports_Gun); - if((iPeripherals & 0x04000000) == 0x04000000) - IPBinInformation.AppendLine(Localization.Game_supports_keyboard); + if((iPeripherals & 0x04000000) == 0x04000000) IPBinInformation.AppendLine(Localization.Game_supports_keyboard); - if((iPeripherals & 0x08000000) == 0x08000000) - IPBinInformation.AppendLine(Localization.Game_supports_mouse); + if((iPeripherals & 0x08000000) == 0x08000000) IPBinInformation.AppendLine(Localization.Game_supports_mouse); if((iPeripherals & 0xEE) != 0) IPBinInformation.AppendFormat(Localization.Game_supports_unknown_peripherals_mask_0, iPeripherals & 0xEE); diff --git a/Aaru.Decoders/Sega/Saturn.cs b/Aaru.Decoders/Sega/Saturn.cs index 31225effe..9f6c76557 100644 --- a/Aaru.Decoders/Sega/Saturn.cs +++ b/Aaru.Decoders/Sega/Saturn.cs @@ -53,49 +53,58 @@ public static class Saturn /// Decoded IP.BIN public static IPBin? DecodeIPBin(byte[] ipbin_sector) { - if(ipbin_sector == null) - return null; + if(ipbin_sector == null) return null; - if(ipbin_sector.Length < 512) - return null; + if(ipbin_sector.Length < 512) return null; IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian(ipbin_sector); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.maker_id = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.product_no = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_no)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.product_version = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.product_version = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_version)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.release_date = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.saturn_media = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.saturn_media = \"{0}\"", Encoding.ASCII.GetString(ipbin.saturn_media)); AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.disc_no_separator = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator); AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.release_date = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(ipbin.release_date)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.spare_space1 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.spare_space1 = \"{0}\"", Encoding.ASCII.GetString(ipbin.spare_space1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.region_codes = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(ipbin.region_codes)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.peripherals = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(ipbin.peripherals)); - AaruConsole.DebugWriteLine(MODULE_NAME, "saturn_ipbin.product_name = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "saturn_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_name)); return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : null; @@ -106,8 +115,7 @@ public static class Saturn /// Description of the IP.BIN contents public static string Prettify(IPBin? decoded) { - if(decoded == null) - return null; + if(decoded == null) return null; IPBin ipbin = decoded.Value; @@ -121,18 +129,18 @@ public static class Saturn CultureInfo provider = CultureInfo.InvariantCulture; var ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat(Localization.Product_name_0, Encoding.ASCII.GetString(ipbin.product_name)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Product_name_0, Encoding.ASCII.GetString(ipbin.product_name)) + .AppendLine(); IPBinInformation.Append($"Product number: {Encoding.ASCII.GetString(ipbin.product_no)}").AppendLine(); - IPBinInformation.AppendFormat(Localization.Product_version_0, Encoding.ASCII.GetString(ipbin.product_version)). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Product_version_0, Encoding.ASCII.GetString(ipbin.product_version)) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Release_date_0, ipbindate).AppendLine(); - IPBinInformation.AppendFormat(Localization.Disc_number_0_of_1, (char)ipbin.disc_no, (char)ipbin.disc_total_nos). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Disc_number_0_of_1, (char)ipbin.disc_no, (char)ipbin.disc_total_nos) + .AppendLine(); IPBinInformation.AppendFormat(Localization.Peripherals).AppendLine(); @@ -167,8 +175,8 @@ public static class Saturn case ' ': break; default: - IPBinInformation.AppendFormat(Localization.Game_supports_unknown_peripheral_0, peripheral). - AppendLine(); + IPBinInformation.AppendFormat(Localization.Game_supports_unknown_peripheral_0, peripheral) + .AppendLine(); break; } diff --git a/Aaru.Decoders/Xbox/DMI.cs b/Aaru.Decoders/Xbox/DMI.cs index 262fa13dd..6920ec0e4 100644 --- a/Aaru.Decoders/Xbox/DMI.cs +++ b/Aaru.Decoders/Xbox/DMI.cs @@ -45,28 +45,23 @@ public static class DMI { public static bool IsXbox(byte[] dmi) { - if(dmi?.Length != 2052) - return false; + if(dmi?.Length != 2052) return false; // Version is 1 - if(BitConverter.ToUInt32(dmi, 4) != 1) - return false; + if(BitConverter.ToUInt32(dmi, 4) != 1) return false; // Catalogue number is two letters, five numbers, one letter for(var i = 12; i < 14; i++) { - if(dmi[i] < 0x41 || dmi[i] > 0x5A) - return false; + if(dmi[i] < 0x41 || dmi[i] > 0x5A) return false; } for(var i = 14; i < 19; i++) { - if(dmi[i] < 0x30 || dmi[i] > 0x39) - return false; + if(dmi[i] < 0x30 || dmi[i] > 0x39) return false; } - if(dmi[19] < 0x41 || dmi[19] > 0x5A) - return false; + if(dmi[19] < 0x41 || dmi[19] > 0x5A) return false; var timestamp = BitConverter.ToInt64(dmi, 20); @@ -76,8 +71,7 @@ public static class DMI public static bool IsXbox360(byte[] dmi) { - if(dmi?.Length != 2052) - return false; + if(dmi?.Length != 2052) return false; var signature = BitConverter.ToUInt32(dmi, 0x7EC); @@ -89,8 +83,7 @@ public static class DMI { bool isXbox = IsXbox(response); - if(!isXbox) - return null; + if(!isXbox) return null; var dmi = new XboxDMI { @@ -112,8 +105,7 @@ public static class DMI { bool isX360 = IsXbox360(response); - if(!isX360) - return null; + if(!isX360) return null; var dmi = new Xbox360DMI { @@ -135,21 +127,18 @@ public static class DMI public static string PrettifyXbox(XboxDMI? dmi) { - if(dmi == null) - return null; + if(dmi == null) return null; XboxDMI decoded = dmi.Value; var sb = new StringBuilder(); sb.Append(Localization.Catalogue_number); - for(var i = 0; i < 2; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 0; i < 2; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); - for(var i = 2; i < 7; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 2; i < 7; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); sb.Append($"{decoded.CatalogNumber[7]}"); @@ -162,54 +151,45 @@ public static class DMI public static string PrettifyXbox360(Xbox360DMI? dmi) { - if(dmi == null) - return null; + if(dmi == null) return null; Xbox360DMI decoded = dmi.Value; var sb = new StringBuilder(); sb.Append(Localization.Catalogue_number); - for(var i = 0; i < 2; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 0; i < 2; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); - for(var i = 2; i < 6; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 2; i < 6; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); - for(var i = 6; i < 8; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 6; i < 8; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); switch(decoded.CatalogNumber.Length) { case 13: - for(var i = 8; i < 10; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 8; i < 10; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); - for(var i = 10; i < 13; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 10; i < 13; i++) sb.Append($"{decoded.CatalogNumber[i]}"); break; case 14: - for(var i = 8; i < 11; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 8; i < 11; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); - for(var i = 11; i < 14; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 11; i < 14; i++) sb.Append($"{decoded.CatalogNumber[i]}"); break; default: - for(var i = 8; i < decoded.CatalogNumber.Length - 3; i++) - sb.Append($"{decoded.CatalogNumber[i]}"); + for(var i = 8; i < decoded.CatalogNumber.Length - 3; i++) sb.Append($"{decoded.CatalogNumber[i]}"); sb.Append("-"); @@ -223,13 +203,11 @@ public static class DMI sb.Append(Localization.Media_ID); - for(var i = 0; i < 12; i++) - sb.Append($"{decoded.MediaID[i]:X2}"); + for(var i = 0; i < 12; i++) sb.Append($"{decoded.MediaID[i]:X2}"); sb.Append("-"); - for(var i = 12; i < 16; i++) - sb.Append($"{decoded.MediaID[i]:X2}"); + for(var i = 12; i < 16; i++) sb.Append($"{decoded.MediaID[i]:X2}"); sb.AppendLine(); diff --git a/Aaru.Decoders/Xbox/SS.cs b/Aaru.Decoders/Xbox/SS.cs index 539e78448..7e04f5824 100644 --- a/Aaru.Decoders/Xbox/SS.cs +++ b/Aaru.Decoders/Xbox/SS.cs @@ -45,11 +45,9 @@ public static class SS { public static SecuritySector? Decode(byte[] response) { - if(response == null) - return null; + if(response == null) return null; - if(response.Length < 2048) - return null; + if(response.Length < 2048) return null; var ss = new SecuritySector { @@ -95,10 +93,11 @@ public static class SS { Level = response[770 + i * 11 + 0], ChallengeId = response[770 + i * 11 + 1], - ChallengeValue = (uint)((response[770 + i * 11 + 2] << 24) + - (response[770 + i * 11 + 3] << 16) + - (response[770 + i * 11 + 4] << 8) + - response[770 + i * 11 + 5]), + ChallengeValue = + (uint)((response[770 + i * 11 + 2] << 24) + + (response[770 + i * 11 + 3] << 16) + + (response[770 + i * 11 + 4] << 8) + + response[770 + i * 11 + 5]), ResponseModifier = response[770 + i * 11 + 6], ResponseValue = (uint)((response[770 + i * 11 + 7] << 24) + (response[770 + i * 11 + 8] << 16) + @@ -117,9 +116,10 @@ public static class SS { ss.Extents[i] = new SecuritySectorExtent { - Unknown = (uint)((response[1633 + i * 9 + 0] << 16) + - (response[1633 + i * 9 + 1] << 8) + - response[1633 + i * 9 + 2]), + Unknown = + (uint)((response[1633 + i * 9 + 0] << 16) + + (response[1633 + i * 9 + 1] << 8) + + response[1633 + i * 9 + 2]), StartPSN = (uint)((response[1633 + i * 9 + 3] << 16) + (response[1633 + i * 9 + 4] << 8) + response[1633 + i * 9 + 5]), @@ -133,9 +133,10 @@ public static class SS { ss.ExtentsCopy[i] = new SecuritySectorExtent { - Unknown = (uint)((response[1840 + i * 9 + 0] << 16) + - (response[1840 + i * 9 + 1] << 8) + - response[1840 + i * 9 + 2]), + Unknown = + (uint)((response[1840 + i * 9 + 0] << 16) + + (response[1840 + i * 9 + 1] << 8) + + response[1840 + i * 9 + 2]), StartPSN = (uint)((response[1840 + i * 9 + 3] << 16) + (response[1840 + i * 9 + 4] << 8) + response[1840 + i * 9 + 5]), @@ -150,8 +151,7 @@ public static class SS public static string Prettify(SecuritySector? ss) { - if(ss == null) - return null; + if(ss == null) return null; SecuritySector decoded = ss.Value; var sb = new StringBuilder(); @@ -168,18 +168,18 @@ public static class SS switch(decoded.DiskCategory) { case DiskCategory.DVDPRWDL: - sb.AppendFormat(categorySentence, sizeString, Localization.Xbox_Game_Disc, decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, Localization.Xbox_Game_Disc, decoded.PartVersion) + .AppendLine(); break; case DiskCategory.DVDPRDL: - sb.AppendFormat(categorySentence, sizeString, Localization.Xbox_360_Game_Disc, decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, Localization.Xbox_360_Game_Disc, decoded.PartVersion) + .AppendLine(); break; default: - sb.AppendFormat(categorySentence, sizeString, Localization.unknown_disc_type, decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, Localization.unknown_disc_type, decoded.PartVersion) + .AppendLine(); break; } @@ -212,8 +212,8 @@ public static class SS break; default: sb.AppendFormat(Localization.Disc_maximum_transfer_rate_is_specified_by_unknown_key_0, - decoded.MaximumRate). - AppendLine(); + decoded.MaximumRate) + .AppendLine(); break; } @@ -325,9 +325,10 @@ public static class SS for(var i = 0; i < 16; i++) { - sb.AppendFormat(Localization.Extent_starts_at_PSN_0_and_ends_at_PSN_1, decoded.Extents[i].StartPSN, - decoded.Extents[i].EndPSN). - AppendLine(); + sb.AppendFormat(Localization.Extent_starts_at_PSN_0_and_ends_at_PSN_1, + decoded.Extents[i].StartPSN, + decoded.Extents[i].EndPSN) + .AppendLine(); } return sb.ToString(); diff --git a/Aaru.Decryption/DVD/CSS.cs b/Aaru.Decryption/DVD/CSS.cs index 56869fb0d..c2a95a73a 100644 --- a/Aaru.Decryption/DVD/CSS.cs +++ b/Aaru.Decryption/DVD/CSS.cs @@ -384,13 +384,11 @@ public class CSS /// A DiscKey struct with the decoded key. public static CSS_CPRM.DiscKey? DecodeDiscKey(byte[] response, byte[] busKey) { - if(response.Length != 2052 || busKey.Length != 5) - return null; + if(response.Length != 2052 || busKey.Length != 5) return null; byte[] key = response.Skip(4).Take(2048).ToArray(); - for(uint i = 0; i < key.Length; i++) - key[i] ^= busKey[4 - i % busKey.Length]; + for(uint i = 0; i < key.Length; i++) key[i] ^= busKey[4 - i % busKey.Length]; return new CSS_CPRM.DiscKey { @@ -410,13 +408,11 @@ public class CSS /// A TitleKey struct with the decoded key. public static CSS_CPRM.TitleKey? DecodeTitleKey(byte[] response, byte[] busKey) { - if(response.Length != 12 || busKey.Length != 5) - return null; + if(response.Length != 12 || busKey.Length != 5) return null; byte[] key = response.Skip(5).Take(5).ToArray(); - for(uint i = 0; i < key.Length; i++) - key[i] ^= busKey[4 - i % busKey.Length]; + for(uint i = 0; i < key.Length; i++) key[i] ^= busKey[4 - i % busKey.Length]; return new CSS_CPRM.TitleKey { @@ -446,13 +442,11 @@ public class CSS byte carry = 0; key = new byte[5]; - for(var i = 9; i >= 0; --i) - scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]]; + for(var i = 9; i >= 0; --i) scratch[i] = challenge[_permutationChallenge[(uint)keyType, i]]; var cssVariant = (byte)(keyType == 0 ? variant : _permutationVariant[(uint)keyType - 1, variant]); - for(var i = 5; --i >= 0;) - temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]); + for(var i = 5; --i >= 0;) temp1[i] = (byte)(scratch[5 + i] ^ _secret[i] ^ _encryptTable2[i]); var lfsr0 = (uint)(temp1[0] << 17 | temp1[1] << 9 | (temp1[2] & ~7) << 1 | 8 | temp1[2] & 7); var lfsr1 = (uint)(temp1[3] << 9 | 0x100 | temp1[4]); @@ -618,8 +612,7 @@ public class CSS // we found the correct key. DecryptKey(0, decryptedKey, verificationKey, out byte[] verify); - if(decryptedKey.SequenceEqual(verify)) - return; + if(decryptedKey.SequenceEqual(verify)) return; } } @@ -655,7 +648,10 @@ public class CSS continue; } - Array.Copy(UnscrambleSector(currentKey, currentSector), 0, decryptedBuffer, (int)(i * blockSize), + Array.Copy(UnscrambleSector(currentKey, currentSector), + 0, + decryptedBuffer, + (int)(i * blockSize), blockSize); } @@ -680,23 +676,26 @@ public class CSS for(uint i = 0; i < blocks; i++) { - byte[] currentKey = keyData.Skip((int)(i * 5)).Take(5).ToArray(); + byte[] currentKey = keyData.Skip((int)(i * 5)).Take(5).ToArray(); byte[] currentPrefix = sectorData.Skip((int)(i * 2064)).Take(12).ToArray(); byte[] currentSuffix = sectorData.Skip((int)(2060 + i * 2064)).Take(4).ToArray(); - byte[] currentSector = sectorData.Skip((int)(12 + i * blockSize + (16 * i))).Take((int)blockSize).ToArray(); + byte[] currentSector = sectorData.Skip((int)(12 + i * blockSize + 16 * i)).Take((int)blockSize).ToArray(); Array.Copy(currentPrefix, 0, decryptedBuffer, (int)(i * 2064), 12); Array.Copy(currentSuffix, 0, decryptedBuffer, (int)(2060 + i * 2064), 4); if(!IsEncrypted(cmiData?[i], currentKey, currentSector)) { - Array.Copy(currentSector, 0, decryptedBuffer, (int)(12 + i * blockSize + (16 * i)), blockSize); + Array.Copy(currentSector, 0, decryptedBuffer, (int)(12 + i * blockSize + 16 * i), blockSize); continue; } - Array.Copy(UnscrambleSector(currentKey, currentSector), 0, decryptedBuffer, - (int)(12 + i * blockSize + (16 * i)), blockSize); + Array.Copy(UnscrambleSector(currentKey, currentSector), + 0, + decryptedBuffer, + (int)(12 + i * blockSize + 16 * i), + blockSize); } return decryptedBuffer; @@ -761,16 +760,13 @@ public class CSS static bool IsEncrypted(byte? cmi, byte[]? key, IReadOnlyList sector) { // Only MPEG packets can be encrypted. - if(!Mpeg.IsMpegPacket(sector)) - return false; + if(!Mpeg.IsMpegPacket(sector)) return false; // The CMI tells us the sector is not encrypted. - if(cmi != null && (cmi & 0x80) >> 7 == 0) - return false; + if(cmi != null && (cmi & 0x80) >> 7 == 0) return false; // We have the key but it's all zeroes, so sector is unencrypted. - if(key != null && key.All(static k => k == 0)) - return false; + if(key != null && key.All(static k => k == 0)) return false; // These packet types cannot be encrypted if(sector[17] == (byte)Mpeg.Mpeg2StreamId.SystemHeader || @@ -789,8 +785,7 @@ public class CSS public static bool CheckRegion(CSS_CPRM.RegionalPlaybackControlState rpc, CSS_CPRM.LeadInCopyright cmi) { // if disc region is all or none, we cannot do anything but try to read it as is - if(cmi.RegionInformation is 0xFF or 0x00) - return true; + if(cmi.RegionInformation is 0xFF or 0x00) return true; return (rpc.RegionMask & 0x01) == (cmi.RegionInformation & 0x01) && (rpc.RegionMask & 0x01) != 0x01 || (rpc.RegionMask & 0x02) == (cmi.RegionInformation & 0x02) && (rpc.RegionMask & 0x02) != 0x02 || @@ -822,8 +817,7 @@ public class CSS // Find the number of bytes that repeats in cycles. for(uint j = i + 1; j < 0x80 && sector[0x7F - j % i] == sector[0x7F - j]; j++) { - if(j <= bestPatternLength) - continue; + if(j <= bestPatternLength) continue; bestPatternLength = j; bestPattern = i; @@ -831,14 +825,15 @@ public class CSS } // If we found an adequate pattern. - if(bestPattern <= 0 || bestPatternLength <= 3 || bestPatternLength / bestPattern < 2) - return false; + if(bestPattern <= 0 || bestPatternLength <= 3 || bestPatternLength / bestPattern < 2) return false; var offset = (int)(0x80 - bestPatternLength / bestPattern * bestPattern); - int result = RecoverTitleKey(0, sector.Skip(0x80).Take(sector.Length - 0x80).ToArray(), - sector.Skip(offset).Take(sector.Length - offset).ToArray(), - sector.Skip(0x54).Take(5).ToArray(), out key); + int result = RecoverTitleKey(0, + sector.Skip(0x80).Take(sector.Length - 0x80).ToArray(), + sector.Skip(offset).Take(sector.Length - offset).ToArray(), + sector.Skip(0x54).Take(5).ToArray(), + out key); return result >= 0; } @@ -862,8 +857,7 @@ public class CSS int exit = -1; key = new byte[5]; - for(i = 0; i < 10; i++) - buffer[i] = (byte)(_cssTable1[encryptedBytes[i]] ^ decryptedBytes[i]); + for(i = 0; i < 10; i++) buffer[i] = (byte)(_cssTable1[encryptedBytes[i]] ^ decryptedBytes[i]); for(iTry = start; iTry < 0x10000; iTry++) { @@ -875,6 +869,7 @@ public class CSS // Iterate cipher 4 times to reconstruct LFSR2 long oLfsr1; long oLfsr0; + for(i = 0; i < 4; i++) { // Advance LFSR1 normally @@ -884,11 +879,9 @@ public class CSS oLfsr1 = _cssTable5[oLfsr1]; oLfsr0 = buffer[i]; - if(combined > 0) - oLfsr0 = oLfsr0 + 0xff & 0x0ff; + if(combined > 0) oLfsr0 = oLfsr0 + 0xff & 0x0ff; - if(oLfsr0 < oLfsr1) - oLfsr0 += 0x100; + if(oLfsr0 < oLfsr1) oLfsr0 += 0x100; oLfsr0 -= oLfsr1; combined += oLfsr0 + oLfsr1; @@ -911,14 +904,12 @@ public class CSS oLfsr0 = _cssTable4[oLfsr0]; combined += oLfsr0 + oLfsr1; - if((combined & 0xff) != buffer[i]) - break; + if((combined & 0xff) != buffer[i]) break; combined >>= 8; } - if(i != 10) - continue; + if(i != 10) continue; lfsr0 = candidate; @@ -932,8 +923,7 @@ public class CSS lfsr0 = lfsr0 & 0x1ffff | j << 17; oLfsr0 = (((lfsr0 >> 3 ^ lfsr0) >> 1 ^ lfsr0) >> 8 ^ lfsr0) >> 5 & 0xff; - if(oLfsr0 == lfsr1Lo) - break; + if(oLfsr0 == lfsr1Lo) break; } } @@ -941,8 +931,7 @@ public class CSS for(combined = 0; combined < 8; combined++) { - if((oLfsr1 + combined) * 2 + 8 - (oLfsr1 + combined & 7) != lfsr0) - continue; + if((oLfsr1 + combined) * 2 + 8 - (oLfsr1 + combined & 7) != lfsr0) continue; key[0] = (byte)(iTry >> 8); key[1] = (byte)(iTry & 0xFF); @@ -953,8 +942,7 @@ public class CSS } } - if(exit < 0) - return exit; + if(exit < 0) return exit; key[0] ^= sectorSeed[0]; key[1] ^= sectorSeed[1]; @@ -980,11 +968,9 @@ public class CSS { input.ReadSector(startSector + i, out byte[] sector); - if(!IsEncrypted(null, null, sector)) - continue; + if(!IsEncrypted(null, null, sector)) continue; - if(AttackPattern(sector, out byte[] key)) - return key; + if(AttackPattern(sector, out byte[] key)) return key; } return titleKey; @@ -1005,28 +991,23 @@ public class CSS foreach(Partition partition in partitions) { - if(fs is null) - continue; + if(fs is null) continue; - if(!HasVideoTsFolder(input, fs, partition)) - continue; + if(!HasVideoTsFolder(input, fs, partition)) continue; - if(fs.Mount(input, partition, null, null, null) != ErrorNumber.NoError) - continue; + if(fs.Mount(input, partition, null, null, null) != ErrorNumber.NoError) continue; if(fs.OpenDir("VIDEO_TS", out IDirNode node) == ErrorNumber.NoError) { while(fs.ReadDir(node, out string entry) == ErrorNumber.NoError && entry is not null) { - if(!entry.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) - continue; + if(!entry.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) continue; fs.Stat("VIDEO_TS" + "/" + entry, out FileEntryInfo stat); byte[] key = FindTitleKey(input, stat.Inode); - for(long i = 0; i < stat.Blocks; i++) - key.CopyTo(keys, (long)(5 * (stat.Inode + (ulong)i))); + for(long i = 0; i < stat.Blocks; i++) key.CopyTo(keys, (long)(5 * (stat.Inode + (ulong)i))); } fs.CloseDir(node); @@ -1049,8 +1030,7 @@ public class CSS { ErrorNumber error = fs.Mount(input, partition, null, null, null); - if(error != ErrorNumber.NoError) - return false; + if(error != ErrorNumber.NoError) return false; error = fs.Stat("VIDEO_TS", out FileEntryInfo stat); fs.Unmount(); diff --git a/Aaru.Decryption/DVD/Dump.cs b/Aaru.Decryption/DVD/Dump.cs index a68c25f53..1bd928059 100644 --- a/Aaru.Decryption/DVD/Dump.cs +++ b/Aaru.Decryption/DVD/Dump.cs @@ -73,8 +73,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.REPORT_ASF_AGID_1_Sense_2_Last_Error_3_took_0_ms, duration, - Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.REPORT_ASF_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -101,8 +105,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.REPORT_ASF_AGID_1_Sense_2_Last_Error_3_took_0_ms, duration, - Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.REPORT_ASF_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -129,8 +137,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.INVALIDATE_AGID_AGID_1_Sense_2_Last_Error_3_took_0_ms, - duration, Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.INVALIDATE_AGID_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -157,8 +169,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.REPORT_AGID_CSS_CPPM_AGID_1_Sense_2_Last_Error_3_took_0_ms, - duration, Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.REPORT_AGID_CSS_CPPM_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -185,8 +201,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.REPORT_KEY1_AGID_1_Sense_2_Last_Error_3_took_0_ms, - duration, Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.REPORT_KEY1_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -213,8 +233,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.REPORT_CHALLENGE_AGID_1_Sense_2_Last_Error_3_took_0_ms, - duration, Agid, sense, dev.LastError); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.REPORT_CHALLENGE_AGID_1_Sense_2_Last_Error_3_took_0_ms, + duration, + Agid, + sense, + dev.LastError); return sense; } @@ -256,7 +280,11 @@ public sealed class Dump(Device dev) AaruConsole.DebugWriteLine(MODULE_NAME, Localization.SEND_CHALLENGE_AGID_1_Challenge_2_Sense_3_Last_Error_4_took_0_ms, - duration, Agid, challengeKey, sense, dev.LastError); + duration, + Agid, + challengeKey, + sense, + dev.LastError); return sense; } @@ -292,8 +320,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, out bool sense); AaruConsole.DebugWriteLine(MODULE_NAME, - Localization.SEND_CHALLENGE_AGID_1_KEY2_2_Sense_3_Last_Error_4_took_0_ms, duration, - Agid, key2, sense, dev.LastError); + Localization.SEND_CHALLENGE_AGID_1_KEY2_2_Sense_3_Last_Error_4_took_0_ms, + duration, + Agid, + key2, + sense, + dev.LastError); return sense; } @@ -353,7 +385,10 @@ public sealed class Dump(Device dev) { // Get AGID case CopyrightType.CSS: - sense = ReportAgidCssCppm(out buffer, out senseBuffer, DvdCssKeyClass.DvdCssCppmOrCprm, timeout, + sense = ReportAgidCssCppm(out buffer, + out senseBuffer, + DvdCssKeyClass.DvdCssCppmOrCprm, + timeout, out duration); break; @@ -361,33 +396,31 @@ public sealed class Dump(Device dev) throw new NotImplementedException(); } - if(sense) - continue; + if(sense) continue; Agid = (byte)(buffer[7] >> 6); break; } - if(sense) - return true; + if(sense) return true; - for(byte i = 0; i < CHALLENGE_SIZE; i++) - challenge[i] = i; + for(byte i = 0; i < CHALLENGE_SIZE; i++) challenge[i] = i; - sense = SendChallenge(out buffer, out senseBuffer, DvdCssKeyClass.DvdCssCppmOrCprm, challenge, timeout, + sense = SendChallenge(out buffer, + out senseBuffer, + DvdCssKeyClass.DvdCssCppmOrCprm, + challenge, + timeout, out duration); - if(sense) - return true; + if(sense) return true; sense = ReportKey1(out buffer, out senseBuffer, DvdCssKeyClass.DvdCssCppmOrCprm, timeout, out duration); - if(sense) - return true; + if(sense) return true; - for(byte i = 0; i < KEY_SIZE; i++) - key1[i] = buffer[8 - i]; + for(byte i = 0; i < KEY_SIZE; i++) key1[i] = buffer[8 - i]; for(byte i = 0; i < 32; i++) { @@ -400,8 +433,7 @@ public sealed class Dump(Device dev) break; } - if(i < 31) - continue; + if(i < 31) continue; senseBuffer = Array.Empty(); @@ -410,18 +442,15 @@ public sealed class Dump(Device dev) sense = ReportChallenge(out buffer, out senseBuffer, DvdCssKeyClass.DvdCssCppmOrCprm, timeout, out duration); - if(sense) - return true; + if(sense) return true; - for(byte i = 0; i < CHALLENGE_SIZE; i++) - challenge[i] = buffer[13 - i]; + for(byte i = 0; i < CHALLENGE_SIZE; i++) challenge[i] = buffer[13 - i]; CSS.EncryptKey(DvdCssKeyType.Key2, variant, challenge, out byte[] key2); sense = SendKey2(out buffer, out senseBuffer, DvdCssKeyClass.DvdCssCppmOrCprm, key2, timeout, out duration); - if(sense) - return true; + if(sense) return true; key1.CopyTo(challenge, 0); key2.CopyTo(challenge, key1.Length); @@ -464,8 +493,12 @@ public sealed class Dump(Device dev) dev.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out bool sense); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.GET_TITLE_KEY_AGID_1_LBA_2_Sense_3_took_0_ms, duration, - Agid, address, sense); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.GET_TITLE_KEY_AGID_1_LBA_2_Sense_3_took_0_ms, + duration, + Agid, + address, + sense); return sense; } diff --git a/Aaru.Decryption/DVD/MPEG.cs b/Aaru.Decryption/DVD/MPEG.cs index 42320dd5b..5bbad977b 100644 --- a/Aaru.Decryption/DVD/MPEG.cs +++ b/Aaru.Decryption/DVD/MPEG.cs @@ -140,8 +140,7 @@ public class Mpeg { for(uint i = 0; i < blocks; i++) { - if(IsMpegPacket(sectorData.Skip((int)(i * blockSize)))) - return true; + if(IsMpegPacket(sectorData.Skip((int)(i * blockSize)))) return true; } return false; diff --git a/Aaru.Devices/Device/AtaCommands/Ata28.cs b/Aaru.Devices/Device/AtaCommands/Ata28.cs index d1d3b7f0f..78fc6fb73 100644 --- a/Aaru.Devices/Device/AtaCommands/Ata28.cs +++ b/Aaru.Devices/Device/AtaCommands/Ata28.cs @@ -56,8 +56,15 @@ public partial class Device Command = (byte)AtaCommands.ReadBuffer }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -82,8 +89,15 @@ public partial class Device Command = (byte)AtaCommands.ReadBufferDma }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.Dma, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -130,8 +144,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.Dma, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -168,8 +189,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -197,8 +225,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -254,8 +289,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -302,8 +344,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -333,8 +382,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/Ata48.cs b/Aaru.Devices/Device/AtaCommands/Ata48.cs index 8abdd2c58..b49470e2c 100644 --- a/Aaru.Devices/Device/AtaCommands/Ata48.cs +++ b/Aaru.Devices/Device/AtaCommands/Ata48.cs @@ -56,8 +56,15 @@ public partial class Device Feature = 0x0000 }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -106,8 +113,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.Dma, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -139,8 +153,15 @@ public partial class Device LbaLowCurrent = logAddress }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -172,8 +193,15 @@ public partial class Device LbaLowCurrent = logAddress }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.Dma, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -212,8 +240,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -241,8 +276,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -291,8 +333,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/AtaCHS.cs b/Aaru.Devices/Device/AtaCommands/AtaCHS.cs index 3c0038dfd..f664d5435 100644 --- a/Aaru.Devices/Device/AtaCommands/AtaCHS.cs +++ b/Aaru.Devices/Device/AtaCommands/AtaCHS.cs @@ -83,8 +83,15 @@ public partial class Device SectorCount = 1 }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -133,8 +140,15 @@ public partial class Device Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.Dma, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -171,8 +185,15 @@ public partial class Device Sector = sector }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -221,8 +242,15 @@ public partial class Device Sector = sector }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -271,8 +299,15 @@ public partial class Device Sector = sector }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -303,8 +338,15 @@ public partial class Device Sector = sector }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -349,8 +391,15 @@ public partial class Device Feature = (byte)feature }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -373,8 +422,15 @@ public partial class Device Command = (byte)AtaCommands.DoorLock }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -397,8 +453,15 @@ public partial class Device Command = (byte)AtaCommands.DoorUnLock }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; @@ -421,8 +484,15 @@ public partial class Device Command = (byte)AtaCommands.MediaEject }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/Atapi.cs b/Aaru.Devices/Device/AtaCommands/Atapi.cs index 934cdc029..5cd8a2d10 100644 --- a/Aaru.Devices/Device/AtaCommands/Atapi.cs +++ b/Aaru.Devices/Device/AtaCommands/Atapi.cs @@ -77,8 +77,15 @@ public partial class Device Sector = 1 }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.SectorCount, - ref buffer, timeout, true, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.SectorCount, + ref buffer, + timeout, + true, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/Cfa.cs b/Aaru.Devices/Device/AtaCommands/Cfa.cs index dd490fbdd..681b37c81 100644 --- a/Aaru.Devices/Device/AtaCommands/Cfa.cs +++ b/Aaru.Devices/Device/AtaCommands/Cfa.cs @@ -61,8 +61,15 @@ public partial class Device registers.DeviceHead += 0x40; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -94,8 +101,15 @@ public partial class Device DeviceHead = (byte)(head & 0x0F) }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -120,8 +134,15 @@ public partial class Device Command = (byte)AtaCommands.RequestSense }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/MCPT.cs b/Aaru.Devices/Device/AtaCommands/MCPT.cs index f7e614c5e..6dbb8fe1c 100644 --- a/Aaru.Devices/Device/AtaCommands/MCPT.cs +++ b/Aaru.Devices/Device/AtaCommands/MCPT.cs @@ -79,8 +79,15 @@ public partial class Device Feature = feature }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/AtaCommands/Smart.cs b/Aaru.Devices/Device/AtaCommands/Smart.cs index 1e7c1bfb3..b4e9844dc 100644 --- a/Aaru.Devices/Device/AtaCommands/Smart.cs +++ b/Aaru.Devices/Device/AtaCommands/Smart.cs @@ -55,8 +55,15 @@ public partial class Device LbaMid = 0x4F }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -84,8 +91,15 @@ public partial class Device SectorCount = 0xF1 }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -112,8 +126,15 @@ public partial class Device LbaMid = 0x4F }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -139,8 +160,15 @@ public partial class Device LbaMid = 0x4F }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -169,8 +197,15 @@ public partial class Device LbaLow = subcommand }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -198,8 +233,15 @@ public partial class Device LbaMid = 0x4F }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -229,8 +271,15 @@ public partial class Device LbaLow = logAddress }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.PioIn, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; @@ -256,8 +305,15 @@ public partial class Device LbaMid = 0x4F }; - LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData, AtaTransferRegister.NoTransfer, - ref buffer, timeout, false, out duration, out bool sense); + LastError = SendAtaCommand(registers, + out statusRegisters, + AtaProtocol.NonData, + AtaTransferRegister.NoTransfer, + ref buffer, + timeout, + false, + out duration, + out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index 71166b6d9..354c10a42 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -79,8 +79,7 @@ public partial class Device else errno = ErrorNumber.NotSupported; - if(dev is null) - return null; + if(dev is null) return null; if(dev.Type is DeviceType.SCSI or DeviceType.ATAPI) { @@ -91,25 +90,21 @@ public partial class Device dev.Type = DeviceType.SCSI; bool serialSense = dev.ScsiInquiry(out inqBuf, out _, 0x80); - if(!serialSense) - dev.Serial = EVPD.DecodePage80(inqBuf); + if(!serialSense) dev.Serial = EVPD.DecodePage80(inqBuf); if(inquiry.HasValue) { string tmp = StringHandlers.CToString(inquiry.Value.ProductRevisionLevel); - if(tmp != null) - dev.FirmwareRevision = tmp.Trim(); + if(tmp != null) dev.FirmwareRevision = tmp.Trim(); tmp = StringHandlers.CToString(inquiry.Value.ProductIdentification); - if(tmp != null) - dev.Model = tmp.Trim(); + if(tmp != null) dev.Model = tmp.Trim(); tmp = StringHandlers.CToString(inquiry.Value.VendorIdentification); - if(tmp != null) - dev.Manufacturer = tmp.Trim(); + if(tmp != null) dev.Manufacturer = tmp.Trim(); dev.IsRemovable = inquiry.Value.RMB; @@ -123,8 +118,7 @@ public partial class Device dev.Type = DeviceType.ATAPI; Identify.IdentifyDevice? ataId = Identify.Decode(ataBuf); - if(ataId.HasValue) - dev.Serial = ataId.Value.SerialNumber; + if(ataId.HasValue) dev.Serial = ataId.Value.SerialNumber; } dev.LastError = 0; @@ -180,58 +174,52 @@ public partial class Device if(dev.IsUsb) { - if(string.IsNullOrEmpty(dev.Manufacturer)) - dev.Manufacturer = dev.UsbManufacturerString; + if(string.IsNullOrEmpty(dev.Manufacturer)) dev.Manufacturer = dev.UsbManufacturerString; - if(string.IsNullOrEmpty(dev.Model)) - dev.Model = dev.UsbProductString; + if(string.IsNullOrEmpty(dev.Model)) dev.Model = dev.UsbProductString; if(string.IsNullOrEmpty(dev.Serial)) dev.Serial = dev.UsbSerialString; else { - foreach(char c in dev.Serial.Where(c => !char.IsControl(c))) - dev.Serial = $"{dev.Serial}{c:X2}"; + foreach(char c in dev.Serial.Where(c => !char.IsControl(c))) dev.Serial = $"{dev.Serial}{c:X2}"; } } if(dev.IsFireWire) { - if(string.IsNullOrEmpty(dev.Manufacturer)) - dev.Manufacturer = dev.FireWireVendorName; + if(string.IsNullOrEmpty(dev.Manufacturer)) dev.Manufacturer = dev.FireWireVendorName; - if(string.IsNullOrEmpty(dev.Model)) - dev.Model = dev.FireWireModelName; + if(string.IsNullOrEmpty(dev.Model)) dev.Model = dev.FireWireModelName; if(string.IsNullOrEmpty(dev.Serial)) dev.Serial = $"{dev.FirewireGuid:X16}"; else { - foreach(char c in dev.Serial.Where(c => !char.IsControl(c))) - dev.Serial = $"{dev.Serial}{c:X2}"; + foreach(char c in dev.Serial.Where(c => !char.IsControl(c))) dev.Serial = $"{dev.Serial}{c:X2}"; } } // Some optical drives are not getting the correct serial, and IDENTIFY PACKET DEVICE is blocked without // administrator privileges - if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice) - return dev; + if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice) return dev; - bool featureSense = dev.GetConfiguration(out byte[] featureBuffer, out _, 0x0108, MmcGetConfigurationRt.Single, - dev.Timeout, out _); + bool featureSense = dev.GetConfiguration(out byte[] featureBuffer, + out _, + 0x0108, + MmcGetConfigurationRt.Single, + dev.Timeout, + out _); - if(featureSense) - return dev; + if(featureSense) return dev; Features.SeparatedFeatures features = Features.Separate(featureBuffer); - if(features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108) - return dev; + if(features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108) return dev; Feature_0108? serialFeature = Features.Decode_0108(features.Descriptors[0].Data); - if(serialFeature is null) - return dev; + if(serialFeature is null) return dev; dev.Serial = serialFeature.Value.Serial; diff --git a/Aaru.Devices/Device/List.cs b/Aaru.Devices/Device/List.cs index 4d1d531f6..4e1fb8984 100644 --- a/Aaru.Devices/Device/List.cs +++ b/Aaru.Devices/Device/List.cs @@ -102,11 +102,9 @@ public partial class Device if(aaruRemote is null) { - if(OperatingSystem.IsWindows()) - return Windows.ListDevices.GetList(); + if(OperatingSystem.IsWindows()) return Windows.ListDevices.GetList(); - if(OperatingSystem.IsLinux()) - return Linux.ListDevices.GetList(); + if(OperatingSystem.IsLinux()) return Linux.ListDevices.GetList(); throw new InvalidOperationException(string.Format(Localization.Platform_0_not_yet_supported, DetectOS.GetRealPlatformID())); diff --git a/Aaru.Devices/Device/MmcCommands/MMC.cs b/Aaru.Devices/Device/MmcCommands/MMC.cs index 4ece875ed..c9aa5e2c1 100644 --- a/Aaru.Devices/Device/MmcCommands/MMC.cs +++ b/Aaru.Devices/Device/MmcCommands/MMC.cs @@ -51,9 +51,18 @@ public partial class Device { buffer = new byte[16]; - LastError = SendMmcCommand(MmcCommands.SendCsd, false, false, - MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SendCsd, + false, + false, + MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, + 0, + 16, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -72,9 +81,18 @@ public partial class Device { buffer = new byte[16]; - LastError = SendMmcCommand(MmcCommands.SendCid, false, false, - MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SendCid, + false, + false, + MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, + 0, + 16, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -93,9 +111,18 @@ public partial class Device { buffer = new byte[4]; - LastError = SendMmcCommand(MmcCommands.SendOpCond, false, true, - MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SendOpCond, + false, + true, + MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, + 0, + 4, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -114,9 +141,18 @@ public partial class Device { buffer = new byte[512]; - LastError = SendMmcCommand(MmcCommands.SendExtCsd, false, false, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 512, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SendExtCsd, + false, + false, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + 0, + 512, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -135,9 +171,18 @@ public partial class Device { byte[] buffer = Array.Empty(); - LastError = SendMmcCommand(MmcCommands.SetBlocklen, false, false, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, length, 0, 0, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SetBlocklen, + false, + false, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, + length, + 0, + 0, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -169,14 +214,26 @@ public partial class Device if(!ReadMultipleBlockCannotSetBlockCount) { - sense = ReadMultipleBlock(out buffer, out response, lba, blockSize, transferLength, byteAddressed, timeout, + sense = ReadMultipleBlock(out buffer, + out response, + lba, + blockSize, + transferLength, + byteAddressed, + timeout, out duration); } if(ReadMultipleBlockCannotSetBlockCount) { - return ReadMultipleUsingSingle(out buffer, out response, lba, blockSize, transferLength, byteAddressed, - timeout, out duration); + return ReadMultipleUsingSingle(out buffer, + out response, + lba, + blockSize, + transferLength, + byteAddressed, + timeout, + out duration); } return sense; @@ -203,9 +260,18 @@ public partial class Device else address = lba; - LastError = SendMmcCommand(MmcCommands.ReadSingleBlock, false, false, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address, - blockSize, 1, ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.ReadSingleBlock, + false, + false, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + address, + blockSize, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -236,9 +302,17 @@ public partial class Device else address = lba; - LastError = SendMmcCommand(MmcCommands.ReadMultipleBlock, false, false, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address, - blockSize, transferLength, ref buffer, out response, out duration, out bool sense, + LastError = SendMmcCommand(MmcCommands.ReadMultipleBlock, + false, + false, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + address, + blockSize, + transferLength, + ref buffer, + out response, + out duration, + out bool sense, timeout); Error = LastError != 0; @@ -246,7 +320,8 @@ public partial class Device AaruConsole.DebugWriteLine(MMC_MODULE_NAME, transferLength > 1 ? Localization.READ_MULTIPLE_BLOCK_took_0_ms - : Localization.READ_SINGLE_BLOCK_took_0_ms, duration); + : Localization.READ_SINGLE_BLOCK_took_0_ms, + duration); return sense; } @@ -279,17 +354,24 @@ public partial class Device else address = lba + i; - LastError = SendMmcCommand(MmcCommands.ReadSingleBlock, false, false, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, address, - blockSize, 1, ref blockBuffer, out response, out double blockDuration, out sense, + LastError = SendMmcCommand(MmcCommands.ReadSingleBlock, + false, + false, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + address, + blockSize, + 1, + ref blockBuffer, + out response, + out double blockDuration, + out sense, timeout); Error = LastError != 0; duration += blockDuration; - if(Error || sense) - break; + if(Error || sense) break; Array.Copy(blockBuffer, 0, buffer, i * blockSize, blockSize); } @@ -309,9 +391,18 @@ public partial class Device { buffer = new byte[4]; - LastError = SendMmcCommand(MmcCommands.SendStatus, false, true, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, 0, 4, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand(MmcCommands.SendStatus, + false, + true, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAc, + 0, + 4, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; diff --git a/Aaru.Devices/Device/MmcCommands/SecureDigital.cs b/Aaru.Devices/Device/MmcCommands/SecureDigital.cs index 0bbb417eb..935d2fe9b 100644 --- a/Aaru.Devices/Device/MmcCommands/SecureDigital.cs +++ b/Aaru.Devices/Device/MmcCommands/SecureDigital.cs @@ -46,9 +46,18 @@ public partial class Device { buffer = new byte[64]; - LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, false, true, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 64, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendStatus, + false, + true, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + 0, + 64, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -67,9 +76,18 @@ public partial class Device { buffer = new byte[4]; - LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, false, true, - MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, 4, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendOperatingCondition, + false, + true, + MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, + 0, + 4, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; @@ -88,9 +106,18 @@ public partial class Device { buffer = new byte[8]; - LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, 8, 1, - ref buffer, out response, out duration, out bool sense, timeout); + LastError = SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, + false, + true, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + 0, + 8, + 1, + ref buffer, + out response, + out duration, + out bool sense, + timeout); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs index 7d34a1273..d9e25f287 100644 --- a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs +++ b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs @@ -69,10 +69,14 @@ public partial class Device cdb[2] = (byte)((lba & 0xFF00) >> 8); cdb[3] = (byte)(lba & 0xFF); - if(drive1) - cdb[1] += 0x20; + if(drive1) cdb[1] += 0x20; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -108,12 +112,16 @@ public partial class Device cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold; - if(drive1) - cdb[1] += 0x20; + if(drive1) cdb[1] += 0x20; cdb[4] = 1; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; @@ -146,12 +154,16 @@ public partial class Device cdb[0] = (byte)ScsiCommands.AdaptecTranslate; - if(drive1) - cdb[1] += 0x20; + if(drive1) cdb[1] += 0x20; cdb[4] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -176,7 +188,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer; - LastError = SendScsiCommand(cdb, ref oneKBuffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref oneKBuffer, + out senseBuffer, + timeout, + ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; @@ -199,7 +216,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs b/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs index 3df1f6a27..406b1f794 100644 --- a/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs +++ b/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs @@ -58,12 +58,18 @@ public partial class Device cdb[3] = (byte)(lba & 0xFF); cdb[4] = 3; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.ARCHIVE_CORP_REQUEST_BLOCK_ADDRESS_took_0_ms, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.ARCHIVE_CORP_REQUEST_BLOCK_ADDRESS_took_0_ms, duration); return sense; @@ -95,10 +101,14 @@ public partial class Device cdb[2] = (byte)((lba & 0xFF00) >> 8); cdb[3] = (byte)(lba & 0xFF); - if(immediate) - cdb[1] += 0x01; + if(immediate) cdb[1] += 0x01; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Certance.cs b/Aaru.Devices/Device/ScsiCommands/Certance.cs index 370a7d53b..49a0f4fe2 100644 --- a/Aaru.Devices/Device/ScsiCommands/Certance.cs +++ b/Aaru.Devices/Device/ScsiCommands/Certance.cs @@ -66,10 +66,14 @@ public partial class Device cdb[0] = (byte)ScsiCommands.CertanceParkUnpark; - if(park) - cdb[4] = 1; + if(park) cdb[4] = 1; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs index 55f278988..6867e3767 100644 --- a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs +++ b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs @@ -83,14 +83,11 @@ public partial class Device buffer[0] = (byte)((byte)mode << 5); - if(displayLen) - buffer[0] += 0x10; + if(displayLen) buffer[0] += 0x10; - if(flash) - buffer[0] += 0x08; + if(flash) buffer[0] += 0x08; - if(halfMsg) - buffer[0] += 0x04; + if(halfMsg) buffer[0] += 0x04; buffer[0] += 0x01; // Always ASCII @@ -100,7 +97,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.FujitsuDisplay; cdb[6] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs index 2deeea2ca..5c79a762c 100644 --- a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs +++ b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.Console; @@ -58,7 +57,7 @@ public partial class Device var cdb = new byte[12]; buffer = new byte[2064 * transferLength]; - uint cacheDataOffset = 0x80000000 + (lba % 96 * 2064); + uint cacheDataOffset = 0x80000000 + lba % 96 * 2064; cdb[0] = (byte)ScsiCommands.HlDtStVendor; cdb[1] = 0x48; @@ -72,25 +71,29 @@ public partial class Device cdb[10] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[11] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.HL_DT_ST_READ_DVD_RAW_took_0_ms, duration); - if(!CheckSectorNumber(buffer, lba, transferLength)) - return true; + if(!CheckSectorNumber(buffer, lba, transferLength)) return true; - if(_decoding.Scramble(buffer, transferLength, out byte[] scrambledBuffer) != ErrorNumber.NoError) - return true; + if(_decoding.Scramble(buffer, transferLength, out byte[] scrambledBuffer) != ErrorNumber.NoError) return true; buffer = scrambledBuffer; + return sense; } /// - /// Makes sure the data's sector number is the one expected. + /// Makes sure the data's sector number is the one expected. /// /// Data buffer /// First consecutive LBA of the buffer @@ -98,17 +101,16 @@ public partial class Device /// false if any sector is not matching expected value, else true static bool CheckSectorNumber(IReadOnlyList buffer, uint firstLba, uint transferLength) { - for(int i = 0; i < transferLength; i++) + for(var i = 0; i < transferLength; i++) { byte[] sectorBuffer = { - 0x0, buffer[1 + (2064 * i)], buffer[2 + (2064 * i)], buffer[3 + (2064 * i)] + 0x0, buffer[1 + 2064 * i], buffer[2 + 2064 * i], buffer[3 + 2064 * i] }; - uint sectorNumber = BigEndianBitConverter.ToUInt32(sectorBuffer, 0); + var sectorNumber = BigEndianBitConverter.ToUInt32(sectorBuffer, 0); - if(sectorNumber != firstLba + i + 0x30000) - return false; + if(sectorNumber != firstLba + i + 0x30000) return false; } return true; diff --git a/Aaru.Devices/Device/ScsiCommands/HP.cs b/Aaru.Devices/Device/ScsiCommands/HP.cs index ec05f8c00..1f1e3ccdf 100644 --- a/Aaru.Devices/Device/ScsiCommands/HP.cs +++ b/Aaru.Devices/Device/ScsiCommands/HP.cs @@ -75,8 +75,7 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadLong; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((address & 0xFF000000) >> 24); cdb[3] = (byte)((address & 0xFF0000) >> 16); @@ -85,15 +84,18 @@ public partial class Device cdb[7] = (byte)((transferLen & 0xFF00) >> 8); cdb[8] = (byte)(transferLen & 0xFF); - if(pba) - cdb[9] += 0x80; + if(pba) cdb[9] += 0x80; - if(sectorCount) - cdb[9] += 0x40; + if(sectorCount) cdb[9] += 0x40; buffer = sectorCount ? new byte[blockBytes * transferLen] : new byte[transferLen]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Kreon.cs b/Aaru.Devices/Device/ScsiCommands/Kreon.cs index 5aa5a12ee..292fa1490 100644 --- a/Aaru.Devices/Device/ScsiCommands/Kreon.cs +++ b/Aaru.Devices/Device/ScsiCommands/Kreon.cs @@ -53,7 +53,12 @@ public partial class Device cdb[2] = 0x01; cdb[3] = 0x01; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -105,7 +110,12 @@ public partial class Device cdb[3] = 0x11; cdb[4] = (byte)state; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -134,25 +144,27 @@ public partial class Device cdb[2] = 0x01; cdb[3] = 0x10; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.KREON_GET_FEATURE_LIST_took_0_ms, duration); - if(sense) - return true; + if(sense) return true; - if(buffer[0] != 0xA5 || buffer[1] != 0x5A || buffer[2] != 0x5A || buffer[3] != 0xA5) - return true; + if(buffer[0] != 0xA5 || buffer[1] != 0x5A || buffer[2] != 0x5A || buffer[3] != 0xA5) return true; for(var i = 4; i < 26; i += 2) { var feature = BitConverter.ToUInt16(buffer, i); - if(feature == 0x0000) - break; + if(feature == 0x0000) break; switch(feature) { @@ -229,7 +241,12 @@ public partial class Device cdb[10] = requestNumber; cdb[11] = 0xC0; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/MMC.cs b/Aaru.Devices/Device/ScsiCommands/MMC.cs index 2e917ea2a..a004591b3 100644 --- a/Aaru.Devices/Device/ScsiCommands/MMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/MMC.cs @@ -60,7 +60,11 @@ public partial class Device /// Duration in milliseconds it took for the device to execute the command. public bool GetConfiguration(out byte[] buffer, out byte[] senseBuffer, ushort startingFeatureNumber, uint timeout, out double duration) => - GetConfiguration(out buffer, out senseBuffer, startingFeatureNumber, MmcGetConfigurationRt.All, timeout, + GetConfiguration(out buffer, + out senseBuffer, + startingFeatureNumber, + MmcGetConfigurationRt.All, + timeout, out duration); /// Sends the MMC GET CONFIGURATION command @@ -86,13 +90,17 @@ public partial class Device cdb[8] = (byte)(buffer.Length & 0xFF); cdb[9] = 0; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4); buffer = new byte[confLength]; @@ -100,15 +108,24 @@ public partial class Device cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - GET_CONFIGURATION_Starting_Feature_Number_1_Return_Type_2_Sense_3_Last_Error_4_took_0_ms, - duration, startingFeatureNumber, rt, sense, LastError); + Localization + .GET_CONFIGURATION_Starting_Feature_Number_1_Return_Type_2_Sense_3_Last_Error_4_took_0_ms, + duration, + startingFeatureNumber, + rt, + sense, + LastError); return sense; } @@ -144,13 +161,17 @@ public partial class Device cdb[9] = (byte)(buffer.Length & 0xFF); cdb[10] = (byte)((agid & 0x03) << 6); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); @@ -174,15 +195,27 @@ public partial class Device cdb[9] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_DISC_STRUCTURE_Media_Type_1_Address_2_Layer_Number_3_Format_4_AGID_5_Sense_6_Last_Error_7_took_0_ms, - duration, mediaType, address, layerNumber, format, agid, sense, LastError); + Localization + .READ_DISC_STRUCTURE_Media_Type_1_Address_2_Layer_Number_3_Format_4_AGID_5_Sense_6_Last_Error_7_took_0_ms, + duration, + mediaType, + address, + layerNumber, + format, + agid, + sense, + LastError); return sense; } @@ -286,15 +319,19 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadTocPmaAtip; - if(msf) - cdb[1] = 0x02; + if(msf) cdb[1] = 0x02; cdb[2] = (byte)(format & 0x0F); cdb[6] = trackSessionNumber; cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(tmpBuffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref tmpBuffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -307,16 +344,26 @@ public partial class Device Array.Copy(tmpBuffer, 0, buffer, 0, buffer.Length); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_TOC_PMA_ATIP_took_MSF_1_Format_2_Track_Session_Number_3_Sense_4_LastError_5_0_ms, - duration, msf, format, trackSessionNumber, sense, LastError); + Localization + .READ_TOC_PMA_ATIP_took_MSF_1_Format_2_Track_Session_Number_3_Sense_4_LastError_5_0_ms, + duration, + msf, + format, + trackSessionNumber, + sense, + LastError); return sense; } double tmpDuration = duration; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -324,9 +371,14 @@ public partial class Device duration += tmpDuration; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_TOC_PMA_ATIP_took_MSF_1_Format_2_Track_Session_Number_3_Sense_4_LastError_5_0_ms, - duration, msf, format, trackSessionNumber, sense, LastError); + Localization + .READ_TOC_PMA_ATIP_took_MSF_1_Format_2_Track_Session_Number_3_Sense_4_LastError_5_0_ms, + duration, + msf, + format, + trackSessionNumber, + sense, + LastError); return sense; } @@ -338,7 +390,10 @@ public partial class Device /// Timeout in seconds. /// Duration in milliseconds it took for the device to execute the command. public bool ReadDiscInformation(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => - ReadDiscInformation(out buffer, out senseBuffer, MmcDiscInformationDataTypes.DiscInformation, timeout, + ReadDiscInformation(out buffer, + out senseBuffer, + MmcDiscInformationDataTypes.DiscInformation, + timeout, out duration); /// Sends the MMC READ DISC INFORMATION command @@ -360,22 +415,29 @@ public partial class Device cdb[7] = (byte)((tmpBuffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(tmpBuffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref tmpBuffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); - if(strctLength > tmpBuffer.Length) - strctLength = (uint)tmpBuffer.Length; + if(strctLength > tmpBuffer.Length) strctLength = (uint)tmpBuffer.Length; buffer = new byte[strctLength]; Array.Copy(tmpBuffer, 0, buffer, 0, buffer.Length); AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.READ_DISC_INFORMATION_Data_Type_1_Sense_2_Last_Error_3_took_0_ms, - duration, dataType, sense, LastError); + duration, + dataType, + sense, + LastError); return sense; } @@ -409,11 +471,9 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadCd; cdb[1] = (byte)((byte)expectedSectorType << 2); - if(dap) - cdb[1] += 0x02; + if(dap) cdb[1] += 0x02; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((lba & 0xFF000000) >> 24); cdb[3] = (byte)((lba & 0xFF0000) >> 16); @@ -425,29 +485,44 @@ public partial class Device cdb[9] = (byte)((byte)c2Error << 1); cdb[9] += (byte)((byte)headerCodes << 5); - if(sync) - cdb[9] += 0x80; + if(sync) cdb[9] += 0x80; - if(userData) - cdb[9] += 0x10; + if(userData) cdb[9] += 0x10; - if(edcEcc) - cdb[9] += 0x08; + if(edcEcc) cdb[9] += 0x08; cdb[10] = (byte)subchannel; buffer = new byte[blockSize * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_CD_LBA_1_Block_Size_2_Transfer_Length_3_Expected_Sector_Type_4_DAP_5_Relative_Address_6_Sync_7_Headers_8_User_Data_9_ECC_EDC_10_C2_11_Subchannel_12_Sense_13_Last_Error_14_took_0_ms, - duration, lba, blockSize, transferLength, expectedSectorType, dap, relAddr, sync, - headerCodes, userData, edcEcc, c2Error, subchannel, sense, LastError); + Localization + .READ_CD_LBA_1_Block_Size_2_Transfer_Length_3_Expected_Sector_Type_4_DAP_5_Relative_Address_6_Sync_7_Headers_8_User_Data_9_ECC_EDC_10_C2_11_Subchannel_12_Sense_13_Last_Error_14_took_0_ms, + duration, + lba, + blockSize, + transferLength, + expectedSectorType, + dap, + relAddr, + sync, + headerCodes, + userData, + edcEcc, + c2Error, + subchannel, + sense, + LastError); return sense; } @@ -480,8 +555,7 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadCdMsf; cdb[1] = (byte)((byte)expectedSectorType << 2); - if(dap) - cdb[1] += 0x02; + if(dap) cdb[1] += 0x02; cdb[3] = (byte)((startMsf & 0xFF0000) >> 16); cdb[4] = (byte)((startMsf & 0xFF00) >> 8); @@ -492,14 +566,11 @@ public partial class Device cdb[9] = (byte)((byte)c2Error << 1); cdb[9] += (byte)((byte)headerCodes << 5); - if(sync) - cdb[9] += 0x80; + if(sync) cdb[9] += 0x80; - if(userData) - cdb[9] += 0x10; + if(userData) cdb[9] += 0x10; - if(edcEcc) - cdb[9] += 0x08; + if(edcEcc) cdb[9] += 0x08; cdb[10] = (byte)subchannel; @@ -507,16 +578,33 @@ public partial class Device buffer = new byte[blockSize * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_CD_MSF_Start_MSF_1_End_MSF_2_Block_Size_3_Expected_Sector_Type_4_DAP_5_Sync_6_Headers_7_User_Data_8_ECC_EDC_9_C2_10_Subchannel_11_Sense_12_LastError_13_took_0_ms, - duration, startMsf, endMsf, blockSize, expectedSectorType, dap, sync, headerCodes, - userData, edcEcc, c2Error, subchannel, sense, LastError); + Localization + .READ_CD_MSF_Start_MSF_1_End_MSF_2_Block_Size_3_Expected_Sector_Type_4_DAP_5_Sync_6_Headers_7_User_Data_8_ECC_EDC_9_C2_10_Subchannel_11_Sense_12_LastError_13_took_0_ms, + duration, + startMsf, + endMsf, + blockSize, + expectedSectorType, + dap, + sync, + headerCodes, + userData, + edcEcc, + c2Error, + subchannel, + sense, + LastError); return sense; } @@ -553,21 +641,28 @@ public partial class Device cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval; - if(prevent) - cdb[4] += 0x01; + if(prevent) cdb[4] += 0x01; - if(persistent) - cdb[4] += 0x02; + if(persistent) cdb[4] += 0x02; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - PREVENT_ALLOW_MEDIUM_REMOVAL_Persistent_1_Prevent_2_Sense_3_LastError_4_took_0_ms, - duration, persistent, prevent, sense, LastError); + Localization + .PREVENT_ALLOW_MEDIUM_REMOVAL_Persistent_1_Prevent_2_Sense_3_LastError_4_took_0_ms, + duration, + persistent, + prevent, + sense, + LastError); return sense; } @@ -624,8 +719,7 @@ public partial class Device cdb[0] = (byte)ScsiCommands.StartStopUnit; - if(immediate) - cdb[1] += 0x01; + if(immediate) cdb[1] += 0x01; if(changeFormatLayer) { @@ -634,25 +728,35 @@ public partial class Device } else { - if(loadEject) - cdb[4] += 0x02; + if(loadEject) cdb[4] += 0x02; - if(start) - cdb[4] += 0x01; + if(start) cdb[4] += 0x01; } cdb[4] += (byte)((powerConditions & 0x0F) << 4); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - START_STOP_UNIT_Immediate_1_FormatLayer_2_Power_Conditions_3_Change_Format_Layer_4_Load_Eject_5_Start_6_Sense_7_Last_Error_8_took_0_ms, - duration, immediate, formatLayer, powerConditions, changeFormatLayer, loadEject, - start, sense, LastError); + Localization + .START_STOP_UNIT_Immediate_1_FormatLayer_2_Power_Conditions_3_Change_Format_Layer_4_Load_Eject_5_Start_6_Sense_7_Last_Error_8_took_0_ms, + duration, + immediate, + formatLayer, + powerConditions, + changeFormatLayer, + loadEject, + start, + sense, + LastError); return sense; } @@ -680,17 +784,23 @@ public partial class Device buffer = new byte[23]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms, duration, - sense, LastError); + Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms, + duration, + sense, + LastError); - if(!sense && (buffer[8] & 0x80) == 0x80) - mcn = Encoding.ASCII.GetString(buffer, 9, 13); + if(!sense && (buffer[8] & 0x80) == 0x80) mcn = Encoding.ASCII.GetString(buffer, 9, 13); return sense; } @@ -721,18 +831,25 @@ public partial class Device buffer = new byte[23]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - READ_READ_SUB_CHANNEL_ISRC_Track_Number_1_Sense_2_Last_Error_3_took_0_ms, - duration, trackNumber, sense, LastError); + Localization + .READ_READ_SUB_CHANNEL_ISRC_Track_Number_1_Sense_2_Last_Error_3_took_0_ms, + duration, + trackNumber, + sense, + LastError); - if(!sense && (buffer[8] & 0x80) == 0x80) - isrc = Encoding.ASCII.GetString(buffer, 9, 12); + if(!sense && (buffer[8] & 0x80) == 0x80) isrc = Encoding.ASCII.GetString(buffer, 9, 12); return sense; } @@ -759,15 +876,25 @@ public partial class Device cdb[4] = (byte)((writeSpeed & 0xFF00) >> 8); cdb[5] = (byte)(writeSpeed & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - SET_CD_SPEED_Rotational_Control_1_Read_Speed_2_Write_Speed_3_Sense_4_Last_Error_5_took_0_ms, - duration, rotationalControl, readSpeed, writeSpeed, sense, LastError); + Localization + .SET_CD_SPEED_Rotational_Control_1_Read_Speed_2_Write_Speed_3_Sense_4_Last_Error_5_took_0_ms, + duration, + rotationalControl, + readSpeed, + writeSpeed, + sense, + LastError); return sense; } @@ -797,17 +924,24 @@ public partial class Device cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); - if(open) - cdb[1] += 4; + if(open) cdb[1] += 4; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.READ_TRACK_INFORMATION_Data_Type_1_Sense_2_Last_Error_3_took_0_ms, - duration, type, sense, LastError); + duration, + type, + sense, + LastError); return sense; } diff --git a/Aaru.Devices/Device/ScsiCommands/MediaTek.cs b/Aaru.Devices/Device/ScsiCommands/MediaTek.cs index 5ecb48504..b2ff8f832 100644 --- a/Aaru.Devices/Device/ScsiCommands/MediaTek.cs +++ b/Aaru.Devices/Device/ScsiCommands/MediaTek.cs @@ -62,7 +62,12 @@ public partial class Device cdb[8] = (byte)((length & 0xFF00) >> 8); cdb[9] = (byte)(length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs index 9ac56bcf9..44e31edcf 100644 --- a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs +++ b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs @@ -60,7 +60,12 @@ public partial class Device buffer = new byte[transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -95,7 +100,12 @@ public partial class Device buffer = new byte[transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -124,7 +134,12 @@ public partial class Device buffer = new byte[transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -149,7 +164,12 @@ public partial class Device buffer = Array.Empty(); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -178,7 +198,12 @@ public partial class Device buffer = new byte[transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -207,7 +232,12 @@ public partial class Device buffer = new byte[transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/NEC.cs b/Aaru.Devices/Device/ScsiCommands/NEC.cs index a59ff2de3..12faf373c 100644 --- a/Aaru.Devices/Device/ScsiCommands/NEC.cs +++ b/Aaru.Devices/Device/ScsiCommands/NEC.cs @@ -60,7 +60,12 @@ public partial class Device buffer = new byte[2352 * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Optical.cs b/Aaru.Devices/Device/ScsiCommands/Optical.cs index c023e1754..c2b6fd0fa 100644 --- a/Aaru.Devices/Device/ScsiCommands/Optical.cs +++ b/Aaru.Devices/Device/ScsiCommands/Optical.cs @@ -70,20 +70,15 @@ public partial class Device cdb[0] = (byte)ScsiCommands.MediumScan; - if(written) - cdb[1] += 0x10; + if(written) cdb[1] += 0x10; - if(advancedScan) - cdb[1] += 0x08; + if(advancedScan) cdb[1] += 0x08; - if(reverse) - cdb[1] += 0x04; + if(reverse) cdb[1] += 0x04; - if(partial) - cdb[1] += 0x02; + if(partial) cdb[1] += 0x02; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((lba & 0xFF000000) >> 24); cdb[3] = (byte)((lba & 0xFF0000) >> 16); @@ -104,16 +99,19 @@ public partial class Device cdb[8] = 8; } - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, - buffer.Length == 0 ? ScsiDirection.None : ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + buffer.Length == 0 ? ScsiDirection.None : ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.MEDIUM_SCAN_took_0_ms, duration); - if(Error) - return sense; + if(Error) return sense; DecodedSense? decodedSense = Sense.Decode(senseBuffer); diff --git a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs index d41af5a7a..e9c766a13 100644 --- a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs +++ b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs @@ -64,7 +64,12 @@ public partial class Device buffer = new byte[blockSize * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -102,7 +107,12 @@ public partial class Device var transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5])); buffer = new byte[blockSize * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -156,7 +166,12 @@ public partial class Device cdb[6] = 0x00; } - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Plasmon.cs b/Aaru.Devices/Device/ScsiCommands/Plasmon.cs index b7769d383..7c0a977d4 100644 --- a/Aaru.Devices/Device/ScsiCommands/Plasmon.cs +++ b/Aaru.Devices/Device/ScsiCommands/Plasmon.cs @@ -67,10 +67,17 @@ public partial class Device /// /// Timeout in seconds. /// Duration in milliseconds it took for the device to execute the command. - public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, - ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout, - out double duration) => HpReadLong(out buffer, out senseBuffer, relAddr, address, - transferLen, blockBytes, pba, sectorCount, timeout, + public bool PlasmonReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, + ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout, + out double duration) => HpReadLong(out buffer, + out senseBuffer, + relAddr, + address, + transferLen, + blockBytes, + pba, + sectorCount, + timeout, out duration); /// Retrieves the logical or physical block address for the specified @@ -93,12 +100,16 @@ public partial class Device cdb[4] = (byte)((address & 0xFF00) >> 8); cdb[5] = (byte)(address & 0xFF); - if(pba) - cdb[9] += 0x80; + if(pba) cdb[9] += 0x80; buffer = new byte[8]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Plextor.cs b/Aaru.Devices/Device/ScsiCommands/Plextor.cs index 1aaf9f7d8..d52f6c134 100644 --- a/Aaru.Devices/Device/ScsiCommands/Plextor.cs +++ b/Aaru.Devices/Device/ScsiCommands/Plextor.cs @@ -66,15 +66,26 @@ public partial class Device buffer = new byte[blockSize * transferLength]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, - Localization. - Plextor_READ_CD_DA_LBA_1_Block_Size_2_Transfer_Length_3_Subchannel_4_Sense_5_Last_Error_6_took_0_ms, - duration, lba, blockSize, transferLength, subchannel, sense, LastError); + Localization + .Plextor_READ_CD_DA_LBA_1_Block_Size_2_Transfer_Length_3_Subchannel_4_Sense_5_Last_Error_6_took_0_ms, + duration, + lba, + blockSize, + transferLength, + subchannel, + sense, + LastError); return sense; } @@ -103,7 +114,12 @@ public partial class Device cdb[4] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[5] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -128,7 +144,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 1; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -153,7 +174,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 2; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -184,7 +210,12 @@ public partial class Device cdb[8] = (byte)((blockSize & 0xFF00) >> 8); cdb[9] = (byte)(blockSize & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -216,15 +247,19 @@ public partial class Device cdb[0] = (byte)ScsiCommands.PlextorPoweRec; cdb[9] = (byte)buf.Length; - LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buf, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.PLEXTOR_POWEREC_GET_SPEEDS_took_0_ms, duration); - if(sense || Error) - return sense; + if(sense || Error) return sense; selected = BigEndianBitConverter.ToUInt16(buf, 4); max = BigEndianBitConverter.ToUInt16(buf, 6); @@ -254,15 +289,19 @@ public partial class Device cdb[1] = (byte)PlextorSubCommands.GetMode; cdb[9] = (byte)buf.Length; - LastError = SendScsiCommand(cdb, ref buf, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buf, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.PLEXTOR_POWEREC_GET_SPEEDS_took_0_ms, duration); - if(sense || Error) - return sense; + if(sense || Error) return sense; enabled = buf[2] != 0; speed = BigEndianBitConverter.ToUInt16(buf, 4); @@ -288,7 +327,12 @@ public partial class Device cdb[3] = 4; cdb[10] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -315,7 +359,12 @@ public partial class Device cdb[2] = (byte)PlextorSubCommands.GigaRec; cdb[10] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -349,7 +398,12 @@ public partial class Device else cdb[3] = 0x02; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -375,7 +429,12 @@ public partial class Device cdb[2] = (byte)PlextorSubCommands.SecuRec; cdb[10] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -402,7 +461,12 @@ public partial class Device cdb[2] = (byte)PlextorSubCommands.SpeedRead; cdb[10] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -429,12 +493,18 @@ public partial class Device cdb[2] = (byte)PlextorSubCommands.SessionHide; cdb[9] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, Localization.PLEXTOR_GET_SINGLE_SESSION_HIDE_CD_R_took_0_ms, + AaruConsole.DebugWriteLine(SCSI_MODULE_NAME, + Localization.PLEXTOR_GET_SINGLE_SESSION_HIDE_CD_R_took_0_ms, duration); return sense; @@ -464,7 +534,12 @@ public partial class Device else cdb[3] = (byte)PlextorSubCommands.BitSetR; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -491,7 +566,12 @@ public partial class Device cdb[2] = (byte)PlextorSubCommands.TestWriteDvdPlus; cdb[10] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SBC.cs b/Aaru.Devices/Device/ScsiCommands/SBC.cs index 29fa56965..9726e74ac 100644 --- a/Aaru.Devices/Device/ScsiCommands/SBC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SBC.cs @@ -72,7 +72,12 @@ public partial class Device buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -113,17 +118,13 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read10; cdb[1] = (byte)((rdprotect & 0x07) << 5); - if(dpo) - cdb[1] += 0x10; + if(dpo) cdb[1] += 0x10; - if(fua) - cdb[1] += 0x08; + if(fua) cdb[1] += 0x08; - if(fuaNv) - cdb[1] += 0x02; + if(fuaNv) cdb[1] += 0x02; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((lba & 0xFF000000) >> 24); cdb[3] = (byte)((lba & 0xFF0000) >> 16); @@ -135,7 +136,12 @@ public partial class Device buffer = new byte[transferLength * blockSize]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -177,17 +183,13 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read12; cdb[1] = (byte)((rdprotect & 0x07) << 5); - if(dpo) - cdb[1] += 0x10; + if(dpo) cdb[1] += 0x10; - if(fua) - cdb[1] += 0x08; + if(fua) cdb[1] += 0x08; - if(fuaNv) - cdb[1] += 0x02; + if(fuaNv) cdb[1] += 0x02; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((lba & 0xFF000000) >> 24); cdb[3] = (byte)((lba & 0xFF0000) >> 16); @@ -199,12 +201,16 @@ public partial class Device cdb[9] = (byte)(transferLength & 0xFF); cdb[10] = (byte)(groupNumber & 0x1F); - if(streaming) - cdb[10] += 0x80; + if(streaming) cdb[10] += 0x80; buffer = new byte[transferLength * blockSize]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -246,14 +252,11 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read16; cdb[1] = (byte)((rdprotect & 0x07) << 5); - if(dpo) - cdb[1] += 0x10; + if(dpo) cdb[1] += 0x10; - if(fua) - cdb[1] += 0x08; + if(fua) cdb[1] += 0x08; - if(fuaNv) - cdb[1] += 0x02; + if(fuaNv) cdb[1] += 0x02; cdb[2] = lbaBytes[7]; cdb[3] = lbaBytes[6]; @@ -269,12 +272,16 @@ public partial class Device cdb[13] = (byte)(transferLength & 0xFF); cdb[14] = (byte)(groupNumber & 0x1F); - if(streaming) - cdb[14] += 0x80; + if(streaming) cdb[14] += 0x80; buffer = new byte[transferLength * blockSize]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -305,11 +312,9 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadLong; - if(correct) - cdb[1] += 0x02; + if(correct) cdb[1] += 0x02; - if(relAddr) - cdb[1] += 0x01; + if(relAddr) cdb[1] += 0x01; cdb[2] = (byte)((lba & 0xFF000000) >> 24); cdb[3] = (byte)((lba & 0xFF0000) >> 16); @@ -320,7 +325,12 @@ public partial class Device buffer = new byte[transferBytes]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -362,12 +372,16 @@ public partial class Device cdb[12] = (byte)((transferBytes & 0xFF00) >> 8); cdb[13] = (byte)(transferBytes & 0xFF); - if(correct) - cdb[14] += 0x01; + if(correct) cdb[14] += 0x01; buffer = new byte[transferBytes]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -393,7 +407,12 @@ public partial class Device cdb[2] = (byte)((lba & 0xFF00) >> 8); cdb[3] = (byte)(lba & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -420,7 +439,12 @@ public partial class Device cdb[4] = (byte)((lba & 0xFF00) >> 8); cdb[5] = (byte)(lba & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SMC.cs b/Aaru.Devices/Device/ScsiCommands/SMC.cs index e82c71d02..f30954e8b 100644 --- a/Aaru.Devices/Device/ScsiCommands/SMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SMC.cs @@ -70,16 +70,19 @@ public partial class Device cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[13] = (byte)(buffer.Length & 0xFF); - if(cache) - cdb[14] += 0x01; + if(cache) cdb[14] += 0x01; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[attrLen]; @@ -89,7 +92,12 @@ public partial class Device cdb[13] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SPC.cs b/Aaru.Devices/Device/ScsiCommands/SPC.cs index 9c2f22722..e594ea566 100644 --- a/Aaru.Devices/Device/ScsiCommands/SPC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SPC.cs @@ -82,13 +82,17 @@ public partial class Device (byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0 }; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var pagesLength = (byte)(buffer[4] + 5); @@ -100,7 +104,12 @@ public partial class Device buffer = new byte[pagesLength]; senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -159,17 +168,20 @@ public partial class Device (byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0 }; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; // This is because INQ was returned instead of EVPD - if(buffer[1] != page) - return true; + if(buffer[1] != page) return true; var pagesLength = (byte)(buffer[3] + 4); @@ -181,7 +193,12 @@ public partial class Device buffer = new byte[pagesLength]; senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -207,7 +224,12 @@ public partial class Device byte[] buffer = Array.Empty(); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -258,8 +280,7 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ModeSense; - if(dbd) - cdb[1] = 0x08; + if(dbd) cdb[1] = 0x08; cdb[2] |= (byte)pageControl; cdb[2] |= (byte)(pageCode & 0x3F); @@ -267,23 +288,31 @@ public partial class Device cdb[4] = (byte)buffer.Length; cdb[5] = 0; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var modeLength = (byte)(buffer[0] + 1); - if(modeLength % 2 != 0) - modeLength++; + if(modeLength % 2 != 0) modeLength++; buffer = new byte[modeLength]; cdb[4] = (byte)buffer.Length; senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -341,11 +370,9 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ModeSense10; - if(llbaa) - cdb[1] |= 0x10; + if(llbaa) cdb[1] |= 0x10; - if(dbd) - cdb[1] |= 0x08; + if(dbd) cdb[1] |= 0x08; cdb[2] |= (byte)pageControl; cdb[2] |= (byte)(pageCode & 0x3F); @@ -354,24 +381,32 @@ public partial class Device cdb[8] = (byte)(buffer.Length & 0xFF); cdb[9] = 0; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); - if(modeLength % 2 != 0) - modeLength++; + if(modeLength % 2 != 0) modeLength++; buffer = new byte[modeLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -424,7 +459,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval; cdb[4] = (byte)((byte)preventMode & 0x03); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -465,8 +505,7 @@ public partial class Device { cdb[8] = 0x01; - if(relAddr) - cdb[1] = 0x01; + if(relAddr) cdb[1] = 0x01; cdb[2] = (byte)((address & 0xFF000000) >> 24); cdb[3] = (byte)((address & 0xFF0000) >> 16); @@ -474,7 +513,12 @@ public partial class Device cdb[5] = (byte)(address & 0xFF); } - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -530,7 +574,12 @@ public partial class Device cdb[12] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[13] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -559,13 +608,17 @@ public partial class Device cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[9] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[strctLength]; @@ -575,7 +628,12 @@ public partial class Device cdb[9] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -596,7 +654,16 @@ public partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition, ushort firstAttribute, bool cache, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, cache, timeout, + ReadAttribute(out buffer, + out senseBuffer, + action, + 0, + 0, + 0, + partition, + firstAttribute, + cache, + timeout, out duration); /// Reads an attribute from the medium auxiliary memory @@ -621,7 +688,16 @@ public partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte partition, ushort firstAttribute, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, partition, firstAttribute, false, timeout, + ReadAttribute(out buffer, + out senseBuffer, + action, + 0, + 0, + 0, + partition, + firstAttribute, + false, + timeout, out duration); /// Reads an attribute from the medium auxiliary memory @@ -646,7 +722,16 @@ public partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume, byte partition, ushort firstAttribute, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, false, timeout, + ReadAttribute(out buffer, + out senseBuffer, + action, + 0, + 0, + volume, + partition, + firstAttribute, + false, + timeout, out duration); /// Reads an attribute from the medium auxiliary memory @@ -661,7 +746,16 @@ public partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, byte volume, byte partition, ushort firstAttribute, bool cache, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, cache, timeout, + ReadAttribute(out buffer, + out senseBuffer, + action, + 0, + 0, + volume, + partition, + firstAttribute, + cache, + timeout, out duration); /// Sends the SPC MODE SELECT(6) command @@ -700,15 +794,18 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ModeSelect; - if(pageFormat) - cdb[1] += 0x10; + if(pageFormat) cdb[1] += 0x10; - if(savePages) - cdb[1] += 0x01; + if(savePages) cdb[1] += 0x01; cdb[4] = (byte)buffer.Length; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; @@ -754,16 +851,19 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ModeSelect10; - if(pageFormat) - cdb[1] += 0x10; + if(pageFormat) cdb[1] += 0x10; - if(savePages) - cdb[1] += 0x01; + if(savePages) cdb[1] += 0x01; cdb[7] = (byte)((buffer.Length & 0xFF00) << 8); cdb[8] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.Out, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.Out, + out duration, out bool sense); Error = LastError != 0; @@ -794,8 +894,7 @@ public partial class Device cdb[0] = (byte)ScsiCommands.RequestSense; - if(descriptor) - cdb[1] = 0x01; + if(descriptor) cdb[1] = 0x01; cdb[2] = 0; cdb[3] = 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SSC.cs b/Aaru.Devices/Device/ScsiCommands/SSC.cs index 244c33432..ccb20f4ef 100644 --- a/Aaru.Devices/Device/ScsiCommands/SSC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SSC.cs @@ -79,22 +79,22 @@ public partial class Device cdb[0] = (byte)ScsiCommands.LoadUnload; - if(immediate) - cdb[1] = 0x01; + if(immediate) cdb[1] = 0x01; - if(load) - cdb[4] += 0x01; + if(load) cdb[4] += 0x01; - if(retense) - cdb[4] += 0x02; + if(retense) cdb[4] += 0x02; - if(endOfTape) - cdb[4] += 0x04; + if(endOfTape) cdb[4] += 0x04; - if(hold) - cdb[4] += 0x08; + if(hold) cdb[4] += 0x08; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -138,7 +138,13 @@ public partial class Device /// Timeout. /// Duration. public bool Locate(out byte[] senseBuffer, bool immediate, byte partition, uint lba, uint timeout, - out double duration) => Locate(out senseBuffer, immediate, false, false, partition, lba, timeout, + out double duration) => Locate(out senseBuffer, + immediate, + false, + false, + partition, + lba, + timeout, out duration); /// Positions the medium to the specified object identifier @@ -159,14 +165,11 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Locate; - if(immediate) - cdb[1] += 0x01; + if(immediate) cdb[1] += 0x01; - if(changePartition) - cdb[1] += 0x02; + if(changePartition) cdb[1] += 0x02; - if(blockType) - cdb[1] += 0x04; + if(blockType) cdb[1] += 0x04; cdb[3] = (byte)((objectId & 0xFF000000) >> 24); cdb[4] = (byte)((objectId & 0xFF0000) >> 16); @@ -174,7 +177,12 @@ public partial class Device cdb[6] = (byte)(objectId & 0xFF); cdb[8] = partition; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -199,7 +207,14 @@ public partial class Device /// Timeout. /// Duration. public bool Locate16(out byte[] senseBuffer, byte partition, ulong lba, uint timeout, out double duration) => - Locate16(out senseBuffer, false, false, SscLogicalIdTypes.ObjectId, false, partition, lba, timeout, + Locate16(out senseBuffer, + false, + false, + SscLogicalIdTypes.ObjectId, + false, + partition, + lba, + timeout, out duration); /// Positions the medium to the specified block in the current partition @@ -219,8 +234,15 @@ public partial class Device /// Timeout. /// Duration. public bool Locate16(out byte[] senseBuffer, bool immediate, byte partition, ulong lba, uint timeout, - out double duration) => Locate16(out senseBuffer, immediate, false, SscLogicalIdTypes.ObjectId, - false, partition, lba, timeout, out duration); + out double duration) => Locate16(out senseBuffer, + immediate, + false, + SscLogicalIdTypes.ObjectId, + false, + partition, + lba, + timeout, + out duration); /// Positions the medium to the specified object identifier /// Sense buffer. @@ -243,14 +265,11 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Locate16; cdb[1] = (byte)((byte)destType << 3); - if(immediate) - cdb[1] += 0x01; + if(immediate) cdb[1] += 0x01; - if(changePartition) - cdb[1] += 0x02; + if(changePartition) cdb[1] += 0x02; - if(bam) - cdb[2] = 0x01; + if(bam) cdb[2] = 0x01; cdb[3] = partition; @@ -263,7 +282,12 @@ public partial class Device cdb[10] = idBytes[1]; cdb[11] = idBytes[0]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -295,9 +319,15 @@ public partial class Device /// Block size in bytes. /// Timeout. /// Duration. - public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize, - uint timeout, out double duration) => Read6(out buffer, out senseBuffer, sili, false, transferLen, - blockSize, timeout, out duration); + public bool Read6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize, + uint timeout, out double duration) => Read6(out buffer, + out senseBuffer, + sili, + false, + transferLen, + blockSize, + timeout, + out duration); /// Reads the specified number of bytes or of blocks from the medium /// Buffer. @@ -323,17 +353,20 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read6; - if(fixedLen) - cdb[1] += 0x01; + if(fixedLen) cdb[1] += 0x01; - if(sili) - cdb[1] += 0x02; + if(sili) cdb[1] += 0x02; cdb[2] = (byte)((transferLen & 0xFF0000) >> 16); cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -379,8 +412,15 @@ public partial class Device /// Timeout. /// Duration. public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize, - uint timeout, out double duration) => Read16(out buffer, out senseBuffer, false, true, 0, - objectId, blocks, blockSize, timeout, + uint timeout, out double duration) => Read16(out buffer, + out senseBuffer, + false, + true, + 0, + objectId, + blocks, + blockSize, + timeout, out duration); /// Reads a number of fixed-length blocks starting at specified block from the specified partition @@ -423,11 +463,9 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read16; - if(fixedLen) - cdb[1] += 0x01; + if(fixedLen) cdb[1] += 0x01; - if(sili) - cdb[1] += 0x02; + if(sili) cdb[1] += 0x02; cdb[3] = partition; cdb[4] = idBytes[7]; @@ -442,7 +480,12 @@ public partial class Device cdb[13] = (byte)((transferLen & 0xFF00) >> 8); cdb[14] = (byte)(transferLen & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -465,7 +508,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadBlockLimits; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -504,14 +552,11 @@ public partial class Device { byte responseForm = 0; - if(vendorType) - responseForm += 0x01; + if(vendorType) responseForm += 0x01; - if(longForm) - responseForm += 0x02; + if(longForm) responseForm += 0x02; - if(totalPosition) - responseForm += 0x04; + if(totalPosition) responseForm += 0x04; return ReadPosition(out buffer, out senseBuffer, (SscPositionForms)responseForm, timeout, out duration); } @@ -560,7 +605,12 @@ public partial class Device cdb[8] = (byte)(buffer.Length & 0xFF); } - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -578,8 +628,15 @@ public partial class Device /// Timeout. /// Duration. public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, uint blocks, uint blockSize, uint timeout, - out double duration) => ReadReverse6(out buffer, out senseBuffer, false, false, true, - blocks, blockSize, timeout, out duration); + out double duration) => ReadReverse6(out buffer, + out senseBuffer, + false, + false, + true, + blocks, + blockSize, + timeout, + out duration); /// Reads the specified number of bytes or of blocks from the medium, backwards /// Buffer. @@ -618,20 +675,22 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReadReverse; - if(fixedLen) - cdb[1] += 0x01; + if(fixedLen) cdb[1] += 0x01; - if(sili) - cdb[1] += 0x02; + if(sili) cdb[1] += 0x02; - if(byteOrder) - cdb[1] += 0x04; + if(byteOrder) cdb[1] += 0x04; cdb[2] = (byte)((transferLen & 0xFF0000) >> 16); cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -652,7 +711,16 @@ public partial class Device /// Duration. public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - ReadReverse16(out buffer, out senseBuffer, false, sili, false, 0, objectId, blocks, blockSize, timeout, + ReadReverse16(out buffer, + out senseBuffer, + false, + sili, + false, + 0, + objectId, + blocks, + blockSize, + timeout, out duration); /// Reads a number of fixed-length blocks starting at specified block from the specified partition, backwards @@ -667,7 +735,16 @@ public partial class Device /// Duration. public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - ReadReverse16(out buffer, out senseBuffer, false, sili, false, partition, objectId, blocks, blockSize, timeout, + ReadReverse16(out buffer, + out senseBuffer, + false, + sili, + false, + partition, + objectId, + blocks, + blockSize, + timeout, out duration); /// Reads a number of fixed-length blocks starting at specified object, backwards @@ -680,7 +757,16 @@ public partial class Device /// Duration. public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - ReadReverse16(out buffer, out senseBuffer, false, false, true, 0, objectId, blocks, blockSize, timeout, + ReadReverse16(out buffer, + out senseBuffer, + false, + false, + true, + 0, + objectId, + blocks, + blockSize, + timeout, out duration); /// Reads a number of fixed-length blocks starting at specified block from the specified partition, backwards @@ -694,7 +780,16 @@ public partial class Device /// Duration. public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - ReadReverse16(out buffer, out senseBuffer, false, false, true, partition, objectId, blocks, blockSize, timeout, + ReadReverse16(out buffer, + out senseBuffer, + false, + false, + true, + partition, + objectId, + blocks, + blockSize, + timeout, out duration); /// Reads a number of bytes or objects starting at specified object from the specified partition, backwards @@ -726,14 +821,11 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Read16; - if(fixedLen) - cdb[1] += 0x01; + if(fixedLen) cdb[1] += 0x01; - if(sili) - cdb[1] += 0x02; + if(sili) cdb[1] += 0x02; - if(byteOrder) - cdb[1] += 0x04; + if(byteOrder) cdb[1] += 0x04; cdb[3] = partition; cdb[4] = idBytes[7]; @@ -748,7 +840,12 @@ public partial class Device cdb[13] = (byte)((transferLen & 0xFF00) >> 8); cdb[14] = (byte)(transferLen & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -805,17 +902,20 @@ public partial class Device cdb[0] = (byte)ScsiCommands.RecoverBufferedData; - if(fixedLen) - cdb[1] += 0x01; + if(fixedLen) cdb[1] += 0x01; - if(sili) - cdb[1] += 0x02; + if(sili) cdb[1] += 0x02; cdb[2] = (byte)((transferLen & 0xFF0000) >> 16); cdb[3] = (byte)((transferLen & 0xFF00) >> 8); cdb[4] = (byte)(transferLen & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; @@ -859,22 +959,24 @@ public partial class Device cdb[0] = (byte)ScsiCommands.ReportDensitySupport; - if(currentMedia) - cdb[1] += 0x01; + if(currentMedia) cdb[1] += 0x01; - if(mediumType) - cdb[1] += 0x02; + if(mediumType) cdb[1] += 0x02; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out bool sense); Error = LastError != 0; - if(sense) - return true; + if(sense) return true; var availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); buffer = new byte[availableLength]; @@ -882,7 +984,12 @@ public partial class Device cdb[8] = (byte)(buffer.Length & 0xFF); senseBuffer = new byte[64]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); Error = LastError != 0; @@ -912,10 +1019,14 @@ public partial class Device cdb[0] = (byte)ScsiCommands.Rewind; - if(immediate) - cdb[1] += 0x01; + if(immediate) cdb[1] += 0x01; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -940,7 +1051,12 @@ public partial class Device cdb[0] = (byte)ScsiCommands.TrackSelect; cdb[5] = track; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; @@ -970,7 +1086,12 @@ public partial class Device cdb[3] = countB[1]; cdb[4] = countB[0]; - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SyQuest.cs b/Aaru.Devices/Device/ScsiCommands/SyQuest.cs index 63d9b2af1..fdd7a7558 100644 --- a/Aaru.Devices/Device/ScsiCommands/SyQuest.cs +++ b/Aaru.Devices/Device/ScsiCommands/SyQuest.cs @@ -48,8 +48,15 @@ public partial class Device /// Starting block. /// Block size in bytes. public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, uint timeout, - out double duration) => SyQuestRead6(out buffer, out senseBuffer, lba, blockSize, 1, false, - false, timeout, out duration); + out double duration) => SyQuestRead6(out buffer, + out senseBuffer, + lba, + blockSize, + 1, + false, + false, + timeout, + out duration); /// Sends the SyQuest READ LONG (6) command /// true if the command failed and contains the sense buffer. @@ -87,11 +94,9 @@ public partial class Device cdb[3] = (byte)(lba & 0xFF); cdb[4] = transferLength; - if(inhibitDma) - cdb[5] += 0x80; + if(inhibitDma) cdb[5] += 0x80; - if(readLong) - cdb[5] += 0x40; + if(readLong) cdb[5] += 0x40; if(!inhibitDma && !readLong) buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize]; @@ -105,12 +110,22 @@ public partial class Device if(!inhibitDma) { - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); } else { - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out sense); } @@ -167,11 +182,9 @@ public partial class Device cdb[7] = (byte)((transferLength & 0xFF00) >> 8); cdb[8] = (byte)(transferLength & 0xFF); - if(inhibitDma) - cdb[9] += 0x80; + if(inhibitDma) cdb[9] += 0x80; - if(readLong) - cdb[9] += 0x40; + if(readLong) cdb[9] += 0x40; if(!inhibitDma && !readLong) buffer = new byte[transferLength * blockSize]; @@ -185,12 +198,22 @@ public partial class Device if(!inhibitDma) { - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.In, + out duration, out sense); } else { - LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, + LastError = SendScsiCommand(cdb, + ref buffer, + out senseBuffer, + timeout, + ScsiDirection.None, + out duration, out sense); } diff --git a/Aaru.Devices/Linux/Command.cs b/Aaru.Devices/Linux/Command.cs index 58d4fc373..502019663 100644 --- a/Aaru.Devices/Linux/Command.cs +++ b/Aaru.Devices/Linux/Command.cs @@ -47,15 +47,13 @@ partial class Device ScsiDirection direction, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; senseBuffer = null; duration = 0; sense = false; - if(buffer == null) - return -1; + if(buffer == null) return -1; ScsiIoctlDirection dir = direction switch { @@ -90,8 +88,7 @@ partial class Device int error = Extern.ioctlSg(_fileDescriptor, LinuxIoctl.SgIo, ref ioHdr); cmdStopWatch.Stop(); - if(error < 0) - error = Marshal.GetLastWin32Error(); + if(error < 0) error = Marshal.GetLastWin32Error(); Marshal.Copy(ioHdr.dxferp, buffer, 0, buffer.Length); Marshal.Copy(ioHdr.cmdp, cdb, 0, cdb.Length); @@ -139,15 +136,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersChs(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; @@ -168,8 +163,7 @@ partial class Device break; } - if(transferBlocks) - cdb[2] |= 0x04; + if(transferBlocks) cdb[2] |= 0x04; cdb[2] |= (byte)((int)transferRegister & 0x03); } @@ -184,11 +178,15 @@ partial class Device cdb[13] = registers.DeviceHead; cdb[14] = registers.Command; - int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout, - AtaProtocolToScsiDirection(protocol), out duration, out sense); + int error = SendScsiCommand(cdb, + ref buffer, + out byte[] senseBuffer, + timeout, + AtaProtocolToScsiDirection(protocol), + out duration, + out sense); - if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) - return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -210,15 +208,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersLba28(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; @@ -239,8 +235,7 @@ partial class Device break; } - if(transferBlocks) - cdb[2] |= 0x04; + if(transferBlocks) cdb[2] |= 0x04; cdb[2] |= (byte)((int)transferRegister & 0x03); } @@ -255,11 +250,15 @@ partial class Device cdb[13] = registers.DeviceHead; cdb[14] = registers.Command; - int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout, - AtaProtocolToScsiDirection(protocol), out duration, out sense); + int error = SendScsiCommand(cdb, + ref buffer, + out byte[] senseBuffer, + timeout, + AtaProtocolToScsiDirection(protocol), + out duration, + out sense); - if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) - return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -281,15 +280,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersLba48(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; @@ -311,8 +308,7 @@ partial class Device break; } - if(transferBlocks) - cdb[2] |= 0x04; + if(transferBlocks) cdb[2] |= 0x04; cdb[2] |= (byte)((int)transferRegister & 0x03); } @@ -332,11 +328,15 @@ partial class Device cdb[13] = registers.DeviceHead; cdb[14] = registers.Command; - int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout, - AtaProtocolToScsiDirection(protocol), out duration, out sense); + int error = SendScsiCommand(cdb, + ref buffer, + out byte[] senseBuffer, + timeout, + AtaProtocolToScsiDirection(protocol), + out duration, + out sense); - if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) - return error; + if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -363,8 +363,7 @@ partial class Device out uint[] response, out double duration, out bool sense, uint timeout = 15) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; var cmdStopwatch = new Stopwatch(); @@ -425,8 +424,7 @@ partial class Device duration = 0; sense = false; - if(buffer == null) - return -1; + if(buffer == null) return -1; var ioCmd = new MmcIocCmd(); @@ -457,8 +455,7 @@ partial class Device sense |= error < 0; - if(error < 0) - error = Marshal.GetLastWin32Error(); + if(error < 0) error = Marshal.GetLastWin32Error(); Marshal.Copy(bufPtr, buffer, 0, buffer.Length); @@ -475,8 +472,7 @@ partial class Device uint timeout = 15) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; @@ -542,8 +538,7 @@ partial class Device sense |= error < 0; - if(error < 0) - error = Marshal.GetLastWin32Error(); + if(error < 0) error = Marshal.GetLastWin32Error(); duration = cmdStopwatch.Elapsed.TotalMilliseconds; @@ -642,8 +637,7 @@ partial class Device { long result64 = Extern.readlink64(path, buf, 4096); - if(result64 <= 0) - return null; + if(result64 <= 0) return null; resultSize = (int)result64; } @@ -651,8 +645,7 @@ partial class Device { int result = Extern.readlink(path, buf, 4096); - if(result <= 0) - return null; + if(result <= 0) return null; resultSize = result; } @@ -696,9 +689,8 @@ partial class Device int errno = Marshal.GetLastWin32Error(); if(sense == length) - errno = 0; - else if(errno == 0) - errno = -22; + errno = 0; + else if(errno == 0) errno = -22; LastError = errno; Error = errno == 0; diff --git a/Aaru.Devices/Linux/Device.cs b/Aaru.Devices/Linux/Device.cs index fa83d719d..f1b0cc191 100644 --- a/Aaru.Devices/Linux/Device.cs +++ b/Aaru.Devices/Linux/Device.cs @@ -96,8 +96,7 @@ partial class Device : Devices.Device } // Seems ioctl(2) does not allow the atomicity needed - if(dev.PlatformId == PlatformID.Linux) - ReadMultipleBlockCannotSetBlockCount = true; + if(dev.PlatformId == PlatformID.Linux) ReadMultipleBlockCannotSetBlockCount = true; dev.Type = DeviceType.Unknown; dev.ScsiType = PeripheralDeviceTypes.UnknownDevice; @@ -128,37 +127,33 @@ partial class Device : Devices.Device { int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/csd", out dev.CachedCsd); - if(len == 0) - dev.CachedCsd = null; + if(len == 0) dev.CachedCsd = null; } if(File.Exists("/sys/block/" + devPath + "/device/cid")) { int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/cid", out dev.CachedCid); - if(len == 0) - dev.CachedCid = null; + if(len == 0) dev.CachedCid = null; } if(File.Exists("/sys/block/" + devPath + "/device/scr")) { int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/scr", out dev.CachedScr); - if(len == 0) - dev.CachedScr = null; + if(len == 0) dev.CachedScr = null; } if(File.Exists("/sys/block/" + devPath + "/device/ocr")) { int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/ocr", out dev.CachedOcr); - if(len == 0) - dev.CachedOcr = null; + if(len == 0) dev.CachedOcr = null; } } } - #region SecureDigital / MultiMediaCard +#region SecureDigital / MultiMediaCard if(dev.CachedCid != null) { @@ -193,9 +188,9 @@ partial class Device : Devices.Device return dev; } - #endregion SecureDigital / MultiMediaCard +#endregion SecureDigital / MultiMediaCard - #region USB +#region USB string resolvedLink; @@ -233,7 +228,9 @@ partial class Device : Devices.Device var usbSr = new StreamReader(resolvedLink + "/idProduct"); string usbTemp = usbSr.ReadToEnd(); - ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, + ushort.TryParse(usbTemp, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, out dev.UsbProduct); usbSr.Close(); @@ -241,7 +238,9 @@ partial class Device : Devices.Device usbSr = new StreamReader(resolvedLink + "/idVendor"); usbTemp = usbSr.ReadToEnd(); - ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, + ushort.TryParse(usbTemp, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, out dev.UsbVendor); usbSr.Close(); @@ -275,9 +274,9 @@ partial class Device : Devices.Device } } - #endregion USB +#endregion USB - #region FireWire +#region FireWire if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || @@ -304,7 +303,9 @@ partial class Device : Devices.Device var fwSr = new StreamReader(resolvedLink + "/model"); string fwTemp = fwSr.ReadToEnd(); - uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, + uint.TryParse(fwTemp, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, out dev.FirewireModel); fwSr.Close(); @@ -312,7 +313,9 @@ partial class Device : Devices.Device fwSr = new StreamReader(resolvedLink + "/vendor"); fwTemp = fwSr.ReadToEnd(); - uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, + uint.TryParse(fwTemp, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, out dev.FirewireVendor); fwSr.Close(); @@ -320,7 +323,9 @@ partial class Device : Devices.Device fwSr = new StreamReader(resolvedLink + "/guid"); fwTemp = fwSr.ReadToEnd(); - ulong.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, + ulong.TryParse(fwTemp, + NumberStyles.HexNumber, + CultureInfo.InvariantCulture, out dev.FirewireGuid); fwSr.Close(); @@ -347,9 +352,9 @@ partial class Device : Devices.Device } } - #endregion FireWire +#endregion FireWire - #region PCMCIA +#region PCMCIA if(!devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) && !devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) && @@ -358,32 +363,28 @@ partial class Device : Devices.Device devPath = devicePath[5..]; - if(!Directory.Exists("/sys/block/" + devPath)) - return dev; + if(!Directory.Exists("/sys/block/" + devPath)) return dev; resolvedLink = ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink[2..]; - if(string.IsNullOrEmpty(resolvedLink)) - return dev; + if(string.IsNullOrEmpty(resolvedLink)) return dev; while(resolvedLink.Contains("/sys/devices")) { resolvedLink = Path.GetDirectoryName(resolvedLink); - if(!Directory.Exists(resolvedLink + "/pcmcia_socket")) - continue; + if(!Directory.Exists(resolvedLink + "/pcmcia_socket")) continue; - string[] subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket", "pcmcia_socket*", + string[] subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket", + "pcmcia_socket*", SearchOption.TopDirectoryOnly); - if(subdirs.Length <= 0) - continue; + if(subdirs.Length <= 0) continue; string possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]); - if(!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis")) - continue; + if(!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis")) continue; var cisFs = new FileStream(possibleDir + "/cis", FileMode.Open, FileAccess.Read); @@ -398,7 +399,7 @@ partial class Device : Devices.Device break; } - #endregion PCMCIA +#endregion PCMCIA return dev; } @@ -418,8 +419,7 @@ partial class Device : Devices.Device /// public override void Close() { - if(_fileDescriptor == 0) - return; + if(_fileDescriptor == 0) return; Extern.close(_fileDescriptor); diff --git a/Aaru.Devices/Linux/ListDevices.cs b/Aaru.Devices/Linux/ListDevices.cs index 321b14af0..db711cef5 100644 --- a/Aaru.Devices/Linux/ListDevices.cs +++ b/Aaru.Devices/Linux/ListDevices.cs @@ -78,8 +78,7 @@ static class ListDevices devices[i].Vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR"); devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL"); - if(!string.IsNullOrEmpty(devices[i].Model)) - devices[i].Model = devices[i].Model.Replace('_', ' '); + if(!string.IsNullOrEmpty(devices[i].Model)) devices[i].Model = devices[i].Model.Replace('_', ' '); devices[i].Serial = Extern.udev_device_get_property_value(udevDev, "ID_SCSI_SERIAL"); diff --git a/Aaru.Devices/Remote/Command.cs b/Aaru.Devices/Remote/Command.cs index 685676b56..94fd4e9f7 100644 --- a/Aaru.Devices/Remote/Command.cs +++ b/Aaru.Devices/Remote/Command.cs @@ -45,8 +45,7 @@ public partial class Device ScsiDirection direction, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; return _remote.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, direction, out duration, out sense); } @@ -57,11 +56,17 @@ public partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; - return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, - transferBlocks, out duration, out sense); + return _remote.SendAtaCommand(registers, + out errorRegisters, + protocol, + transferRegister, + ref buffer, + timeout, + transferBlocks, + out duration, + out sense); } /// @@ -70,11 +75,17 @@ public partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; - return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, - transferBlocks, out duration, out sense); + return _remote.SendAtaCommand(registers, + out errorRegisters, + protocol, + transferRegister, + ref buffer, + timeout, + transferBlocks, + out duration, + out sense); } /// @@ -83,11 +94,17 @@ public partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; - return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, - transferBlocks, out duration, out sense); + return _remote.SendAtaCommand(registers, + out errorRegisters, + protocol, + transferRegister, + ref buffer, + timeout, + transferBlocks, + out duration, + out sense); } /// @@ -96,8 +113,7 @@ public partial class Device out uint[] response, out double duration, out bool sense, uint timeout = 15) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; var cmdStopwatch = new Stopwatch(); @@ -154,8 +170,18 @@ public partial class Device } } - return _remote.SendMmcCommand(command, write, isApplication, flags, argument, blockSize, blocks, ref buffer, - out response, out duration, out sense, timeout); + return _remote.SendMmcCommand(command, + write, + isApplication, + flags, + argument, + blockSize, + blocks, + ref buffer, + out response, + out duration, + out sense, + timeout); } /// @@ -163,8 +189,7 @@ public partial class Device uint timeout = 15) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; if(_remote.ServerProtocolVersion >= 2) return _remote.SendMultipleMmcCommands(commands, out duration, out sense, timeout); @@ -175,18 +200,24 @@ public partial class Device foreach(MmcSingleCommand command in commands) { - int singleError = _remote.SendMmcCommand(command.command, command.write, command.isApplication, - command.flags, command.argument, command.blockSize, command.blocks, - ref command.buffer, out command.response, out double cmdDuration, - out bool cmdSense, timeout); + int singleError = _remote.SendMmcCommand(command.command, + command.write, + command.isApplication, + command.flags, + command.argument, + command.blockSize, + command.blocks, + ref command.buffer, + out command.response, + out double cmdDuration, + out bool cmdSense, + timeout); - if(error == 0 && singleError != 0) - error = singleError; + if(error == 0 && singleError != 0) error = singleError; duration += cmdDuration; - if(cmdSense) - sense = true; + if(cmdSense) sense = true; } return error; diff --git a/Aaru.Devices/Remote/Device.cs b/Aaru.Devices/Remote/Device.cs index 100c0f47c..671eef156 100644 --- a/Aaru.Devices/Remote/Device.cs +++ b/Aaru.Devices/Remote/Device.cs @@ -59,6 +59,7 @@ public sealed partial class Device : Devices.Device } /// Current device is remote + // ReSharper disable once UnusedMember.Global public bool IsRemote => _remote != null; @@ -96,16 +97,13 @@ public sealed partial class Device : Devices.Device IsRemovable = false }; - if(aaruUri.Scheme is not ("dic" or "aaru")) - return null; + if(aaruUri.Scheme is not ("dic" or "aaru")) return null; string devicePath = aaruUri.AbsolutePath; - if(devicePath.StartsWith('/')) - devicePath = devicePath[1..]; + if(devicePath.StartsWith('/')) devicePath = devicePath[1..]; - if(devicePath.StartsWith("dev", StringComparison.Ordinal)) - devicePath = $"/{devicePath}"; + if(devicePath.StartsWith("dev", StringComparison.Ordinal)) devicePath = $"/{devicePath}"; dev.DevicePath = devicePath; @@ -134,8 +132,7 @@ public sealed partial class Device : Devices.Device return null; } - if(dev._remote.ServerOperatingSystem == "Linux") - ReadMultipleBlockCannotSetBlockCount = true; + if(dev._remote.ServerOperatingSystem == "Linux") ReadMultipleBlockCannotSetBlockCount = true; dev.Type = DeviceType.Unknown; dev.ScsiType = PeripheralDeviceTypes.UnknownDevice; @@ -153,7 +150,9 @@ public sealed partial class Device : Devices.Device { case DeviceType.SecureDigital: case DeviceType.MMC: - if(!dev._remote.GetSdhciRegisters(out dev.CachedCsd, out dev.CachedCid, out dev.CachedOcr, + if(!dev._remote.GetSdhciRegisters(out dev.CachedCsd, + out dev.CachedCid, + out dev.CachedOcr, out dev.CachedScr)) { dev.Type = DeviceType.SCSI; @@ -163,7 +162,7 @@ public sealed partial class Device : Devices.Device break; } - #region SecureDigital / MultiMediaCard +#region SecureDigital / MultiMediaCard if(dev.CachedCid != null) { @@ -198,13 +197,16 @@ public sealed partial class Device : Devices.Device return dev; } - #endregion SecureDigital / MultiMediaCard +#endregion SecureDigital / MultiMediaCard - #region USB +#region USB - if(dev._remote.GetUsbData(out byte[] remoteUsbDescriptors, out ushort remoteUsbVendor, - out ushort remoteUsbProduct, out string remoteUsbManufacturer, - out string remoteUsbProductString, out string remoteUsbSerial)) + if(dev._remote.GetUsbData(out byte[] remoteUsbDescriptors, + out ushort remoteUsbVendor, + out ushort remoteUsbProduct, + out string remoteUsbManufacturer, + out string remoteUsbProductString, + out string remoteUsbSerial)) { dev.IsUsb = true; dev.UsbDescriptors = remoteUsbDescriptors; @@ -215,29 +217,31 @@ public sealed partial class Device : Devices.Device dev.UsbSerialString = remoteUsbSerial; } - #endregion USB +#endregion USB - #region FireWire +#region FireWire - if(dev._remote.GetFireWireData(out dev.FirewireVendor, out dev.FirewireModel, out dev.FirewireGuid, - out string remoteFireWireVendorName, out string remoteFireWireModelName)) + if(dev._remote.GetFireWireData(out dev.FirewireVendor, + out dev.FirewireModel, + out dev.FirewireGuid, + out string remoteFireWireVendorName, + out string remoteFireWireModelName)) { dev.IsFireWire = true; dev.FireWireVendorName = remoteFireWireVendorName; dev.FireWireModelName = remoteFireWireModelName; } - #endregion FireWire +#endregion FireWire - #region PCMCIA +#region PCMCIA - if(!dev._remote.GetPcmciaData(out byte[] cisBuf)) - return dev; + if(!dev._remote.GetPcmciaData(out byte[] cisBuf)) return dev; dev.IsPcmcia = true; dev.Cis = cisBuf; - #endregion PCMCIA +#endregion PCMCIA return dev; } @@ -245,8 +249,7 @@ public sealed partial class Device : Devices.Device /// public override void Close() { - if(_remote == null) - return; + if(_remote == null) return; _remote.Close(); _remote.Disconnect(); diff --git a/Aaru.Devices/Remote/Remote.cs b/Aaru.Devices/Remote/Remote.cs index fa74cbaa6..029058118 100644 --- a/Aaru.Devices/Remote/Remote.cs +++ b/Aaru.Devices/Remote/Remote.cs @@ -184,8 +184,7 @@ public class Remote : IDisposable len = _socket.Send(buf, SocketFlags.None); - if(len >= buf.Length) - return; + if(len >= buf.Length) return; AaruConsole.ErrorWriteLine(Localization.Could_not_write_to_the_network); @@ -260,9 +259,9 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAmIRoot) { - AaruConsole. - ErrorWriteLine(Localization.Remote_IsRoot_Expected_Am_I_Root_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruConsole.ErrorWriteLine(Localization + .Remote_IsRoot_Expected_Am_I_Root_Response_Packet_got_packet_type_0, + hdr.packetType); return false; } @@ -355,9 +354,9 @@ public class Remote : IDisposable { if(hdr.packetType != AaruPacketType.Nop) { - AaruConsole. - ErrorWriteLine(Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruConsole.ErrorWriteLine(Localization + .Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, + hdr.packetType); return Array.Empty(); } @@ -475,9 +474,9 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.Nop) { - AaruConsole. - ErrorWriteLine(Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, - hdr.packetType); + AaruConsole.ErrorWriteLine(Localization + .Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0, + hdr.packetType); lastError = -1; @@ -543,11 +542,9 @@ public class Remote : IDisposable timeout = timeout * 1000 }; - if(cdb != null) - cmdPkt.cdb_len = (uint)cdb.Length; + if(cdb != null) cmdPkt.cdb_len = (uint)cdb.Length; - if(buffer != null) - cmdPkt.buf_len = (uint)buffer.Length; + if(buffer != null) cmdPkt.buf_len = (uint)buffer.Length; cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.cdb_len + cmdPkt.buf_len); @@ -556,8 +553,7 @@ public class Remote : IDisposable Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); - if(cdb != null) - Array.Copy(cdb, 0, buf, Marshal.SizeOf(), cmdPkt.cdb_len); + if(cdb != null) Array.Copy(cdb, 0, buf, Marshal.SizeOf(), cmdPkt.cdb_len); if(buffer != null) Array.Copy(buffer, 0, buf, Marshal.SizeOf() + cmdPkt.cdb_len, cmdPkt.buf_len); @@ -658,8 +654,7 @@ public class Remote : IDisposable timeout = timeout * 1000 }; - if(buffer != null) - cmdPkt.buf_len = (uint)buffer.Length; + if(buffer != null) cmdPkt.buf_len = (uint)buffer.Length; cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); @@ -668,8 +663,7 @@ public class Remote : IDisposable Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); - if(buffer != null) - Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); + if(buffer != null) Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); int len = _socket.Send(buf, SocketFlags.None); @@ -766,8 +760,7 @@ public class Remote : IDisposable timeout = timeout * 1000 }; - if(buffer != null) - cmdPkt.buf_len = (uint)buffer.Length; + if(buffer != null) cmdPkt.buf_len = (uint)buffer.Length; cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); @@ -776,8 +769,7 @@ public class Remote : IDisposable Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); - if(buffer != null) - Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); + if(buffer != null) Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); int len = _socket.Send(buf, SocketFlags.None); @@ -875,8 +867,7 @@ public class Remote : IDisposable timeout = timeout * 1000 }; - if(buffer != null) - cmdPkt.buf_len = (uint)buffer.Length; + if(buffer != null) cmdPkt.buf_len = (uint)buffer.Length; cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); @@ -885,8 +876,7 @@ public class Remote : IDisposable Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); - if(buffer != null) - Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); + if(buffer != null) Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.buf_len); int len = _socket.Send(buf, SocketFlags.None); @@ -990,8 +980,7 @@ public class Remote : IDisposable } }; - if(buffer != null) - cmdPkt.command.buf_len = (uint)buffer.Length; + if(buffer != null) cmdPkt.command.buf_len = (uint)buffer.Length; cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.command.buf_len); @@ -1000,8 +989,7 @@ public class Remote : IDisposable Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); - if(buffer != null) - Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.command.buf_len); + if(buffer != null) Array.Copy(buffer, 0, buf, Marshal.SizeOf(), cmdPkt.command.buf_len); int len = _socket.Send(buf, SocketFlags.None); @@ -1215,8 +1203,7 @@ public class Remote : IDisposable if(res.csd_len > 0) { - if(res.csd_len > 16) - res.csd_len = 16; + if(res.csd_len > 16) res.csd_len = 16; csd = new byte[res.csd_len]; @@ -1225,8 +1212,7 @@ public class Remote : IDisposable if(res.cid_len > 0) { - if(res.cid_len > 16) - res.cid_len = 16; + if(res.cid_len > 16) res.cid_len = 16; cid = new byte[res.cid_len]; @@ -1235,8 +1221,7 @@ public class Remote : IDisposable if(res.ocr_len > 0) { - if(res.ocr_len > 16) - res.ocr_len = 16; + if(res.ocr_len > 16) res.ocr_len = 16; ocr = new byte[res.ocr_len]; @@ -1341,8 +1326,7 @@ public class Remote : IDisposable AaruPacketResGetUsbData res = Marshal.ByteArrayToStructureLittleEndian(buf); - if(!res.isUsb) - return false; + if(!res.isUsb) return false; descriptors = new byte[res.descLen]; Array.Copy(res.descriptors, 0, descriptors, 0, res.descLen); @@ -1434,8 +1418,7 @@ public class Remote : IDisposable AaruPacketResGetFireWireData res = Marshal.ByteArrayToStructureLittleEndian(buf); - if(!res.isFireWire) - return false; + if(!res.isFireWire) return false; idVendor = res.idVendor; idProduct = res.idModel; @@ -1516,8 +1499,7 @@ public class Remote : IDisposable AaruPacketResGetPcmciaData res = Marshal.ByteArrayToStructureLittleEndian(buf); - if(!res.isPcmcia) - return false; + if(!res.isPcmcia) return false; cis = res.cis; @@ -1538,8 +1520,7 @@ public class Remote : IDisposable { int got = socket.Receive(buffer, offset, size, socketFlags); - if(got <= 0) - break; + if(got <= 0) break; offset += got; size -= got; @@ -1587,8 +1568,7 @@ public class Remote : IDisposable public int SendMultipleMmcCommands(Devices.Device.MmcSingleCommand[] commands, out double duration, out bool sense, uint timeout = 0) { - if(ServerProtocolVersion < 2) - return SendMultipleMmcCommandsV1(commands, out duration, out sense, timeout); + if(ServerProtocolVersion < 2) return SendMultipleMmcCommandsV1(commands, out duration, out sense, timeout); sense = false; duration = 0; @@ -1619,17 +1599,17 @@ public class Remote : IDisposable int off = tmp.Length; foreach(AaruCmdSdhci cmd in commands.Select(command => new AaruCmdSdhci - { - application = command.isApplication, - argument = command.argument, - block_size = command.blockSize, - blocks = command.blocks, - buf_len = (uint)(command.buffer?.Length ?? 0), - command = command.command, - flags = command.flags, - timeout = timeout, - write = command.write - })) + { + application = command.isApplication, + argument = command.argument, + block_size = command.blockSize, + blocks = command.blocks, + buf_len = (uint)(command.buffer?.Length ?? 0), + command = command.command, + flags = command.flags, + timeout = timeout, + write = command.write + })) { tmp = Marshal.StructureToByteArrayLittleEndian(cmd); Array.Copy(tmp, 0, buf, off, tmp.Length); @@ -1638,7 +1618,7 @@ public class Remote : IDisposable } foreach(Devices.Device.MmcSingleCommand command in - commands.Where(command => (command.buffer?.Length ?? 0) != 0)) + commands.Where(command => (command.buffer?.Length ?? 0) != 0)) { Array.Copy(command.buffer, 0, buf, off, command.buffer.Length); @@ -1697,7 +1677,8 @@ public class Remote : IDisposable if(res.cmd_count != (ulong)commands.Length) { AaruConsole.ErrorWriteLine(Localization.Expected_the_response_to_0_SD_MMC_commands_but_got_1_responses, - commands.Length, res.cmd_count); + commands.Length, + res.cmd_count); return -1; } @@ -1714,14 +1695,11 @@ public class Remote : IDisposable command.response = cmdRes.response; duration += cmdRes.duration; - if(cmdRes.error_no != 0 && error == 0) - error = (int)cmdRes.error_no; + if(cmdRes.error_no != 0 && error == 0) error = (int)cmdRes.error_no; - if(cmdRes.sense != 0) - sense = true; + if(cmdRes.sense != 0) sense = true; - if(cmdRes.buf_len > 0) - command.buffer = new byte[cmdRes.buf_len]; + if(cmdRes.buf_len > 0) command.buffer = new byte[cmdRes.buf_len]; off += Marshal.SizeOf(); } @@ -1753,12 +1731,20 @@ public class Remote : IDisposable foreach(Devices.Device.MmcSingleCommand command in commands) { - error = SendMmcCommand(command.command, command.write, command.isApplication, command.flags, - command.argument, command.blockSize, command.blocks, ref command.buffer, - out command.response, out double cmdDuration, out bool cmdSense, timeout); + error = SendMmcCommand(command.command, + command.write, + command.isApplication, + command.flags, + command.argument, + command.blockSize, + command.blocks, + ref command.buffer, + out command.response, + out double cmdDuration, + out bool cmdSense, + timeout); - if(cmdSense) - sense = true; + if(cmdSense) sense = true; duration += cmdDuration; } @@ -1770,8 +1756,7 @@ public class Remote : IDisposable /// Returned error number if any public bool ReOpen() { - if(ServerProtocolVersion < 2) - return false; + if(ServerProtocolVersion < 2) return false; var cmdPkt = new AaruPacketCmdReOpen { @@ -1871,8 +1856,7 @@ public class Remote : IDisposable duration = 0; buffer = null; - if(ServerProtocolVersion < 2) - return false; + if(ServerProtocolVersion < 2) return false; var cmdPkt = new AaruPacketCmdOsRead { diff --git a/Aaru.Devices/Windows/Command.cs b/Aaru.Devices/Windows/Command.cs index 481ff9fe5..51a992f18 100644 --- a/Aaru.Devices/Windows/Command.cs +++ b/Aaru.Devices/Windows/Command.cs @@ -48,15 +48,13 @@ partial class Device ScsiDirection direction, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; senseBuffer = null; duration = 0; sense = false; - if(buffer == null) - return -1; + if(buffer == null) return -1; ScsiIoctlDirection dir = direction switch { @@ -92,14 +90,18 @@ partial class Device var cmdStopwatch = new Stopwatch(); cmdStopwatch.Start(); - bool hasError = !Extern.DeviceIoControlScsi(_fileHandle, WindowsIoctl.IoctlScsiPassThroughDirect, ref sptdSb, - (uint)Marshal.SizeOf(sptdSb), ref sptdSb, - (uint)Marshal.SizeOf(sptdSb), ref k, IntPtr.Zero); + bool hasError = !Extern.DeviceIoControlScsi(_fileHandle, + WindowsIoctl.IoctlScsiPassThroughDirect, + ref sptdSb, + (uint)Marshal.SizeOf(sptdSb), + ref sptdSb, + (uint)Marshal.SizeOf(sptdSb), + ref k, + IntPtr.Zero); cmdStopwatch.Stop(); - if(hasError) - error = Marshal.GetLastWin32Error(); + if(hasError) error = Marshal.GetLastWin32Error(); Marshal.Copy(sptdSb.sptd.DataBuffer, buffer, 0, buffer.Length); @@ -121,15 +123,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersChs(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var aptd = new AtaPassThroughDirect { @@ -188,14 +188,18 @@ partial class Device var cmdStopwatch = new Stopwatch(); cmdStopwatch.Start(); - sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, - (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, + sense = !Extern.DeviceIoControlAta(_fileHandle, + WindowsIoctl.IoctlAtaPassThroughDirect, + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref k, IntPtr.Zero); cmdStopwatch.Stop(); - if(sense) - error = Marshal.GetLastWin32Error(); + if(sense) error = Marshal.GetLastWin32Error(); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); @@ -222,15 +226,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersLba28(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var aptd = new AtaPassThroughDirect { @@ -289,14 +291,18 @@ partial class Device var cmdStopwatch = new Stopwatch(); cmdStopwatch.Start(); - sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, - (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, + sense = !Extern.DeviceIoControlAta(_fileHandle, + WindowsIoctl.IoctlAtaPassThroughDirect, + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref k, IntPtr.Zero); cmdStopwatch.Stop(); - if(sense) - error = Marshal.GetLastWin32Error(); + if(sense) error = Marshal.GetLastWin32Error(); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); @@ -323,15 +329,13 @@ partial class Device uint timeout, bool transferBlocks, out double duration, out bool sense) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; duration = 0; sense = false; errorRegisters = new AtaErrorRegistersLba48(); - if(buffer == null) - return -1; + if(buffer == null) return -1; var aptd = new AtaPassThroughDirect { @@ -399,14 +403,18 @@ partial class Device var cmdStopwatch = new Stopwatch(); cmdStopwatch.Start(); - sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, - (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, + sense = !Extern.DeviceIoControlAta(_fileHandle, + WindowsIoctl.IoctlAtaPassThroughDirect, + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref aptd, + (uint)Marshal.SizeOf(aptd), + ref k, IntPtr.Zero); cmdStopwatch.Stop(); - if(sense) - error = Marshal.GetLastWin32Error(); + if(sense) error = Marshal.GetLastWin32Error(); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); @@ -440,8 +448,14 @@ partial class Device var queryData1 = new SffdiskQueryDeviceProtocolData(); queryData1.size = (ushort)Marshal.SizeOf(queryData1); - Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskQueryDeviceProtocol, IntPtr.Zero, 0, ref queryData1, - queryData1.size, out _, IntPtr.Zero); + Extern.DeviceIoControl(fd, + WindowsIoctl.IoctlSffdiskQueryDeviceProtocol, + IntPtr.Zero, + 0, + ref queryData1, + queryData1.size, + out _, + IntPtr.Zero); return queryData1.protocolGuid.Equals(Consts.GuidSffProtocolSd) || queryData1.protocolGuid.Equals(Consts.GuidSffProtocolMmc); @@ -543,8 +557,7 @@ partial class Device if(flags.HasFlag(MmcFlags.ResponseR5) || flags.HasFlag(MmcFlags.ResponseSpiR5)) commandDescriptor.responseType = SdResponseType.R5; - if(flags.HasFlag(MmcFlags.ResponseR6)) - commandDescriptor.responseType = SdResponseType.R6; + if(flags.HasFlag(MmcFlags.ResponseR6)) commandDescriptor.responseType = SdResponseType.R6; var commandB = new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize]; @@ -559,13 +572,18 @@ partial class Device var error = 0; cmdStopwatch.Restart(); - sense = !Extern.DeviceIoControl(_fileHandle, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB, - (uint)commandB.Length, commandB, (uint)commandB.Length, out _, IntPtr.Zero); + sense = !Extern.DeviceIoControl(_fileHandle, + WindowsIoctl.IoctlSffdiskDeviceCommand, + commandB, + (uint)commandB.Length, + commandB, + (uint)commandB.Length, + out _, + IntPtr.Zero); cmdStopwatch.Stop(); - if(sense) - error = Marshal.GetLastWin32Error(); + if(sense) error = Marshal.GetLastWin32Error(); buffer = new byte[blockSize * blocks]; Buffer.BlockCopy(commandB, commandB.Length - buffer.Length, buffer, 0, buffer.Length); @@ -581,8 +599,7 @@ partial class Device uint timeout = 15) { // We need a timeout - if(timeout == 0) - timeout = Timeout > 0 ? Timeout : 15; + if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; var error = 0; duration = 0; @@ -593,24 +610,40 @@ partial class Device commands[1].command == MmcCommands.ReadMultipleBlock && commands[2].command == MmcCommands.StopTransmission) { - return SendMmcCommand(commands[1].command, commands[1].write, commands[1].isApplication, commands[1].flags, - commands[1].argument, commands[1].blockSize, commands[1].blocks, - ref commands[1].buffer, out commands[1].response, out duration, out sense, timeout); + return SendMmcCommand(commands[1].command, + commands[1].write, + commands[1].isApplication, + commands[1].flags, + commands[1].argument, + commands[1].blockSize, + commands[1].blocks, + ref commands[1].buffer, + out commands[1].response, + out duration, + out sense, + timeout); } foreach(MmcSingleCommand command in commands) { - int singleError = SendMmcCommand(command.command, command.write, command.isApplication, command.flags, - command.argument, command.blockSize, command.blocks, ref command.buffer, - out command.response, out double cmdDuration, out bool cmdSense, timeout); + int singleError = SendMmcCommand(command.command, + command.write, + command.isApplication, + command.flags, + command.argument, + command.blockSize, + command.blocks, + ref command.buffer, + out command.response, + out double cmdDuration, + out bool cmdSense, + timeout); - if(error == 0 && singleError != 0) - error = singleError; + if(error == 0 && singleError != 0) error = singleError; duration += cmdDuration; - if(cmdSense) - sense = true; + if(cmdSense) sense = true; } return error; @@ -621,9 +654,13 @@ partial class Device { Extern.CloseHandle(_fileHandle); - SafeFileHandle newFd = Extern.CreateFile(DevicePath, FileAccess.GenericRead | FileAccess.GenericWrite, - FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.OpenExisting, - FileAttributes.Normal, IntPtr.Zero); + SafeFileHandle newFd = Extern.CreateFile(DevicePath, + FileAccess.GenericRead | FileAccess.GenericWrite, + FileShare.Read | FileShare.Write, + IntPtr.Zero, + FileMode.OpenExisting, + FileAttributes.Normal, + IntPtr.Zero); if(newFd.IsInvalid) { diff --git a/Aaru.Devices/Windows/Device.cs b/Aaru.Devices/Windows/Device.cs index 0dcd849ca..1a1290fb4 100644 --- a/Aaru.Devices/Windows/Device.cs +++ b/Aaru.Devices/Windows/Device.cs @@ -57,13 +57,17 @@ partial class Device : Devices.Device var dev = new Device { - PlatformId = DetectOS.GetRealPlatformID(), - Timeout = 15, - Error = false, + PlatformId = DetectOS.GetRealPlatformID(), + Timeout = 15, + Error = false, IsRemovable = false, - _fileHandle = Extern.CreateFile(devicePath, FileAccess.GenericRead | FileAccess.GenericWrite, - FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.OpenExisting, - FileAttributes.Normal, IntPtr.Zero) + _fileHandle = Extern.CreateFile(devicePath, + FileAccess.GenericRead | FileAccess.GenericWrite, + FileShare.Read | FileShare.Write, + IntPtr.Zero, + FileMode.OpenExisting, + FileAttributes.Normal, + IntPtr.Zero) }; if(dev._fileHandle.IsInvalid) @@ -103,12 +107,16 @@ partial class Device : Devices.Device uint returned = 0; var error = 0; - bool hasError = !Extern.DeviceIoControlStorageQuery(dev._fileHandle, WindowsIoctl.IoctlStorageQueryProperty, - ref query, (uint)Marshal.SizeOf(query), descriptorPtr, 1000, - ref returned, IntPtr.Zero); + bool hasError = !Extern.DeviceIoControlStorageQuery(dev._fileHandle, + WindowsIoctl.IoctlStorageQueryProperty, + ref query, + (uint)Marshal.SizeOf(query), + descriptorPtr, + 1000, + ref returned, + IntPtr.Zero); - if(hasError) - error = Marshal.GetLastWin32Error(); + if(hasError) error = Marshal.GetLastWin32Error(); Marshal.Copy(descriptorPtr, descriptorB, 0, 1000); @@ -197,9 +205,17 @@ partial class Device : Devices.Device { var sdBuffer = new byte[16]; - dev.LastError = dev.SendMmcCommand(MmcCommands.SendCsd, false, false, - MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, - 1, ref sdBuffer, out _, out _, out bool sense); + dev.LastError = dev.SendMmcCommand(MmcCommands.SendCsd, + false, + false, + MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, + 0, + 16, + 1, + ref sdBuffer, + out _, + out _, + out bool sense); if(!sense) { @@ -209,9 +225,17 @@ partial class Device : Devices.Device sdBuffer = new byte[16]; - dev.LastError = dev.SendMmcCommand(MmcCommands.SendCid, false, false, - MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, 0, 16, - 1, ref sdBuffer, out _, out _, out sense); + dev.LastError = dev.SendMmcCommand(MmcCommands.SendCid, + false, + false, + MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | MmcFlags.CommandAc, + 0, + 16, + 1, + ref sdBuffer, + out _, + out _, + out sense); if(!sense) { @@ -221,9 +245,17 @@ partial class Device : Devices.Device sdBuffer = new byte[8]; - dev.LastError = dev.SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, false, true, - MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, 0, - 8, 1, ref sdBuffer, out _, out _, out sense); + dev.LastError = dev.SendMmcCommand((MmcCommands)SecureDigitalCommands.SendScr, + false, + true, + MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | MmcFlags.CommandAdtc, + 0, + 8, + 1, + ref sdBuffer, + out _, + out _, + out sense); if(!sense) { @@ -234,9 +266,19 @@ partial class Device : Devices.Device sdBuffer = new byte[4]; dev.LastError = - dev.SendMmcCommand(dev.CachedScr != null ? (MmcCommands)SecureDigitalCommands.SendOperatingCondition : MmcCommands.SendOpCond, - false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0, - 4, 1, ref sdBuffer, out _, out _, out sense); + dev.SendMmcCommand(dev.CachedScr != null + ? (MmcCommands)SecureDigitalCommands.SendOperatingCondition + : MmcCommands.SendOpCond, + false, + true, + MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, + 0, + 4, + 1, + ref sdBuffer, + out _, + out _, + out sense); if(!sense) { @@ -245,7 +287,7 @@ partial class Device : Devices.Device } } - #region SecureDigital / MultiMediaCard +#region SecureDigital / MultiMediaCard if(dev.CachedCid != null) { @@ -280,23 +322,22 @@ partial class Device : Devices.Device return dev; } - #endregion SecureDigital / MultiMediaCard +#endregion SecureDigital / MultiMediaCard - #region USB +#region USB Usb.UsbDevice usbDevice = null; // I have to search for USB disks, floppies and CD-ROMs as separate device types foreach(string devGuid in new[] - { - Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK, - Usb.GUID_DEVINTERFACE_TAPE - }) + { + Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK, + Usb.GUID_DEVINTERFACE_TAPE + }) { usbDevice = Usb.FindDrivePath(devicePath, devGuid); - if(usbDevice != null) - break; + if(usbDevice != null) break; } if(usbDevice != null) @@ -311,21 +352,21 @@ partial class Device : Devices.Device usbDevice.SerialNumber; // This is incorrect filled by Windows with SCSI/ATA serial number } - #endregion USB +#endregion USB - #region FireWire +#region FireWire // TODO: Implement dev.IsFireWire = false; - #endregion FireWire +#endregion FireWire - #region PCMCIA +#region PCMCIA // TODO: Implement - #endregion PCMCIA +#endregion PCMCIA return dev; } @@ -333,8 +374,7 @@ partial class Device : Devices.Device /// public override void Close() { - if(_fileHandle == null) - return; + if(_fileHandle == null) return; _fileHandle?.Close(); diff --git a/Aaru.Devices/Windows/ListDevices.cs b/Aaru.Devices/Windows/ListDevices.cs index ad5f59eb6..256032742 100644 --- a/Aaru.Devices/Windows/ListDevices.cs +++ b/Aaru.Devices/Windows/ListDevices.cs @@ -87,31 +87,33 @@ static class ListDevices } catch(Exception) { - #if DEBUG +#if DEBUG throw; - #else +#else return null; - #endif +#endif } var devList = new List(); foreach(string devId in deviceIDs) { - if(devId is null) - continue; + if(devId is null) continue; string physId = devId; // TODO: This can be done better - if(devId.Length == 2 && devId[1] == ':') - physId = "\\\\?\\" + devId; + if(devId.Length == 2 && devId[1] == ':') physId = "\\\\?\\" + devId; - SafeFileHandle fd = Extern.CreateFile(physId, 0, FileShare.Read | FileShare.Write, IntPtr.Zero, - FileMode.OpenExisting, 0, IntPtr.Zero); + SafeFileHandle fd = Extern.CreateFile(physId, + 0, + FileShare.Read | FileShare.Write, + IntPtr.Zero, + FileMode.OpenExisting, + 0, + IntPtr.Zero); - if(fd.IsInvalid) - continue; + if(fd.IsInvalid) continue; var query = new StoragePropertyQuery { @@ -129,17 +131,20 @@ static class ListDevices uint returned = 0; var error = 0; - bool hasError = !Extern.DeviceIoControlStorageQuery(fd, WindowsIoctl.IoctlStorageQueryProperty, ref query, - (uint)Marshal.SizeOf(query), descriptorPtr, 1000, - ref returned, IntPtr.Zero); + bool hasError = !Extern.DeviceIoControlStorageQuery(fd, + WindowsIoctl.IoctlStorageQueryProperty, + ref query, + (uint)Marshal.SizeOf(query), + descriptorPtr, + 1000, + ref returned, + IntPtr.Zero); - if(hasError) - error = Marshal.GetLastWin32Error(); + if(hasError) error = Marshal.GetLastWin32Error(); Marshal.Copy(descriptorPtr, descriptorB, 0, 1000); - if(hasError && error != 0) - continue; + if(hasError && error != 0) continue; var descriptor = new StorageDeviceDescriptor { diff --git a/Aaru.Devices/Windows/Usb.cs b/Aaru.Devices/Windows/Usb.cs index ab06e0a66..872d2b525 100644 --- a/Aaru.Devices/Windows/Usb.cs +++ b/Aaru.Devices/Windows/Usb.cs @@ -58,8 +58,7 @@ static partial class Usb // devices that match the interface GUID of a Hub Controller IntPtr h = SetupDiGetClassDevs(ref hostGuid, 0, IntPtr.Zero, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); - if(h == _invalidHandleValue) - return new ReadOnlyCollection(hostList); + if(h == _invalidHandleValue) return new ReadOnlyCollection(hostList); IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); bool success; @@ -104,11 +103,21 @@ static partial class Usb var requiredSize = 0; int regType = REG_SZ; - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, BUFFER_SIZE, + if(SetupDiGetDeviceRegistryProperty(h, + ref da, + SPDRP_DEVICEDESC, + ref regType, + ptrBuf, + BUFFER_SIZE, ref requiredSize)) host.ControllerDeviceDesc = Marshal.PtrToStringAuto(ptrBuf); - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, + if(SetupDiGetDeviceRegistryProperty(h, + ref da, + SPDRP_DRIVER, + ref regType, + ptrBuf, + BUFFER_SIZE, ref requiredSize)) host.ControllerDriverKeyName = Marshal.PtrToStringAuto(ptrBuf); } @@ -137,8 +146,7 @@ static partial class Usb // to generate a list of all USB devices IntPtr h = SetupDiGetClassDevs(0, REGSTR_KEY_USB, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); - if(h == _invalidHandleValue) - return ans; + if(h == _invalidHandleValue) return ans; IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); @@ -160,14 +168,24 @@ static partial class Usb int regType = REG_SZ; var keyName = ""; - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, + if(SetupDiGetDeviceRegistryProperty(h, + ref da, + SPDRP_DRIVER, + ref regType, + ptrBuf, + BUFFER_SIZE, 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, + if(SetupDiGetDeviceRegistryProperty(h, + ref da, + SPDRP_DEVICEDESC, + ref regType, + ptrBuf, + BUFFER_SIZE, ref requiredSize)) ans = Marshal.PtrToStringAuto(ptrBuf); @@ -195,8 +213,7 @@ static partial class Usb // to generate a list of all USB devices IntPtr h = SetupDiGetClassDevs(0, REGSTR_KEY_USB, IntPtr.Zero, DIGCF_PRESENT | DIGCF_ALLCLASSES); - if(h == _invalidHandleValue) - return ans; + if(h == _invalidHandleValue) return ans; IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); @@ -219,7 +236,12 @@ static partial class Usb var keyName = ""; - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, + if(SetupDiGetDeviceRegistryProperty(h, + ref da, + SPDRP_DRIVER, + ref regType, + ptrBuf, + BUFFER_SIZE, ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf); @@ -285,18 +307,28 @@ static partial class Usb }; // Open a handle to the Host Controller - IntPtr h = CreateFile(ControllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h = CreateFile(ControllerDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); - if(h == _invalidHandleValue) - return root; + if(h == _invalidHandleValue) return root; var hubName = new UsbRootHubName(); int nBytes = Marshal.SizeOf(hubName); IntPtr ptrHubName = Marshal.AllocHGlobal(nBytes); // get the Hub Name - if(DeviceIoControl(h, IOCTL_USB_GET_ROOT_HUB_NAME, ptrHubName, nBytes, ptrHubName, nBytes, out _, + if(DeviceIoControl(h, + IOCTL_USB_GET_ROOT_HUB_NAME, + ptrHubName, + nBytes, + ptrHubName, + nBytes, + out _, IntPtr.Zero)) { hubName = (UsbRootHubName)(Marshal.PtrToStructure(ptrHubName, typeof(UsbRootHubName)) ?? @@ -307,7 +339,12 @@ static partial class Usb // TODO: Get DriverKeyName for Root Hub // Now let's open the Hub (based upon the HubName we got above) - IntPtr h2 = CreateFile(root.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h2 = CreateFile(root.HubDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); if(h2 != _invalidHandleValue) @@ -322,7 +359,13 @@ static partial class Usb Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true); // get the Hub Information - if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out _, + if(DeviceIoControl(h2, + IOCTL_USB_GET_NODE_INFORMATION, + ptrNodeInfo, + nBytes, + ptrNodeInfo, + nBytes, + out _, IntPtr.Zero)) { nodeInfo = (UsbNodeInformation)(Marshal.PtrToStructure(ptrNodeInfo, typeof(UsbNodeInformation)) ?? @@ -458,11 +501,15 @@ static partial class Usb var portList = new List(); // Open a handle to the Hub device - IntPtr h = CreateFile(HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h = CreateFile(HubDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); - if(h == _invalidHandleValue) - return new ReadOnlyCollection(portList); + if(h == _invalidHandleValue) return new ReadOnlyCollection(portList); int nBytes = Marshal.SizeOf(typeof(UsbNodeConnectionInformationEx)); IntPtr ptrNodeConnection = Marshal.AllocHGlobal(nBytes); @@ -478,8 +525,14 @@ static partial class Usb Marshal.StructureToPtr(nodeConnection, ptrNodeConnection, true); - if(!DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, ptrNodeConnection, nBytes, - ptrNodeConnection, nBytes, out _, IntPtr.Zero)) + if(!DeviceIoControl(h, + IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, + ptrNodeConnection, + nBytes, + ptrNodeConnection, + nBytes, + out _, + IntPtr.Zero)) continue; nodeConnection = @@ -556,8 +609,7 @@ static partial class Usb /// Downstream external hub internal UsbDevice GetDevice() { - if(!PortIsDeviceConnected) - return null; + if(!PortIsDeviceConnected) return null; // Copy over some values from the Port class // Ya know, I've given some thought about making Device a derived class... @@ -569,11 +621,15 @@ static partial class Usb }; // Open a handle to the Hub device - IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h = CreateFile(PortHubDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); - if(h == _invalidHandleValue) - return device; + if(h == _invalidHandleValue) return device; int nBytesReturned; int nBytes = BUFFER_SIZE; @@ -606,8 +662,14 @@ static partial class Usb Marshal.StructureToPtr(request, ptrRequest, true); // Use an IOCTL call to request the String Descriptor - if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, - nBytes, out nBytesReturned, IntPtr.Zero)) + if(DeviceIoControl(h, + IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, + ptrRequest, + nBytes, + ptrRequest, + nBytes, + out nBytesReturned, + IntPtr.Zero)) { // The location of the string descriptor is immediately after // the Request structure. Because this location is not "covered" @@ -646,8 +708,14 @@ static partial class Usb Marshal.StructureToPtr(request, ptrRequest, true); // Use an IOCTL call to request the String Descriptor - if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, - nBytes, out nBytesReturned, IntPtr.Zero)) + if(DeviceIoControl(h, + IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, + ptrRequest, + nBytes, + ptrRequest, + nBytes, + out nBytesReturned, + IntPtr.Zero)) { // the location of the string descriptor is immediately after the Request structure var ptrStringDesc = IntPtr.Add(ptrRequest, Marshal.SizeOf(request)); @@ -683,8 +751,14 @@ static partial class Usb Marshal.StructureToPtr(request, ptrRequest, true); // Use an IOCTL call to request the String Descriptor - if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, ptrRequest, nBytes, ptrRequest, - nBytes, out nBytesReturned, IntPtr.Zero)) + if(DeviceIoControl(h, + IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, + ptrRequest, + nBytes, + ptrRequest, + nBytes, + out nBytesReturned, + IntPtr.Zero)) { // the location of the string descriptor is immediately after the Request structure var ptrStringDesc = IntPtr.Add(ptrRequest, Marshal.SizeOf(request)); @@ -717,8 +791,14 @@ static partial class Usb Marshal.StructureToPtr(dcrRequest, dcrPtrRequest, true); // Use an IOCTL call to request the String Descriptor - if(DeviceIoControl(h, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, dcrPtrRequest, nBytes, dcrPtrRequest, - nBytes, out nBytesReturned, IntPtr.Zero)) + if(DeviceIoControl(h, + IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, + dcrPtrRequest, + nBytes, + dcrPtrRequest, + nBytes, + out nBytesReturned, + IntPtr.Zero)) { var ptrStringDesc = IntPtr.Add(dcrPtrRequest, Marshal.SizeOf(dcrRequest)); device.BinaryDeviceDescriptors = new byte[nBytesReturned]; @@ -738,8 +818,14 @@ static partial class Usb Marshal.StructureToPtr(driverKey, ptrDriverKey, true); // Use an IOCTL call to request the Driver Key Name - if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, ptrDriverKey, nBytes, ptrDriverKey, - nBytes, out nBytesReturned, IntPtr.Zero)) + if(DeviceIoControl(h, + IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, + ptrDriverKey, + nBytes, + ptrDriverKey, + nBytes, + out nBytesReturned, + IntPtr.Zero)) { driverKey = (UsbNodeConnectionDriverkeyName)(Marshal.PtrToStructure(ptrDriverKey, typeof(UsbNodeConnectionDriverkeyName)) ?? @@ -762,8 +848,7 @@ static partial class Usb /// Downstream external hub internal UsbHub GetHub() { - if(!PortIsHub) - return null; + if(!PortIsHub) return null; var hub = new UsbHub { @@ -772,11 +857,15 @@ static partial class Usb }; // Open a handle to the Host Controller - IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h = CreateFile(PortHubDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); - if(h == _invalidHandleValue) - return hub; + if(h == _invalidHandleValue) return hub; // Get the DevicePath for downstream hub var nodeName = new UsbNodeConnectionName @@ -789,7 +878,13 @@ static partial class Usb Marshal.StructureToPtr(nodeName, ptrNodeName, true); // Use an IOCTL call to request the Node Name - if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes, out _, + if(DeviceIoControl(h, + IOCTL_USB_GET_NODE_CONNECTION_NAME, + ptrNodeName, + nBytes, + ptrNodeName, + nBytes, + out _, IntPtr.Zero)) { nodeName = (UsbNodeConnectionName)(Marshal.PtrToStructure(ptrNodeName, typeof(UsbNodeConnectionName)) ?? @@ -799,7 +894,12 @@ static partial class Usb } // Now let's open the Hub (based upon the HubName we got above) - IntPtr h2 = CreateFile(hub.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, + IntPtr h2 = CreateFile(hub.HubDevicePath, + GENERIC_WRITE, + FILE_SHARE_WRITE, + IntPtr.Zero, + OPEN_EXISTING, + 0, IntPtr.Zero); if(h2 != _invalidHandleValue) @@ -814,7 +914,13 @@ static partial class Usb Marshal.StructureToPtr(nodeInfo, ptrNodeInfo, true); // get the Hub Information - if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out _, + if(DeviceIoControl(h2, + IOCTL_USB_GET_NODE_INFORMATION, + ptrNodeInfo, + nBytes, + ptrNodeInfo, + nBytes, + out _, IntPtr.Zero)) { nodeInfo = (UsbNodeInformation)(Marshal.PtrToStructure(ptrNodeInfo, typeof(UsbNodeInformation)) ?? diff --git a/Aaru.Devices/Windows/UsbFunctions.cs b/Aaru.Devices/Windows/UsbFunctions.cs index 3e2de3cb6..84bb56e28 100644 --- a/Aaru.Devices/Windows/UsbFunctions.cs +++ b/Aaru.Devices/Windows/UsbFunctions.cs @@ -59,8 +59,7 @@ static partial class Usb { var devList = new List(); - foreach(UsbController controller in GetHostControllers()) - ListHub(controller.GetRootHub(), devList); + foreach(UsbController controller in GetHostControllers()) ListHub(controller.GetRootHub(), devList); return devList; } @@ -76,8 +75,7 @@ static partial class Usb ListHub(port.GetHub(), devList); else { - if(port.IsDeviceConnected) - devList.Add(port.GetDevice()); + if(port.IsDeviceConnected) devList.Add(port.GetDevice()); } } } @@ -93,8 +91,7 @@ static partial class Usb { SearchHubDriverKeyName(controller.GetRootHub(), ref foundDevice, driverKeyName); - if(foundDevice != null) - break; + if(foundDevice != null) break; } return foundDevice; @@ -112,13 +109,11 @@ static partial class Usb SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName); else { - if(!port.IsDeviceConnected) - continue; + if(!port.IsDeviceConnected) continue; UsbDevice device = port.GetDevice(); - if(device.DeviceDriverKey != driverKeyName) - continue; + if(device.DeviceDriverKey != driverKeyName) continue; foundDevice = device; @@ -138,8 +133,7 @@ static partial class Usb { SearchHubInstanceId(controller.GetRootHub(), ref foundDevice, instanceId); - if(foundDevice != null) - break; + if(foundDevice != null) break; } return foundDevice; @@ -157,13 +151,11 @@ static partial class Usb SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId); else { - if(!port.IsDeviceConnected) - continue; + if(!port.IsDeviceConnected) continue; UsbDevice device = port.GetDevice(); - if(device.InstanceId != instanceId) - continue; + if(device.InstanceId != instanceId) continue; foundDevice = device; @@ -293,8 +285,7 @@ static partial class Usb IntPtr h = CreateFile(devicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero); - if(h == _invalidHandleValue) - return ans; + if(h == _invalidHandleValue) return ans; var sdn = new StorageDeviceNumber(); int nBytes = Marshal.SizeOf(sdn); diff --git a/Aaru.Dto/DeviceDto.cs b/Aaru.Dto/DeviceDto.cs index 449c86cfb..757b4e6ea 100644 --- a/Aaru.Dto/DeviceDto.cs +++ b/Aaru.Dto/DeviceDto.cs @@ -97,8 +97,7 @@ public class DeviceDto : DeviceReport TestedMedia[] medias = ATA.RemovableMedias.ToArray(); ATA.RemovableMedias = new List(); - foreach(TestedMedia media in medias) - ATA.RemovableMedias.Add(ClearBinaries(media)); + foreach(TestedMedia media in medias) ATA.RemovableMedias.Add(ClearBinaries(media)); } } @@ -112,8 +111,7 @@ public class DeviceDto : DeviceReport TestedMedia[] medias = ATAPI.RemovableMedias.ToArray(); ATAPI.RemovableMedias = new List(); - foreach(TestedMedia media in medias) - ATAPI.RemovableMedias.Add(ClearBinaries(media)); + foreach(TestedMedia media in medias) ATAPI.RemovableMedias.Add(ClearBinaries(media)); } } @@ -149,32 +147,28 @@ public class DeviceDto : DeviceReport TestedMedia[] medias = SCSI.RemovableMedias.ToArray(); SCSI.RemovableMedias = new List(); - foreach(TestedMedia media in medias) - SCSI.RemovableMedias.Add(ClearBinaries(media)); + foreach(TestedMedia media in medias) SCSI.RemovableMedias.Add(ClearBinaries(media)); } if(SCSI.MultiMediaDevice != null) { SCSI.MultiMediaDevice.ModeSense2AData = null; - if(SCSI.MultiMediaDevice.Features != null) - SCSI.MultiMediaDevice.Features.BinaryData = null; + if(SCSI.MultiMediaDevice.Features != null) SCSI.MultiMediaDevice.Features.BinaryData = null; if(SCSI.MultiMediaDevice.TestedMedia != null) { TestedMedia[] medias = SCSI.MultiMediaDevice.TestedMedia.ToArray(); SCSI.MultiMediaDevice.TestedMedia = new List(); - foreach(TestedMedia media in medias) - SCSI.MultiMediaDevice.TestedMedia.Add(ClearBinaries(media)); + foreach(TestedMedia media in medias) SCSI.MultiMediaDevice.TestedMedia.Add(ClearBinaries(media)); } } SCSI.SequentialDevice = null; } - if(USB != null) - USB.Descriptors = null; + if(USB != null) USB.Descriptors = null; Id = id; OptimalMultipleSectorsRead = optimalMultipleSectorsRead; @@ -192,8 +186,7 @@ public class DeviceDto : DeviceReport static TestedMedia ClearBinaries(TestedMedia media) { - if(media is null) - return null; + if(media is null) return null; media.AdipData = null; media.AtipData = null; diff --git a/Aaru.Filesystems/AODOS/Info.cs b/Aaru.Filesystems/AODOS/Info.cs index a6baa4037..572731160 100644 --- a/Aaru.Filesystems/AODOS/Info.cs +++ b/Aaru.Filesystems/AODOS/Info.cs @@ -52,21 +52,17 @@ public sealed partial class AODOS public bool Identify(IMediaImage imagePlugin, Partition partition) { // Does AO-DOS support hard disks? - if(partition.Start > 0) - return false; + if(partition.Start > 0) return false; // How is it really? - if(imagePlugin.Info.SectorSize != 512) - return false; + if(imagePlugin.Info.SectorSize != 512) return false; // Does AO-DOS support any other kind of disk? - if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600) - return false; + if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600) return false; ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -82,8 +78,7 @@ public sealed partial class AODOS ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector); metadata = new FileSystem(); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -105,8 +100,8 @@ public sealed partial class AODOS sbInformation.AppendFormat(Localization._0_files_in_volume, bb.files).AppendLine(); sbInformation.AppendFormat(Localization._0_used_sectors_on_volume, bb.usedSectors).AppendLine(); - sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(bb.volumeLabel, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(bb.volumeLabel, encoding)) + .AppendLine(); information = sbInformation.ToString(); } diff --git a/Aaru.Filesystems/APFS/Info.cs b/Aaru.Filesystems/APFS/Info.cs index 7f9e6156c..ca59bd934 100644 --- a/Aaru.Filesystems/APFS/Info.cs +++ b/Aaru.Filesystems/APFS/Info.cs @@ -46,13 +46,11 @@ public sealed partial class APFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; ContainerSuperBlock nxSb; @@ -76,13 +74,11 @@ public sealed partial class APFS metadata = new FileSystem(); information = ""; - if(partition.Start >= partition.End) - return; + if(partition.Start >= partition.End) return; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; ContainerSuperBlock nxSb; @@ -95,16 +91,16 @@ public sealed partial class APFS return; } - if(nxSb.magic != APFS_CONTAINER_MAGIC) - return; + if(nxSb.magic != APFS_CONTAINER_MAGIC) return; sbInformation.AppendLine(Localization.Apple_File_System); sbInformation.AppendLine(); sbInformation.AppendFormat(Localization._0_bytes_per_block, nxSb.blockSize).AppendLine(); sbInformation.AppendFormat(Localization.Container_has_0_bytes_in_1_blocks, - nxSb.containerBlocks * nxSb.blockSize, nxSb.containerBlocks). - AppendLine(); + nxSb.containerBlocks * nxSb.blockSize, + nxSb.containerBlocks) + .AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/Acorn/Helpers.cs b/Aaru.Filesystems/Acorn/Helpers.cs index f5e341778..eb37f5fdb 100644 --- a/Aaru.Filesystems/Acorn/Helpers.cs +++ b/Aaru.Filesystems/Acorn/Helpers.cs @@ -39,8 +39,7 @@ public sealed partial class AcornADFS var sum = 0; var carry = 0; - if(length > data.Length) - length = data.Length; + if(length > data.Length) length = data.Length; // ADC r0, r0, r1 // MOVS r0, r0, LSL #24 @@ -97,8 +96,7 @@ public sealed partial class AcornADFS { uint sum = 0; - if(length > data.Count) - length = data.Count; + if(length > data.Count) length = data.Count; // EOR r0, r1, r0, ROR #13 for(var i = 0; i < length; i++) diff --git a/Aaru.Filesystems/Acorn/Info.cs b/Aaru.Filesystems/Acorn/Info.cs index 3ed120a19..46a071af7 100644 --- a/Aaru.Filesystems/Acorn/Info.cs +++ b/Aaru.Filesystems/Acorn/Info.cs @@ -47,14 +47,12 @@ public sealed partial class AcornADFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ulong sbSector; uint sectorsToRead; - if(imagePlugin.Info.SectorSize < 256) - return false; + if(imagePlugin.Info.SectorSize < 256) return false; byte[] sector; ErrorNumber errno; @@ -64,16 +62,14 @@ public sealed partial class AcornADFS { errno = imagePlugin.ReadSector(0, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; byte oldChk0 = AcornMapChecksum(sector, 255); OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector); errno = imagePlugin.ReadSector(1, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; byte oldChk1 = AcornMapChecksum(sector, 255); OldMapSector1 oldMap1 = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -86,8 +82,7 @@ public sealed partial class AcornADFS { errno = imagePlugin.ReadSector(0, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var tmp = new byte[256]; Array.Copy(sector, 256, tmp, 0, 256); @@ -106,13 +101,11 @@ public sealed partial class AcornADFS sbSector = OLD_DIRECTORY_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = OLD_DIRECTORY_SIZE / imagePlugin.Info.SectorSize; - if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; if(sector.Length > OLD_DIRECTORY_SIZE) { @@ -129,7 +122,8 @@ public sealed partial class AcornADFS AaruConsole.DebugWriteLine(MODULE_NAME, "oldRoot.tail.magic at 0x200 = {0}", oldRoot.tail.magic); - AaruConsole.DebugWriteLine(MODULE_NAME, "oldRoot.tail.checkByte at 0x200 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "oldRoot.tail.checkByte at 0x200 = {0}", oldRoot.tail.checkByte); AaruConsole.DebugWriteLine(MODULE_NAME, "dirChk at 0x200 = {0}", dirChk); @@ -142,13 +136,11 @@ public sealed partial class AcornADFS sbSector = NEW_DIRECTORY_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = NEW_DIRECTORY_SIZE / imagePlugin.Info.SectorSize; - if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; if(sector.Length > OLD_DIRECTORY_SIZE) { @@ -165,7 +157,8 @@ public sealed partial class AcornADFS AaruConsole.DebugWriteLine(MODULE_NAME, "oldRoot.tail.magic at 0x400 = {0}", oldRoot.tail.magic); - AaruConsole.DebugWriteLine(MODULE_NAME, "oldRoot.tail.checkByte at 0x400 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "oldRoot.tail.checkByte at 0x400 = {0}", oldRoot.tail.checkByte); AaruConsole.DebugWriteLine(MODULE_NAME, "dirChk at 0x400 = {0}", dirChk); @@ -181,8 +174,7 @@ public sealed partial class AcornADFS errno = imagePlugin.ReadSector(partition.Start, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; byte newChk = NewMapChecksum(sector); AaruConsole.DebugWriteLine(MODULE_NAME, "newChk = {0}", newChk); @@ -191,24 +183,19 @@ public sealed partial class AcornADFS sbSector = BOOT_BLOCK_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = BOOT_BLOCK_SIZE / imagePlugin.Info.SectorSize; - if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; - if(sbSector + partition.Start + sectorsToRead >= partition.End) - return false; + if(sbSector + partition.Start + sectorsToRead >= partition.End) return false; errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var bootChk = 0; - if(bootSector.Length < 512) - return false; + if(bootSector.Length < 512) return false; - for(var i = 0; i < 0x1FF; i++) - bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; + for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; AaruConsole.DebugWriteLine(MODULE_NAME, "bootChk = {0}", bootChk); AaruConsole.DebugWriteLine(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]); @@ -231,20 +218,17 @@ public sealed partial class AcornADFS AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_size_high = {0}", drSb.disc_size_high); AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_size = {0}", drSb.disc_size); - AaruConsole.DebugWriteLine(MODULE_NAME, "IsNullOrEmpty(drSb.reserved) = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "IsNullOrEmpty(drSb.reserved) = {0}", ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)); - if(drSb.log2secsize is < 8 or > 10) - return false; + if(drSb.log2secsize is < 8 or > 10) return false; - if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) - return false; + if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) return false; - if(drSb.disc_size_high >> drSb.log2secsize != 0) - return false; + if(drSb.disc_size_high >> drSb.log2secsize != 0) return false; - if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) - return false; + if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) return false; ulong bytes = drSb.disc_size_high; bytes *= 0x100000000; @@ -276,16 +260,14 @@ public sealed partial class AcornADFS { errno = imagePlugin.ReadSector(0, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; byte oldChk0 = AcornMapChecksum(sector, 255); OldMapSector0 oldMap0 = Marshal.ByteArrayToStructureLittleEndian(sector); errno = imagePlugin.ReadSector(1, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; byte oldChk1 = AcornMapChecksum(sector, 255); OldMapSector1 oldMap1 = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -295,8 +277,7 @@ public sealed partial class AcornADFS { errno = imagePlugin.ReadSector(0, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var tmp = new byte[256]; Array.Copy(sector, 256, tmp, 0, 256); @@ -331,13 +312,11 @@ public sealed partial class AcornADFS sbSector = OLD_DIRECTORY_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = OLD_DIRECTORY_SIZE / imagePlugin.Info.SectorSize; - if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(OLD_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; if(sector.Length > OLD_DIRECTORY_SIZE) { @@ -357,13 +336,11 @@ public sealed partial class AcornADFS sbSector = NEW_DIRECTORY_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = NEW_DIRECTORY_SIZE / imagePlugin.Info.SectorSize; - if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(NEW_DIRECTORY_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; if(sector.Length > OLD_DIRECTORY_SIZE) { @@ -383,8 +360,7 @@ public sealed partial class AcornADFS { errno = imagePlugin.ReadSectors(sbSector, sectorsToRead, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; if(sector.Length > NEW_DIRECTORY_SIZE) { @@ -409,8 +385,8 @@ public sealed partial class AcornADFS sbInformation.AppendFormat(Localization._0_bytes_per_sector, imagePlugin.Info.SectorSize).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_bytes, bytes).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(namebytes, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(namebytes, encoding)) + .AppendLine(); if(oldMap1.discId > 0) { @@ -432,8 +408,7 @@ public sealed partial class AcornADFS errno = imagePlugin.ReadSector(partition.Start, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; byte newChk = NewMapChecksum(sector); AaruConsole.DebugWriteLine(MODULE_NAME, "newChk = {0}", newChk); @@ -442,18 +417,15 @@ public sealed partial class AcornADFS sbSector = BOOT_BLOCK_LOCATION / imagePlugin.Info.SectorSize; sectorsToRead = BOOT_BLOCK_SIZE / imagePlugin.Info.SectorSize; - if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(BOOT_BLOCK_SIZE % imagePlugin.Info.SectorSize > 0) sectorsToRead++; errno = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead, out byte[] bootSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var bootChk = 0; - for(var i = 0; i < 0x1FF; i++) - bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; + for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; AaruConsole.DebugWriteLine(MODULE_NAME, "bootChk = {0}", bootChk); AaruConsole.DebugWriteLine(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]); @@ -486,7 +458,8 @@ public sealed partial class AcornADFS AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_size = {0}", drSb.disc_size); AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_id = {0}", drSb.disc_id); - AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_name = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "drSb.disc_name = {0}", StringHandlers.CToString(drSb.disc_name, encoding)); AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.disc_type = {0}", drSb.disc_type); @@ -496,17 +469,13 @@ public sealed partial class AcornADFS AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.format_version = {0}", drSb.format_version); AaruConsole.DebugWriteLine(MODULE_NAME, "drSb.root_size = {0}", drSb.root_size); - if(drSb.log2secsize is < 8 or > 10) - return; + if(drSb.log2secsize is < 8 or > 10) return; - if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) - return; + if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19) return; - if(drSb.disc_size_high >> drSb.log2secsize != 0) - return; + if(drSb.disc_size_high >> drSb.log2secsize != 0) return; - if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) - return; + if(!ArrayHelpers.ArrayIsNullOrEmpty(drSb.reserved)) return; bytes = drSb.disc_size_high; bytes *= 0x100000000; @@ -516,8 +485,7 @@ public sealed partial class AcornADFS zones *= 0x100000000; zones += drSb.nzones; - if(bytes > imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize) - return; + if(bytes > imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize) return; metadata = new FileSystem(); diff --git a/Aaru.Filesystems/AmigaDOS/Helpers.cs b/Aaru.Filesystems/AmigaDOS/Helpers.cs index 2cd9bad27..dd59863a5 100644 --- a/Aaru.Filesystems/AmigaDOS/Helpers.cs +++ b/Aaru.Filesystems/AmigaDOS/Helpers.cs @@ -67,8 +67,7 @@ public sealed partial class AmigaDOSPlugin { uint psum = sum; - if((sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3])) < psum) - sum++; + if((sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3])) < psum) sum++; } return ~sum; diff --git a/Aaru.Filesystems/AmigaDOS/Info.cs b/Aaru.Filesystems/AmigaDOS/Info.cs index 24f72ae77..f4c52d3f7 100644 --- a/Aaru.Filesystems/AmigaDOS/Info.cs +++ b/Aaru.Filesystems/AmigaDOS/Info.cs @@ -48,8 +48,7 @@ public sealed partial class AmigaDOSPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start + 4 >= partition.End) - return false; + if(partition.Start + 4 >= partition.End) return false; // Boot block is unless defined otherwise, 2 blocks // Funny, you may need boot block to find root block if it's not in standard place just to know size of @@ -59,8 +58,7 @@ public sealed partial class AmigaDOSPlugin // so this is not entirely wrong... ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; BootBlock bblk = Marshal.ByteArrayToStructureBigEndian(sector); @@ -73,15 +71,13 @@ public sealed partial class AmigaDOSPlugin { errno = imagePlugin.ReadSectors(1 + partition.Start, 2, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; bblk = Marshal.ByteArrayToStructureBigEndian(sector); } // Not FFS or MuFS? - if((bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK) - return false; + if((bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK) return false; // Clear checksum on sector sector[4] = sector[5] = sector[6] = sector[7] = 0; @@ -116,14 +112,12 @@ public sealed partial class AmigaDOSPlugin errno = imagePlugin.ReadSector(rootPtr, out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; rblk.type = BigEndianBitConverter.ToUInt32(sector, 0x00); AaruConsole.DebugWriteLine(MODULE_NAME, "rblk.type = {0}", rblk.type); - if(rblk.type != TYPE_HEADER) - continue; + if(rblk.type != TYPE_HEADER) continue; rblk.hashTableSize = BigEndianBitConverter.ToUInt32(sector, 0x0C); @@ -135,16 +129,13 @@ public sealed partial class AmigaDOSPlugin AaruConsole.DebugWriteLine(MODULE_NAME, "blockSize = {0}", blockSize); AaruConsole.DebugWriteLine(MODULE_NAME, "sectorsPerBlock = {0}", sectorsPerBlock); - if(blockSize % sector.Length > 0) - sectorsPerBlock++; + if(blockSize % sector.Length > 0) sectorsPerBlock++; - if(rootPtr + sectorsPerBlock >= partition.End) - continue; + if(rootPtr + sectorsPerBlock >= partition.End) continue; errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; // Clear checksum on sector rblk.checksum = BigEndianBitConverter.ToUInt32(sector, 20); @@ -157,8 +148,7 @@ public sealed partial class AmigaDOSPlugin rblk.sec_type = BigEndianBitConverter.ToUInt32(sector, sector.Length - 4); AaruConsole.DebugWriteLine(MODULE_NAME, "rblk.sec_type = {0}", rblk.sec_type); - if(rblk.sec_type == SUBTYPE_ROOT && rblk.checksum == rsum) - return true; + if(rblk.sec_type == SUBTYPE_ROOT && rblk.checksum == rsum) return true; } return false; @@ -174,8 +164,7 @@ public sealed partial class AmigaDOSPlugin information = null; ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, 2, out byte[] bootBlockSectors); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BootBlock bootBlk = Marshal.ByteArrayToStructureBigEndian(bootBlockSectors); bootBlk.bootCode = new byte[bootBlockSectors.Length - 12]; @@ -213,14 +202,12 @@ public sealed partial class AmigaDOSPlugin errno = imagePlugin.ReadSector(rootPtr, out rootBlockSector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; rootBlk.type = BigEndianBitConverter.ToUInt32(rootBlockSector, 0x00); AaruConsole.DebugWriteLine(MODULE_NAME, "rootBlk.type = {0}", rootBlk.type); - if(rootBlk.type != TYPE_HEADER) - continue; + if(rootBlk.type != TYPE_HEADER) continue; rootBlk.hashTableSize = BigEndianBitConverter.ToUInt32(rootBlockSector, 0x0C); @@ -232,16 +219,13 @@ public sealed partial class AmigaDOSPlugin AaruConsole.DebugWriteLine(MODULE_NAME, "blockSize = {0}", blockSize); AaruConsole.DebugWriteLine(MODULE_NAME, "sectorsPerBlock = {0}", sectorsPerBlock); - if(blockSize % rootBlockSector.Length > 0) - sectorsPerBlock++; + if(blockSize % rootBlockSector.Length > 0) sectorsPerBlock++; - if(rootPtr + sectorsPerBlock >= partition.End) - continue; + if(rootPtr + sectorsPerBlock >= partition.End) continue; errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; // Clear checksum on sector rootBlk.checksum = BigEndianBitConverter.ToUInt32(rootBlockSector, 20); @@ -254,21 +238,18 @@ public sealed partial class AmigaDOSPlugin rootBlk.sec_type = BigEndianBitConverter.ToUInt32(rootBlockSector, rootBlockSector.Length - 4); AaruConsole.DebugWriteLine(MODULE_NAME, "rootBlk.sec_type = {0}", rootBlk.sec_type); - if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum) - continue; + if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum) continue; errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; rootFound = true; break; } - if(!rootFound) - return; + if(!rootFound) return; rootBlk = MarshalRootBlock(rootBlockSector); @@ -318,8 +299,7 @@ public sealed partial class AmigaDOSPlugin break; } - if((bootBlk.diskType & 0x6D754600) == 0x6D754600) - sbInformation.Append(Localization.with_multi_user_patches); + if((bootBlk.diskType & 0x6D754600) == 0x6D754600) sbInformation.Append(Localization.with_multi_user_patches); sbInformation.AppendLine(); @@ -333,13 +313,12 @@ public sealed partial class AmigaDOSPlugin sbInformation.AppendFormat(Localization.Boot_code_SHA1_0, sha1Ctx.End()).AppendLine(); } - if(rootBlk.bitmapFlag == 0xFFFFFFFF) - sbInformation.AppendLine(Localization.Volume_bitmap_is_valid); + if(rootBlk.bitmapFlag == 0xFFFFFFFF) sbInformation.AppendLine(Localization.Volume_bitmap_is_valid); if(rootBlk.bitmapExtensionBlock != 0x00000000 && rootBlk.bitmapExtensionBlock != 0xFFFFFFFF) { - sbInformation.AppendFormat(Localization.Bitmap_extension_at_block_0, rootBlk.bitmapExtensionBlock). - AppendLine(); + sbInformation.AppendFormat(Localization.Bitmap_extension_at_block_0, rootBlk.bitmapExtensionBlock) + .AppendLine(); } if((bootBlk.diskType & 0xFF) == 4 || (bootBlk.diskType & 0xFF) == 5) @@ -351,16 +330,16 @@ public sealed partial class AmigaDOSPlugin sbInformation.AppendFormat(Localization.Volume_has_0_blocks, blocks).AppendLine(); sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks)). - AppendLine(); + DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_last_modified_on_0, - DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks)). - AppendLine(); + DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_root_directory_last_modified_on_0, - DateHandlers.AmigaToDateTime(rootBlk.rDays, rootBlk.rMins, rootBlk.rTicks)). - AppendLine(); + DateHandlers.AmigaToDateTime(rootBlk.rDays, rootBlk.rMins, rootBlk.rTicks)) + .AppendLine(); sbInformation.AppendFormat(Localization.Root_block_checksum_is_0, rootBlk.checksum).AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/AppleCommon/Info.cs b/Aaru.Filesystems/AppleCommon/Info.cs index 6440c08f4..7a0e89b0e 100644 --- a/Aaru.Filesystems/AppleCommon/Info.cs +++ b/Aaru.Filesystems/AppleCommon/Info.cs @@ -37,13 +37,11 @@ static partial class AppleCommon { internal static string GetBootBlockInformation(byte[] bbSector, Encoding encoding) { - if(bbSector is null || bbSector.Length < 0x100) - return null; + if(bbSector is null || bbSector.Length < 0x100) return null; BootBlock bb = Marshal.ByteArrayToStructureBigEndian(bbSector); - if(bb.bbID != BB_MAGIC) - return null; + if(bb.bbID != BB_MAGIC) return null; var sb = new StringBuilder(); sb.AppendLine(Localization.Boot_Block); @@ -58,15 +56,15 @@ static partial class AppleCommon if((bb.bbVersion & 0x2000) > 0) { - sb. - AppendFormat(Localization.System_heap_will_be_extended_by_0_bytes_and_a_1_fraction_of_the_available_RAM, - bb.bbSysHeapExtra, bb.bbSysHeapFract). - AppendLine(); + sb.AppendFormat(Localization + .System_heap_will_be_extended_by_0_bytes_and_a_1_fraction_of_the_available_RAM, + bb.bbSysHeapExtra, + bb.bbSysHeapFract) + .AppendLine(); } } } - else if((bb.bbVersion & 0xFF) == 0x0D) - sb.AppendLine(Localization.Boot_block_should_be_executed); + else if((bb.bbVersion & 0xFF) == 0x0D) sb.AppendLine(Localization.Boot_block_should_be_executed); switch(bb.bbPageFlags) { @@ -80,28 +78,28 @@ static partial class AppleCommon break; } - sb.AppendFormat(Localization.System_filename_0, StringHandlers.PascalToString(bb.bbSysName, encoding)). - AppendLine(); + sb.AppendFormat(Localization.System_filename_0, StringHandlers.PascalToString(bb.bbSysName, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Finder_filename_0, StringHandlers.PascalToString(bb.bbShellName, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Finder_filename_0, StringHandlers.PascalToString(bb.bbShellName, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Debugger_filename_0, StringHandlers.PascalToString(bb.bbDbg1Name, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Debugger_filename_0, StringHandlers.PascalToString(bb.bbDbg1Name, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Disassembler_filename_0, StringHandlers.PascalToString(bb.bbDbg2Name, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Disassembler_filename_0, StringHandlers.PascalToString(bb.bbDbg2Name, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Startup_screen_filename_0, - StringHandlers.PascalToString(bb.bbScreenName, encoding)). - AppendLine(); + StringHandlers.PascalToString(bb.bbScreenName, encoding)) + .AppendLine(); sb.AppendFormat(Localization.First_program_to_execute_at_boot_0, - StringHandlers.PascalToString(bb.bbHelloName, encoding)). - AppendLine(); + StringHandlers.PascalToString(bb.bbHelloName, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Clipboard_filename_0, StringHandlers.PascalToString(bb.bbScrapName, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Clipboard_filename_0, StringHandlers.PascalToString(bb.bbScrapName, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Maximum_opened_files_0, bb.bbCntFCBs * 4).AppendLine(); sb.AppendFormat(Localization.Event_queue_size_0, bb.bbCntEvts).AppendLine(); diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs index 6b43134fe..b5e729cab 100644 --- a/Aaru.Filesystems/AppleDOS/Dir.cs +++ b/Aaru.Filesystems/AppleDOS/Dir.cs @@ -57,8 +57,7 @@ public sealed partial class AppleDOS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return ErrorNumber.NotSupported; @@ -89,17 +88,13 @@ public sealed partial class AppleDOS { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not AppleDosDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleDosDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; @@ -109,8 +104,7 @@ public sealed partial class AppleDOS /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not AppleDosDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleDosDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; @@ -129,21 +123,18 @@ public sealed partial class AppleDOS _fileTypeCache = new Dictionary(); _lockedFiles = new List(); - if(lba == 0 || lba > _device.Info.Sectors) - return ErrorNumber.InvalidArgument; + if(lba == 0 || lba > _device.Info.Sectors) return ErrorNumber.InvalidArgument; while(lba != 0) { _usedSectors++; ErrorNumber errno = _device.ReadSector(lba, out byte[] catSectorB); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _totalFileEntries += 7; - if(_debug) - catalogMs.Write(catSectorB, 0, catSectorB.Length); + if(_debug) catalogMs.Write(catSectorB, 0, catSectorB.Length); // Read the catalog sector CatalogSector catSector = Marshal.ByteArrayToStructureLittleEndian(catSectorB); @@ -157,26 +148,22 @@ public sealed partial class AppleDOS var ts = (ushort)(entry.extentTrack << 8 | entry.extentSector); // Apple DOS has high byte set over ASCII. - for(var i = 0; i < 30; i++) - filenameB[i] = (byte)(entry.filename[i] & 0x7F); + for(var i = 0; i < 30; i++) filenameB[i] = (byte)(entry.filename[i] & 0x7F); string filename = StringHandlers.SpacePaddedToString(filenameB, _encoding); _catalogCache.TryAdd(filename, ts); _fileTypeCache.TryAdd(filename, (byte)(entry.typeAndFlags & 0x7F)); - if((entry.typeAndFlags & 0x80) == 0x80 && !_lockedFiles.Contains(filename)) - _lockedFiles.Add(filename); + if((entry.typeAndFlags & 0x80) == 0x80 && !_lockedFiles.Contains(filename)) _lockedFiles.Add(filename); } lba = (ulong)(catSector.trackOfNext * _sectorsPerTrack + catSector.sectorOfNext); - if(lba > _device.Info.Sectors) - break; + if(lba > _device.Info.Sectors) break; } - if(_debug) - _catalogBlocks = catalogMs.ToArray(); + if(_debug) _catalogBlocks = catalogMs.ToArray(); return ErrorNumber.NoError; } diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index f5d7f9569..6d31f9db4 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -47,27 +47,24 @@ public sealed partial class AppleDOS { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(!_fileCache.ContainsKey(filename)) - return ErrorNumber.NoSuchFile; + if(!_fileCache.ContainsKey(filename)) return ErrorNumber.NoSuchFile; attributes = FileAttributes.Extents; attributes |= FileAttributes.File; - if(_lockedFiles.Contains(filename)) - attributes |= FileAttributes.ReadOnly; + if(_lockedFiles.Contains(filename)) attributes |= FileAttributes.ReadOnly; if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || @@ -82,22 +79,20 @@ public sealed partial class AppleDOS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; byte[] file; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 30) - return ErrorNumber.NameTooLong; + if(filename.Length > 30) return ErrorNumber.NameTooLong; if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || @@ -117,11 +112,9 @@ public sealed partial class AppleDOS { ErrorNumber error = CacheFile(filename); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; - if(!_fileCache.TryGetValue(filename, out file)) - return ErrorNumber.InvalidArgument; + if(!_fileCache.TryGetValue(filename, out file)) return ErrorNumber.InvalidArgument; } } @@ -139,11 +132,9 @@ public sealed partial class AppleDOS /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not AppleDosFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleDosFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Cache = null; @@ -155,19 +146,15 @@ public sealed partial class AppleDOS { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not AppleDosFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleDosFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; Array.Copy(mynode.Cache, mynode.Offset, buffer, 0, read); @@ -181,24 +168,21 @@ public sealed partial class AppleDOS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 30) - return ErrorNumber.NameTooLong; + if(filename.Length > 30) return ErrorNumber.NameTooLong; - if(!_fileCache.ContainsKey(filename)) - return ErrorNumber.NoSuchFile; + if(!_fileCache.ContainsKey(filename)) return ErrorNumber.NoSuchFile; stat = new FileEntryInfo(); @@ -237,20 +221,18 @@ public sealed partial class AppleDOS ErrorNumber CacheFile(string path) { string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 30) - return ErrorNumber.NameTooLong; + if(filename.Length > 30) return ErrorNumber.NameTooLong; - if(!_catalogCache.TryGetValue(filename, out ushort ts)) - return ErrorNumber.NoSuchFile; + if(!_catalogCache.TryGetValue(filename, out ushort ts)) return ErrorNumber.NoSuchFile; var lba = (ulong)(((ts & 0xFF00) >> 8) * _sectorsPerTrack + (ts & 0xFF)); var fileMs = new MemoryStream(); @@ -262,11 +244,9 @@ public sealed partial class AppleDOS _usedSectors++; ErrorNumber errno = _device.ReadSector(lba, out byte[] tsSectorB); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; - if(_debug) - tsListMs.Write(tsSectorB, 0, tsSectorB.Length); + if(_debug) tsListMs.Write(tsSectorB, 0, tsSectorB.Length); // Read the track/sector list sector TrackSectorList tsSector = Marshal.ByteArrayToStructureLittleEndian(tsSectorB); @@ -286,13 +266,11 @@ public sealed partial class AppleDOS var blockLba = (ulong)(entry.track * _sectorsPerTrack + entry.sector); - if(blockLba == 0) - break; + if(blockLba == 0) break; errno = _device.ReadSector(blockLba, out byte[] fileBlock); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; fileMs.Write(fileBlock, 0, fileBlock.Length); expectedBlock++; @@ -301,14 +279,11 @@ public sealed partial class AppleDOS lba = (ulong)(tsSector.nextListTrack * _sectorsPerTrack + tsSector.nextListSector); } - if(_fileCache.ContainsKey(filename)) - _fileCache.Remove(filename); + if(_fileCache.ContainsKey(filename)) _fileCache.Remove(filename); - if(_extentCache.ContainsKey(filename)) - _extentCache.Remove(filename); + if(_extentCache.ContainsKey(filename)) _extentCache.Remove(filename); - if(_fileSizeCache.ContainsKey(filename)) - _fileSizeCache.Remove(filename); + if(_fileSizeCache.ContainsKey(filename)) _fileSizeCache.Remove(filename); _fileCache.Add(filename, fileMs.ToArray()); _extentCache.Add(filename, tsListMs.ToArray()); @@ -327,16 +302,13 @@ public sealed partial class AppleDOS uint tracksOnBoot = 1; - if(!_track1UsedByFiles) - tracksOnBoot++; + if(!_track1UsedByFiles) tracksOnBoot++; - if(!_track2UsedByFiles) - tracksOnBoot++; + if(!_track2UsedByFiles) tracksOnBoot++; ErrorNumber errno = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack), out _bootBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _usedSectors += (uint)(_bootBlocks.Length / _vtoc.bytesPerSector); diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs index 3a48592ca..6faec4af8 100644 --- a/Aaru.Filesystems/AppleDOS/Info.cs +++ b/Aaru.Filesystems/AppleDOS/Info.cs @@ -42,18 +42,15 @@ public sealed partial class AppleDOS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.Sectors != 455 && imagePlugin.Info.Sectors != 560) - return false; + if(imagePlugin.Info.Sectors != 455 && imagePlugin.Info.Sectors != 560) return false; - if(partition.Start > 0 || imagePlugin.Info.SectorSize != 256) - return false; + if(partition.Start > 0 || imagePlugin.Info.SectorSize != 256) return false; int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; _vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); @@ -75,16 +72,15 @@ public sealed partial class AppleDOS ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; _vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); sb.AppendLine(Localization.AppleDOS_Name); sb.AppendLine(); - sb.AppendFormat(Localization.Catalog_starts_at_sector_0_of_track_1, _vtoc.catalogSector, _vtoc.catalogTrack). - AppendLine(); + sb.AppendFormat(Localization.Catalog_starts_at_sector_0_of_track_1, _vtoc.catalogSector, _vtoc.catalogTrack) + .AppendLine(); sb.AppendFormat(Localization.File_system_initialized_by_DOS_release_0, _vtoc.dosRelease).AppendLine(); sb.AppendFormat(Localization.Disk_volume_number_0, _vtoc.volumeNumber).AppendLine(); diff --git a/Aaru.Filesystems/AppleDOS/Structs.cs b/Aaru.Filesystems/AppleDOS/Structs.cs index 78363fde9..28c8afb1c 100644 --- a/Aaru.Filesystems/AppleDOS/Structs.cs +++ b/Aaru.Filesystems/AppleDOS/Structs.cs @@ -40,12 +40,12 @@ public sealed partial class AppleDOS internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -56,7 +56,7 @@ public sealed partial class AppleDOS { internal byte[] Cache; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -67,7 +67,7 @@ public sealed partial class AppleDOS /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index 6a5f3c2c4..76308e2dd 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -77,8 +77,7 @@ public sealed partial class AppleDOS // Read the VTOC ErrorNumber error = _device.ReadSector((ulong)(17 * _sectorsPerTrack), out _vtocBlocks); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; _vtoc = Marshal.ByteArrayToStructureLittleEndian(_vtocBlocks); @@ -120,8 +119,7 @@ public sealed partial class AppleDOS options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); _mounted = true; diff --git a/Aaru.Filesystems/AppleDOS/Xattr.cs b/Aaru.Filesystems/AppleDOS/Xattr.cs index bd3d7d994..93e3695d8 100644 --- a/Aaru.Filesystems/AppleDOS/Xattr.cs +++ b/Aaru.Filesystems/AppleDOS/Xattr.cs @@ -45,21 +45,19 @@ public sealed partial class AppleDOS { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 30) - return ErrorNumber.NameTooLong; + if(filename.Length > 30) return ErrorNumber.NameTooLong; xattrs = new List(); @@ -69,13 +67,11 @@ public sealed partial class AppleDOS string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) {} else { - if(!_catalogCache.ContainsKey(filename)) - return ErrorNumber.NoSuchFile; + if(!_catalogCache.ContainsKey(filename)) return ErrorNumber.NoSuchFile; xattrs.Add("com.apple.dos.type"); - if(_debug) - xattrs.Add("com.apple.dos.tracksectorlist"); + if(_debug) xattrs.Add("com.apple.dos.tracksectorlist"); } return ErrorNumber.NoError; @@ -84,21 +80,19 @@ public sealed partial class AppleDOS /// public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 30) - return ErrorNumber.NameTooLong; + if(filename.Length > 30) return ErrorNumber.NameTooLong; if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || @@ -106,13 +100,11 @@ public sealed partial class AppleDOS string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) return ErrorNumber.NoSuchExtendedAttribute; - if(!_catalogCache.ContainsKey(filename)) - return ErrorNumber.NoSuchFile; + if(!_catalogCache.ContainsKey(filename)) return ErrorNumber.NoSuchFile; if(string.Compare(xattr, "com.apple.dos.type", StringComparison.InvariantCulture) == 0) { - if(!_fileTypeCache.TryGetValue(filename, out byte type)) - return ErrorNumber.InvalidArgument; + if(!_fileTypeCache.TryGetValue(filename, out byte type)) return ErrorNumber.InvalidArgument; buf = new byte[1]; buf[0] = type; @@ -123,8 +115,7 @@ public sealed partial class AppleDOS if(string.Compare(xattr, "com.apple.dos.tracksectorlist", StringComparison.InvariantCulture) != 0 || !_debug) return ErrorNumber.NoSuchExtendedAttribute; - if(!_extentCache.TryGetValue(filename, out byte[] ts)) - return ErrorNumber.InvalidArgument; + if(!_extentCache.TryGetValue(filename, out byte[] ts)) return ErrorNumber.InvalidArgument; buf = new byte[ts.Length]; Array.Copy(ts, 0, buf, 0, buf.Length); diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs index 9d325443f..d7f5847bd 100644 --- a/Aaru.Filesystems/AppleHFS/Info.cs +++ b/Aaru.Filesystems/AppleHFS/Info.cs @@ -46,8 +46,7 @@ public sealed partial class AppleHFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; byte[] mdbSector; ushort drSigWord; @@ -57,18 +56,16 @@ public sealed partial class AppleHFS { errno = imagePlugin.ReadSectors(partition.Start, 2, out mdbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; foreach(int offset in new[] - { - 0, 0x200, 0x400, 0x600, 0x800, 0xA00 - }.Where(offset => mdbSector.Length >= offset + 0x7C + 2)) + { + 0, 0x200, 0x400, 0x600, 0x800, 0xA00 + }.Where(offset => mdbSector.Length >= offset + 0x7C + 2)) { drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, offset); - if(drSigWord != AppleCommon.HFS_MAGIC) - continue; + if(drSigWord != AppleCommon.HFS_MAGIC) continue; drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, offset + 0x7C); // Seek to embedded HFS+ signature @@ -79,16 +76,13 @@ public sealed partial class AppleHFS { errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(mdbSector.Length < 0x7C + 2) - return false; + if(mdbSector.Length < 0x7C + 2) return false; drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0); - if(drSigWord != AppleCommon.HFS_MAGIC) - return false; + if(drSigWord != AppleCommon.HFS_MAGIC) return false; drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x7C); // Seek to embedded HFS+ signature @@ -119,24 +113,21 @@ public sealed partial class AppleHFS { errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmpSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; foreach(int offset in new[] - { - 0, 0x200, 0x400, 0x600, 0x800, 0xA00 - }) + { + 0, 0x200, 0x400, 0x600, 0x800, 0xA00 + }) { drSigWord = BigEndianBitConverter.ToUInt16(tmpSector, offset); - if(drSigWord != AppleCommon.HFS_MAGIC) - continue; + if(drSigWord != AppleCommon.HFS_MAGIC) continue; bbSector = new byte[1024]; mdbSector = new byte[512]; - if(offset >= 0x400) - Array.Copy(tmpSector, offset - 0x400, bbSector, 0, 1024); + if(offset >= 0x400) Array.Copy(tmpSector, offset - 0x400, bbSector, 0, 1024); Array.Copy(tmpSector, offset, mdbSector, 0, 512); apmFromHddOnCd = true; @@ -144,15 +135,13 @@ public sealed partial class AppleHFS break; } - if(!apmFromHddOnCd) - return; + if(!apmFromHddOnCd) return; } else { errno = imagePlugin.ReadSector(2 + partition.Start, out mdbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0); @@ -160,8 +149,7 @@ public sealed partial class AppleHFS { errno = imagePlugin.ReadSector(partition.Start, out bbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; } else return; @@ -206,8 +194,7 @@ public sealed partial class AppleHFS if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.ReusedIds)) sb.AppendLine(Localization.There_are_reused_CNIDs); - if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Journaled)) - sb.AppendLine(Localization.Volume_is_journaled); + if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Journaled)) sb.AppendLine(Localization.Volume_is_journaled); if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Inconsistent)) sb.AppendLine(Localization.Volume_is_seriously_inconsistent); @@ -277,8 +264,7 @@ public sealed partial class AppleHFS metadata = new FileSystem(); - if(mdb.drVolBkUp > 0) - metadata.BackupDate = DateHandlers.MacToDateTime(mdb.drVolBkUp); + if(mdb.drVolBkUp > 0) metadata.BackupDate = DateHandlers.MacToDateTime(mdb.drVolBkUp); metadata.Bootable = bootBlockInfo != null || mdb.drFndrInfo0 != 0 || mdb.drFndrInfo3 != 0 || mdb.drFndrInfo5 != 0; @@ -286,15 +272,13 @@ public sealed partial class AppleHFS metadata.Clusters = mdb.drNmAlBlks; metadata.ClusterSize = mdb.drAlBlkSiz; - if(mdb.drCrDate > 0) - metadata.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); + if(mdb.drCrDate > 0) metadata.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); metadata.Dirty = !mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Unmounted); metadata.Files = mdb.drFilCnt; metadata.FreeClusters = mdb.drFreeBks; - if(mdb.drLsMod > 0) - metadata.ModificationDate = DateHandlers.MacToDateTime(mdb.drLsMod); + if(mdb.drLsMod > 0) metadata.ModificationDate = DateHandlers.MacToDateTime(mdb.drLsMod); metadata.Type = FS_TYPE; metadata.VolumeName = StringHandlers.PascalToString(mdb.drVN, encoding); diff --git a/Aaru.Filesystems/AppleHFSPlus/Info.cs b/Aaru.Filesystems/AppleHFSPlus/Info.cs index b6788e6cb..41e62ed40 100644 --- a/Aaru.Filesystems/AppleHFSPlus/Info.cs +++ b/Aaru.Filesystems/AppleHFSPlus/Info.cs @@ -46,23 +46,19 @@ public sealed partial class AppleHFSPlus /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ulong hfspOffset; uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; - if(0x800 % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(vhSector.Length < 0x800) - return false; + if(vhSector.Length < 0x800) return false; var drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); @@ -87,11 +83,11 @@ public sealed partial class AppleHFSPlus else hfspOffset = 0; - errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, + errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, + sectorsToRead, out vhSector); // Read volume header - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); @@ -112,13 +108,11 @@ public sealed partial class AppleHFSPlus uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; - if(0x800 % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; + if(0x800 % imagePlugin.Info.SectorSize > 0) sectorsToRead++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); @@ -150,16 +144,15 @@ public sealed partial class AppleHFSPlus wrapped = false; } - errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, + errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, + sectorsToRead, out vhSector); // Read volume header - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; vh.signature = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - if(vh.signature != AppleCommon.HFSP_MAGIC && vh.signature != AppleCommon.HFSX_MAGIC) - return; + if(vh.signature != AppleCommon.HFSP_MAGIC && vh.signature != AppleCommon.HFSX_MAGIC) return; var sb = new StringBuilder(); @@ -175,8 +168,7 @@ public sealed partial class AppleHFSPlus break; } - if(wrapped) - sb.AppendLine(Localization.Volume_is_wrapped_inside_an_HFS_volume); + if(wrapped) sb.AppendLine(Localization.Volume_is_wrapped_inside_an_HFS_volume); var tmp = new byte[0x400]; Array.Copy(vhSector, 0x400, tmp, 0, 0x400); @@ -188,54 +180,46 @@ public sealed partial class AppleHFSPlus { sb.AppendFormat(Localization.Filesystem_version_is_0, vh.version).AppendLine(); - if((vh.attributes & 0x80) == 0x80) - sb.AppendLine(Localization.Volume_is_locked_by_hardware); + if((vh.attributes & 0x80) == 0x80) sb.AppendLine(Localization.Volume_is_locked_by_hardware); - if((vh.attributes & 0x100) == 0x100) - sb.AppendLine(Localization.Volume_is_unmounted); + if((vh.attributes & 0x100) == 0x100) sb.AppendLine(Localization.Volume_is_unmounted); - if((vh.attributes & 0x200) == 0x200) - sb.AppendLine(Localization.There_are_bad_blocks_in_the_extents_file); + if((vh.attributes & 0x200) == 0x200) sb.AppendLine(Localization.There_are_bad_blocks_in_the_extents_file); - if((vh.attributes & 0x400) == 0x400) - sb.AppendLine(Localization.Volume_does_not_need_cache); + if((vh.attributes & 0x400) == 0x400) sb.AppendLine(Localization.Volume_does_not_need_cache); - if((vh.attributes & 0x800) == 0x800) - sb.AppendLine(Localization.Volume_state_is_inconsistent); + if((vh.attributes & 0x800) == 0x800) sb.AppendLine(Localization.Volume_state_is_inconsistent); - if((vh.attributes & 0x1000) == 0x1000) - sb.AppendLine(Localization.There_are_reused_CNIDs); + if((vh.attributes & 0x1000) == 0x1000) sb.AppendLine(Localization.There_are_reused_CNIDs); - if((vh.attributes & 0x2000) == 0x2000) - sb.AppendLine(Localization.Volume_is_journaled); + if((vh.attributes & 0x2000) == 0x2000) sb.AppendLine(Localization.Volume_is_journaled); - if((vh.attributes & 0x8000) == 0x8000) - sb.AppendLine(Localization.Volume_is_locked_by_software); + if((vh.attributes & 0x8000) == 0x8000) sb.AppendLine(Localization.Volume_is_locked_by_software); sb.AppendFormat(Localization.Implementation_that_last_mounted_the_volume_0, - Encoding.ASCII.GetString(vh.lastMountedVersion)). - AppendLine(); + Encoding.ASCII.GetString(vh.lastMountedVersion)) + .AppendLine(); if((vh.attributes & 0x2000) == 0x2000) sb.AppendFormat(Localization.Journal_starts_at_allocation_block_0, vh.journalInfoBlock).AppendLine(); sb.AppendFormat(Localization.Creation_date_0, DateHandlers.MacToDateTime(vh.createDate)).AppendLine(); - sb.AppendFormat(Localization.Last_modification_date_0, DateHandlers.MacToDateTime(vh.modifyDate)). - AppendLine(); + sb.AppendFormat(Localization.Last_modification_date_0, DateHandlers.MacToDateTime(vh.modifyDate)) + .AppendLine(); if(vh.backupDate > 0) { - sb.AppendFormat(Localization.Last_backup_date_0, DateHandlers.MacToDateTime(vh.backupDate)). - AppendLine(); + sb.AppendFormat(Localization.Last_backup_date_0, DateHandlers.MacToDateTime(vh.backupDate)) + .AppendLine(); } else sb.AppendLine(Localization.Volume_has_never_been_backed_up); if(vh.backupDate > 0) { - sb.AppendFormat(Localization.Last_check_date_0, DateHandlers.MacToDateTime(vh.checkedDate)). - AppendLine(); + sb.AppendFormat(Localization.Last_check_date_0, DateHandlers.MacToDateTime(vh.checkedDate)) + .AppendLine(); } else sb.AppendLine(Localization.Volume_has_never_been_checked_up); @@ -267,22 +251,19 @@ public sealed partial class AppleHFSPlus metadata = new FileSystem(); - if(vh.backupDate > 0) - metadata.BackupDate = DateHandlers.MacToDateTime(vh.backupDate); + if(vh.backupDate > 0) metadata.BackupDate = DateHandlers.MacToDateTime(vh.backupDate); metadata.Bootable |= vh.drFndrInfo0 != 0 || vh.drFndrInfo3 != 0 || vh.drFndrInfo5 != 0; metadata.Clusters = vh.totalBlocks; metadata.ClusterSize = vh.blockSize; - if(vh.createDate > 0) - metadata.CreationDate = DateHandlers.MacToDateTime(vh.createDate); + if(vh.createDate > 0) metadata.CreationDate = DateHandlers.MacToDateTime(vh.createDate); metadata.Dirty = (vh.attributes & 0x100) != 0x100; metadata.Files = vh.fileCount; metadata.FreeClusters = vh.freeBlocks; - if(vh.modifyDate > 0) - metadata.ModificationDate = DateHandlers.MacToDateTime(vh.modifyDate); + if(vh.modifyDate > 0) metadata.ModificationDate = DateHandlers.MacToDateTime(vh.modifyDate); metadata.Type = vh.signature switch { diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index 07d134568..efcd4d041 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -46,8 +46,7 @@ public sealed partial class AppleMFS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return ErrorNumber.NotSupported; @@ -60,8 +59,7 @@ public sealed partial class AppleMFS contents.Add("$Bitmap"); contents.Add("$MDB"); - if(_bootBlocks != null) - contents.Add("$Boot"); + if(_bootBlocks != null) contents.Add("$Boot"); } contents.Sort(); @@ -81,17 +79,13 @@ public sealed partial class AppleMFS { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not AppleMfsDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleMfsDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode._position < 0) - return ErrorNumber.InvalidArgument; + if(mynode._position < 0) return ErrorNumber.InvalidArgument; - if(mynode._position >= mynode._contents.Length) - return ErrorNumber.NoError; + if(mynode._position >= mynode._contents.Length) return ErrorNumber.NoError; filename = mynode._contents[mynode._position++]; @@ -101,8 +95,7 @@ public sealed partial class AppleMFS /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not AppleMfsDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleMfsDirNode mynode) return ErrorNumber.InvalidArgument; mynode._position = -1; mynode._contents = null; @@ -127,8 +120,7 @@ public sealed partial class AppleMFS flFlags = (FileFlags)_directoryBlocks[offset + 0] }; - if(!entry.flFlags.HasFlag(FileFlags.Used)) - break; + if(!entry.flFlags.HasFlag(FileFlags.Used)) break; entry.flTyp = _directoryBlocks[offset + 1]; @@ -146,9 +138,9 @@ public sealed partial class AppleMFS entry.flNam = new byte[_directoryBlocks[offset + 50] + 1]; Array.Copy(_directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length); - string lowerFilename = StringHandlers.PascalToString(entry.flNam, _encoding). - ToLowerInvariant(). - Replace('/', ':'); + string lowerFilename = StringHandlers.PascalToString(entry.flNam, _encoding) + .ToLowerInvariant() + .Replace('/', ':'); if(entry.flFlags.HasFlag(FileFlags.Used) && !_idToFilename.ContainsKey(entry.flFlNum) && @@ -173,21 +165,23 @@ public sealed partial class AppleMFS AaruConsole.DebugWriteLine(MODULE_NAME, "entry.flRLgLen = {0}", entry.flRLgLen); AaruConsole.DebugWriteLine(MODULE_NAME, "entry.flRPyLen = {0}", entry.flRPyLen); - AaruConsole.DebugWriteLine(MODULE_NAME, "entry.flCrDat = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "entry.flCrDat = {0}", DateHandlers.MacToDateTime(entry.flCrDat)); - AaruConsole.DebugWriteLine(MODULE_NAME, "entry.flMdDat = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "entry.flMdDat = {0}", DateHandlers.MacToDateTime(entry.flMdDat)); - AaruConsole.DebugWriteLine(MODULE_NAME, "entry.flNam0 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "entry.flNam0 = {0}", StringHandlers.PascalToString(entry.flNam, _encoding)); } offset += 50 + entry.flNam.Length; // "Entries are always an integral number of words" - if(offset % 2 != 0) - offset++; + if(offset % 2 != 0) offset++; // TODO: "Entries don't cross logical block boundaries" } diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index 8d70e40a7..749d1a472 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -47,30 +47,25 @@ public sealed partial class AppleMFS { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; path = pathElements[0]; - if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return ErrorNumber.NoSuchFile; + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile; - if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return ErrorNumber.NoSuchFile; + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias)) - attributes |= FileAttributes.Alias; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias)) attributes |= FileAttributes.Alias; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBundle)) - attributes |= FileAttributes.Bundle; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBundle)) attributes |= FileAttributes.Bundle; if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBeenInited)) attributes |= FileAttributes.HasBeenInited; @@ -78,20 +73,15 @@ public sealed partial class AppleMFS if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasCustomIcon)) attributes |= FileAttributes.HasCustomIcon; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasNoINITs)) - attributes |= FileAttributes.HasNoINITs; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasNoINITs)) attributes |= FileAttributes.HasNoINITs; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsInvisible)) - attributes |= FileAttributes.Hidden; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsInvisible)) attributes |= FileAttributes.Hidden; - if(entry.flFlags.HasFlag(FileFlags.Locked)) - attributes |= FileAttributes.Immutable; + if(entry.flFlags.HasFlag(FileFlags.Locked)) attributes |= FileAttributes.Immutable; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsOnDesk)) - attributes |= FileAttributes.IsOnDesk; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsOnDesk)) attributes |= FileAttributes.IsOnDesk; - if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsShared)) - attributes |= FileAttributes.Shared; + if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsShared)) attributes |= FileAttributes.Shared; if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsStationery)) attributes |= FileAttributes.Stationery; @@ -111,8 +101,7 @@ public sealed partial class AppleMFS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; byte[] file; ErrorNumber error = ErrorNumber.NoError; @@ -141,8 +130,7 @@ public sealed partial class AppleMFS break; } - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; node = new AppleMfsFileNode { @@ -158,11 +146,9 @@ public sealed partial class AppleMFS /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not AppleMfsFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleMfsFileNode mynode) return ErrorNumber.InvalidArgument; mynode._cache = null; @@ -174,19 +160,15 @@ public sealed partial class AppleMFS { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not AppleMfsFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not AppleMfsFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; Array.Copy(mynode._cache, mynode.Offset, buffer, 0, read); @@ -200,16 +182,15 @@ public sealed partial class AppleMFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; path = pathElements[0]; @@ -257,16 +238,13 @@ public sealed partial class AppleMFS } } - if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return ErrorNumber.NoSuchFile; + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile; - if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return ErrorNumber.NoSuchFile; + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile; ErrorNumber error = GetAttributes(path, out FileAttributes attr); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; stat = new FileEntryInfo { @@ -297,24 +275,21 @@ public sealed partial class AppleMFS { buf = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; path = pathElements[0]; - if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return ErrorNumber.NoSuchFile; + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile; - if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return ErrorNumber.NoSuchFile; + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile; uint nextBlock; @@ -346,16 +321,19 @@ public sealed partial class AppleMFS do { ErrorNumber errno = tags - ? _device. - ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, - (uint)_sectorsPerBlock, SectorTagType.AppleSectorTag, - out byte[] sectors) - : _device. - ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, - (uint)_sectorsPerBlock, out sectors); + ? _device.ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + + _volMdb.drAlBlSt + + _partitionStart, + (uint)_sectorsPerBlock, + SectorTagType.AppleSectorTag, + out byte[] sectors) + : _device.ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) + + _volMdb.drAlBlSt + + _partitionStart, + (uint)_sectorsPerBlock, + out sectors); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sectors, 0, sectors.Length); diff --git a/Aaru.Filesystems/AppleMFS/Info.cs b/Aaru.Filesystems/AppleMFS/Info.cs index 0f1128042..1e255b201 100644 --- a/Aaru.Filesystems/AppleMFS/Info.cs +++ b/Aaru.Filesystems/AppleMFS/Info.cs @@ -46,13 +46,11 @@ public sealed partial class AppleMFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); @@ -73,18 +71,15 @@ public sealed partial class AppleMFS ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] mdbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; mdb.drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); - if(mdb.drSigWord != MFS_MAGIC) - return; + if(mdb.drSigWord != MFS_MAGIC) return; mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002); mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006); @@ -160,15 +155,13 @@ public sealed partial class AppleMFS metadata = new FileSystem(); - if(mdb.drLsBkUp > 0) - metadata.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp); + if(mdb.drLsBkUp > 0) metadata.BackupDate = DateHandlers.MacToDateTime(mdb.drLsBkUp); metadata.Bootable = bootBlockInfo != null; metadata.Clusters = mdb.drNmAlBlks; metadata.ClusterSize = mdb.drAlBlkSiz; - if(mdb.drCrDate > 0) - metadata.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); + if(mdb.drCrDate > 0) metadata.CreationDate = DateHandlers.MacToDateTime(mdb.drCrDate); metadata.Files = mdb.drNmFls; metadata.FreeClusters = mdb.drFreeBks; diff --git a/Aaru.Filesystems/AppleMFS/Structs.cs b/Aaru.Filesystems/AppleMFS/Structs.cs index 2326bd8ad..58c560a19 100644 --- a/Aaru.Filesystems/AppleMFS/Structs.cs +++ b/Aaru.Filesystems/AppleMFS/Structs.cs @@ -46,12 +46,12 @@ public sealed partial class AppleMFS internal string[] _contents; internal int _position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -62,7 +62,7 @@ public sealed partial class AppleMFS { internal byte[] _cache; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -73,7 +73,7 @@ public sealed partial class AppleMFS /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index 481bc5644..2e6a4363d 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -55,25 +55,21 @@ public sealed partial class AppleMFS options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); _volMdb = new MasterDirectoryBlock(); ErrorNumber errno = _device.ReadSector(2 + _partitionStart, out _mdbBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; errno = _device.ReadSector(0 + _partitionStart, out _bootBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _volMdb.drSigWord = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x000); - if(_volMdb.drSigWord != MFS_MAGIC) - return ErrorNumber.InvalidArgument; + if(_volMdb.drSigWord != MFS_MAGIC) return ErrorNumber.InvalidArgument; _volMdb.drCrDate = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x002); _volMdb.drLsBkUp = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x006); @@ -94,8 +90,7 @@ public sealed partial class AppleMFS errno = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, out _directoryBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; int bytesInBlockMap = _volMdb.drNmAlBlks * 12 / 8 + _volMdb.drNmAlBlks * 12 % 8; int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; @@ -105,8 +100,7 @@ public sealed partial class AppleMFS errno = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb, out byte[] wholeMdb); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _blockMapBytes = new byte[bytesInBlockMap]; Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, _blockMapBytes, 0, _blockMapBytes.Length); @@ -120,8 +114,7 @@ public sealed partial class AppleMFS uint tmp2 = 0; uint tmp3 = 0; - if(offset + 4 <= _blockMapBytes.Length) - tmp1 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset); + if(offset + 4 <= _blockMapBytes.Length) tmp1 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset); if(offset + 4 + 4 <= _blockMapBytes.Length) tmp2 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset + 4); @@ -129,29 +122,21 @@ public sealed partial class AppleMFS if(offset + 8 + 4 <= _blockMapBytes.Length) tmp3 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset + 8); - if(i < _blockMap.Length) - _blockMap[i] = (tmp1 & 0xFFF00000) >> 20; + if(i < _blockMap.Length) _blockMap[i] = (tmp1 & 0xFFF00000) >> 20; - if(i + 2 < _blockMap.Length) - _blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8; + if(i + 2 < _blockMap.Length) _blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8; - if(i + 3 < _blockMap.Length) - _blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28); + if(i + 3 < _blockMap.Length) _blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28); - if(i + 4 < _blockMap.Length) - _blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16; + if(i + 4 < _blockMap.Length) _blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16; - if(i + 5 < _blockMap.Length) - _blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4; + if(i + 5 < _blockMap.Length) _blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4; - if(i + 6 < _blockMap.Length) - _blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24); + if(i + 6 < _blockMap.Length) _blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24); - if(i + 7 < _blockMap.Length) - _blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12; + if(i + 7 < _blockMap.Length) _blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12; - if(i + 8 < _blockMap.Length) - _blockMap[i + 7] = tmp3 & 0xFFF; + if(i + 8 < _blockMap.Length) _blockMap[i + 7] = tmp3 & 0xFFF; offset += 12; } @@ -161,36 +146,36 @@ public sealed partial class AppleMFS _device.ReadSectorTag(2 + _partitionStart, SectorTagType.AppleSectorTag, out _mdbTags); _device.ReadSectorTag(0 + _partitionStart, SectorTagType.AppleSectorTag, out _bootTags); - _device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, SectorTagType.AppleSectorTag, + _device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, + _volMdb.drBlLen, + SectorTagType.AppleSectorTag, out _directoryTags); - _device.ReadSectorsTag(_partitionStart + 2, (uint)sectorsInWholeMdb, SectorTagType.AppleSectorTag, + _device.ReadSectorsTag(_partitionStart + 2, + (uint)sectorsInWholeMdb, + SectorTagType.AppleSectorTag, out _bitmapTags); } _sectorsPerBlock = (int)(_volMdb.drAlBlkSiz / _device.Info.SectorSize); - if(!FillDirectory()) - return ErrorNumber.InvalidArgument; + if(!FillDirectory()) return ErrorNumber.InvalidArgument; _mounted = true; var bbSig = BigEndianBitConverter.ToUInt16(_bootBlocks, 0x000); - if(bbSig != AppleCommon.BB_MAGIC) - _bootBlocks = null; + if(bbSig != AppleCommon.BB_MAGIC) _bootBlocks = null; Metadata = new FileSystem(); - if(_volMdb.drLsBkUp > 0) - Metadata.BackupDate = DateHandlers.MacToDateTime(_volMdb.drLsBkUp); + if(_volMdb.drLsBkUp > 0) Metadata.BackupDate = DateHandlers.MacToDateTime(_volMdb.drLsBkUp); Metadata.Bootable = bbSig == AppleCommon.BB_MAGIC; Metadata.Clusters = _volMdb.drNmAlBlks; Metadata.ClusterSize = _volMdb.drAlBlkSiz; - if(_volMdb.drCrDate > 0) - Metadata.CreationDate = DateHandlers.MacToDateTime(_volMdb.drCrDate); + if(_volMdb.drCrDate > 0) Metadata.CreationDate = DateHandlers.MacToDateTime(_volMdb.drCrDate); Metadata.Files = _volMdb.drNmFls; Metadata.FreeClusters = _volMdb.drFreeBks; diff --git a/Aaru.Filesystems/AppleMFS/Xattr.cs b/Aaru.Filesystems/AppleMFS/Xattr.cs index 8a9e5320c..9835beb4f 100644 --- a/Aaru.Filesystems/AppleMFS/Xattr.cs +++ b/Aaru.Filesystems/AppleMFS/Xattr.cs @@ -48,16 +48,15 @@ public sealed partial class AppleMFS { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; path = pathElements[0]; @@ -77,11 +76,9 @@ public sealed partial class AppleMFS } } - if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return ErrorNumber.NoSuchFile; + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile; - if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return ErrorNumber.NoSuchFile; + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile; if(entry.flRLgLen > 0) { @@ -104,16 +101,15 @@ public sealed partial class AppleMFS /// public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; path = pathElements[0]; @@ -166,11 +162,9 @@ public sealed partial class AppleMFS ErrorNumber error; - if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return ErrorNumber.NoSuchFile; + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return ErrorNumber.NoSuchFile; - if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return ErrorNumber.NoSuchFile; + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return ErrorNumber.NoSuchFile; switch(entry.flRLgLen) { diff --git a/Aaru.Filesystems/AtheOS/Info.cs b/Aaru.Filesystems/AtheOS/Info.cs index 951634fde..4d9776d02 100644 --- a/Aaru.Filesystems/AtheOS/Info.cs +++ b/Aaru.Filesystems/AtheOS/Info.cs @@ -51,21 +51,17 @@ public sealed partial class AtheOS uint offset = AFS_BOOTBLOCK_SIZE % imagePlugin.Info.SectorSize; uint run = 1; - if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) - run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize; + if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize; - if(sector + partition.Start >= partition.End) - return false; + if(sector + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var sbSector = new byte[AFS_SUPERBLOCK_SIZE]; - if(offset + AFS_SUPERBLOCK_SIZE > tmp.Length) - return false; + if(offset + AFS_SUPERBLOCK_SIZE > tmp.Length) return false; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); @@ -88,13 +84,11 @@ public sealed partial class AtheOS uint offset = AFS_BOOTBLOCK_SIZE % imagePlugin.Info.SectorSize; uint run = 1; - if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) - run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize; + if(imagePlugin.Info.SectorSize < AFS_SUPERBLOCK_SIZE) run = AFS_SUPERBLOCK_SIZE / imagePlugin.Info.SectorSize; ErrorNumber errno = imagePlugin.ReadSectors(sector + partition.Start, run, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sbSector = new byte[AFS_SUPERBLOCK_SIZE]; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); @@ -103,57 +97,67 @@ public sealed partial class AtheOS sb.AppendLine(Localization.Atheos_filesystem); - if(afsSb.flags == 1) - sb.AppendLine(Localization.Filesystem_is_read_only); + if(afsSb.flags == 1) sb.AppendLine(Localization.Filesystem_is_read_only); sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(afsSb.name, encoding)).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_block, afsSb.block_size).AppendLine(); - sb.AppendFormat(Localization._0_blocks_in_volume_1_bytes, afsSb.num_blocks, - afsSb.num_blocks * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_in_volume_1_bytes, afsSb.num_blocks, afsSb.num_blocks * afsSb.block_size) + .AppendLine(); - sb.AppendFormat(Localization._0_used_blocks_1_bytes, afsSb.used_blocks, afsSb.used_blocks * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_used_blocks_1_bytes, afsSb.used_blocks, afsSb.used_blocks * afsSb.block_size) + .AppendLine(); sb.AppendFormat(Localization._0_bytes_per_i_node, afsSb.inode_size).AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_allocation_group_1_bytes, afsSb.blocks_per_ag, - afsSb.blocks_per_ag * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_allocation_group_1_bytes, + afsSb.blocks_per_ag, + afsSb.blocks_per_ag * afsSb.block_size) + .AppendLine(); sb.AppendFormat(Localization._0_allocation_groups_in_volume, afsSb.num_ags).AppendLine(); sb.AppendFormat(Localization.Journal_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - afsSb.log_blocks_start, afsSb.log_blocks_ag, afsSb.log_blocks_len, - afsSb.log_blocks_len * afsSb.block_size). - AppendLine(); + afsSb.log_blocks_start, + afsSb.log_blocks_ag, + afsSb.log_blocks_len, + afsSb.log_blocks_len * afsSb.block_size) + .AppendLine(); - sb.AppendFormat(Localization.Journal_starts_in_byte_0_and_has_1_bytes_in_2_blocks, afsSb.log_start, - afsSb.log_size, afsSb.log_valid_blocks). - AppendLine(); + sb.AppendFormat(Localization.Journal_starts_in_byte_0_and_has_1_bytes_in_2_blocks, + afsSb.log_start, + afsSb.log_size, + afsSb.log_valid_blocks) + .AppendLine(); - sb. - AppendFormat(Localization.Root_folder_s_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - afsSb.root_dir_start, afsSb.root_dir_ag, afsSb.root_dir_len, - afsSb.root_dir_len * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization + .Root_folder_s_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, + afsSb.root_dir_start, + afsSb.root_dir_ag, + afsSb.root_dir_len, + afsSb.root_dir_len * afsSb.block_size) + .AppendLine(); - sb. - AppendFormat(Localization.Directory_containing_files_scheduled_for_deletion_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - afsSb.deleted_start, afsSb.deleted_ag, afsSb.deleted_len, - afsSb.deleted_len * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization + .Directory_containing_files_scheduled_for_deletion_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, + afsSb.deleted_start, + afsSb.deleted_ag, + afsSb.deleted_len, + afsSb.deleted_len * afsSb.block_size) + .AppendLine(); - sb. - AppendFormat(Localization.Indices_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - afsSb.indices_start, afsSb.indices_ag, afsSb.indices_len, - afsSb.indices_len * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization + .Indices_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, + afsSb.indices_start, + afsSb.indices_ag, + afsSb.indices_len, + afsSb.indices_len * afsSb.block_size) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_for_bootloader_1_bytes, afsSb.boot_size, - afsSb.boot_size * afsSb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_for_bootloader_1_bytes, + afsSb.boot_size, + afsSb.boot_size * afsSb.block_size) + .AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/BFS/Info.cs b/Aaru.Filesystems/BFS/Info.cs index 1a46b4af0..46a6fadb0 100644 --- a/Aaru.Filesystems/BFS/Info.cs +++ b/Aaru.Filesystems/BFS/Info.cs @@ -48,19 +48,16 @@ public sealed partial class BeFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(sbSector, 0x20); var magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); - if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) - return true; + if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) return true; if(sbSector.Length >= 0x400) { @@ -68,13 +65,11 @@ public sealed partial class BeFS magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x220); } - if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) - return true; + if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) return true; errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; magic = BitConverter.ToUInt32(sbSector, 0x20); magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); @@ -96,8 +91,7 @@ public sealed partial class BeFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; bool littleEndian; @@ -109,8 +103,7 @@ public sealed partial class BeFS { errno = imagePlugin.ReadSector(1 + partition.Start, out sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; besb.magic1 = BigEndianBitConverter.ToUInt32(sbSector, 0x20); @@ -120,8 +113,7 @@ public sealed partial class BeFS { errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] temp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; besb.magic1 = BigEndianBitConverter.ToUInt32(temp, 0x220); @@ -159,14 +151,16 @@ public sealed partial class BeFS sb.AppendFormat(Localization.Filesystem_endianness_0_Should_be_0x42494745, besb.fs_byte_order).AppendLine(); - sb.AppendFormat(Localization.Root_folder_i_node_size_0_blocks_Should_be_one, besb.root_dir_len). - AppendLine(); + sb.AppendFormat(Localization.Root_folder_i_node_size_0_blocks_Should_be_one, besb.root_dir_len) + .AppendLine(); sb.AppendFormat(Localization.Indices_i_node_size_0_blocks_Should_be_one, besb.indices_len).AppendLine(); - sb.AppendFormat(Localization.blockshift_0_1_should_be_2, besb.block_shift, 1 << (int)besb.block_shift, - besb.block_size). - AppendLine(); + sb.AppendFormat(Localization.blockshift_0_1_should_be_2, + besb.block_shift, + 1 << (int)besb.block_shift, + besb.block_size) + .AppendLine(); } switch(besb.flags) @@ -190,37 +184,46 @@ public sealed partial class BeFS sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(besb.name, encoding)).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_block, besb.block_size).AppendLine(); - sb.AppendFormat(Localization._0_blocks_in_volume_1_bytes, besb.num_blocks, besb.num_blocks * besb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_in_volume_1_bytes, besb.num_blocks, besb.num_blocks * besb.block_size) + .AppendLine(); - sb.AppendFormat(Localization._0_used_blocks_1_bytes, besb.used_blocks, besb.used_blocks * besb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_used_blocks_1_bytes, besb.used_blocks, besb.used_blocks * besb.block_size) + .AppendLine(); sb.AppendFormat(Localization._0_bytes_per_i_node, besb.inode_size).AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_allocation_group_1_bytes, besb.blocks_per_ag, - besb.blocks_per_ag * besb.block_size). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_allocation_group_1_bytes, + besb.blocks_per_ag, + besb.blocks_per_ag * besb.block_size) + .AppendLine(); sb.AppendFormat(Localization._0_allocation_groups_in_volume, besb.num_ags).AppendLine(); sb.AppendFormat(Localization.Journal_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - besb.log_blocks_start, besb.log_blocks_ag, besb.log_blocks_len, - besb.log_blocks_len * besb.block_size). - AppendLine(); + besb.log_blocks_start, + besb.log_blocks_ag, + besb.log_blocks_len, + besb.log_blocks_len * besb.block_size) + .AppendLine(); - sb.AppendFormat(Localization.Journal_starts_in_byte_0_and_ends_in_byte_1, besb.log_start, besb.log_end). - AppendLine(); + sb.AppendFormat(Localization.Journal_starts_in_byte_0_and_ends_in_byte_1, besb.log_start, besb.log_end) + .AppendLine(); - sb. - AppendFormat(Localization.Root_folder_s_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - besb.root_dir_start, besb.root_dir_ag, besb.root_dir_len, besb.root_dir_len * besb.block_size). - AppendLine(); + sb.AppendFormat(Localization + .Root_folder_s_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, + besb.root_dir_start, + besb.root_dir_ag, + besb.root_dir_len, + besb.root_dir_len * besb.block_size) + .AppendLine(); - sb. - AppendFormat(Localization.Indices_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, - besb.indices_start, besb.indices_ag, besb.indices_len, besb.indices_len * besb.block_size). - AppendLine(); + sb.AppendFormat(Localization + .Indices_i_node_resides_in_block_0_of_allocation_group_1_and_runs_for_2_blocks_3_bytes, + besb.indices_start, + besb.indices_ag, + besb.indices_len, + besb.indices_len * besb.block_size) + .AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/BTRFS/Info.cs b/Aaru.Filesystems/BTRFS/Info.cs index 8a0f7b711..73c519291 100644 --- a/Aaru.Filesystems/BTRFS/Info.cs +++ b/Aaru.Filesystems/BTRFS/Info.cs @@ -49,19 +49,16 @@ public sealed partial class BTRFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ulong sbSectorOff = 0x10000 / imagePlugin.Info.SectorSize; uint sbSectorSize = 0x1000 / imagePlugin.Info.SectorSize; - if(sbSectorOff + partition.Start >= partition.End) - return false; + if(sbSectorOff + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; SuperBlock btrfsSb; @@ -95,8 +92,7 @@ public sealed partial class BTRFS ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SuperBlock btrfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -163,9 +159,10 @@ public sealed partial class BTRFS sbInformation.AppendFormat(Localization.Chunk_tree_starts_at_LBA_0, btrfsSb.chunk_lba).AppendLine(); sbInformation.AppendFormat(Localization.Log_tree_starts_at_LBA_0, btrfsSb.log_lba).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_has_0_bytes_spanned_in_1_devices, btrfsSb.total_bytes, - btrfsSb.num_devices). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_has_0_bytes_spanned_in_1_devices, + btrfsSb.total_bytes, + btrfsSb.num_devices) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_bytes_used, btrfsSb.bytes_used).AppendLine(); sbInformation.AppendFormat(Localization._0_bytes_sector, btrfsSb.sectorsize).AppendLine(); diff --git a/Aaru.Filesystems/CBM/CBM.cs b/Aaru.Filesystems/CBM/CBM.cs index 62ea60123..7efd5ef85 100644 --- a/Aaru.Filesystems/CBM/CBM.cs +++ b/Aaru.Filesystems/CBM/CBM.cs @@ -99,11 +99,9 @@ public sealed partial class CBM : IReadOnlyFilesystem ulong CbmChsToLba(byte track, byte sector, bool is1581) { - if(track == 0 || track > 40) - return 0; + if(track == 0 || track > 40) return 0; - if(is1581) - return (ulong)((track - 1) * 40 + sector - 1); + if(is1581) return (ulong)((track - 1) * 40 + sector - 1); return trackStartingLbas[track - 1] + sector; } diff --git a/Aaru.Filesystems/CBM/Dir.cs b/Aaru.Filesystems/CBM/Dir.cs index 87fa13308..e40fd6463 100644 --- a/Aaru.Filesystems/CBM/Dir.cs +++ b/Aaru.Filesystems/CBM/Dir.cs @@ -44,8 +44,7 @@ public sealed partial class CBM { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return ErrorNumber.NotSupported; @@ -56,7 +55,9 @@ public sealed partial class CBM node = new CbmDirNode { - Path = path, Position = 0, Contents = contents.ToArray() + Path = path, + Position = 0, + Contents = contents.ToArray() }; return ErrorNumber.NoError; @@ -65,8 +66,7 @@ public sealed partial class CBM /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not CbmDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CbmDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; @@ -79,17 +79,13 @@ public sealed partial class CBM { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not CbmDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CbmDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; diff --git a/Aaru.Filesystems/CBM/File.cs b/Aaru.Filesystems/CBM/File.cs index 01dec4c0f..7a595eee3 100644 --- a/Aaru.Filesystems/CBM/File.cs +++ b/Aaru.Filesystems/CBM/File.cs @@ -44,21 +44,19 @@ public sealed partial class CBM { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(!_cache.TryGetValue(filename, out CachedFile file)) - return ErrorNumber.NoSuchFile; + if(!_cache.TryGetValue(filename, out CachedFile file)) return ErrorNumber.NoSuchFile; attributes = file.attributes; @@ -70,24 +68,21 @@ public sealed partial class CBM { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 14) - return ErrorNumber.NameTooLong; + if(filename.Length > 14) return ErrorNumber.NameTooLong; - if(!_cache.TryGetValue(filename, out CachedFile file)) - return ErrorNumber.NoSuchFile; + if(!_cache.TryGetValue(filename, out CachedFile file)) return ErrorNumber.NoSuchFile; stat = new FileEntryInfo { @@ -107,28 +102,28 @@ public sealed partial class CBM { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); - if(filename.Length > 14) - return ErrorNumber.NameTooLong; + if(filename.Length > 14) return ErrorNumber.NameTooLong; - if(!_cache.TryGetValue(filename, out CachedFile file)) - return ErrorNumber.NoSuchFile; + if(!_cache.TryGetValue(filename, out CachedFile file)) return ErrorNumber.NoSuchFile; node = new CbmFileNode { - Path = path, Length = (long)file.length, Offset = 0, Cache = file.data + Path = path, + Length = (long)file.length, + Offset = 0, + Cache = file.data }; return ErrorNumber.NoError; @@ -137,11 +132,9 @@ public sealed partial class CBM /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not CbmFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CbmFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Cache = null; @@ -153,19 +146,15 @@ public sealed partial class CBM { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not CbmFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CbmFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; Array.Copy(mynode.Cache, mynode.Offset, buffer, 0, read); diff --git a/Aaru.Filesystems/CBM/Info.cs b/Aaru.Filesystems/CBM/Info.cs index afd2846bf..925c05793 100644 --- a/Aaru.Filesystems/CBM/Info.cs +++ b/Aaru.Filesystems/CBM/Info.cs @@ -42,16 +42,14 @@ namespace Aaru.Filesystems; /// Implements detection of the filesystem used in 8-bit Commodore microcomputers public sealed partial class CBM { -#region IFilesystem Members +#region IReadOnlyFilesystem Members /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start > 0) - return false; + if(partition.Start > 0) return false; - if(imagePlugin.Info.SectorSize != 256) - return false; + if(imagePlugin.Info.SectorSize != 256) return false; if(imagePlugin.Info.Sectors != 683 && imagePlugin.Info.Sectors != 768 && @@ -65,20 +63,17 @@ public sealed partial class CBM { ErrorNumber errno = imagePlugin.ReadSector(1560, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Header cbmHdr = Marshal.ByteArrayToStructureLittleEndian
(sector); - if(cbmHdr.diskDosVersion == 0x44 && cbmHdr is { dosVersion: 0x33, diskVersion: 0x44 }) - return true; + if(cbmHdr.diskDosVersion == 0x44 && cbmHdr is { dosVersion: 0x33, diskVersion: 0x44 }) return true; } else { ErrorNumber errno = imagePlugin.ReadSector(357, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; BAM cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -112,37 +107,40 @@ public sealed partial class CBM { ErrorNumber errno = imagePlugin.ReadSector(1560, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; Header cbmHdr = Marshal.ByteArrayToStructureLittleEndian
(sector); - sbInformation.AppendFormat(Localization.Directory_starts_at_track_0_sector_1, cbmHdr.directoryTrack, - cbmHdr.directorySector). - AppendLine(); + sbInformation.AppendFormat(Localization.Directory_starts_at_track_0_sector_1, + cbmHdr.directoryTrack, + cbmHdr.directorySector) + .AppendLine(); - sbInformation.AppendFormat(Localization.Disk_DOS_Version_0, Encoding.ASCII.GetString(new[] - { - cbmHdr.diskDosVersion - })). - AppendLine(); + sbInformation.AppendFormat(Localization.Disk_DOS_Version_0, + Encoding.ASCII.GetString(new[] + { + cbmHdr.diskDosVersion + })) + .AppendLine(); - sbInformation.AppendFormat(Localization.DOS_Version_0, Encoding.ASCII.GetString(new[] - { - cbmHdr.dosVersion - })). - AppendLine(); + sbInformation.AppendFormat(Localization.DOS_Version_0, + Encoding.ASCII.GetString(new[] + { + cbmHdr.dosVersion + })) + .AppendLine(); - sbInformation.AppendFormat(Localization.Disk_Version_0, Encoding.ASCII.GetString(new[] - { - cbmHdr.diskVersion - })). - AppendLine(); + sbInformation.AppendFormat(Localization.Disk_Version_0, + Encoding.ASCII.GetString(new[] + { + cbmHdr.diskVersion + })) + .AppendLine(); sbInformation.AppendFormat(Localization.Disk_ID_0, cbmHdr.diskId).AppendLine(); - sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(cbmHdr.name, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(cbmHdr.name, encoding)) + .AppendLine(); metadata.VolumeName = StringHandlers.CToString(cbmHdr.name, encoding); metadata.VolumeSerial = $"{cbmHdr.diskId}"; @@ -151,29 +149,30 @@ public sealed partial class CBM { ErrorNumber errno = imagePlugin.ReadSector(357, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BAM cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); - sbInformation.AppendFormat(Localization.Directory_starts_at_track_0_sector_1, cbmBam.directoryTrack, - cbmBam.directorySector). - AppendLine(); + sbInformation.AppendFormat(Localization.Directory_starts_at_track_0_sector_1, + cbmBam.directoryTrack, + cbmBam.directorySector) + .AppendLine(); sbInformation.AppendFormat(Localization.Disk_DOS_type_0, - Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType))). - AppendLine(); + Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType))) + .AppendLine(); - sbInformation.AppendFormat(Localization.DOS_Version_0, Encoding.ASCII.GetString(new[] - { - cbmBam.dosVersion - })). - AppendLine(); + sbInformation.AppendFormat(Localization.DOS_Version_0, + Encoding.ASCII.GetString(new[] + { + cbmBam.dosVersion + })) + .AppendLine(); sbInformation.AppendFormat(Localization.Disk_ID_0, cbmBam.diskId).AppendLine(); - sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(cbmBam.name, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(cbmBam.name, encoding)) + .AppendLine(); metadata.VolumeName = StringHandlers.CToString(cbmBam.name, encoding); metadata.VolumeSerial = $"{cbmBam.diskId}"; diff --git a/Aaru.Filesystems/CBM/Structs.cs b/Aaru.Filesystems/CBM/Structs.cs index d52af01bc..4954108df 100644 --- a/Aaru.Filesystems/CBM/Structs.cs +++ b/Aaru.Filesystems/CBM/Structs.cs @@ -103,12 +103,12 @@ public sealed partial class CBM internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -119,7 +119,7 @@ public sealed partial class CBM { internal byte[] Cache; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -130,7 +130,7 @@ public sealed partial class CBM /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs index c185aaf90..8997997cf 100644 --- a/Aaru.Filesystems/CBM/Super.cs +++ b/Aaru.Filesystems/CBM/Super.cs @@ -53,11 +53,9 @@ public sealed partial class CBM public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - if(partition.Start > 0) - return ErrorNumber.InvalidArgument; + if(partition.Start > 0) return ErrorNumber.InvalidArgument; - if(imagePlugin.Info.SectorSize != 256) - return ErrorNumber.InvalidArgument; + if(imagePlugin.Info.SectorSize != 256) return ErrorNumber.InvalidArgument; if(imagePlugin.Info.Sectors != 683 && imagePlugin.Info.Sectors != 768 && @@ -67,25 +65,28 @@ public sealed partial class CBM options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); encoding = new PETSCII(); byte[] sector; ulong rootLba; string volumeName = null; + Metadata = new FileSystem { - Type = FS_TYPE, Clusters = imagePlugin.Info.Sectors, ClusterSize = 256 + Type = FS_TYPE, + Clusters = imagePlugin.Info.Sectors, + ClusterSize = 256 }; + uint serial; + // Commodore 1581 if(imagePlugin.Info.Sectors == 3200) { ErrorNumber errno = imagePlugin.ReadSector(1560, out _diskHeader); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Header cbmHdr = Marshal.ByteArrayToStructureBigEndian
(_diskHeader); @@ -93,11 +94,11 @@ public sealed partial class CBM return ErrorNumber.InvalidArgument; _bam = new byte[512]; + // Got to first BAM sector errno = imagePlugin.ReadSector(1561, out sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(sector, 0, _bam, 0, 256); @@ -106,14 +107,12 @@ public sealed partial class CBM // Got to next (and last) BAM sector errno = imagePlugin.ReadSector((ulong)((_bam[0] - 1) * 40), out sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(sector, 0, _bam, 256, 256); } - if(cbmHdr.directoryTrack == 0) - return ErrorNumber.InvalidArgument; + if(cbmHdr.directoryTrack == 0) return ErrorNumber.InvalidArgument; rootLba = CbmChsToLba(cbmHdr.directoryTrack, cbmHdr.directorySector, true); serial = cbmHdr.diskId; @@ -125,8 +124,7 @@ public sealed partial class CBM { ErrorNumber errno = imagePlugin.ReadSector(357, out _bam); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; BAM cbmBam = Marshal.ByteArrayToStructureBigEndian(_bam); @@ -141,8 +139,7 @@ public sealed partial class CBM Metadata.VolumeSerial = $"{cbmBam.diskId}"; } - if(rootLba >= imagePlugin.Info.Sectors) - return ErrorNumber.IllegalSeek; + if(rootLba >= imagePlugin.Info.Sectors) return ErrorNumber.IllegalSeek; ulong nextLba = rootLba; var rootMs = new MemoryStream(); @@ -152,13 +149,11 @@ public sealed partial class CBM { ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; rootMs.Write(sector, 0, 256); - if(sector[0] == 0) - break; + if(sector[0] == 0) break; nextLba = CbmChsToLba(sector[0], sector[1], _is1581); } while(nextLba > 0); @@ -176,7 +171,8 @@ public sealed partial class CBM FreeFiles = (ulong)(_root.Length / 32), Id = new FileSystemId { - Serial32 = serial, IsInt = true + Serial32 = serial, + IsInt = true }, PluginId = Id, Type = "CBMFS" @@ -190,38 +186,42 @@ public sealed partial class CBM if(_debug) { // Root - _cache.Add("$", new CachedFile - { - attributes = FileAttributes.Directory | FileAttributes.Hidden | FileAttributes.System, - length = (ulong)_root.Length, - data = _root, - blocks = _root.Length / 256, - id = fileId++ - }); + _cache.Add("$", + new CachedFile + { + attributes = FileAttributes.Directory | FileAttributes.Hidden | FileAttributes.System, + length = (ulong)_root.Length, + data = _root, + blocks = _root.Length / 256, + id = fileId++ + }); // BAM - _cache.Add("$BAM", new CachedFile - { - attributes = FileAttributes.File | FileAttributes.Hidden | FileAttributes.System, - length = (ulong)_bam.Length, - data = _bam, - blocks = _bam.Length / 256, - id = fileId++ - }); + _cache.Add("$BAM", + new CachedFile + { + attributes = FileAttributes.File | FileAttributes.Hidden | FileAttributes.System, + length = (ulong)_bam.Length, + data = _bam, + blocks = _bam.Length / 256, + id = fileId++ + }); _statfs.Files += 2; // 1581 disk header if(_diskHeader != null) { - _cache.Add("$DISK_HEADER", new CachedFile - { - attributes = FileAttributes.File | FileAttributes.Hidden | FileAttributes.System, - length = (ulong)_diskHeader.Length, - data = _diskHeader, - blocks = _diskHeader.Length / 256, - id = fileId++ - }); + _cache.Add("$DISK_HEADER", + new CachedFile + { + attributes = FileAttributes.File | FileAttributes.Hidden | FileAttributes.System, + length = (ulong)_diskHeader.Length, + data = _diskHeader, + blocks = _diskHeader.Length / 256, + id = fileId++ + }); + _statfs.Files++; } } @@ -233,6 +233,7 @@ public sealed partial class CBM if(dirEntry.fileType == 0) { offset += 32; + continue; } @@ -241,8 +242,7 @@ public sealed partial class CBM for(var i = 0; i < dirEntry.name.Length; i++) { - if(dirEntry.name[i] == 0xA0) - dirEntry.name[i] = 0; + if(dirEntry.name[i] == 0xA0) dirEntry.name[i] = 0; } string name = StringHandlers.CToString(dirEntry.name, encoding); @@ -261,33 +261,27 @@ public sealed partial class CBM while(dirEntry.blocks > 0) { - if(dirEntry.firstFileBlockTrack == 0) - break; + if(dirEntry.firstFileBlockTrack == 0) break; ErrorNumber errno = imagePlugin.ReadSector(nextLba, out sector); - if(errno != ErrorNumber.NoError) - break; + + if(errno != ErrorNumber.NoError) break; byte toRead = sector[0] == 0 ? sector[1] : (byte)254; - if(toRead == 255) - toRead--; + if(toRead == 255) toRead--; data.Write(sector, 2, toRead); - if(sector[0] == 0) - break; + if(sector[0] == 0) break; nextLba = CbmChsToLba(sector[0], sector[1], _is1581); } FileAttributes attributes = FileAttributes.File; - if((dirEntry.fileType & 0x80) != 0x80) - attributes |= FileAttributes.Open; - if((dirEntry.fileType & 0x40) > 0) - attributes |= FileAttributes.ReadOnly; - if((dirEntry.fileType & 7) == 2) - attributes |= FileAttributes.Executable; + if((dirEntry.fileType & 0x80) != 0x80) attributes |= FileAttributes.Open; + if((dirEntry.fileType & 0x40) > 0) attributes |= FileAttributes.ReadOnly; + if((dirEntry.fileType & 7) == 2) attributes |= FileAttributes.Executable; _cache[name] = new CachedFile { @@ -302,14 +296,14 @@ public sealed partial class CBM } _mounted = true; + return ErrorNumber.NoError; } /// public ErrorNumber Unmount() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _mounted = false; @@ -321,8 +315,7 @@ public sealed partial class CBM { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); diff --git a/Aaru.Filesystems/CPM/Definitions.cs b/Aaru.Filesystems/CPM/Definitions.cs index 1bea96c16..d24941140 100644 --- a/Aaru.Filesystems/CPM/Definitions.cs +++ b/Aaru.Filesystems/CPM/Definitions.cs @@ -49,12 +49,13 @@ public sealed partial class CPM try { _definitions = - JsonSerializer. - Deserialize(Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.json") ?? new MemoryStream(), - typeof(CpmDefinitions), CpmDefinitionsContext.Default) as CpmDefinitions; + JsonSerializer.Deserialize(Assembly.GetExecutingAssembly() + .GetManifestResourceStream("Aaru.Filesystems.CPM.cpmdefs.json") ?? + new MemoryStream(), + typeof(CpmDefinitions), + CpmDefinitionsContext.Default) as CpmDefinitions; - if(_definitions is null) - return false; + if(_definitions is null) return false; // Patch definitions foreach(CpmDefinition def in _definitions.definitions) @@ -67,12 +68,10 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(var i = 0; i < def.sectorsPerTrack; i++) - def.side1.sectorIds[i] = i + 1; + for(var i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; } - if(def.sides != 2 || def.side2 != null) - continue; + if(def.sides != 2 || def.side2 != null) continue; { def.side2 = new Side @@ -81,8 +80,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(var i = 0; i < def.sectorsPerTrack; i++) - def.side2.sectorIds[i] = i + 1; + for(var i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; } } @@ -95,9 +93,11 @@ public sealed partial class CPM } } -[JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +[JsonSourceGenerationOptions(WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, IncludeFields = true)] [JsonSerializable(typeof(CpmDefinitions))] + // ReSharper disable once PartialTypeWithSinglePart public partial class CpmDefinitionsContext : JsonSerializerContext; diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index 51d347136..dba38b6ec 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -47,8 +47,7 @@ public sealed partial class CPM { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return ErrorNumber.NotSupported; @@ -68,17 +67,13 @@ public sealed partial class CPM { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not CpmDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CpmDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; @@ -88,8 +83,7 @@ public sealed partial class CPM /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not CpmDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CpmDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; @@ -110,8 +104,7 @@ public sealed partial class CPM { try { - if(directory == null) - return false; + if(directory == null) return false; var fileCount = 0; @@ -123,18 +116,15 @@ public sealed partial class CPM { for(var f = 0; f < 8; f++) { - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) - return false; + if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; } for(var e = 0; e < 3; e++) { - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) - return false; + if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; } - if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename)) - fileCount++; + if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename)) fileCount++; } else { @@ -144,14 +134,12 @@ public sealed partial class CPM { for(var f = 0; f < 8; f++) { - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) - return false; + if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; } for(var e = 0; e < 3; e++) { - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) - return false; + if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; } _label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); diff --git a/Aaru.Filesystems/CPM/File.cs b/Aaru.Filesystems/CPM/File.cs index e9ff46bad..ab87502c7 100644 --- a/Aaru.Filesystems/CPM/File.cs +++ b/Aaru.Filesystems/CPM/File.cs @@ -43,16 +43,15 @@ public sealed partial class CPM { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; if(string.IsNullOrEmpty(pathElements[0]) || string.Compare(pathElements[0], "/", StringComparison.OrdinalIgnoreCase) == 0) @@ -76,19 +75,17 @@ public sealed partial class CPM { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; - if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file)) - return ErrorNumber.NoSuchFile; + if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file)) return ErrorNumber.NoSuchFile; node = new CpmFileNode { @@ -104,11 +101,9 @@ public sealed partial class CPM /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not CpmFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CpmFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Cache = null; @@ -120,19 +115,15 @@ public sealed partial class CPM { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not CpmFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not CpmFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; Array.Copy(mynode.Cache, mynode.Offset, buffer, 0, read); @@ -154,16 +145,15 @@ public sealed partial class CPM { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) { @@ -178,11 +168,9 @@ public sealed partial class CPM BlockSize = Metadata.ClusterSize }; - if(_labelCreationDate != null) - stat.CreationTime = DateHandlers.CpmToDateTime(_labelCreationDate); + if(_labelCreationDate != null) stat.CreationTime = DateHandlers.CpmToDateTime(_labelCreationDate); - if(_labelUpdateDate != null) - stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate); + if(_labelUpdateDate != null) stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate); return ErrorNumber.NoError; } diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index 09e6f7e41..90a949fea 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -191,8 +191,7 @@ public sealed partial class CPM var sig3 = BitConverter.ToUInt32(sector, 0x7C); // PCW16 extended boot record - if(sig1 == 0x4D2F5043 && sig2 == 0x004B5344 && sig3 == sig1) - amsSbOffset = 0x80; + if(sig1 == 0x4D2F5043 && sig2 == 0x004B5344 && sig3 == sig1) amsSbOffset = 0x80; // Read the superblock AmstradSuperBlock amsSb = @@ -222,8 +221,7 @@ public sealed partial class CPM bsh = amsSb.bsh }; - for(var i = 0; i < _dpb.bsh; i++) - _dpb.blm += (byte)Math.Pow(2, i); + for(var i = 0; i < _dpb.bsh; i++) _dpb.blm += (byte)Math.Pow(2, i); if(sectorCount >= 1440) { @@ -241,13 +239,13 @@ public sealed partial class CPM _dpb.off = amsSb.off; _dpb.psh = amsSb.psh; - for(var i = 0; i < _dpb.psh; i++) - _dpb.phm += (byte)Math.Pow(2, i); + for(var i = 0; i < _dpb.psh; i++) _dpb.phm += (byte)Math.Pow(2, i); _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); - imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength, + imagePlugin.ReadSectors(firstDirectorySector + partition.Start, + directoryLength, out directory); // Build a CP/M disk definition @@ -276,8 +274,7 @@ public sealed partial class CPM } }; - for(var si = 0; si < amsSb.spt; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side1.sectorIds[si] = si + 1; if(amsSb.format == 2) { @@ -294,8 +291,7 @@ public sealed partial class CPM sectorIds = new int[amsSb.spt] }; - for(var si = 0; si < amsSb.spt; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } else _workingDefinition.order = null; @@ -320,8 +316,7 @@ public sealed partial class CPM ushort sum = 0; // Sum of all 16-bit words that make this sector must be 0 - for(var i = 0; i < sector.Length; i += 2) - sum += BitConverter.ToUInt16(sector, i); + for(var i = 0; i < sector.Length; i += 2) sum += BitConverter.ToUInt16(sector, i); // It may happen that there is a corrupted superblock // Better to ignore corrupted than to false positive the rest @@ -368,7 +363,8 @@ public sealed partial class CPM var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); - imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength, + imagePlugin.ReadSectors(firstDirectorySector + partition.Start, + directoryLength, out directory); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CPM_86_hard_disk_superblock); @@ -410,8 +406,7 @@ public sealed partial class CPM for(var si = 0; si < hddSb.sectorsPerTrack; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < hddSb.spt; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < hddSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } } } @@ -496,8 +491,7 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 8; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1; } break; @@ -556,11 +550,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 8; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 8; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 8; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -621,11 +613,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 9; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 9; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -685,11 +675,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 9; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 9; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -748,11 +736,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 9; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 9; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -811,11 +797,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 15; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 15; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 15; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 15; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -874,11 +858,9 @@ public sealed partial class CPM sofs = 0 }; - for(var si = 0; si < 18; si++) - _workingDefinition.side1.sectorIds[si] = si + 1; + for(var si = 0; si < 18; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(var si = 0; si < 18; si++) - _workingDefinition.side2.sectorIds[si] = si + 1; + for(var si = 0; si < 18; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -888,7 +870,8 @@ public sealed partial class CPM { var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize); - imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength, + imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, + directoryLength, out directory); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CPM_86_floppy_identifier); @@ -962,7 +945,8 @@ public sealed partial class CPM } // Head changes after whole side - else if(string.Compare(def.order, "CYLINDERS", + else if(string.Compare(def.order, + "CYLINDERS", StringComparison.InvariantCultureIgnoreCase) == 0) { @@ -981,13 +965,14 @@ public sealed partial class CPM } // TODO: Implement COLUMBIA ordering - else if(string.Compare(def.order, "COLUMBIA", + else if(string.Compare(def.order, + "COLUMBIA", StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); + Localization + .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); continue; } @@ -997,16 +982,16 @@ public sealed partial class CPM 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); + Localization + .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); continue; } else { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Unknown_order_type_0_not_proceeding_with_this_definition, + Localization + .Unknown_order_type_0_not_proceeding_with_this_definition, def.order); continue; @@ -1018,13 +1003,13 @@ public sealed partial class CPM for(var p = 0; p < dirLen; p++) { - errno = - imagePlugin. - ReadSector((ulong)((int)offset + (int)partition.Start + p / _sectorMask.Length * _sectorMask.Length + _sectorMask[p % _sectorMask.Length]), - out byte[] dirSector); + errno = imagePlugin.ReadSector((ulong)((int)offset + + (int)partition.Start + + p / _sectorMask.Length * _sectorMask.Length + + _sectorMask[p % _sectorMask.Length]), + out byte[] dirSector); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; ms.Write(dirSector, 0, dirSector.Length); } @@ -1034,21 +1019,21 @@ public sealed partial class CPM if(def.evenOdd) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Definition_contains_EVEN_ODD_field_with_unknown_meaning_detection_may_be_wrong); + Localization + .Definition_contains_EVEN_ODD_field_with_unknown_meaning_detection_may_be_wrong); } // Complement of the directory bytes if needed if(def.complement) { - for(var b = 0; b < directory.Length; b++) - directory[b] = (byte)(~directory[b] & 0xFF); + for(var b = 0; b < directory.Length; b++) directory[b] = (byte)(~directory[b] & 0xFF); } // Check the directory if(CheckDir(directory)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Definition_0_has_a_correct_directory, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Definition_0_has_a_correct_directory, def.comment); // Build a Disc Parameter Block @@ -1157,8 +1142,7 @@ public sealed partial class CPM metadata = new FileSystem(); // As the identification is so complex, just call Identify() and relay on its findings - if(!Identify(imagePlugin, partition) || !_cpmFound || _workingDefinition == null || _dpb == null) - return; + if(!Identify(imagePlugin, partition) || !_cpmFound || _workingDefinition == null || _dpb == null) return; var sb = new StringBuilder(); sb.AppendLine(Localization.CPM_filesystem); @@ -1170,8 +1154,8 @@ public sealed partial class CPM if(_dpb.dsm > 0) { - sb.AppendFormat(Localization.Volume_contains_0_blocks_1_bytes, _dpb.dsm, _dpb.dsm * (128 << _dpb.bsh)). - AppendLine(); + sb.AppendFormat(Localization.Volume_contains_0_blocks_1_bytes, _dpb.dsm, _dpb.dsm * (128 << _dpb.bsh)) + .AppendLine(); } sb.AppendFormat(Localization.Volume_contains_0_directory_entries, _dpb.drm + 1).AppendLine(); @@ -1181,8 +1165,9 @@ public sealed partial class CPM else { sb.AppendFormat(Localization.Volume_reserves_1_tracks_0_sectors_for_system, - _workingDefinition.ofs * _workingDefinition.sectorsPerTrack, _workingDefinition.ofs). - AppendLine(); + _workingDefinition.ofs * _workingDefinition.sectorsPerTrack, + _workingDefinition.ofs) + .AppendLine(); } if(_workingDefinition.side1.sectorIds.Length >= 2) @@ -1201,8 +1186,8 @@ public sealed partial class CPM if(interleaveSide2 > 1) { - sb.AppendFormat(Localization.Side_one_uses_0_one_software_interleaving, interleaveSide2). - AppendLine(); + sb.AppendFormat(Localization.Side_one_uses_0_one_software_interleaving, interleaveSide2) + .AppendLine(); } } @@ -1217,8 +1202,8 @@ public sealed partial class CPM break; default: - sb.AppendFormat(Localization.Unknown_how_0_side_ordering_works, _workingDefinition.order). - AppendLine(); + sb.AppendFormat(Localization.Unknown_how_0_side_ordering_works, _workingDefinition.order) + .AppendLine(); break; } @@ -1238,25 +1223,22 @@ public sealed partial class CPM :X2}H AL1 {_dpb.al1:X2}H OFS {_workingDefinition.ofs}"); } - if(_label != null) - sb.AppendFormat(Localization.Volume_label_0, _label).AppendLine(); + if(_label != null) sb.AppendFormat(Localization.Volume_label_0, _label).AppendLine(); - if(_standardTimestamps) - sb.AppendLine(Localization.Volume_uses_standard_CPM_timestamps); + if(_standardTimestamps) sb.AppendLine(Localization.Volume_uses_standard_CPM_timestamps); - if(_thirdPartyTimestamps) - sb.AppendLine(Localization.Volume_uses_third_party_timestamps); + if(_thirdPartyTimestamps) sb.AppendLine(Localization.Volume_uses_third_party_timestamps); if(_labelCreationDate != null) { - sb.AppendFormat(Localization.Volume_created_on_0, DateHandlers.CpmToDateTime(_labelCreationDate)). - AppendLine(); + sb.AppendFormat(Localization.Volume_created_on_0, DateHandlers.CpmToDateTime(_labelCreationDate)) + .AppendLine(); } if(_labelUpdateDate != null) { - sb.AppendFormat(Localization.Volume_updated_on_0, DateHandlers.CpmToDateTime(_labelUpdateDate)). - AppendLine(); + sb.AppendFormat(Localization.Volume_updated_on_0, DateHandlers.CpmToDateTime(_labelUpdateDate)) + .AppendLine(); } metadata = new FileSystem(); @@ -1268,11 +1250,9 @@ public sealed partial class CPM else metadata.Clusters = partition.End - partition.Start; - if(_labelCreationDate != null) - metadata.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); + if(_labelCreationDate != null) metadata.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); - if(_labelUpdateDate != null) - metadata.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); + if(_labelUpdateDate != null) metadata.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); metadata.Type = FS_TYPE; metadata.VolumeName = _label; diff --git a/Aaru.Filesystems/CPM/Structs.cs b/Aaru.Filesystems/CPM/Structs.cs index 4f7ff8ba4..237ef6a58 100644 --- a/Aaru.Filesystems/CPM/Structs.cs +++ b/Aaru.Filesystems/CPM/Structs.cs @@ -89,12 +89,12 @@ public sealed partial class CPM internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -105,7 +105,7 @@ public sealed partial class CPM { internal byte[] Cache; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -116,7 +116,7 @@ public sealed partial class CPM /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index e4507b684..3cf3cafc3 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -94,7 +94,8 @@ public sealed partial class CPM } // Head changes after whole side - else if(string.Compare(_workingDefinition.order, "CYLINDERS", + else if(string.Compare(_workingDefinition.order, + "CYLINDERS", StringComparison.InvariantCultureIgnoreCase) == 0) { @@ -122,8 +123,8 @@ public sealed partial class CPM 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); + Localization + .Dont_know_how_to_handle_COLUMBIA_ordering_not_proceeding_with_this_definition); return ErrorNumber.NotImplemented; } @@ -132,8 +133,8 @@ public sealed partial class CPM else if(string.Compare(_workingDefinition.order, "EAGLE", StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); + Localization + .Don_know_how_to_handle_EAGLE_ordering_not_proceeding_with_this_definition); return ErrorNumber.NotImplemented; } @@ -158,16 +159,16 @@ public sealed partial class CPM for(var p = 0; p <= (int)(partition.End - partition.Start); p++) { ErrorNumber errno = - _device.ReadSector((ulong)((int)partition.Start + p / _sectorMask.Length * _sectorMask.Length + _sectorMask[p % _sectorMask.Length]), + _device.ReadSector((ulong)((int)partition.Start + + p / _sectorMask.Length * _sectorMask.Length + + _sectorMask[p % _sectorMask.Length]), out byte[] readSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; if(_workingDefinition.complement) { - for(var b = 0; b < readSector.Length; b++) - readSector[b] = (byte)(~readSector[b] & 0xFF); + for(var b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); } deinterleavedSectors.Add((ulong)p, readSector); @@ -204,8 +205,7 @@ public sealed partial class CPM blockMs.Write(sector, 0, sector.Length); sectorsPerBlock++; - if(sectorsPerBlock != blockSize / sector.Length) - continue; + if(sectorsPerBlock != blockSize / sector.Length) continue; allocationBlocks.Add(blockNo++, blockMs.ToArray()); sectorsPerBlock = 0; @@ -238,8 +238,7 @@ public sealed partial class CPM byte[] directory = dirMs.ToArray(); - if(directory == null) - return ErrorNumber.InvalidArgument; + if(directory == null) return ErrorNumber.InvalidArgument; var dirCnt = 0; string file1 = null; @@ -291,18 +290,15 @@ public sealed partial class CPM validEntry &= entry.extension[i] >= 0x20; } - if(!validEntry) - continue; + if(!validEntry) continue; string filename = Encoding.ASCII.GetString(entry.filename).Trim(); string extension = Encoding.ASCII.GetString(entry.extension).Trim(); // If user is != 0, append user to name to have identical filenames - if(user > 0) - filename = $"{user:X1}:{filename}"; + if(user > 0) filename = $"{user:X1}:{filename}"; - if(!string.IsNullOrEmpty(extension)) - filename = filename + "." + extension; + if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; filename = filename.Replace('/', '\u2215'); @@ -332,14 +328,11 @@ public sealed partial class CPM blocks = new List(); // Attributes - if(hidden) - fInfo.Attributes |= FileAttributes.Hidden; + if(hidden) fInfo.Attributes |= FileAttributes.Hidden; - if(rdOnly) - fInfo.Attributes |= FileAttributes.ReadOnly; + if(rdOnly) fInfo.Attributes |= FileAttributes.ReadOnly; - if(system) - fInfo.Attributes |= FileAttributes.System; + if(system) fInfo.Attributes |= FileAttributes.System; // Supposedly there is a value in the directory entry telling how many blocks are designated in // this entry. However some implementations tend to do whatever they wish, but none will ever @@ -356,8 +349,7 @@ public sealed partial class CPM _statCache.Add(filename, fInfo); // Add the file to the directory listing - if(!_dirList.Contains(filename)) - _dirList.Add(filename); + if(!_dirList.Contains(filename)) _dirList.Add(filename); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -406,18 +398,15 @@ public sealed partial class CPM validEntry &= entry.extension[i] >= 0x20; } - if(!validEntry) - continue; + if(!validEntry) continue; string filename = Encoding.ASCII.GetString(entry.filename).Trim(); string extension = Encoding.ASCII.GetString(entry.extension).Trim(); // If user is != 0, append user to name to have identical filenames - if(user > 0) - filename = $"{user:X1}:{filename}"; + if(user > 0) filename = $"{user:X1}:{filename}"; - if(!string.IsNullOrEmpty(extension)) - filename = filename + "." + extension; + if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; filename = filename.Replace('/', '\u2215'); @@ -447,14 +436,11 @@ public sealed partial class CPM blocks = new List(); // Attributes - if(hidden) - fInfo.Attributes |= FileAttributes.Hidden; + if(hidden) fInfo.Attributes |= FileAttributes.Hidden; - if(rdOnly) - fInfo.Attributes |= FileAttributes.ReadOnly; + if(rdOnly) fInfo.Attributes |= FileAttributes.ReadOnly; - if(system) - fInfo.Attributes |= FileAttributes.System; + if(system) fInfo.Attributes |= FileAttributes.System; // Supposedly there is a value in the directory entry telling how many blocks are designated in // this entry. However some implementations tend to do whatever they wish, but none will ever @@ -471,8 +457,7 @@ public sealed partial class CPM _statCache.Add(filename, fInfo); // Add the file to the directory listing - if(!_dirList.Contains(filename)) - _dirList.Add(filename); + if(!_dirList.Contains(filename)) _dirList.Add(filename); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -503,27 +488,22 @@ public sealed partial class CPM int user = entry.userNumber & 0x0F; - for(var i = 0; i < 8; i++) - entry.filename[i] &= 0x7F; + for(var i = 0; i < 8; i++) entry.filename[i] &= 0x7F; - for(var i = 0; i < 3; i++) - entry.extension[i] &= 0x7F; + for(var i = 0; i < 3; i++) entry.extension[i] &= 0x7F; string filename = Encoding.ASCII.GetString(entry.filename).Trim(); string extension = Encoding.ASCII.GetString(entry.extension).Trim(); // If user is != 0, append user to name to have identical filenames - if(user > 0) - filename = $"{user:X1}:{filename}"; + if(user > 0) filename = $"{user:X1}:{filename}"; - if(!string.IsNullOrEmpty(extension)) - filename = filename + "." + extension; + if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; filename = filename.Replace('/', '\u2215'); // Do not repeat passwords - if(_passwordCache.ContainsKey(filename)) - _passwordCache.Remove(filename); + if(_passwordCache.ContainsKey(filename)) _passwordCache.Remove(filename); // Copy whole password entry var tmp = new byte[32]; @@ -745,8 +725,7 @@ public sealed partial class CPM { var fileMs = new MemoryStream(); - if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) - _statCache.Remove(filename); + if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) _statCache.Remove(filename); fInfo.Blocks = 0; @@ -754,8 +733,7 @@ public sealed partial class CPM { for(var ex = 0; ex < extents.Count; ex++) { - if(!extents.TryGetValue(ex, out List alBlks)) - continue; + if(!extents.TryGetValue(ex, out List alBlks)) continue; foreach(ushort alBlk in alBlks) { @@ -787,8 +765,7 @@ public sealed partial class CPM var tmp = new byte[8]; Array.Copy(kvp.Value, 16, tmp, 0, 8); - for(var t = 0; t < 8; t++) - tmp[t] ^= kvp.Value[13]; + for(var t = 0; t < 8; t++) tmp[t] ^= kvp.Value[13]; _decodedPasswordCache.Add(kvp.Key, tmp); } @@ -812,14 +789,11 @@ public sealed partial class CPM Type = FS_TYPE }; - if(_labelCreationDate != null) - Metadata.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); + if(_labelCreationDate != null) Metadata.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); - if(_labelUpdateDate != null) - Metadata.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); + if(_labelUpdateDate != null) Metadata.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); - if(!string.IsNullOrEmpty(_label)) - Metadata.VolumeName = _label; + if(!string.IsNullOrEmpty(_label)) Metadata.VolumeName = _label; _mounted = true; @@ -831,8 +805,7 @@ public sealed partial class CPM { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _cpmStat; diff --git a/Aaru.Filesystems/CPM/Xattr.cs b/Aaru.Filesystems/CPM/Xattr.cs index 485e07573..6ec8b942c 100644 --- a/Aaru.Filesystems/CPM/Xattr.cs +++ b/Aaru.Filesystems/CPM/Xattr.cs @@ -43,24 +43,21 @@ public sealed partial class CPM /// public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; - if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) - return ErrorNumber.NoSuchFile; + if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return ErrorNumber.NoSuchFile; if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) { - if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) - return ErrorNumber.NoError; + if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return ErrorNumber.NoError; } if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0) @@ -76,24 +73,21 @@ public sealed partial class CPM { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; - if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) - return ErrorNumber.NoSuchFile; + if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return ErrorNumber.NoSuchFile; xattrs = new List(); - if(_passwordCache.ContainsKey(pathElements[0].ToUpperInvariant())) - xattrs.Add("com.caldera.cpm.password"); + if(_passwordCache.ContainsKey(pathElements[0].ToUpperInvariant())) xattrs.Add("com.caldera.cpm.password"); if(_decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant())) xattrs.Add("com.caldera.cpm.password.text"); diff --git a/Aaru.Filesystems/Cram/Info.cs b/Aaru.Filesystems/Cram/Info.cs index 5c69a36c9..657a7385a 100644 --- a/Aaru.Filesystems/Cram/Info.cs +++ b/Aaru.Filesystems/Cram/Info.cs @@ -49,13 +49,11 @@ public sealed partial class Cram /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -71,8 +69,7 @@ public sealed partial class Cram ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); metadata = new FileSystem(); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -98,8 +95,8 @@ public sealed partial class Cram sbInformation.AppendLine(littleEndian ? Localization.Little_endian : Localization.Big_endian); sbInformation.AppendFormat(Localization.Volume_edition_0, crSb.edition).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(crSb.name, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(crSb.name, encoding)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_bytes, crSb.size).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_blocks, crSb.blocks).AppendLine(); diff --git a/Aaru.Filesystems/ECMA67/Info.cs b/Aaru.Filesystems/ECMA67/Info.cs index 8e720c5cc..80b223e33 100644 --- a/Aaru.Filesystems/ECMA67/Info.cs +++ b/Aaru.Filesystems/ECMA67/Info.cs @@ -49,19 +49,15 @@ public sealed partial class ECMA67 /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start > 0) - return false; + if(partition.Start > 0) return false; - if(partition.End < 8) - return false; + if(partition.End < 8) return false; ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length != 128) - return false; + if(sector.Length != 128) return false; VolumeLabel vol = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -76,8 +72,7 @@ public sealed partial class ECMA67 metadata = new FileSystem(); ErrorNumber errno = imagePlugin.ReadSector(6, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sbInformation = new StringBuilder(); @@ -85,8 +80,8 @@ public sealed partial class ECMA67 sbInformation.AppendLine(Localization.ECMA_67); - sbInformation.AppendFormat(Localization.Volume_name_0, Encoding.ASCII.GetString(vol.volumeIdentifier)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, Encoding.ASCII.GetString(vol.volumeIdentifier)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_owner_0, Encoding.ASCII.GetString(vol.owner)).AppendLine(); diff --git a/Aaru.Filesystems/EFS/Info.cs b/Aaru.Filesystems/EFS/Info.cs index 43ebbc47b..264ade059 100644 --- a/Aaru.Filesystems/EFS/Info.cs +++ b/Aaru.Filesystems/EFS/Info.cs @@ -46,24 +46,20 @@ public sealed partial class EFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; // Misaligned if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc) { var sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) - sbSize++; + if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; var sbpiece = new byte[Marshal.SizeOf()]; @@ -71,34 +67,37 @@ public sealed partial class EFS Superblock sb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, 0x200, - sb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_expected_2_or_3, + 0x200, + sb.sb_magic, + EFS_MAGIC, + EFS_MAGIC_NEW); - if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) - return true; + if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) return true; } else { var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, 1, sb.sb_magic, - EFS_MAGIC, EFS_MAGIC_NEW); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_expected_2_or_3, + 1, + sb.sb_magic, + EFS_MAGIC, + EFS_MAGIC_NEW); - if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) - return true; + if(sb.sb_magic is EFS_MAGIC or EFS_MAGIC_NEW) return true; } return false; @@ -112,8 +111,7 @@ public sealed partial class EFS information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; Superblock efsSb; @@ -122,16 +120,13 @@ public sealed partial class EFS { var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) - sbSize++; + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; var sbpiece = new byte[Marshal.SizeOf()]; @@ -139,39 +134,42 @@ public sealed partial class EFS efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2_or_3, 0x200, - efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_X3_equals_1_expected_2_or_3, + 0x200, + efsSb.sb_magic, + EFS_MAGIC, + EFS_MAGIC_NEW); } else { var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; efsSb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2_or_3, 1, efsSb.sb_magic, - EFS_MAGIC, EFS_MAGIC_NEW); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_expected_2_or_3, + 1, + efsSb.sb_magic, + EFS_MAGIC, + EFS_MAGIC_NEW); } - if(efsSb.sb_magic != EFS_MAGIC && efsSb.sb_magic != EFS_MAGIC_NEW) - return; + if(efsSb.sb_magic != EFS_MAGIC && efsSb.sb_magic != EFS_MAGIC_NEW) return; var sb = new StringBuilder(); sb.AppendLine(Localization.SGI_extent_filesystem); - if(efsSb.sb_magic == EFS_MAGIC_NEW) - sb.AppendLine(Localization.New_version); + if(efsSb.sb_magic == EFS_MAGIC_NEW) sb.AppendLine(Localization.New_version); sb.AppendFormat(Localization.Filesystem_size_0_basic_blocks, efsSb.sb_size).AppendLine(); sb.AppendFormat(Localization.First_cylinder_group_starts_at_block_0, efsSb.sb_firstcg).AppendLine(); @@ -185,8 +183,7 @@ public sealed partial class EFS sb.AppendFormat(Localization._0_free_blocks, efsSb.sb_tfree).AppendLine(); sb.AppendFormat(Localization._0_free_inodes, efsSb.sb_tinode).AppendLine(); - if(efsSb.sb_bmblock > 0) - sb.AppendFormat(Localization.Bitmap_resides_at_block_0, efsSb.sb_bmblock).AppendLine(); + if(efsSb.sb_bmblock > 0) sb.AppendFormat(Localization.Bitmap_resides_at_block_0, efsSb.sb_bmblock).AppendLine(); if(efsSb.sb_replsb > 0) sb.AppendFormat(Localization.Replacement_superblock_resides_at_block_0, efsSb.sb_replsb).AppendLine(); @@ -194,8 +191,7 @@ public sealed partial class EFS if(efsSb.sb_lastinode > 0) sb.AppendFormat(Localization.Last_inode_allocated_0, efsSb.sb_lastinode).AppendLine(); - if(efsSb.sb_dirty > 0) - sb.AppendLine(Localization.Volume_is_dirty); + if(efsSb.sb_dirty > 0) sb.AppendLine(Localization.Volume_is_dirty); sb.AppendFormat(Localization.Checksum_0_X8, efsSb.sb_checksum).AppendLine(); sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(efsSb.sb_fname, encoding)).AppendLine(); diff --git a/Aaru.Filesystems/F2FS/Consts.cs b/Aaru.Filesystems/F2FS/Consts.cs index afcdf19b6..edc172d58 100644 --- a/Aaru.Filesystems/F2FS/Consts.cs +++ b/Aaru.Filesystems/F2FS/Consts.cs @@ -36,6 +36,7 @@ namespace Aaru.Filesystems; public sealed partial class F2FS { const string FS_TYPE = "f2fs"; + // ReSharper disable InconsistentNaming const uint F2FS_MAGIC = 0xF2F52010; const uint F2FS_SUPER_OFFSET = 1024; diff --git a/Aaru.Filesystems/F2FS/Info.cs b/Aaru.Filesystems/F2FS/Info.cs index 3bd49df6d..ff102d84d 100644 --- a/Aaru.Filesystems/F2FS/Info.cs +++ b/Aaru.Filesystems/F2FS/Info.cs @@ -46,29 +46,23 @@ public sealed partial class F2FS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize is < F2FS_MIN_SECTOR or > F2FS_MAX_SECTOR) - return false; + if(imagePlugin.Info.SectorSize is < F2FS_MIN_SECTOR or > F2FS_MAX_SECTOR) return false; uint sbAddr = F2FS_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbAddr + sbSize >= partition.End) - return false; + if(partition.Start + sbAddr + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock sb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -82,32 +76,26 @@ public sealed partial class F2FS information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize is < F2FS_MIN_SECTOR or > F2FS_MAX_SECTOR) - return; + if(imagePlugin.Info.SectorSize is < F2FS_MIN_SECTOR or > F2FS_MAX_SECTOR) return; uint sbAddr = F2FS_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; // ReSharper disable once InconsistentNaming Superblock f2fsSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(f2fsSb.magic != F2FS_MAGIC) - return; + if(f2fsSb.magic != F2FS_MAGIC) return; var sb = new StringBuilder(); @@ -115,9 +103,10 @@ public sealed partial class F2FS sb.AppendFormat(Localization.Version_0_1, f2fsSb.major_ver, f2fsSb.minor_ver).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_sector, 1 << (int)f2fsSb.log_sectorsize).AppendLine(); - sb.AppendFormat(Localization._0_sectors_1_bytes_per_block, 1 << (int)f2fsSb.log_sectors_per_block, - 1 << (int)f2fsSb.log_blocksize). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_1_bytes_per_block, + 1 << (int)f2fsSb.log_sectors_per_block, + 1 << (int)f2fsSb.log_blocksize) + .AppendLine(); sb.AppendFormat(Localization._0_blocks_per_segment, f2fsSb.log_blocks_per_seg).AppendLine(); sb.AppendFormat(Localization._0_blocks_in_volume, f2fsSb.block_count).AppendLine(); @@ -129,14 +118,14 @@ public sealed partial class F2FS sb.AppendFormat(Localization.Volume_UUID_0, f2fsSb.uuid).AppendLine(); sb.AppendFormat(Localization.Volume_name_0, - StringHandlers.CToString(f2fsSb.volume_name, Encoding.Unicode, true)). - AppendLine(); + StringHandlers.CToString(f2fsSb.volume_name, Encoding.Unicode, true)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_last_mounted_on_kernel_version_0, StringHandlers.CToString(f2fsSb.version)). - AppendLine(); + sb.AppendFormat(Localization.Volume_last_mounted_on_kernel_version_0, StringHandlers.CToString(f2fsSb.version)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_created_on_kernel_version_0, StringHandlers.CToString(f2fsSb.init_version)). - AppendLine(); + sb.AppendFormat(Localization.Volume_created_on_kernel_version_0, StringHandlers.CToString(f2fsSb.init_version)) + .AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 79edf1d71..2540f56a0 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -384,9 +384,9 @@ public sealed partial class FAT var rootMs = new MemoryStream(); foreach(ulong rootSector in new ulong[] - { - 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 - }) + { + 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 + }) { imagePlugin.ReadSector(rootSector, out byte[] tmp); rootMs.Write(tmp, 0, tmp.Length); @@ -410,8 +410,7 @@ public sealed partial class FAT break; } - if(!validRootDir) - break; + if(!validRootDir) break; } if(z80Di == 0xF3 && @@ -792,8 +791,7 @@ public sealed partial class FAT return BpbKind.Atari; } - if(!useApricotBpb) - return BpbKind.None; + if(!useApricotBpb) return BpbKind.None; fakeBpb.bps = apricotBpb.mainBPB.bps; fakeBpb.spc = apricotBpb.mainBPB.spc; diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index e72417bc8..5e26736c9 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -58,8 +58,7 @@ public sealed partial class FAT { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { @@ -90,18 +89,17 @@ public sealed partial class FAT } string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -111,20 +109,16 @@ public sealed partial class FAT { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.Dirent.start_cluster; - if(_fat32) - currentCluster += (uint)(entry.Value.Dirent.ea_handle << 16); + if(_fat32) currentCluster += (uint)(entry.Value.Dirent.ea_handle << 16); - if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) - continue; + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; // Reserved unallocated directory, seen in Atari ST if(currentCluster == 0) @@ -143,18 +137,17 @@ public sealed partial class FAT uint[] clusters = GetClusters(currentCluster); - if(clusters is null) - return ErrorNumber.InvalidArgument; + if(clusters is null) return ErrorNumber.InvalidArgument; var directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; for(var i = 0; i < clusters.Length; i++) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buffer); + _sectorsPerCluster, + out byte[] buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(buffer, 0, directoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } @@ -166,25 +159,24 @@ public sealed partial class FAT for(var pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf()) { DirectoryEntry dirent = - Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, + Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, + pos, Marshal.SizeOf()); - if(dirent.filename[0] == DIRENT_FINISHED) - break; + if(dirent.filename[0] == DIRENT_FINISHED) break; if(dirent.attributes.HasFlag(FatAttributes.LFN)) { - if(_namespace != Namespace.Lfn && _namespace != Namespace.Ecs) - continue; + if(_namespace != Namespace.Lfn && _namespace != Namespace.Ecs) continue; LfnEntry lfnEntry = - Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, + Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, + pos, Marshal.SizeOf()); int lfnSequence = lfnEntry.sequence & LFN_MASK; - if((lfnEntry.sequence & LFN_ERASED) > 0) - continue; + if((lfnEntry.sequence & LFN_ERASED) > 0) continue; if((lfnEntry.sequence & LFN_LAST) > 0) { @@ -192,11 +184,9 @@ public sealed partial class FAT lastLfnChecksum = lfnEntry.checksum; } - if(lastLfnName is null) - continue; + if(lastLfnName is null) continue; - if(lfnEntry.checksum != lastLfnChecksum) - continue; + if(lfnEntry.checksum != lastLfnChecksum) continue; lfnSequence--; @@ -208,25 +198,20 @@ public sealed partial class FAT } // Not a correct entry - if(dirent.filename[0] < DIRENT_MIN && dirent.filename[0] != DIRENT_E5) - continue; + if(dirent.filename[0] < DIRENT_MIN && dirent.filename[0] != DIRENT_E5) continue; // Self - if(_encoding.GetString(dirent.filename).TrimEnd() == ".") - continue; + if(_encoding.GetString(dirent.filename).TrimEnd() == ".") continue; // Parent - if(_encoding.GetString(dirent.filename).TrimEnd() == "..") - continue; + if(_encoding.GetString(dirent.filename).TrimEnd() == "..") continue; // Deleted - if(dirent.filename[0] == DIRENT_DELETED) - continue; + if(dirent.filename[0] == DIRENT_DELETED) continue; string filename; - if(dirent.attributes.HasFlag(FatAttributes.VolumeLabel)) - continue; + if(dirent.attributes.HasFlag(FatAttributes.VolumeLabel)) continue; var completeEntry = new CompleteDirectoryEntry { @@ -247,8 +232,7 @@ public sealed partial class FAT } } - if(dirent.filename[0] == DIRENT_E5) - dirent.filename[0] = DIRENT_DELETED; + if(dirent.filename[0] == DIRENT_E5) dirent.filename[0] = DIRENT_DELETED; string name = _encoding.GetString(dirent.filename).TrimEnd(); string extension = _encoding.GetString(dirent.extension).TrimEnd(); @@ -257,8 +241,7 @@ public sealed partial class FAT { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_empty_filename_in_0, path); - if(!_debug || dirent is { size: > 0, start_cluster: 0 }) - continue; // Skip invalid name + if(!_debug || dirent is { size: > 0, start_cluster: 0 }) continue; // Skip invalid name // If debug, add it name = ":{EMPTYNAME}:"; @@ -268,13 +251,11 @@ public sealed partial class FAT { extension = $"{uniq:D03}"; - if(!currentDirectory.ContainsKey($"{name}.{extension}")) - break; + if(!currentDirectory.ContainsKey($"{name}.{extension}")) break; } // If we couldn't find it, just skip over - if(currentDirectory.ContainsKey($"{name}.{extension}")) - continue; + if(currentDirectory.ContainsKey($"{name}.{extension}")) continue; } if(_namespace == Namespace.Nt) @@ -294,7 +275,8 @@ public sealed partial class FAT if(_namespace == Namespace.Human) { HumanDirectoryEntry humanEntry = - Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, + Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, + pos, Marshal.SizeOf()); completeEntry.HumanDirent = humanEntry; @@ -330,19 +312,15 @@ public sealed partial class FAT { Dictionary eas = GetEas(fileWithEa.Value.Dirent.ea_handle); - if(eas is null) - continue; + if(eas is null) continue; - if(!eas.TryGetValue("com.microsoft.os2.longname", out byte[] longnameEa)) - continue; + if(!eas.TryGetValue("com.microsoft.os2.longname", out byte[] longnameEa)) continue; - if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) - continue; + if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue; var longnameSize = BitConverter.ToUInt16(longnameEa, 2); - if(longnameSize + 4 > longnameEa.Length) - continue; + if(longnameSize + 4 > longnameEa.Length) continue; var longnameBytes = new byte[longnameSize]; @@ -350,8 +328,7 @@ public sealed partial class FAT string longname = StringHandlers.CToString(longnameBytes, _encoding); - if(string.IsNullOrWhiteSpace(longname)) - continue; + if(string.IsNullOrWhiteSpace(longname)) continue; // Forward slash is allowed in .LONGNAME, so change it to visually similar division slash longname = longname.Replace('/', '\u2215'); @@ -365,8 +342,8 @@ public sealed partial class FAT // Check FAT32.IFS EAs if(_fat32 || _debug) { - var fat32EaSidecars = currentDirectory.Where(t => t.Key.EndsWith(FAT32_EA_TAIL, true, _cultureInfo)). - ToList(); + var fat32EaSidecars = currentDirectory.Where(t => t.Key.EndsWith(FAT32_EA_TAIL, true, _cultureInfo)) + .ToList(); foreach(KeyValuePair sidecar in fat32EaSidecars) { @@ -387,16 +364,14 @@ public sealed partial class FAT fileWithEa.Fat32Ea = sidecar.Value.Dirent; - if(!_debug) - currentDirectory.Remove(sidecar.Key); + if(!_debug) currentDirectory.Remove(sidecar.Key); } } _directoryCache.Add(currentPath, currentDirectory); } - if(currentDirectory is null) - return ErrorNumber.NoSuchFile; + if(currentDirectory is null) return ErrorNumber.NoSuchFile; node = new FatDirNode { @@ -413,17 +388,13 @@ public sealed partial class FAT { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not FatDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Entries.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Entries.Length) return ErrorNumber.NoError; CompleteDirectoryEntry entry = mynode.Entries[mynode.Position]; @@ -445,8 +416,7 @@ public sealed partial class FAT /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not FatDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Entries = null; diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 99670efea..64417ed25 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -47,13 +47,11 @@ public sealed partial class FAT { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; @@ -65,21 +63,17 @@ public sealed partial class FAT { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return ErrorNumber.IsDirectory; + if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) return ErrorNumber.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); - if(clusters is null) - return ErrorNumber.InvalidArgument; + if(clusters is null) return ErrorNumber.InvalidArgument; node = new FatFileNode { @@ -95,11 +89,9 @@ public sealed partial class FAT /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not FatFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Clusters = null; @@ -111,40 +103,34 @@ public sealed partial class FAT { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not FatFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; long firstCluster = mynode.Offset / _bytesPerCluster; long offsetInCluster = mynode.Offset % _bytesPerCluster; long sizeInClusters = (read + offsetInCluster) / _bytesPerCluster; - if((read + offsetInCluster) % _bytesPerCluster > 0) - sizeInClusters++; + if((read + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++; var ms = new MemoryStream(); for(var i = 0; i < sizeInClusters; i++) { - if(i + firstCluster >= mynode.Clusters.Length) - return ErrorNumber.InvalidArgument; + if(i + firstCluster >= mynode.Clusters.Length) return ErrorNumber.InvalidArgument; ErrorNumber errno = _image.ReadSectors(_firstClusterSector + mynode.Clusters[i + firstCluster] * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buf); + _sectorsPerCluster, + out byte[] buf); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(buf, 0, buf.Length); } @@ -161,13 +147,11 @@ public sealed partial class FAT { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; DirectoryEntry entry = completeEntry.Dirent; @@ -181,20 +165,17 @@ public sealed partial class FAT Links = 1 }; - if(entry.cdate > 0 || entry.ctime > 0) - stat.CreationTime = DateHandlers.DosToDateTime(entry.cdate, entry.ctime); + if(entry.cdate > 0 || entry.ctime > 0) stat.CreationTime = DateHandlers.DosToDateTime(entry.cdate, entry.ctime); if(_namespace != Namespace.Human) { if(entry.mdate > 0 || entry.mtime > 0) stat.LastWriteTime = DateHandlers.DosToDateTime(entry.mdate, entry.mtime); - if(entry.ctime_ms > 0) - stat.CreationTime = stat.CreationTime?.AddMilliseconds(entry.ctime_ms * 10); + if(entry.ctime_ms > 0) stat.CreationTime = stat.CreationTime?.AddMilliseconds(entry.ctime_ms * 10); } - if(entry.size % _bytesPerCluster > 0) - stat.Blocks++; + if(entry.size % _bytesPerCluster > 0) stat.Blocks++; if(entry.attributes.HasFlag(FatAttributes.Subdirectory)) { @@ -210,20 +191,15 @@ public sealed partial class FAT stat.Length = stat.Blocks * stat.BlockSize; } - if(entry.attributes.HasFlag(FatAttributes.ReadOnly)) - stat.Attributes |= FileAttributes.ReadOnly; + if(entry.attributes.HasFlag(FatAttributes.ReadOnly)) stat.Attributes |= FileAttributes.ReadOnly; - if(entry.attributes.HasFlag(FatAttributes.Hidden)) - stat.Attributes |= FileAttributes.Hidden; + if(entry.attributes.HasFlag(FatAttributes.Hidden)) stat.Attributes |= FileAttributes.Hidden; - if(entry.attributes.HasFlag(FatAttributes.System)) - stat.Attributes |= FileAttributes.System; + if(entry.attributes.HasFlag(FatAttributes.System)) stat.Attributes |= FileAttributes.System; - if(entry.attributes.HasFlag(FatAttributes.Archive)) - stat.Attributes |= FileAttributes.Archive; + if(entry.attributes.HasFlag(FatAttributes.Archive)) stat.Attributes |= FileAttributes.Archive; - if(entry.attributes.HasFlag(FatAttributes.Device)) - stat.Attributes |= FileAttributes.Device; + if(entry.attributes.HasFlag(FatAttributes.Device)) stat.Attributes |= FileAttributes.Device; return ErrorNumber.NoError; } @@ -232,11 +208,9 @@ public sealed partial class FAT uint[] GetClusters(uint startCluster) { - if(startCluster == 0) - return Array.Empty(); + if(startCluster == 0) return Array.Empty(); - if(startCluster >= Metadata.Clusters) - return null; + if(startCluster >= Metadata.Clusters) return null; List clusters = new(); @@ -249,8 +223,7 @@ public sealed partial class FAT ulong currentSector = nextSector; ErrorNumber errno = _image.ReadSector(currentSector, out byte[] fatData); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; if(_fat32) { @@ -262,8 +235,7 @@ public sealed partial class FAT { errno = _image.ReadSector(nextSector, out fatData); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; currentSector = nextSector; } @@ -279,8 +251,7 @@ public sealed partial class FAT { while(nextCluster is > 0 and <= FAT16_RESERVED) { - if(nextCluster >= _fatEntries.Length) - break; + if(nextCluster >= _fatEntries.Length) break; clusters.Add(nextCluster); nextCluster = _fatEntries[nextCluster]; @@ -290,8 +261,7 @@ public sealed partial class FAT { while(nextCluster is > 0 and <= FAT12_RESERVED) { - if(nextCluster >= _fatEntries.Length) - break; + if(nextCluster >= _fatEntries.Length) break; clusters.Add(nextCluster); nextCluster = _fatEntries[nextCluster]; @@ -308,12 +278,12 @@ public sealed partial class FAT string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pieces.Length == 0) - return ErrorNumber.InvalidArgument; + if(pieces.Length == 0) return ErrorNumber.InvalidArgument; var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); @@ -321,8 +291,7 @@ public sealed partial class FAT { ErrorNumber err = OpenDir(parentPath, out IDirNode node); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; CloseDir(node); } @@ -331,14 +300,12 @@ public sealed partial class FAT if(pieces.Length == 1) parent = _rootDirectoryCache; - else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return ErrorNumber.InvalidArgument; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); - if(string.IsNullOrEmpty(dirent.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile; entry = dirent.Value; @@ -349,11 +316,9 @@ public sealed partial class FAT { byte sum = 0; - for(var i = 0; i < 8; i++) - sum = (byte)(((sum & 1) << 7) + (sum >> 1) + name[i]); + for(var i = 0; i < 8; i++) sum = (byte)(((sum & 1) << 7) + (sum >> 1) + name[i]); - for(var i = 0; i < 3; i++) - sum = (byte)(((sum & 1) << 7) + (sum >> 1) + extension[i]); + for(var i = 0; i < 3; i++) sum = (byte)(((sum & 1) << 7) + (sum >> 1) + extension[i]); return sum; } diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index 069e96eaf..c5d009eeb 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -51,8 +51,7 @@ public sealed partial class FAT [SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")] public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ushort bps; byte spc; @@ -77,13 +76,11 @@ public sealed partial class FAT ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; errno = imagePlugin.ReadSector(sectorsPerBpb + partition.Start, out byte[] fatSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; HumanParameterBlock humanBpb = Marshal.ByteArrayToStructureBigEndian(bpbSector); @@ -125,8 +122,7 @@ public sealed partial class FAT AaruConsole.DebugWriteLine(MODULE_NAME, "humanBranchCorrect = {0}", humanBranchCorrect); // If all Human68k checks are correct, it is a Human68k FAT16 - if(humanClustersCorrect && humanOemCorrect && humanBranchCorrect && expectedClusters > 0) - return true; + if(humanClustersCorrect && humanOemCorrect && humanBranchCorrect && expectedClusters > 0) return true; Array.Copy(bpbSector, 0x02, atariOem, 0, 6); Array.Copy(bpbSector, 0x03, dosOem, 0, 8); @@ -147,8 +143,7 @@ public sealed partial class FAT fatId = fatSector[0]; int bitsInBps = CountBits.Count(bps); - if(imagePlugin.Info.SectorSize >= 512) - bootable = BitConverter.ToUInt16(bpbSector, 0x1FE); + if(imagePlugin.Info.SectorSize >= 512) bootable = BitConverter.ToUInt16(bpbSector, 0x1FE); bool correctSpc = spc is 1 or 2 or 4 or 8 or 16 or 32 or 64; string msxString = Encoding.ASCII.GetString(msxId); @@ -245,14 +240,12 @@ public sealed partial class FAT errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16 - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); var hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); - if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) - return false; + if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) return false; } switch(bitsInBps) @@ -315,8 +308,7 @@ public sealed partial class FAT return true; // All FAT12 without BPB can only be used on floppies, without partitions. - if(partition.Start != 0) - return false; + if(partition.Start != 0) return false; // DEC Rainbow, lacks a BPB but has a very concrete structure... if(imagePlugin.Info is { Sectors: 800, SectorSize: 512 }) @@ -327,14 +319,12 @@ public sealed partial class FAT // First FAT1 sector resides at LBA 0x14 errno = imagePlugin.ReadSector(0x14, out byte[] fat1Sector0); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; // First FAT2 sector resides at LBA 0x1A errno = imagePlugin.ReadSector(0x1A, out byte[] fat2Sector0); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; bool equalFatIds = fat1Sector0[0] == fat2Sector0[0] && fat1Sector0[1] == fat2Sector0[1]; @@ -342,14 +332,13 @@ public sealed partial class FAT var rootMs = new MemoryStream(); foreach(ulong rootSector in new ulong[] - { - 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 - }) + { + 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 + }) { errno = imagePlugin.ReadSector(rootSector, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; rootMs.Write(tmp, 0, tmp.Length); } @@ -372,8 +361,7 @@ public sealed partial class FAT break; } - if(!validRootDir) - break; + if(!validRootDir) break; } if(z80Di == 0xF3 && @@ -390,16 +378,14 @@ public sealed partial class FAT AaruConsole.DebugWriteLine(MODULE_NAME, "1st fat cluster 1 = {0:X3}", fatCluster2); - if(fatCluster2 < 0xFF0) - return false; + if(fatCluster2 < 0xFF0) return false; ulong fat2SectorNo = 0; switch(fatId) { case 0xE5: - if(imagePlugin.Info is { Sectors: 2002, SectorSize: 128 }) - fat2SectorNo = 2; + if(imagePlugin.Info is { Sectors: 2002, SectorSize: 128 }) fat2SectorNo = 2; break; case 0xFD: @@ -427,35 +413,30 @@ public sealed partial class FAT break; case 0xFF: - if(imagePlugin.Info is { Sectors: 640, SectorSize: 512 }) - fat2SectorNo = 2; + if(imagePlugin.Info is { Sectors: 640, SectorSize: 512 }) fat2SectorNo = 2; break; default: - if(fatId < 0xE8) - return false; + if(fatId < 0xE8) return false; fat2SectorNo = 2; break; } - if(fat2SectorNo > partition.End || fat2SectorNo == 0) - return false; + if(fat2SectorNo > partition.End || fat2SectorNo == 0) return false; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Second_fat_starts_at_0, fat2SectorNo); errno = imagePlugin.ReadSector(fat2SectorNo, out byte[] fat2Sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; fat2 = fat2Sector[1]; fat3 = fat2Sector[2]; fatCluster2 = (ushort)((fat2 << 8) + fat3 & 0xFFF); - if(fatCluster2 < 0xFF0) - return false; + if(fatCluster2 < 0xFF0) return false; return fatId == fat2Sector[0]; } @@ -474,12 +455,17 @@ public sealed partial class FAT ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - BpbKind bpbKind = DetectBpbKind(bpbSector, imagePlugin, partition, out BiosParameterBlockEbpb fakeBpb, - out HumanParameterBlock humanBpb, out AtariParameterBlock atariBpb, - out byte minBootNearJump, out bool andosOemCorrect, out bool bootable); + BpbKind bpbKind = DetectBpbKind(bpbSector, + imagePlugin, + partition, + out BiosParameterBlockEbpb fakeBpb, + out HumanParameterBlock humanBpb, + out AtariParameterBlock atariBpb, + out byte minBootNearJump, + out bool andosOemCorrect, + out bool bootable); var isFat12 = false; var isFat16 = false; @@ -553,25 +539,28 @@ public sealed partial class FAT if(fat32Bpb is { big_sectors: 0, signature: 0x28 }) { - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, shortFat32Bpb.huge_sectors, - shortFat32Bpb.huge_sectors * shortFat32Bpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, + shortFat32Bpb.huge_sectors, + shortFat32Bpb.huge_sectors * shortFat32Bpb.bps) + .AppendLine(); metadata.Clusters = shortFat32Bpb.huge_sectors / shortFat32Bpb.spc; } else if(fat32Bpb.sectors == 0) { - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fat32Bpb.big_sectors, - fat32Bpb.big_sectors * fat32Bpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, + fat32Bpb.big_sectors, + fat32Bpb.big_sectors * fat32Bpb.bps) + .AppendLine(); metadata.Clusters = fat32Bpb.big_sectors / fat32Bpb.spc; } else { - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fat32Bpb.sectors, - fat32Bpb.sectors * fat32Bpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, + fat32Bpb.sectors, + fat32Bpb.sectors * fat32Bpb.bps) + .AppendLine(); metadata.Clusters = (ulong)(fat32Bpb.sectors / fat32Bpb.spc); } @@ -585,8 +574,8 @@ public sealed partial class FAT sb.AppendFormat(Localization.Cluster_of_root_directory_0, fat32Bpb.root_cluster).AppendLine(); sb.AppendFormat(Localization.Sector_of_FSINFO_structure_0, fat32Bpb.fsinfo_sector).AppendLine(); - sb.AppendFormat(Localization.Sector_of_backup_FAT32_parameter_block_0, fat32Bpb.backup_sector). - AppendLine(); + sb.AppendFormat(Localization.Sector_of_backup_FAT32_parameter_block_0, fat32Bpb.backup_sector) + .AppendLine(); sb.AppendFormat(Localization.Drive_number_0, fat32Bpb.drive_no).AppendLine(); sb.AppendFormat(Localization.Volume_Serial_Number_0, fat32Bpb.serial_no).AppendLine(); @@ -606,8 +595,8 @@ public sealed partial class FAT if((fat32Bpb.mirror_flags & 0x80) == 0x80) { - sb.AppendFormat(Localization.FATs_are_out_of_sync_FAT_0_is_in_use, fat32Bpb.mirror_flags & 0xF). - AppendLine(); + sb.AppendFormat(Localization.FATs_are_out_of_sync_FAT_0_is_in_use, fat32Bpb.mirror_flags & 0xF) + .AppendLine(); } else sb.AppendLine(Localization.All_copies_of_FAT_are_the_same); @@ -622,8 +611,8 @@ public sealed partial class FAT metadata.VolumeName = StringHandlers.SpacePaddedToString(fat32Bpb.volume_label, encoding); metadata.VolumeName = metadata.VolumeName?.Replace("\0", ""); - sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fat32Bpb.fs_type)). - AppendLine(); + sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fat32Bpb.fs_type)) + .AppendLine(); bootChk = Sha1Context.Data(fat32Bpb.boot_code, out _); } @@ -654,8 +643,7 @@ public sealed partial class FAT { errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; FsInfoSector fsInfo = Marshal.ByteArrayToStructureLittleEndian(fsinfoSector); @@ -681,8 +669,7 @@ public sealed partial class FAT { ushort sum = 0; - for(var i = 0; i < bpbSector.Length; i += 2) - sum += BigEndianBitConverter.ToUInt16(bpbSector, i); + for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i); // TODO: Check this if(sum == 0x1234) @@ -691,14 +678,14 @@ public sealed partial class FAT var atariSb = new StringBuilder(); atariSb.AppendFormat(Localization.cmdload_will_be_loaded_with_value_0, - BigEndianBitConverter.ToUInt16(bpbSector, 0x01E)). - AppendLine(); + BigEndianBitConverter.ToUInt16(bpbSector, 0x01E)) + .AppendLine(); - atariSb.AppendFormat(Localization.Boot_program_will_be_loaded_at_address_0, atariBpb.ldaaddr). - AppendLine(); + atariSb.AppendFormat(Localization.Boot_program_will_be_loaded_at_address_0, atariBpb.ldaaddr) + .AppendLine(); - atariSb.AppendFormat(Localization.FAT_and_directory_will_be_cached_at_address_0, atariBpb.fatbuf). - AppendLine(); + atariSb.AppendFormat(Localization.FAT_and_directory_will_be_cached_at_address_0, atariBpb.fatbuf) + .AppendLine(); if(atariBpb.ldmode == 0) { @@ -720,8 +707,10 @@ public sealed partial class FAT else { atariSb.AppendFormat(Localization.Boot_program_starts_in_sector_0_and_is_1_sectors_long_2_bytes, - atariBpb.ssect, atariBpb.sectcnt, atariBpb.sectcnt * atariBpb.bps). - AppendLine(); + atariBpb.ssect, + atariBpb.sectcnt, + atariBpb.sectcnt * atariBpb.bps) + .AppendLine(); } extraInfo = atariSb.ToString(); @@ -748,8 +737,7 @@ public sealed partial class FAT fakeBpb.sptrk /= 4; fakeBpb.rsectors /= 4; - if(fakeBpb.spc == 0) - fakeBpb.spc = 1; + if(fakeBpb.spc == 0) fakeBpb.spc = 1; } ulong clusters; @@ -792,8 +780,7 @@ public sealed partial class FAT errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var pos = 0; @@ -801,23 +788,20 @@ public sealed partial class FAT { fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); - if(pos >= fat12.Length) - break; + if(pos >= fat12.Length) break; fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } bool fat12Valid = fat12[0] >= FAT12_RESERVED && fat12[1] >= FAT12_RESERVED; - if(fat12.Any(entry => entry < FAT12_RESERVED && entry > clusters + 2)) - fat12Valid = false; + if(fat12.Any(entry => entry < FAT12_RESERVED && entry > clusters + 2)) fat12Valid = false; ushort[] fat16 = MemoryMarshal.Cast(fatBytes).ToArray(); bool fat16Valid = fat16[0] >= FAT16_RESERVED && fat16[1] >= 0x3FF0; - if(fat16.Any(entry => entry < FAT16_RESERVED && entry > clusters + 2)) - fat16Valid = false; + if(fat16.Any(entry => entry < FAT16_RESERVED && entry > clusters + 2)) fat16Valid = false; isFat12 = fat12Valid; isFat16 = fat16Valid; @@ -830,8 +814,7 @@ public sealed partial class FAT isFat16 = fakeBpb.fs_type != null && Encoding.ASCII.GetString(fakeBpb.fs_type) == "FAT16 "; } - if(!isFat12 && !isFat16) - isFat12 = true; + if(!isFat12 && !isFat16) isFat12 = true; } else isFat16 = true; @@ -885,8 +868,7 @@ public sealed partial class FAT metadata.SystemIdentifier = StringHandlers.CToString(atariBpb.oem_name); - if(string.IsNullOrEmpty(metadata.SystemIdentifier)) - metadata.SystemIdentifier = null; + if(string.IsNullOrEmpty(metadata.SystemIdentifier)) metadata.SystemIdentifier = null; } else if(fakeBpb.oem_name != null) { @@ -932,8 +914,7 @@ public sealed partial class FAT }; } - if(fakeBpb.signature is 0x28 or 0x29) - metadata.VolumeSerial = $"{fakeBpb.serial_no:X8}"; + if(fakeBpb.signature is 0x28 or 0x29) metadata.VolumeSerial = $"{fakeBpb.serial_no:X8}"; } if(metadata.SystemIdentifier != null) @@ -945,22 +926,25 @@ public sealed partial class FAT { if(fakeBpb.sectors == 0) { - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fakeBpb.big_sectors, - fakeBpb.big_sectors * fakeBpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, + fakeBpb.big_sectors, + fakeBpb.big_sectors * fakeBpb.bps) + .AppendLine(); } else { - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fakeBpb.sectors, - fakeBpb.sectors * fakeBpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, + fakeBpb.sectors, + fakeBpb.sectors * fakeBpb.bps) + .AppendLine(); } } else { sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, - clusters * humanBpb.bpc / imagePlugin.Info.SectorSize, clusters * humanBpb.bpc). - AppendLine(); + clusters * humanBpb.bpc / imagePlugin.Info.SectorSize, + clusters * humanBpb.bpc) + .AppendLine(); } metadata.Clusters = clusters; @@ -971,8 +955,7 @@ public sealed partial class FAT sb.AppendFormat(Localization._0_FATs, fakeBpb.fats_no).AppendLine(); sb.AppendFormat(Localization._0_entries_in_root_directory, fakeBpb.root_ent).AppendLine(); - if(fakeBpb.media > 0) - sb.AppendFormat(Localization.Media_descriptor_0, fakeBpb.media).AppendLine(); + if(fakeBpb.media > 0) sb.AppendFormat(Localization.Media_descriptor_0, fakeBpb.media).AppendLine(); sb.AppendFormat(Localization._0_sectors_per_FAT, fakeBpb.spfat).AppendLine(); @@ -1009,8 +992,8 @@ public sealed partial class FAT metadata.VolumeName = StringHandlers.SpacePaddedToString(fakeBpb.volume_label, encoding); metadata.VolumeName = metadata.VolumeName?.Replace("\0", ""); - sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fakeBpb.fs_type)). - AppendLine(); + sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fakeBpb.fs_type)) + .AppendLine(); } } else if(bpbKind == BpbKind.Atari && metadata.VolumeSerial != null) @@ -1019,8 +1002,7 @@ public sealed partial class FAT bootChk = Sha1Context.Data(fakeBpb.boot_code, out _); // Workaround that PCExchange jumps into "FAT16 "... - if(metadata.SystemIdentifier == "PCX 2.0 ") - fakeBpb.jump[1] += 8; + if(metadata.SystemIdentifier == "PCX 2.0 ") fakeBpb.jump[1] += 8; // Check that jumps to a correct boot code position and has boot signature set. // This will mean that the volume will boot, even if just to say "this is not bootable change disk"...... @@ -1042,31 +1024,29 @@ public sealed partial class FAT sectorsForRootDirectory = (uint)(fakeBpb.root_ent * 32 / imagePlugin.Info.SectorSize); } - if(extraInfo != null) - sb.Append(extraInfo); + if(extraInfo != null) sb.Append(extraInfo); if(rootDirectorySector + partition.Start < partition.End && imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) { - errno = imagePlugin.ReadSectors(rootDirectorySector + partition.Start, sectorsForRootDirectory, + errno = imagePlugin.ReadSectors(rootDirectorySector + partition.Start, + sectorsForRootDirectory, out byte[] rootDirectory); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; if(bpbKind == BpbKind.DecRainbow) { var rootMs = new MemoryStream(); foreach(ulong rootSector in new ulong[] - { - 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 - }) + { + 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 + }) { errno = imagePlugin.ReadSector(rootSector, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; rootMs.Write(tmp, 0, tmp.Length); } @@ -1077,16 +1057,13 @@ public sealed partial class FAT for(var i = 0; i < rootDirectory.Length; i += 32) { // Not a correct entry - if(rootDirectory[i] < DIRENT_MIN && rootDirectory[i] != DIRENT_E5) - continue; + if(rootDirectory[i] < DIRENT_MIN && rootDirectory[i] != DIRENT_E5) continue; // Deleted or subdirectory entry - if(rootDirectory[i] == DIRENT_SUBDIR || rootDirectory[i] == DIRENT_DELETED) - continue; + if(rootDirectory[i] == DIRENT_SUBDIR || rootDirectory[i] == DIRENT_DELETED) continue; // Not a volume label - if(rootDirectory[i + 0x0B] != 0x08 && rootDirectory[i + 0x0B] != 0x28) - continue; + if(rootDirectory[i + 0x0B] != 0x08 && rootDirectory[i + 0x0B] != 0x28) continue; DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, 32); @@ -1117,8 +1094,8 @@ public sealed partial class FAT if(entry.adate > 0) { sb.AppendFormat(Localization.Volume_last_accessed_on_0_d, - DateHandlers.DosToDateTime(entry.adate, 0)). - AppendLine(); + DateHandlers.DosToDateTime(entry.adate, 0)) + .AppendLine(); } break; diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index 40d0b778d..7a145c1db 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -652,16 +652,13 @@ public sealed partial class FAT public override string ToString() { // This ensures UMSDOS takes preference when present - if(!string.IsNullOrEmpty(LinuxName)) - return LinuxName; + if(!string.IsNullOrEmpty(LinuxName)) return LinuxName; // This ensures LFN takes preference when eCS is in use - if(!string.IsNullOrEmpty(Lfn)) - return Lfn; + if(!string.IsNullOrEmpty(Lfn)) return Lfn; // This ensures Humans takes preference when present - if(!string.IsNullOrEmpty(HumanName)) - return HumanName; + if(!string.IsNullOrEmpty(HumanName)) return HumanName; return !string.IsNullOrEmpty(Longname) ? Longname : Shortname; } @@ -863,12 +860,12 @@ public sealed partial class FAT internal CompleteDirectoryEntry[] Entries; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -879,7 +876,7 @@ public sealed partial class FAT { internal uint[] Clusters; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -890,7 +887,7 @@ public sealed partial class FAT /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 75283ac27..ced43f624 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -57,8 +57,7 @@ public sealed partial class FAT options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); // Default namespace @namespace ??= "ecs"; @@ -99,12 +98,17 @@ public sealed partial class FAT ErrorNumber errno = imagePlugin.ReadSectors(0 + partition.Start, sectorsPerBpb, out byte[] bpbSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; - BpbKind bpbKind = DetectBpbKind(bpbSector, imagePlugin, partition, out BiosParameterBlockEbpb fakeBpb, - out HumanParameterBlock humanBpb, out AtariParameterBlock atariBpb, - out byte minBootNearJump, out bool andosOemCorrect, out bool bootable); + BpbKind bpbKind = DetectBpbKind(bpbSector, + imagePlugin, + partition, + out BiosParameterBlockEbpb fakeBpb, + out HumanParameterBlock humanBpb, + out AtariParameterBlock atariBpb, + out byte minBootNearJump, + out bool andosOemCorrect, + out bool bootable); _fat12 = false; _fat16 = false; @@ -190,12 +194,10 @@ public sealed partial class FAT if((fat32Bpb.flags & 0xF8) == 0x00) { - if((fat32Bpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + if((fat32Bpb.flags & 0x01) == 0x01) Metadata.Dirty = true; } - if((fat32Bpb.mirror_flags & 0x80) == 0x80) - _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; + if((fat32Bpb.mirror_flags & 0x80) == 0x80) _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; if(fat32Bpb.signature == 0x29) { @@ -224,8 +226,7 @@ public sealed partial class FAT { errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; FsInfoSector fsInfo = Marshal.ByteArrayToStructureLittleEndian(fsinfoSector); @@ -242,12 +243,10 @@ public sealed partial class FAT { ushort sum = 0; - for(var i = 0; i < bpbSector.Length; i += 2) - sum += BigEndianBitConverter.ToUInt16(bpbSector, i); + for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i); // TODO: Check this - if(sum == 0x1234) - Metadata.Bootable = true; + if(sum == 0x1234) Metadata.Bootable = true; // BGM changes the bytes per sector instead of changing the sectors per cluster. Why?! WHY!? uint ratio = fakeBpb.bps / imagePlugin.Info.SectorSize; @@ -264,8 +263,7 @@ public sealed partial class FAT case BpbKind.Human: // If not debug set Human68k namespace and ShiftJIS codepage as defaults - if(!_debug) - _namespace = Namespace.Human; + if(!_debug) _namespace = Namespace.Human; Metadata.Bootable = true; @@ -286,8 +284,7 @@ public sealed partial class FAT fakeBpb.sptrk /= 4; fakeBpb.rsectors /= 4; - if(fakeBpb.spc == 0) - fakeBpb.spc = 1; + if(fakeBpb.spc == 0) fakeBpb.spc = 1; } ulong clusters; @@ -329,8 +326,7 @@ public sealed partial class FAT errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; var pos = 0; @@ -338,23 +334,20 @@ public sealed partial class FAT { fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); - if(pos >= fat12.Length) - break; + if(pos >= fat12.Length) break; fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } bool fat12Valid = fat12[0] >= FAT12_RESERVED && fat12[1] >= FAT12_RESERVED; - if(fat12.Any(entry => entry < FAT12_RESERVED && entry > clusters)) - fat12Valid = false; + if(fat12.Any(entry => entry < FAT12_RESERVED && entry > clusters)) fat12Valid = false; ushort[] fat16 = MemoryMarshal.Cast(fatBytes).ToArray(); bool fat16Valid = fat16[0] >= FAT16_RESERVED && fat16[1] >= 0x3FF0; - if(fat16.Any(entry => entry < FAT16_RESERVED && entry > clusters)) - fat16Valid = false; + if(fat16.Any(entry => entry < FAT16_RESERVED && entry > clusters)) fat16Valid = false; _fat12 = fat12Valid; _fat16 = fat16Valid; @@ -378,9 +371,8 @@ public sealed partial class FAT } if(_fat12) - Metadata.Type = FS_TYPE_FAT12; - else if(_fat16) - Metadata.Type = FS_TYPE_FAT16; + Metadata.Type = FS_TYPE_FAT12; + else if(_fat16) Metadata.Type = FS_TYPE_FAT16; if(bpbKind == BpbKind.Atari) { @@ -400,8 +392,7 @@ public sealed partial class FAT Metadata.SystemIdentifier = StringHandlers.CToString(atariBpb.oem_name); - if(string.IsNullOrEmpty(Metadata.SystemIdentifier)) - Metadata.SystemIdentifier = null; + if(string.IsNullOrEmpty(Metadata.SystemIdentifier)) Metadata.SystemIdentifier = null; } else if(fakeBpb.oem_name != null) { @@ -467,8 +458,7 @@ public sealed partial class FAT { if((fakeBpb.flags & 0xF8) == 0x00) { - if((fakeBpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + if((fakeBpb.flags & 0x01) == 0x01) Metadata.Dirty = true; } if(fakeBpb.signature == 0x29 || andosOemCorrect) @@ -479,8 +469,7 @@ public sealed partial class FAT } // Workaround that PCExchange jumps into "FAT16 "... - if(Metadata.SystemIdentifier == "PCX 2.0 ") - fakeBpb.jump[1] += 8; + if(Metadata.SystemIdentifier == "PCX 2.0 ") fakeBpb.jump[1] += 8; // Check that jumps to a correct boot code position and has boot signature set. // This will mean that the volume will boot, even if just to say "this is not bootable change disk"...... @@ -525,22 +514,20 @@ public sealed partial class FAT _firstClusterSector = firstRootSector + sectorsForRootDirectory - _sectorsPerCluster * 2; errno = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory, out rootDirectory); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; if(bpbKind == BpbKind.DecRainbow) { var rootMs = new MemoryStream(); foreach(ulong rootSector in new ulong[] - { - 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 - }) + { + 0x17, 0x19, 0x1B, 0x1D, 0x1E, 0x20 + }) { errno = imagePlugin.ReadSector(rootSector, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; rootMs.Write(tmp, 0, tmp.Length); } @@ -550,19 +537,18 @@ public sealed partial class FAT } else { - if(rootDirectoryCluster == 0) - return ErrorNumber.InvalidArgument; + if(rootDirectoryCluster == 0) return ErrorNumber.InvalidArgument; var rootMs = new MemoryStream(); uint[] rootDirectoryClusters = GetClusters(rootDirectoryCluster); foreach(uint cluster in rootDirectoryClusters) { - errno = imagePlugin.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, _sectorsPerCluster, + errno = imagePlugin.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, + _sectorsPerCluster, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; rootMs.Write(buffer, 0, buffer.Length); } @@ -570,12 +556,10 @@ public sealed partial class FAT rootDirectory = rootMs.ToArray(); // OS/2 FAT32.IFS uses LFN instead of .LONGNAME - if(_namespace == Namespace.Os2) - _namespace = Namespace.Lfn; + if(_namespace == Namespace.Os2) _namespace = Namespace.Lfn; } - if(rootDirectory is null) - return ErrorNumber.InvalidArgument; + if(rootDirectory is null) return ErrorNumber.InvalidArgument; byte[] lastLfnName = null; byte lastLfnChecksum = 0; @@ -583,24 +567,22 @@ public sealed partial class FAT for(var i = 0; i < rootDirectory.Length; i += Marshal.SizeOf()) { DirectoryEntry entry = - Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, + Marshal.ByteArrayToStructureLittleEndian(rootDirectory, + i, Marshal.SizeOf()); - if(entry.filename[0] == DIRENT_FINISHED) - break; + if(entry.filename[0] == DIRENT_FINISHED) break; if(entry.attributes.HasFlag(FatAttributes.LFN)) { - if(_namespace != Namespace.Lfn && _namespace != Namespace.Ecs) - continue; + if(_namespace != Namespace.Lfn && _namespace != Namespace.Ecs) continue; LfnEntry lfnEntry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, Marshal.SizeOf()); int lfnSequence = lfnEntry.sequence & LFN_MASK; - if((lfnEntry.sequence & LFN_ERASED) > 0) - continue; + if((lfnEntry.sequence & LFN_ERASED) > 0) continue; if((lfnEntry.sequence & LFN_LAST) > 0) { @@ -608,11 +590,9 @@ public sealed partial class FAT lastLfnChecksum = lfnEntry.checksum; } - if(lastLfnName is null) - continue; + if(lastLfnName is null) continue; - if(lfnEntry.checksum != lastLfnChecksum) - continue; + if(lfnEntry.checksum != lastLfnChecksum) continue; lfnSequence--; @@ -624,20 +604,16 @@ public sealed partial class FAT } // Not a correct entry - if(entry.filename[0] < DIRENT_MIN && entry.filename[0] != DIRENT_E5) - continue; + if(entry.filename[0] < DIRENT_MIN && entry.filename[0] != DIRENT_E5) continue; // Self - if(_encoding.GetString(entry.filename).TrimEnd() == ".") - continue; + if(_encoding.GetString(entry.filename).TrimEnd() == ".") continue; // Parent - if(_encoding.GetString(entry.filename).TrimEnd() == "..") - continue; + if(_encoding.GetString(entry.filename).TrimEnd() == "..") continue; // Deleted - if(entry.filename[0] == DIRENT_DELETED) - continue; + if(entry.filename[0] == DIRENT_DELETED) continue; string filename; @@ -690,8 +666,7 @@ public sealed partial class FAT } } - if(entry.filename[0] == DIRENT_E5) - entry.filename[0] = DIRENT_DELETED; + if(entry.filename[0] == DIRENT_E5) entry.filename[0] = DIRENT_DELETED; string name = _encoding.GetString(entry.filename).TrimEnd(); string extension = _encoding.GetString(entry.extension).TrimEnd(); @@ -701,8 +676,7 @@ public sealed partial class FAT if(entry.caseinfo.HasFlag(CaseInfo.LowerCaseExtension)) extension = extension.ToLower(CultureInfo.CurrentCulture); - if(entry.caseinfo.HasFlag(CaseInfo.LowerCaseBasename)) - name = name.ToLower(CultureInfo.CurrentCulture); + if(entry.caseinfo.HasFlag(CaseInfo.LowerCaseBasename)) name = name.ToLower(CultureInfo.CurrentCulture); } if(extension != "") @@ -714,8 +688,7 @@ public sealed partial class FAT { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_empty_filename_in_root_directory); - if(!_debug || entry is { size: > 0, start_cluster: 0 }) - continue; // Skip invalid name + if(!_debug || entry is { size: > 0, start_cluster: 0 }) continue; // Skip invalid name // If debug, add it name = ":{EMPTYNAME}:"; @@ -725,13 +698,11 @@ public sealed partial class FAT { extension = $"{uniq:D03}"; - if(!_rootDirectoryCache.ContainsKey($"{name}.{extension}")) - break; + if(!_rootDirectoryCache.ContainsKey($"{name}.{extension}")) break; } // If we couldn't find it, just skip over - if(_rootDirectoryCache.ContainsKey($"{name}.{extension}")) - continue; + if(_rootDirectoryCache.ContainsKey($"{name}.{extension}")) continue; } // Atari ST allows slash AND colon so cannot simply substitute one for the other like in Mac filesystems @@ -742,7 +713,8 @@ public sealed partial class FAT if(_namespace == Namespace.Human) { HumanDirectoryEntry humanEntry = - Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, + Marshal.ByteArrayToStructureLittleEndian(rootDirectory, + i, Marshal.SizeOf()); completeEntry.HumanDirent = humanEntry; @@ -765,8 +737,7 @@ public sealed partial class FAT lastLfnName = null; lastLfnChecksum = 0; - if(_debug) - _rootDirectoryCache[completeEntry.ToString()] = completeEntry; + if(_debug) _rootDirectoryCache[completeEntry.ToString()] = completeEntry; continue; } @@ -806,8 +777,7 @@ public sealed partial class FAT errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; var pos = 0; @@ -815,16 +785,14 @@ public sealed partial class FAT { firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); - if(pos >= firstFatEntries.Length) - break; + if(pos >= firstFatEntries.Length) break; firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _fatEntries = new ushort[_statfs.Blocks + 2]; @@ -834,8 +802,7 @@ public sealed partial class FAT { secondFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); - if(pos >= secondFatEntries.Length) - break; + if(pos >= secondFatEntries.Length) break; secondFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } @@ -859,16 +826,14 @@ public sealed partial class FAT errno = imagePlugin.ReadSectors(_fatFirstSector, _sectorsPerFat, out byte[] fatBytes); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Casting_FAT); firstFatEntries = MemoryMarshal.Cast(fatBytes).ToArray(); errno = imagePlugin.ReadSectors(_fatFirstSector + _sectorsPerFat, _sectorsPerFat, out fatBytes); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Casting_FAT); secondFatEntries = MemoryMarshal.Cast(fatBytes).ToArray(); @@ -905,8 +870,7 @@ public sealed partial class FAT else _eaCache = new Dictionary>(); } - else if(_fat32) - _eaCache = new Dictionary>(); + else if(_fat32) _eaCache = new Dictionary>(); // Check OS/2 .LONGNAME if(_eaCache != null && _namespace is Namespace.Os2 or Namespace.Ecs && !_fat32) @@ -917,19 +881,15 @@ public sealed partial class FAT { Dictionary eas = GetEas(fileWithEa.Value.Dirent.ea_handle); - if(eas is null) - continue; + if(eas is null) continue; - if(!eas.TryGetValue("com.microsoft.os2.longname", out byte[] longnameEa)) - continue; + if(!eas.TryGetValue("com.microsoft.os2.longname", out byte[] longnameEa)) continue; - if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) - continue; + if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue; var longnameSize = BitConverter.ToUInt16(longnameEa, 2); - if(longnameSize + 4 > longnameEa.Length) - continue; + if(longnameSize + 4 > longnameEa.Length) continue; var longnameBytes = new byte[longnameSize]; @@ -937,8 +897,7 @@ public sealed partial class FAT string longname = StringHandlers.CToString(longnameBytes, _encoding); - if(string.IsNullOrWhiteSpace(longname)) - continue; + if(string.IsNullOrWhiteSpace(longname)) continue; // Forward slash is allowed in .LONGNAME, so change it to visually similar division slash longname = longname.Replace('/', '\u2215'); @@ -952,8 +911,8 @@ public sealed partial class FAT // Check FAT32.IFS EAs if(_fat32 || _debug) { - var fat32EaSidecars = _rootDirectoryCache.Where(t => t.Key.EndsWith(FAT32_EA_TAIL, true, _cultureInfo)). - ToList(); + var fat32EaSidecars = _rootDirectoryCache.Where(t => t.Key.EndsWith(FAT32_EA_TAIL, true, _cultureInfo)) + .ToList(); foreach(KeyValuePair sidecar in fat32EaSidecars) { @@ -974,15 +933,13 @@ public sealed partial class FAT fileWithEa.Fat32Ea = sidecar.Value.Dirent; - if(!_debug) - _rootDirectoryCache.Remove(sidecar.Key); + if(!_debug) _rootDirectoryCache.Remove(sidecar.Key); } } _mounted = true; - if(string.IsNullOrWhiteSpace(Metadata.VolumeName)) - Metadata.VolumeName = null; + if(string.IsNullOrWhiteSpace(Metadata.VolumeName)) Metadata.VolumeName = null; return ErrorNumber.NoError; } @@ -990,8 +947,7 @@ public sealed partial class FAT /// public ErrorNumber Unmount() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _mounted = false; _fatEntries = null; @@ -1004,8 +960,7 @@ public sealed partial class FAT { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index 00b95a1d4..57a94562d 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -47,15 +47,12 @@ public sealed partial class FAT { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; // No other xattr recognized yet - if(_cachedEaData is null && !_fat32) - return ErrorNumber.NotSupported; + if(_cachedEaData is null && !_fat32) return ErrorNumber.NotSupported; - if(path[0] == '/') - path = path[1..]; + if(path[0] == '/') path = path[1..]; if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas)) { @@ -66,28 +63,24 @@ public sealed partial class FAT ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry entry); - if(err != ErrorNumber.NoError || entry is null) - return err; + if(err != ErrorNumber.NoError || entry is null) return err; xattrs = new List(); if(!_fat32) { - if(entry.Dirent.ea_handle == 0) - return ErrorNumber.NoError; + if(entry.Dirent.ea_handle == 0) return ErrorNumber.NoError; eas = GetEas(entry.Dirent.ea_handle); } else { - if(entry.Fat32Ea.start_cluster == 0) - return ErrorNumber.NoError; + if(entry.Fat32Ea.start_cluster == 0) return ErrorNumber.NoError; eas = GetEas(entry.Fat32Ea); } - if(eas is null) - return ErrorNumber.NoError; + if(eas is null) return ErrorNumber.NoError; _eaCache.Add(path.ToLower(_cultureInfo), eas); xattrs = eas.Keys.ToList(); @@ -98,25 +91,20 @@ public sealed partial class FAT /// public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = ListXAttr(path, out List xattrs); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if(path[0] == '/') - path = path[1..]; + if(path[0] == '/') path = path[1..]; - if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) - return ErrorNumber.NoSuchExtendedAttribute; + if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) return ErrorNumber.NoSuchExtendedAttribute; if(!_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas)) return ErrorNumber.InvalidArgument; - if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) - return ErrorNumber.InvalidArgument; + if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) return ErrorNumber.InvalidArgument; buf = new byte[data.Length]; data.CopyTo(buf, 0); @@ -134,10 +122,10 @@ public sealed partial class FAT foreach(uint cluster in rootDirectoryClusters) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buffer); + _sectorsPerCluster, + out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; eaMs.Write(buffer, 0, buffer.Length); } @@ -163,15 +151,14 @@ public sealed partial class FAT var eaCluster = (uint)(a + b); - if(b == EA_UNUSED) - return null; + if(b == EA_UNUSED) return null; EaHeader header = - Marshal.ByteArrayToStructureLittleEndian(_cachedEaData, (int)(eaCluster * _bytesPerCluster), + Marshal.ByteArrayToStructureLittleEndian(_cachedEaData, + (int)(eaCluster * _bytesPerCluster), Marshal.SizeOf()); - if(header.magic != 0x4145) - return null; + if(header.magic != 0x4145) return null; var eaLen = BitConverter.ToUInt32(_cachedEaData, (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf()); @@ -185,13 +172,11 @@ public sealed partial class FAT Dictionary GetEas(byte[] eaData) { - if(eaData is null || eaData.Length < 4) - return null; + if(eaData is null || eaData.Length < 4) return null; Dictionary eas = new(); - if(_debug) - eas.Add("com.microsoft.os2.fea", eaData); + if(_debug) eas.Add("com.microsoft.os2.fea", eaData); var pos = 4; @@ -228,18 +213,17 @@ public sealed partial class FAT void CacheEaData() { - if(_eaDirEntry.start_cluster == 0) - return; + if(_eaDirEntry.start_cluster == 0) return; var eaDataMs = new MemoryStream(); foreach(uint cluster in GetClusters(_eaDirEntry.start_cluster)) { ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buffer); + _sectorsPerCluster, + out byte[] buffer); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; eaDataMs.Write(buffer, 0, buffer.Length); } diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index 906ec0d61..a2fa6da87 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -44,8 +44,7 @@ public sealed partial class XboxFatPlugin { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { @@ -74,18 +73,17 @@ public sealed partial class XboxFatPlugin } string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = _rootDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.attributes.HasFlag(Attributes.Directory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.attributes.HasFlag(Attributes.Directory)) return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -95,22 +93,18 @@ public sealed partial class XboxFatPlugin { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.attributes.HasFlag(Attributes.Directory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.attributes.HasFlag(Attributes.Directory)) return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.firstCluster; - if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) - continue; + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; uint[] clusters = GetClusters(currentCluster); - if(clusters is null) - return ErrorNumber.InvalidArgument; + if(clusters is null) return ErrorNumber.InvalidArgument; var directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; @@ -118,10 +112,10 @@ public sealed partial class XboxFatPlugin { ErrorNumber errno = _imagePlugin.ReadSectors(_firstClusterSector + (clusters[i] - 1) * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buffer); + _sectorsPerCluster, + out byte[] buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(buffer, 0, directoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } @@ -134,17 +128,17 @@ public sealed partial class XboxFatPlugin { DirectoryEntry dirent = _littleEndian ? Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, - pos, Marshal.SizeOf()) + pos, + Marshal.SizeOf()) : Marshal.ByteArrayToStructureBigEndian(directoryBuffer, - pos, Marshal.SizeOf()); + pos, + Marshal.SizeOf()); pos += Marshal.SizeOf(); - if(dirent.filenameSize is UNUSED_DIRENTRY or FINISHED_DIRENTRY) - break; + if(dirent.filenameSize is UNUSED_DIRENTRY or FINISHED_DIRENTRY) break; - if(dirent.filenameSize is DELETED_DIRENTRY or > MAX_FILENAME) - continue; + if(dirent.filenameSize is DELETED_DIRENTRY or > MAX_FILENAME) continue; string filename = _encoding.GetString(dirent.filename, 0, dirent.filenameSize); @@ -154,8 +148,7 @@ public sealed partial class XboxFatPlugin _directoryCache.Add(currentPath, currentDirectory); } - if(currentDirectory is null) - return ErrorNumber.NoSuchFile; + if(currentDirectory is null) return ErrorNumber.NoSuchFile; node = new FatxDirNode { @@ -172,19 +165,16 @@ public sealed partial class XboxFatPlugin { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not FatxDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatxDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Entries.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Entries.Length) return ErrorNumber.NoError; - filename = _encoding.GetString(mynode.Entries[mynode.Position].filename, 0, + filename = _encoding.GetString(mynode.Entries[mynode.Position].filename, + 0, mynode.Entries[mynode.Position].filenameSize); mynode.Position++; @@ -195,8 +185,7 @@ public sealed partial class XboxFatPlugin /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not FatxDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatxDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Entries = null; diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 3913489d8..447d967dd 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -47,13 +47,11 @@ public sealed partial class XboxFatPlugin { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; @@ -65,16 +63,13 @@ public sealed partial class XboxFatPlugin { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return ErrorNumber.IsDirectory; + if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) return ErrorNumber.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); @@ -92,11 +87,9 @@ public sealed partial class XboxFatPlugin /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not FatxFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatxFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Clusters = null; @@ -108,41 +101,35 @@ public sealed partial class XboxFatPlugin { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not FatxFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not FatxFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; long firstCluster = mynode.Offset / _bytesPerCluster; long offsetInCluster = mynode.Offset % _bytesPerCluster; long sizeInClusters = (read + offsetInCluster) / _bytesPerCluster; - if((read + offsetInCluster) % _bytesPerCluster > 0) - sizeInClusters++; + if((read + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++; var ms = new MemoryStream(); for(var i = 0; i < sizeInClusters; i++) { - if(i + firstCluster >= mynode.Clusters.Length) - return ErrorNumber.InvalidArgument; + if(i + firstCluster >= mynode.Clusters.Length) return ErrorNumber.InvalidArgument; ErrorNumber errno = - _imagePlugin. - ReadSectors(_firstClusterSector + (mynode.Clusters[i + firstCluster] - 1) * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buf); + _imagePlugin.ReadSectors(_firstClusterSector + + (mynode.Clusters[i + firstCluster] - 1) * _sectorsPerCluster, + _sectorsPerCluster, + out byte[] buf); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(buf, 0, buf.Length); } @@ -159,8 +146,7 @@ public sealed partial class XboxFatPlugin { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(_debug && (string.IsNullOrEmpty(path) || path is "$" or "/")) { @@ -179,8 +165,7 @@ public sealed partial class XboxFatPlugin ErrorNumber err = GetFileEntry(path, out DirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; stat = new FileEntryInfo { @@ -190,19 +175,20 @@ public sealed partial class XboxFatPlugin Length = entry.length, Inode = entry.firstCluster, Links = 1, - CreationTime = _littleEndian - ? DateHandlers.DosToDateTime(entry.creationDate, entry.creationTime).AddYears(20) - : DateHandlers.DosToDateTime(entry.creationTime, entry.creationDate), - AccessTime = _littleEndian - ? DateHandlers.DosToDateTime(entry.lastAccessDate, entry.lastAccessTime).AddYears(20) - : DateHandlers.DosToDateTime(entry.lastAccessTime, entry.lastAccessDate), + CreationTime = + _littleEndian + ? DateHandlers.DosToDateTime(entry.creationDate, entry.creationTime).AddYears(20) + : DateHandlers.DosToDateTime(entry.creationTime, entry.creationDate), + AccessTime = + _littleEndian + ? DateHandlers.DosToDateTime(entry.lastAccessDate, entry.lastAccessTime).AddYears(20) + : DateHandlers.DosToDateTime(entry.lastAccessTime, entry.lastAccessDate), LastWriteTime = _littleEndian ? DateHandlers.DosToDateTime(entry.lastWrittenDate, entry.lastWrittenTime).AddYears(20) : DateHandlers.DosToDateTime(entry.lastWrittenTime, entry.lastWrittenDate) }; - if(entry.length % _bytesPerCluster > 0) - stat.Blocks++; + if(entry.length % _bytesPerCluster > 0) stat.Blocks++; if(entry.attributes.HasFlag(Attributes.Directory)) { @@ -211,17 +197,13 @@ public sealed partial class XboxFatPlugin stat.Length = stat.Blocks * stat.BlockSize; } - if(entry.attributes.HasFlag(Attributes.ReadOnly)) - stat.Attributes |= FileAttributes.ReadOnly; + if(entry.attributes.HasFlag(Attributes.ReadOnly)) stat.Attributes |= FileAttributes.ReadOnly; - if(entry.attributes.HasFlag(Attributes.Hidden)) - stat.Attributes |= FileAttributes.Hidden; + if(entry.attributes.HasFlag(Attributes.Hidden)) stat.Attributes |= FileAttributes.Hidden; - if(entry.attributes.HasFlag(Attributes.System)) - stat.Attributes |= FileAttributes.System; + if(entry.attributes.HasFlag(Attributes.System)) stat.Attributes |= FileAttributes.System; - if(entry.attributes.HasFlag(Attributes.Archive)) - stat.Attributes |= FileAttributes.Archive; + if(entry.attributes.HasFlag(Attributes.Archive)) stat.Attributes |= FileAttributes.Archive; return ErrorNumber.NoError; } @@ -230,16 +212,13 @@ public sealed partial class XboxFatPlugin uint[] GetClusters(uint startCluster) { - if(startCluster == 0) - return null; + if(startCluster == 0) return null; if(_fat16 is null) { - if(startCluster >= _fat32.Length) - return null; + if(startCluster >= _fat32.Length) return null; } - else if(startCluster >= _fat16.Length) - return null; + else if(startCluster >= _fat16.Length) return null; List clusters = new(); @@ -272,19 +251,18 @@ public sealed partial class XboxFatPlugin string cutPath = path.StartsWith('/') ? path[1..].ToLower(_cultureInfo) : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pieces.Length == 0) - return ErrorNumber.InvalidArgument; + if(pieces.Length == 0) return ErrorNumber.InvalidArgument; var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); ErrorNumber err = OpenDir(parentPath, out IDirNode node); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; CloseDir(node); @@ -292,14 +270,12 @@ public sealed partial class XboxFatPlugin if(pieces.Length == 1) parent = _rootDirectory; - else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return ErrorNumber.InvalidArgument; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); - if(string.IsNullOrEmpty(dirent.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile; entry = dirent.Value; diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index d9b534e42..2b1f635d7 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -42,13 +42,11 @@ public sealed partial class XboxFatPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector); @@ -62,15 +60,13 @@ public sealed partial class XboxFatPlugin information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; var bigEndian = true; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian(sector); @@ -80,8 +76,7 @@ public sealed partial class XboxFatPlugin bigEndian = false; } - if(fatxSb.magic != FATX_MAGIC) - return; + if(fatxSb.magic != FATX_MAGIC) return; int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && !bigEndian ? 8 : 1; @@ -89,18 +84,21 @@ public sealed partial class XboxFatPlugin sb.AppendLine(Localization.FATX_filesystem); - sb.AppendFormat(Localization._0_logical_sectors_1_bytes_per_physical_sector, logicalSectorsPerPhysicalSectors, - logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize). - AppendLine(); + sb.AppendFormat(Localization._0_logical_sectors_1_bytes_per_physical_sector, + logicalSectorsPerPhysicalSectors, + logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize) + .AppendLine(); - sb.AppendFormat(Localization._0_sectors_1_bytes_per_cluster, fatxSb.sectorsPerCluster, - fatxSb.sectorsPerCluster * logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_1_bytes_per_cluster, + fatxSb.sectorsPerCluster, + fatxSb.sectorsPerCluster * logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize) + .AppendLine(); sb.AppendFormat(Localization.Root_directory_starts_at_cluster_0, fatxSb.rootDirectoryCluster).AppendLine(); string volumeLabel = StringHandlers.CToString(fatxSb.volumeLabel, - bigEndian ? Encoding.BigEndianUnicode : Encoding.Unicode, true); + bigEndian ? Encoding.BigEndianUnicode : Encoding.Unicode, + true); sb.AppendFormat(Localization.Volume_label_0, volumeLabel).AppendLine(); sb.AppendFormat(Localization.Volume_serial_0_X8, fatxSb.id).AppendLine(); diff --git a/Aaru.Filesystems/FATX/Structs.cs b/Aaru.Filesystems/FATX/Structs.cs index e667add36..64afbac09 100644 --- a/Aaru.Filesystems/FATX/Structs.cs +++ b/Aaru.Filesystems/FATX/Structs.cs @@ -61,12 +61,12 @@ public sealed partial class XboxFatPlugin internal DirectoryEntry[] Entries; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -77,7 +77,7 @@ public sealed partial class XboxFatPlugin { internal uint[] Clusters; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -88,7 +88,7 @@ public sealed partial class XboxFatPlugin /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index dd2e18d77..138a2085e 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -55,18 +55,15 @@ public sealed partial class XboxFatPlugin options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); - if(imagePlugin.Info.SectorSize < 512) - return ErrorNumber.InvalidArgument; + if(imagePlugin.Info.SectorSize < 512) return ErrorNumber.InvalidArgument; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reading_superblock); ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _superblock = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -76,8 +73,7 @@ public sealed partial class XboxFatPlugin _littleEndian = false; } - if(_superblock.magic != FATX_MAGIC) - return ErrorNumber.InvalidArgument; + if(_superblock.magic != FATX_MAGIC) return ErrorNumber.InvalidArgument; AaruConsole.DebugWriteLine(MODULE_NAME, _littleEndian @@ -86,7 +82,8 @@ public sealed partial class XboxFatPlugin int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && _littleEndian ? 8 : 1; - AaruConsole.DebugWriteLine(MODULE_NAME, "logicalSectorsPerPhysicalSectors = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "logicalSectorsPerPhysicalSectors = {0}", logicalSectorsPerPhysicalSectors); string volumeLabel = StringHandlers.CToString(_superblock.volumeLabel, @@ -141,13 +138,11 @@ public sealed partial class XboxFatPlugin fatSize = (uint)((_statfs.Blocks + 1) * sizeof(uint) / imagePlugin.Info.SectorSize); - if((uint)((_statfs.Blocks + 1) * sizeof(uint) % imagePlugin.Info.SectorSize) > 0) - fatSize++; + if((uint)((_statfs.Blocks + 1) * sizeof(uint) % imagePlugin.Info.SectorSize) > 0) fatSize++; long fatClusters = fatSize * imagePlugin.Info.SectorSize / 4096; - if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) - fatClusters++; + if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) fatClusters++; fatSize = (uint)(fatClusters * 4096 / imagePlugin.Info.SectorSize); @@ -155,22 +150,19 @@ public sealed partial class XboxFatPlugin errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Casting_FAT); _fat32 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) { - for(var i = 0; i < _fat32.Length; i++) - _fat32[i] = Swapping.Swap(_fat32[i]); + for(var i = 0; i < _fat32.Length; i++) _fat32[i] = Swapping.Swap(_fat32[i]); } AaruConsole.DebugWriteLine(MODULE_NAME, "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); - if(_fat32[0] != FATX32_ID) - return ErrorNumber.InvalidArgument; + if(_fat32[0] != FATX32_ID) return ErrorNumber.InvalidArgument; } else { @@ -178,13 +170,11 @@ public sealed partial class XboxFatPlugin fatSize = (uint)((_statfs.Blocks + 1) * sizeof(ushort) / imagePlugin.Info.SectorSize); - if((uint)((_statfs.Blocks + 1) * sizeof(ushort) % imagePlugin.Info.SectorSize) > 0) - fatSize++; + if((uint)((_statfs.Blocks + 1) * sizeof(ushort) % imagePlugin.Info.SectorSize) > 0) fatSize++; long fatClusters = fatSize * imagePlugin.Info.SectorSize / 4096; - if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) - fatClusters++; + if(fatSize * imagePlugin.Info.SectorSize % 4096 > 0) fatClusters++; fatSize = (uint)(fatClusters * 4096 / imagePlugin.Info.SectorSize); @@ -192,22 +182,19 @@ public sealed partial class XboxFatPlugin errno = imagePlugin.ReadSectors(_fatStartSector, fatSize, out buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Casting_FAT); _fat16 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) { - for(var i = 0; i < _fat16.Length; i++) - _fat16[i] = Swapping.Swap(_fat16[i]); + for(var i = 0; i < _fat16.Length; i++) _fat16[i] = Swapping.Swap(_fat16[i]); } AaruConsole.DebugWriteLine(MODULE_NAME, "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); - if(_fat16[0] != FATX16_ID) - return ErrorNumber.InvalidArgument; + if(_fat16[0] != FATX16_ID) return ErrorNumber.InvalidArgument; } _sectorsPerCluster = (uint)(_superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors); @@ -221,8 +208,7 @@ public sealed partial class XboxFatPlugin uint[] rootDirectoryClusters = GetClusters(_superblock.rootDirectoryCluster); - if(rootDirectoryClusters is null) - return ErrorNumber.InvalidArgument; + if(rootDirectoryClusters is null) return ErrorNumber.InvalidArgument; var rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length]; @@ -231,10 +217,10 @@ public sealed partial class XboxFatPlugin for(var i = 0; i < rootDirectoryClusters.Length; i++) { errno = imagePlugin.ReadSectors(_firstClusterSector + (rootDirectoryClusters[i] - 1) * _sectorsPerCluster, - _sectorsPerCluster, out buffer); + _sectorsPerCluster, + out buffer); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(buffer, 0, rootDirectoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } @@ -247,17 +233,17 @@ public sealed partial class XboxFatPlugin { DirectoryEntry entry = _littleEndian ? Marshal.ByteArrayToStructureLittleEndian(rootDirectoryBuffer, - pos, Marshal.SizeOf()) - : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, pos, + pos, + Marshal.SizeOf()) + : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, + pos, Marshal.SizeOf()); pos += Marshal.SizeOf(); - if(entry.filenameSize is UNUSED_DIRENTRY or FINISHED_DIRENTRY) - break; + if(entry.filenameSize is UNUSED_DIRENTRY or FINISHED_DIRENTRY) break; - if(entry.filenameSize is DELETED_DIRENTRY or > MAX_FILENAME) - continue; + if(entry.filenameSize is DELETED_DIRENTRY or > MAX_FILENAME) continue; string filename = _encoding.GetString(entry.filename, 0, entry.filenameSize); @@ -274,8 +260,7 @@ public sealed partial class XboxFatPlugin /// public ErrorNumber Unmount() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _fat16 = null; _fat32 = null; @@ -290,8 +275,7 @@ public sealed partial class XboxFatPlugin { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); diff --git a/Aaru.Filesystems/FFS/Consts.cs b/Aaru.Filesystems/FFS/Consts.cs index a13e004b3..7a80426b1 100644 --- a/Aaru.Filesystems/FFS/Consts.cs +++ b/Aaru.Filesystems/FFS/Consts.cs @@ -27,8 +27,6 @@ // ****************************************************************************/ using System.Diagnostics.CodeAnalysis; -using time_t = int; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/FFS/FFS.cs b/Aaru.Filesystems/FFS/FFS.cs index be4444e94..0066bc51c 100644 --- a/Aaru.Filesystems/FFS/FFS.cs +++ b/Aaru.Filesystems/FFS/FFS.cs @@ -29,8 +29,6 @@ using System; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Interfaces; -using time_t = int; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs index 81a1e4622..4ff481207 100644 --- a/Aaru.Filesystems/FFS/Info.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -36,8 +36,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Partition = Aaru.CommonTypes.Partition; -using time_t = int; -using ufs_daddr_t = int; namespace Aaru.Filesystems; @@ -52,8 +50,7 @@ public sealed partial class FFSPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; uint sbSizeInSectors; @@ -76,13 +73,18 @@ public sealed partial class FFSPlugin ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + loc, sbSizeInSectors, out byte[] ufsSbSectors); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; var magic = BitConverter.ToUInt32(ufsSbSectors, 0x055C); - if(magic is UFS_MAGIC or UFS_CIGAM or UFS_MAGIC_BW or UFS_CIGAM_BW or UFS2_MAGIC or UFS2_CIGAM - or UFS_BAD_MAGIC or UFS_BAD_CIGAM) + if(magic is UFS_MAGIC + or UFS_CIGAM + or UFS_MAGIC_BW + or UFS_CIGAM_BW + or UFS2_MAGIC + or UFS2_CIGAM + or UFS_BAD_MAGIC + or UFS_BAD_CIGAM) return true; } @@ -132,13 +134,18 @@ public sealed partial class FFSPlugin { errno = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors, out ufs_sb_sectors); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; magic = BitConverter.ToUInt32(ufs_sb_sectors, 0x055C); - if(magic is UFS_MAGIC or UFS_CIGAM or UFS_MAGIC_BW or UFS_CIGAM_BW or UFS2_MAGIC or UFS2_CIGAM - or UFS_BAD_MAGIC or UFS_BAD_CIGAM) + if(magic is UFS_MAGIC + or UFS_CIGAM + or UFS_MAGIC_BW + or UFS_CIGAM_BW + or UFS2_MAGIC + or UFS2_CIGAM + or UFS_BAD_MAGIC + or UFS_BAD_CIGAM) { sb_offset = partition.Start + loc; @@ -206,8 +213,7 @@ public sealed partial class FFSPlugin // Fun with seeking follows on superblock reading! errno = imagePlugin.ReadSectors(sb_offset, sb_size_in_sectors, out ufs_sb_sectors); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian(ufs_sb_sectors); @@ -323,30 +329,24 @@ public sealed partial class FFSPlugin if(!fs_type_ufs2) { - sbInformation.AppendLine(Localization. - There_are_a_lot_of_variants_of_UFS_using_overlapped_values_on_same_fields); + sbInformation.AppendLine(Localization + .There_are_a_lot_of_variants_of_UFS_using_overlapped_values_on_same_fields); - sbInformation.AppendLine(Localization. - I_will_try_to_guess_which_one_it_is_but_unless_its_UFS2_I_may_be_surely_wrong); + sbInformation.AppendLine(Localization + .I_will_try_to_guess_which_one_it_is_but_unless_its_UFS2_I_may_be_surely_wrong); } - if(fs_type_42bsd) - sbInformation.AppendLine(Localization.Guessed_as_42BSD_FFS); + if(fs_type_42bsd) sbInformation.AppendLine(Localization.Guessed_as_42BSD_FFS); - if(fs_type_43bsd) - sbInformation.AppendLine(Localization.Guessed_as_43BSD_FFS); + if(fs_type_43bsd) sbInformation.AppendLine(Localization.Guessed_as_43BSD_FFS); - if(fs_type_44bsd) - sbInformation.AppendLine(Localization.Guessed_as_44BSD_FFS); + if(fs_type_44bsd) sbInformation.AppendLine(Localization.Guessed_as_44BSD_FFS); - if(fs_type_sun) - sbInformation.AppendLine(Localization.Guessed_as_SunOS_FFS); + if(fs_type_sun) sbInformation.AppendLine(Localization.Guessed_as_SunOS_FFS); - if(fs_type_sun86) - sbInformation.AppendLine(Localization.Guessed_as_SunOS_x86_FFS); + if(fs_type_sun86) sbInformation.AppendLine(Localization.Guessed_as_SunOS_x86_FFS); - if(fs_type_ufs) - sbInformation.AppendLine(Localization.Guessed_as_UFS); + if(fs_type_ufs) sbInformation.AppendLine(Localization.Guessed_as_UFS); if(fs_type_42bsd) sbInformation.AppendFormat(Localization.Linked_list_of_filesystems_0, sb.fs_link).AppendLine(); @@ -357,21 +357,23 @@ public sealed partial class FFSPlugin sbInformation.AppendFormat(Localization.First_data_block_LBA_0, sb.fs_dblkno).AppendLine(); sbInformation.AppendFormat(Localization.Cylinder_group_offset_in_cylinder_0, sb.fs_old_cgoffset).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixToDateTime(sb.fs_old_time)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixToDateTime(sb.fs_old_time)) + .AppendLine(); metadata.ModificationDate = DateHandlers.UnixToDateTime(sb.fs_old_time); - sbInformation.AppendFormat(Localization._0_blocks_in_volume_1_bytes, sb.fs_old_size, - (long)sb.fs_old_size * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_blocks_in_volume_1_bytes, + sb.fs_old_size, + (long)sb.fs_old_size * sb.fs_fsize) + .AppendLine(); metadata.Clusters = (ulong)sb.fs_old_size; metadata.ClusterSize = (uint)sb.fs_fsize; - sbInformation.AppendFormat(Localization._0_data_blocks_in_volume_1_bytes, sb.fs_old_dsize, - (long)sb.fs_old_dsize * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_data_blocks_in_volume_1_bytes, + sb.fs_old_dsize, + (long)sb.fs_old_dsize * sb.fs_fsize) + .AppendLine(); sbInformation.AppendFormat(Localization._0_cylinder_groups_in_volume, sb.fs_ncg).AppendLine(); sbInformation.AppendFormat(Localization._0_bytes_in_a_basic_block, sb.fs_bsize).AppendLine(); @@ -380,9 +382,9 @@ public sealed partial class FFSPlugin sbInformation.AppendFormat(Localization._0_of_blocks_must_be_free, sb.fs_minfree).AppendLine(); sbInformation.AppendFormat(Localization._0_ms_for_optimal_next_block, sb.fs_old_rotdelay).AppendLine(); - sbInformation. - AppendFormat(Localization.Disk_rotates_0_times_per_second_1_rpm, sb.fs_old_rps, sb.fs_old_rps * 60). - AppendLine(); + sbInformation + .AppendFormat(Localization.Disk_rotates_0_times_per_second_1_rpm, sb.fs_old_rps, sb.fs_old_rps * 60) + .AppendLine(); /* sbInformation.AppendFormat("fs_bmask: 0x{0:X8}", sb.fs_bmask).AppendLine(); sbInformation.AppendFormat("fs_fmask: 0x{0:X8}", sb.fs_fmask).AppendLine(); @@ -415,8 +417,8 @@ public sealed partial class FFSPlugin sbInformation.AppendFormat(Localization._0_sectors_track, sb.fs_old_npsect).AppendLine(); else if(fs_type_sun86) { - sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_old_npsect)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_old_npsect)) + .AppendLine(); } sbInformation.AppendFormat(Localization.Hardware_sector_interleave_0, sb.fs_old_interleave).AppendLine(); @@ -447,9 +449,10 @@ public sealed partial class FFSPlugin sbInformation.AppendFormat(Localization._0_blocks_per_group, sb.fs_fpg / sb.fs_frag).AppendLine(); sbInformation.AppendFormat(Localization._0_directories, sb.fs_old_cstotal.cs_ndir).AppendLine(); - sbInformation.AppendFormat(Localization._0_free_blocks_1_bytes, sb.fs_old_cstotal.cs_nbfree, - (long)sb.fs_old_cstotal.cs_nbfree * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_free_blocks_1_bytes, + sb.fs_old_cstotal.cs_nbfree, + (long)sb.fs_old_cstotal.cs_nbfree * sb.fs_fsize) + .AppendLine(); metadata.FreeClusters = (ulong)sb.fs_old_cstotal.cs_nbfree; sbInformation.AppendFormat(Localization._0_free_inodes, sb.fs_old_cstotal.cs_nifree).AppendLine(); @@ -461,26 +464,24 @@ public sealed partial class FFSPlugin metadata.Dirty = true; } - if(sb.fs_clean == 1) - sbInformation.AppendLine(Localization.Volume_is_clean); + if(sb.fs_clean == 1) sbInformation.AppendLine(Localization.Volume_is_clean); - if(sb.fs_ronly == 1) - sbInformation.AppendLine(Localization.Volume_is_read_only); + if(sb.fs_ronly == 1) sbInformation.AppendLine(Localization.Volume_is_read_only); sbInformation.AppendFormat(Localization.Volume_flags_0_X2, sb.fs_flags).AppendLine(); if(fs_type_ufs) { - sbInformation.AppendFormat(Localization.Volume_last_mounted_at_0, StringHandlers.CToString(sb.fs_fsmnt)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_last_mounted_at_0, StringHandlers.CToString(sb.fs_fsmnt)) + .AppendLine(); } else if(fs_type_ufs2) { - sbInformation.AppendFormat(Localization.Volume_last_mounted_at_0, StringHandlers.CToString(sb.fs_fsmnt)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_last_mounted_at_0, StringHandlers.CToString(sb.fs_fsmnt)) + .AppendLine(); - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(sb.fs_volname)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(sb.fs_volname)) + .AppendLine(); metadata.VolumeName = StringHandlers.CToString(sb.fs_volname); sbInformation.AppendFormat(Localization.Volume_ID_0_X16, sb.fs_swuid).AppendLine(); @@ -488,33 +489,34 @@ public sealed partial class FFSPlugin //xmlFSType.VolumeSerial = string.Format("{0:X16}", sb.fs_swuid); sbInformation.AppendFormat(Localization.Last_searched_cylinder_group_0, sb.fs_cgrotor).AppendLine(); - sbInformation.AppendFormat(Localization._0_contiguously_allocated_directories, sb.fs_contigdirs). - AppendLine(); + sbInformation.AppendFormat(Localization._0_contiguously_allocated_directories, sb.fs_contigdirs) + .AppendLine(); sbInformation.AppendFormat(Localization.Standard_superblock_LBA_0, sb.fs_sblkno).AppendLine(); sbInformation.AppendFormat(Localization._0_directories, sb.fs_cstotal.cs_ndir).AppendLine(); - sbInformation.AppendFormat(Localization._0_free_blocks_1_bytes, sb.fs_cstotal.cs_nbfree, - sb.fs_cstotal.cs_nbfree * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_free_blocks_1_bytes, + sb.fs_cstotal.cs_nbfree, + sb.fs_cstotal.cs_nbfree * sb.fs_fsize) + .AppendLine(); metadata.FreeClusters = (ulong)sb.fs_cstotal.cs_nbfree; sbInformation.AppendFormat(Localization._0_free_inodes, sb.fs_cstotal.cs_nifree).AppendLine(); sbInformation.AppendFormat(Localization._0_free_frags, sb.fs_cstotal.cs_nffree).AppendLine(); sbInformation.AppendFormat(Localization._0_free_clusters, sb.fs_cstotal.cs_numclusters).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixToDateTime(sb.fs_time)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixToDateTime(sb.fs_time)) + .AppendLine(); metadata.ModificationDate = DateHandlers.UnixToDateTime(sb.fs_time); - sbInformation.AppendFormat(Localization._0_blocks_1_bytes, sb.fs_size, sb.fs_size * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_blocks_1_bytes, sb.fs_size, sb.fs_size * sb.fs_fsize) + .AppendLine(); metadata.Clusters = (ulong)sb.fs_size; - sbInformation.AppendFormat(Localization._0_data_blocks_1_bytes, sb.fs_dsize, sb.fs_dsize * sb.fs_fsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_data_blocks_1_bytes, sb.fs_dsize, sb.fs_dsize * sb.fs_fsize) + .AppendLine(); sbInformation.AppendFormat(Localization.Cylinder_group_summary_area_LBA_0, sb.fs_csaddr).AppendLine(); sbInformation.AppendFormat(Localization._0_blocks_pending_of_being_freed, sb.fs_pendingblocks).AppendLine(); @@ -523,23 +525,23 @@ public sealed partial class FFSPlugin if(fs_type_sun) { - sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_old_npsect)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_old_npsect)) + .AppendLine(); } else if(fs_type_sun86) sbInformation.AppendFormat(Localization._0_sectors_track, sb.fs_state).AppendLine(); else if(fs_type_44bsd) { - sbInformation.AppendFormat(Localization._0_blocks_on_cluster_summary_array, sb.fs_contigsumsize). - AppendLine(); + sbInformation.AppendFormat(Localization._0_blocks_on_cluster_summary_array, sb.fs_contigsumsize) + .AppendLine(); - sbInformation.AppendFormat(Localization.Maximum_length_of_a_symbolic_link_0, sb.fs_maxsymlinklen). - AppendLine(); + sbInformation.AppendFormat(Localization.Maximum_length_of_a_symbolic_link_0, sb.fs_maxsymlinklen) + .AppendLine(); sbInformation.AppendFormat(Localization.A_file_can_be_0_bytes_at_max, sb.fs_maxfilesize).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_state)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_state_on_0, DateHandlers.UnixToDateTime(sb.fs_state)) + .AppendLine(); } if(sb.fs_old_nrpos > 0) diff --git a/Aaru.Filesystems/FFS/Structs.cs b/Aaru.Filesystems/FFS/Structs.cs index aaf2ff6ed..356891928 100644 --- a/Aaru.Filesystems/FFS/Structs.cs +++ b/Aaru.Filesystems/FFS/Structs.cs @@ -28,8 +28,6 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using time_t = int; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/Fossil/Info.cs b/Aaru.Filesystems/Fossil/Info.cs index cb4fe6233..8877370a8 100644 --- a/Aaru.Filesystems/Fossil/Info.cs +++ b/Aaru.Filesystems/Fossil/Info.cs @@ -47,13 +47,11 @@ public sealed partial class Fossil { ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; - if(partition.Start + hdrSector > imagePlugin.Info.Sectors) - return false; + if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); @@ -71,15 +69,13 @@ public sealed partial class Fossil information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + hdrSector, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); diff --git a/Aaru.Filesystems/HAMMER/Consts.cs b/Aaru.Filesystems/HAMMER/Consts.cs index 60413e166..ddb9151f6 100644 --- a/Aaru.Filesystems/HAMMER/Consts.cs +++ b/Aaru.Filesystems/HAMMER/Consts.cs @@ -26,10 +26,6 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using hammer_crc_t = uint; -using hammer_off_t = ulong; -using hammer_tid_t = ulong; - #pragma warning disable 169 namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/HAMMER/HAMMER.cs b/Aaru.Filesystems/HAMMER/HAMMER.cs index fabb4b995..059866546 100644 --- a/Aaru.Filesystems/HAMMER/HAMMER.cs +++ b/Aaru.Filesystems/HAMMER/HAMMER.cs @@ -28,9 +28,6 @@ using System; using Aaru.CommonTypes.Interfaces; -using hammer_crc_t = uint; -using hammer_off_t = ulong; -using hammer_tid_t = ulong; #pragma warning disable 169 diff --git a/Aaru.Filesystems/HAMMER/Info.cs b/Aaru.Filesystems/HAMMER/Info.cs index 89df4bbb9..42fa9bc0e 100644 --- a/Aaru.Filesystems/HAMMER/Info.cs +++ b/Aaru.Filesystems/HAMMER/Info.cs @@ -32,9 +32,6 @@ using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -using hammer_crc_t = uint; -using hammer_off_t = ulong; -using hammer_tid_t = ulong; using Partition = Aaru.CommonTypes.Partition; #pragma warning disable 169 @@ -52,16 +49,13 @@ public sealed partial class HAMMER { uint run = HAMMER_VOLHDR_SIZE / imagePlugin.Info.SectorSize; - if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) - run++; + if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) run++; - if(run + partition.Start >= partition.End) - return false; + if(run + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt64(sbSector, 0); @@ -80,13 +74,11 @@ public sealed partial class HAMMER uint run = HAMMER_VOLHDR_SIZE / imagePlugin.Info.SectorSize; - if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) - run++; + if(HAMMER_VOLHDR_SIZE % imagePlugin.Info.SectorSize > 0) run++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, run, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var magic = BitConverter.ToUInt64(sbSector, 0); @@ -98,11 +90,11 @@ public sealed partial class HAMMER sb.AppendFormat(Localization.Volume_version_0, superBlock.vol_version).AppendLine(); - sb.AppendFormat(Localization.Volume_0_of_1_on_this_filesystem, superBlock.vol_no + 1, superBlock.vol_count). - AppendLine(); + sb.AppendFormat(Localization.Volume_0_of_1_on_this_filesystem, superBlock.vol_no + 1, superBlock.vol_count) + .AppendLine(); - sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(superBlock.vol_label, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(superBlock.vol_label, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Volume_serial_0, superBlock.vol_fsid).AppendLine(); sb.AppendFormat(Localization.Filesystem_type_0, superBlock.vol_fstype).AppendLine(); @@ -123,13 +115,15 @@ public sealed partial class HAMMER if(superBlock.vol_no == superBlock.vol_rootvol) { - sb.AppendFormat(Localization.Filesystem_contains_0_big_blocks_1_bytes, superBlock.vol0_stat_bigblocks, - superBlock.vol0_stat_bigblocks * HAMMER_BIGBLOCK_SIZE). - AppendLine(); + sb.AppendFormat(Localization.Filesystem_contains_0_big_blocks_1_bytes, + superBlock.vol0_stat_bigblocks, + superBlock.vol0_stat_bigblocks * HAMMER_BIGBLOCK_SIZE) + .AppendLine(); - sb.AppendFormat(Localization.Filesystem_has_0_big_blocks_free_1_bytes, superBlock.vol0_stat_freebigblocks, - superBlock.vol0_stat_freebigblocks * HAMMER_BIGBLOCK_SIZE). - AppendLine(); + sb.AppendFormat(Localization.Filesystem_has_0_big_blocks_free_1_bytes, + superBlock.vol0_stat_freebigblocks, + superBlock.vol0_stat_freebigblocks * HAMMER_BIGBLOCK_SIZE) + .AppendLine(); sb.AppendFormat(Localization.Filesystem_has_0_inodes_used, superBlock.vol0_stat_inodes).AppendLine(); diff --git a/Aaru.Filesystems/HPFS/Info.cs b/Aaru.Filesystems/HPFS/Info.cs index 952f80aab..e2a03d8b8 100644 --- a/Aaru.Filesystems/HPFS/Info.cs +++ b/Aaru.Filesystems/HPFS/Info.cs @@ -51,15 +51,13 @@ public sealed partial class HPFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(16 + partition.Start >= partition.End) - return false; + if(16 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16 - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); var magic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); @@ -81,20 +79,17 @@ public sealed partial class HPFS imagePlugin.ReadSector(0 + partition.Start, out byte[] hpfsBpbSector); // Seek to BIOS parameter block, on logical sector 0 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] hpfsSbSector); // Seek to superblock, on logical sector 16 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(17 + partition.Start, out byte[] hpfsSpSector); // Seek to spareblock, on logical sector 17 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpfsBpbSector); @@ -131,8 +126,8 @@ public sealed partial class HPFS // sb.AppendFormat("{0} heads", hpfs_bpb.heads).AppendLine(); sb.AppendFormat(Localization._0_sectors_hidden_before_BPB, bpb.hsectors).AppendLine(); - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, hpfsSb.sectors, hpfsSb.sectors * bpb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, hpfsSb.sectors, hpfsSb.sectors * bpb.bps) + .AppendLine(); // sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfs_bpb.big_sectors, hpfs_bpb.big_sectors * hpfs_bpb.bps).AppendLine(); sb.AppendFormat(Localization.BIOS_drive_number_0, bpb.drive_no).AppendLine(); @@ -182,50 +177,35 @@ public sealed partial class HPFS sb.AppendLine(Localization.Flags); sb.AppendLine((sp.flags1 & 0x01) == 0x01 ? Localization.Filesystem_is_dirty : Localization.Filesystem_is_clean); - if((sp.flags1 & 0x02) == 0x02) - sb.AppendLine(Localization.Spare_directory_blocks_are_in_use); + if((sp.flags1 & 0x02) == 0x02) sb.AppendLine(Localization.Spare_directory_blocks_are_in_use); - if((sp.flags1 & 0x04) == 0x04) - sb.AppendLine(Localization.Hotfixes_are_in_use); + if((sp.flags1 & 0x04) == 0x04) sb.AppendLine(Localization.Hotfixes_are_in_use); - if((sp.flags1 & 0x08) == 0x08) - sb.AppendLine(Localization.Disk_contains_bad_sectors); + if((sp.flags1 & 0x08) == 0x08) sb.AppendLine(Localization.Disk_contains_bad_sectors); - if((sp.flags1 & 0x10) == 0x10) - sb.AppendLine(Localization.Disk_has_a_bad_bitmap); + if((sp.flags1 & 0x10) == 0x10) sb.AppendLine(Localization.Disk_has_a_bad_bitmap); - if((sp.flags1 & 0x20) == 0x20) - sb.AppendLine(Localization.Filesystem_was_formatted_fast); + if((sp.flags1 & 0x20) == 0x20) sb.AppendLine(Localization.Filesystem_was_formatted_fast); - if((sp.flags1 & 0x40) == 0x40) - sb.AppendLine(Localization.Unknown_flag_0x40_on_flags1_is_active); + if((sp.flags1 & 0x40) == 0x40) sb.AppendLine(Localization.Unknown_flag_0x40_on_flags1_is_active); - if((sp.flags1 & 0x80) == 0x80) - sb.AppendLine(Localization.Filesystem_has_been_mounted_by_an_old_IFS); + if((sp.flags1 & 0x80) == 0x80) sb.AppendLine(Localization.Filesystem_has_been_mounted_by_an_old_IFS); - if((sp.flags2 & 0x01) == 0x01) - sb.AppendLine(Localization.Install_DASD_limits); + if((sp.flags2 & 0x01) == 0x01) sb.AppendLine(Localization.Install_DASD_limits); - if((sp.flags2 & 0x02) == 0x02) - sb.AppendLine(Localization.Resync_DASD_limits); + if((sp.flags2 & 0x02) == 0x02) sb.AppendLine(Localization.Resync_DASD_limits); - if((sp.flags2 & 0x04) == 0x04) - sb.AppendLine(Localization.DASD_limits_are_operational); + if((sp.flags2 & 0x04) == 0x04) sb.AppendLine(Localization.DASD_limits_are_operational); - if((sp.flags2 & 0x08) == 0x08) - sb.AppendLine(Localization.Multimedia_is_active); + if((sp.flags2 & 0x08) == 0x08) sb.AppendLine(Localization.Multimedia_is_active); - if((sp.flags2 & 0x10) == 0x10) - sb.AppendLine(Localization.DCE_ACLs_are_active); + if((sp.flags2 & 0x10) == 0x10) sb.AppendLine(Localization.DCE_ACLs_are_active); - if((sp.flags2 & 0x20) == 0x20) - sb.AppendLine(Localization.DASD_limits_are_dirty); + if((sp.flags2 & 0x20) == 0x20) sb.AppendLine(Localization.DASD_limits_are_dirty); - if((sp.flags2 & 0x40) == 0x40) - sb.AppendLine(Localization.Unknown_flag_0x40_on_flags2_is_active); + if((sp.flags2 & 0x40) == 0x40) sb.AppendLine(Localization.Unknown_flag_0x40_on_flags2_is_active); - if((sp.flags2 & 0x80) == 0x80) - sb.AppendLine(Localization.Unknown_flag_0x80_on_flags2_is_active); + if((sp.flags2 & 0x80) == 0x80) sb.AppendLine(Localization.Unknown_flag_0x80_on_flags2_is_active); metadata = new FileSystem(); diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index 9691baf7b..79f04a9d7 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -49,18 +49,15 @@ public sealed partial class HPOFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(16 + partition.Start >= partition.End) - return false; + if(16 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] hpofsBpbSector); // Seek to BIOS parameter block, on logical sector 0 - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(hpofsBpbSector.Length < 512) - return false; + if(hpofsBpbSector.Length < 512) return false; BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpofsBpbSector); @@ -81,20 +78,17 @@ public sealed partial class HPOFS imagePlugin.ReadSector(0 + partition.Start, out byte[] hpofsBpbSector); // Seek to BIOS parameter block, on logical sector 0 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(13 + partition.Start, out byte[] medInfoSector); // Seek to media information block, on logical sector 13 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSector(14 + partition.Start, out byte[] volInfoSector); // Seek to volume information block, on logical sector 14 - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpofsBpbSector); MediaInformationBlock mib = Marshal.ByteArrayToStructureBigEndian(medInfoSector); @@ -119,12 +113,14 @@ public sealed partial class HPOFS AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.signature = 0x{0:X2}", bpb.signature); AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.serial_no = 0x{0:X8}", bpb.serial_no); - AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.volume_label = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "bpb.volume_label = \"{0}\"", StringHandlers.SpacePaddedToString(bpb.volume_label)); AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.fs_type = \"{0}\"", StringHandlers.CToString(bpb.fs_type)); - AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.boot_code is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "bpb.boot_code is empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(bpb.boot_code)); AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.unknown = {0}", bpb.unknown); @@ -132,15 +128,18 @@ public sealed partial class HPOFS AaruConsole.DebugWriteLine(MODULE_NAME, "bpb.signature2 = {0}", bpb.signature2); AaruConsole.DebugWriteLine(MODULE_NAME, "mib.blockId = \"{0}\"", StringHandlers.CToString(mib.blockId)); - AaruConsole.DebugWriteLine(MODULE_NAME, "mib.volumeLabel = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mib.volumeLabel = \"{0}\"", StringHandlers.SpacePaddedToString(mib.volumeLabel)); - AaruConsole.DebugWriteLine(MODULE_NAME, "mib.comment = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mib.comment = \"{0}\"", StringHandlers.SpacePaddedToString(mib.comment)); AaruConsole.DebugWriteLine(MODULE_NAME, "mib.serial = 0x{0:X8}", mib.serial); - AaruConsole.DebugWriteLine(MODULE_NAME, "mib.creationTimestamp = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mib.creationTimestamp = {0}", DateHandlers.DosToDateTime(mib.creationDate, mib.creationTime)); AaruConsole.DebugWriteLine(MODULE_NAME, "mib.codepageType = {0}", mib.codepageType); @@ -157,29 +156,34 @@ public sealed partial class HPOFS AaruConsole.DebugWriteLine(MODULE_NAME, "mib.unknown5 = {0}", mib.unknown5); AaruConsole.DebugWriteLine(MODULE_NAME, "mib.unknown6 = {0}", mib.unknown6); - AaruConsole.DebugWriteLine(MODULE_NAME, "mib.filler is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mib.filler is empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(mib.filler)); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.blockId = \"{0}\"", StringHandlers.CToString(vib.blockId)); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown = {0}", vib.unknown); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown2 = {0}", vib.unknown2); - AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown3 is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "vib.unknown3 is empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vib.unknown3)); - AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown4 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "vib.unknown4 = \"{0}\"", StringHandlers.SpacePaddedToString(vib.unknown4)); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.owner = \"{0}\"", StringHandlers.SpacePaddedToString(vib.owner)); - AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown5 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "vib.unknown5 = \"{0}\"", StringHandlers.SpacePaddedToString(vib.unknown5)); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown6 = {0}", vib.unknown6); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.percentFull = {0}", vib.percentFull); AaruConsole.DebugWriteLine(MODULE_NAME, "vib.unknown7 = {0}", vib.unknown7); - AaruConsole.DebugWriteLine(MODULE_NAME, "vib.filler is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "vib.filler is empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vib.filler)); sb.AppendLine(Localization.HPOFS_Name); @@ -194,24 +198,25 @@ public sealed partial class HPOFS sb.AppendFormat(Localization.BIOS_drive_number_0, bpb.drive_no).AppendLine(); sb.AppendFormat(Localization.Serial_number_0, mib.serial).AppendLine(); - sb.AppendFormat(Localization.Volume_label_0, StringHandlers.SpacePaddedToString(mib.volumeLabel, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_label_0, StringHandlers.SpacePaddedToString(mib.volumeLabel, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_comment_0, StringHandlers.SpacePaddedToString(mib.comment, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_comment_0, StringHandlers.SpacePaddedToString(mib.comment, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_owner_0, StringHandlers.SpacePaddedToString(vib.owner, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_owner_0, StringHandlers.SpacePaddedToString(vib.owner, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.DosToDateTime(mib.creationDate, mib.creationTime)). - AppendLine(); + DateHandlers.DosToDateTime(mib.creationDate, mib.creationTime)) + .AppendLine(); sb.AppendFormat(Localization.Volume_uses_0_codepage_1, mib.codepageType is > 0 and < 3 ? mib.codepageType == 2 ? Localization.EBCDIC : Localization.ASCII - : Localization.Unknown_codepage, mib.codepage). - AppendLine(); + : Localization.Unknown_codepage, + mib.codepage) + .AppendLine(); sb.AppendFormat(Localization.RPS_level_0, mib.rps).AppendLine(); sb.AppendFormat(Localization.Filesystem_version_0_1, mib.major, mib.minor).AppendLine(); diff --git a/Aaru.Filesystems/ISO9660/Date.cs b/Aaru.Filesystems/ISO9660/Date.cs index b5f7e5ee9..53c2dfbcb 100644 --- a/Aaru.Filesystems/ISO9660/Date.cs +++ b/Aaru.Filesystems/ISO9660/Date.cs @@ -36,8 +36,8 @@ public sealed partial class ISO9660 { static DateTime? DecodeIsoDateTime(byte[] timestamp) => timestamp?.Length switch { - 7 => DecodeIsoDateTime(Marshal. - ByteArrayToStructureLittleEndian< + 7 => DecodeIsoDateTime(Marshal + .ByteArrayToStructureLittleEndian< IsoTimestamp>(timestamp)), 17 => DateHandlers.Iso9660ToDateTime(timestamp), _ => null @@ -47,8 +47,13 @@ public sealed partial class ISO9660 { try { - var date = new DateTime(timestamp.Years + 1900, timestamp.Month, timestamp.Day, timestamp.Hour, - timestamp.Minute, timestamp.Second, DateTimeKind.Unspecified); + var date = new DateTime(timestamp.Years + 1900, + timestamp.Month, + timestamp.Day, + timestamp.Hour, + timestamp.Minute, + timestamp.Second, + DateTimeKind.Unspecified); date = date.AddMinutes(timestamp.GmtOffset * 15); @@ -65,8 +70,13 @@ public sealed partial class ISO9660 { try { - var date = new DateTime(timestamp.Years + 1900, timestamp.Month, timestamp.Day, timestamp.Hour, - timestamp.Minute, timestamp.Second, DateTimeKind.Unspecified); + var date = new DateTime(timestamp.Years + 1900, + timestamp.Month, + timestamp.Day, + timestamp.Hour, + timestamp.Minute, + timestamp.Second, + DateTimeKind.Unspecified); return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT")); } diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index 3631b3b48..4f83d7e3f 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -50,8 +50,7 @@ public sealed partial class ISO9660 { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { @@ -82,18 +81,17 @@ public sealed partial class ISO9660 } string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = _rootDirectoryCache.FirstOrDefault(t => t.Key.Equals(pieces[0], StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -101,43 +99,35 @@ public sealed partial class ISO9660 for(var p = 0; p < pieces.Length; p++) { - entry = - currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p], - StringComparison.CurrentCultureIgnoreCase)); + entry = currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p], + StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) - return ErrorNumber.NotDirectory; + if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; - if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) - continue; + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; - if(entry.Value.Extents.Count == 0) - return ErrorNumber.InvalidArgument; + if(entry.Value.Extents.Count == 0) return ErrorNumber.InvalidArgument; - currentDirectory = - _cdi - ? - DecodeCdiDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, - entry.Value.Extents[0].size) - : _highSierra - ? DecodeHighSierraDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, - entry.Value.Extents[0].size) - : DecodeIsoDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, - entry.Value.Extents[0].size); + currentDirectory = _cdi + ? DecodeCdiDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, + entry.Value.Extents[0].size) + : _highSierra + ? DecodeHighSierraDirectory(entry.Value.Extents[0].extent + + entry.Value.XattrLength, + entry.Value.Extents[0].size) + : DecodeIsoDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, + entry.Value.Extents[0].size); if(_usePathTable) { foreach(DecodedDirectoryEntry subDirectory in _cdi ? GetSubdirsFromCdiPathTable(currentPath) - : - _highSierra - ? - GetSubdirsFromHighSierraPathTable(currentPath) + : _highSierra + ? GetSubdirsFromHighSierraPathTable(currentPath) : GetSubdirsFromIsoPathTable(currentPath)) currentDirectory[subDirectory.Filename] = subDirectory; } @@ -145,8 +135,7 @@ public sealed partial class ISO9660 _directoryCache.Add(currentPath, currentDirectory); } - if(currentDirectory is null) - return ErrorNumber.NoSuchFile; + if(currentDirectory is null) return ErrorNumber.NoSuchFile; node = new Iso9660DirNode { @@ -163,17 +152,13 @@ public sealed partial class ISO9660 { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not Iso9660DirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Entries.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Entries.Length) return ErrorNumber.NoError; switch(_namespace) { @@ -202,8 +187,7 @@ public sealed partial class ISO9660 /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not Iso9660DirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not Iso9660DirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Entries = null; @@ -220,8 +204,7 @@ public sealed partial class ISO9660 ErrorNumber errno = ReadSingleExtent(size, (uint)start, out byte[] data); - if(errno != ErrorNumber.NoError) - return entries; + if(errno != ErrorNumber.NoError) return entries; while(entryOff + _cdiDirectoryRecordSize < data.Length) { @@ -262,8 +245,7 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.start_lbn, record.size)); + if(record.size != 0) entry.Extents.Add((record.start_lbn, record.size)); if(record.flags.HasFlag(CdiFileFlags.Hidden)) { @@ -274,8 +256,7 @@ public sealed partial class ISO9660 int systemAreaStart = entryOff + record.name_len + _cdiDirectoryRecordSize; - if(systemAreaStart % 2 != 0) - systemAreaStart++; + if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = Marshal.ByteArrayToStructureBigEndian(data, systemAreaStart, _cdiSystemAreaSize); @@ -299,13 +280,13 @@ public sealed partial class ISO9660 ErrorNumber errno = ReadSingleExtent(size, (uint)start, out byte[] data); - if(errno != ErrorNumber.NoError) - return entries; + if(errno != ErrorNumber.NoError) return entries; while(entryOff + _directoryRecordSize < data.Length) { HighSierraDirectoryRecord record = - Marshal.ByteArrayToStructureLittleEndian(data, entryOff, + Marshal.ByteArrayToStructureLittleEndian(data, + entryOff, _highSierraDirectoryRecordSize); if(record.length == 0) @@ -344,8 +325,7 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.extent, record.size)); + if(record.size != 0) entry.Extents.Add((record.extent, record.size)); if(entry.Flags.HasFlag(FileFlags.Directory) && _usePathTable) { @@ -359,8 +339,7 @@ public sealed partial class ISO9660 entryOff += record.length; } - if(_useTransTbl) - DecodeTransTable(entries); + if(_useTransTbl) DecodeTransTable(entries); return entries; } @@ -372,8 +351,7 @@ public sealed partial class ISO9660 ErrorNumber errno = ReadSingleExtent(size, (uint)start, out byte[] data); - if(errno != ErrorNumber.NoError) - return entries; + if(errno != ErrorNumber.NoError) return entries; while(entryOff + _directoryRecordSize < data.Length) { @@ -409,7 +387,8 @@ public sealed partial class ISO9660 Size = record.size, Flags = record.flags, Filename = _joliet - ? Encoding.BigEndianUnicode.GetString(data, entryOff + _directoryRecordSize, + ? Encoding.BigEndianUnicode.GetString(data, + entryOff + _directoryRecordSize, record.name_len) : _encoding.GetString(data, entryOff + _directoryRecordSize, record.name_len), FileUnitSize = record.file_unit_size, @@ -420,8 +399,7 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.extent, record.size)); + if(record.size != 0) entry.Extents.Add((record.extent, record.size)); if(entry.Flags.HasFlag(FileFlags.Directory) && _usePathTable) { @@ -434,11 +412,9 @@ public sealed partial class ISO9660 entry.Filename = entry.Filename.Replace('/', '\u2215'); // Tailing '.' is only allowed on RRIP. If present it will be recreated below with the alternate name - if(entry.Filename.EndsWith(".", StringComparison.Ordinal)) - entry.Filename = entry.Filename[..^1]; + if(entry.Filename.EndsWith(".", StringComparison.Ordinal)) entry.Filename = entry.Filename[..^1]; - if(entry.Filename.EndsWith(".;1", StringComparison.Ordinal)) - entry.Filename = entry.Filename[..^3] + ";1"; + if(entry.Filename.EndsWith(".;1", StringComparison.Ordinal)) entry.Filename = entry.Filename[..^3] + ";1"; // This is a legal Joliet name, different from VMS version fields, but Nero MAX incorrectly creates these filenames if(_joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal)) @@ -453,7 +429,10 @@ public sealed partial class ISO9660 systemAreaLength--; } - DecodeSystemArea(data, systemAreaStart, systemAreaStart + systemAreaLength, ref entry, + DecodeSystemArea(data, + systemAreaStart, + systemAreaStart + systemAreaLength, + ref entry, out bool hasResourceFork); if(entry.Flags.HasFlag(FileFlags.Associated)) @@ -510,8 +489,7 @@ public sealed partial class ISO9660 entries[entry.Filename].XattrLength = entry.XattrLength; } - if(entry.Extents?.Count > 0) - entries[entry.Filename].Extents.Add(entry.Extents[0]); + if(entry.Extents?.Count > 0) entries[entry.Filename].Extents.Add(entry.Extents[0]); } else entries[entry.Filename] = entry; @@ -520,8 +498,7 @@ public sealed partial class ISO9660 entryOff += record.length; } - if(_useTransTbl) - DecodeTransTable(entries); + if(_useTransTbl) DecodeTransTable(entries); // Relocated directories should be shown in correct place when using Rock Ridge namespace return _namespace == Namespace.Rrip @@ -538,16 +515,18 @@ public sealed partial class ISO9660 e.Value.Filename.Equals("trans.tbl;1", StringComparison.CurrentCultureIgnoreCase))); - if(transTblEntry.Value == null) - return; + if(transTblEntry.Value == null) return; - ErrorNumber errno = ReadWithExtents(0, (long)transTblEntry.Value.Size, transTblEntry.Value.Extents, + ErrorNumber errno = ReadWithExtents(0, + (long)transTblEntry.Value.Size, + transTblEntry.Value.Extents, transTblEntry.Value.XA?.signature == XA_MAGIC && transTblEntry.Value.XA?.attributes.HasFlag(XaAttributes.Interleaved) == - true, transTblEntry.Value.XA?.filenumber ?? 0, out byte[] transTbl); + true, + transTblEntry.Value.XA?.filenumber ?? 0, + out byte[] transTbl); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var mr = new MemoryStream(transTbl, 0, (int)transTblEntry.Value.Size, false); var sr = new StreamReader(mr, _encoding); @@ -603,8 +582,7 @@ public sealed partial class ISO9660 { var systemAreaSignature = BigEndianBitConverter.ToUInt16(data, systemAreaOff); - if(BigEndianBitConverter.ToUInt16(data, systemAreaOff + 6) == XA_MAGIC) - systemAreaSignature = XA_MAGIC; + if(BigEndianBitConverter.ToUInt16(data, systemAreaOff + 6) == XA_MAGIC) systemAreaSignature = XA_MAGIC; AppleCommon.FInfo fInfo; @@ -615,14 +593,14 @@ public sealed partial class ISO9660 var appleId = (AppleId)data[systemAreaOff + 3]; // Old AAIP - if(appleId == AppleId.ProDOS && appleLength != 7) - goto case AAIP_MAGIC; + if(appleId == AppleId.ProDOS && appleLength != 7) goto case AAIP_MAGIC; switch(appleId) { case AppleId.ProDOS: AppleProDOSSystemUse appleProDosSystemUse = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); entry.AppleProDosType = appleProDosSystemUse.aux_type; @@ -631,7 +609,8 @@ public sealed partial class ISO9660 break; case AppleId.HFS: AppleHFSSystemUse appleHfsSystemUse = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); hasResourceFork = true; @@ -658,7 +637,8 @@ public sealed partial class ISO9660 { case AppleOldId.ProDOS: AppleProDOSOldSystemUse appleProDosOldSystemUse = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); entry.AppleProDosType = appleProDosOldSystemUse.aux_type; @@ -670,7 +650,8 @@ public sealed partial class ISO9660 case AppleOldId.TypeCreator: case AppleOldId.TypeCreatorBundle: AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); hasResourceFork = true; @@ -689,7 +670,8 @@ public sealed partial class ISO9660 case AppleOldId.TypeCreatorIcon: case AppleOldId.TypeCreatorIconBundle: AppleHFSIconSystemUse appleHfsIconSystemUse = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); hasResourceFork = true; @@ -708,7 +690,8 @@ public sealed partial class ISO9660 break; case AppleOldId.HFS: AppleHFSOldSystemUse appleHfsSystemUse = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); hasResourceFork = true; @@ -734,7 +717,8 @@ public sealed partial class ISO9660 break; case XA_MAGIC: - entry.XA = Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + entry.XA = Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); systemAreaOff += Marshal.SizeOf(); @@ -745,7 +729,8 @@ public sealed partial class ISO9660 case AAIP_MAGIC: case AMIGA_MAGIC: AmigaEntry amiga = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureBigEndian(data, + systemAreaOff, Marshal.SizeOf()); var protectionLength = 0; @@ -754,7 +739,8 @@ public sealed partial class ISO9660 { entry.AmigaProtection = Marshal.ByteArrayToStructureBigEndian(data, - systemAreaOff + Marshal.SizeOf(), Marshal.SizeOf()); + systemAreaOff + Marshal.SizeOf(), + Marshal.SizeOf()); protectionLength = Marshal.SizeOf(); } @@ -764,13 +750,16 @@ public sealed partial class ISO9660 entry.AmigaComment ??= Array.Empty(); var newComment = new byte[entry.AmigaComment.Length + - data - [systemAreaOff + Marshal.SizeOf() + protectionLength] - + data[systemAreaOff + + Marshal.SizeOf() + + protectionLength] - 1]; Array.Copy(entry.AmigaComment, 0, newComment, 0, entry.AmigaComment.Length); - Array.Copy(data, systemAreaOff + Marshal.SizeOf() + protectionLength, newComment, + Array.Copy(data, + systemAreaOff + Marshal.SizeOf() + protectionLength, + newComment, entry.AmigaComment.Length, data[systemAreaOff + Marshal.SizeOf() + protectionLength] - 1); @@ -794,13 +783,15 @@ public sealed partial class ISO9660 { case 36: entry.PosixAttributesOld = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); break; case >= 44: entry.PosixAttributes = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); break; @@ -813,7 +804,8 @@ public sealed partial class ISO9660 byte pnLength = data[systemAreaOff + 2]; entry.PosixDeviceNumber = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); systemAreaOff += pnLength; @@ -823,7 +815,8 @@ public sealed partial class ISO9660 byte slLength = data[systemAreaOff + 2]; SymbolicLink sl = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); SymbolicLinkComponent slc = @@ -831,29 +824,25 @@ public sealed partial class ISO9660 systemAreaOff + Marshal.SizeOf(), Marshal.SizeOf()); - if(!continueSymlink || entry.SymbolicLink is null) - entry.SymbolicLink = ""; + if(!continueSymlink || entry.SymbolicLink is null) entry.SymbolicLink = ""; - if(slc.flags.HasFlag(SymlinkComponentFlags.Root)) - entry.SymbolicLink = "/"; + if(slc.flags.HasFlag(SymlinkComponentFlags.Root)) entry.SymbolicLink = "/"; - if(slc.flags.HasFlag(SymlinkComponentFlags.Current)) - entry.SymbolicLink += "."; + if(slc.flags.HasFlag(SymlinkComponentFlags.Current)) entry.SymbolicLink += "."; - if(slc.flags.HasFlag(SymlinkComponentFlags.Parent)) - entry.SymbolicLink += ".."; + if(slc.flags.HasFlag(SymlinkComponentFlags.Parent)) entry.SymbolicLink += ".."; if(!continueSymlinkComponent && !slc.flags.HasFlag(SymlinkComponentFlags.Root)) entry.SymbolicLink += "/"; entry.SymbolicLink += slc.flags.HasFlag(SymlinkComponentFlags.Networkname) - ? - Environment.MachineName + ? Environment.MachineName : _joliet ? Encoding.BigEndianUnicode.GetString(data, systemAreaOff + Marshal.SizeOf() + - Marshal.SizeOf(), slc.length) + Marshal.SizeOf(), + slc.length) : _encoding.GetString(data, systemAreaOff + Marshal.SizeOf() + @@ -877,7 +866,8 @@ public sealed partial class ISO9660 } AlternateName alternateName = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); byte[] nm; @@ -927,7 +917,8 @@ public sealed partial class ISO9660 } ChildLink cl = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); ErrorNumber errno = ReadSector(cl.child_dir_lba, out byte[] childSector); @@ -977,7 +968,8 @@ public sealed partial class ISO9660 byte tfLength = data[systemAreaOff + 2]; Timestamps timestamps = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); int tfOff = systemAreaOff + Marshal.SizeOf(); @@ -1044,7 +1036,8 @@ public sealed partial class ISO9660 byte ceLength = data[systemAreaOff + 2]; ContinuationArea ca = - Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.ByteArrayToStructureLittleEndian(data, + systemAreaOff, Marshal.SizeOf()); errno = ReadSingleExtent(ca.offset, ca.ca_length, ca.block, out byte[] caData); @@ -1115,9 +1108,10 @@ public sealed partial class ISO9660 : path.ToLower(CultureInfo.CurrentUICulture); string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); var currentParent = 1; var currentPiece = 0; @@ -1125,13 +1119,12 @@ public sealed partial class ISO9660 while(currentPiece < pieces.Length) { PathTableEntryInternal currentEntry = _pathTable.FirstOrDefault(p => p.Parent == currentParent && - p.Name. - Equals(pieces[currentPiece], - StringComparison. - CurrentCultureIgnoreCase)); + p.Name.Equals(pieces + [currentPiece], + StringComparison + .CurrentCultureIgnoreCase)); - if(currentEntry is null) - break; + if(currentEntry is null) break; currentPiece++; currentParent = pathTableList.IndexOf(currentEntry) + 1; @@ -1152,15 +1145,14 @@ public sealed partial class ISO9660 { ErrorNumber errno = ReadSector(tEntry.Extent, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; CdiDirectoryRecord record = - Marshal.ByteArrayToStructureBigEndian(sector, tEntry.XattrLength, + Marshal.ByteArrayToStructureBigEndian(sector, + tEntry.XattrLength, _cdiDirectoryRecordSize); - if(record.length == 0) - break; + if(record.length == 0) break; var entry = new DecodedDirectoryEntry { @@ -1172,16 +1164,13 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.start_lbn, record.size)); + if(record.size != 0) entry.Extents.Add((record.start_lbn, record.size)); - if(record.flags.HasFlag(CdiFileFlags.Hidden)) - entry.Flags |= FileFlags.Hidden; + if(record.flags.HasFlag(CdiFileFlags.Hidden)) entry.Flags |= FileFlags.Hidden; int systemAreaStart = record.name_len + _cdiDirectoryRecordSize; - if(systemAreaStart % 2 != 0) - systemAreaStart++; + if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = Marshal.ByteArrayToStructureBigEndian(sector, systemAreaStart, _cdiSystemAreaSize); @@ -1204,15 +1193,14 @@ public sealed partial class ISO9660 { ErrorNumber errno = ReadSector(tEntry.Extent, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DirectoryRecord record = - Marshal.ByteArrayToStructureLittleEndian(sector, tEntry.XattrLength, + Marshal.ByteArrayToStructureLittleEndian(sector, + tEntry.XattrLength, _directoryRecordSize); - if(record.length == 0) - break; + if(record.length == 0) break; var entry = new DecodedDirectoryEntry { @@ -1227,8 +1215,7 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.extent, record.size)); + if(record.size != 0) entry.Extents.Add((record.extent, record.size)); int systemAreaStart = record.name_len + _directoryRecordSize; int systemAreaLength = record.length - record.name_len - _directoryRecordSize; @@ -1256,11 +1243,11 @@ public sealed partial class ISO9660 { ErrorNumber errno = ReadSector(tEntry.Extent, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; HighSierraDirectoryRecord record = - Marshal.ByteArrayToStructureLittleEndian(sector, tEntry.XattrLength, + Marshal.ByteArrayToStructureLittleEndian(sector, + tEntry.XattrLength, _highSierraDirectoryRecordSize); var entry = new DecodedDirectoryEntry @@ -1275,8 +1262,7 @@ public sealed partial class ISO9660 Extents = new List<(uint extent, uint size)>() }; - if(record.size != 0) - entry.Extents.Add((record.extent, record.size)); + if(record.size != 0) entry.Extents.Add((record.extent, record.size)); entries.Add(entry); } diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index b329c8cd9..64e6659f3 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -51,13 +51,11 @@ public sealed partial class ISO9660 { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; @@ -69,19 +67,15 @@ public sealed partial class ISO9660 { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if(entry.Flags.HasFlag(FileFlags.Directory) && !_debug) - return ErrorNumber.IsDirectory; + if(entry.Flags.HasFlag(FileFlags.Directory) && !_debug) return ErrorNumber.IsDirectory; - if(entry.Extents is null) - return ErrorNumber.InvalidArgument; + if(entry.Extents is null) return ErrorNumber.InvalidArgument; node = new Iso9660FileNode { @@ -97,11 +91,9 @@ public sealed partial class ISO9660 /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not Iso9660FileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not Iso9660FileNode mynode) return ErrorNumber.InvalidArgument; mynode.Dentry = null; @@ -114,29 +106,28 @@ public sealed partial class ISO9660 { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not Iso9660FileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not Iso9660FileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; long offset = mynode.Offset + mynode.Dentry.XattrLength * _blockSize; if(mynode.Dentry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) != true || mynode.Dentry.Extents.Count != 1) { - ErrorNumber err = ReadWithExtents(offset, read, mynode.Dentry.Extents, + ErrorNumber err = ReadWithExtents(offset, + read, + mynode.Dentry.Extents, mynode.Dentry.XA?.signature == XA_MAGIC && mynode.Dentry.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, - mynode.Dentry.XA?.filenumber ?? 0, out byte[] buf); + mynode.Dentry.XA?.filenumber ?? 0, + out byte[] buf); if(err != ErrorNumber.NoError) { @@ -158,11 +149,11 @@ public sealed partial class ISO9660 long offsetInSector = offset % 2352; long sizeInSectors = (read + offsetInSector) / 2352; - if((read + offsetInSector) % 2352 > 0) - sizeInSectors++; + if((read + offsetInSector) % 2352 > 0) sizeInSectors++; ErrorNumber errno = _image.ReadSectorsLong((ulong)(mynode.Dentry.Extents[0].extent + firstSector), - (uint)sizeInSectors, out byte[] buf); + (uint)sizeInSectors, + out byte[] buf); if(errno != ErrorNumber.NoError) { @@ -193,13 +184,11 @@ public sealed partial class ISO9660 { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; stat = new FileEntryInfo { @@ -211,17 +200,13 @@ public sealed partial class ISO9660 LastWriteTimeUtc = entry.Timestamp }; - if(entry.Extents?.Count > 0) - stat.Inode = entry.Extents[0].extent; + if(entry.Extents?.Count > 0) stat.Inode = entry.Extents[0].extent; - if(entry.Size % 2048 > 0) - stat.Blocks++; + if(entry.Size % 2048 > 0) stat.Blocks++; - if(entry.Flags.HasFlag(FileFlags.Directory)) - stat.Attributes |= FileAttributes.Directory; + if(entry.Flags.HasFlag(FileFlags.Directory)) stat.Attributes |= FileAttributes.Directory; - if(entry.Flags.HasFlag(FileFlags.Hidden)) - stat.Attributes |= FileAttributes.Hidden; + if(entry.Flags.HasFlag(FileFlags.Hidden)) stat.Attributes |= FileAttributes.Hidden; if(entry.FinderInfo?.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias) == true) stat.Attributes |= FileAttributes.Alias; @@ -250,28 +235,21 @@ public sealed partial class ISO9660 if(entry.FinderInfo?.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBundle) == true) stat.Attributes |= FileAttributes.Bundle; - if(entry.AppleIcon != null) - stat.Attributes |= FileAttributes.HasCustomIcon; + if(entry.AppleIcon != null) stat.Attributes |= FileAttributes.HasCustomIcon; if(entry.XA != null) { - if(entry.XA.Value.attributes.HasFlag(XaAttributes.GroupExecute)) - stat.Mode |= 8; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.GroupExecute)) stat.Mode |= 8; - if(entry.XA.Value.attributes.HasFlag(XaAttributes.GroupRead)) - stat.Mode |= 32; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.GroupRead)) stat.Mode |= 32; - if(entry.XA.Value.attributes.HasFlag(XaAttributes.OwnerExecute)) - stat.Mode |= 64; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.OwnerExecute)) stat.Mode |= 64; - if(entry.XA.Value.attributes.HasFlag(XaAttributes.OwnerRead)) - stat.Mode |= 256; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.OwnerRead)) stat.Mode |= 256; - if(entry.XA.Value.attributes.HasFlag(XaAttributes.SystemExecute)) - stat.Mode |= 1; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.SystemExecute)) stat.Mode |= 1; - if(entry.XA.Value.attributes.HasFlag(XaAttributes.SystemRead)) - stat.Mode |= 4; + if(entry.XA.Value.attributes.HasFlag(XaAttributes.SystemRead)) stat.Mode |= 4; stat.UID = entry.XA.Value.user; stat.GID = entry.XA.Value.group; @@ -288,11 +266,9 @@ public sealed partial class ISO9660 if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Character)) stat.Attributes |= FileAttributes.CharDevice; - if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Pipe)) - stat.Attributes |= FileAttributes.Pipe; + if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Pipe)) stat.Attributes |= FileAttributes.Pipe; - if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Socket)) - stat.Attributes |= FileAttributes.Socket; + if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Socket)) stat.Attributes |= FileAttributes.Socket; if(entry.PosixAttributes.Value.st_mode.HasFlag(PosixMode.Symlink)) stat.Attributes |= FileAttributes.Symlink; @@ -312,8 +288,7 @@ public sealed partial class ISO9660 if(entry.PosixAttributesOld.Value.st_mode.HasFlag(PosixMode.Character)) stat.Attributes |= FileAttributes.CharDevice; - if(entry.PosixAttributesOld.Value.st_mode.HasFlag(PosixMode.Pipe)) - stat.Attributes |= FileAttributes.Pipe; + if(entry.PosixAttributesOld.Value.st_mode.HasFlag(PosixMode.Pipe)) stat.Attributes |= FileAttributes.Pipe; if(entry.PosixAttributesOld.Value.st_mode.HasFlag(PosixMode.Socket)) stat.Attributes |= FileAttributes.Socket; @@ -328,32 +303,23 @@ public sealed partial class ISO9660 if(entry.AmigaProtection != null) { - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupExec)) - stat.Mode |= 8; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupExec)) stat.Mode |= 8; - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupRead)) - stat.Mode |= 32; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupRead)) stat.Mode |= 32; - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupWrite)) - stat.Mode |= 16; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.GroupWrite)) stat.Mode |= 16; - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherExec)) - stat.Mode |= 1; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherExec)) stat.Mode |= 1; - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherRead)) - stat.Mode |= 4; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherRead)) stat.Mode |= 4; - if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherWrite)) - stat.Mode |= 2; + if(entry.AmigaProtection.Value.Multiuser.HasFlag(AmigaMultiuser.OtherWrite)) stat.Mode |= 2; - if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerExec)) - stat.Mode |= 64; + if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerExec)) stat.Mode |= 64; - if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerRead)) - stat.Mode |= 256; + if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerRead)) stat.Mode |= 256; - if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerWrite)) - stat.Mode |= 128; + if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.OwnerWrite)) stat.Mode |= 128; if(entry.AmigaProtection.Value.Protection.HasFlag(AmigaAttributes.Archive)) stat.Attributes |= FileAttributes.Archive; @@ -365,52 +331,39 @@ public sealed partial class ISO9660 entry.PosixDeviceNumber.Value.dev_t_low; } - if(entry.RripModify != null) - stat.LastWriteTimeUtc = DecodeIsoDateTime(entry.RripModify); + if(entry.RripModify != null) stat.LastWriteTimeUtc = DecodeIsoDateTime(entry.RripModify); - if(entry.RripAccess != null) - stat.AccessTimeUtc = DecodeIsoDateTime(entry.RripAccess); + if(entry.RripAccess != null) stat.AccessTimeUtc = DecodeIsoDateTime(entry.RripAccess); - if(entry.RripAttributeChange != null) - stat.StatusChangeTimeUtc = DecodeIsoDateTime(entry.RripAttributeChange); + if(entry.RripAttributeChange != null) stat.StatusChangeTimeUtc = DecodeIsoDateTime(entry.RripAttributeChange); - if(entry.RripBackup != null) - stat.BackupTimeUtc = DecodeIsoDateTime(entry.RripBackup); + if(entry.RripBackup != null) stat.BackupTimeUtc = DecodeIsoDateTime(entry.RripBackup); - if(entry.SymbolicLink != null) - stat.Attributes |= FileAttributes.Symlink; + if(entry.SymbolicLink != null) stat.Attributes |= FileAttributes.Symlink; - if(entry.XattrLength == 0 || _cdi || _highSierra) - return ErrorNumber.NoError; + if(entry.XattrLength == 0 || _cdi || _highSierra) return ErrorNumber.NoError; if(entry.CdiSystemArea != null) { stat.UID = entry.CdiSystemArea.Value.owner; stat.GID = entry.CdiSystemArea.Value.group; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupExecute)) - stat.Mode |= 8; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupExecute)) stat.Mode |= 8; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupRead)) - stat.Mode |= 32; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupRead)) stat.Mode |= 32; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherExecute)) - stat.Mode |= 1; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherExecute)) stat.Mode |= 1; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherRead)) - stat.Mode |= 4; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherRead)) stat.Mode |= 4; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerExecute)) - stat.Mode |= 64; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerExecute)) stat.Mode |= 64; - if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) - stat.Mode |= 256; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) stat.Mode |= 256; } ErrorNumber errno = ReadSingleExtent(entry.XattrLength * _blockSize, entry.Extents[0].extent, out byte[] ea); - if(errno != ErrorNumber.NoError) - return ErrorNumber.NoError; + if(errno != ErrorNumber.NoError) return ErrorNumber.NoError; ExtendedAttributeRecord ear = Marshal.ByteArrayToStructureLittleEndian(ea); @@ -419,23 +372,17 @@ public sealed partial class ISO9660 stat.Mode = 0; - if(ear.permissions.HasFlag(Permissions.GroupExecute)) - stat.Mode |= 8; + if(ear.permissions.HasFlag(Permissions.GroupExecute)) stat.Mode |= 8; - if(ear.permissions.HasFlag(Permissions.GroupRead)) - stat.Mode |= 32; + if(ear.permissions.HasFlag(Permissions.GroupRead)) stat.Mode |= 32; - if(ear.permissions.HasFlag(Permissions.OwnerExecute)) - stat.Mode |= 64; + if(ear.permissions.HasFlag(Permissions.OwnerExecute)) stat.Mode |= 64; - if(ear.permissions.HasFlag(Permissions.OwnerRead)) - stat.Mode |= 256; + if(ear.permissions.HasFlag(Permissions.OwnerRead)) stat.Mode |= 256; - if(ear.permissions.HasFlag(Permissions.OtherExecute)) - stat.Mode |= 1; + if(ear.permissions.HasFlag(Permissions.OtherExecute)) stat.Mode |= 1; - if(ear.permissions.HasFlag(Permissions.OtherRead)) - stat.Mode |= 4; + if(ear.permissions.HasFlag(Permissions.OtherRead)) stat.Mode |= 4; stat.CreationTimeUtc = DateHandlers.Iso9660ToDateTime(ear.creation_date); stat.LastWriteTimeUtc = DateHandlers.Iso9660ToDateTime(ear.modification_date); @@ -450,11 +397,9 @@ public sealed partial class ISO9660 ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if(entry.SymbolicLink is null) - return ErrorNumber.InvalidArgument; + if(entry.SymbolicLink is null) return ErrorNumber.InvalidArgument; dest = entry.SymbolicLink; @@ -472,12 +417,12 @@ public sealed partial class ISO9660 : path.ToLower(CultureInfo.CurrentUICulture); string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pieces.Length == 0) - return ErrorNumber.InvalidArgument; + if(pieces.Length == 0) return ErrorNumber.InvalidArgument; var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); @@ -485,8 +430,7 @@ public sealed partial class ISO9660 { ErrorNumber err = OpenDir(parentPath, out IDirNode node); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; CloseDir(node); } @@ -495,8 +439,7 @@ public sealed partial class ISO9660 if(pieces.Length == 1) parent = _rootDirectoryCache; - else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return ErrorNumber.InvalidArgument; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase)); @@ -508,8 +451,7 @@ public sealed partial class ISO9660 dirent = parent.FirstOrDefault(t => t.Key.Equals(pieces[^1] + ";1", StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(dirent.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile; } else return ErrorNumber.NoSuchFile; @@ -522,18 +464,27 @@ public sealed partial class ISO9660 [MethodImpl(MethodImplOptions.AggressiveInlining)] ErrorNumber ReadSingleExtent(long size, uint startingSector, out byte[] buffer, bool interleaved = false, - byte fileNumber = 0) => ReadWithExtents(0, size, new List<(uint extent, uint size)> - { - (startingSector, (uint)size) - }, interleaved, fileNumber, out buffer); + byte fileNumber = 0) => ReadWithExtents(0, + size, + new List<(uint extent, uint size)> + { + (startingSector, (uint)size) + }, + interleaved, + fileNumber, + out buffer); [MethodImpl(MethodImplOptions.AggressiveInlining)] ErrorNumber ReadSingleExtent(long offset, long size, uint startingSector, out byte[] buffer, - bool interleaved = false, byte fileNumber = 0) => ReadWithExtents(offset, size, + bool interleaved = false, byte fileNumber = 0) => ReadWithExtents(offset, + size, new List<(uint extent, uint size)> { (startingSector, (uint)size) - }, interleaved, fileNumber, out buffer); + }, + interleaved, + fileNumber, + out buffer); // Cannot think how to make this faster, as we don't know the mode sector until it is read, but we have size in bytes ErrorNumber ReadWithExtents(long offset, long size, List<(uint extent, uint size)> extents, bool interleaved, @@ -556,7 +507,9 @@ public sealed partial class ISO9660 while(leftExtentSize > 0) { - ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector, out byte[] sector, interleaved, + ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector, + out byte[] sector, + interleaved, fileNumber); if(errno != ErrorNumber.NoError) @@ -593,16 +546,13 @@ public sealed partial class ISO9660 leftExtentSize -= sector.Length; currentFilePos += sector.Length; - if(ms.Length >= size) - break; + if(ms.Length >= size) break; } - if(ms.Length >= size) - break; + if(ms.Length >= size) break; } - if(ms.Length >= size) - ms.SetLength(size); + if(ms.Length >= size) ms.SetLength(size); buffer = ms.ToArray(); @@ -621,10 +571,10 @@ public sealed partial class ISO9660 while(leftExtentSize > 0) { ErrorNumber errno = _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048, - SectorTagType.CdSectorSubHeader, out byte[] fullSector); + SectorTagType.CdSectorSubHeader, + out byte[] fullSector); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; ms.Write(fullSector, copy ? 0 : 4, 4); diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index 62f898f15..8a19b2821 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -49,31 +49,26 @@ public sealed partial class ISO9660 public bool Identify(IMediaImage imagePlugin, Partition partition) { // ISO9660 is designed for 2048 bytes/sector devices - if(imagePlugin.Info.SectorSize < 2048) - return false; + if(imagePlugin.Info.SectorSize < 2048) return false; // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. - if(partition.End <= 16 + partition.Start) - return false; + if(partition.End <= 16 + partition.Start) return false; // Read to Volume Descriptor ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var xaOff = 0; - if(vdSector.Length == 2336) - xaOff = 8; + if(vdSector.Length == 2336) xaOff = 8; byte vdType = vdSector[0 + xaOff]; var vdMagic = new byte[5]; var hsMagic = new byte[5]; // This indicates the end of a volume descriptor. HighSierra here would have 16 so no problem - if(vdType == 255) - return false; + if(vdType == 255) return false; Array.Copy(vdSector, 0x001 + xaOff, vdMagic, 0, 5); Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); @@ -107,27 +102,23 @@ public sealed partial class ISO9660 ElToritoBootRecord? torito = null; // ISO9660 is designed for 2048 bytes/sector devices - if(imagePlugin.Info.SectorSize < 2048) - return; + if(imagePlugin.Info.SectorSize < 2048) return; // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. - if(partition.End < 16) - return; + if(partition.End < 16) return; ulong counter = 0; ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); bool highSierraInfo = encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; var hsOff = 0; - if(highSierraInfo) - hsOff = 8; + if(highSierraInfo) hsOff = 8; var cdiInfo = false; var evd = false; @@ -141,8 +132,7 @@ public sealed partial class ISO9660 AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start); errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; vdSector = new byte[vdSectorTmp.Length - xaOff]; Array.Copy(vdSectorTmp, xaOff, vdSector, 0, vdSector.Length); @@ -152,8 +142,7 @@ public sealed partial class ISO9660 if(vdType == 255) // Supposedly we are in the PVD. { - if(counter == 0) - return; + if(counter == 0) return; break; } @@ -165,8 +154,7 @@ public sealed partial class ISO9660 encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && encoding.GetString(vdMagic) != CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { - if(counter == 0) - return; + if(counter == 0) return; break; } @@ -261,8 +249,7 @@ public sealed partial class ISO9660 else decodedVd = DecodeVolumeDescriptor(pvd.Value); - if(jolietvd != null) - decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); + if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); uint rootLocation = 0; uint rootSize = 0; @@ -278,15 +265,13 @@ public sealed partial class ISO9660 { rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size; - if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) - rootSize++; + if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) rootSize++; } else { rootSize = pvd.Value.root_directory_record.size / pvd.Value.logical_block_size; - if(pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0) - rootSize++; + if(pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0) rootSize++; } } @@ -307,15 +292,15 @@ public sealed partial class ISO9660 { errno = imagePlugin.ReadSectors(rootLocation, rootSize, out rootDir); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; } // Walk thru root directory to see system area extensions in use while(rootOff + Marshal.SizeOf() < rootDir.Length && !cdiInfo) { DirectoryRecord record = - Marshal.ByteArrayToStructureLittleEndian(rootDir, rootOff, + Marshal.ByteArrayToStructureLittleEndian(rootDir, + rootOff, Marshal.SizeOf()); int saOff = Marshal.SizeOf() + record.name_len; @@ -344,8 +329,7 @@ public sealed partial class ISO9660 } } - if(saOff + 2 >= saLen) - break; + if(saOff + 2 >= saLen) break; var nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); @@ -426,9 +410,16 @@ public sealed partial class ISO9660 break; } - rrip |= nextSignature is RRIP_MAGIC or RRIP_POSIX_ATTRIBUTES or RRIP_POSIX_DEV_NO - or RRIP_SYMLINK or RRIP_NAME or RRIP_CHILDLINK or RRIP_PARENTLINK - or RRIP_RELOCATED_DIR or RRIP_TIMESTAMPS or RRIP_SPARSE; + rrip |= nextSignature is RRIP_MAGIC + or RRIP_POSIX_ATTRIBUTES + or RRIP_POSIX_DEV_NO + or RRIP_SYMLINK + or RRIP_NAME + or RRIP_CHILDLINK + or RRIP_PARENTLINK + or RRIP_RELOCATED_DIR + or RRIP_TIMESTAMPS + or RRIP_SPARSE; ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; @@ -438,22 +429,19 @@ public sealed partial class ISO9660 saOff += sa[saOff + 2]; - if(nextSignature == SUSP_TERMINATOR) - break; + if(nextSignature == SUSP_TERMINATOR) break; } break; } - if(noneFound) - break; + if(noneFound) break; } } rootOff += record.length; - if(record.length == 0) - break; + if(record.length == 0) break; } foreach(ContinuationArea ca in contareas) @@ -468,8 +456,7 @@ public sealed partial class ISO9660 errno = imagePlugin.ReadSectors(ca.block_be, caLen, out byte[] caSectors); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var caData = new byte[ca.ca_length_be]; Array.Copy(caSectors, ca.offset_be, caData, 0, ca.ca_length_be); @@ -497,9 +484,16 @@ public sealed partial class ISO9660 break; } - rrip |= nextSignature is RRIP_MAGIC or RRIP_POSIX_ATTRIBUTES or RRIP_POSIX_DEV_NO or RRIP_SYMLINK - or RRIP_NAME or RRIP_CHILDLINK or RRIP_PARENTLINK or RRIP_RELOCATED_DIR - or RRIP_TIMESTAMPS or RRIP_SPARSE; + rrip |= nextSignature is RRIP_MAGIC + or RRIP_POSIX_ATTRIBUTES + or RRIP_POSIX_DEV_NO + or RRIP_SYMLINK + or RRIP_NAME + or RRIP_CHILDLINK + or RRIP_PARENTLINK + or RRIP_RELOCATED_DIR + or RRIP_TIMESTAMPS + or RRIP_SPARSE; ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; @@ -526,8 +520,8 @@ public sealed partial class ISO9660 string extDes = encoding.GetString(erb, Marshal.SizeOf() + er.id_len, er.des_len); - string extSrc = encoding.GetString(erb, Marshal.SizeOf() + er.id_len + er.des_len, - er.src_len); + string extSrc = + encoding.GetString(erb, Marshal.SizeOf() + er.id_len + er.des_len, er.src_len); suspInformation.AppendFormat(Localization.Extension_0, counter).AppendLine(); suspInformation.AppendFormat("\t" + Localization.ID_0_version_1, extId, er.ext_ver).AppendLine(); @@ -539,8 +533,7 @@ public sealed partial class ISO9660 errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ipbinSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; CD.IPBin? segaCd = CD.DecodeIPBin(ipbinSector); Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); @@ -553,35 +546,25 @@ public sealed partial class ISO9660 else isoMetadata.AppendLine(Localization.ISO9660_file_system); - if(xaExtensions) - isoMetadata.AppendLine(Localization.CD_ROM_XA_extensions_present); + if(xaExtensions) isoMetadata.AppendLine(Localization.CD_ROM_XA_extensions_present); - if(amiga) - isoMetadata.AppendLine(Localization.Amiga_extensions_present); + if(amiga) isoMetadata.AppendLine(Localization.Amiga_extensions_present); - if(apple) - isoMetadata.AppendLine(Localization.Apple_extensions_present); + if(apple) isoMetadata.AppendLine(Localization.Apple_extensions_present); - if(jolietvd != null) - isoMetadata.AppendLine(Localization.Joliet_extensions_present); + if(jolietvd != null) isoMetadata.AppendLine(Localization.Joliet_extensions_present); - if(susp) - isoMetadata.AppendLine(Localization.System_Use_Sharing_Protocol_present); + if(susp) isoMetadata.AppendLine(Localization.System_Use_Sharing_Protocol_present); - if(rrip) - isoMetadata.AppendLine(Localization.Rock_Ridge_Interchange_Protocol_present); + if(rrip) isoMetadata.AppendLine(Localization.Rock_Ridge_Interchange_Protocol_present); - if(aaip) - isoMetadata.AppendLine(Localization.Arbitrary_Attribute_Interchange_Protocol_present); + if(aaip) isoMetadata.AppendLine(Localization.Arbitrary_Attribute_Interchange_Protocol_present); - if(ziso) - isoMetadata.AppendLine(Localization.zisofs_compression_present); + if(ziso) isoMetadata.AppendLine(Localization.zisofs_compression_present); - if(evd) - isoMetadata.AppendLine(Localization.Contains_Enhanced_Volume_Descriptor); + if(evd) isoMetadata.AppendLine(Localization.Contains_Enhanced_Volume_Descriptor); - if(vpd) - isoMetadata.AppendLine(Localization.Contains_Volume_Partition_Descriptor); + if(vpd) isoMetadata.AppendLine(Localization.Contains_Volume_Partition_Descriptor); if(bvd != null) isoMetadata.AppendFormat(Localization.Disc_bootable_following_0_specifications, bootSpec).AppendLine(); @@ -622,8 +605,8 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat(Localization.Volume_set_identifier_0, decodedVd.VolumeSetIdentifier).AppendLine(); isoMetadata.AppendFormat(Localization.Publisher_identifier_0, decodedVd.PublisherIdentifier).AppendLine(); - isoMetadata.AppendFormat(Localization.Data_preparer_identifier_0, decodedVd.DataPreparerIdentifier). - AppendLine(); + isoMetadata.AppendFormat(Localization.Data_preparer_identifier_0, decodedVd.DataPreparerIdentifier) + .AppendLine(); isoMetadata.AppendFormat(Localization.Application_identifier_0, decodedVd.ApplicationIdentifier).AppendLine(); isoMetadata.AppendFormat(Localization.Volume_creation_date_0, decodedVd.CreationTime).AppendLine(); @@ -643,9 +626,10 @@ public sealed partial class ISO9660 else isoMetadata.AppendFormat(Localization.Volume_has_always_been_effective).AppendLine(); - isoMetadata. - AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, decodedVd.Blocks, decodedVd.BlockSize). - AppendLine(); + isoMetadata.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, + decodedVd.Blocks, + decodedVd.BlockSize) + .AppendLine(); if(jolietvd != null) { @@ -655,40 +639,40 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat(Localization.System_identifier_0, decodedJolietVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat(Localization.Volume_identifier_0, decodedJolietVd.VolumeIdentifier).AppendLine(); - isoMetadata.AppendFormat(Localization.Volume_set_identifier_0, decodedJolietVd.VolumeSetIdentifier). - AppendLine(); + isoMetadata.AppendFormat(Localization.Volume_set_identifier_0, decodedJolietVd.VolumeSetIdentifier) + .AppendLine(); - isoMetadata.AppendFormat(Localization.Publisher_identifier_0, decodedJolietVd.PublisherIdentifier). - AppendLine(); + isoMetadata.AppendFormat(Localization.Publisher_identifier_0, decodedJolietVd.PublisherIdentifier) + .AppendLine(); - isoMetadata.AppendFormat(Localization.Data_preparer_identifier_0, decodedJolietVd.DataPreparerIdentifier). - AppendLine(); + isoMetadata.AppendFormat(Localization.Data_preparer_identifier_0, decodedJolietVd.DataPreparerIdentifier) + .AppendLine(); - isoMetadata.AppendFormat(Localization.Application_identifier_0, decodedJolietVd.ApplicationIdentifier). - AppendLine(); + isoMetadata.AppendFormat(Localization.Application_identifier_0, decodedJolietVd.ApplicationIdentifier) + .AppendLine(); isoMetadata.AppendFormat(Localization.Volume_creation_date_0, decodedJolietVd.CreationTime).AppendLine(); if(decodedJolietVd.HasModificationTime) { - isoMetadata.AppendFormat(Localization.Volume_modification_date_0, decodedJolietVd.ModificationTime). - AppendLine(); + isoMetadata.AppendFormat(Localization.Volume_modification_date_0, decodedJolietVd.ModificationTime) + .AppendLine(); } else isoMetadata.AppendFormat(Localization.Volume_has_not_been_modified).AppendLine(); if(decodedJolietVd.HasExpirationTime) { - isoMetadata.AppendFormat(Localization.Volume_expiration_date_0, decodedJolietVd.ExpirationTime). - AppendLine(); + isoMetadata.AppendFormat(Localization.Volume_expiration_date_0, decodedJolietVd.ExpirationTime) + .AppendLine(); } else isoMetadata.AppendFormat(Localization.Volume_does_not_expire).AppendLine(); if(decodedJolietVd.HasEffectiveTime) { - isoMetadata.AppendFormat(Localization.Volume_effective_date_0, decodedJolietVd.EffectiveTime). - AppendLine(); + isoMetadata.AppendFormat(Localization.Volume_effective_date_0, decodedJolietVd.EffectiveTime) + .AppendLine(); } else isoMetadata.AppendFormat(Localization.Volume_has_always_been_effective).AppendLine(); @@ -698,25 +682,24 @@ public sealed partial class ISO9660 { errno = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start, out vdSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var toritoOff = 0; - if(vdSector[toritoOff] != 1) - goto exit_torito; + if(vdSector[toritoOff] != 1) goto exit_torito; ElToritoValidationEntry valentry = - Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + Marshal.ByteArrayToStructureLittleEndian(vdSector, + toritoOff, EL_TORITO_ENTRY_SIZE); - if(valentry.signature != EL_TORITO_MAGIC) - goto exit_torito; + if(valentry.signature != EL_TORITO_MAGIC) goto exit_torito; toritoOff = EL_TORITO_ENTRY_SIZE; ElToritoInitialEntry initialEntry = - Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + Marshal.ByteArrayToStructureLittleEndian(vdSector, + toritoOff, EL_TORITO_ENTRY_SIZE); initialEntry.boot_type = (ElToritoEmulation)((byte)initialEntry.boot_type & 0xF); @@ -729,7 +712,8 @@ public sealed partial class ISO9660 if(initialEntry.load_rba + partition.Start + initialEntry.sector_count - 1 <= partition.End) { - imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start, initialEntry.sector_count, + imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start, + initialEntry.sector_count, out bootImage); } @@ -739,28 +723,29 @@ public sealed partial class ISO9660 isoMetadata.AppendLine(Localization.Initial_entry); - isoMetadata.AppendFormat("\t" + Localization.Developer_ID_0, encoding.GetString(valentry.developer_id)). - AppendLine(); + isoMetadata.AppendFormat("\t" + Localization.Developer_ID_0, encoding.GetString(valentry.developer_id)) + .AppendLine(); if(initialEntry.bootable == ElToritoIndicator.Bootable) { isoMetadata.AppendFormat("\t" + Localization.Bootable_on_0, valentry.platform_id).AppendLine(); isoMetadata.AppendFormat("\t" + Localization.Bootable_image_starts_at_sector_0_and_runs_for_1_sectors, - initialEntry.load_rba, initialEntry.sector_count). - AppendLine(); + initialEntry.load_rba, + initialEntry.sector_count) + .AppendLine(); if(valentry.platform_id == ElToritoPlatform.x86) { isoMetadata.AppendFormat("\t" + Localization.Bootable_image_will_be_loaded_at_segment_0, - initialEntry.load_seg == 0 ? 0x7C0 : initialEntry.load_seg). - AppendLine(); + initialEntry.load_seg == 0 ? 0x7C0 : initialEntry.load_seg) + .AppendLine(); } else { isoMetadata.AppendFormat("\t" + Localization.Bootable_image_will_be_loaded_at_0, - (uint)initialEntry.load_seg * 10). - AppendLine(); + (uint)initialEntry.load_seg * 10) + .AppendLine(); } switch(initialEntry.boot_type) @@ -783,8 +768,8 @@ public sealed partial class ISO9660 break; default: isoMetadata.AppendFormat("\t" + Localization.Image_uses_unknown_emulation_type_0, - (byte)initialEntry.boot_type). - AppendLine(); + (byte)initialEntry.boot_type) + .AppendLine(); break; } @@ -793,9 +778,9 @@ public sealed partial class ISO9660 if(bootImage != null) { - isoMetadata. - AppendFormat("\t" + Localization.Bootable_image_SHA1_0, Sha1Context.Data(bootImage, out _)). - AppendLine(); + isoMetadata.AppendFormat("\t" + Localization.Bootable_image_SHA1_0, + Sha1Context.Data(bootImage, out _)) + .AppendLine(); } } else @@ -810,23 +795,24 @@ public sealed partial class ISO9660 vdSector[toritoOff] == (byte)ElToritoIndicator.LastHeader)) { ElToritoSectionHeaderEntry sectionHeader = - Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + Marshal.ByteArrayToStructureLittleEndian(vdSector, + toritoOff, EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; isoMetadata.AppendFormat(Localization.Boot_section_0, sectionCounter); - isoMetadata. - AppendFormat("\t" + Localization.Section_ID_0, encoding.GetString(sectionHeader.identifier)). - AppendLine(); + isoMetadata.AppendFormat("\t" + Localization.Section_ID_0, encoding.GetString(sectionHeader.identifier)) + .AppendLine(); for(var entryCounter = 1; entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length; entryCounter++) { ElToritoSectionEntry sectionEntry = - Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + Marshal.ByteArrayToStructureLittleEndian(vdSector, + toritoOff, EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; @@ -839,29 +825,31 @@ public sealed partial class ISO9660 if(sectionEntry.load_rba + partition.Start + sectionEntry.sector_count - 1 <= partition.End) { - imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, sectionEntry.sector_count, + imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, + sectionEntry.sector_count, out bootImage); } - isoMetadata.AppendFormat("\t\t" + Localization.Bootable_on_0, sectionHeader.platform_id). - AppendLine(); + isoMetadata.AppendFormat("\t\t" + Localization.Bootable_on_0, sectionHeader.platform_id) + .AppendLine(); - isoMetadata. - AppendFormat("\t\t" + Localization.Bootable_image_starts_at_sector_0_and_runs_for_1_sectors, - sectionEntry.load_rba, sectionEntry.sector_count). - AppendLine(); + isoMetadata + .AppendFormat("\t\t" + Localization.Bootable_image_starts_at_sector_0_and_runs_for_1_sectors, + sectionEntry.load_rba, + sectionEntry.sector_count) + .AppendLine(); if(valentry.platform_id == ElToritoPlatform.x86) { isoMetadata.AppendFormat("\t\t" + Localization.Bootable_image_will_be_loaded_at_segment_0, - sectionEntry.load_seg == 0 ? 0x7C0 : sectionEntry.load_seg). - AppendLine(); + sectionEntry.load_seg == 0 ? 0x7C0 : sectionEntry.load_seg) + .AppendLine(); } else { isoMetadata.AppendFormat("\t\t" + Localization.Bootable_image_will_be_loaded_at_0, - (uint)sectionEntry.load_seg * 10). - AppendLine(); + (uint)sectionEntry.load_seg * 10) + .AppendLine(); } switch((ElToritoEmulation)((byte)sectionEntry.boot_type & 0xF)) @@ -887,24 +875,24 @@ public sealed partial class ISO9660 break; default: isoMetadata.AppendFormat("\t\t" + Localization.Image_uses_unknown_emulation_type_0, - (byte)initialEntry.boot_type). - AppendLine(); + (byte)initialEntry.boot_type) + .AppendLine(); break; } isoMetadata.AppendFormat("\t\t" + Localization.Selection_criteria_type_0, - sectionEntry.selection_criteria_type). - AppendLine(); + sectionEntry.selection_criteria_type) + .AppendLine(); - isoMetadata.AppendFormat("\t\t" + Localization.System_type_0, sectionEntry.system_type). - AppendLine(); + isoMetadata.AppendFormat("\t\t" + Localization.System_type_0, sectionEntry.system_type) + .AppendLine(); if(bootImage != null) { isoMetadata.AppendFormat("\t\t" + Localization.Bootable_image_SHA1_0, - Sha1Context.Data(bootImage, out _)). - AppendLine(); + Sha1Context.Data(bootImage, out _)) + .AppendLine(); } } else @@ -918,31 +906,28 @@ public sealed partial class ISO9660 if(flags.HasFlag(ElToritoFlags.SCSI)) isoMetadata.AppendLine("\t\t" + Localization.Image_contains_SCSI_drivers); - if(!flags.HasFlag(ElToritoFlags.Continued)) - continue; + if(!flags.HasFlag(ElToritoFlags.Continued)) continue; while(toritoOff < vdSector.Length) { ElToritoSectionEntryExtension sectionExtension = - Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + Marshal.ByteArrayToStructureLittleEndian(vdSector, + toritoOff, EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; - if(!sectionExtension.extension_flags.HasFlag(ElToritoFlags.Continued)) - break; + if(!sectionExtension.extension_flags.HasFlag(ElToritoFlags.Continued)) break; } } - if(sectionHeader.header_id == ElToritoIndicator.LastHeader) - break; + if(sectionHeader.header_id == ElToritoIndicator.LastHeader) break; } } exit_torito: - if(refareas.Count > 0) - isoMetadata.Append(suspInformation); + if(refareas.Count > 0) isoMetadata.Append(suspInformation); if(highSierraInfo) metadata.Type = FS_TYPE_HSF; @@ -1007,14 +992,11 @@ public sealed partial class ISO9660 metadata.CreationDate = decodedJolietVd.CreationTime; - if(decodedJolietVd.HasModificationTime) - metadata.ModificationDate = decodedJolietVd.ModificationTime; + if(decodedJolietVd.HasModificationTime) metadata.ModificationDate = decodedJolietVd.ModificationTime; - if(decodedJolietVd.HasExpirationTime) - metadata.ExpirationDate = decodedJolietVd.ExpirationTime; + if(decodedJolietVd.HasExpirationTime) metadata.ExpirationDate = decodedJolietVd.ExpirationTime; - if(decodedJolietVd.HasEffectiveTime) - metadata.EffectiveDate = decodedJolietVd.EffectiveTime; + if(decodedJolietVd.HasEffectiveTime) metadata.EffectiveDate = decodedJolietVd.EffectiveTime; } else { @@ -1026,14 +1008,11 @@ public sealed partial class ISO9660 metadata.ApplicationIdentifier = decodedVd.ApplicationIdentifier; metadata.CreationDate = decodedVd.CreationTime; - if(decodedVd.HasModificationTime) - metadata.ModificationDate = decodedVd.ModificationTime; + if(decodedVd.HasModificationTime) metadata.ModificationDate = decodedVd.ModificationTime; - if(decodedVd.HasExpirationTime) - metadata.ExpirationDate = decodedVd.ExpirationTime; + if(decodedVd.HasExpirationTime) metadata.ExpirationDate = decodedVd.ExpirationTime; - if(decodedVd.HasEffectiveTime) - metadata.EffectiveDate = decodedVd.EffectiveTime; + if(decodedVd.HasEffectiveTime) metadata.EffectiveDate = decodedVd.EffectiveTime; } metadata.Bootable |= bvd != null || segaCd != null || saturn != null || dreamcast != null; diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs index 93ce453f3..86a5fff5c 100644 --- a/Aaru.Filesystems/ISO9660/Mode2.cs +++ b/Aaru.Filesystems/ISO9660/Mode2.cs @@ -48,8 +48,7 @@ public sealed partial class ISO9660 uint sectorCount = (uint)_blockSize / 2048; - if(_blockSize % 2048 > 0) - sectorCount++; + if(_blockSize % 2048 > 0) sectorCount++; ulong realSector = sector * _blockSize / 2048; @@ -61,11 +60,9 @@ public sealed partial class ISO9660 { errno = _image.ReadSectorLong(realSector, out data); - if(errno != ErrorNumber.NoError) - errno = _image.ReadSector(realSector, out data); + if(errno != ErrorNumber.NoError) errno = _image.ReadSector(realSector, out data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; if(_debug) { @@ -78,17 +75,21 @@ public sealed partial class ISO9660 break; case 2324: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.tor_Sector_0_Cooked_Mode_two_Form_two, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.tor_Sector_0_Cooked_Mode_two_Form_two, realSector); break; case 2336: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5, + Localization + .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5, realSector, - ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1, data[0], - data[1], (Mode2Submode)data[2], data[3]); + ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1, + data[0], + data[1], + (Mode2Submode)data[2], + data[3]); break; case 2352 when data[0] != 0x00 || @@ -107,17 +108,28 @@ public sealed partial class ISO9660 break; case 2352 when data[15] != 2: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.tor_Sector_0_1_2_3_Raw_Mode_4, realSector, - data[12], data[13], data[14], data[15]); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.tor_Sector_0_1_2_3_Raw_Mode_4, + realSector, + data[12], + data[13], + data[14], + data[15]); break; case 2352: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8, - realSector, data[12], data[13], data[14], + Localization + .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8, + realSector, + data[12], + data[13], + data[14], ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1, - data[16], data[17], (Mode2Submode)data[18], data[19]); + data[16], + data[17], + (Mode2Submode)data[18], + data[19]); break; } @@ -147,11 +159,9 @@ public sealed partial class ISO9660 errno = _image.ReadSectorLong(dstSector, out data); - if(errno != ErrorNumber.NoError) - errno = _image.ReadSector(dstSector, out data); + if(errno != ErrorNumber.NoError) errno = _image.ReadSector(dstSector, out data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; if(_debug) { @@ -164,17 +174,21 @@ public sealed partial class ISO9660 break; case 2324: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.tor_Sector_0_Cooked_Mode_two_Form_two, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.tor_Sector_0_Cooked_Mode_two_Form_two, dstSector); break; case 2336: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5, + Localization + .tor_Sector_0_Cooked_Mode_two_Form_1_File_Number_2_Channel_Number_3_Submode_4_Coding_Information_5, dstSector, ((Mode2Submode)data[2]).HasFlag(Mode2Submode.Form2) ? 2 : 1, - data[0], data[1], (Mode2Submode)data[2], data[3]); + data[0], + data[1], + (Mode2Submode)data[2], + data[3]); break; case 2352 when data[0] != 0x00 || @@ -193,17 +207,28 @@ public sealed partial class ISO9660 break; case 2352 when data[15] != 2: - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.tor_Sector_0_1_2_3_Raw_Mode_4, - dstSector, data[12], data[13], data[14], data[15]); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.tor_Sector_0_1_2_3_Raw_Mode_4, + dstSector, + data[12], + data[13], + data[14], + data[15]); break; case 2352: AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8, - dstSector, data[12], data[13], data[14], + Localization + .tor_Sector_0_1_2_3_Raw_Mode_two_Form_4_File_Number_5_Channel_Number_6_Submode_7_Coding_Information_8, + dstSector, + data[12], + data[13], + data[14], ((Mode2Submode)data[18]).HasFlag(Mode2Submode.Form2) ? 2 : 1, - data[16], data[17], (Mode2Submode)data[18], data[19]); + data[16], + data[17], + (Mode2Submode)data[18], + data[19]); break; } diff --git a/Aaru.Filesystems/ISO9660/PathTable.cs b/Aaru.Filesystems/ISO9660/PathTable.cs index 6bf6930b9..036726ac0 100644 --- a/Aaru.Filesystems/ISO9660/PathTable.cs +++ b/Aaru.Filesystems/ISO9660/PathTable.cs @@ -36,8 +36,7 @@ public sealed partial class ISO9660 { PathTableEntryInternal[] DecodePathTable(byte[] data) { - if(data is null || data.Length == 0) - return null; + if(data is null || data.Length == 0) return null; List table = new(); @@ -56,8 +55,7 @@ public sealed partial class ISO9660 { entry = Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); - if(entry.name_len == 0) - break; + if(entry.name_len == 0) break; off += Marshal.SizeOf(); @@ -73,8 +71,7 @@ public sealed partial class ISO9660 off += entry.name_len; - if(entry.name_len % 2 != 0) - off++; + if(entry.name_len % 2 != 0) off++; } return table.ToArray(); @@ -82,8 +79,7 @@ public sealed partial class ISO9660 PathTableEntryInternal[] DecodeHighSierraPathTable(byte[] data) { - if(data is null) - return null; + if(data is null) return null; List table = new(); @@ -92,13 +88,13 @@ public sealed partial class ISO9660 while(off < data.Length) { HighSierraPathTableEntry entry = - Marshal.ByteArrayToStructureBigEndian(data, off, - Marshal. - SizeOf< + Marshal.ByteArrayToStructureBigEndian(data, + off, + Marshal + .SizeOf< HighSierraPathTableEntry>()); - if(entry.name_len == 0) - break; + if(entry.name_len == 0) break; off += Marshal.SizeOf(); @@ -114,8 +110,7 @@ public sealed partial class ISO9660 off += entry.name_len; - if(entry.name_len % 2 != 0) - off++; + if(entry.name_len % 2 != 0) off++; } return table.ToArray(); diff --git a/Aaru.Filesystems/ISO9660/Structs/Internal.cs b/Aaru.Filesystems/ISO9660/Structs/Internal.cs index 803a599d0..7b1633d2e 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Internal.cs @@ -109,12 +109,12 @@ public sealed partial class ISO9660 internal DecodedDirectoryEntry[] Entries; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -125,7 +125,7 @@ public sealed partial class ISO9660 { internal DecodedDirectoryEntry Dentry; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -136,7 +136,7 @@ public sealed partial class ISO9660 /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs index a509127ab..cf850da46 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs @@ -41,18 +41,15 @@ public sealed partial class ISO9660 { SystemIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.system_id).Replace('\u0000', ' ').TrimEnd(), VolumeIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.volume_id).Replace('\u0000', ' ').TrimEnd(), - VolumeSetIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.volume_set_id). - Replace('\u0000', ' '). - TrimEnd(), - PublisherIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.publisher_id). - Replace('\u0000', ' '). - TrimEnd(), - DataPreparerIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.preparer_id). - Replace('\u0000', ' '). - TrimEnd(), - ApplicationIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.application_id). - Replace('\u0000', ' '). - TrimEnd() + VolumeSetIdentifier = + Encoding.BigEndianUnicode.GetString(jolietvd.volume_set_id).Replace('\u0000', ' ').TrimEnd(), + PublisherIdentifier = + Encoding.BigEndianUnicode.GetString(jolietvd.publisher_id).Replace('\u0000', ' ').TrimEnd(), + DataPreparerIdentifier = + Encoding.BigEndianUnicode.GetString(jolietvd.preparer_id).Replace('\u0000', ' ').TrimEnd(), + ApplicationIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.application_id) + .Replace('\u0000', ' ') + .TrimEnd() }; if(jolietvd.creation_date[0] < 0x31 || jolietvd.creation_date[0] > 0x39) diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 1f56901fb..ae28ccd19 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -59,8 +59,7 @@ public sealed partial class ISO9660 options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); if(options.TryGetValue("use_path_table", out string usePathTableString)) bool.TryParse(usePathTableString, out _usePathTable); @@ -68,8 +67,7 @@ public sealed partial class ISO9660 if(options.TryGetValue("use_trans_tbl", out string useTransTblString)) bool.TryParse(useTransTblString, out _useTransTbl); - if(options.TryGetValue("use_evd", out string useEvdString)) - bool.TryParse(useEvdString, out _useEvd); + if(options.TryGetValue("use_evd", out string useEvdString)) bool.TryParse(useEvdString, out _useEvd); // Default namespace @namespace ??= "joliet"; @@ -107,27 +105,23 @@ public sealed partial class ISO9660 FileStructureVolumeDescriptor? fsvd = null; // ISO9660 is designed for 2048 bytes/sector devices - if(imagePlugin.Info.SectorSize < 2048) - return ErrorNumber.InvalidArgument; + if(imagePlugin.Info.SectorSize < 2048) return ErrorNumber.InvalidArgument; // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. - if(partition.End < 16) - return ErrorNumber.InvalidArgument; + if(partition.End < 16) return ErrorNumber.InvalidArgument; ulong counter = 0; ErrorNumber errno = imagePlugin.ReadSector(16 + partition.Start, out byte[] vdSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); _highSierra = _encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; var hsOff = 0; - if(_highSierra) - hsOff = 8; + if(_highSierra) hsOff = 8; _cdi = false; List bvdSectors = new(); @@ -144,8 +138,7 @@ public sealed partial class ISO9660 AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reading_sector_0, 16 + counter + partition.Start); errno = imagePlugin.ReadSector(16 + counter + partition.Start, out byte[] vdSectorTmp); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; vdSector = new byte[vdSectorTmp.Length - xaOff]; Array.Copy(vdSectorTmp, xaOff, vdSector, 0, vdSector.Length); @@ -155,8 +148,7 @@ public sealed partial class ISO9660 if(vdType == 255) // Supposedly we are in the PVD. { - if(counter == 0) - return ErrorNumber.InvalidArgument; + if(counter == 0) return ErrorNumber.InvalidArgument; break; } @@ -168,8 +160,7 @@ public sealed partial class ISO9660 _encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && _encoding.GetString(vdMagic) != CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { - if(counter == 0) - return ErrorNumber.InvalidArgument; + if(counter == 0) return ErrorNumber.InvalidArgument; break; } @@ -180,8 +171,7 @@ public sealed partial class ISO9660 { case 0: { - if(_debug) - bvdSectors.Add(16 + counter + partition.Start); + if(_debug) bvdSectors.Add(16 + counter + partition.Start); break; } @@ -195,8 +185,7 @@ public sealed partial class ISO9660 else pvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); - if(_debug) - pvdSectors.Add(16 + counter + partition.Start); + if(_debug) pvdSectors.Add(16 + counter + partition.Start); break; } @@ -223,13 +212,11 @@ public sealed partial class ISO9660 } } - if(_debug) - svdSectors.Add(16 + counter + partition.Start); + if(_debug) svdSectors.Add(16 + counter + partition.Start); } else { - if(_debug) - evdSectors.Add(16 + counter + partition.Start); + if(_debug) evdSectors.Add(16 + counter + partition.Start); if(_useEvd) { @@ -245,8 +232,7 @@ public sealed partial class ISO9660 case 3: { - if(_debug) - vpdSectors.Add(16 + counter + partition.Start); + if(_debug) vpdSectors.Add(16 + counter + partition.Start); break; } @@ -274,11 +260,9 @@ public sealed partial class ISO9660 else decodedVd = DecodeVolumeDescriptor(pvd.Value, _namespace == Namespace.Romeo ? _encoding : Encoding.ASCII); - if(jolietvd != null) - decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); + if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); - if(_namespace != Namespace.Romeo) - _encoding = Encoding.ASCII; + if(_namespace != Namespace.Romeo) _encoding = Encoding.ASCII; string fsFormat; byte[] pathTableData; @@ -292,11 +276,11 @@ public sealed partial class ISO9660 { _blockSize = hsvd.Value.logical_block_size; - errno = ReadSingleExtent(hsvd.Value.path_table_size, Swapping.Swap(hsvd.Value.mandatory_path_table_msb), + errno = ReadSingleExtent(hsvd.Value.path_table_size, + Swapping.Swap(hsvd.Value.mandatory_path_table_msb), out pathTableData); - if(errno != ErrorNumber.NoError) - pathTableData = null; + if(errno != ErrorNumber.NoError) pathTableData = null; fsFormat = FS_TYPE_HSF; @@ -309,8 +293,7 @@ public sealed partial class ISO9660 errno = ReadSingleExtent(fsvd.Value.path_table_size, fsvd.Value.path_table_addr, out pathTableData); - if(errno != ErrorNumber.NoError) - pathTableData = null; + if(errno != ErrorNumber.NoError) pathTableData = null; fsFormat = FS_TYPE_CDI; @@ -323,11 +306,11 @@ public sealed partial class ISO9660 { _blockSize = pvd.Value.logical_block_size; - errno = ReadSingleExtent(pvd.Value.path_table_size, Swapping.Swap(pvd.Value.type_m_path_table), + errno = ReadSingleExtent(pvd.Value.path_table_size, + Swapping.Swap(pvd.Value.type_m_path_table), out pathTableData); - if(errno != ErrorNumber.NoError) - pathTableData = null; + if(errno != ErrorNumber.NoError) pathTableData = null; fsFormat = FS_TYPE_ISO; @@ -348,8 +331,7 @@ public sealed partial class ISO9660 if((_highSierra || _cdi) && _namespace != Namespace.Normal && _namespace != Namespace.Vms) _namespace = Namespace.Normal; - if(jolietvd is null && _namespace == Namespace.Joliet) - _namespace = Namespace.Normal; + if(jolietvd is null && _namespace == Namespace.Joliet) _namespace = Namespace.Normal; uint rootLocation; uint rootSize; @@ -370,13 +352,12 @@ public sealed partial class ISO9660 if(_pathTable?.Length > 1 && rootLocation != _pathTable[0].Extent) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Path_table_and_PVD_do_not_point_to_the_same_location_for_the_root_directory); + Localization + .Path_table_and_PVD_do_not_point_to_the_same_location_for_the_root_directory); errno = ReadSector(rootLocation, out byte[] firstRootSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; var pvdWrongRoot = false; @@ -385,23 +366,21 @@ public sealed partial class ISO9660 HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); - if(rootEntry.extent != rootLocation) - pvdWrongRoot = true; + if(rootEntry.extent != rootLocation) pvdWrongRoot = true; } else { DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); - if(rootEntry.extent != rootLocation) - pvdWrongRoot = true; + if(rootEntry.extent != rootLocation) pvdWrongRoot = true; } if(pvdWrongRoot) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - PVD_does_not_point_to_correct_root_directory_checking_path_table); + Localization + .PVD_does_not_point_to_correct_root_directory_checking_path_table); var pathTableWrongRoot = false; @@ -414,16 +393,14 @@ public sealed partial class ISO9660 HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); - if(rootEntry.extent != rootLocation) - pathTableWrongRoot = true; + if(rootEntry.extent != rootLocation) pathTableWrongRoot = true; } else { DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); - if(rootEntry.extent != rootLocation) - pathTableWrongRoot = true; + if(rootEntry.extent != rootLocation) pathTableWrongRoot = true; } if(pathTableWrongRoot) @@ -443,8 +420,7 @@ public sealed partial class ISO9660 errno = ReadSector(rootLocation, out byte[] firstRootSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian(firstRootSector); @@ -455,8 +431,7 @@ public sealed partial class ISO9660 } // In case the path table is incomplete - if(_usePathTable && (_pathTable is null || _pathTable?.Length <= 1)) - _usePathTable = false; + if(_usePathTable && (_pathTable is null || _pathTable?.Length <= 1)) _usePathTable = false; if(_usePathTable && !_cdi) { @@ -464,8 +439,7 @@ public sealed partial class ISO9660 errno = ReadSector(rootLocation, out byte[] firstRootSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; if(_highSierra) { @@ -495,8 +469,7 @@ public sealed partial class ISO9660 errno = ReadSector(partition.Start, out byte[] ipbinSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; CD.IPBin? segaCd = CD.DecodeIPBin(ipbinSector); Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); @@ -509,14 +482,15 @@ public sealed partial class ISO9660 } // Cannot traverse path table if we substitute the names for the ones in TRANS.TBL - if(_useTransTbl) - _usePathTable = false; + if(_useTransTbl) _usePathTable = false; if(_namespace != Namespace.Joliet) { - _rootDirectoryCache = _cdi ? DecodeCdiDirectory(rootLocation + rootXattrLength, rootSize) : - _highSierra ? DecodeHighSierraDirectory(rootLocation + rootXattrLength, rootSize) : - DecodeIsoDirectory(rootLocation + rootXattrLength, rootSize); + _rootDirectoryCache = _cdi + ? DecodeCdiDirectory(rootLocation + rootXattrLength, rootSize) + : _highSierra + ? DecodeHighSierraDirectory(rootLocation + rootXattrLength, rootSize) + : DecodeIsoDirectory(rootLocation + rootXattrLength, rootSize); } Metadata.Type = fsFormat; @@ -586,14 +560,11 @@ public sealed partial class ISO9660 Metadata.CreationDate = decodedJolietVd.CreationTime; - if(decodedJolietVd.HasModificationTime) - Metadata.ModificationDate = decodedJolietVd.ModificationTime; + if(decodedJolietVd.HasModificationTime) Metadata.ModificationDate = decodedJolietVd.ModificationTime; - if(decodedJolietVd.HasExpirationTime) - Metadata.ExpirationDate = decodedJolietVd.ExpirationTime; + if(decodedJolietVd.HasExpirationTime) Metadata.ExpirationDate = decodedJolietVd.ExpirationTime; - if(decodedJolietVd.HasEffectiveTime) - Metadata.EffectiveDate = decodedJolietVd.EffectiveTime; + if(decodedJolietVd.HasEffectiveTime) Metadata.EffectiveDate = decodedJolietVd.EffectiveTime; decodedVd = decodedJolietVd; } @@ -607,164 +578,172 @@ public sealed partial class ISO9660 Metadata.ApplicationIdentifier = decodedVd.ApplicationIdentifier; Metadata.CreationDate = decodedVd.CreationTime; - if(decodedVd.HasModificationTime) - Metadata.ModificationDate = decodedVd.ModificationTime; + if(decodedVd.HasModificationTime) Metadata.ModificationDate = decodedVd.ModificationTime; - if(decodedVd.HasExpirationTime) - Metadata.ExpirationDate = decodedVd.ExpirationTime; + if(decodedVd.HasExpirationTime) Metadata.ExpirationDate = decodedVd.ExpirationTime; - if(decodedVd.HasEffectiveTime) - Metadata.EffectiveDate = decodedVd.EffectiveTime; + if(decodedVd.HasEffectiveTime) Metadata.EffectiveDate = decodedVd.EffectiveTime; } if(_debug) { - _rootDirectoryCache.Add("$", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - (rootLocation, rootSize) - }, - Filename = "$", - Size = rootSize, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + (rootLocation, rootSize) + }, + Filename = "$", + Size = rootSize, + Timestamp = decodedVd.CreationTime + }); if(!_cdi) { - _rootDirectoryCache.Add("$PATH_TABLE.LSB", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - (pathTableLsbLocation, (uint)pathTableData.Length) - }, - Filename = "$PATH_TABLE.LSB", - Size = (uint)pathTableData.Length, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$PATH_TABLE.LSB", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + (pathTableLsbLocation, (uint)pathTableData.Length) + }, + Filename = "$PATH_TABLE.LSB", + Size = (uint)pathTableData.Length, + Timestamp = decodedVd.CreationTime + }); } - _rootDirectoryCache.Add("$PATH_TABLE.MSB", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - (Swapping.Swap(pathTableMsbLocation), (uint)pathTableData.Length) - }, - Filename = "$PATH_TABLE.MSB", - Size = (uint)pathTableData.Length, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$PATH_TABLE.MSB", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + (Swapping.Swap(pathTableMsbLocation), (uint)pathTableData.Length) + }, + Filename = "$PATH_TABLE.MSB", + Size = (uint)pathTableData.Length, + Timestamp = decodedVd.CreationTime + }); for(var i = 0; i < bvdSectors.Count; i++) { - _rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)i, 2048) - }, - Filename = i == 0 ? "$BOOT" : $"$BOOT_{i}", - Size = 2048, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)i, 2048) + }, + Filename = i == 0 ? "$BOOT" : $"$BOOT_{i}", + Size = 2048, + Timestamp = decodedVd.CreationTime + }); } for(var i = 0; i < pvdSectors.Count; i++) { - _rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)i, 2048) - }, - Filename = i == 0 ? "$PVD" : $"PVD_{i}", - Size = 2048, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)i, 2048) + }, + Filename = i == 0 ? "$PVD" : $"PVD_{i}", + Size = 2048, + Timestamp = decodedVd.CreationTime + }); } for(var i = 0; i < svdSectors.Count; i++) { - _rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)i, 2048) - }, - Filename = i == 0 ? "$SVD" : $"$SVD_{i}", - Size = 2048, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)i, 2048) + }, + Filename = i == 0 ? "$SVD" : $"$SVD_{i}", + Size = 2048, + Timestamp = decodedVd.CreationTime + }); } for(var i = 0; i < evdSectors.Count; i++) { - _rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)i, 2048) - }, - Filename = i == 0 ? "$EVD" : $"$EVD_{i}", - Size = 2048, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)i, 2048) + }, + Filename = i == 0 ? "$EVD" : $"$EVD_{i}", + Size = 2048, + Timestamp = decodedVd.CreationTime + }); } for(var i = 0; i < vpdSectors.Count; i++) { - _rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)i, 2048) - }, - Filename = i == 0 ? "$VPD" : $"$VPD_{i}", - Size = 2048, - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)i, 2048) + }, + Filename = i == 0 ? "$VPD" : $"$VPD_{i}", + Size = 2048, + Timestamp = decodedVd.CreationTime + }); } if(segaCd != null) { - _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)partition.Start, (uint)Marshal.SizeOf()) - }, - Filename = "$IP.BIN", - Size = (uint)Marshal.SizeOf(), - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$IP.BIN", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)partition.Start, (uint)Marshal.SizeOf()) + }, + Filename = "$IP.BIN", + Size = (uint)Marshal.SizeOf(), + Timestamp = decodedVd.CreationTime + }); } if(saturn != null) { - _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)partition.Start, (uint)Marshal.SizeOf()) - }, - Filename = "$IP.BIN", - Size = (uint)Marshal.SizeOf(), - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$IP.BIN", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)partition.Start, (uint)Marshal.SizeOf()) + }, + Filename = "$IP.BIN", + Size = (uint)Marshal.SizeOf(), + Timestamp = decodedVd.CreationTime + }); } if(dreamcast != null) { - _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry - { - Extents = new List<(uint extent, uint size)> - { - ((uint)partition.Start, (uint)Marshal.SizeOf()) - }, - Filename = "$IP.BIN", - Size = (uint)Marshal.SizeOf(), - Timestamp = decodedVd.CreationTime - }); + _rootDirectoryCache.Add("$IP.BIN", + new DecodedDirectoryEntry + { + Extents = new List<(uint extent, uint size)> + { + ((uint)partition.Start, (uint)Marshal.SizeOf()) + }, + Filename = "$IP.BIN", + Size = (uint)Marshal.SizeOf(), + Timestamp = decodedVd.CreationTime + }); } } @@ -784,9 +763,11 @@ public sealed partial class ISO9660 if(_usePathTable) { - foreach(DecodedDirectoryEntry subDirectory in _cdi ? GetSubdirsFromCdiPathTable("") : - _highSierra ? GetSubdirsFromHighSierraPathTable("") : - GetSubdirsFromIsoPathTable("")) + foreach(DecodedDirectoryEntry subDirectory in _cdi + ? GetSubdirsFromCdiPathTable("") + : _highSierra + ? GetSubdirsFromHighSierraPathTable("") + : GetSubdirsFromIsoPathTable("")) _rootDirectoryCache[subDirectory.Filename] = subDirectory; } @@ -798,8 +779,7 @@ public sealed partial class ISO9660 /// public ErrorNumber Unmount() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _rootDirectoryCache = null; _directoryCache = null; @@ -813,8 +793,7 @@ public sealed partial class ISO9660 { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index 35c34e676..743f65810 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -47,50 +47,38 @@ public sealed partial class ISO9660 { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; xattrs = new List(); - if(entry.XattrLength > 0) - xattrs.Add("org.iso.9660.ea"); + if(entry.XattrLength > 0) xattrs.Add("org.iso.9660.ea"); - if(entry.AssociatedFile != null) - xattrs.Add("org.iso.9660.AssociatedFile"); + if(entry.AssociatedFile != null) xattrs.Add("org.iso.9660.AssociatedFile"); - if(entry.AppleDosType is not null) - xattrs.Add("com.apple.dos.type"); + if(entry.AppleDosType is not null) xattrs.Add("com.apple.dos.type"); - if(entry.AppleProDosType is not null) - xattrs.Add("com.apple.prodos.type"); + if(entry.AppleProDosType is not null) xattrs.Add("com.apple.prodos.type"); - if(entry.ResourceFork != null) - xattrs.Add("com.apple.ResourceFork"); + if(entry.ResourceFork != null) xattrs.Add("com.apple.ResourceFork"); - if(entry.FinderInfo != null) - xattrs.Add("com.apple.FinderInfo"); + if(entry.FinderInfo != null) xattrs.Add("com.apple.FinderInfo"); - if(entry.AppleIcon != null) - xattrs.Add("com.apple.Macintosh.Icon"); + if(entry.AppleIcon != null) xattrs.Add("com.apple.Macintosh.Icon"); - if(entry.AmigaComment != null) - xattrs.Add("com.amiga.comments"); + if(entry.AmigaComment != null) xattrs.Add("com.amiga.comments"); if(entry.Flags.HasFlag(FileFlags.Directory) || entry.Extents == null || entry.Extents.Count == 0) return ErrorNumber.NoError; ErrorNumber errno = _image.ReadSectorLong(entry.Extents[0].extent * _blockSize / 2048, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; - if(sector[15] != 2) - return ErrorNumber.NoError; + if(sector[15] != 2) return ErrorNumber.NoError; xattrs.Add("org.iso.mode2.subheader"); xattrs.Add("org.iso.mode2.subheader.copy"); @@ -103,36 +91,36 @@ public sealed partial class ISO9660 { buf = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; switch(xattr) { case "org.iso.9660.ea": - return entry.XattrLength == 0 ? ErrorNumber.NoSuchExtendedAttribute : - entry.Extents is null ? ErrorNumber.InvalidArgument : - ReadSingleExtent(entry.XattrLength * _blockSize, - entry.Extents[0].extent, - out buf); + return entry.XattrLength == 0 + ? ErrorNumber.NoSuchExtendedAttribute + : entry.Extents is null + ? ErrorNumber.InvalidArgument + : ReadSingleExtent(entry.XattrLength * _blockSize, entry.Extents[0].extent, out buf); case "org.iso.9660.AssociatedFile": - if(entry.AssociatedFile is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.AssociatedFile is null) return ErrorNumber.NoSuchExtendedAttribute; - if(entry.AssociatedFile.Extents is null) - return ErrorNumber.InvalidArgument; + if(entry.AssociatedFile.Extents is null) return ErrorNumber.InvalidArgument; if(entry.AssociatedFile.Size != 0) { - return ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents, + return ReadWithExtents(0, + (long)entry.AssociatedFile.Size, + entry.AssociatedFile.Extents, entry.AssociatedFile.XA?.signature == XA_MAGIC && entry.AssociatedFile.XA?.attributes.HasFlag(XaAttributes.Interleaved) == - true, entry.AssociatedFile.XA?.filenumber ?? 0, out buf); + true, + entry.AssociatedFile.XA?.filenumber ?? 0, + out buf); } buf = Array.Empty(); @@ -140,33 +128,32 @@ public sealed partial class ISO9660 return ErrorNumber.NoError; case "com.apple.dos.type": - if(entry.AppleDosType is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.AppleDosType is null) return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[1]; buf[0] = entry.AppleDosType.Value; return ErrorNumber.NoError; case "com.apple.prodos.type": - if(entry.AppleProDosType is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.AppleProDosType is null) return ErrorNumber.NoSuchExtendedAttribute; buf = BitConverter.GetBytes(entry.AppleProDosType.Value); return ErrorNumber.NoError; case "com.apple.ResourceFork": - if(entry.ResourceFork is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.ResourceFork is null) return ErrorNumber.NoSuchExtendedAttribute; - if(entry.ResourceFork.Extents is null) - return ErrorNumber.InvalidArgument; + if(entry.ResourceFork.Extents is null) return ErrorNumber.InvalidArgument; if(entry.ResourceFork.Size != 0) { - return ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents, + return ReadWithExtents(0, + (long)entry.ResourceFork.Size, + entry.ResourceFork.Extents, entry.ResourceFork.XA?.signature == XA_MAGIC && entry.ResourceFork.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, - entry.ResourceFork.XA?.filenumber ?? 0, out buf); + entry.ResourceFork.XA?.filenumber ?? 0, + out buf); } buf = Array.Empty(); @@ -174,23 +161,20 @@ public sealed partial class ISO9660 return ErrorNumber.NoError; case "com.apple.FinderInfo": - if(entry.FinderInfo is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.FinderInfo is null) return ErrorNumber.NoSuchExtendedAttribute; buf = Marshal.StructureToByteArrayBigEndian(entry.FinderInfo.Value); return ErrorNumber.NoError; case "com.apple.Macintosh.Icon": - if(entry.AppleIcon is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.AppleIcon is null) return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[entry.AppleIcon.Length]; Array.Copy(entry.AppleIcon, 0, buf, 0, entry.AppleIcon.Length); return ErrorNumber.NoError; case "com.amiga.comments": - if(entry.AmigaComment is null) - return ErrorNumber.NoSuchExtendedAttribute; + if(entry.AmigaComment is null) return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[entry.AmigaComment.Length]; Array.Copy(entry.AmigaComment, 0, buf, 0, entry.AmigaComment.Length); diff --git a/Aaru.Filesystems/JFS/Info.cs b/Aaru.Filesystems/JFS/Info.cs index 26a67f0e6..f60b6b037 100644 --- a/Aaru.Filesystems/JFS/Info.cs +++ b/Aaru.Filesystems/JFS/Info.cs @@ -48,16 +48,13 @@ public sealed partial class JFS { uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize; - if(partition.Start + bootSectors >= partition.End) - return false; + if(partition.Start + bootSectors >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < 512) - return false; + if(sector.Length < 512) return false; SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -75,11 +72,9 @@ public sealed partial class JFS uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < 512) - return; + if(sector.Length < 512) return; SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -88,81 +83,59 @@ public sealed partial class JFS sb.AppendFormat(Localization._0_blocks_of_1_bytes, jfsSb.s_size, jfsSb.s_bsize).AppendLine(); sb.AppendFormat(Localization._0_blocks_per_allocation_group, jfsSb.s_agsize).AppendLine(); - if(jfsSb.s_flags.HasFlag(Flags.Unicode)) - sb.AppendLine(Localization.Volume_uses_Unicode_for_directory_entries); + if(jfsSb.s_flags.HasFlag(Flags.Unicode)) sb.AppendLine(Localization.Volume_uses_Unicode_for_directory_entries); - if(jfsSb.s_flags.HasFlag(Flags.RemountRO)) - sb.AppendLine(Localization.Volume_remounts_read_only_on_error); + if(jfsSb.s_flags.HasFlag(Flags.RemountRO)) sb.AppendLine(Localization.Volume_remounts_read_only_on_error); - if(jfsSb.s_flags.HasFlag(Flags.Continue)) - sb.AppendLine(Localization.Volume_continues_on_error); + if(jfsSb.s_flags.HasFlag(Flags.Continue)) sb.AppendLine(Localization.Volume_continues_on_error); - if(jfsSb.s_flags.HasFlag(Flags.Panic)) - sb.AppendLine(Localization.Volume_panics_on_error); + if(jfsSb.s_flags.HasFlag(Flags.Panic)) sb.AppendLine(Localization.Volume_panics_on_error); - if(jfsSb.s_flags.HasFlag(Flags.UserQuota)) - sb.AppendLine(Localization.Volume_has_user_quotas_enabled); + if(jfsSb.s_flags.HasFlag(Flags.UserQuota)) sb.AppendLine(Localization.Volume_has_user_quotas_enabled); - if(jfsSb.s_flags.HasFlag(Flags.GroupQuota)) - sb.AppendLine(Localization.Volume_has_group_quotas_enabled); + if(jfsSb.s_flags.HasFlag(Flags.GroupQuota)) sb.AppendLine(Localization.Volume_has_group_quotas_enabled); - if(jfsSb.s_flags.HasFlag(Flags.NoJournal)) - sb.AppendLine(Localization.Volume_is_not_using_any_journal); + if(jfsSb.s_flags.HasFlag(Flags.NoJournal)) sb.AppendLine(Localization.Volume_is_not_using_any_journal); if(jfsSb.s_flags.HasFlag(Flags.Discard)) sb.AppendLine(Localization.Volume_sends_TRIM_UNMAP_commands_to_underlying_device); - if(jfsSb.s_flags.HasFlag(Flags.GroupCommit)) - sb.AppendLine(Localization.Volume_commits_in_groups_of_1); + if(jfsSb.s_flags.HasFlag(Flags.GroupCommit)) sb.AppendLine(Localization.Volume_commits_in_groups_of_1); - if(jfsSb.s_flags.HasFlag(Flags.LazyCommit)) - sb.AppendLine(Localization.Volume_commits_lazy); + if(jfsSb.s_flags.HasFlag(Flags.LazyCommit)) sb.AppendLine(Localization.Volume_commits_lazy); - if(jfsSb.s_flags.HasFlag(Flags.Temporary)) - sb.AppendLine(Localization.Volume_does_not_commit_to_log); + if(jfsSb.s_flags.HasFlag(Flags.Temporary)) sb.AppendLine(Localization.Volume_does_not_commit_to_log); - if(jfsSb.s_flags.HasFlag(Flags.InlineLog)) - sb.AppendLine(Localization.Volume_has_log_within_itself); + if(jfsSb.s_flags.HasFlag(Flags.InlineLog)) sb.AppendLine(Localization.Volume_has_log_within_itself); if(jfsSb.s_flags.HasFlag(Flags.InlineMoving)) sb.AppendLine(Localization.Volume_has_log_within_itself_and_is_moving_it_out); - if(jfsSb.s_flags.HasFlag(Flags.BadSAIT)) - sb.AppendLine(Localization.Volume_has_bad_current_secondary_ait); + if(jfsSb.s_flags.HasFlag(Flags.BadSAIT)) sb.AppendLine(Localization.Volume_has_bad_current_secondary_ait); - if(jfsSb.s_flags.HasFlag(Flags.Sparse)) - sb.AppendLine(Localization.Volume_supports_sparse_files); + if(jfsSb.s_flags.HasFlag(Flags.Sparse)) sb.AppendLine(Localization.Volume_supports_sparse_files); - if(jfsSb.s_flags.HasFlag(Flags.DASDEnabled)) - sb.AppendLine(Localization.Volume_has_DASD_limits_enabled); + if(jfsSb.s_flags.HasFlag(Flags.DASDEnabled)) sb.AppendLine(Localization.Volume_has_DASD_limits_enabled); - if(jfsSb.s_flags.HasFlag(Flags.DASDPrime)) - sb.AppendLine(Localization.Volume_primes_DASD_on_boot); + if(jfsSb.s_flags.HasFlag(Flags.DASDPrime)) sb.AppendLine(Localization.Volume_primes_DASD_on_boot); - if(jfsSb.s_flags.HasFlag(Flags.SwapBytes)) - sb.AppendLine(Localization.Volume_is_in_a_big_endian_system); + if(jfsSb.s_flags.HasFlag(Flags.SwapBytes)) sb.AppendLine(Localization.Volume_is_in_a_big_endian_system); - if(jfsSb.s_flags.HasFlag(Flags.DirIndex)) - sb.AppendLine(Localization.Volume_has_persistent_indexes); + if(jfsSb.s_flags.HasFlag(Flags.DirIndex)) sb.AppendLine(Localization.Volume_has_persistent_indexes); - if(jfsSb.s_flags.HasFlag(Flags.Linux)) - sb.AppendLine(Localization.Volume_supports_Linux); + if(jfsSb.s_flags.HasFlag(Flags.Linux)) sb.AppendLine(Localization.Volume_supports_Linux); - if(jfsSb.s_flags.HasFlag(Flags.DFS)) - sb.AppendLine(Localization.Volume_supports_DCE_DFS_LFS); + if(jfsSb.s_flags.HasFlag(Flags.DFS)) sb.AppendLine(Localization.Volume_supports_DCE_DFS_LFS); - if(jfsSb.s_flags.HasFlag(Flags.OS2)) - sb.AppendLine(Localization.Volume_supports_OS2_and_is_case_insensitive); + if(jfsSb.s_flags.HasFlag(Flags.OS2)) sb.AppendLine(Localization.Volume_supports_OS2_and_is_case_insensitive); - if(jfsSb.s_flags.HasFlag(Flags.AIX)) - sb.AppendLine(Localization.Volume_supports_AIX); + if(jfsSb.s_flags.HasFlag(Flags.AIX)) sb.AppendLine(Localization.Volume_supports_AIX); - if(jfsSb.s_state != 0) - sb.AppendLine(Localization.Volume_is_dirty); + if(jfsSb.s_state != 0) sb.AppendLine(Localization.Volume_is_dirty); sb.AppendFormat(Localization.Volume_was_last_updated_on_0_, - DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)) + .AppendLine(); if(jfsSb.s_version == 1) sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(jfsSb.s_fpack, encoding)).AppendLine(); @@ -182,8 +155,7 @@ public sealed partial class JFS ModificationDate = DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec) }; - if(jfsSb.s_state != 0) - metadata.Dirty = true; + if(jfsSb.s_state != 0) metadata.Dirty = true; information = sb.ToString(); } diff --git a/Aaru.Filesystems/LIF/Info.cs b/Aaru.Filesystems/LIF/Info.cs index 0d1bd675d..3092a4c07 100644 --- a/Aaru.Filesystems/LIF/Info.cs +++ b/Aaru.Filesystems/LIF/Info.cs @@ -46,13 +46,11 @@ public sealed partial class LIF /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 256) - return false; + if(imagePlugin.Info.SectorSize < 256) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_0_expected_1, lifSb.magic, LIF_MAGIC); @@ -68,18 +66,15 @@ public sealed partial class LIF information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 256) - return; + if(imagePlugin.Info.SectorSize < 256) return; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); - if(lifSb.magic != LIF_MAGIC) - return; + if(lifSb.magic != LIF_MAGIC) return; var sb = new StringBuilder(); diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs index b978a7858..4d7b4c5f8 100644 --- a/Aaru.Filesystems/LisaFS/Dir.cs +++ b/Aaru.Filesystems/LisaFS/Dir.cs @@ -60,11 +60,9 @@ public sealed partial class LisaFS node = null; ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; - if(!isDir) - return ErrorNumber.NotDirectory; + if(!isDir) return ErrorNumber.NotDirectory; /*List catalog; error = ReadCatalog(fileId, out catalog); @@ -102,17 +100,13 @@ public sealed partial class LisaFS { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not LisaDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; @@ -122,8 +116,7 @@ public sealed partial class LisaFS /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not LisaDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not LisaDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; @@ -146,8 +139,7 @@ public sealed partial class LisaFS { ErrorNumber errno; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _catalogCache = new List(); @@ -156,8 +148,7 @@ public sealed partial class LisaFS { ErrorNumber error = ReadFile((short)FILEID_CATALOG, out byte[] buf); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; var offset = 0; List catalogV2 = new(); @@ -191,8 +182,7 @@ public sealed partial class LisaFS { error = ReadExtentsFile(entV2.fileID, out ExtentFile ext); - if(error != ErrorNumber.NoError) - continue; + if(error != ErrorNumber.NoError) continue; var entV3 = new CatalogEntry { @@ -221,25 +211,21 @@ public sealed partial class LisaFS { errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out LisaTag.PriamTag catTag); - if(catTag.FileId != FILEID_CATALOG || catTag.RelPage != 0) - continue; + if(catTag.FileId != FILEID_CATALOG || catTag.RelPage != 0) continue; errno = _device.ReadSectors(i, 4, out firstCatalogBlock); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; break; } // Catalog not found - if(firstCatalogBlock == null) - return ErrorNumber.NoSuchFile; + if(firstCatalogBlock == null) return ErrorNumber.NoSuchFile; ulong prevCatalogPointer = BigEndianBitConverter.ToUInt32(firstCatalogBlock, 0x7F6); @@ -247,21 +233,20 @@ public sealed partial class LisaFS while(prevCatalogPointer != 0xFFFFFFFF) { errno = _device.ReadSectorTag(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, - SectorTagType.AppleSectorTag, out byte[] tag); + SectorTagType.AppleSectorTag, + out byte[] tag); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; DecodeTag(tag, out LisaTag.PriamTag prevTag); - if(prevTag.FileId != FILEID_CATALOG) - return ErrorNumber.InvalidArgument; + if(prevTag.FileId != FILEID_CATALOG) return ErrorNumber.InvalidArgument; - errno = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, 4, + errno = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, + 4, out firstCatalogBlock); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; prevCatalogPointer = BigEndianBitConverter.ToUInt32(firstCatalogBlock, 0x7F6); } @@ -277,21 +262,20 @@ public sealed partial class LisaFS while(nextCatalogPointer != 0xFFFFFFFF) { errno = _device.ReadSectorTag(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, - SectorTagType.AppleSectorTag, out byte[] tag); + SectorTagType.AppleSectorTag, + out byte[] tag); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; DecodeTag(tag, out LisaTag.PriamTag nextTag); - if(nextTag.FileId != FILEID_CATALOG) - return ErrorNumber.InvalidArgument; + if(nextTag.FileId != FILEID_CATALOG) return ErrorNumber.InvalidArgument; - errno = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, 4, + errno = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, + 4, out byte[] nextCatalogBlock); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; nextCatalogPointer = BigEndianBitConverter.ToUInt32(nextCatalogBlock, 0x7FA); catalogBlocks.Add(nextCatalogBlock); @@ -392,8 +376,7 @@ public sealed partial class LisaFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = new FileEntryInfo { diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index 36265c161..0871df2a1 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -45,24 +45,20 @@ public sealed partial class LisaFS file = new ExtentFile(); ErrorNumber errno; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(fileId < 4 || fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1) return ErrorNumber.InvalidArgument; - if(_extentCache.TryGetValue(fileId, out file)) - return ErrorNumber.NoError; + if(_extentCache.TryGetValue(fileId, out file)) return ErrorNumber.NoError; // A file ID that cannot be stored in the S-Records File - if(fileId >= _srecords.Length) - return ErrorNumber.InvalidArgument; + if(fileId >= _srecords.Length) return ErrorNumber.InvalidArgument; ulong ptr = _srecords[fileId].extent_ptr; // An invalid pointer denotes file does not exist - if(ptr is 0xFFFFFFFF or 0x00000000) - return ErrorNumber.NoSuchFile; + if(ptr is 0xFFFFFFFF or 0x00000000) return ErrorNumber.NoSuchFile; // Pointers are relative to MDDF ptr += _mddf.mddf_block + _volumePrefix; @@ -81,13 +77,11 @@ public sealed partial class LisaFS { errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out extTag); - if(extTag.FileId != fileId * -1) - continue; + if(extTag.FileId != fileId * -1) continue; ptr = i; found = true; @@ -95,30 +89,25 @@ public sealed partial class LisaFS break; } - if(!found) - return ErrorNumber.InvalidArgument; + if(!found) return ErrorNumber.InvalidArgument; } // Checks that the sector tag indicates its the Extents File we are searching for errno = _device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag, out tag); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; DecodeTag(tag, out extTag); - if(extTag.FileId != (short)(-1 * fileId)) - return ErrorNumber.NoSuchFile; + if(extTag.FileId != (short)(-1 * fileId)) return ErrorNumber.NoSuchFile; errno = _mddf.fsversion == LISA_V1 ? _device.ReadSectors(ptr, 2, out byte[] sector) : _device.ReadSector(ptr, out sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; - if(sector[0] >= 32 || sector[0] == 0) - return ErrorNumber.InvalidArgument; + if(sector[0] >= 32 || sector[0] == 0) return ErrorNumber.InvalidArgument; file.filenameLen = sector[0]; file.filename = new byte[file.filenameLen]; @@ -179,8 +168,7 @@ public sealed partial class LisaFS for(var j = 0; j < 41; j++) { - if(BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) == 0) - break; + if(BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) == 0) break; extentsCount++; } @@ -198,15 +186,15 @@ public sealed partial class LisaFS _extentCache.Add(fileId, file); - if(!_debug) - return ErrorNumber.NoError; + if(!_debug) return ErrorNumber.NoError; - if(_printedExtents.Contains(fileId)) - return ErrorNumber.NoError; + if(_printedExtents.Contains(fileId)) return ErrorNumber.NoError; AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].filenameLen = {1}", fileId, file.filenameLen); - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].filename = {1}", fileId, + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].filename = {1}", + fileId, StringHandlers.CToString(file.filename, _encoding)); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown1 = 0x{1:X4}", fileId, file.unknown1); @@ -231,9 +219,19 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown5 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" + - "{10:X2}{11:X2}", fileId, file.unknown5[0], file.unknown5[1], file.unknown5[2], - file.unknown5[3], file.unknown5[4], file.unknown5[5], file.unknown5[6], - file.unknown5[7], file.unknown5[8], file.unknown5[9], file.unknown5[10]); + "{10:X2}{11:X2}", + fileId, + file.unknown5[0], + file.unknown5[1], + file.unknown5[2], + file.unknown5[3], + file.unknown5[4], + file.unknown5[5], + file.unknown5[6], + file.unknown5[7], + file.unknown5[8], + file.unknown5[9], + file.unknown5[10]); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].release = {1}", fileId, file.release); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].build = {1}", fileId, file.build); @@ -243,34 +241,61 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].revision = {1}", fileId, file.revision); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown6 = 0x{1:X4}", fileId, file.unknown6); - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].password_valid = {1}", fileId, + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].password_valid = {1}", + fileId, file.password_valid > 0); - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].password = {1}", fileId, + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].password = {1}", + fileId, _encoding.GetString(file.password)); - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}", fileId, - file.unknown7[0], file.unknown7[1], file.unknown7[2]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}", + fileId, + file.unknown7[0], + file.unknown7[1], + file.unknown7[2]); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].overhead = {1}", fileId, file.overhead); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown8 = 0x{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}" + - "{10:X2}{11:X2}{12:X2}{13:X2}{14:X2}{15:X2}{16:X2}", fileId, file.unknown8[0], - file.unknown8[1], file.unknown8[2], file.unknown8[3], file.unknown8[4], - file.unknown8[5], file.unknown8[6], file.unknown8[7], file.unknown8[8], - file.unknown8[9], file.unknown8[10], file.unknown8[11], file.unknown8[12], - file.unknown8[13], file.unknown8[14], file.unknown8[15]); + "{10:X2}{11:X2}{12:X2}{13:X2}{14:X2}{15:X2}{16:X2}", + fileId, + file.unknown8[0], + file.unknown8[1], + file.unknown8[2], + file.unknown8[3], + file.unknown8[4], + file.unknown8[5], + file.unknown8[6], + file.unknown8[7], + file.unknown8[8], + file.unknown8[9], + file.unknown8[10], + file.unknown8[11], + file.unknown8[12], + file.unknown8[13], + file.unknown8[14], + file.unknown8[15]); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].length = {1}", fileId, file.length); AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].unknown9 = 0x{1:X8}", fileId, file.unknown9); for(var ext = 0; ext < file.extents.Length; ext++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].extents[{1}].start = {2}", fileId, ext, + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].extents[{1}].start = {2}", + fileId, + ext, file.extents[ext].start); - AaruConsole.DebugWriteLine(MODULE_NAME, "ExtentFile[{0}].extents[{1}].length = {2}", fileId, ext, + AaruConsole.DebugWriteLine(MODULE_NAME, + "ExtentFile[{0}].extents[{1}].length = {2}", + fileId, + ext, file.extents[ext].length); } @@ -284,15 +309,14 @@ public sealed partial class LisaFS /// Reads all the S-Records and caches it ErrorNumber ReadSRecords() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; // Searches the S-Records place using MDDF pointers - ErrorNumber errno = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix, _mddf.srec_len, + ErrorNumber errno = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix, + _mddf.srec_len, out byte[] sectors); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; // Each entry takes 14 bytes _srecords = new SRecord[sectors.Length / 14]; diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index b9223ac26..487eb04ba 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -47,11 +47,9 @@ public sealed partial class LisaFS ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; - if(!isDir) - return GetAttributes(fileId, out attributes); + if(!isDir) return GetAttributes(fileId, out attributes); attributes = FileAttributes.Directory; @@ -63,21 +61,17 @@ public sealed partial class LisaFS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; - if(isDir) - return ErrorNumber.IsDirectory; + if(isDir) return ErrorNumber.IsDirectory; error = Stat(fileId, out FileEntryInfo stat); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; node = new LisaFileNode { @@ -93,11 +87,9 @@ public sealed partial class LisaFS /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not LisaFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not LisaFileNode mynode) return ErrorNumber.InvalidArgument; return ErrorNumber.NoError; } @@ -107,19 +99,15 @@ public sealed partial class LisaFS { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not LisaFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not LisaFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; byte[] tmp; ErrorNumber error; @@ -166,8 +154,7 @@ public sealed partial class LisaFS stat = null; ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; return isDir ? StatDir(fileId, out stat) : Stat(fileId, out stat); } @@ -178,13 +165,11 @@ public sealed partial class LisaFS { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(fileId < 4) { - if(!_debug) - return ErrorNumber.NoSuchFile; + if(!_debug) return ErrorNumber.NoSuchFile; attributes = new FileAttributes(); attributes = FileAttributes.System; @@ -197,8 +182,7 @@ public sealed partial class LisaFS ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile extFile); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; switch(extFile.ftype) { @@ -224,14 +208,11 @@ public sealed partial class LisaFS break; } - if(extFile.protect > 0) - attributes |= FileAttributes.Immutable; + if(extFile.protect > 0) attributes |= FileAttributes.Immutable; - if(extFile.locked > 0) - attributes |= FileAttributes.ReadOnly; + if(extFile.locked > 0) attributes |= FileAttributes.ReadOnly; - if(extFile.password_valid > 0) - attributes |= FileAttributes.Password; + if(extFile.password_valid > 0) attributes |= FileAttributes.Password; return ErrorNumber.NoError; } @@ -243,17 +224,14 @@ public sealed partial class LisaFS buf = null; ErrorNumber errno; - if(!_mounted || !_debug) - return ErrorNumber.AccessDenied; + if(!_mounted || !_debug) return ErrorNumber.AccessDenied; if(fileId is > 4 or <= 0) { - if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) - return ErrorNumber.InvalidArgument; + if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return ErrorNumber.InvalidArgument; } - if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) - return ErrorNumber.NoError; + if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return ErrorNumber.NoError; var count = 0; @@ -263,16 +241,17 @@ public sealed partial class LisaFS { errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, out buf); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _systemFileCache.Add(fileId, buf); return ErrorNumber.NoError; } - errno = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, - SectorTagType.AppleSectorTag, out buf); + errno = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, + _mddf.srec_len, + SectorTagType.AppleSectorTag, + out buf); return errno != ErrorNumber.NoError ? errno : ErrorNumber.NoError; } @@ -284,17 +263,14 @@ public sealed partial class LisaFS { errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out sysTag); - if(sysTag.FileId == fileId) - count++; + if(sysTag.FileId == fileId) count++; } - if(count == 0) - return ErrorNumber.NoSuchFile; + if(count == 0) return ErrorNumber.NoSuchFile; buf = !tags ? new byte[count * _device.Info.SectorSize] : new byte[count * _devTagSize]; @@ -303,30 +279,25 @@ public sealed partial class LisaFS { errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out sysTag); - if(sysTag.FileId != fileId) - continue; + if(sysTag.FileId != fileId) continue; errno = !tags ? _device.ReadSector(i, out byte[] sector) : _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; // Relative block for $Loader starts at $Boot block - if(sysTag.FileId == FILEID_LOADER_SIGNED) - sysTag.RelPage--; + if(sysTag.FileId == FILEID_LOADER_SIGNED) sysTag.RelPage--; Array.Copy(sector, 0, buf, sector.Length * sysTag.RelPage, sector.Length); } - if(!tags) - _systemFileCache.Add(fileId, buf); + if(!tags) _systemFileCache.Add(fileId, buf); return ErrorNumber.NoError; } @@ -335,31 +306,27 @@ public sealed partial class LisaFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber error; ExtentFile file; if(fileId <= 4) { - if(!_debug || fileId == 0) - return ErrorNumber.NoSuchFile; + if(!_debug || fileId == 0) return ErrorNumber.NoSuchFile; stat = new FileEntryInfo(); error = GetAttributes(fileId, out FileAttributes attrs); stat.Attributes = attrs; - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; if(fileId < 0 && fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) { error = ReadExtentsFile((short)(fileId * -1), out file); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; stat.CreationTime = DateHandlers.LisaToDateTime(file.dtc); stat.AccessTime = DateHandlers.LisaToDateTime(file.dta); @@ -376,8 +343,7 @@ public sealed partial class LisaFS { error = ReadSystemFile(fileId, out byte[] buf); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; stat.CreationTime = fileId != 4 ? _mddf.dtvc : _mddf.dtcc; @@ -398,13 +364,11 @@ public sealed partial class LisaFS error = GetAttributes(fileId, out FileAttributes fileAttributes); stat.Attributes = fileAttributes; - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; error = ReadExtentsFile(fileId, out file); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; stat.CreationTime = DateHandlers.LisaToDateTime(file.dtc); stat.AccessTime = DateHandlers.LisaToDateTime(file.dta); @@ -431,21 +395,18 @@ public sealed partial class LisaFS { buf = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; tags &= _debug; if(fileId < 4 || fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1) return ErrorNumber.InvalidArgument; - if(!tags && _fileCache.TryGetValue(fileId, out buf)) - return ErrorNumber.NoError; + if(!tags && _fileCache.TryGetValue(fileId, out buf)) return ErrorNumber.NoError; ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; int sectorSize; @@ -461,16 +422,19 @@ public sealed partial class LisaFS for(var i = 0; i < file.extents.Length; i++) { ErrorNumber errno = !tags - ? _device. - ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, - (uint)file.extents[i].length, out byte[] sector) - : _device. - ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, - (uint)file.extents[i].length, SectorTagType.AppleSectorTag, - out sector); + ? _device.ReadSectors((ulong)file.extents[i].start + + _mddf.mddf_block + + _volumePrefix, + (uint)file.extents[i].length, + out byte[] sector) + : _device.ReadSectorsTag((ulong)file.extents[i].start + + _mddf.mddf_block + + _volumePrefix, + (uint)file.extents[i].length, + SectorTagType.AppleSectorTag, + out sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(sector, 0, temp, offset, sector.Length); offset += sector.Length; @@ -480,8 +444,7 @@ public sealed partial class LisaFS { if(_fileSizeCache.TryGetValue(fileId, out int realSize)) { - if(realSize > temp.Length) - AaruConsole.ErrorWriteLine(Localization.File_0_gets_truncated, fileId); + if(realSize > temp.Length) AaruConsole.ErrorWriteLine(Localization.File_0_gets_truncated, fileId); } buf = temp; @@ -499,13 +462,13 @@ public sealed partial class LisaFS fileId = 0; isDir = false; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); switch(pathElements.Length) { @@ -583,12 +546,10 @@ public sealed partial class LisaFS isDir = entry.fileType == 0x01; // Not last path element, and it's not a directory - if(lvl != pathElements.Length - 1 && !isDir) - return ErrorNumber.NotDirectory; + if(lvl != pathElements.Length - 1 && !isDir) return ErrorNumber.NotDirectory; // Arrived last path element - if(lvl == pathElements.Length - 1) - return ErrorNumber.NoError; + if(lvl == pathElements.Length - 1) return ErrorNumber.NoError; } } diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs index 2860bc9f2..b810a0135 100644 --- a/Aaru.Filesystems/LisaFS/Info.cs +++ b/Aaru.Filesystems/LisaFS/Info.cs @@ -47,12 +47,10 @@ public sealed partial class LisaFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) - return false; + if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) return false; // Minimal LisaOS disk is 3.5" single sided double density, 800 sectors - if(imagePlugin.Info.Sectors < 800) - return false; + if(imagePlugin.Info.Sectors < 800) return false; int beforeMddf = -1; @@ -61,23 +59,19 @@ public sealed partial class LisaFS { ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out LisaTag.PriamTag searchTag); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Sector_0_file_ID_1, i, searchTag.FileId); - if(beforeMddf == -1 && searchTag.FileId == FILEID_LOADER_SIGNED) - beforeMddf = i - 1; + if(beforeMddf == -1 && searchTag.FileId == FILEID_LOADER_SIGNED) beforeMddf = i - 1; - if(searchTag.FileId != FILEID_MDDF) - continue; + if(searchTag.FileId != FILEID_MDDF) continue; errno = imagePlugin.ReadSector((ulong)i, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; var infoMddf = new MDDF { @@ -95,30 +89,25 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.vol_size = {0} sectors", infoMddf.vol_size); AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.vol_size - 1 = {0}", infoMddf.volsize_minus_one); - AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.vol_size - mddf.mddf_block -1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mddf.vol_size - mddf.mddf_block -1 = {0}", infoMddf.volsize_minus_mddf_minus_one); AaruConsole.DebugWriteLine(MODULE_NAME, "Disk sector = {0} bytes", imagePlugin.Info.SectorSize); AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.blocksize = {0} bytes", infoMddf.blocksize); AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.datasize = {0} bytes", infoMddf.datasize); - if(infoMddf.mddf_block != i - beforeMddf) - return false; + if(infoMddf.mddf_block != i - beforeMddf) return false; - if(infoMddf.vol_size > imagePlugin.Info.Sectors) - return false; + if(infoMddf.vol_size > imagePlugin.Info.Sectors) return false; - if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one) - return false; + if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one) return false; - if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf) - return false; + if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf) return false; - if(infoMddf.datasize > infoMddf.blocksize) - return false; + if(infoMddf.datasize > infoMddf.blocksize) return false; - if(infoMddf.blocksize < imagePlugin.Info.SectorSize) - return false; + if(infoMddf.blocksize < imagePlugin.Info.SectorSize) return false; return infoMddf.datasize == imagePlugin.Info.SectorSize; } @@ -135,12 +124,10 @@ public sealed partial class LisaFS metadata = new FileSystem(); var sb = new StringBuilder(); - if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) - return; + if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) return; // Minimal LisaOS disk is 3.5" single sided double density, 800 sectors - if(imagePlugin.Info.Sectors < 800) - return; + if(imagePlugin.Info.Sectors < 800) return; int beforeMddf = -1; @@ -149,23 +136,19 @@ public sealed partial class LisaFS { ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out LisaTag.PriamTag searchTag); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Sector_0_file_ID_1, i, searchTag.FileId); - if(beforeMddf == -1 && searchTag.FileId == FILEID_LOADER_SIGNED) - beforeMddf = i - 1; + if(beforeMddf == -1 && searchTag.FileId == FILEID_LOADER_SIGNED) beforeMddf = i - 1; - if(searchTag.FileId != FILEID_MDDF) - continue; + if(searchTag.FileId != FILEID_MDDF) continue; errno = imagePlugin.ReadSector((ulong)i, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; var infoMddf = new MDDF(); var pString = new byte[33]; @@ -288,30 +271,24 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.unknown37 = 0x{0:X8} ({0})", infoMddf.unknown37); AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.unknown38 = 0x{0:X8} ({0})", infoMddf.unknown38); - AaruConsole.DebugWriteLine(MODULE_NAME, "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})", + AaruConsole.DebugWriteLine(MODULE_NAME, + "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})", infoMddf.unknown_timestamp, DateHandlers.LisaToDateTime(infoMddf.unknown_timestamp)); - if(infoMddf.mddf_block != i - beforeMddf) - return; + if(infoMddf.mddf_block != i - beforeMddf) return; - if(infoMddf.vol_size > imagePlugin.Info.Sectors) - return; + if(infoMddf.vol_size > imagePlugin.Info.Sectors) return; - if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one) - return; + if(infoMddf.vol_size - 1 != infoMddf.volsize_minus_one) return; - if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf) - return; + if(infoMddf.vol_size - i - 1 != infoMddf.volsize_minus_mddf_minus_one - beforeMddf) return; - if(infoMddf.datasize > infoMddf.blocksize) - return; + if(infoMddf.datasize > infoMddf.blocksize) return; - if(infoMddf.blocksize < imagePlugin.Info.SectorSize) - return; + if(infoMddf.blocksize < imagePlugin.Info.SectorSize) return; - if(infoMddf.datasize != imagePlugin.Info.SectorSize) - return; + if(infoMddf.datasize != imagePlugin.Info.SectorSize) return; switch(infoMddf.fsversion) { @@ -342,13 +319,12 @@ public sealed partial class LisaFS sb.AppendFormat(Localization.Volume_is_number_0_of_1, infoMddf.volnum, infoMddf.vol_sequence).AppendLine(); - sb.AppendFormat(Localization.Serial_number_of_Lisa_computer_that_created_this_volume_0, - infoMddf.machine_id). - AppendLine(); + sb.AppendFormat(Localization.Serial_number_of_Lisa_computer_that_created_this_volume_0, infoMddf.machine_id) + .AppendLine(); sb.AppendFormat(Localization.Serial_number_of_Lisa_computer_that_can_use_this_volume_software_0, - infoMddf.serialization). - AppendLine(); + infoMddf.serialization) + .AppendLine(); sb.AppendFormat(Localization.Volume_created_on_0, infoMddf.dtvc).AppendLine(); sb.AppendFormat(Localization.Volume_catalog_created_on_0, infoMddf.dtcc).AppendLine(); @@ -358,8 +334,8 @@ public sealed partial class LisaFS sb.AppendFormat(Localization.There_are_0_reserved_blocks_before_volume, beforeMddf).AppendLine(); sb.AppendFormat(Localization._0_blocks_minus_one, infoMddf.volsize_minus_one).AppendLine(); - sb.AppendFormat(Localization._0_blocks_minus_one_minus_MDDF_offset, infoMddf.volsize_minus_mddf_minus_one). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_minus_one_minus_MDDF_offset, infoMddf.volsize_minus_mddf_minus_one) + .AppendLine(); sb.AppendFormat(Localization._0_blocks_in_volume, infoMddf.vol_size).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_sector_uncooked, infoMddf.blocksize).AppendLine(); @@ -376,8 +352,9 @@ public sealed partial class LisaFS sb.AppendFormat(Localization.Overmount_stamp_0, infoMddf.overmount_stamp).AppendLine(); sb.AppendFormat(Localization.S_Records_start_at_0_and_spans_for_1_blocks, - infoMddf.srec_ptr + infoMddf.mddf_block + beforeMddf, infoMddf.srec_len). - AppendLine(); + infoMddf.srec_ptr + infoMddf.mddf_block + beforeMddf, + infoMddf.srec_len) + .AppendLine(); sb.AppendLine(infoMddf.vol_left_mounted == 0 ? Localization.Volume_is_clean : Localization.Volume_is_dirty); @@ -385,8 +362,7 @@ public sealed partial class LisaFS metadata = new FileSystem(); - if(DateTime.Compare(infoMddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) - metadata.BackupDate = infoMddf.dtvb; + if(DateTime.Compare(infoMddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) metadata.BackupDate = infoMddf.dtvb; metadata.Clusters = infoMddf.vol_size; metadata.ClusterSize = (uint)(infoMddf.clustersize * infoMddf.datasize); diff --git a/Aaru.Filesystems/LisaFS/Structs.cs b/Aaru.Filesystems/LisaFS/Structs.cs index 399c62f1a..951491875 100644 --- a/Aaru.Filesystems/LisaFS/Structs.cs +++ b/Aaru.Filesystems/LisaFS/Structs.cs @@ -227,12 +227,12 @@ public sealed partial class LisaFS internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -243,7 +243,7 @@ public sealed partial class LisaFS { internal short FileId; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -254,7 +254,7 @@ public sealed partial class LisaFS /// public long Offset { get; set; } - #endregion +#endregion } #endregion @@ -411,7 +411,7 @@ public sealed partial class LisaFS public ushort vol_sequence; /// 0x138, Volume is dirty? public byte vol_left_mounted; - #pragma warning disable CS0649 +#pragma warning disable CS0649 /// Is password present? (On-disk position unknown) public byte passwd_present; /// Opened files (memory-only?) (On-disk position unknown) @@ -432,7 +432,7 @@ public sealed partial class LisaFS public byte copy_flag; /// No idea (On-disk position unknown) public byte scavenge_flag; - #pragma warning restore CS0649 +#pragma warning restore CS0649 } #endregion diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index a8c8f04af..c2cda6203 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -80,8 +80,7 @@ public sealed partial class LisaFS { ErrorNumber errno = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag, out byte[] tag); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; DecodeTag(tag, out LisaTag.PriamTag searchTag); @@ -90,14 +89,12 @@ public sealed partial class LisaFS if(_volumePrefix == _device.Info.Sectors && searchTag.FileId == FILEID_LOADER_SIGNED) _volumePrefix = i - 1; - if(searchTag.FileId != FILEID_MDDF) - continue; + if(searchTag.FileId != FILEID_MDDF) continue; _devTagSize = tag.Length; errno = _device.ReadSector(i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _mddf = new MDDF(); var pString = new byte[33]; @@ -230,11 +227,9 @@ public sealed partial class LisaFS options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); - if(_debug) - _printedExtents = new List(); + if(_debug) _printedExtents = new List(); // Read the S-Records file ErrorNumber error = ReadSRecords(); @@ -258,7 +253,8 @@ public sealed partial class LisaFS if(error != ErrorNumber.NoError) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Cannot_read_Catalog_File_error_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Cannot_read_Catalog_File_error_0, error.ToString()); _mounted = false; @@ -323,14 +319,12 @@ public sealed partial class LisaFS // Create XML metadata for mounted filesystem Metadata = new FileSystem(); - if(DateTime.Compare(_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) - Metadata.BackupDate = _mddf.dtvb; + if(DateTime.Compare(_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) Metadata.BackupDate = _mddf.dtvb; Metadata.Clusters = _mddf.vol_size; Metadata.ClusterSize = (uint)(_mddf.clustersize * _mddf.datasize); - if(DateTime.Compare(_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) - Metadata.CreationDate = _mddf.dtvc; + if(DateTime.Compare(_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) Metadata.CreationDate = _mddf.dtvc; Metadata.Dirty = _mddf.vol_left_mounted != 0; Metadata.Files = _mddf.filecount; @@ -377,8 +371,7 @@ public sealed partial class LisaFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = new FileSystemInfo { diff --git a/Aaru.Filesystems/LisaFS/Xattr.cs b/Aaru.Filesystems/LisaFS/Xattr.cs index 4a7f899e5..49e54b511 100644 --- a/Aaru.Filesystems/LisaFS/Xattr.cs +++ b/Aaru.Filesystems/LisaFS/Xattr.cs @@ -50,8 +50,7 @@ public sealed partial class LisaFS xattrs = null; ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; return isDir ? ErrorNumber.InvalidArgument : ListXAttr(fileId, out xattrs); } @@ -61,8 +60,7 @@ public sealed partial class LisaFS { ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; return isDir ? ErrorNumber.InvalidArgument : GetXattr(fileId, xattr, out buf); } @@ -77,14 +75,12 @@ public sealed partial class LisaFS { xattrs = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; // System files if(fileId < 4) { - if(!_debug || fileId == 0) - return ErrorNumber.InvalidArgument; + if(!_debug || fileId == 0) return ErrorNumber.InvalidArgument; xattrs = new List(); @@ -94,8 +90,7 @@ public sealed partial class LisaFS byte[] buf = Encoding.ASCII.GetBytes(_mddf.password); // If the MDDF contains a password, show it - if(buf.Length > 0) - xattrs.Add("com.apple.lisa.password"); + if(buf.Length > 0) xattrs.Add("com.apple.lisa.password"); } } else @@ -103,27 +98,22 @@ public sealed partial class LisaFS // Search for the file ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; xattrs = new List(); // Password field is never emptied, check if valid - if(file.password_valid > 0) - xattrs.Add("com.apple.lisa.password"); + if(file.password_valid > 0) xattrs.Add("com.apple.lisa.password"); // Check for a valid copy-protection serial number - if(file.serial > 0) - xattrs.Add("com.apple.lisa.serial"); + if(file.serial > 0) xattrs.Add("com.apple.lisa.serial"); // Check if the label contains something or is empty - if(!ArrayHelpers.ArrayIsNullOrEmpty(file.LisaInfo)) - xattrs.Add("com.apple.lisa.label"); + if(!ArrayHelpers.ArrayIsNullOrEmpty(file.LisaInfo)) xattrs.Add("com.apple.lisa.label"); } // On debug mode allow sector tags to be accessed as an xattr - if(_debug) - xattrs.Add("com.apple.lisa.tags"); + if(_debug) xattrs.Add("com.apple.lisa.tags"); xattrs.Sort(); @@ -139,14 +129,12 @@ public sealed partial class LisaFS { buf = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; // System files if(fileId < 4) { - if(!_debug || fileId == 0) - return ErrorNumber.InvalidArgument; + if(!_debug || fileId == 0) return ErrorNumber.InvalidArgument; // Only MDDF contains an extended attributes if(fileId == FILEID_MDDF) @@ -160,8 +148,7 @@ public sealed partial class LisaFS } // But on debug mode even system files contain tags - if(_debug && xattr == "com.apple.lisa.tags") - return ReadSystemFile(fileId, out buf, true); + if(_debug && xattr == "com.apple.lisa.tags") return ReadSystemFile(fileId, out buf, true); return ErrorNumber.NoSuchExtendedAttribute; } @@ -169,8 +156,7 @@ public sealed partial class LisaFS // Search for the file ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; switch(xattr) { @@ -193,8 +179,7 @@ public sealed partial class LisaFS return ErrorNumber.NoError; } - if(_debug && xattr == "com.apple.lisa.tags") - return ReadFile(fileId, out buf, true); + if(_debug && xattr == "com.apple.lisa.tags") return ReadFile(fileId, out buf, true); return ErrorNumber.NoSuchExtendedAttribute; } @@ -208,8 +193,7 @@ public sealed partial class LisaFS decoded = new LisaTag.PriamTag(); LisaTag.PriamTag? pmTag = LisaTag.DecodeTag(tag); - if(!pmTag.HasValue) - return ErrorNumber.InvalidArgument; + if(!pmTag.HasValue) return ErrorNumber.InvalidArgument; decoded = pmTag.Value; diff --git a/Aaru.Filesystems/Locus/Consts.cs b/Aaru.Filesystems/Locus/Consts.cs index 6e8bc0175..5b7681ea5 100644 --- a/Aaru.Filesystems/Locus/Consts.cs +++ b/Aaru.Filesystems/Locus/Consts.cs @@ -28,25 +28,17 @@ // Commit count -using commitcnt_t = int; - // Disk address -using daddr_t = int; // Fstore -using fstore_t = int; // Global File System number -using gfs_t = int; // Inode number -using ino_t = int; // Filesystem pack number -using pckno_t = short; // Timestamp -using time_t = int; // ReSharper disable UnusedMember.Local // ReSharper disable UnusedType.Local diff --git a/Aaru.Filesystems/Locus/Enums.cs b/Aaru.Filesystems/Locus/Enums.cs index 6b5b57d26..1b5028fc2 100644 --- a/Aaru.Filesystems/Locus/Enums.cs +++ b/Aaru.Filesystems/Locus/Enums.cs @@ -30,25 +30,18 @@ using System; using System.Diagnostics.CodeAnalysis; -using commitcnt_t = int; // Disk address -using daddr_t = int; // Fstore -using fstore_t = int; // Global File System number -using gfs_t = int; // Inode number -using ino_t = int; // Filesystem pack number -using pckno_t = short; // Timestamp -using time_t = int; // ReSharper disable UnusedMember.Local // ReSharper disable UnusedType.Local diff --git a/Aaru.Filesystems/Locus/Info.cs b/Aaru.Filesystems/Locus/Info.cs index 7b19b73e4..2f232759b 100644 --- a/Aaru.Filesystems/Locus/Info.cs +++ b/Aaru.Filesystems/Locus/Info.cs @@ -34,26 +34,19 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -using commitcnt_t = int; // Disk address -using daddr_t = int; // Fstore -using fstore_t = int; // Global File System number -using gfs_t = int; // Inode number -using ino_t = int; using Partition = Aaru.CommonTypes.Partition; // Filesystem pack number -using pckno_t = short; // Timestamp -using time_t = int; // ReSharper disable UnusedMember.Local // ReSharper disable UnusedType.Local @@ -69,33 +62,27 @@ public sealed partial class Locus /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; for(ulong location = 0; location <= 8; location++) { var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) - break; + if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_1_equals_0, locusSb.s_magic, location); - if(locusSb.s_magic is LOCUS_MAGIC or LOCUS_CIGAM or LOCUS_MAGIC_OLD or LOCUS_CIGAM_OLD) - return true; + if(locusSb.s_magic is LOCUS_MAGIC or LOCUS_CIGAM or LOCUS_MAGIC_OLD or LOCUS_CIGAM_OLD) return true; } return false; @@ -109,8 +96,7 @@ public sealed partial class Locus information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; var locusSb = new Superblock(); byte[] sector = null; @@ -119,21 +105,17 @@ public sealed partial class Locus { var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(locusSb.s_magic is LOCUS_MAGIC or LOCUS_CIGAM or LOCUS_MAGIC_OLD or LOCUS_CIGAM_OLD) - break; + if(locusSb.s_magic is LOCUS_MAGIC or LOCUS_CIGAM or LOCUS_MAGIC_OLD or LOCUS_CIGAM_OLD) break; } // We don't care about old version for information @@ -186,57 +168,46 @@ public sealed partial class Locus AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fmod = {0}", locusSb.s_fmod); AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_version = {0}", locusSb.s_version); - sb.AppendFormat(Localization.Superblock_last_modified_on_0, DateHandlers.UnixToDateTime(locusSb.s_time)). - AppendLine(); + sb.AppendFormat(Localization.Superblock_last_modified_on_0, DateHandlers.UnixToDateTime(locusSb.s_time)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each_total_2_bytes, locusSb.s_fsize, blockSize, - locusSb.s_fsize * blockSize). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each_total_2_bytes, + locusSb.s_fsize, + blockSize, + locusSb.s_fsize * blockSize) + .AppendLine(); sb.AppendFormat(Localization._0_blocks_free_1_bytes, locusSb.s_tfree, locusSb.s_tfree * blockSize).AppendLine(); sb.AppendFormat(Localization.Inode_list_uses_0_blocks, locusSb.s_isize).AppendLine(); sb.AppendFormat(Localization._0_free_inodes, locusSb.s_tinode).AppendLine(); sb.AppendFormat(Localization.Next_free_inode_search_will_start_at_inode_0, locusSb.s_lasti).AppendLine(); - sb.AppendFormat(Localization.There_are_an_estimate_of_0_free_inodes_before_next_search_start, - locusSb.s_nbehind). - AppendLine(); + sb.AppendFormat(Localization.There_are_an_estimate_of_0_free_inodes_before_next_search_start, locusSb.s_nbehind) + .AppendLine(); - if(locusSb.s_flags.HasFlag(Flags.SB_RDONLY)) - sb.AppendLine(Localization.Read_only_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_RDONLY)) sb.AppendLine(Localization.Read_only_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_CLEAN)) - sb.AppendLine(Localization.Clean_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_CLEAN)) sb.AppendLine(Localization.Clean_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_DIRTY)) - sb.AppendLine(Localization.Dirty_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_DIRTY)) sb.AppendLine(Localization.Dirty_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_RMV)) - sb.AppendLine(Localization.Removable_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_RMV)) sb.AppendLine(Localization.Removable_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_PRIMPACK)) - sb.AppendLine(Localization.This_is_the_primary_pack); + if(locusSb.s_flags.HasFlag(Flags.SB_PRIMPACK)) sb.AppendLine(Localization.This_is_the_primary_pack); - if(locusSb.s_flags.HasFlag(Flags.SB_REPLTYPE)) - sb.AppendLine(Localization.Replicated_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_REPLTYPE)) sb.AppendLine(Localization.Replicated_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_USER)) - sb.AppendLine(Localization.User_replicated_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_USER)) sb.AppendLine(Localization.User_replicated_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_BACKBONE)) - sb.AppendLine(Localization.Backbone_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_BACKBONE)) sb.AppendLine(Localization.Backbone_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_NFS)) - sb.AppendLine(Localization.NFS_volume); + if(locusSb.s_flags.HasFlag(Flags.SB_NFS)) sb.AppendLine(Localization.NFS_volume); - if(locusSb.s_flags.HasFlag(Flags.SB_BYHAND)) - sb.AppendLine(Localization.Volume_inhibits_automatic_fsck); + if(locusSb.s_flags.HasFlag(Flags.SB_BYHAND)) sb.AppendLine(Localization.Volume_inhibits_automatic_fsck); - if(locusSb.s_flags.HasFlag(Flags.SB_NOSUID)) - sb.AppendLine(Localization.Set_uid_set_gid_is_disabled); + if(locusSb.s_flags.HasFlag(Flags.SB_NOSUID)) sb.AppendLine(Localization.Set_uid_set_gid_is_disabled); - if(locusSb.s_flags.HasFlag(Flags.SB_SYNCW)) - sb.AppendLine(Localization.Volume_uses_synchronous_writes); + if(locusSb.s_flags.HasFlag(Flags.SB_SYNCW)) sb.AppendLine(Localization.Volume_uses_synchronous_writes); sb.AppendFormat(Localization.Volume_label_0, s_fsmnt).AppendLine(); sb.AppendFormat(Localization.Physical_volume_name_0, s_fpack).AppendLine(); diff --git a/Aaru.Filesystems/Locus/Locus.cs b/Aaru.Filesystems/Locus/Locus.cs index fc6d020e9..4d72ff689 100644 --- a/Aaru.Filesystems/Locus/Locus.cs +++ b/Aaru.Filesystems/Locus/Locus.cs @@ -30,25 +30,18 @@ using System; using Aaru.CommonTypes.Interfaces; -using commitcnt_t = int; // Disk address -using daddr_t = int; // Fstore -using fstore_t = int; // Global File System number -using gfs_t = int; // Inode number -using ino_t = int; // Filesystem pack number -using pckno_t = short; // Timestamp -using time_t = int; // ReSharper disable UnusedMember.Local // ReSharper disable UnusedType.Local diff --git a/Aaru.Filesystems/MicroDOS/Info.cs b/Aaru.Filesystems/MicroDOS/Info.cs index ac0c4d92b..127bd9d0b 100644 --- a/Aaru.Filesystems/MicroDOS/Info.cs +++ b/Aaru.Filesystems/MicroDOS/Info.cs @@ -50,16 +50,13 @@ public sealed partial class MicroDOS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(1 + partition.Start >= partition.End) - return false; + if(1 + partition.Start >= partition.End) return false; - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); @@ -77,16 +74,15 @@ public sealed partial class MicroDOS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); sb.AppendLine(Localization.MicroDOS_filesystem); sb.AppendFormat(Localization.Volume_has_0_blocks_1_bytes, block0.blocks, block0.blocks * 512).AppendLine(); - sb.AppendFormat(Localization.Volume_has_0_blocks_used_1_bytes, block0.usedBlocks, block0.usedBlocks * 512). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_blocks_used_1_bytes, block0.usedBlocks, block0.usedBlocks * 512) + .AppendLine(); sb.AppendFormat(Localization.Volume_contains_0_files, block0.files).AppendLine(); sb.AppendFormat(Localization.First_used_block_is_0, block0.firstUsedBlock).AppendLine(); diff --git a/Aaru.Filesystems/MinixFS/Info.cs b/Aaru.Filesystems/MinixFS/Info.cs index b2c07c85c..3e53b6a36 100644 --- a/Aaru.Filesystems/MinixFS/Info.cs +++ b/Aaru.Filesystems/MinixFS/Info.cs @@ -55,13 +55,11 @@ public sealed partial class MinixFS offset = 0x400; } - if(sector + partition.Start >= partition.End) - return false; + if(sector + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; // Optical media if(offset > 0) @@ -73,8 +71,14 @@ public sealed partial class MinixFS var magic = BitConverter.ToUInt16(minixSbSector, 0x010); - if(magic is MINIX_MAGIC or MINIX_MAGIC2 or MINIX2_MAGIC or MINIX2_MAGIC2 or MINIX_CIGAM or MINIX_CIGAM2 - or MINIX2_CIGAM or MINIX2_CIGAM2) + if(magic is MINIX_MAGIC + or MINIX_MAGIC2 + or MINIX2_MAGIC + or MINIX2_MAGIC2 + or MINIX_CIGAM + or MINIX_CIGAM2 + or MINIX2_CIGAM + or MINIX2_CIGAM2) return true; magic = BitConverter.ToUInt16(minixSbSector, 0x018); // Here should reside magic number on Minix v3 @@ -105,8 +109,7 @@ public sealed partial class MinixFS string minixVersion; ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; // Optical media if(offset > 0) @@ -223,33 +226,34 @@ public sealed partial class MinixFS ? Marshal.ByteArrayToStructureLittleEndian(minixSbSector) : Marshal.ByteArrayToStructureBigEndian(minixSbSector); - if(magic != MINIX3_MAGIC && magic != MINIX3_CIGAM) - mnxSb.s_blocksize = 1024; + if(magic != MINIX3_MAGIC && magic != MINIX3_CIGAM) mnxSb.s_blocksize = 1024; sb.AppendLine(minixVersion); sb.AppendFormat(Localization._0_chars_in_filename, filenamesize).AppendLine(); if(mnxSb.s_zones > 0) // On V2 { - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_zones, mnxSb.s_zones * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_zones, mnxSb.s_zones * 1024) + .AppendLine(); } else { - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_nzones, mnxSb.s_nzones * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_nzones, mnxSb.s_nzones * 1024) + .AppendLine(); } sb.AppendFormat(Localization._0_bytes_block, mnxSb.s_blocksize).AppendLine(); sb.AppendFormat(Localization._0_inodes_in_volume, mnxSb.s_ninodes).AppendLine(); - sb.AppendFormat(Localization._0_blocks_on_inode_map_1_bytes, mnxSb.s_imap_blocks, - mnxSb.s_imap_blocks * mnxSb.s_blocksize). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_on_inode_map_1_bytes, + mnxSb.s_imap_blocks, + mnxSb.s_imap_blocks * mnxSb.s_blocksize) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_on_zone_map_1_bytes, mnxSb.s_zmap_blocks, - mnxSb.s_zmap_blocks * mnxSb.s_blocksize). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_on_zone_map_1_bytes, + mnxSb.s_zmap_blocks, + mnxSb.s_zmap_blocks * mnxSb.s_blocksize) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, mnxSb.s_firstdatazone).AppendLine(); @@ -271,24 +275,24 @@ public sealed partial class MinixFS if(mnxSb.s_zones > 0) // On V2 { - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_zones, mnxSb.s_zones * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_zones, mnxSb.s_zones * 1024) + .AppendLine(); } else { - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_nzones, mnxSb.s_nzones * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, mnxSb.s_nzones, mnxSb.s_nzones * 1024) + .AppendLine(); } sb.AppendFormat(Localization._0_inodes_in_volume, mnxSb.s_ninodes).AppendLine(); - sb.AppendFormat(Localization._0_blocks_on_inode_map_1_bytes, mnxSb.s_imap_blocks, - mnxSb.s_imap_blocks * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_on_inode_map_1_bytes, + mnxSb.s_imap_blocks, + mnxSb.s_imap_blocks * 1024) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_on_zone_map_1_bytes, mnxSb.s_zmap_blocks, - mnxSb.s_zmap_blocks * 1024). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_on_zone_map_1_bytes, mnxSb.s_zmap_blocks, mnxSb.s_zmap_blocks * 1024) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, mnxSb.s_firstdatazone).AppendLine(); diff --git a/Aaru.Filesystems/NILFS2/Info.cs b/Aaru.Filesystems/NILFS2/Info.cs index 992eea79f..3cb10359e 100644 --- a/Aaru.Filesystems/NILFS2/Info.cs +++ b/Aaru.Filesystems/NILFS2/Info.cs @@ -46,29 +46,23 @@ public sealed partial class NILFS2 /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; uint sbAddr = NILFS2_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbAddr + sbSize >= partition.End) - return false; + if(partition.Start + sbAddr + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -83,31 +77,25 @@ public sealed partial class NILFS2 information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; uint sbAddr = NILFS2_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(nilfsSb.magic != NILFS2_MAGIC) - return; + if(nilfsSb.magic != NILFS2_MAGIC) return; var sb = new StringBuilder(); @@ -126,17 +114,17 @@ public sealed partial class NILFS2 sb.AppendFormat(Localization._0_bytes_per_inode, nilfsSb.inode_size).AppendLine(); sb.AppendFormat(Localization.Volume_UUID_0, nilfsSb.uuid).AppendLine(); - sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(nilfsSb.volume_name, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(nilfsSb.volume_name, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_created_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.ctime)). - AppendLine(); + sb.AppendFormat(Localization.Volume_created_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.ctime)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_last_mounted_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.mtime)). - AppendLine(); + sb.AppendFormat(Localization.Volume_last_mounted_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.mtime)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.wtime)). - AppendLine(); + sb.AppendFormat(Localization.Volume_last_written_on_0, DateHandlers.UnixUnsignedToDateTime(nilfsSb.wtime)) + .AppendLine(); information = sb.ToString(); @@ -150,8 +138,7 @@ public sealed partial class NILFS2 ModificationDate = DateHandlers.UnixUnsignedToDateTime(nilfsSb.wtime) }; - if(nilfsSb.creator_os == 0) - metadata.SystemIdentifier = "Linux"; + if(nilfsSb.creator_os == 0) metadata.SystemIdentifier = "Linux"; metadata.Clusters = nilfsSb.dev_size / metadata.ClusterSize; } diff --git a/Aaru.Filesystems/NTFS/Info.cs b/Aaru.Filesystems/NTFS/Info.cs index 5305b4146..6c5b434c2 100644 --- a/Aaru.Filesystems/NTFS/Info.cs +++ b/Aaru.Filesystems/NTFS/Info.cs @@ -47,31 +47,26 @@ public sealed partial class NTFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; var eigthBytes = new byte[8]; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Array.Copy(ntfsBpb, 0x003, eigthBytes, 0, 8); string oemName = StringHandlers.CToString(eigthBytes); - if(oemName != "NTFS ") - return false; + if(oemName != "NTFS ") return false; byte fatsNo = ntfsBpb[0x010]; var spFat = BitConverter.ToUInt16(ntfsBpb, 0x016); var signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE); - if(fatsNo != 0) - return false; + if(fatsNo != 0) return false; - if(spFat != 0) - return false; + if(spFat != 0) return false; return signature == 0xAA55; } @@ -87,8 +82,7 @@ public sealed partial class NTFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; BiosParameterBlock ntfsBb = Marshal.ByteArrayToStructureLittleEndian(ntfsBpb); @@ -111,26 +105,28 @@ public sealed partial class NTFS // sb.AppendFormat("NT flags: 0x{0:X2}", ntfs_bb.nt_flags).AppendLine(); // sb.AppendFormat("Signature 1: 0x{0:X2}", ntfs_bb.signature1).AppendLine(); - sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, ntfsBb.sectors, ntfsBb.sectors * ntfsBb.bps). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, ntfsBb.sectors, ntfsBb.sectors * ntfsBb.bps) + .AppendLine(); sb.AppendFormat(Localization.Cluster_where_MFT_starts_0, ntfsBb.mft_lsn).AppendLine(); sb.AppendFormat(Localization.Cluster_where_MFTMirr_starts_0, ntfsBb.mftmirror_lsn).AppendLine(); if(ntfsBb.mft_rc_clusters > 0) { - sb.AppendFormat(Localization._0_clusters_per_MFT_record_1_bytes, ntfsBb.mft_rc_clusters, - ntfsBb.mft_rc_clusters * ntfsBb.bps * ntfsBb.spc). - AppendLine(); + sb.AppendFormat(Localization._0_clusters_per_MFT_record_1_bytes, + ntfsBb.mft_rc_clusters, + ntfsBb.mft_rc_clusters * ntfsBb.bps * ntfsBb.spc) + .AppendLine(); } else sb.AppendFormat(Localization._0_bytes_per_MFT_record, 1 << -ntfsBb.mft_rc_clusters).AppendLine(); if(ntfsBb.index_blk_cts > 0) { - sb.AppendFormat(Localization._0_clusters_per_Index_block_1_bytes, ntfsBb.index_blk_cts, - ntfsBb.index_blk_cts * ntfsBb.bps * ntfsBb.spc). - AppendLine(); + sb.AppendFormat(Localization._0_clusters_per_Index_block_1_bytes, + ntfsBb.index_blk_cts, + ntfsBb.index_blk_cts * ntfsBb.bps * ntfsBb.spc) + .AppendLine(); } else sb.AppendFormat(Localization._0_bytes_per_Index_block, 1 << -ntfsBb.index_blk_cts).AppendLine(); diff --git a/Aaru.Filesystems/Nintendo/Helpers.cs b/Aaru.Filesystems/Nintendo/Helpers.cs index 883ba2ca8..fc15f7c7d 100644 --- a/Aaru.Filesystems/Nintendo/Helpers.cs +++ b/Aaru.Filesystems/Nintendo/Helpers.cs @@ -46,8 +46,8 @@ public sealed partial class NintendoPlugin "L" => Localization.Master_System_Virtual_Console, "M" => Localization.Megadrive_Virtual_Console, "N" => Localization.Nintendo_64_Virtual_Console, - "P" => Localization. - Promotional_or_TurboGrafx_Virtual_Console, + "P" => Localization + .Promotional_or_TurboGrafx_Virtual_Console, "Q" => Localization.TurboGrafx_CD_Virtual_Console, "R" => Localization.Wii, "S" => Localization.Wii, @@ -63,41 +63,41 @@ public sealed partial class NintendoPlugin static string RegionCodeToString(string regionCode) => regionCode switch { - "A" => Localization. - NintendoPlugin_RegionCodeToString_any_region, - "D" => Localization. - NintendoPlugin_RegionCodeToString_Germany, - "N" => Localization. - NintendoPlugin_RegionCodeToString_USA, - "E" => Localization. - NintendoPlugin_RegionCodeToString_USA, - "F" => Localization. - NintendoPlugin_RegionCodeToString_France, - "I" => Localization. - NintendoPlugin_RegionCodeToString_Italy, - "J" => Localization. - NintendoPlugin_RegionCodeToString_Japan, - "K" => Localization. - NintendoPlugin_RegionCodeToString_Korea, - "Q" => Localization. - NintendoPlugin_RegionCodeToString_Korea, - "L" => Localization. - NintendoPlugin_RegionCodeToString_PAL, - "M" => Localization. - NintendoPlugin_RegionCodeToString_PAL, - "P" => Localization. - NintendoPlugin_RegionCodeToString_PAL, - "R" => Localization. - NintendoPlugin_RegionCodeToString_Russia, - "S" => Localization. - NintendoPlugin_RegionCodeToString_Spain, - "T" => Localization. - NintendoPlugin_RegionCodeToString_Taiwan, - "U" => Localization. - NintendoPlugin_RegionCodeToString_Australia, - _ => string. - Format(Localization.NintendoPlugin_RegionCodeToString_unknown_region_code_0, - regionCode) + "A" => Localization + .NintendoPlugin_RegionCodeToString_any_region, + "D" => Localization + .NintendoPlugin_RegionCodeToString_Germany, + "N" => Localization + .NintendoPlugin_RegionCodeToString_USA, + "E" => Localization + .NintendoPlugin_RegionCodeToString_USA, + "F" => Localization + .NintendoPlugin_RegionCodeToString_France, + "I" => Localization + .NintendoPlugin_RegionCodeToString_Italy, + "J" => Localization + .NintendoPlugin_RegionCodeToString_Japan, + "K" => Localization + .NintendoPlugin_RegionCodeToString_Korea, + "Q" => Localization + .NintendoPlugin_RegionCodeToString_Korea, + "L" => Localization + .NintendoPlugin_RegionCodeToString_PAL, + "M" => Localization + .NintendoPlugin_RegionCodeToString_PAL, + "P" => Localization + .NintendoPlugin_RegionCodeToString_PAL, + "R" => Localization + .NintendoPlugin_RegionCodeToString_Russia, + "S" => Localization + .NintendoPlugin_RegionCodeToString_Spain, + "T" => Localization + .NintendoPlugin_RegionCodeToString_Taiwan, + "U" => Localization + .NintendoPlugin_RegionCodeToString_Australia, + _ => string.Format(Localization + .NintendoPlugin_RegionCodeToString_unknown_region_code_0, + regionCode) }; [SuppressMessage("ReSharper", "StringLiteralTypo")] @@ -124,9 +124,9 @@ public sealed partial class NintendoPlugin "4Q" => "Disney Interactive", "GD" => "Square Enix", "7D" => "Sierra", - _ => string. - Format(Localization.Unknown_publisher_0, - publisherCode) + _ => string.Format(Localization + .Unknown_publisher_0, + publisherCode) }; static string PartitionTypeToString(uint type) => type switch diff --git a/Aaru.Filesystems/Nintendo/Info.cs b/Aaru.Filesystems/Nintendo/Info.cs index c6a3daf91..5ae85acf7 100644 --- a/Aaru.Filesystems/Nintendo/Info.cs +++ b/Aaru.Filesystems/Nintendo/Info.cs @@ -46,16 +46,13 @@ public sealed partial class NintendoPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start != 0) - return false; + if(partition.Start != 0) return false; - if(imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize < 0x50000) - return false; + if(imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize < 0x50000) return false; ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C); var magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); @@ -76,8 +73,7 @@ public sealed partial class NintendoPlugin ErrorNumber errno = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize, out byte[] header); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var wii = false; @@ -86,8 +82,7 @@ public sealed partial class NintendoPlugin if(magicWii == 0x5D1C9EA3) wii = true; - else if(magicGc != 0xC2339F3D) - return; + else if(magicGc != 0xC2339F3D) return; fields.DiscType = Encoding.ASCII.GetString(header, 0, 1); fields.GameCode = Encoding.ASCII.GetString(header, 1, 2); @@ -126,8 +121,7 @@ public sealed partial class NintendoPlugin for(var i = 0; i < fields.FirstPartitions.Length; i++) { - if(offset1 + i * 8 + 8 >= 0x50000) - continue; + if(offset1 + i * 8 + 8 >= 0x50000) continue; fields.FirstPartitions[i].Offset = BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 0)) << 2; @@ -137,8 +131,7 @@ public sealed partial class NintendoPlugin for(var i = 0; i < fields.SecondPartitions.Length; i++) { - if(offset1 + i * 8 + 8 >= 0x50000) - continue; + if(offset1 + i * 8 + 8 >= 0x50000) continue; fields.FirstPartitions[i].Offset = BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 0)) << 2; @@ -148,8 +141,7 @@ public sealed partial class NintendoPlugin for(var i = 0; i < fields.ThirdPartitions.Length; i++) { - if(offset1 + i * 8 + 8 >= 0x50000) - continue; + if(offset1 + i * 8 + 8 >= 0x50000) continue; fields.FirstPartitions[i].Offset = BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 0)) << 2; @@ -159,8 +151,7 @@ public sealed partial class NintendoPlugin for(var i = 0; i < fields.FourthPartitions.Length; i++) { - if(offset1 + i * 8 + 8 >= 0x50000) - continue; + if(offset1 + i * 8 + 8 >= 0x50000) continue; fields.FirstPartitions[i].Offset = BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 0)) << 2; @@ -206,37 +197,53 @@ public sealed partial class NintendoPlugin for(var i = 0; i < fields.FirstPartitions.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "firstPartitions[{1}].offset = {0}", - fields.FirstPartitions[i].Offset, i); + AaruConsole.DebugWriteLine(MODULE_NAME, + "firstPartitions[{1}].offset = {0}", + fields.FirstPartitions[i].Offset, + i); - AaruConsole.DebugWriteLine(MODULE_NAME, "firstPartitions[{1}].type = {0}", fields.FirstPartitions[i].Type, + AaruConsole.DebugWriteLine(MODULE_NAME, + "firstPartitions[{1}].type = {0}", + fields.FirstPartitions[i].Type, i); } for(var i = 0; i < fields.SecondPartitions.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "secondPartitions[{1}].offset = {0}", - fields.SecondPartitions[i].Offset, i); + AaruConsole.DebugWriteLine(MODULE_NAME, + "secondPartitions[{1}].offset = {0}", + fields.SecondPartitions[i].Offset, + i); - AaruConsole.DebugWriteLine(MODULE_NAME, "secondPartitions[{1}].type = {0}", fields.SecondPartitions[i].Type, + AaruConsole.DebugWriteLine(MODULE_NAME, + "secondPartitions[{1}].type = {0}", + fields.SecondPartitions[i].Type, i); } for(var i = 0; i < fields.ThirdPartitions.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "thirdPartitions[{1}].offset = {0}", - fields.ThirdPartitions[i].Offset, i); + AaruConsole.DebugWriteLine(MODULE_NAME, + "thirdPartitions[{1}].offset = {0}", + fields.ThirdPartitions[i].Offset, + i); - AaruConsole.DebugWriteLine(MODULE_NAME, "thirdPartitions[{1}].type = {0}", fields.ThirdPartitions[i].Type, + AaruConsole.DebugWriteLine(MODULE_NAME, + "thirdPartitions[{1}].type = {0}", + fields.ThirdPartitions[i].Type, i); } for(var i = 0; i < fields.FourthPartitions.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "fourthPartitions[{1}].offset = {0}", - fields.FourthPartitions[i].Offset, i); + AaruConsole.DebugWriteLine(MODULE_NAME, + "fourthPartitions[{1}].offset = {0}", + fields.FourthPartitions[i].Offset, + i); - AaruConsole.DebugWriteLine(MODULE_NAME, "fourthPartitions[{1}].type = {0}", fields.FourthPartitions[i].Type, + AaruConsole.DebugWriteLine(MODULE_NAME, + "fourthPartitions[{1}].type = {0}", + fields.FourthPartitions[i].Type, i); } @@ -261,22 +268,21 @@ public sealed partial class NintendoPlugin sbInformation.AppendFormat(Localization.Disc_is_a_0_disc, DiscTypeToString(fields.DiscType)).AppendLine(); sbInformation.AppendFormat(Localization.Disc_region_is_0, RegionCodeToString(fields.RegionCode)).AppendLine(); - sbInformation.AppendFormat(Localization.Published_by_0, PublisherCodeToString(fields.PublisherCode)). - AppendLine(); + sbInformation.AppendFormat(Localization.Published_by_0, PublisherCodeToString(fields.PublisherCode)) + .AppendLine(); if(fields.DiscNumber > 0) { - sbInformation.AppendFormat(Localization.Disc_number_0_of_a_multi_disc_set, fields.DiscNumber + 1). - AppendLine(); + sbInformation.AppendFormat(Localization.Disc_number_0_of_a_multi_disc_set, fields.DiscNumber + 1) + .AppendLine(); } - if(fields.Streaming) - sbInformation.AppendLine(Localization.Disc_is_prepared_for_audio_streaming); + if(fields.Streaming) sbInformation.AppendLine(Localization.Disc_is_prepared_for_audio_streaming); if(fields.StreamBufferSize > 0) { - sbInformation.AppendFormat(Localization.Audio_streaming_buffer_size_is_0_bytes, fields.StreamBufferSize). - AppendLine(); + sbInformation.AppendFormat(Localization.Audio_streaming_buffer_size_is_0_bytes, fields.StreamBufferSize) + .AppendLine(); } sbInformation.AppendFormat(Localization.Title_0, fields.Title).AppendLine(); @@ -287,32 +293,32 @@ public sealed partial class NintendoPlugin { sbInformation.AppendFormat(Localization.First_0_partition_starts_at_sector_1, PartitionTypeToString(fields.FirstPartitions[i].Type), - fields.FirstPartitions[i].Offset / 2048). - AppendLine(); + fields.FirstPartitions[i].Offset / 2048) + .AppendLine(); } for(var i = 0; i < fields.SecondPartitions.Length; i++) { sbInformation.AppendFormat(Localization.Second_0_partition_starts_at_sector_1, PartitionTypeToString(fields.SecondPartitions[i].Type), - fields.SecondPartitions[i].Offset / 2048). - AppendLine(); + fields.SecondPartitions[i].Offset / 2048) + .AppendLine(); } for(var i = 0; i < fields.ThirdPartitions.Length; i++) { sbInformation.AppendFormat(Localization.Third_0_partition_starts_at_sector_1, PartitionTypeToString(fields.ThirdPartitions[i].Type), - fields.ThirdPartitions[i].Offset / 2048). - AppendLine(); + fields.ThirdPartitions[i].Offset / 2048) + .AppendLine(); } for(var i = 0; i < fields.FourthPartitions.Length; i++) { sbInformation.AppendFormat(Localization.Fourth_0_partition_starts_at_sector_1, PartitionTypeToString(fields.FourthPartitions[i].Type), - fields.FourthPartitions[i].Offset / 2048). - AppendLine(); + fields.FourthPartitions[i].Offset / 2048) + .AppendLine(); } // sbInformation.AppendFormat("Region byte is {0}", fields.region).AppendLine(); @@ -345,8 +351,8 @@ public sealed partial class NintendoPlugin } else { - sbInformation.AppendFormat(Localization.FST_starts_at_0_and_has_1_bytes, fields.FstOff, fields.FstSize). - AppendLine(); + sbInformation.AppendFormat(Localization.FST_starts_at_0_and_has_1_bytes, fields.FstOff, fields.FstSize) + .AppendLine(); } information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/ODS/Info.cs b/Aaru.Filesystems/ODS/Info.cs index 9b8bc0284..efef6db63 100644 --- a/Aaru.Filesystems/ODS/Info.cs +++ b/Aaru.Filesystems/ODS/Info.cs @@ -59,37 +59,30 @@ public sealed partial class ODS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; var magicB = new byte[12]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Array.Copy(hbSector, 0x1F0, magicB, 0, 12); string magic = Encoding.ASCII.GetString(magicB); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_0, magic); - if(magic is "DECFILE11A " or "DECFILE11B ") - return true; + if(magic is "DECFILE11A " or "DECFILE11B ") return true; // Optical disc - if(imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) - return false; + if(imagePlugin.Info.MetadataMediaType != MetadataMediaType.OpticalDisc) return false; - if(hbSector.Length < 0x400) - return false; + if(hbSector.Length < 0x400) return false; errno = imagePlugin.ReadSector(partition.Start, out hbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Array.Copy(hbSector, 0x3F0, magicB, 0, 12); magic = Encoding.ASCII.GetString(magicB); @@ -111,8 +104,7 @@ public sealed partial class ODS ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); @@ -121,13 +113,11 @@ public sealed partial class ODS StringHandlers.CToString(homeblock.format) != "DECFILE11A " && StringHandlers.CToString(homeblock.format) != "DECFILE11B ") { - if(hbSector.Length < 0x400) - return; + if(hbSector.Length < 0x400) return; errno = imagePlugin.ReadSector(partition.Start, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; hbSector = new byte[0x200]; Array.Copy(tmp, 0x200, hbSector, 0, 0x200); @@ -144,77 +134,83 @@ public sealed partial class ODS StringHandlers.CToString(homeblock.format) != "DECFILE11B ") sb.AppendLine(Localization.The_following_information_may_be_incorrect_for_this_volume); - if(homeblock.resfiles < 5 || homeblock.devtype != 0) - sb.AppendLine(Localization.This_volume_may_be_corrupted); + if(homeblock.resfiles < 5 || homeblock.devtype != 0) sb.AppendLine(Localization.This_volume_may_be_corrupted); - sb.AppendFormat(Localization.Volume_format_is_0, - StringHandlers.SpacePaddedToString(homeblock.format, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_format_is_0, StringHandlers.SpacePaddedToString(homeblock.format, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_is_Level_0_revision_1, (homeblock.struclev & 0xFF00) >> 8, - homeblock.struclev & 0xFF). - AppendLine(); + sb.AppendFormat(Localization.Volume_is_Level_0_revision_1, + (homeblock.struclev & 0xFF00) >> 8, + homeblock.struclev & 0xFF) + .AppendLine(); sb.AppendFormat(Localization.Lowest_structure_in_the_volume_is_Level_0_revision_1, - (homeblock.lowstruclev & 0xFF00) >> 8, homeblock.lowstruclev & 0xFF). - AppendLine(); + (homeblock.lowstruclev & 0xFF00) >> 8, + homeblock.lowstruclev & 0xFF) + .AppendLine(); sb.AppendFormat(Localization.Highest_structure_in_the_volume_is_Level_0_revision_1, - (homeblock.highstruclev & 0xFF00) >> 8, homeblock.highstruclev & 0xFF). - AppendLine(); + (homeblock.highstruclev & 0xFF00) >> 8, + homeblock.highstruclev & 0xFF) + .AppendLine(); - sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, homeblock.cluster, homeblock.cluster * 512). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, homeblock.cluster, homeblock.cluster * 512) + .AppendLine(); - sb.AppendFormat(Localization.This_home_block_is_on_sector_0_VBN_1, homeblock.homelbn, homeblock.homevbn). - AppendLine(); + sb.AppendFormat(Localization.This_home_block_is_on_sector_0_VBN_1, homeblock.homelbn, homeblock.homevbn) + .AppendLine(); - sb.AppendFormat(Localization.Secondary_home_block_is_on_sector_0_VBN_1, homeblock.alhomelbn, - homeblock.alhomevbn). - AppendLine(); + sb.AppendFormat(Localization.Secondary_home_block_is_on_sector_0_VBN_1, + homeblock.alhomelbn, + homeblock.alhomevbn) + .AppendLine(); - sb.AppendFormat(Localization.Volume_bitmap_starts_in_sector_0_VBN_1, homeblock.ibmaplbn, homeblock.ibmapvbn). - AppendLine(); + sb.AppendFormat(Localization.Volume_bitmap_starts_in_sector_0_VBN_1, homeblock.ibmaplbn, homeblock.ibmapvbn) + .AppendLine(); - sb.AppendFormat(Localization.Volume_bitmap_runs_for_0_sectors_1_bytes, homeblock.ibmapsize, - homeblock.ibmapsize * 512). - AppendLine(); + sb.AppendFormat(Localization.Volume_bitmap_runs_for_0_sectors_1_bytes, + homeblock.ibmapsize, + homeblock.ibmapsize * 512) + .AppendLine(); - sb.AppendFormat(Localization.Backup_INDEXF_SYS_is_in_sector_0_VBN_1, homeblock.altidxlbn, homeblock.altidxvbn). - AppendLine(); + sb.AppendFormat(Localization.Backup_INDEXF_SYS_is_in_sector_0_VBN_1, homeblock.altidxlbn, homeblock.altidxvbn) + .AppendLine(); sb.AppendFormat(Localization._0_maximum_files_on_the_volume, homeblock.maxfiles).AppendLine(); sb.AppendFormat(Localization._0_reserved_files, homeblock.resfiles).AppendLine(); if(homeblock is { rvn: > 0, setcount: > 0 } && StringHandlers.CToString(homeblock.strucname) != " ") { - sb.AppendFormat(Localization.Volume_is_0_of_1_in_set_2, homeblock.rvn, homeblock.setcount, - StringHandlers.SpacePaddedToString(homeblock.strucname, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_is_0_of_1_in_set_2, + homeblock.rvn, + homeblock.setcount, + StringHandlers.SpacePaddedToString(homeblock.strucname, encoding)) + .AppendLine(); } sb.AppendFormat(Localization.Volume_owner_is_0_ID_1, - StringHandlers.SpacePaddedToString(homeblock.ownername, encoding), homeblock.volowner). - AppendLine(); + StringHandlers.SpacePaddedToString(homeblock.ownername, encoding), + homeblock.volowner) + .AppendLine(); - sb.AppendFormat(Localization.Volume_label_0, StringHandlers.SpacePaddedToString(homeblock.volname, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_label_0, StringHandlers.SpacePaddedToString(homeblock.volname, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Drive_serial_number_0, homeblock.serialnum).AppendLine(); - sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.VmsToDateTime(homeblock.credate)). - AppendLine(); + sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.VmsToDateTime(homeblock.credate)) + .AppendLine(); if(homeblock.revdate > 0) { - sb.AppendFormat(Localization.Volume_was_last_modified_on_0, DateHandlers.VmsToDateTime(homeblock.revdate)). - AppendLine(); + sb.AppendFormat(Localization.Volume_was_last_modified_on_0, DateHandlers.VmsToDateTime(homeblock.revdate)) + .AppendLine(); } if(homeblock.copydate > 0) { - sb.AppendFormat(Localization.Volume_copied_on_0, DateHandlers.VmsToDateTime(homeblock.copydate)). - AppendLine(); + sb.AppendFormat(Localization.Volume_copied_on_0, DateHandlers.VmsToDateTime(homeblock.copydate)) + .AppendLine(); } sb.AppendFormat(Localization.Checksums_0_and_1, homeblock.checksum1, homeblock.checksum2).AppendLine(); @@ -223,20 +219,16 @@ public sealed partial class ODS sb.AppendFormat(Localization.Cached_directories_0, homeblock.lru_lim).AppendLine(); sb.AppendFormat(Localization.Default_allocation_0_blocks, homeblock.extend).AppendLine(); - if((homeblock.volchar & 0x01) == 0x01) - sb.AppendLine(Localization.Readings_should_be_verified); + if((homeblock.volchar & 0x01) == 0x01) sb.AppendLine(Localization.Readings_should_be_verified); - if((homeblock.volchar & 0x02) == 0x02) - sb.AppendLine(Localization.Writings_should_be_verified); + if((homeblock.volchar & 0x02) == 0x02) sb.AppendLine(Localization.Writings_should_be_verified); if((homeblock.volchar & 0x04) == 0x04) sb.AppendLine(Localization.Files_should_be_erased_or_overwritten_when_deleted); - if((homeblock.volchar & 0x08) == 0x08) - sb.AppendLine(Localization.Highwater_mark_is_to_be_disabled); + if((homeblock.volchar & 0x08) == 0x08) sb.AppendLine(Localization.Highwater_mark_is_to_be_disabled); - if((homeblock.volchar & 0x10) == 0x10) - sb.AppendLine(Localization.Classification_checks_are_enabled); + if((homeblock.volchar & 0x10) == 0x10) sb.AppendLine(Localization.Classification_checks_are_enabled); sb.AppendLine(Localization.Volume_permissions_r_read_w_write_c_create_d_delete); sb.AppendLine(Localization.System_owner_group_world); @@ -281,11 +273,9 @@ public sealed partial class ODS VolumeSerial = $"{homeblock.serialnum:X8}" }; - if(homeblock.credate > 0) - metadata.CreationDate = DateHandlers.VmsToDateTime(homeblock.credate); + if(homeblock.credate > 0) metadata.CreationDate = DateHandlers.VmsToDateTime(homeblock.credate); - if(homeblock.revdate > 0) - metadata.ModificationDate = DateHandlers.VmsToDateTime(homeblock.revdate); + if(homeblock.revdate > 0) metadata.ModificationDate = DateHandlers.VmsToDateTime(homeblock.revdate); information = sb.ToString(); } diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index da771a657..793e003d7 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -45,8 +45,7 @@ public sealed partial class OperaFS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { @@ -77,18 +76,17 @@ public sealed partial class OperaFS } string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = _rootDirectoryCache.FirstOrDefault(t => t.Key.Equals(pieces[0], StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) - return ErrorNumber.NotDirectory; + if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -96,31 +94,25 @@ public sealed partial class OperaFS for(var p = 0; p < pieces.Length; p++) { - entry = - currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p], - StringComparison.CurrentCultureIgnoreCase)); + entry = currentDirectory.FirstOrDefault(t => t.Key.Equals(pieces[p], + StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(entry.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(entry.Key)) return ErrorNumber.NoSuchFile; - if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) - return ErrorNumber.NotDirectory; + if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; - if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) - continue; + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; - if(entry.Value.Pointers.Length < 1) - return ErrorNumber.InvalidArgument; + if(entry.Value.Pointers.Length < 1) return ErrorNumber.InvalidArgument; currentDirectory = DecodeDirectory((int)entry.Value.Pointers[0]); _directoryCache.Add(currentPath, currentDirectory); } - if(currentDirectory is null) - return ErrorNumber.NoSuchFile; + if(currentDirectory is null) return ErrorNumber.NoSuchFile; node = new OperaDirNode { @@ -137,17 +129,13 @@ public sealed partial class OperaFS { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not OperaDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not OperaDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; @@ -157,8 +145,7 @@ public sealed partial class OperaFS /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not OperaDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not OperaDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; @@ -178,11 +165,11 @@ public sealed partial class OperaFS do { - ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), _volumeBlockSizeRatio, + ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), + _volumeBlockSizeRatio, out byte[] data); - if(errno != ErrorNumber.NoError) - break; + if(errno != ErrorNumber.NoError) break; header = Marshal.ByteArrayToStructureBigEndian(data); nextBlock = header.next_block + firstBlock; @@ -217,8 +204,7 @@ public sealed partial class OperaFS off += (int)(_directoryEntrySize + (entry.last_copy + 1) * 4); } - if((entry.flags & (uint)FileFlags.LastEntry) != 0) - break; + if((entry.flags & (uint)FileFlags.LastEntry) != 0) break; } while(header.next_block != -1); return entries; diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index 5be23f4c3..cf30f3974 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -45,13 +45,11 @@ public sealed partial class OperaFS { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; @@ -63,19 +61,15 @@ public sealed partial class OperaFS { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DirectoryEntryWithPointers entry); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; - if((entry.Entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && !_debug) - return ErrorNumber.IsDirectory; + if((entry.Entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && !_debug) return ErrorNumber.IsDirectory; - if(entry.Pointers.Length < 1) - return ErrorNumber.InvalidArgument; + if(entry.Pointers.Length < 1) return ErrorNumber.InvalidArgument; node = new OperaFileNode { @@ -91,11 +85,9 @@ public sealed partial class OperaFS /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not OperaFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not OperaFileNode mynode) return ErrorNumber.InvalidArgument; return ErrorNumber.NoError; } @@ -105,26 +97,21 @@ public sealed partial class OperaFS { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not OperaFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not OperaFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; long firstBlock = mynode.Offset / mynode.Dentry.Entry.block_size; long offsetInBlock = mynode.Offset % mynode.Dentry.Entry.block_size; long sizeInBlocks = (read + offsetInBlock) / mynode.Dentry.Entry.block_size; - if((read + offsetInBlock) % mynode.Dentry.Entry.block_size > 0) - sizeInBlocks++; + if((read + offsetInBlock) % mynode.Dentry.Entry.block_size > 0) sizeInBlocks++; uint fileBlockSizeRatio; @@ -134,7 +121,8 @@ public sealed partial class OperaFS fileBlockSizeRatio = mynode.Dentry.Entry.block_size / _image.Info.SectorSize; ErrorNumber errno = _image.ReadSectors((ulong)(mynode.Dentry.Pointers[0] + firstBlock * fileBlockSizeRatio), - (uint)(sizeInBlocks * fileBlockSizeRatio), out byte[] buf); + (uint)(sizeInBlocks * fileBlockSizeRatio), + out byte[] buf); if(errno != ErrorNumber.NoError) { @@ -155,13 +143,11 @@ public sealed partial class OperaFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; ErrorNumber err = GetFileEntry(path, out DirectoryEntryWithPointers entryWithPointers); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; DirectoryEntry entry = entryWithPointers.Entry; @@ -203,12 +189,12 @@ public sealed partial class OperaFS : path.ToLower(CultureInfo.CurrentUICulture); string[] pieces = cutPath.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pieces.Length == 0) - return ErrorNumber.InvalidArgument; + if(pieces.Length == 0) return ErrorNumber.InvalidArgument; var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); @@ -216,8 +202,7 @@ public sealed partial class OperaFS { ErrorNumber err = OpenDir(parentPath, out IDirNode node); - if(err != ErrorNumber.NoError) - return err; + if(err != ErrorNumber.NoError) return err; CloseDir(node); } @@ -226,14 +211,12 @@ public sealed partial class OperaFS if(pieces.Length == 1) parent = _rootDirectoryCache; - else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return ErrorNumber.InvalidArgument; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.Equals(pieces[^1], StringComparison.CurrentCultureIgnoreCase)); - if(string.IsNullOrEmpty(dirent.Key)) - return ErrorNumber.NoSuchFile; + if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile; entry = dirent.Value; diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index d53b034a8..a39cd148e 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -43,13 +43,11 @@ public sealed partial class OperaFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var syncBytes = new byte[5]; @@ -57,8 +55,7 @@ public sealed partial class OperaFS Array.Copy(sbSector, 0x001, syncBytes, 0, 5); byte recordVersion = sbSector[0x006]; - if(recordType != 1 || recordVersion != 1) - return false; + if(recordType != 1 || recordVersion != 1) return false; return Encoding.ASCII.GetString(syncBytes) == SYNC; } @@ -75,31 +72,28 @@ public sealed partial class OperaFS ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); - if(sb.record_type != 1 || sb.record_version != 1) - return; + if(sb.record_type != 1 || sb.record_version != 1) return; - if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) - return; + if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) return; superBlockmetadata.AppendFormat(Localization.Opera_filesystem_disc).AppendLine(); if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_label, encoding))) { - superBlockmetadata. - AppendFormat(Localization.Volume_label_0, StringHandlers.CToString(sb.volume_label, encoding)). - AppendLine(); + superBlockmetadata + .AppendFormat(Localization.Volume_label_0, StringHandlers.CToString(sb.volume_label, encoding)) + .AppendLine(); } if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_comment, encoding))) { - superBlockmetadata. - AppendFormat(Localization.Volume_comment_0, StringHandlers.CToString(sb.volume_comment, encoding)). - AppendLine(); + superBlockmetadata + .AppendFormat(Localization.Volume_comment_0, StringHandlers.CToString(sb.volume_comment, encoding)) + .AppendLine(); } superBlockmetadata.AppendFormat(Localization.Volume_identifier_0_X8, sb.volume_id).AppendLine(); @@ -109,35 +103,39 @@ public sealed partial class OperaFS { if(sb.block_size != 2048) { - superBlockmetadata. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - sb.block_size, 2048); + superBlockmetadata.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + sb.block_size, + 2048); } } else if(imagePlugin.Info.SectorSize != sb.block_size) { - superBlockmetadata. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - sb.block_size, imagePlugin.Info.SectorSize); + superBlockmetadata.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + sb.block_size, + imagePlugin.Info.SectorSize); } - superBlockmetadata. - AppendFormat(Localization.Volume_size_0_blocks_1_bytes, sb.block_count, sb.block_size * sb.block_count). - AppendLine(); + superBlockmetadata + .AppendFormat(Localization.Volume_size_0_blocks_1_bytes, sb.block_count, sb.block_size * sb.block_count) + .AppendLine(); if(sb.block_count > imagePlugin.Info.Sectors) { - superBlockmetadata. - AppendFormat(Localization.WARNING__Filesystem_indicates_0_blocks_while_device_indicates_1_blocks, - sb.block_count, imagePlugin.Info.Sectors); + superBlockmetadata.AppendFormat(Localization + .WARNING__Filesystem_indicates_0_blocks_while_device_indicates_1_blocks, + sb.block_count, + imagePlugin.Info.Sectors); } superBlockmetadata.AppendFormat(Localization.Root_directory_identifier_0, sb.root_dirid).AppendLine(); superBlockmetadata.AppendFormat(Localization.Root_directory_block_size_0_bytes, sb.rootdir_bsize).AppendLine(); - superBlockmetadata.AppendFormat(Localization.Root_directory_size_0_blocks_1_bytes, sb.rootdir_blocks, - sb.rootdir_bsize * sb.rootdir_blocks). - AppendLine(); + superBlockmetadata.AppendFormat(Localization.Root_directory_size_0_blocks_1_bytes, + sb.rootdir_blocks, + sb.rootdir_bsize * sb.rootdir_blocks) + .AppendLine(); superBlockmetadata.AppendFormat(Localization.Last_root_directory_copy_0, sb.last_root_copy).AppendLine(); diff --git a/Aaru.Filesystems/Opera/Structs.cs b/Aaru.Filesystems/Opera/Structs.cs index 59fd12c35..b0a75eefc 100644 --- a/Aaru.Filesystems/Opera/Structs.cs +++ b/Aaru.Filesystems/Opera/Structs.cs @@ -99,12 +99,12 @@ public sealed partial class OperaFS internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -115,7 +115,7 @@ public sealed partial class OperaFS { internal DirectoryEntryWithPointers Dentry; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -126,7 +126,7 @@ public sealed partial class OperaFS /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index d6ca19cba..6074f60e7 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -50,21 +50,17 @@ public sealed partial class OperaFS options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; SuperBlock sb = Marshal.ByteArrayToStructureBigEndian(sbSector); - if(sb.record_type != 1 || sb.record_version != 1) - return ErrorNumber.InvalidArgument; + if(sb.record_type != 1 || sb.record_version != 1) return ErrorNumber.InvalidArgument; - if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) - return ErrorNumber.InvalidArgument; + if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) return ErrorNumber.InvalidArgument; if(imagePlugin.Info.SectorSize is 2336 or 2352 or 2448) _volumeBlockSizeRatio = sb.block_size / 2048; @@ -107,8 +103,7 @@ public sealed partial class OperaFS /// public ErrorNumber Unmount() { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; _mounted = false; @@ -120,8 +115,7 @@ public sealed partial class OperaFS { stat = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); diff --git a/Aaru.Filesystems/PCEngine/Info.cs b/Aaru.Filesystems/PCEngine/Info.cs index b08a57420..ae7e3d1f9 100644 --- a/Aaru.Filesystems/PCEngine/Info.cs +++ b/Aaru.Filesystems/PCEngine/Info.cs @@ -48,14 +48,12 @@ public sealed partial class PCEnginePlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; var systemDescriptor = new byte[23]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; Array.Copy(sector, 0x20, systemDescriptor, 0, 23); diff --git a/Aaru.Filesystems/PCFX/Info.cs b/Aaru.Filesystems/PCFX/Info.cs index 3861edbb1..2286b3ec3 100644 --- a/Aaru.Filesystems/PCFX/Info.cs +++ b/Aaru.Filesystems/PCFX/Info.cs @@ -55,8 +55,7 @@ public sealed partial class PCFX ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var encoding = Encoding.GetEncoding("shift_jis"); @@ -74,8 +73,7 @@ public sealed partial class PCFX ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; Header header = Marshal.ByteArrayToStructureLittleEndian
(sector); @@ -106,8 +104,7 @@ public sealed partial class PCFX sb.AppendFormat(Localization.Country_code_0, header.country).AppendLine(); sb.AppendFormat(Localization.Version_0_1, header.minorVersion, header.majorVersion).AppendLine(); - if(date != null) - sb.AppendFormat(Localization.Dated_0, dateTime).AppendLine(); + if(date != null) sb.AppendFormat(Localization.Dated_0, dateTime).AppendLine(); sb.AppendFormat(Localization.Load_0_sectors_from_sector_1, header.loadCount, header.loadOffset).AppendLine(); diff --git a/Aaru.Filesystems/PFS/Info.cs b/Aaru.Filesystems/PFS/Info.cs index e9d5186d3..e14662101 100644 --- a/Aaru.Filesystems/PFS/Info.cs +++ b/Aaru.Filesystems/PFS/Info.cs @@ -46,13 +46,11 @@ public sealed partial class PFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Length < 3) - return false; + if(partition.Length < 3) return false; ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BigEndianBitConverter.ToUInt32(sector, 0x00); @@ -68,8 +66,7 @@ public sealed partial class PFS metadata = new FileSystem(); ErrorNumber errno = imagePlugin.ReadSector(2 + partition.Start, out byte[] rootBlockSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian(rootBlockSector); @@ -97,28 +94,28 @@ public sealed partial class PFS break; } - if(rootBlock.diskType is MUAF_DISK or MUPFS_DISK) - sbInformation.Append(Localization.with_multi_user_support); + if(rootBlock.diskType is MUAF_DISK or MUPFS_DISK) sbInformation.Append(Localization.with_multi_user_support); sbInformation.AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_name_0, StringHandlers.PascalToString(rootBlock.diskname, encoding)). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_name_0, StringHandlers.PascalToString(rootBlock.diskname, encoding)) + .AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_has_0_free_sectors_of_1, rootBlock.blocksfree, rootBlock.diskSize). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_has_0_free_sectors_of_1, rootBlock.blocksfree, rootBlock.diskSize) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.AmigaToDateTime(rootBlock.creationday, rootBlock.creationminute, - rootBlock.creationtick)). - AppendLine(); + DateHandlers.AmigaToDateTime(rootBlock.creationday, + rootBlock.creationminute, + rootBlock.creationtick)) + .AppendLine(); if(rootBlock.extension > 0) { - sbInformation.AppendFormat(Localization.Root_block_extension_resides_at_block_0, rootBlock.extension). - AppendLine(); + sbInformation.AppendFormat(Localization.Root_block_extension_resides_at_block_0, rootBlock.extension) + .AppendLine(); } information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/ProDOS/Info.cs b/Aaru.Filesystems/ProDOS/Info.cs index 7795e8594..439b1fce3 100644 --- a/Aaru.Filesystems/ProDOS/Info.cs +++ b/Aaru.Filesystems/ProDOS/Info.cs @@ -54,17 +54,15 @@ public sealed partial class ProDOSPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Length < 3) - return false; + if(partition.Length < 3) return false; var multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier, - out byte[] rootDirectoryKeyBlock); + ErrorNumber errno = + imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier, out byte[] rootDirectoryKeyBlock); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var apmFromHddOnCd = false; @@ -72,17 +70,16 @@ public sealed partial class ProDOSPlugin { errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; foreach(int offset in new[] - { - 0, 0x200, 0x400, 0x600, 0x800, 0xA00 - }.Where(offset => tmp.Length > offset + 0x200 && - BitConverter.ToUInt16(tmp, offset) == 0 && - (byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE && - tmp[offset + 0x23] == ENTRY_LENGTH && - tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) + { + 0, 0x200, 0x400, 0x600, 0x800, 0xA00 + }.Where(offset => tmp.Length > offset + 0x200 && + BitConverter.ToUInt16(tmp, offset) == 0 && + (byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE && + tmp[offset + 0x23] == ENTRY_LENGTH && + tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) { Array.Copy(tmp, offset, rootDirectoryKeyBlock, 0, 0x200); apmFromHddOnCd = true; @@ -94,40 +91,38 @@ public sealed partial class ProDOSPlugin var prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0); AaruConsole.DebugWriteLine(MODULE_NAME, "prePointer = {0}", prePointer); - if(prePointer != 0) - return false; + if(prePointer != 0) return false; var storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4); AaruConsole.DebugWriteLine(MODULE_NAME, "storage_type = {0}", storageType); - if(storageType != ROOT_DIRECTORY_TYPE) - return false; + if(storageType != ROOT_DIRECTORY_TYPE) return false; byte entryLength = rootDirectoryKeyBlock[0x23]; AaruConsole.DebugWriteLine(MODULE_NAME, "entry_length = {0}", entryLength); - if(entryLength != ENTRY_LENGTH) - return false; + if(entryLength != ENTRY_LENGTH) return false; byte entriesPerBlock = rootDirectoryKeyBlock[0x24]; AaruConsole.DebugWriteLine(MODULE_NAME, "entries_per_block = {0}", entriesPerBlock); - if(entriesPerBlock != ENTRIES_PER_BLOCK) - return false; + if(entriesPerBlock != ENTRIES_PER_BLOCK) return false; var bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27); AaruConsole.DebugWriteLine(MODULE_NAME, "bit_map_pointer = {0}", bitMapPointer); - if(bitMapPointer > partition.End) - return false; + if(bitMapPointer > partition.End) return false; var totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); - if(apmFromHddOnCd) - totalBlocks /= 4; + if(apmFromHddOnCd) totalBlocks /= 4; - AaruConsole.DebugWriteLine(MODULE_NAME, "{0} <= ({1} - {2} + 1)? {3}", totalBlocks, partition.End, - partition.Start, totalBlocks <= partition.End - partition.Start + 1); + AaruConsole.DebugWriteLine(MODULE_NAME, + "{0} <= ({1} - {2} + 1)? {3}", + totalBlocks, + partition.End, + partition.Start, + totalBlocks <= partition.End - partition.Start + 1); return totalBlocks <= partition.End - partition.Start + 1; } @@ -143,11 +138,11 @@ public sealed partial class ProDOSPlugin var multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, multiplier, + ErrorNumber errno = imagePlugin.ReadSectors(2 * multiplier + partition.Start, + multiplier, out byte[] rootDirectoryKeyBlockBytes); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var apmFromHddOnCd = false; @@ -155,16 +150,15 @@ public sealed partial class ProDOSPlugin { errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; foreach(int offset in new[] - { - 0, 0x200, 0x400, 0x600, 0x800, 0xA00 - }.Where(offset => BitConverter.ToUInt16(tmp, offset) == 0 && - (byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE && - tmp[offset + 0x23] == ENTRY_LENGTH && - tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) + { + 0, 0x200, 0x400, 0x600, 0x800, 0xA00 + }.Where(offset => BitConverter.ToUInt16(tmp, offset) == 0 && + (byte)((tmp[offset + 0x04] & STORAGE_TYPE_MASK) >> 4) == ROOT_DIRECTORY_TYPE && + tmp[offset + 0x23] == ENTRY_LENGTH && + tmp[offset + 0x24] == ENTRIES_PER_BLOCK)) { Array.Copy(tmp, offset, rootDirectoryKeyBlockBytes, 0, 0x200); apmFromHddOnCd = true; @@ -203,15 +197,19 @@ public sealed partial class ProDOSPlugin var minute = (int)(tempTimestamp & MINUTE_MASK); year += 1900; - if(year < 1940) - year += 100; + if(year < 1940) year += 100; AaruConsole.DebugWriteLine(MODULE_NAME, "temp_timestamp_left = 0x{0:X4}", tempTimestampLeft); AaruConsole.DebugWriteLine(MODULE_NAME, "temp_timestamp_right = 0x{0:X4}", tempTimestampRight); AaruConsole.DebugWriteLine(MODULE_NAME, "temp_timestamp = 0x{0:X8}", tempTimestamp); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Datetime_field_year_0_month_1_day_2_hour_3_minute_4, - year, month, day, hour, minute); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Datetime_field_year_0_month_1_day_2_hour_3_minute_4, + year, + month, + day, + hour, + minute); rootDirectoryKeyBlock.header.creation_time = new DateTime(year, month, day, hour, minute, 0); dateCorrect = true; @@ -233,8 +231,8 @@ public sealed partial class ProDOSPlugin if(apmFromHddOnCd) { - sbInformation.AppendLine(Localization.ProDOS_uses_512_bytes_sector_while_device_uses_2048_bytes_sector). - AppendLine(); + sbInformation.AppendLine(Localization.ProDOS_uses_512_bytes_sector_while_device_uses_2048_bytes_sector) + .AppendLine(); } if(rootDirectoryKeyBlock.header.version != VERSION1 || rootDirectoryKeyBlock.header.min_version != VERSION1) @@ -248,45 +246,45 @@ public sealed partial class ProDOSPlugin else { sbInformation.AppendFormat(Localization.Unknown_ProDOS_version_with_field_0_used_to_create_this_volume, - rootDirectoryKeyBlock.header.version). - AppendLine(); + rootDirectoryKeyBlock.header.version) + .AppendLine(); } if(rootDirectoryKeyBlock.header.min_version == VERSION1) sbInformation.AppendLine(Localization.ProDOS_version_one_at_least_required_for_reading_this_volume); else { - sbInformation. - AppendFormat(Localization.Unknown_ProDOS_version_with_field_0_is_at_least_required_for_reading_this_volume, - rootDirectoryKeyBlock.header.min_version). - AppendLine(); + sbInformation + .AppendFormat(Localization + .Unknown_ProDOS_version_with_field_0_is_at_least_required_for_reading_this_volume, + rootDirectoryKeyBlock.header.min_version) + .AppendLine(); } - sbInformation.AppendFormat(Localization.Volume_name_is_0, rootDirectoryKeyBlock.header.volume_name). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_is_0, rootDirectoryKeyBlock.header.volume_name) + .AppendLine(); if(dateCorrect) { - sbInformation.AppendFormat(Localization.Volume_created_on_0, rootDirectoryKeyBlock.header.creation_time). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_created_on_0, rootDirectoryKeyBlock.header.creation_time) + .AppendLine(); } - sbInformation. - AppendFormat(Localization._0_bytes_per_directory_entry, rootDirectoryKeyBlock.header.entry_length). - AppendLine(); + sbInformation.AppendFormat(Localization._0_bytes_per_directory_entry, rootDirectoryKeyBlock.header.entry_length) + .AppendLine(); - sbInformation. - AppendFormat(Localization._0_entries_per_directory_block, rootDirectoryKeyBlock.header.entries_per_block). - AppendLine(); + sbInformation.AppendFormat(Localization._0_entries_per_directory_block, + rootDirectoryKeyBlock.header.entries_per_block) + .AppendLine(); - sbInformation.AppendFormat(Localization._0_files_in_root_directory, rootDirectoryKeyBlock.header.file_count). - AppendLine(); + sbInformation.AppendFormat(Localization._0_files_in_root_directory, rootDirectoryKeyBlock.header.file_count) + .AppendLine(); - sbInformation.AppendFormat(Localization._0_blocks_in_volume, rootDirectoryKeyBlock.header.total_blocks). - AppendLine(); + sbInformation.AppendFormat(Localization._0_blocks_in_volume, rootDirectoryKeyBlock.header.total_blocks) + .AppendLine(); - sbInformation.AppendFormat(Localization.Bitmap_starts_at_block_0, rootDirectoryKeyBlock.header.bit_map_pointer). - AppendLine(); + sbInformation.AppendFormat(Localization.Bitmap_starts_at_block_0, rootDirectoryKeyBlock.header.bit_map_pointer) + .AppendLine(); if((rootDirectoryKeyBlock.header.access & READ_ATTRIBUTE) == READ_ATTRIBUTE) sbInformation.AppendLine(Localization.Volume_can_be_read); @@ -306,7 +304,8 @@ public sealed partial class ProDOSPlugin // TODO: Fix mask if((rootDirectoryKeyBlock.header.access & RESERVED_ATTRIBUTE_MASK) != 0) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reserved_attributes_are_set_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Reserved_attributes_are_set_0, rootDirectoryKeyBlock.header.access); } @@ -323,8 +322,7 @@ public sealed partial class ProDOSPlugin metadata.ClusterSize = (uint)((partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / metadata.Clusters); - if(!dateCorrect) - return; + if(!dateCorrect) return; metadata.CreationDate = rootDirectoryKeyBlock.header.creation_time; } diff --git a/Aaru.Filesystems/QNX4/Info.cs b/Aaru.Filesystems/QNX4/Info.cs index d9e694c56..fd238aa37 100644 --- a/Aaru.Filesystems/QNX4/Info.cs +++ b/Aaru.Filesystems/QNX4/Info.cs @@ -47,22 +47,18 @@ public sealed partial class QNX4 /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start + 1 >= imagePlugin.Info.Sectors) - return false; + if(partition.Start + 1 >= imagePlugin.Info.Sectors) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < 512) - return false; + if(sector.Length < 512) return false; Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); // Check root directory name - if(!_rootDirFname.SequenceEqual(qnxSb.rootDir.di_fname)) - return false; + if(!_rootDirFname.SequenceEqual(qnxSb.rootDir.di_fname)) return false; // Check sizes are multiple of blocks if(qnxSb.rootDir.di_size % 512 != 0 || @@ -94,11 +90,9 @@ public sealed partial class QNX4 metadata = new FileSystem(); ErrorNumber errno = imagePlugin.ReadSector(partition.Start + 1, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < 512) - return; + if(sector.Length < 512) return; Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); diff --git a/Aaru.Filesystems/QNX6/Info.cs b/Aaru.Filesystems/QNX6/Info.cs index d7216c39a..e7b4189e8 100644 --- a/Aaru.Filesystems/QNX6/Info.cs +++ b/Aaru.Filesystems/QNX6/Info.cs @@ -47,21 +47,17 @@ public sealed partial class QNX6 uint sectors = QNX6_SUPER_BLOCK_SIZE / imagePlugin.Info.SectorSize; uint bootSectors = QNX6_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize; - if(partition.Start + bootSectors + sectors >= partition.End) - return false; + if(partition.Start + bootSectors + sectors >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < QNX6_SUPER_BLOCK_SIZE) - return false; + if(sector.Length < QNX6_SUPER_BLOCK_SIZE) return false; AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); @@ -82,16 +78,13 @@ public sealed partial class QNX6 ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectors, out byte[] audiSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; errno = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < QNX6_SUPER_BLOCK_SIZE) - return; + if(sector.Length < QNX6_SUPER_BLOCK_SIZE) return; AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); @@ -107,10 +100,12 @@ public sealed partial class QNX6 sb.AppendFormat(Localization._0_bytes_per_block, audiSb.blockSize).AppendLine(); sb.AppendFormat(Localization._0_inodes_free_of_1, audiSb.freeInodes, audiSb.numInodes).AppendLine(); - sb.AppendFormat(Localization._0_blocks_1_bytes_free_of_2_3_bytes, audiSb.freeBlocks, - audiSb.freeBlocks * audiSb.blockSize, audiSb.numBlocks, - audiSb.numBlocks * audiSb.blockSize). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_1_bytes_free_of_2_3_bytes, + audiSb.freeBlocks, + audiSb.freeBlocks * audiSb.blockSize, + audiSb.numBlocks, + audiSb.numBlocks * audiSb.blockSize) + .AppendLine(); metadata = new FileSystem { @@ -143,9 +138,12 @@ public sealed partial class QNX6 sb.AppendFormat(Localization._0_bytes_per_block, qnxSb.blockSize).AppendLine(); sb.AppendFormat(Localization._0_inodes_free_of_1, qnxSb.freeInodes, qnxSb.numInodes).AppendLine(); - sb.AppendFormat(Localization._0_blocks_1_bytes_free_of_2_3_bytes, qnxSb.freeBlocks, - qnxSb.freeBlocks * qnxSb.blockSize, qnxSb.numBlocks, qnxSb.numBlocks * qnxSb.blockSize). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_1_bytes_free_of_2_3_bytes, + qnxSb.freeBlocks, + qnxSb.freeBlocks * qnxSb.blockSize, + qnxSb.numBlocks, + qnxSb.numBlocks * qnxSb.blockSize) + .AppendLine(); metadata = new FileSystem { diff --git a/Aaru.Filesystems/RBF/Helpers.cs b/Aaru.Filesystems/RBF/Helpers.cs index 55117f690..3218b1591 100644 --- a/Aaru.Filesystems/RBF/Helpers.cs +++ b/Aaru.Filesystems/RBF/Helpers.cs @@ -34,8 +34,7 @@ public sealed partial class RBF { static uint LSNToUInt32(byte[] lsn) { - if(lsn is not { Length: 3 }) - return 0; + if(lsn is not { Length: 3 }) return 0; return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]); } diff --git a/Aaru.Filesystems/RBF/Info.cs b/Aaru.Filesystems/RBF/Info.cs index 3a4860c9f..aecc930cc 100644 --- a/Aaru.Filesystems/RBF/Info.cs +++ b/Aaru.Filesystems/RBF/Info.cs @@ -45,43 +45,42 @@ public sealed partial class RBF : IFilesystem /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 256) - return false; + if(imagePlugin.Info.SectorSize < 256) return false; // Documentation says ID should be sector 0 // I've found that OS-9/X68000 has it on sector 4 // I've read OS-9/Apple2 has it on sector 15 foreach(int i in new[] - { - 0, 4, 15 - }) + { + 0, 4, 15 + }) { var location = (ulong)i; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) - break; + if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) break; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_or_2_expected_3_or_4, location, - rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_or_2_expected_3_or_4, + location, + rbfSb.dd_sync, + rbf9000Sb.rid_sync, + RBF_SYNC, + RBF_CNYS); - if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) - return true; + if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) return true; } return false; @@ -95,46 +94,44 @@ public sealed partial class RBF : IFilesystem information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 256) - return; + if(imagePlugin.Info.SectorSize < 256) return; var rbfSb = new IdSector(); var rbf9000Sb = new NewIdSector(); foreach(int i in new[] - { - 0, 4, 15 - }) + { + 0, 4, 15 + }) { var location = (ulong)i; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_or_2_expected_3_or_4, location, - rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_or_2_expected_3_or_4, + location, + rbfSb.dd_sync, + rbf9000Sb.rid_sync, + RBF_SYNC, + RBF_CNYS); - if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) - break; + if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync is RBF_SYNC or RBF_CNYS) break; } - if(rbfSb.dd_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_CNYS) - return; + if(rbfSb.dd_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_CNYS) return; - if(rbf9000Sb.rid_sync == RBF_CNYS) - rbf9000Sb = (NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb); + if(rbf9000Sb.rid_sync == RBF_CNYS) rbf9000Sb = (NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb); var sb = new StringBuilder(); @@ -169,36 +166,36 @@ public sealed partial class RBF : IFilesystem sb.AppendLine(Localization.Disk_is_48_TPI); sb.AppendFormat(Localization.Allocation_bitmap_descriptor_starts_at_block_0, - rbf9000Sb.rid_bitmap == 0 ? 1 : rbf9000Sb.rid_bitmap). - AppendLine(); + rbf9000Sb.rid_bitmap == 0 ? 1 : rbf9000Sb.rid_bitmap) + .AppendLine(); if(rbf9000Sb.rid_firstboot > 0) { - sb.AppendFormat(Localization.Debugger_descriptor_starts_at_block_0, rbf9000Sb.rid_firstboot). - AppendLine(); + sb.AppendFormat(Localization.Debugger_descriptor_starts_at_block_0, rbf9000Sb.rid_firstboot) + .AppendLine(); } if(rbf9000Sb.rid_bootfile > 0) { - sb.AppendFormat(Localization.Boot_file_descriptor_starts_at_block_0, rbf9000Sb.rid_bootfile). - AppendLine(); + sb.AppendFormat(Localization.Boot_file_descriptor_starts_at_block_0, rbf9000Sb.rid_bootfile) + .AppendLine(); } - sb.AppendFormat(Localization.Root_directory_descriptor_starts_at_block_0, rbf9000Sb.rid_rootdir). - AppendLine(); + sb.AppendFormat(Localization.Root_directory_descriptor_starts_at_block_0, rbf9000Sb.rid_rootdir) + .AppendLine(); - sb.AppendFormat(Localization.Disk_is_owned_by_group_0_user_1, rbf9000Sb.rid_group, rbf9000Sb.rid_owner). - AppendLine(); + sb.AppendFormat(Localization.Disk_is_owned_by_group_0_user_1, rbf9000Sb.rid_group, rbf9000Sb.rid_owner) + .AppendLine(); - sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime)). - AppendLine(); + sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime)) + .AppendLine(); sb.AppendFormat(Localization.Volume_identification_block_was_last_written_on_0, - DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime)). - AppendLine(); + DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(rbf9000Sb.rid_name, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(rbf9000Sb.rid_name, encoding)) + .AppendLine(); metadata = new FileSystem { @@ -220,9 +217,10 @@ public sealed partial class RBF : IFilesystem sb.AppendFormat(Localization._0_sectors_per_track, rbfSb.dd_spt).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_sector, 256 << rbfSb.dd_lsnsize).AppendLine(); - sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, rbfSb.dd_bit, - rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize)). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, + rbfSb.dd_bit, + rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize)) + .AppendLine(); // TODO: Convert to flags? sb.AppendLine((rbfSb.dd_fmt & 0x01) == 0x01 @@ -243,31 +241,32 @@ public sealed partial class RBF : IFilesystem sb.AppendLine(Localization.Disk_is_48_TPI); sb.AppendFormat(Localization.Allocation_bitmap_descriptor_starts_at_block_0, - rbfSb.dd_maplsn == 0 ? 1 : rbfSb.dd_maplsn). - AppendLine(); + rbfSb.dd_maplsn == 0 ? 1 : rbfSb.dd_maplsn) + .AppendLine(); sb.AppendFormat(Localization._0_bytes_in_allocation_bitmap, rbfSb.dd_map).AppendLine(); if(LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0) { - sb.AppendFormat(Localization.Boot_file_starts_at_block_0_and_has_1_bytes, LSNToUInt32(rbfSb.dd_bt), - rbfSb.dd_bsz). - AppendLine(); + sb.AppendFormat(Localization.Boot_file_starts_at_block_0_and_has_1_bytes, + LSNToUInt32(rbfSb.dd_bt), + rbfSb.dd_bsz) + .AppendLine(); } - sb.AppendFormat(Localization.Root_directory_descriptor_starts_at_block_0, LSNToUInt32(rbfSb.dd_dir)). - AppendLine(); + sb.AppendFormat(Localization.Root_directory_descriptor_starts_at_block_0, LSNToUInt32(rbfSb.dd_dir)) + .AppendLine(); sb.AppendFormat(Localization.Disk_is_owned_by_user_0, rbfSb.dd_own).AppendLine(); - sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.Os9ToDateTime(rbfSb.dd_dat)). - AppendLine(); + sb.AppendFormat(Localization.Volume_was_created_on_0, DateHandlers.Os9ToDateTime(rbfSb.dd_dat)) + .AppendLine(); sb.AppendFormat(Localization.Volume_attributes_0, rbfSb.dd_att).AppendLine(); sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(rbfSb.dd_nam, encoding)).AppendLine(); - sb.AppendFormat(Localization.Path_descriptor_options_0, StringHandlers.CToString(rbfSb.dd_opt, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Path_descriptor_options_0, StringHandlers.CToString(rbfSb.dd_opt, encoding)) + .AppendLine(); metadata = new FileSystem { diff --git a/Aaru.Filesystems/RT11/Info.cs b/Aaru.Filesystems/RT11/Info.cs index 2a4882a30..6a54b1534 100644 --- a/Aaru.Filesystems/RT11/Info.cs +++ b/Aaru.Filesystems/RT11/Info.cs @@ -52,17 +52,14 @@ public sealed partial class RT11 /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(1 + partition.Start >= partition.End) - return false; + if(1 + partition.Start >= partition.End) return false; var magicB = new byte[12]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(hbSector.Length < 512) - return false; + if(hbSector.Length < 512) return false; Array.Copy(hbSector, 0x1F0, magicB, 0, 12); string magic = Encoding.ASCII.GetString(magicB); @@ -82,8 +79,7 @@ public sealed partial class RT11 ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); @@ -98,15 +94,14 @@ public sealed partial class RT11 */ ushort check = 0; - for(var i = 0; i < 512; i += 2) - check += BitConverter.ToUInt16(hbSector, i); + for(var i = 0; i < 512; i += 2) check += BitConverter.ToUInt16(hbSector, i); sb.AppendFormat(Localization.Volume_format_is_0, - StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)). - AppendLine(); + StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)) + .AppendLine(); - sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, homeblock.cluster, homeblock.cluster * 512). - AppendLine(); + sb.AppendFormat(Localization._0_sectors_per_cluster_1_bytes, homeblock.cluster, homeblock.cluster * 512) + .AppendLine(); sb.AppendFormat(Localization.First_directory_segment_starts_at_block_0, homeblock.rootBlock).AppendLine(); sb.AppendFormat(Localization.Volume_owner_is_0, encoding.GetString(homeblock.ownername).TrimEnd()).AppendLine(); diff --git a/Aaru.Filesystems/ReFS/Info.cs b/Aaru.Filesystems/ReFS/Info.cs index b727bd3b7..55523fa4d 100644 --- a/Aaru.Filesystems/ReFS/Info.cs +++ b/Aaru.Filesystems/ReFS/Info.cs @@ -49,19 +49,15 @@ public sealed partial class ReFS : IFilesystem { var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbSize >= partition.End) - return false; + if(partition.Start + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; VolumeHeader vhdr = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -79,32 +75,32 @@ public sealed partial class ReFS : IFilesystem var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbSize >= partition.End) - return; + if(partition.Start + sbSize >= partition.End) return; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; VolumeHeader vhdr = Marshal.ByteArrayToStructureLittleEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.jump empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "VolumeHeader.jump empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vhdr.jump)); - AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.signature = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "VolumeHeader.signature = {0}", StringHandlers.CToString(vhdr.signature)); - AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.mustBeZero empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "VolumeHeader.mustBeZero empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero)); - AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.identifier = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "VolumeHeader.identifier = {0}", StringHandlers.CToString(BitConverter.GetBytes(vhdr.identifier))); AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.length = {0}", vhdr.length); @@ -119,7 +115,8 @@ public sealed partial class ReFS : IFilesystem AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.unknown3 zero? = {0}", vhdr.unknown3 == 0); AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.unknown4 zero? = {0}", vhdr.unknown4 == 0); - AaruConsole.DebugWriteLine(MODULE_NAME, "VolumeHeader.unknown5 empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "VolumeHeader.unknown5 empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(vhdr.unknown5)); if(vhdr.identifier != FSRS || @@ -132,12 +129,13 @@ public sealed partial class ReFS : IFilesystem sb.AppendLine(Localization.Microsoft_Resilient_File_System); sb.AppendFormat(Localization.Volume_uses_0_bytes_per_sector, vhdr.bytesPerSector).AppendLine(); - sb.AppendFormat(Localization.Volume_uses_0_sectors_per_cluster_1_bytes, vhdr.sectorsPerCluster, - vhdr.sectorsPerCluster * vhdr.bytesPerSector). - AppendLine(); + sb.AppendFormat(Localization.Volume_uses_0_sectors_per_cluster_1_bytes, + vhdr.sectorsPerCluster, + vhdr.sectorsPerCluster * vhdr.bytesPerSector) + .AppendLine(); - sb.AppendFormat(Localization.Volume_has_0_sectors_1_bytes, vhdr.sectors, vhdr.sectors * vhdr.bytesPerSector). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_sectors_1_bytes, vhdr.sectors, vhdr.sectors * vhdr.bytesPerSector) + .AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/Reiser/Info.cs b/Aaru.Filesystems/Reiser/Info.cs index 44ed2962c..ad759b40c 100644 --- a/Aaru.Filesystems/Reiser/Info.cs +++ b/Aaru.Filesystems/Reiser/Info.cs @@ -45,29 +45,23 @@ public sealed partial class Reiser : IFilesystem /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbAddr + sbSize >= partition.End) - return false; + if(partition.Start + sbAddr + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -84,26 +78,21 @@ public sealed partial class Reiser : IFilesystem information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -118,22 +107,18 @@ public sealed partial class Reiser : IFilesystem sb.AppendLine(Localization.Reiser_3_5_filesystem); else if(_magic36.SequenceEqual(reiserSb.magic)) sb.AppendLine(Localization.Reiser_3_6_filesystem); - else if(_magicJr.SequenceEqual(reiserSb.magic)) - sb.AppendLine(Localization.Reiser_Jr_filesystem); + else if(_magicJr.SequenceEqual(reiserSb.magic)) sb.AppendLine(Localization.Reiser_Jr_filesystem); - sb.AppendFormat(Localization.Volume_has_0_blocks_with_1_blocks_free, reiserSb.block_count, - reiserSb.free_blocks). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_blocks_with_1_blocks_free, reiserSb.block_count, reiserSb.free_blocks) + .AppendLine(); sb.AppendFormat(Localization._0_bytes_per_block, reiserSb.blocksize).AppendLine(); sb.AppendFormat(Localization.Root_directory_resides_on_block_0, reiserSb.root_block).AppendLine(); - if(reiserSb.umount_state == 2) - sb.AppendLine(Localization.Volume_has_not_been_cleanly_umounted); + if(reiserSb.umount_state == 2) sb.AppendLine(Localization.Volume_has_not_been_cleanly_umounted); - sb.AppendFormat(Localization.Volume_last_checked_on_0, - DateHandlers.UnixUnsignedToDateTime(reiserSb.last_check)). - AppendLine(); + sb.AppendFormat(Localization.Volume_last_checked_on_0, DateHandlers.UnixUnsignedToDateTime(reiserSb.last_check)) + .AppendLine(); if(reiserSb.version >= 2) { @@ -152,8 +137,7 @@ public sealed partial class Reiser : IFilesystem Dirty = reiserSb.umount_state == 2 }; - if(reiserSb.version < 2) - return; + if(reiserSb.version < 2) return; metadata.VolumeName = StringHandlers.CToString(reiserSb.label, encoding); metadata.VolumeSerial = reiserSb.uuid.ToString(); diff --git a/Aaru.Filesystems/Reiser4/Info.cs b/Aaru.Filesystems/Reiser4/Info.cs index bf52b25de..e3dfd61cf 100644 --- a/Aaru.Filesystems/Reiser4/Info.cs +++ b/Aaru.Filesystems/Reiser4/Info.cs @@ -45,29 +45,23 @@ public sealed partial class Reiser4 /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; uint sbAddr = REISER4_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbAddr + sbSize >= partition.End) - return false; + if(partition.Start + sbAddr + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -82,31 +76,25 @@ public sealed partial class Reiser4 information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; uint sbAddr = REISER4_SUPER_OFFSET / imagePlugin.Info.SectorSize; - if(sbAddr == 0) - sbAddr = 1; + if(sbAddr == 0) sbAddr = 1; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(!_magic.SequenceEqual(reiserSb.magic)) - return; + if(!_magic.SequenceEqual(reiserSb.magic)) return; var sb = new StringBuilder(); diff --git a/Aaru.Filesystems/SFS/Info.cs b/Aaru.Filesystems/SFS/Info.cs index 1d20519fd..3585cf1ea 100644 --- a/Aaru.Filesystems/SFS/Info.cs +++ b/Aaru.Filesystems/SFS/Info.cs @@ -44,13 +44,11 @@ public sealed partial class SFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BigEndianBitConverter.ToUInt32(sector, 0x00); @@ -65,8 +63,7 @@ public sealed partial class SFS metadata = new FileSystem(); ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] rootBlockSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; RootBlock rootBlock = Marshal.ByteArrayToStructureBigEndian(rootBlockSector); @@ -76,36 +73,37 @@ public sealed partial class SFS sbInformation.AppendFormat(Localization.Volume_version_0, rootBlock.version).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_starts_on_device_byte_0_and_ends_on_byte_1, rootBlock.firstbyte, - rootBlock.lastbyte). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_starts_on_device_byte_0_and_ends_on_byte_1, + rootBlock.firstbyte, + rootBlock.lastbyte) + .AppendLine(); - sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, rootBlock.totalblocks, - rootBlock.blocksize). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, + rootBlock.totalblocks, + rootBlock.blocksize) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8)) + .AppendLine(); sbInformation.AppendFormat(Localization.Bitmap_starts_at_block_0, rootBlock.bitmapbase).AppendLine(); - sbInformation.AppendFormat(Localization.Admin_space_container_starts_in_block_0, rootBlock.adminspacecontainer). - AppendLine(); + sbInformation.AppendFormat(Localization.Admin_space_container_starts_in_block_0, rootBlock.adminspacecontainer) + .AppendLine(); - sbInformation.AppendFormat(Localization.Root_object_container_starts_in_block_0, rootBlock.rootobjectcontainer). - AppendLine(); + sbInformation.AppendFormat(Localization.Root_object_container_starts_in_block_0, rootBlock.rootobjectcontainer) + .AppendLine(); - sbInformation. - AppendFormat(Localization.Root_node_of_the_extent_B_tree_resides_in_block_0, rootBlock.extentbnoderoot). - AppendLine(); + sbInformation + .AppendFormat(Localization.Root_node_of_the_extent_B_tree_resides_in_block_0, rootBlock.extentbnoderoot) + .AppendLine(); - sbInformation. - AppendFormat(Localization.Root_node_of_the_object_B_tree_resides_in_block_0, rootBlock.objectnoderoot). - AppendLine(); + sbInformation + .AppendFormat(Localization.Root_node_of_the_object_B_tree_resides_in_block_0, rootBlock.objectnoderoot) + .AppendLine(); - if(rootBlock.bits.HasFlag(Flags.CaseSensitive)) - sbInformation.AppendLine(Localization.Volume_is_case_sensitive); + if(rootBlock.bits.HasFlag(Flags.CaseSensitive)) sbInformation.AppendLine(Localization.Volume_is_case_sensitive); if(rootBlock.bits.HasFlag(Flags.RecycledFolder)) sbInformation.AppendLine(Localization.Volume_moves_deleted_files_to_a_recycled_folder); diff --git a/Aaru.Filesystems/SolarFS/Info.cs b/Aaru.Filesystems/SolarFS/Info.cs index a0fc225ca..debf1021f 100644 --- a/Aaru.Filesystems/SolarFS/Info.cs +++ b/Aaru.Filesystems/SolarFS/Info.cs @@ -47,13 +47,11 @@ public sealed partial class SolarFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var fsTypeB = new byte[8]; @@ -75,8 +73,7 @@ public sealed partial class SolarFS var sb = new StringBuilder(); ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var bpb = new BiosParameterBlock { @@ -108,7 +105,10 @@ public sealed partial class SolarFS Array.Copy(bpbSector, 0x1B, bpb.unk3, 0, 10); bpb.unk4 = BitConverter.ToUInt32(bpbSector, 0x26); - AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}", bpb.x86_jump[0], bpb.x86_jump[1], + AaruConsole.DebugWriteLine(MODULE_NAME, + "BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}", + bpb.x86_jump[0], + bpb.x86_jump[1], bpb.x86_jump[2]); AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.OEMName: \"{0}\"", bpb.OEMName); @@ -124,8 +124,16 @@ public sealed partial class SolarFS AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.unk3: 0x{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}", - bpb.unk3[0], bpb.unk3[1], bpb.unk3[2], bpb.unk3[3], bpb.unk3[4], bpb.unk3[5], - bpb.unk3[6], bpb.unk3[7], bpb.unk3[8], bpb.unk3[9]); + bpb.unk3[0], + bpb.unk3[1], + bpb.unk3[2], + bpb.unk3[3], + bpb.unk3[4], + bpb.unk3[5], + bpb.unk3[6], + bpb.unk3[7], + bpb.unk3[8], + bpb.unk3[9]); AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.signature: 0x{0:X2}", bpb.signature); AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.unk4: 0x{0:X8}", bpb.unk4); @@ -140,18 +148,20 @@ public sealed partial class SolarFS { if(bpb.bps != imagePlugin.Info.SectorSize) { - sb. - AppendFormat(Localization.WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector, - bpb.bps, 2048). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector, + bpb.bps, + 2048) + .AppendLine(); } } else if(bpb.bps != imagePlugin.Info.SectorSize) { - sb. - AppendFormat(Localization.WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector, - bpb.bps, imagePlugin.Info.SectorSize). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector, + bpb.bps, + imagePlugin.Info.SectorSize) + .AppendLine(); } sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, bpb.sectors, bpb.sectors * bpb.bps).AppendLine(); @@ -159,7 +169,8 @@ public sealed partial class SolarFS if(bpb.sectors > imagePlugin.Info.Sectors) { sb.AppendFormat(Localization.WARNING_Filesystem_describes_a_0_sectors_volume_bigger_than_device_1_sectors, - bpb.sectors, imagePlugin.Info.Sectors); + bpb.sectors, + imagePlugin.Info.Sectors); } sb.AppendFormat(Localization._0_heads, bpb.heads).AppendLine(); diff --git a/Aaru.Filesystems/Squash/Info.cs b/Aaru.Filesystems/Squash/Info.cs index 8e9168b8b..95355d8ec 100644 --- a/Aaru.Filesystems/Squash/Info.cs +++ b/Aaru.Filesystems/Squash/Info.cs @@ -45,13 +45,11 @@ public sealed partial class Squash /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -66,8 +64,7 @@ public sealed partial class Squash metadata = new FileSystem(); ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -95,9 +92,9 @@ public sealed partial class Squash sbInformation.AppendFormat(Localization.Volume_has_0_bytes, sqSb.bytes_used).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_bytes_per_block, sqSb.block_size).AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_created_on_0, DateHandlers.UnixUnsignedToDateTime(sqSb.mkfs_time)). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_created_on_0, DateHandlers.UnixUnsignedToDateTime(sqSb.mkfs_time)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_inodes, sqSb.inodes).AppendLine(); @@ -128,9 +125,9 @@ public sealed partial class Squash break; default: - sbInformation. - AppendFormat(Localization.Volume_is_compressed_using_unknown_algorithm_0, sqSb.compression). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_is_compressed_using_unknown_algorithm_0, sqSb.compression) + .AppendLine(); break; } diff --git a/Aaru.Filesystems/SysV/Info.cs b/Aaru.Filesystems/SysV/Info.cs index 8e1c71df8..783b46e32 100644 --- a/Aaru.Filesystems/SysV/Info.cs +++ b/Aaru.Filesystems/SysV/Info.cs @@ -53,8 +53,7 @@ public sealed partial class SysVfs /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; byte sb_size_in_sectors; @@ -88,23 +87,19 @@ public sealed partial class SysVfs ErrorNumber errno = imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out byte[] sb_sector); - if(errno != ErrorNumber.NoError || sb_sector.Length < 0x400) - continue; + if(errno != ErrorNumber.NoError || sb_sector.Length < 0x400) continue; var magic = BitConverter.ToUInt32(sb_sector, 0x3F8); - if(magic is XENIX_MAGIC or XENIX_CIGAM or SYSV_MAGIC or SYSV_CIGAM) - return true; + if(magic is XENIX_MAGIC or XENIX_CIGAM or SYSV_MAGIC or SYSV_CIGAM) return true; magic = BitConverter.ToUInt32(sb_sector, 0x1F8); // System V magic location - if(magic is SYSV_MAGIC or SYSV_CIGAM) - return true; + if(magic is SYSV_MAGIC or SYSV_CIGAM) return true; magic = BitConverter.ToUInt32(sb_sector, 0x1F0); // XENIX 3 magic location - if(magic is XENIX_MAGIC or XENIX_CIGAM) - return true; + if(magic is XENIX_MAGIC or XENIX_CIGAM) return true; var coherent_string = new byte[6]; Array.Copy(sb_sector, 0x1E4, coherent_string, 0, 6); // Coherent UNIX s_fname location @@ -137,11 +132,9 @@ public sealed partial class SysVfs s_ninode = (ushort)(s_ninode >> 8); } - if((s_fsize & 0xFF000000) != 0x00 || (s_nfree & 0xFF00) != 0x00 || (s_ninode & 0xFF00) != 0x00) - continue; + if((s_fsize & 0xFF000000) != 0x00 || (s_nfree & 0xFF00) != 0x00 || (s_ninode & 0xFF00) != 0x00) continue; - if(s_fsize >= V7_MAXSIZE || s_nfree >= V7_NICFREE || s_ninode >= V7_NICINOD) - continue; + if(s_fsize >= V7_MAXSIZE || s_nfree >= V7_NICFREE || s_ninode >= V7_NICINOD) continue; if(s_fsize * 1024 == (partition.End - partition.Start) * imagePlugin.Info.SectorSize || s_fsize * 512 == (partition.End - partition.Start) * imagePlugin.Info.SectorSize) @@ -195,8 +188,7 @@ public sealed partial class SysVfs { errno = imagePlugin.ReadSectors((ulong)i + partition.Start, sb_size_in_sectors, out sb_sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; var magic = BitConverter.ToUInt32(sb_sector, 0x3F8); @@ -306,11 +298,9 @@ public sealed partial class SysVfs s_ninode = (ushort)(s_ninode >> 8); } - if((s_fsize & 0xFF000000) != 0x00 || (s_nfree & 0xFF00) != 0x00 || (s_ninode & 0xFF00) != 0x00) - continue; + if((s_fsize & 0xFF000000) != 0x00 || (s_nfree & 0xFF00) != 0x00 || (s_ninode & 0xFF00) != 0x00) continue; - if(s_fsize >= V7_MAXSIZE || s_nfree >= V7_NICFREE || s_ninode >= V7_NICINOD) - continue; + if(s_fsize >= V7_MAXSIZE || s_nfree >= V7_NICFREE || s_ninode >= V7_NICINOD) continue; if(s_fsize * 1024 != (partition.End - partition.Start) * imagePlugin.Info.SectorSize && s_fsize * 512 != (partition.End - partition.Start) * imagePlugin.Info.SectorSize) @@ -322,8 +312,7 @@ public sealed partial class SysVfs break; } - if(!sys7th && !sysv && !coherent && !xenix && !xenix3) - return; + if(!sys7th && !sysv && !coherent && !xenix && !xenix3) return; metadata = new FileSystem(); @@ -333,8 +322,7 @@ public sealed partial class SysVfs var xnx_sb = new XenixSuperBlock(); errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; if(xenix3) { @@ -437,58 +425,55 @@ public sealed partial class SysVfs { if(bs != 2048) { - sb. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - bs, 2048). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + bs, + 2048) + .AppendLine(); } } else { if(bs != imagePlugin.Info.SectorSize) { - sb. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - bs, imagePlugin.Info.SectorSize). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + bs, + imagePlugin.Info.SectorSize) + .AppendLine(); } } sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, xnx_sb.s_fsize, xnx_sb.s_fsize * bs).AppendLine(); - sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, xnx_sb.s_tfree, xnx_sb.s_tfree * bs). - AppendLine(); + sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, xnx_sb.s_tfree, xnx_sb.s_tfree * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, xnx_sb.s_nfree, xnx_sb.s_nfree * bs). - AppendLine(); + sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, xnx_sb.s_nfree, xnx_sb.s_nfree * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_cylinder_1_bytes, xnx_sb.s_cylblks, xnx_sb.s_cylblks * bs). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_cylinder_1_bytes, xnx_sb.s_cylblks, xnx_sb.s_cylblks * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_gap_1_bytes, xnx_sb.s_gapblks, xnx_sb.s_gapblks * bs). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_gap_1_bytes, xnx_sb.s_gapblks, xnx_sb.s_gapblks * bs) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, xnx_sb.s_isize).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_volume, xnx_sb.s_tinode).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_list, xnx_sb.s_ninode).AppendLine(); - if(xnx_sb.s_flock > 0) - sb.AppendLine(Localization.Free_block_list_is_locked); + if(xnx_sb.s_flock > 0) sb.AppendLine(Localization.Free_block_list_is_locked); - if(xnx_sb.s_ilock > 0) - sb.AppendLine(Localization.inode_cache_is_locked); + if(xnx_sb.s_ilock > 0) sb.AppendLine(Localization.inode_cache_is_locked); - if(xnx_sb.s_fmod > 0) - sb.AppendLine(Localization.Superblock_is_being_modified); + if(xnx_sb.s_fmod > 0) sb.AppendLine(Localization.Superblock_is_being_modified); - if(xnx_sb.s_ronly > 0) - sb.AppendLine(Localization.Volume_is_mounted_read_only); + if(xnx_sb.s_ronly > 0) sb.AppendLine(Localization.Volume_is_mounted_read_only); - sb.AppendFormat(Localization.Superblock_last_updated_on_0, DateHandlers.UnixToDateTime(xnx_sb.s_time)). - AppendLine(); + sb.AppendFormat(Localization.Superblock_last_updated_on_0, DateHandlers.UnixToDateTime(xnx_sb.s_time)) + .AppendLine(); - if(xnx_sb.s_time != 0) - metadata.ModificationDate = DateHandlers.UnixToDateTime(xnx_sb.s_time); + if(xnx_sb.s_time != 0) metadata.ModificationDate = DateHandlers.UnixToDateTime(xnx_sb.s_time); sb.AppendFormat(Localization.Volume_name_0, xnx_sb.s_fname).AppendLine(); metadata.VolumeName = xnx_sb.s_fname; @@ -507,8 +492,7 @@ public sealed partial class SysVfs { errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sysv_strings = new byte[6]; @@ -517,8 +501,7 @@ public sealed partial class SysVfs s_type = BitConverter.ToUInt32(sb_sector, 0x1FC + offset) }; - if(bigEndian) - sysv_sb.s_type = Swapping.Swap(sysv_sb.s_type); + if(bigEndian) sysv_sb.s_type = Swapping.Swap(sysv_sb.s_type); uint bs = 512; @@ -546,8 +529,7 @@ public sealed partial class SysVfs sysv_sb.s_fsize = BitConverter.ToUInt32(sb_sector, 0x002 + offset); - if(bigEndian) - sysv_sb.s_fsize = Swapping.Swap(sysv_sb.s_fsize); + if(bigEndian) sysv_sb.s_fsize = Swapping.Swap(sysv_sb.s_fsize); bool sysvr4 = sysv_sb.s_fsize * bs <= 0 || sysv_sb.s_fsize * bs != partition.Size; @@ -625,43 +607,38 @@ public sealed partial class SysVfs metadata.Clusters = sysv_sb.s_fsize; - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, sysv_sb.s_fsize, sysv_sb.s_fsize * bs). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, sysv_sb.s_fsize, sysv_sb.s_fsize * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, sysv_sb.s_tfree, sysv_sb.s_tfree * bs). - AppendLine(); + sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, sysv_sb.s_tfree, sysv_sb.s_tfree * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, sysv_sb.s_nfree, sysv_sb.s_nfree * bs). - AppendLine(); + sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, sysv_sb.s_nfree, sysv_sb.s_nfree * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_cylinder_1_bytes, sysv_sb.s_cylblks, sysv_sb.s_cylblks * bs). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_cylinder_1_bytes, sysv_sb.s_cylblks, sysv_sb.s_cylblks * bs) + .AppendLine(); - sb.AppendFormat(Localization._0_blocks_per_gap_1_bytes, sysv_sb.s_gapblks, sysv_sb.s_gapblks * bs). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_per_gap_1_bytes, sysv_sb.s_gapblks, sysv_sb.s_gapblks * bs) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, sysv_sb.s_isize).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_volume, sysv_sb.s_tinode).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_list, sysv_sb.s_ninode).AppendLine(); - if(sysv_sb.s_flock > 0) - sb.AppendLine(Localization.Free_block_list_is_locked); + if(sysv_sb.s_flock > 0) sb.AppendLine(Localization.Free_block_list_is_locked); - if(sysv_sb.s_ilock > 0) - sb.AppendLine(Localization.inode_cache_is_locked); + if(sysv_sb.s_ilock > 0) sb.AppendLine(Localization.inode_cache_is_locked); - if(sysv_sb.s_fmod > 0) - sb.AppendLine(Localization.Superblock_is_being_modified); + if(sysv_sb.s_fmod > 0) sb.AppendLine(Localization.Superblock_is_being_modified); - if(sysv_sb.s_ronly > 0) - sb.AppendLine(Localization.Volume_is_mounted_read_only); + if(sysv_sb.s_ronly > 0) sb.AppendLine(Localization.Volume_is_mounted_read_only); sb.AppendFormat(Localization.Superblock_last_updated_on_0, - DateHandlers.UnixUnsignedToDateTime(sysv_sb.s_time)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(sysv_sb.s_time)) + .AppendLine(); - if(sysv_sb.s_time != 0) - metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(sysv_sb.s_time); + if(sysv_sb.s_time != 0) metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(sysv_sb.s_time); sb.AppendFormat(Localization.Volume_name_0, sysv_sb.s_fname).AppendLine(); metadata.VolumeName = sysv_sb.s_fname; @@ -680,8 +657,7 @@ public sealed partial class SysVfs { errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var coh_sb = new CoherentSuperBlock(); var coh_strings = new byte[6]; @@ -712,42 +688,38 @@ public sealed partial class SysVfs if(imagePlugin.Info.SectorSize != 512) { - sb. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - 512, 2048). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + 512, + 2048) + .AppendLine(); } sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, coh_sb.s_fsize, coh_sb.s_fsize * 512).AppendLine(); - sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, coh_sb.s_tfree, coh_sb.s_tfree * 512). - AppendLine(); + sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, coh_sb.s_tfree, coh_sb.s_tfree * 512) + .AppendLine(); - sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, coh_sb.s_nfree, coh_sb.s_nfree * 512). - AppendLine(); + sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, coh_sb.s_nfree, coh_sb.s_nfree * 512) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, coh_sb.s_isize).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_volume, coh_sb.s_tinode).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_list, coh_sb.s_ninode).AppendLine(); - if(coh_sb.s_flock > 0) - sb.AppendLine(Localization.Free_block_list_is_locked); + if(coh_sb.s_flock > 0) sb.AppendLine(Localization.Free_block_list_is_locked); - if(coh_sb.s_ilock > 0) - sb.AppendLine(Localization.inode_cache_is_locked); + if(coh_sb.s_ilock > 0) sb.AppendLine(Localization.inode_cache_is_locked); - if(coh_sb.s_fmod > 0) - sb.AppendLine(Localization.Superblock_is_being_modified); + if(coh_sb.s_fmod > 0) sb.AppendLine(Localization.Superblock_is_being_modified); - if(coh_sb.s_ronly > 0) - sb.AppendLine(Localization.Volume_is_mounted_read_only); + if(coh_sb.s_ronly > 0) sb.AppendLine(Localization.Volume_is_mounted_read_only); sb.AppendFormat(Localization.Superblock_last_updated_on_0, - DateHandlers.UnixUnsignedToDateTime(coh_sb.s_time)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(coh_sb.s_time)) + .AppendLine(); - if(coh_sb.s_time != 0) - metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(coh_sb.s_time); + if(coh_sb.s_time != 0) metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(coh_sb.s_time); sb.AppendFormat(Localization.Volume_name_0, coh_sb.s_fname).AppendLine(); metadata.VolumeName = coh_sb.s_fname; @@ -758,8 +730,7 @@ public sealed partial class SysVfs { errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var v7_sb = new UNIX7thEditionSuperBlock(); var sys7_strings = new byte[6]; @@ -789,42 +760,38 @@ public sealed partial class SysVfs if(imagePlugin.Info.SectorSize != 512) { - sb. - AppendFormat(Localization.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, - 512, 2048). - AppendLine(); + sb.AppendFormat(Localization + .WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block, + 512, + 2048) + .AppendLine(); } sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, v7_sb.s_fsize, v7_sb.s_fsize * 512).AppendLine(); - sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, v7_sb.s_tfree, v7_sb.s_tfree * 512). - AppendLine(); + sb.AppendFormat(Localization._0_free_zones_on_volume_1_bytes, v7_sb.s_tfree, v7_sb.s_tfree * 512) + .AppendLine(); - sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, v7_sb.s_nfree, v7_sb.s_nfree * 512). - AppendLine(); + sb.AppendFormat(Localization._0_free_blocks_on_list_1_bytes, v7_sb.s_nfree, v7_sb.s_nfree * 512) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, v7_sb.s_isize).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_volume, v7_sb.s_tinode).AppendLine(); sb.AppendFormat(Localization._0_free_inodes_on_list, v7_sb.s_ninode).AppendLine(); - if(v7_sb.s_flock > 0) - sb.AppendLine(Localization.Free_block_list_is_locked); + if(v7_sb.s_flock > 0) sb.AppendLine(Localization.Free_block_list_is_locked); - if(v7_sb.s_ilock > 0) - sb.AppendLine(Localization.inode_cache_is_locked); + if(v7_sb.s_ilock > 0) sb.AppendLine(Localization.inode_cache_is_locked); - if(v7_sb.s_fmod > 0) - sb.AppendLine(Localization.Superblock_is_being_modified); + if(v7_sb.s_fmod > 0) sb.AppendLine(Localization.Superblock_is_being_modified); - if(v7_sb.s_ronly > 0) - sb.AppendLine(Localization.Volume_is_mounted_read_only); + if(v7_sb.s_ronly > 0) sb.AppendLine(Localization.Volume_is_mounted_read_only); sb.AppendFormat(Localization.Superblock_last_updated_on_0, - DateHandlers.UnixUnsignedToDateTime(v7_sb.s_time)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(v7_sb.s_time)) + .AppendLine(); - if(v7_sb.s_time != 0) - metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(v7_sb.s_time); + if(v7_sb.s_time != 0) metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(v7_sb.s_time); sb.AppendFormat(Localization.Volume_name_0, v7_sb.s_fname).AppendLine(); metadata.VolumeName = v7_sb.s_fname; diff --git a/Aaru.Filesystems/UCSDPascal/Dir.cs b/Aaru.Filesystems/UCSDPascal/Dir.cs index 31f7f664c..c17f6f86f 100644 --- a/Aaru.Filesystems/UCSDPascal/Dir.cs +++ b/Aaru.Filesystems/UCSDPascal/Dir.cs @@ -48,8 +48,7 @@ public sealed partial class PascalPlugin { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return ErrorNumber.NotSupported; @@ -79,17 +78,13 @@ public sealed partial class PascalPlugin { filename = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not PascalDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not PascalDirNode mynode) return ErrorNumber.InvalidArgument; - if(mynode.Position < 0) - return ErrorNumber.InvalidArgument; + if(mynode.Position < 0) return ErrorNumber.InvalidArgument; - if(mynode.Position >= mynode.Contents.Length) - return ErrorNumber.NoError; + if(mynode.Position >= mynode.Contents.Length) return ErrorNumber.NoError; filename = mynode.Contents[mynode.Position++]; @@ -99,8 +94,7 @@ public sealed partial class PascalPlugin /// public ErrorNumber CloseDir(IDirNode node) { - if(node is not PascalDirNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not PascalDirNode mynode) return ErrorNumber.InvalidArgument; mynode.Position = -1; mynode.Contents = null; diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index c2a182ffb..c5ab25380 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -45,21 +45,19 @@ public sealed partial class PascalPlugin { attributes = new FileAttributes(); - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; ErrorNumber error = GetFileEntry(path, out _); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; attributes = FileAttributes.File; @@ -71,16 +69,15 @@ public sealed partial class PascalPlugin { node = null; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; byte[] file; @@ -92,14 +89,13 @@ public sealed partial class PascalPlugin { ErrorNumber error = GetFileEntry(path, out PascalFileEntry entry); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; error = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier, - (uint)(entry.LastBlock - entry.FirstBlock) * _multiplier, out byte[] tmp); + (uint)(entry.LastBlock - entry.FirstBlock) * _multiplier, + out byte[] tmp); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; file = new byte[(entry.LastBlock - entry.FirstBlock - 1) * _device.Info.SectorSize * _multiplier + entry.LastBytes]; @@ -121,11 +117,9 @@ public sealed partial class PascalPlugin /// public ErrorNumber CloseFile(IFileNode node) { - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(node is not PascalFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not PascalFileNode mynode) return ErrorNumber.InvalidArgument; mynode.Cache = null; @@ -137,19 +131,15 @@ public sealed partial class PascalPlugin { read = 0; - if(!_mounted) - return ErrorNumber.AccessDenied; + if(!_mounted) return ErrorNumber.AccessDenied; - if(buffer is null || buffer.Length < length) - return ErrorNumber.InvalidArgument; + if(buffer is null || buffer.Length < length) return ErrorNumber.InvalidArgument; - if(node is not PascalFileNode mynode) - return ErrorNumber.InvalidArgument; + if(node is not PascalFileNode mynode) return ErrorNumber.InvalidArgument; read = length; - if(length + mynode.Offset >= mynode.Length) - read = mynode.Length - mynode.Offset; + if(length + mynode.Offset >= mynode.Length) read = mynode.Length - mynode.Offset; Array.Copy(mynode.Cache, mynode.Offset, buffer, 0, read); mynode.Offset += read; @@ -163,12 +153,12 @@ public sealed partial class PascalPlugin stat = null; string[] pathElements = path.Split(new[] - { - '/' - }, StringSplitOptions.RemoveEmptyEntries); + { + '/' + }, + StringSplitOptions.RemoveEmptyEntries); - if(pathElements.Length != 1) - return ErrorNumber.NotSupported; + if(pathElements.Length != 1) return ErrorNumber.NotSupported; if(_debug) { @@ -200,8 +190,7 @@ public sealed partial class PascalPlugin ErrorNumber error = GetFileEntry(path, out PascalFileEntry entry); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; stat = new FileEntryInfo { @@ -222,13 +211,13 @@ public sealed partial class PascalPlugin { entry = new PascalFileEntry(); - foreach(PascalFileEntry ent in _fileEntries.Where(ent => - string.Compare(path, - StringHandlers.PascalToString(ent.Filename, - _encoding), - StringComparison. - InvariantCultureIgnoreCase) == - 0)) + foreach(PascalFileEntry ent in _fileEntries.Where(ent => string.Compare(path, + StringHandlers + .PascalToString(ent.Filename, + _encoding), + StringComparison + .InvariantCultureIgnoreCase) == + 0)) { entry = ent; diff --git a/Aaru.Filesystems/UCSDPascal/Info.cs b/Aaru.Filesystems/UCSDPascal/Info.cs index af4ebd35f..901b2c667 100644 --- a/Aaru.Filesystems/UCSDPascal/Info.cs +++ b/Aaru.Filesystems/UCSDPascal/Info.cs @@ -51,8 +51,7 @@ public sealed partial class PascalPlugin /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Length < 3) - return false; + if(partition.Length < 3) return false; _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); @@ -60,8 +59,7 @@ public sealed partial class PascalPlugin ErrorNumber errno = imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; // On Apple II, it's little endian // TODO: Fix @@ -95,8 +93,7 @@ public sealed partial class PascalPlugin AaruConsole.DebugWriteLine(MODULE_NAME, "volEntry.tail = {0}", volEntry.Tail); // First block is always 0 (even is it's sector 2) - if(volEntry.FirstBlock != 0) - return false; + if(volEntry.FirstBlock != 0) return false; // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || @@ -104,16 +101,13 @@ public sealed partial class PascalPlugin return false; // Volume record entry type must be volume or secure - if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) - return false; + if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) return false; // Volume name is max 7 characters - if(volEntry.VolumeName[0] > 7) - return false; + if(volEntry.VolumeName[0] > 7) return false; // Volume blocks is equal to volume sectors - if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) - return false; + if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) return false; // There can be not less than zero files return volEntry.Files >= 0; @@ -129,15 +123,13 @@ public sealed partial class PascalPlugin information = ""; _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); - if(imagePlugin.Info.Sectors < 3) - return; + if(imagePlugin.Info.Sectors < 3) return; // Blocks 0 and 1 are boot code ErrorNumber errno = imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; // On Apple //, it's little endian // TODO: Fix @@ -160,8 +152,7 @@ public sealed partial class PascalPlugin Array.Copy(volBlock, 0x06, volEntry.VolumeName, 0, 8); // First block is always 0 (even is it's sector 2) - if(volEntry.FirstBlock != 0) - return; + if(volEntry.FirstBlock != 0) return; // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || @@ -169,35 +160,32 @@ public sealed partial class PascalPlugin return; // Volume record entry type must be volume or secure - if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) - return; + if(volEntry.EntryType != PascalFileKind.Volume && volEntry.EntryType != PascalFileKind.Secure) return; // Volume name is max 7 characters - if(volEntry.VolumeName[0] > 7) - return; + if(volEntry.VolumeName[0] > 7) return; // Volume blocks is equal to volume sectors - if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) - return; + if(volEntry.Blocks < 0 || (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) return; // There can be not less than zero files - if(volEntry.Files < 0) - return; + if(volEntry.Files < 0) return; - sbInformation.AppendFormat(Localization.Volume_record_spans_from_block_0_to_block_1, volEntry.FirstBlock, - volEntry.LastBlock). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_record_spans_from_block_0_to_block_1, + volEntry.FirstBlock, + volEntry.LastBlock) + .AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_name_0, StringHandlers.PascalToString(volEntry.VolumeName, encoding)). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_name_0, StringHandlers.PascalToString(volEntry.VolumeName, encoding)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_blocks, volEntry.Blocks).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_files, volEntry.Files).AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_last_booted_on_0, DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot)). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_last_booted_on_0, DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot)) + .AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/UCSDPascal/Structs.cs b/Aaru.Filesystems/UCSDPascal/Structs.cs index fc03f4ba2..5cfe19f07 100644 --- a/Aaru.Filesystems/UCSDPascal/Structs.cs +++ b/Aaru.Filesystems/UCSDPascal/Structs.cs @@ -46,12 +46,12 @@ public sealed partial class PascalPlugin internal string[] Contents; internal int Position; - #region IDirNode Members +#region IDirNode Members /// public string Path { get; init; } - #endregion +#endregion } #endregion @@ -82,7 +82,7 @@ public sealed partial class PascalPlugin { internal byte[] Cache; - #region IFileNode Members +#region IFileNode Members /// public string Path { get; init; } @@ -93,7 +93,7 @@ public sealed partial class PascalPlugin /// public long Offset { get; set; } - #endregion +#endregion } #endregion diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs index 83c0e4d93..a8b7f93ab 100644 --- a/Aaru.Filesystems/UCSDPascal/Super.cs +++ b/Aaru.Filesystems/UCSDPascal/Super.cs @@ -57,19 +57,16 @@ public sealed partial class PascalPlugin options ??= GetDefaultOptions(); - if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out _debug); + if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out _debug); - if(_device.Info.Sectors < 3) - return ErrorNumber.InvalidArgument; + if(_device.Info.Sectors < 3) return ErrorNumber.InvalidArgument; _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code ErrorNumber errno = _device.ReadSectors(_multiplier * 2, _multiplier, out _catalogBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; // On Apple //, it's little endian // TODO: Fix @@ -101,8 +98,7 @@ public sealed partial class PascalPlugin (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * _multiplier, out _catalogBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; var offset = 26; @@ -122,16 +118,14 @@ public sealed partial class PascalPlugin Array.Copy(_catalogBlocks, offset + 0x06, entry.Filename, 0, 16); - if(entry.Filename[0] <= 15 && entry.Filename[0] > 0) - _fileEntries.Add(entry); + if(entry.Filename[0] <= 15 && entry.Filename[0] > 0) _fileEntries.Add(entry); offset += 26; } errno = _device.ReadSectors(0, 2 * _multiplier, out _bootBlocks); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Metadata = new FileSystem { @@ -172,8 +166,7 @@ public sealed partial class PascalPlugin stat.FreeBlocks = (ulong)(_mountedVolEntry.Blocks - (_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock)); - foreach(PascalFileEntry entry in _fileEntries) - stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock); + foreach(PascalFileEntry entry in _fileEntries) stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock); return ErrorNumber.NotImplemented; } diff --git a/Aaru.Filesystems/UDF/Helpers.cs b/Aaru.Filesystems/UDF/Helpers.cs index 6bc9a9dc7..e27e02754 100644 --- a/Aaru.Filesystems/UDF/Helpers.cs +++ b/Aaru.Filesystems/UDF/Helpers.cs @@ -39,6 +39,13 @@ namespace Aaru.Filesystems; public sealed partial class UDF { static DateTime EcmaToDateTime(Timestamp timestamp) => DateHandlers.EcmaToDateTime(timestamp.typeAndZone, - timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second, - timestamp.centiseconds, timestamp.hundredsMicroseconds, timestamp.microseconds); + timestamp.year, + timestamp.month, + timestamp.day, + timestamp.hour, + timestamp.minute, + timestamp.second, + timestamp.centiseconds, + timestamp.hundredsMicroseconds, + timestamp.microseconds); } \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/Info.cs b/Aaru.Filesystems/UDF/Info.cs index 3899d3284..a038a915c 100644 --- a/Aaru.Filesystems/UDF/Info.cs +++ b/Aaru.Filesystems/UDF/Info.cs @@ -51,12 +51,10 @@ public sealed partial class UDF public bool Identify(IMediaImage imagePlugin, Partition partition) { // UDF needs at least that - if(partition.End - partition.Start < 256) - return false; + if(partition.End - partition.Start < 256) return false; // UDF needs at least that - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; var anchor = new AnchorVolumeDescriptorPointer(); @@ -123,21 +121,26 @@ public sealed partial class UDF AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.tag.descriptorCrc = 0x{0:X4}", anchor.tag.descriptorCrc); - AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.tag.descriptorCrcLength = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "anchor.tag.descriptorCrcLength = {0}", anchor.tag.descriptorCrcLength); AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.tag.tagLocation = {0}", anchor.tag.tagLocation); - AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.mainVolumeDescriptorSequenceExtent.length = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "anchor.mainVolumeDescriptorSequenceExtent.length = {0}", anchor.mainVolumeDescriptorSequenceExtent.length); - AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.mainVolumeDescriptorSequenceExtent.location = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "anchor.mainVolumeDescriptorSequenceExtent.location = {0}", anchor.mainVolumeDescriptorSequenceExtent.location); - AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.reserveVolumeDescriptorSequenceExtent.length = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "anchor.reserveVolumeDescriptorSequenceExtent.length = {0}", anchor.reserveVolumeDescriptorSequenceExtent.length); - AaruConsole.DebugWriteLine(MODULE_NAME, "anchor.reserveVolumeDescriptorSequenceExtent.location = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "anchor.reserveVolumeDescriptorSequenceExtent.location = {0}", anchor.reserveVolumeDescriptorSequenceExtent.location); if(anchor.tag.tagIdentifier != TagIdentifier.AnchorVolumeDescriptorPointer || @@ -151,17 +154,18 @@ public sealed partial class UDF break; } - if(!anchorFound) - return false; + if(!anchorFound) return false; ulong count = 0; while(count < 256) { ErrorNumber errno = - imagePlugin. - ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, - ratio, out sector); + imagePlugin.ReadSectors(partition.Start + + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + + count * ratio, + ratio, + out sector); if(errno != ErrorNumber.NoError) { @@ -175,8 +179,7 @@ public sealed partial class UDF if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count) { - if(tagId == TagIdentifier.TerminatingDescriptor) - break; + if(tagId == TagIdentifier.TerminatingDescriptor) break; if(tagId == TagIdentifier.LogicalVolumeDescriptor) { @@ -256,8 +259,7 @@ public sealed partial class UDF { errno = imagePlugin.ReadSectors(position[0], (uint)position[1], out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; anchor = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -279,21 +281,20 @@ public sealed partial class UDF while(count < 256) { - errno = - imagePlugin. - ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, - ratio, out sector); + errno = imagePlugin.ReadSectors(partition.Start + + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + + count * ratio, + ratio, + out sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0); var location = BitConverter.ToUInt32(sector, 0x0C); if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count) { - if(tagId == TagIdentifier.TerminatingDescriptor) - break; + if(tagId == TagIdentifier.TerminatingDescriptor) break; switch(tagId) { @@ -315,8 +316,7 @@ public sealed partial class UDF errno = imagePlugin.ReadSectors(lvd.integritySequenceExtent.location * ratio, ratio, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; LogicalVolumeIntegrityDescriptor lvid = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -324,59 +324,59 @@ public sealed partial class UDF if(lvid.tag.tagIdentifier == TagIdentifier.LogicalVolumeIntegrityDescriptor && lvid.tag.tagLocation == lvd.integritySequenceExtent.location) { - lvidiu = - Marshal.ByteArrayToStructureLittleEndian(sector, - (int)(lvid.numberOfPartitions * 8 + 80), - System.Runtime.InteropServices.Marshal.SizeOf(lvidiu)); + lvidiu = Marshal.ByteArrayToStructureLittleEndian(sector, + (int)(lvid.numberOfPartitions * 8 + 80), + System.Runtime.InteropServices.Marshal.SizeOf(lvidiu)); } else lvid = new LogicalVolumeIntegrityDescriptor(); - sbInformation.AppendFormat(Localization.Volume_is_number_0_of_1, pvd.volumeSequenceNumber, - pvd.maximumVolumeSequenceNumber). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_is_number_0_of_1, + pvd.volumeSequenceNumber, + pvd.maximumVolumeSequenceNumber) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_set_identifier_0, - StringHandlers.DecompressUnicode(pvd.volumeSetIdentifier)). - AppendLine(); + StringHandlers.DecompressUnicode(pvd.volumeSetIdentifier)) + .AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_name_0, StringHandlers.DecompressUnicode(lvd.logicalVolumeIdentifier)). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_name_0, StringHandlers.DecompressUnicode(lvd.logicalVolumeIdentifier)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_uses_0_bytes_per_block, lvd.logicalBlockSize).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_was_last_written_on_0, EcmaToDateTime(lvid.recordingDateTime)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_was_last_written_on_0, EcmaToDateTime(lvid.recordingDateTime)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_contains_0_partitions, lvid.numberOfPartitions).AppendLine(); - sbInformation. - AppendFormat(Localization.Volume_contains_0_files_and_1_directories, lvidiu.files, lvidiu.directories). - AppendLine(); + sbInformation + .AppendFormat(Localization.Volume_contains_0_files_and_1_directories, lvidiu.files, lvidiu.directories) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_conforms_to_0, - encoding.GetString(lvd.domainIdentifier.identifier).TrimEnd('\u0000')). - AppendLine(); + encoding.GetString(lvd.domainIdentifier.identifier).TrimEnd('\u0000')) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_was_last_written_by_0, - encoding.GetString(pvd.implementationIdentifier.identifier).TrimEnd('\u0000')). - AppendLine(); + encoding.GetString(pvd.implementationIdentifier.identifier).TrimEnd('\u0000')) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_requires_UDF_version_0_1_to_be_read, Convert.ToInt32($"{(lvidiu.minimumReadUDF & 0xFF00) >> 8}", 10), - Convert.ToInt32($"{lvidiu.minimumReadUDF & 0xFF}", 10)). - AppendLine(); + Convert.ToInt32($"{lvidiu.minimumReadUDF & 0xFF}", 10)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_requires_UDF_version_0_1_to_be_written_to, Convert.ToInt32($"{(lvidiu.minimumWriteUDF & 0xFF00) >> 8}", 10), - Convert.ToInt32($"{lvidiu.minimumWriteUDF & 0xFF}", 10)). - AppendLine(); + Convert.ToInt32($"{lvidiu.minimumWriteUDF & 0xFF}", 10)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_cannot_be_written_by_any_UDF_version_higher_than_0_1, Convert.ToInt32($"{(lvidiu.maximumWriteUDF & 0xFF00) >> 8}", 10), - Convert.ToInt32($"{lvidiu.maximumWriteUDF & 0xFF}", 10)). - AppendLine(); + Convert.ToInt32($"{lvidiu.maximumWriteUDF & 0xFF}", 10)) + .AppendLine(); metadata = new FileSystem { diff --git a/Aaru.Filesystems/UNICOS/Consts.cs b/Aaru.Filesystems/UNICOS/Consts.cs index 104b1ebc7..9d8dfc387 100644 --- a/Aaru.Filesystems/UNICOS/Consts.cs +++ b/Aaru.Filesystems/UNICOS/Consts.cs @@ -28,13 +28,6 @@ // UNICOS is ILP64 so let's think everything is 64-bit -using blkno_t = long; -using daddr_t = long; -using dev_t = long; -using extent_t = long; -using ino_t = long; -using time_t = long; - namespace Aaru.Filesystems; /// diff --git a/Aaru.Filesystems/UNICOS/Info.cs b/Aaru.Filesystems/UNICOS/Info.cs index 8316228d7..f89a95bed 100644 --- a/Aaru.Filesystems/UNICOS/Info.cs +++ b/Aaru.Filesystems/UNICOS/Info.cs @@ -34,13 +34,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -using blkno_t = long; -using daddr_t = long; -using dev_t = long; -using extent_t = long; -using ino_t = long; using Partition = Aaru.CommonTypes.Partition; -using time_t = long; namespace Aaru.Filesystems; @@ -53,24 +47,19 @@ public sealed partial class UNICOS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - if(partition.Start + sbSize >= partition.End) - return false; + if(partition.Start + sbSize >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); @@ -87,33 +76,27 @@ public sealed partial class UNICOS information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); - if(unicosSb.s_magic != UNICOS_MAGIC) - return; + if(unicosSb.s_magic != UNICOS_MAGIC) return; var sb = new StringBuilder(); sb.AppendLine(Localization.UNICOS_filesystem); - if(unicosSb.s_secure == UNICOS_SECURE) - sb.AppendLine(Localization.Volume_is_secure); + if(unicosSb.s_secure == UNICOS_SECURE) sb.AppendLine(Localization.Volume_is_secure); sb.AppendFormat(Localization.Volume_contains_0_partitions, unicosSb.s_npart).AppendLine(); sb.AppendFormat(Localization._0_bytes_per_sector, unicosSb.s_iounit).AppendLine(); @@ -122,8 +105,8 @@ public sealed partial class UNICOS sb.AppendFormat(Localization.Root_resides_on_inode_0, unicosSb.s_root).AppendLine(); sb.AppendFormat(Localization._0_inodes_in_volume, unicosSb.s_isize).AppendLine(); - sb.AppendFormat(Localization.Volume_last_updated_on_0, DateHandlers.UnixToDateTime(unicosSb.s_time)). - AppendLine(); + sb.AppendFormat(Localization.Volume_last_updated_on_0, DateHandlers.UnixToDateTime(unicosSb.s_time)) + .AppendLine(); if(unicosSb.s_error > 0) sb.AppendFormat(Localization.Volume_is_dirty_error_code_equals_0, unicosSb.s_error).AppendLine(); diff --git a/Aaru.Filesystems/UNICOS/UNICOS.cs b/Aaru.Filesystems/UNICOS/UNICOS.cs index 63ef5a58f..0418701f3 100644 --- a/Aaru.Filesystems/UNICOS/UNICOS.cs +++ b/Aaru.Filesystems/UNICOS/UNICOS.cs @@ -30,12 +30,6 @@ using System; using Aaru.CommonTypes.Interfaces; -using blkno_t = long; -using daddr_t = long; -using dev_t = long; -using extent_t = long; -using ino_t = long; -using time_t = long; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/UNIXBFS/Info.cs b/Aaru.Filesystems/UNIXBFS/Info.cs index 2112f6595..db4a7e861 100644 --- a/Aaru.Filesystems/UNIXBFS/Info.cs +++ b/Aaru.Filesystems/UNIXBFS/Info.cs @@ -47,13 +47,11 @@ public sealed partial class BFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(2 + partition.Start >= partition.End) - return false; + if(2 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] tmp); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(tmp, 0); @@ -71,8 +69,7 @@ public sealed partial class BFS var sb = new StringBuilder(); ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bfsSbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sbStrings = new byte[6]; @@ -104,9 +101,11 @@ public sealed partial class BFS sb.AppendLine(Localization.UNIX_Boot_Filesystem); - sb.AppendFormat(Localization.Volume_goes_from_byte_0_to_byte_1_for_2_bytes, bfsSb.s_start, bfsSb.s_end, - bfsSb.s_end - bfsSb.s_start). - AppendLine(); + sb.AppendFormat(Localization.Volume_goes_from_byte_0_to_byte_1_for_2_bytes, + bfsSb.s_start, + bfsSb.s_end, + bfsSb.s_end - bfsSb.s_start) + .AppendLine(); sb.AppendFormat(Localization.Filesystem_name_0, bfsSb.s_fsname).AppendLine(); sb.AppendFormat(Localization.Volume_name_0, bfsSb.s_volume).AppendLine(); diff --git a/Aaru.Filesystems/VMfs/Info.cs b/Aaru.Filesystems/VMfs/Info.cs index 61a1da616..c336893e0 100644 --- a/Aaru.Filesystems/VMfs/Info.cs +++ b/Aaru.Filesystems/VMfs/Info.cs @@ -51,18 +51,15 @@ public sealed partial class VMfs /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(partition.Start >= partition.End) - return false; + if(partition.Start >= partition.End) return false; ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize; - if(partition.Start + vmfsSuperOff > partition.End) - return false; + if(partition.Start + vmfsSuperOff > partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -79,8 +76,7 @@ public sealed partial class VMfs ulong vmfsSuperOff = VMFS_BASE / imagePlugin.Info.SectorSize; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; VolumeInfo volInfo = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -95,19 +91,19 @@ public sealed partial class VMfs sbInformation.AppendFormat(Localization.Volume_version_0, volInfo.version).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(volInfo.name, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(volInfo.name, encoding)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_size_0_bytes, volInfo.size * 256).AppendLine(); sbInformation.AppendFormat(Localization.Volume_UUID_0, volInfo.uuid).AppendLine(); sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(ctimeSecs, ctimeNanoSecs)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_last_modified_on_0, - DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(mtimeSecs, mtimeNanoSecs)) + .AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/VxFS/Info.cs b/Aaru.Filesystems/VxFS/Info.cs index 63da51199..932fad542 100644 --- a/Aaru.Filesystems/VxFS/Info.cs +++ b/Aaru.Filesystems/VxFS/Info.cs @@ -47,13 +47,11 @@ public sealed partial class VxFS { ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; - if(partition.Start + vmfsSuperOff >= partition.End) - return false; + if(partition.Start + vmfsSuperOff >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var magic = BitConverter.ToUInt32(sector, 0x00); @@ -70,8 +68,7 @@ public sealed partial class VxFS ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -81,26 +78,25 @@ public sealed partial class VxFS sbInformation.AppendFormat(Localization.Volume_version_0, vxSb.vs_version).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(vxSb.vs_fname, encoding)). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(vxSb.vs_fname, encoding)) + .AppendLine(); - sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, vxSb.vs_bsize, vxSb.vs_size). - AppendLine(); + sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, vxSb.vs_bsize, vxSb.vs_size) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_inodes_per_block, vxSb.vs_inopb).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_free_inodes, vxSb.vs_ifree).AppendLine(); sbInformation.AppendFormat(Localization.Volume_has_0_free_blocks, vxSb.vs_free).AppendLine(); sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)) + .AppendLine(); sbInformation.AppendFormat(Localization.Volume_last_modified_on_0, - DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)) + .AppendLine(); - if(vxSb.vs_clean != 0) - sbInformation.AppendLine(Localization.Volume_is_dirty); + if(vxSb.vs_clean != 0) sbInformation.AppendLine(Localization.Volume_is_dirty); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/XFS/Info.cs b/Aaru.Filesystems/XFS/Info.cs index 02bec98b7..6dc6fc9a8 100644 --- a/Aaru.Filesystems/XFS/Info.cs +++ b/Aaru.Filesystems/XFS/Info.cs @@ -46,72 +46,69 @@ public sealed partial class XFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; // Misaligned if(imagePlugin.Info.MetadataMediaType == MetadataMediaType.OpticalDisc) { var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) - sbSize++; + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; var sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] - { - 0, 0x200, 0x400 - }) + { + 0, 0x200, 0x400 + }) { Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2, location, - xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_X3_equals_1_expected_2, + location, + xfsSb.magicnum, + XFS_MAGIC); - if(xfsSb.magicnum == XFS_MAGIC) - return true; + if(xfsSb.magicnum == XFS_MAGIC) return true; } } else { foreach(int i in new[] - { - 0, 1, 2 - }) + { + 0, 1, 2 + }) { var location = (ulong)i; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2, location, - xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_expected_2, + location, + xfsSb.magicnum, + XFS_MAGIC); - if(xfsSb.magicnum == XFS_MAGIC) - return true; + if(xfsSb.magicnum == XFS_MAGIC) return true; } } @@ -126,8 +123,7 @@ public sealed partial class XFS information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; var xfsSb = new Superblock(); @@ -136,62 +132,61 @@ public sealed partial class XFS { var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) - sbSize++; + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) - return; + if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return; var sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] - { - 0, 0x200, 0x400 - }) + { + 0, 0x200, 0x400 + }) { Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_X3_equals_1_expected_2, location, - xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_X3_equals_1_expected_2, + location, + xfsSb.magicnum, + XFS_MAGIC); - if(xfsSb.magicnum == XFS_MAGIC) - break; + if(xfsSb.magicnum == XFS_MAGIC) break; } } else { foreach(int i in new[] - { - 0, 1, 2 - }) + { + 0, 1, 2 + }) { var location = (ulong)i; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + location, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) - return; + if(errno != ErrorNumber.NoError || sector.Length < Marshal.SizeOf()) return; xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.magic_at_0_equals_1_expected_2, location, - xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.magic_at_0_equals_1_expected_2, + location, + xfsSb.magicnum, + XFS_MAGIC); - if(xfsSb.magicnum == XFS_MAGIC) - break; + if(xfsSb.magicnum == XFS_MAGIC) break; } } - if(xfsSb.magicnum != XFS_MAGIC) - return; + if(xfsSb.magicnum != XFS_MAGIC) return; var sb = new StringBuilder(); @@ -205,8 +200,7 @@ public sealed partial class XFS sb.AppendFormat(Localization._0_allocation_groups_in_volume, xfsSb.agcount).AppendLine(); sb.AppendFormat(Localization._0_inodes_in_volume_1_free, xfsSb.icount, xfsSb.ifree).AppendLine(); - if(xfsSb.inprogress > 0) - sb.AppendLine(Localization.fsck_in_progress); + if(xfsSb.inprogress > 0) sb.AppendLine(Localization.fsck_in_progress); sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(xfsSb.fname, encoding)).AppendLine(); sb.AppendFormat(Localization.Volume_UUID_0, xfsSb.uuid).AppendLine(); diff --git a/Aaru.Filesystems/Xia/Info.cs b/Aaru.Filesystems/Xia/Info.cs index 8ddb9e5c3..801b3a97e 100644 --- a/Aaru.Filesystems/Xia/Info.cs +++ b/Aaru.Filesystems/Xia/Info.cs @@ -53,16 +53,13 @@ public sealed partial class Xia int sbSizeInBytes = Marshal.SizeOf(); var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); - if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) - sbSizeInSectors++; + if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; - if(sbSizeInSectors + partition.Start >= partition.End) - return false; + if(sbSizeInSectors + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); @@ -81,43 +78,45 @@ public sealed partial class Xia int sbSizeInBytes = Marshal.SizeOf(); var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); - if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) - sbSizeInSectors++; + if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); sb.AppendFormat(Localization._0_bytes_per_zone, supblk.s_zone_size).AppendLine(); - sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, supblk.s_nzones, supblk.s_nzones * supblk.s_zone_size). - AppendLine(); + sb.AppendFormat(Localization._0_zones_in_volume_1_bytes, supblk.s_nzones, supblk.s_nzones * supblk.s_zone_size) + .AppendLine(); sb.AppendFormat(Localization._0_inodes, supblk.s_ninodes).AppendLine(); - sb.AppendFormat(Localization._0_data_zones_1_bytes, supblk.s_ndatazones, - supblk.s_ndatazones * supblk.s_zone_size). - AppendLine(); + sb.AppendFormat(Localization._0_data_zones_1_bytes, + supblk.s_ndatazones, + supblk.s_ndatazones * supblk.s_zone_size) + .AppendLine(); - sb.AppendFormat(Localization._0_imap_zones_1_bytes, supblk.s_imap_zones, - supblk.s_imap_zones * supblk.s_zone_size). - AppendLine(); + sb.AppendFormat(Localization._0_imap_zones_1_bytes, + supblk.s_imap_zones, + supblk.s_imap_zones * supblk.s_zone_size) + .AppendLine(); - sb.AppendFormat(Localization._0_zmap_zones_1_bytes, supblk.s_zmap_zones, - supblk.s_zmap_zones * supblk.s_zone_size). - AppendLine(); + sb.AppendFormat(Localization._0_zmap_zones_1_bytes, + supblk.s_zmap_zones, + supblk.s_zmap_zones * supblk.s_zone_size) + .AppendLine(); sb.AppendFormat(Localization.First_data_zone_0, supblk.s_firstdatazone).AppendLine(); - sb.AppendFormat(Localization.Maximum_filesize_is_0_bytes_1_MiB, supblk.s_max_size, supblk.s_max_size / 1048576). - AppendLine(); + sb.AppendFormat(Localization.Maximum_filesize_is_0_bytes_1_MiB, supblk.s_max_size, supblk.s_max_size / 1048576) + .AppendLine(); - sb.AppendFormat(Localization._0_zones_reserved_for_kernel_images_1_bytes, supblk.s_kernzones, - supblk.s_kernzones * supblk.s_zone_size). - AppendLine(); + sb.AppendFormat(Localization._0_zones_reserved_for_kernel_images_1_bytes, + supblk.s_kernzones, + supblk.s_kernzones * supblk.s_zone_size) + .AppendLine(); sb.AppendFormat(Localization.First_kernel_zone_0, supblk.s_firstkernzone).AppendLine(); diff --git a/Aaru.Filesystems/ZFS/Helpers.cs b/Aaru.Filesystems/ZFS/Helpers.cs index 6d3ae298e..027f666d8 100644 --- a/Aaru.Filesystems/ZFS/Helpers.cs +++ b/Aaru.Filesystems/ZFS/Helpers.cs @@ -77,11 +77,9 @@ public sealed partial class ZFS { decodedNvList = new Dictionary(); - if(nvlist == null || nvlist.Length < 16) - return false; + if(nvlist == null || nvlist.Length < 16) return false; - if(!xdr) - return false; + if(!xdr) return false; var offset = 8; @@ -93,8 +91,7 @@ public sealed partial class ZFS item.encodedSize = BigEndianBitConverter.ToUInt32(nvlist, offset); // Finished - if(item.encodedSize == 0) - break; + if(item.encodedSize == 0) break; offset += 4; item.decodedSize = BigEndianBitConverter.ToUInt32(nvlist, offset); @@ -102,8 +99,7 @@ public sealed partial class ZFS var nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - if(nameLength % 4 > 0) - nameLength += 4 - nameLength % 4; + if(nameLength % 4 > 0) nameLength += 4 - nameLength % 4; var nameBytes = new byte[nameLength]; Array.Copy(nvlist, offset, nameBytes, 0, nameLength); @@ -157,8 +153,7 @@ public sealed partial class ZFS Array.Copy(nvlist, offset, byteArray, 0, item.elements); offset += (int)item.elements; - if(item.elements % 4 > 0) - offset += 4 - (int)(item.elements % 4); + if(item.elements % 4 > 0) offset += 4 - (int)(item.elements % 4); item.value = byteArray; } @@ -295,8 +290,7 @@ public sealed partial class ZFS item.value = sbyteArray; - if(sbyteArray.Length % 4 > 0) - offset += 4 - sbyteArray.Length % 4; + if(sbyteArray.Length % 4 > 0) offset += 4 - sbyteArray.Length % 4; } else { @@ -320,8 +314,7 @@ public sealed partial class ZFS stringArray[i] = StringHandlers.CToString(strBytes); offset += (int)strLength; - if(strLength % 4 > 0) - offset += 4 - (int)(strLength % 4); + if(strLength % 4 > 0) offset += 4 - (int)(strLength % 4); } item.value = stringArray; @@ -335,8 +328,7 @@ public sealed partial class ZFS item.value = StringHandlers.CToString(strBytes); offset += (int)strLength; - if(strLength % 4 > 0) - offset += 4 - (int)(strLength % 4); + if(strLength % 4 > 0) offset += 4 - (int)(strLength % 4); } break; @@ -407,8 +399,7 @@ public sealed partial class ZFS break; case NVS_DataTypes.DATA_TYPE_NVLIST: - if(item.elements > 1) - goto default; + if(item.elements > 1) goto default; var subListBytes = new byte[item.encodedSize - (offset - currOff)]; Array.Copy(nvlist, offset, subListBytes, 0, subListBytes.Length); @@ -587,14 +578,15 @@ public sealed partial class ZFS case NVS_DataTypes.DATA_TYPE_NVLIST: if(item.elements == 1) { - sb.Append($"{item.name} =\n{PrintNvList((Dictionary)item.value)}"). - AppendLine(); + sb.Append($"{item.name} =\n{PrintNvList((Dictionary)item.value)}") + .AppendLine(); } else { - sb.AppendFormat(Localization._0_equals_1_elements_nvlist_array_unable_to_print, item.name, - item.elements). - AppendLine(); + sb.AppendFormat(Localization._0_equals_1_elements_nvlist_array_unable_to_print, + item.name, + item.elements) + .AppendLine(); } break; @@ -603,14 +595,14 @@ public sealed partial class ZFS { for(var i = 0; i < item.elements; i++) { - sb.AppendFormat(Localization._0_1_equals_unknown_data_type_2, item.name, i, item.dataType). - AppendLine(); + sb.AppendFormat(Localization._0_1_equals_unknown_data_type_2, item.name, i, item.dataType) + .AppendLine(); } } else { - sb.AppendFormat(Localization._0_equals_unknown_data_type_1, item.name, item.dataType). - AppendLine(); + sb.AppendFormat(Localization._0_equals_unknown_data_type_1, item.name, item.dataType) + .AppendLine(); } break; diff --git a/Aaru.Filesystems/ZFS/Info.cs b/Aaru.Filesystems/ZFS/Info.cs index b819e1fc1..23b929156 100644 --- a/Aaru.Filesystems/ZFS/Info.cs +++ b/Aaru.Filesystems/ZFS/Info.cs @@ -69,8 +69,7 @@ public sealed partial class ZFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; byte[] sector; ulong magic; @@ -80,22 +79,18 @@ public sealed partial class ZFS { errno = imagePlugin.ReadSector(partition.Start + 31, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; magic = BitConverter.ToUInt64(sector, 0x1D8); - if(magic is ZEC_MAGIC or ZEC_CIGAM) - return true; + if(magic is ZEC_MAGIC or ZEC_CIGAM) return true; } - if(partition.Start + 16 >= partition.End) - return false; + if(partition.Start + 16 >= partition.End) return false; errno = imagePlugin.ReadSector(partition.Start + 16, out sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; magic = BitConverter.ToUInt64(sector, 0x1D8); @@ -111,8 +106,7 @@ public sealed partial class ZFS metadata = new FileSystem(); ErrorNumber errno; - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; byte[] sector; ulong magic; @@ -124,26 +118,22 @@ public sealed partial class ZFS { errno = imagePlugin.ReadSector(partition.Start + 31, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; magic = BitConverter.ToUInt64(sector, 0x1D8); - if(magic is ZEC_MAGIC or ZEC_CIGAM) - nvlistOff = 32; + if(magic is ZEC_MAGIC or ZEC_CIGAM) nvlistOff = 32; } if(partition.Start + 16 < partition.End) { errno = imagePlugin.ReadSector(partition.Start + 16, out sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; magic = BitConverter.ToUInt64(sector, 0x1D8); - if(magic is ZEC_MAGIC or ZEC_CIGAM) - nvlistOff = 17; + if(magic is ZEC_MAGIC or ZEC_CIGAM) nvlistOff = 17; } var sb = new StringBuilder(); @@ -151,8 +141,7 @@ public sealed partial class ZFS errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; sb.AppendLine(!DecodeNvList(nvlist, out Dictionary decodedNvList) ? "Could not decode nvlist" @@ -165,14 +154,11 @@ public sealed partial class ZFS Type = FS_TYPE }; - if(decodedNvList.TryGetValue("name", out NVS_Item tmpObj)) - metadata.VolumeName = (string)tmpObj.value; + if(decodedNvList.TryGetValue("name", out NVS_Item tmpObj)) metadata.VolumeName = (string)tmpObj.value; - if(decodedNvList.TryGetValue("guid", out tmpObj)) - metadata.VolumeSerial = $"{(ulong)tmpObj.value}"; + if(decodedNvList.TryGetValue("guid", out tmpObj)) metadata.VolumeSerial = $"{(ulong)tmpObj.value}"; - if(decodedNvList.TryGetValue("pool_guid", out tmpObj)) - metadata.VolumeSetIdentifier = $"{(ulong)tmpObj.value}"; + if(decodedNvList.TryGetValue("pool_guid", out tmpObj)) metadata.VolumeSetIdentifier = $"{(ulong)tmpObj.value}"; } #endregion diff --git a/Aaru.Filesystems/dump/Consts.cs b/Aaru.Filesystems/dump/Consts.cs index 0aaca7ef3..04e946f84 100644 --- a/Aaru.Filesystems/dump/Consts.cs +++ b/Aaru.Filesystems/dump/Consts.cs @@ -31,7 +31,6 @@ // ****************************************************************************/ using System.Diagnostics.CodeAnalysis; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/dump/Info.cs b/Aaru.Filesystems/dump/Info.cs index 36dac017b..b2e8ab581 100644 --- a/Aaru.Filesystems/dump/Info.cs +++ b/Aaru.Filesystems/dump/Info.cs @@ -38,7 +38,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Partition = Aaru.CommonTypes.Partition; -using ufs_daddr_t = int; namespace Aaru.Filesystems; @@ -53,25 +52,20 @@ public sealed partial class Dump /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; // It should be start of a tape or floppy or file - if(partition.Start != 0) - return false; + if(partition.Start != 0) return false; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(sector.Length < Marshal.SizeOf()) - return false; + if(sector.Length < Marshal.SizeOf()) return false; spcl16 oldHdr = Marshal.ByteArrayToStructureLittleEndian(sector); spcl_aix aixHdr = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -98,24 +92,19 @@ public sealed partial class Dump information = ""; metadata = new FileSystem(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; - if(partition.Start != 0) - return; + if(partition.Start != 0) return; var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; - if(sector.Length < Marshal.SizeOf()) - return; + if(sector.Length < Marshal.SizeOf()) return; spcl16 oldHdr = Marshal.ByteArrayToStructureLittleEndian(sector); spcl_aix aixHdr = Marshal.ByteArrayToStructureLittleEndian(sector); @@ -138,8 +127,7 @@ public sealed partial class Dump { useAix = true; - if(aixHdr.c_magic == XIX_CIGAM) - aixHdr = Marshal.ByteArrayToStructureBigEndian(sector); + if(aixHdr.c_magic == XIX_CIGAM) aixHdr = Marshal.ByteArrayToStructureBigEndian(sector); } else if(oldHdr.c_magic == OFS_MAGIC) { @@ -244,18 +232,15 @@ public sealed partial class Dump string str = StringHandlers.CToString(newHdr.c_filesys); - if(!string.IsNullOrEmpty(str)) - sb.AppendFormat(Localization.Dumped_filesystem_name_0, str).AppendLine(); + if(!string.IsNullOrEmpty(str)) sb.AppendFormat(Localization.Dumped_filesystem_name_0, str).AppendLine(); str = StringHandlers.CToString(newHdr.c_dev); - if(!string.IsNullOrEmpty(str)) - sb.AppendFormat(Localization.Dumped_device_0, str).AppendLine(); + if(!string.IsNullOrEmpty(str)) sb.AppendFormat(Localization.Dumped_device_0, str).AppendLine(); str = StringHandlers.CToString(newHdr.c_host); - if(!string.IsNullOrEmpty(str)) - sb.AppendFormat(Localization.Dump_hostname_0, str).AppendLine(); + if(!string.IsNullOrEmpty(str)) sb.AppendFormat(Localization.Dump_hostname_0, str).AppendLine(); } information = sb.ToString(); diff --git a/Aaru.Filesystems/dump/Structs.cs b/Aaru.Filesystems/dump/Structs.cs index 7fb9069db..ba52f8c8c 100644 --- a/Aaru.Filesystems/dump/Structs.cs +++ b/Aaru.Filesystems/dump/Structs.cs @@ -32,7 +32,6 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/dump/dump.cs b/Aaru.Filesystems/dump/dump.cs index c8e305458..cf5fc4742 100644 --- a/Aaru.Filesystems/dump/dump.cs +++ b/Aaru.Filesystems/dump/dump.cs @@ -33,7 +33,6 @@ using System; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Interfaces; -using ufs_daddr_t = int; namespace Aaru.Filesystems; diff --git a/Aaru.Filesystems/exFAT/Info.cs b/Aaru.Filesystems/exFAT/Info.cs index f09749d16..d062a5d34 100644 --- a/Aaru.Filesystems/exFAT/Info.cs +++ b/Aaru.Filesystems/exFAT/Info.cs @@ -51,16 +51,13 @@ public sealed partial class exFAT /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(12 + partition.Start >= partition.End) - return false; + if(12 + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; - if(vbrSector.Length < 512) - return false; + if(vbrSector.Length < 512) return false; VolumeBootRecord vbr = Marshal.ByteArrayToStructureLittleEndian(vbrSector); @@ -78,62 +75,61 @@ public sealed partial class exFAT ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] vbrSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; VolumeBootRecord vbr = Marshal.ByteArrayToStructureLittleEndian(vbrSector); errno = imagePlugin.ReadSector(9 + partition.Start, out byte[] parametersSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; OemParameterTable parametersTable = Marshal.ByteArrayToStructureLittleEndian(parametersSector); errno = imagePlugin.ReadSector(11 + partition.Start, out byte[] chkSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; ChecksumSector chksector = Marshal.ByteArrayToStructureLittleEndian(chkSector); sb.AppendLine(Localization.Microsoft_exFAT); sb.AppendFormat(Localization.Partition_offset_0, vbr.offset).AppendLine(); - sb.AppendFormat(Localization.Volume_has_0_sectors_of_1_bytes_each_for_a_total_of_2_bytes, vbr.sectors, - 1 << vbr.sectorShift, vbr.sectors * (ulong)(1 << vbr.sectorShift)). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_sectors_of_1_bytes_each_for_a_total_of_2_bytes, + vbr.sectors, + 1 << vbr.sectorShift, + vbr.sectors * (ulong)(1 << vbr.sectorShift)) + .AppendLine(); - sb.AppendFormat(Localization.Volume_uses_clusters_of_0_sectors_1_bytes_each, 1 << vbr.clusterShift, - (1 << vbr.sectorShift) * (1 << vbr.clusterShift)). - AppendLine(); + sb.AppendFormat(Localization.Volume_uses_clusters_of_0_sectors_1_bytes_each, + 1 << vbr.clusterShift, + (1 << vbr.sectorShift) * (1 << vbr.clusterShift)) + .AppendLine(); - sb.AppendFormat(Localization.First_FAT_starts_at_sector_0_and_runs_for_1_sectors, vbr.fatOffset, vbr.fatLength). - AppendLine(); + sb.AppendFormat(Localization.First_FAT_starts_at_sector_0_and_runs_for_1_sectors, vbr.fatOffset, vbr.fatLength) + .AppendLine(); sb.AppendFormat(Localization.Volume_uses_0_FATs, vbr.fats).AppendLine(); sb.AppendFormat(Localization.Cluster_heap_starts_at_sector_0_contains_1_clusters_and_is_2_used, - vbr.clusterHeapOffset, vbr.clusterHeapLength, vbr.heapUsage). - AppendLine(); + vbr.clusterHeapOffset, + vbr.clusterHeapLength, + vbr.heapUsage) + .AppendLine(); sb.AppendFormat(Localization.Root_directory_starts_at_cluster_0, vbr.rootDirectoryCluster).AppendLine(); - sb.AppendFormat(Localization.Filesystem_revision_is_0_1, (vbr.revision & 0xFF00) >> 8, vbr.revision & 0xFF). - AppendLine(); + sb.AppendFormat(Localization.Filesystem_revision_is_0_1, (vbr.revision & 0xFF00) >> 8, vbr.revision & 0xFF) + .AppendLine(); sb.AppendFormat(Localization.Volume_serial_number_0_X8, vbr.volumeSerial).AppendLine(); sb.AppendFormat(Localization.BIOS_drive_is_0, vbr.drive).AppendLine(); - if(vbr.flags.HasFlag(VolumeFlags.SecondFatActive)) - sb.AppendLine(Localization.Second_FAT_is_in_use); + if(vbr.flags.HasFlag(VolumeFlags.SecondFatActive)) sb.AppendLine(Localization.Second_FAT_is_in_use); - if(vbr.flags.HasFlag(VolumeFlags.VolumeDirty)) - sb.AppendLine(Localization.Volume_is_dirty); + if(vbr.flags.HasFlag(VolumeFlags.VolumeDirty)) sb.AppendLine(Localization.Volume_is_dirty); - if(vbr.flags.HasFlag(VolumeFlags.MediaFailure)) - sb.AppendLine(Localization.Underlying_media_presented_errors); + if(vbr.flags.HasFlag(VolumeFlags.MediaFailure)) sb.AppendLine(Localization.Underlying_media_presented_errors); var count = 1; @@ -146,16 +142,16 @@ public sealed partial class exFAT sb.AppendFormat("\t" + Localization._0_bytes_per_page, parameter.pageSize).AppendLine(); sb.AppendFormat("\t" + Localization._0_spare_blocks, parameter.spareBlocks).AppendLine(); - sb.AppendFormat("\t" + Localization._0_nanoseconds_random_access_time, parameter.randomAccessTime). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_nanoseconds_random_access_time, parameter.randomAccessTime) + .AppendLine(); sb.AppendFormat("\t" + Localization._0_nanoseconds_program_time, parameter.programTime).AppendLine(); - sb.AppendFormat("\t" + Localization._0_nanoseconds_read_cycle_time, parameter.readCycleTime). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_nanoseconds_read_cycle_time, parameter.readCycleTime) + .AppendLine(); - sb.AppendFormat("\t" + Localization._0_nanoseconds_write_cycle_time, parameter.writeCycleTime). - AppendLine(); + sb.AppendFormat("\t" + Localization._0_nanoseconds_write_cycle_time, parameter.writeCycleTime) + .AppendLine(); } else if(parameter.OemParameterType != Guid.Empty) sb.AppendFormat(Localization.Found_unknown_parameter_type_0, parameter.OemParameterType).AppendLine(); diff --git a/Aaru.Filesystems/ext2FS/Info.cs b/Aaru.Filesystems/ext2FS/Info.cs index 217a8caec..bbd5b91c7 100644 --- a/Aaru.Filesystems/ext2FS/Info.cs +++ b/Aaru.Filesystems/ext2FS/Info.cs @@ -57,25 +57,21 @@ public sealed partial class ext2FS ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize; uint sbOff = SB_POS % imagePlugin.Info.SectorSize; - if(sbSectorOff + partition.Start >= partition.End) - return false; + if(sbSectorOff + partition.Start >= partition.End) return false; int sbSizeInBytes = Marshal.SizeOf(); var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); - if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) - sbSizeInSectors++; + if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var sb = new byte[sbSizeInBytes]; - if(sbOff + sbSizeInBytes > sbSector.Length) - return false; + if(sbOff + sbSizeInBytes > sbSector.Length) return false; Array.Copy(sbSector, sbOff, sb, 0, sbSizeInBytes); @@ -101,8 +97,7 @@ public sealed partial class ext2FS int sbSizeInBytes = Marshal.SizeOf(); var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); - if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) - sbSizeInSectors++; + if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize; uint sbOff = SB_POS % imagePlugin.Info.SectorSize; @@ -110,8 +105,7 @@ public sealed partial class ext2FS ErrorNumber errno = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sblock = new byte[sbSizeInBytes]; Array.Copy(sbSector, sbOff, sblock, 0, sbSizeInBytes); @@ -187,8 +181,9 @@ public sealed partial class ext2FS if(supblk.mkfs_t > 0) { sb.AppendFormat(Localization.Volume_was_created_on_0_for_1, - DateHandlers.UnixUnsignedToDateTime(supblk.mkfs_t), extOs). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(supblk.mkfs_t), + extOs) + .AppendLine(); metadata.CreationDate = DateHandlers.UnixUnsignedToDateTime(supblk.mkfs_t); } @@ -246,9 +241,11 @@ public sealed partial class ext2FS if(supblk.block_size == 0) // Then it is 1024 bytes supblk.block_size = 1024; - sb.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_for_a_total_of_2_bytes, blocks, - 1024 << (int)supblk.block_size, blocks * (ulong)(1024 << (int)supblk.block_size)). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_for_a_total_of_2_bytes, + blocks, + 1024 << (int)supblk.block_size, + blocks * (ulong)(1024 << (int)supblk.block_size)) + .AppendLine(); metadata.Clusters = blocks; metadata.ClusterSize = (uint)(1024 << (int)supblk.block_size); @@ -257,36 +254,37 @@ public sealed partial class ext2FS { if(supblk.mount_t > 0) { - sb.AppendFormat(Localization.Last_mounted_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.mount_t)). - AppendLine(); + sb.AppendFormat(Localization.Last_mounted_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.mount_t)) + .AppendLine(); } if(supblk.max_mount_c != -1) { sb.AppendFormat(Localization.Volume_has_been_mounted_0_times_of_a_maximum_of_1_mounts_before_checking, - supblk.mount_c, supblk.max_mount_c). - AppendLine(); + supblk.mount_c, + supblk.max_mount_c) + .AppendLine(); } else { - sb. - AppendFormat(Localization.Volume_has_been_mounted_0_times_with_no_maximum_no_of_mounts_before_checking, - supblk.mount_c). - AppendLine(); + sb.AppendFormat(Localization + .Volume_has_been_mounted_0_times_with_no_maximum_no_of_mounts_before_checking, + supblk.mount_c) + .AppendLine(); } if(!string.IsNullOrEmpty(StringHandlers.CToString(supblk.last_mount_dir, encoding))) { sb.AppendFormat(Localization.Last_mounted_at_0, - StringHandlers.CToString(supblk.last_mount_dir, encoding)). - AppendLine(); + StringHandlers.CToString(supblk.last_mount_dir, encoding)) + .AppendLine(); } if(!string.IsNullOrEmpty(StringHandlers.CToString(supblk.mount_options, encoding))) { sb.AppendFormat(Localization.Last_used_mount_options_were_0, - StringHandlers.CToString(supblk.mount_options, encoding)). - AppendLine(); + StringHandlers.CToString(supblk.mount_options, encoding)) + .AppendLine(); } } else @@ -295,8 +293,8 @@ public sealed partial class ext2FS if(supblk.max_mount_c != -1) { - sb.AppendFormat(Localization.Volume_can_be_mounted_0_times_before_checking, supblk.max_mount_c). - AppendLine(); + sb.AppendFormat(Localization.Volume_can_be_mounted_0_times_before_checking, supblk.max_mount_c) + .AppendLine(); } else sb.AppendLine(Localization.Volume_has_no_maximum_no_of_mounts_before_checking); @@ -307,21 +305,22 @@ public sealed partial class ext2FS if(supblk.check_inv > 0) { sb.AppendFormat(Localization.Last_checked_on_0_should_check_every_1_seconds, - DateHandlers.UnixUnsignedToDateTime(supblk.check_t), supblk.check_inv). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(supblk.check_t), + supblk.check_inv) + .AppendLine(); } else { - sb.AppendFormat(Localization.Last_checked_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.check_t)). - AppendLine(); + sb.AppendFormat(Localization.Last_checked_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.check_t)) + .AppendLine(); } } else { if(supblk.check_inv > 0) { - sb.AppendFormat(Localization.Volume_has_never_been_checked_should_check_every_0_, supblk.check_inv). - AppendLine(); + sb.AppendFormat(Localization.Volume_has_never_been_checked_should_check_every_0_, supblk.check_inv) + .AppendLine(); } else sb.AppendLine(Localization.Volume_has_never_been_checked); @@ -329,8 +328,8 @@ public sealed partial class ext2FS if(supblk.write_t > 0) { - sb.AppendFormat(Localization.Last_written_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.write_t)). - AppendLine(); + sb.AppendFormat(Localization.Last_written_on_0, DateHandlers.UnixUnsignedToDateTime(supblk.write_t)) + .AppendLine(); metadata.ModificationDate = DateHandlers.UnixUnsignedToDateTime(supblk.write_t); } @@ -362,8 +361,8 @@ public sealed partial class ext2FS if(!string.IsNullOrEmpty(StringHandlers.CToString(supblk.volume_name, encoding))) { - sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(supblk.volume_name, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(supblk.volume_name, encoding)) + .AppendLine(); metadata.VolumeName = StringHandlers.CToString(supblk.volume_name, encoding); } @@ -383,8 +382,8 @@ public sealed partial class ext2FS break; default: - sb.AppendFormat(Localization.On_errors_filesystem_will_do_an_unknown_thing_0, supblk.err_behaviour). - AppendLine(); + sb.AppendFormat(Localization.On_errors_filesystem_will_do_an_unknown_thing_0, supblk.err_behaviour) + .AppendLine(); break; } @@ -404,21 +403,23 @@ public sealed partial class ext2FS sb.AppendFormat(Localization._0_reserved_and_1_free_blocks, reserved, free).AppendLine(); metadata.FreeClusters = free; - sb.AppendFormat(Localization._0_inodes_with_1_free_inodes_2, supblk.inodes, supblk.free_inodes, - supblk.free_inodes * 100 / supblk.inodes). - AppendLine(); + sb.AppendFormat(Localization._0_inodes_with_1_free_inodes_2, + supblk.inodes, + supblk.free_inodes, + supblk.free_inodes * 100 / supblk.inodes) + .AppendLine(); - if(supblk.first_inode > 0) - sb.AppendFormat(Localization.First_inode_is_0, supblk.first_inode).AppendLine(); + if(supblk.first_inode > 0) sb.AppendFormat(Localization.First_inode_is_0, supblk.first_inode).AppendLine(); - if(supblk.frag_size > 0) - sb.AppendFormat(Localization._0_bytes_per_fragment, supblk.frag_size).AppendLine(); + if(supblk.frag_size > 0) sb.AppendFormat(Localization._0_bytes_per_fragment, supblk.frag_size).AppendLine(); if(supblk.blocks_per_grp > 0 && supblk is { flags_per_grp: > 0, inodes_per_grp: > 0 }) { - sb.AppendFormat(Localization._0_blocks_1_flags_and_2_inodes_per_group, supblk.blocks_per_grp, - supblk.flags_per_grp, supblk.inodes_per_grp). - AppendLine(); + sb.AppendFormat(Localization._0_blocks_1_flags_and_2_inodes_per_group, + supblk.blocks_per_grp, + supblk.flags_per_grp, + supblk.inodes_per_grp) + .AppendLine(); } if(supblk.first_block > 0) @@ -435,17 +436,17 @@ public sealed partial class ext2FS if(supblk.first_meta_bg > 0) sb.AppendFormat(Localization.First_metablock_group_is_0, supblk.first_meta_bg).AppendLine(); - if(supblk.raid_stride > 0) - sb.AppendFormat(Localization.RAID_stride_0, supblk.raid_stride).AppendLine(); + if(supblk.raid_stride > 0) sb.AppendFormat(Localization.RAID_stride_0, supblk.raid_stride).AppendLine(); if(supblk.raid_stripe_width > 0) sb.AppendFormat(Localization._0_blocks_on_all_data_disks, supblk.raid_stripe_width).AppendLine(); if(supblk is { mmp_interval: > 0, mmp_block: > 0 }) { - sb.AppendFormat(Localization._0_seconds_for_multi_mount_protection_wait_on_block_1, supblk.mmp_interval, - supblk.mmp_block). - AppendLine(); + sb.AppendFormat(Localization._0_seconds_for_multi_mount_protection_wait_on_block_1, + supblk.mmp_interval, + supblk.mmp_block) + .AppendLine(); } if(supblk.flex_bg_grp_size > 0) @@ -453,9 +454,13 @@ public sealed partial class ext2FS if(supblk is { hash_seed_1: > 0, hash_seed_2: > 0 } and { hash_seed_3: > 0, hash_seed_4: > 0 }) { - sb.AppendFormat(Localization.Hash_seed_0_1_2_3_version_4, supblk.hash_seed_1, supblk.hash_seed_2, - supblk.hash_seed_3, supblk.hash_seed_4, supblk.hash_version). - AppendLine(); + sb.AppendFormat(Localization.Hash_seed_0_1_2_3_version_4, + supblk.hash_seed_1, + supblk.hash_seed_2, + supblk.hash_seed_3, + supblk.hash_seed_4, + supblk.hash_version) + .AppendLine(); } if((supblk.ftr_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) == EXT3_FEATURE_COMPAT_HAS_JOURNAL || @@ -485,11 +490,13 @@ public sealed partial class ext2FS { if(supblk.snapshot_id > 0) { - sb. - AppendFormat(Localization.Active_snapshot_has_ID_0_on_inode_1_with_2_blocks_reserved_list_starting_on_block_3, - supblk.snapshot_id, supblk.snapshot_inum, supblk.snapshot_blocks, - supblk.snapshot_list). - AppendLine(); + sb.AppendFormat(Localization + .Active_snapshot_has_ID_0_on_inode_1_with_2_blocks_reserved_list_starting_on_block_3, + supblk.snapshot_id, + supblk.snapshot_inum, + supblk.snapshot_blocks, + supblk.snapshot_list) + .AppendLine(); } if(supblk.error_count > 0) @@ -498,20 +505,23 @@ public sealed partial class ext2FS sb.AppendFormat(Localization.First_error_occurred_on_0_last_on_1, DateHandlers.UnixUnsignedToDateTime(supblk.first_error_t), - DateHandlers.UnixUnsignedToDateTime(supblk.last_error_t)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(supblk.last_error_t)) + .AppendLine(); - sb.AppendFormat(Localization.First_error_inode_is_0_last_is_1, supblk.first_error_inode, - supblk.last_error_inode). - AppendLine(); + sb.AppendFormat(Localization.First_error_inode_is_0_last_is_1, + supblk.first_error_inode, + supblk.last_error_inode) + .AppendLine(); - sb.AppendFormat(Localization.First_error_block_is_0_last_is_1, supblk.first_error_block, - supblk.last_error_block). - AppendLine(); + sb.AppendFormat(Localization.First_error_block_is_0_last_is_1, + supblk.first_error_block, + supblk.last_error_block) + .AppendLine(); - sb.AppendFormat(Localization.First_error_function_is_0_last_is_1, supblk.first_error_func, - supblk.last_error_func). - AppendLine(); + sb.AppendFormat(Localization.First_error_function_is_0_last_is_1, + supblk.first_error_func, + supblk.last_error_func) + .AppendLine(); } } @@ -526,8 +536,7 @@ public sealed partial class ext2FS if((supblk.flags & EXT2_FLAGS_TEST_FILESYS) == EXT2_FLAGS_TEST_FILESYS) sb.AppendLine(Localization.Volume_is_testing_development_code); - if((supblk.flags & 0xFFFFFFF8) != 0) - sb.AppendFormat(Localization.Unknown_set_flags_0, supblk.flags); + if((supblk.flags & 0xFFFFFFF8) != 0) sb.AppendFormat(Localization.Unknown_set_flags_0, supblk.flags); sb.AppendLine(); diff --git a/Aaru.Filesystems/extFS/Info.cs b/Aaru.Filesystems/extFS/Info.cs index 9637360cb..2592d8482 100644 --- a/Aaru.Filesystems/extFS/Info.cs +++ b/Aaru.Filesystems/extFS/Info.cs @@ -47,24 +47,20 @@ public sealed partial class extFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - if(imagePlugin.Info.SectorSize < 512) - return false; + if(imagePlugin.Info.SectorSize < 512) return false; ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize; uint sbOff = SB_POS % imagePlugin.Info.SectorSize; - if(sbSectorOff + partition.Start >= partition.End) - return false; + if(sbSectorOff + partition.Start >= partition.End) return false; ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sbSector); - if(errno != ErrorNumber.NoError) - return false; + if(errno != ErrorNumber.NoError) return false; var sb = new byte[512]; - if(sbOff + 512 > sbSector.Length) - return false; + if(sbOff + 512 > sbSector.Length) return false; Array.Copy(sbSector, sbOff, sb, 0, 512); @@ -82,19 +78,16 @@ public sealed partial class extFS var sb = new StringBuilder(); - if(imagePlugin.Info.SectorSize < 512) - return; + if(imagePlugin.Info.SectorSize < 512) return; ulong sbSectorOff = SB_POS / imagePlugin.Info.SectorSize; uint sbOff = SB_POS % imagePlugin.Info.SectorSize; - if(sbSectorOff + partition.Start >= partition.End) - return; + if(sbSectorOff + partition.Start >= partition.End) return; ErrorNumber errno = imagePlugin.ReadSector(sbSectorOff + partition.Start, out byte[] sblock); - if(errno != ErrorNumber.NoError) - return; + if(errno != ErrorNumber.NoError) return; var sbSector = new byte[512]; Array.Copy(sblock, sbOff, sbSector, 0, 512); @@ -116,7 +109,9 @@ public sealed partial class extFS sb.AppendFormat(Localization._0_zones_in_volume, extSb.zones); sb.AppendFormat(Localization._0_free_blocks_1_bytes, extSb.freecountblk, extSb.freecountblk * 1024); - sb.AppendFormat(Localization._0_inodes_in_volume_1_free_2, extSb.inodes, extSb.freecountind, + sb.AppendFormat(Localization._0_inodes_in_volume_1_free_2, + extSb.inodes, + extSb.freecountind, extSb.freecountind * 100 / extSb.inodes); sb.AppendFormat(Localization.First_free_inode_is_0, extSb.firstfreeind); diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index 8ccff5ba1..d0be78a76 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -109,10 +109,12 @@ public sealed class AppleDouble : IFilter /// public Stream GetResourceForkStream() { - if(_rsrcFork.length == 0) - return null; + if(_rsrcFork.length == 0) return null; - return new OffsetStream(_headerPath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, + return new OffsetStream(_headerPath, + FileMode.Open, + FileAccess.Read, + _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); } @@ -134,8 +136,7 @@ public sealed class AppleDouble : IFilter parentFolder ??= ""; - if(filename is null || filenameNoExt is null) - return false; + if(filename is null || filenameNoExt is null) return false; // Prepend data fork name with "R." string proDosAppleDouble = System.IO.Path.Combine(parentFolder, "R." + filename); @@ -173,8 +174,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -190,8 +190,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -207,8 +206,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -224,8 +222,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -241,8 +238,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -258,8 +254,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } @@ -275,19 +270,16 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - return true; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) return true; } } // Check AppleDouble created by UnAr (from The Unarchiver) - if(!File.Exists(unArAppleDouble)) - return false; + if(!File.Exists(unArAppleDouble)) return false; var unarStream = new FileStream(unArAppleDouble, FileMode.Open, FileAccess.Read); - if(unarStream.Length <= 26) - return false; + if(unarStream.Length <= 26) return false; var unarB = new byte[26]; unarStream.EnsureRead(unarB, 0, 26); @@ -314,8 +306,7 @@ public sealed class AppleDouble : IFilter parentFolder ??= ""; - if(filename is null || filenameNoExt is null) - return ErrorNumber.InvalidArgument; + if(filename is null || filenameNoExt is null) return ErrorNumber.InvalidArgument; // Prepend data fork name with "R." string proDosAppleDouble = System.IO.Path.Combine(parentFolder, "R." + filename); @@ -353,8 +344,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = proDosAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = proDosAppleDouble; } } @@ -370,8 +360,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = unixAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = unixAppleDouble; } } @@ -387,8 +376,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = dosAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = dosAppleDouble; } } @@ -404,8 +392,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = dosAppleDoubleLower; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = dosAppleDoubleLower; } } @@ -421,8 +408,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = netatalkAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = netatalkAppleDouble; } } @@ -438,8 +424,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = daveAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = daveAppleDouble; } } @@ -455,8 +440,7 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = osxAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = osxAppleDouble; } } @@ -472,14 +456,12 @@ public sealed class AppleDouble : IFilter _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); - if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) - _headerPath = unArAppleDouble; + if(_header is { magic: MAGIC, version: VERSION or VERSION2 }) _headerPath = unArAppleDouble; } } // TODO: More appropriate error - if(_headerPath is null) - return ErrorNumber.NotSupported; + if(_headerPath is null) return ErrorNumber.NotSupported; var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index 1fdb885ab..0eea24538 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -97,18 +97,18 @@ public sealed class AppleSingle : IFilter /// public Stream GetDataForkStream() { - if(_dataFork.length == 0) - return null; + if(_dataFork.length == 0) return null; - if(_isBytes) - return new OffsetStream(_bytes, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); + if(_isBytes) return new OffsetStream(_bytes, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); - if(_isStream) - return new OffsetStream(_stream, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); + if(_isStream) return new OffsetStream(_stream, _dataFork.offset, _dataFork.offset + _dataFork.length - 1); if(_isPath) { - return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _dataFork.offset, + return new OffsetStream(BasePath, + FileMode.Open, + FileAccess.Read, + _dataFork.offset, _dataFork.offset + _dataFork.length - 1); } @@ -136,18 +136,18 @@ public sealed class AppleSingle : IFilter /// public Stream GetResourceForkStream() { - if(_rsrcFork.length == 0) - return null; + if(_rsrcFork.length == 0) return null; - if(_isBytes) - return new OffsetStream(_bytes, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); + if(_isBytes) return new OffsetStream(_bytes, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); - if(_isStream) - return new OffsetStream(_stream, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); + if(_isStream) return new OffsetStream(_stream, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); if(_isPath) { - return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, + return new OffsetStream(BasePath, + FileMode.Open, + FileAccess.Read, + _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1); } @@ -160,8 +160,7 @@ public sealed class AppleSingle : IFilter /// public bool Identify(byte[] buffer) { - if(buffer == null || buffer.Length < 26) - return false; + if(buffer == null || buffer.Length < 26) return false; var hdrB = new byte[26]; Array.Copy(buffer, 0, hdrB, 0, 26); @@ -173,8 +172,7 @@ public sealed class AppleSingle : IFilter /// public bool Identify(Stream stream) { - if(stream == null || stream.Length < 26) - return false; + if(stream == null || stream.Length < 26) return false; var hdrB = new byte[26]; stream.Seek(0, SeekOrigin.Begin); @@ -187,13 +185,11 @@ public sealed class AppleSingle : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var fstream = new FileStream(path, FileMode.Open, FileAccess.Read); - if(fstream.Length < 26) - return false; + if(fstream.Length < 26) return false; var hdrB = new byte[26]; fstream.EnsureRead(hdrB, 0, 26); diff --git a/Aaru.Filters/BZip2.cs b/Aaru.Filters/BZip2.cs index 9ee51194c..d088cec67 100644 --- a/Aaru.Filters/BZip2.cs +++ b/Aaru.Filters/BZip2.cs @@ -87,8 +87,7 @@ public class BZip2 : IFilter if(buffer[0] != 0x42 || buffer[1] != 0x5A || buffer[2] != 0x68 || buffer[3] < 0x31 || buffer[3] > 0x39) return false; - if(buffer.Length <= 512) - return true; + if(buffer.Length <= 512) return true; return buffer[^512] != 0x6B || buffer[^511] != 0x6F || buffer[^510] != 0x6C || buffer[^509] != 0x79; } @@ -105,8 +104,7 @@ public class BZip2 : IFilter if(buffer[0] != 0x42 || buffer[1] != 0x5A || buffer[2] != 0x68 || buffer[3] < 0x31 || buffer[3] > 0x39) return false; - if(stream.Length <= 512) - return true; + if(stream.Length <= 512) return true; stream.Seek(-512, SeekOrigin.End); stream.EnsureRead(buffer, 0, 4); @@ -119,8 +117,7 @@ public class BZip2 : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var buffer = new byte[4]; @@ -132,8 +129,7 @@ public class BZip2 : IFilter if(buffer[0] != 0x42 || buffer[1] != 0x5A || buffer[2] != 0x68 || buffer[3] < 0x31 || buffer[3] > 0x39) return false; - if(stream.Length <= 512) - return true; + if(stream.Length <= 512) return true; stream.Seek(-512, SeekOrigin.End); stream.EnsureRead(buffer, 0, 4); @@ -204,8 +200,7 @@ public class BZip2 : IFilter { get { - if(BasePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true) - return BasePath[..^4]; + if(BasePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true) return BasePath[..^4]; return BasePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^6] diff --git a/Aaru.Filters/GZip.cs b/Aaru.Filters/GZip.cs index 5ee86f209..b2d88b6a9 100644 --- a/Aaru.Filters/GZip.cs +++ b/Aaru.Filters/GZip.cs @@ -100,8 +100,7 @@ public sealed class GZip : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var buffer = new byte[3]; @@ -214,8 +213,7 @@ public sealed class GZip : IFilter { get { - if(BasePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true) - return BasePath[..^3]; + if(BasePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true) return BasePath[..^3]; return BasePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5] diff --git a/Aaru.Filters/LZip.cs b/Aaru.Filters/LZip.cs index dff30c12b..3e876b0a2 100644 --- a/Aaru.Filters/LZip.cs +++ b/Aaru.Filters/LZip.cs @@ -104,8 +104,7 @@ public sealed class LZip : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var buffer = new byte[5]; @@ -187,8 +186,7 @@ public sealed class LZip : IFilter { get { - if(BasePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true) - return BasePath[..^3]; + if(BasePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true) return BasePath[..^3]; return BasePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5] diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index b4a700352..6a8c0fb5a 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -88,18 +88,18 @@ public sealed class MacBinary : IFilter /// public Stream GetDataForkStream() { - if(_header.dataLength == 0) - return null; + if(_header.dataLength == 0) return null; - if(_isBytes) - return new OffsetStream(_bytes, _dataForkOff, _dataForkOff + _header.dataLength - 1); + if(_isBytes) return new OffsetStream(_bytes, _dataForkOff, _dataForkOff + _header.dataLength - 1); - if(_isStream) - return new OffsetStream(_stream, _dataForkOff, _dataForkOff + _header.dataLength - 1); + if(_isStream) return new OffsetStream(_stream, _dataForkOff, _dataForkOff + _header.dataLength - 1); if(_isPath) { - return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _dataForkOff, + return new OffsetStream(BasePath, + FileMode.Open, + FileAccess.Read, + _dataForkOff, _dataForkOff + _header.dataLength - 1); } @@ -127,18 +127,18 @@ public sealed class MacBinary : IFilter /// public Stream GetResourceForkStream() { - if(_header.resourceLength == 0) - return null; + if(_header.resourceLength == 0) return null; - if(_isBytes) - return new OffsetStream(_bytes, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); + if(_isBytes) return new OffsetStream(_bytes, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); - if(_isStream) - return new OffsetStream(_stream, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); + if(_isStream) return new OffsetStream(_stream, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); if(_isPath) { - return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _rsrcForkOff, + return new OffsetStream(BasePath, + FileMode.Open, + FileAccess.Read, + _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1); } @@ -151,8 +151,7 @@ public sealed class MacBinary : IFilter /// public bool Identify(byte[] buffer) { - if(buffer == null || buffer.Length < 128) - return false; + if(buffer == null || buffer.Length < 128) return false; var hdrB = new byte[128]; Array.Copy(buffer, 0, hdrB, 0, 128); @@ -170,8 +169,7 @@ public sealed class MacBinary : IFilter /// public bool Identify(Stream stream) { - if(stream == null || stream.Length < 128) - return false; + if(stream == null || stream.Length < 128) return false; var hdrB = new byte[128]; stream.Seek(0, SeekOrigin.Begin); @@ -190,13 +188,11 @@ public sealed class MacBinary : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var fstream = new FileStream(path, FileMode.Open, FileAccess.Read); - if(fstream.Length < 128) - return false; + if(fstream.Length < 128) return false; var hdrB = new byte[128]; fstream.EnsureRead(hdrB, 0, 128); @@ -226,14 +222,12 @@ public sealed class MacBinary : IFilter uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); - if(_header.secondaryHeaderLength % 128 > 0) - blocks++; + if(_header.secondaryHeaderLength % 128 > 0) blocks++; _dataForkOff = blocks * 128; blocks += _header.dataLength / 128; - if(_header.dataLength % 128 > 0) - blocks++; + if(_header.dataLength % 128 > 0) blocks++; _rsrcForkOff = blocks * 128; @@ -260,14 +254,12 @@ public sealed class MacBinary : IFilter uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); - if(_header.secondaryHeaderLength % 128 > 0) - blocks++; + if(_header.secondaryHeaderLength % 128 > 0) blocks++; _dataForkOff = blocks * 128; blocks += _header.dataLength / 128; - if(_header.dataLength % 128 > 0) - blocks++; + if(_header.dataLength % 128 > 0) blocks++; _rsrcForkOff = blocks * 128; @@ -295,14 +287,12 @@ public sealed class MacBinary : IFilter uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); - if(_header.secondaryHeaderLength % 128 > 0) - blocks++; + if(_header.secondaryHeaderLength % 128 > 0) blocks++; _dataForkOff = blocks * 128; blocks += _header.dataLength / 128; - if(_header.dataLength % 128 > 0) - blocks++; + if(_header.dataLength % 128 > 0) blocks++; _rsrcForkOff = blocks * 128; @@ -360,7 +350,7 @@ public sealed class MacBinary : IFilter /// 0x65, Low byte of Finder flags public readonly byte finderFlags2; - #region MacBinary III +#region MacBinary III /// 0x66, magic identifier, "mBIN" public readonly uint magic; @@ -369,14 +359,14 @@ public sealed class MacBinary : IFilter /// 0x6B, fdXFlags from fxInfo, extended Mac OS 8 finder flags public readonly byte fdXFlags; - #endregion MacBinary III +#endregion MacBinary III /// 0x6C, unused public readonly ulong reserved; /// 0x74, Total unpacked files public readonly uint totalPackedFiles; - #region MacBinary II +#region MacBinary II /// 0x78, Length of secondary header public readonly ushort secondaryHeaderLength; @@ -387,7 +377,7 @@ public sealed class MacBinary : IFilter /// 0x7C, CRC of previous bytes public readonly short crc; - #endregion MacBinary II +#endregion MacBinary II /// 0x7E, Reserved for computer type and OS ID public readonly short computerID; diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index c6c4978c0..2ef576647 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -118,18 +118,17 @@ public sealed class PcExchange : IFilter parentFolder ??= ""; - if(!File.Exists(System.IO.Path.Combine(parentFolder, FINDER_INFO))) - return false; + if(!File.Exists(System.IO.Path.Combine(parentFolder, FINDER_INFO))) return false; - if(!Directory.Exists(System.IO.Path.Combine(parentFolder, RESOURCES))) - return false; + if(!Directory.Exists(System.IO.Path.Combine(parentFolder, RESOURCES))) return false; string baseFilename = System.IO.Path.GetFileName(path); var dataFound = false; var rsrcFound = false; - var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, + var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), + FileMode.Open, FileAccess.Read); while(finderDatStream.Position + 0x5C <= finderDatStream.Length) @@ -153,8 +152,7 @@ public sealed class PcExchange : IFilter string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); - if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) - continue; + if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) continue; dataFound |= File.Exists(System.IO.Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())) || @@ -186,7 +184,8 @@ public sealed class PcExchange : IFilter parentFolder ??= ""; - var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, + var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), + FileMode.Open, FileAccess.Read); while(finderDatStream.Position + 0x5C <= finderDatStream.Length) @@ -209,8 +208,7 @@ public sealed class PcExchange : IFilter string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); - if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) - continue; + if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) continue; if(File.Exists(System.IO.Path.Combine(parentFolder, macName ?? throw new InvalidOperationException()))) _dataPath = System.IO.Path.Combine(parentFolder, macName); diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs index b638cea27..79439d32f 100644 --- a/Aaru.Filters/XZ.cs +++ b/Aaru.Filters/XZ.cs @@ -97,8 +97,7 @@ public sealed class XZ : IFilter var buffer = new byte[6]; var footer = new byte[2]; - if(stream.Length < 8) - return false; + if(stream.Length < 8) return false; stream.Seek(0, SeekOrigin.Begin); stream.EnsureRead(buffer, 0, 6); @@ -119,15 +118,13 @@ public sealed class XZ : IFilter /// public bool Identify(string path) { - if(!File.Exists(path)) - return false; + if(!File.Exists(path)) return false; var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var buffer = new byte[6]; var footer = new byte[2]; - if(stream.Length < 8) - return false; + if(stream.Length < 8) return false; stream.Seek(0, SeekOrigin.Begin); stream.EnsureRead(buffer, 0, 6); @@ -206,8 +203,7 @@ public sealed class XZ : IFilter { get { - if(BasePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true) - return BasePath[..^3]; + if(BasePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true) return BasePath[..^3]; return BasePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5] @@ -266,8 +262,7 @@ public sealed class XZ : IFilter while((buf[i++] & 0x80) == 0x80) { - if(i >= sizeMax || buf[i] == 0x00) - return 0; + if(i >= sizeMax || buf[i] == 0x00) return 0; num |= (ulong)(buf[i] & 0x7F) << i * 7; } diff --git a/Aaru.Generators/PluginRegisterGenerator.cs b/Aaru.Generators/PluginRegisterGenerator.cs index 57975e559..c98ed03f8 100644 --- a/Aaru.Generators/PluginRegisterGenerator.cs +++ b/Aaru.Generators/PluginRegisterGenerator.cs @@ -31,8 +31,7 @@ public class PluginRegisterGenerator : ISourceGenerator ClassDeclarationSyntax pluginRegister = ((PluginFinder)context.SyntaxReceiver)?.Register; - if(pluginRegister == null) - return; + if(pluginRegister == null) return; var @namespace = (pluginRegister.Ancestors().FirstOrDefault(x => x is FileScopedNamespaceDeclarationSyntax) as @@ -111,8 +110,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterArchivePlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in archives.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -124,8 +125,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterChecksumPlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in checksums.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -137,8 +140,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterFilesystemPlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in fileSystems.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -150,8 +155,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterFilterPlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in filters.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -193,8 +200,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterPartitionPlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in partitionPlugins.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -206,8 +215,10 @@ public class PluginRegisterGenerator : ISourceGenerator { sb.AppendLine(" public void RegisterReadOnlyFilesystemPlugins(IServiceCollection services)"); sb.AppendLine(" {"); + foreach(string plugin in readOnlyFileSystems.Distinct()) sb.AppendLine($" services.AddTransient();"); + sb.AppendLine(" }"); } else @@ -282,84 +293,78 @@ public class PluginRegisterGenerator : ISourceGenerator public List ByteAddressableImagePlugins { get; } = new(); public ClassDeclarationSyntax Register { get; private set; } - #region ISyntaxReceiver Members +#region ISyntaxReceiver Members public void OnVisitSyntaxNode(SyntaxNode syntaxNode) { - if(syntaxNode is not ClassDeclarationSyntax plugin) - return; + if(syntaxNode is not ClassDeclarationSyntax plugin) return; - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IPluginRegister") == true) Register = plugin; - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IArchive") == true) { - if(!Archives.Contains(plugin.Identifier.Text)) - Archives.Add(plugin.Identifier.Text); + if(!Archives.Contains(plugin.Identifier.Text)) Archives.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IChecksum") == true) { - if(!Checksums.Contains(plugin.Identifier.Text)) - Checksums.Add(plugin.Identifier.Text); + if(!Checksums.Contains(plugin.Identifier.Text)) Checksums.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IFilesystem") == true) { - if(!FileSystems.Contains(plugin.Identifier.Text)) - FileSystems.Add(plugin.Identifier.Text); + if(!FileSystems.Contains(plugin.Identifier.Text)) FileSystems.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IFilter") == true) { - if(!Filters.Contains(plugin.Identifier.Text)) - Filters.Add(plugin.Identifier.Text); + if(!Filters.Contains(plugin.Identifier.Text)) Filters.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IFloppyImage") == true) { - if(!FloppyImagePlugins.Contains(plugin.Identifier.Text)) - FloppyImagePlugins.Add(plugin.Identifier.Text); + if(!FloppyImagePlugins.Contains(plugin.Identifier.Text)) FloppyImagePlugins.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText is "IMediaImage" or "IOpticalMediaImage" or "IFloppyImage" + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText is "IMediaImage" + or "IOpticalMediaImage" + or "IFloppyImage" or "ITapeImage") == true) { - if(!MediaImagePlugins.Contains(plugin.Identifier.Text)) - MediaImagePlugins.Add(plugin.Identifier.Text); + if(!MediaImagePlugins.Contains(plugin.Identifier.Text)) MediaImagePlugins.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IPartition") == true) { - if(!PartitionPlugins.Contains(plugin.Identifier.Text)) - PartitionPlugins.Add(plugin.Identifier.Text); + if(!PartitionPlugins.Contains(plugin.Identifier.Text)) PartitionPlugins.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IReadOnlyFilesystem") == true) { @@ -367,8 +372,8 @@ public class PluginRegisterGenerator : ISourceGenerator ReadOnlyFileSystems.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IWritableFloppyImage") == true) { @@ -376,17 +381,19 @@ public class PluginRegisterGenerator : ISourceGenerator WritableFloppyImagePlugins.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText is "IWritableImage" or "IWritableOpticalImage" - or "IWritableTapeImage" or "IByteAddressableImage") == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText is "IWritableImage" + or "IWritableOpticalImage" + or "IWritableTapeImage" + or "IByteAddressableImage") == true) { if(!WritableImagePlugins.Contains(plugin.Identifier.Text)) WritableImagePlugins.Add(plugin.Identifier.Text); } - if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier. - ValueText == + if(plugin.BaseList?.Types.Any(t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier + .ValueText == "IByteAddressableImage") == true) { @@ -398,7 +405,7 @@ public class PluginRegisterGenerator : ISourceGenerator FileSystems.AddRange(ReadOnlyFileSystems); } - #endregion +#endregion } #endregion diff --git a/Aaru.Gui/App.xaml b/Aaru.Gui/App.xaml index 02f5aa9c0..9f5dfa4f9 100644 --- a/Aaru.Gui/App.xaml +++ b/Aaru.Gui/App.xaml @@ -31,8 +31,10 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + @@ -44,9 +46,12 @@ - - - + + + \ No newline at end of file diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index c67e437ae..48b805676 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -63,8 +63,7 @@ public sealed class App : Application void OnSplashFinished(object sender, EventArgs e) { - if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) - return; + if(ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) return; // Ensure not exit desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown; diff --git a/Aaru.Gui/ConsoleHandler.cs b/Aaru.Gui/ConsoleHandler.cs index 4412bbb89..38183aebe 100644 --- a/Aaru.Gui/ConsoleHandler.cs +++ b/Aaru.Gui/ConsoleHandler.cs @@ -48,8 +48,7 @@ static class ConsoleHandler { set { - if(_debug == value) - return; + if(_debug == value) return; _debug = value; @@ -68,14 +67,13 @@ static class ConsoleHandler public static ObservableCollection Entries { get; } = new(); - static void OnWriteExceptionEvent([NotNull] Exception ex) => - Entries.Add(new LogEntry - { - Message = ex.ToString(), - Module = null, - Timestamp = DateTime.Now, - Type = UI.LogEntry_Type_Exception - }); + static void OnWriteExceptionEvent([NotNull] Exception ex) => Entries.Add(new LogEntry + { + Message = ex.ToString(), + Module = null, + Timestamp = DateTime.Now, + Type = UI.LogEntry_Type_Exception + }); internal static void Init() { @@ -85,8 +83,7 @@ static class ConsoleHandler static void OnWriteHandler([CanBeNull] string format, [CanBeNull] params object[] arg) { - if(format == null || arg == null) - return; + if(format == null || arg == null) return; Entries.Add(new LogEntry { @@ -99,8 +96,7 @@ static class ConsoleHandler static void OnErrorWriteHandler([CanBeNull] string format, [CanBeNull] params object[] arg) { - if(format == null || arg == null) - return; + if(format == null || arg == null) return; Entries.Add(new LogEntry { @@ -113,8 +109,7 @@ static class ConsoleHandler static void OnDebugWriteHandler(string module, [CanBeNull] string format, [CanBeNull] params object[] arg) { - if(format == null || arg == null) - return; + if(format == null || arg == null) return; Entries.Add(new LogEntry { diff --git a/Aaru.Gui/ViewLocator.cs b/Aaru.Gui/ViewLocator.cs index e75fdfd8a..f5edb9cc9 100644 --- a/Aaru.Gui/ViewLocator.cs +++ b/Aaru.Gui/ViewLocator.cs @@ -50,13 +50,11 @@ public sealed class ViewLocator : DataTemplate { string name = data.GetType().FullName?.Replace("ViewModel", "View"); - if(name is null) - return null; + if(name is null) return null; var type = Type.GetType(name); - if(type != null) - return (Control)Activator.CreateInstance(type); + if(type != null) return (Control)Activator.CreateInstance(type); return new TextBlock { diff --git a/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs index df653b468..5efc595e6 100644 --- a/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs @@ -75,8 +75,7 @@ public sealed class AboutViewModel : ViewModelBase (Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute)?.InformationalVersion; - if(name is null || version is null) - continue; + if(name is null || version is null) continue; Assemblies.Add(new AssemblyModel { diff --git a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs index 05c19234e..038d97825 100644 --- a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs @@ -108,8 +108,7 @@ public sealed class ConsoleViewModel : ViewModelBase string result = await dlgSave.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; try { @@ -128,7 +127,9 @@ public sealed class ConsoleViewModel : ViewModelBase logSw.WriteLine(Localization.Core.System_information); - logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, + logSw.WriteLine("{0} {1} ({2}-bit)", + DetectOS.GetPlatformName(platId, platVer), + platVer, Environment.Is64BitOperatingSystem ? 64 : 32); logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); @@ -138,9 +139,9 @@ public sealed class ConsoleViewModel : ViewModelBase logSw.WriteLine(Localization.Core.Program_information); logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion); logSw.WriteLine(Localization.Core.Running_in_0_bit, Environment.Is64BitProcess ? 64 : 32); - #if DEBUG +#if DEBUG logSw.WriteLine(Localization.Core.DEBUG_version); - #endif +#endif logSw.WriteLine(Localization.Core.Command_line_0, Environment.CommandLine); logSw.WriteLine(); @@ -160,10 +161,13 @@ public sealed class ConsoleViewModel : ViewModelBase catch(Exception exception) { await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Exception_0_trying_to_save_logfile_details_has_been_sent_to_console, - exception.Message), ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + string + .Format(UI + .Exception_0_trying_to_save_logfile_details_has_been_sent_to_console, + exception.Message), + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); AaruConsole.WriteException(exception); } diff --git a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs index 886e3a3f5..955d2151d 100644 --- a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs @@ -55,23 +55,22 @@ public sealed class EncodingsViewModel : ViewModelBase Task.Run(() => { - var encodings = Encoding.GetEncodings(). - Select(info => new EncodingModel + var encodings = Encoding.GetEncodings() + .Select(info => new EncodingModel { Name = info.Name, DisplayName = info.GetEncoding().EncodingName - }). - ToList(); + }) + .ToList(); - encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings(). - Select(info => new EncodingModel + encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings() + .Select(info => new EncodingModel { Name = info.Name, DisplayName = info.DisplayName })); - foreach(EncodingModel encoding in encodings.OrderBy(t => t.DisplayName)) - Encodings.Add(encoding); + foreach(EncodingModel encoding in encodings.OrderBy(t => t.DisplayName)) Encodings.Add(encoding); }); } diff --git a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs index 644eea222..83c7776a9 100644 --- a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs @@ -53,8 +53,7 @@ public sealed class LicenseViewModel : ViewModelBase // TODO: Localize using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Gui.LICENSE"); - if(stream == null) - return; + if(stream == null) return; using var reader = new StreamReader(stream); diff --git a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs index 27c033ff8..e9806784c 100644 --- a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs @@ -63,8 +63,7 @@ public sealed class PluginsViewModel : ViewModelBase // TODO: Takes too much time foreach(IFilter filter in PluginRegister.Singleton.Filters.Values) { - if(filter is null) - continue; + if(filter is null) continue; Filters.Add(new PluginModel { @@ -77,8 +76,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IFloppyImage floppyImage in PluginRegister.Singleton.FloppyImages.Values) { - if(floppyImage is null) - continue; + if(floppyImage is null) continue; FloppyImages.Add(new PluginModel { @@ -91,8 +89,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IMediaImage mediaImage in PluginRegister.Singleton.MediaImages.Values) { - if(mediaImage is null) - continue; + if(mediaImage is null) continue; Images.Add(new PluginModel { @@ -105,8 +102,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IPartition partition in PluginRegister.Singleton.Partitions.Values) { - if(partition is null) - continue; + if(partition is null) continue; PartitionSchemes.Add(new PluginModel { @@ -119,8 +115,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IFilesystem filesystem in PluginRegister.Singleton.Filesystems.Values) { - if(filesystem is null) - continue; + if(filesystem is null) continue; Filesystems.Add(new PluginModel { @@ -133,8 +128,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IReadOnlyFilesystem fs in PluginRegister.Singleton.ReadOnlyFilesystems.Values) { - if(fs is null) - continue; + if(fs is null) continue; ReadOnlyFilesystems.Add(new PluginModel { @@ -147,8 +141,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IWritableFloppyImage writableFloppyImage in PluginRegister.Singleton.WritableFloppyImages.Values) { - if(writableFloppyImage is null) - continue; + if(writableFloppyImage is null) continue; WritableFloppyImages.Add(new PluginModel { @@ -161,8 +154,7 @@ public sealed class PluginsViewModel : ViewModelBase foreach(IBaseWritableImage writableImage in PluginRegister.Singleton.WritableImages.Values) { - if(writableImage is null) - continue; + if(writableImage is null) continue; WritableImages.Add(new PluginModel { diff --git a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs index ee302894c..e3d789aa8 100644 --- a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -85,8 +85,7 @@ public sealed class SettingsViewModel : ViewModelBase CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand); SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand); - if(!_gdprVisible) - _tabControlSelectedIndex = 1; + if(!_gdprVisible) _tabControlSelectedIndex = 1; } // TODO: Show Preferences in macOS diff --git a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs index 2e16ca45c..8d36a9801 100644 --- a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs @@ -132,9 +132,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "fs-info")) { - ulong count = ctx.Commands.Where(c => c.Name == "fs-info" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "fs-info" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "fs-info" && !c.Synchronized); @@ -144,9 +144,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "checksum")) { - ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "checksum" && !c.Synchronized); @@ -156,9 +156,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "compare")) { - ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "compare" && !c.Synchronized); @@ -168,9 +168,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "convert-image")) { - ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "convert-image" && !c.Synchronized); @@ -180,9 +180,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "create-sidecar")) { - ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "create-sidecar" && !c.Synchronized); @@ -192,9 +192,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "decode")) { - ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "decode" && !c.Synchronized); @@ -204,9 +204,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "device-info")) { - ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-info" && !c.Synchronized); @@ -216,9 +216,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "device-report")) { - ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-report" && !c.Synchronized); @@ -228,9 +228,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "dump-media")) { - ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "dump-media" && !c.Synchronized); @@ -240,9 +240,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "entropy")) { - ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "entropy" && !c.Synchronized); @@ -252,9 +252,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "formats")) { - ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "formats" && !c.Synchronized); @@ -264,9 +264,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "image-info")) { - ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "image-info" && !c.Synchronized); @@ -276,9 +276,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "media-info")) { - ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-info" && !c.Synchronized); @@ -288,9 +288,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "media-scan")) { - ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-scan" && !c.Synchronized); @@ -300,9 +300,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "printhex")) { - ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "printhex" && !c.Synchronized); @@ -312,9 +312,9 @@ public sealed class StatisticsViewModel : ViewModelBase if(ctx.Commands.Any(c => c.Name == "verify")) { - ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Commands.LongCount(c => c.Name == "verify" && !c.Synchronized); @@ -346,9 +346,9 @@ public sealed class StatisticsViewModel : ViewModelBase foreach(string nvs in ctx.Filters.Select(n => n.Name).Distinct()) { - ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Filters.LongCount(c => c.Name == nvs && !c.Synchronized); @@ -366,9 +366,9 @@ public sealed class StatisticsViewModel : ViewModelBase foreach(string nvs in ctx.MediaFormats.Select(n => n.Name).Distinct()) { - ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.MediaFormats.LongCount(c => c.Name == nvs && !c.Synchronized); @@ -386,9 +386,9 @@ public sealed class StatisticsViewModel : ViewModelBase foreach(string nvs in ctx.Partitions.Select(n => n.Name).Distinct()) { - ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Partitions.LongCount(c => c.Name == nvs && !c.Synchronized); @@ -406,9 +406,9 @@ public sealed class StatisticsViewModel : ViewModelBase foreach(string nvs in ctx.Filesystems.Select(n => n.Name).Distinct()) { - ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Filesystems.LongCount(c => c.Name == nvs && !c.Synchronized); @@ -424,10 +424,10 @@ public sealed class StatisticsViewModel : ViewModelBase { DevicesVisible = true; - foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer). - ThenBy(n => n.Manufacturer). - ThenBy(n => n.Revision). - ThenBy(n => n.Bus)) + foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer) + .ThenBy(n => n.Manufacturer) + .ThenBy(n => n.Revision) + .ThenBy(n => n.Bus)) { Devices.Add(new DeviceStatsModel { @@ -439,16 +439,15 @@ public sealed class StatisticsViewModel : ViewModelBase } } - if(!ctx.Medias.Any()) - return; + if(!ctx.Medias.Any()) return; MediasVisible = true; foreach(string media in ctx.Medias.OrderBy(ms => ms.Type).Select(ms => ms.Type).Distinct()) { - ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real). - Select(c => c.Count). - FirstOrDefault(); + ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && c.Real); @@ -462,14 +461,13 @@ public sealed class StatisticsViewModel : ViewModelBase }); } - count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real). - Select(c => c.Count). - FirstOrDefault(); + count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real) + .Select(c => c.Count) + .FirstOrDefault(); count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && !c.Real); - if(count == 0) - continue; + if(count == 0) continue; Medias.Add(new MediaStatsModel { diff --git a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs index 3329335fe..0144bd2db 100644 --- a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs @@ -199,9 +199,15 @@ public sealed class DeviceInfoViewModel : ViewModelBase { ScsiInfo = new ScsiInfo { - DataContext = new ScsiInfoViewModel(devInfo.ScsiInquiryData, devInfo.ScsiInquiry, devInfo.ScsiEvpdPages, - devInfo.ScsiMode, devInfo.ScsiType, devInfo.ScsiModeSense6, - devInfo.ScsiModeSense10, devInfo.MmcConfiguration, _view) + DataContext = new ScsiInfoViewModel(devInfo.ScsiInquiryData, + devInfo.ScsiInquiry, + devInfo.ScsiEvpdPages, + devInfo.ScsiMode, + devInfo.ScsiType, + devInfo.ScsiModeSense6, + devInfo.ScsiModeSense10, + devInfo.MmcConfiguration, + _view) }; if(devInfo.PlextorFeatures != null) @@ -221,11 +227,11 @@ public sealed class DeviceInfoViewModel : ViewModelBase { PlextorDvdTimesVisible = true; - PlextorDvdReadTime = devInfo.PlextorFeatures.DvdReadTime.Seconds(). - Humanize(minUnit: TimeUnit.Second); + PlextorDvdReadTime = devInfo.PlextorFeatures.DvdReadTime.Seconds() + .Humanize(minUnit: TimeUnit.Second); - PlextorDvdWriteTime = devInfo.PlextorFeatures.DvdWriteTime.Seconds(). - Humanize(minUnit: TimeUnit.Second); + PlextorDvdWriteTime = devInfo.PlextorFeatures.DvdWriteTime.Seconds() + .Humanize(minUnit: TimeUnit.Second); } } @@ -307,8 +313,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase PlextorSecuRec = devInfo.PlextorFeatures.SecuRec; PlextorSpeedRead = devInfo.PlextorFeatures.SpeedRead; - if(devInfo.PlextorFeatures.SpeedRead) - PlextorSpeedEnabled = devInfo.PlextorFeatures.SpeedReadEnabled; + if(devInfo.PlextorFeatures.SpeedRead) PlextorSpeedEnabled = devInfo.PlextorFeatures.SpeedReadEnabled; PlextorHiding = devInfo.PlextorFeatures.Hiding; @@ -397,8 +402,12 @@ public sealed class DeviceInfoViewModel : ViewModelBase SdMmcInfo = new SdMmcInfo { - DataContext = new SdMmcInfoViewModel(devInfo.Type, devInfo.CID, devInfo.CSD, devInfo.OCR, - devInfo.ExtendedCSD, devInfo.SCR) + DataContext = new SdMmcInfoViewModel(devInfo.Type, + devInfo.CID, + devInfo.CSD, + devInfo.OCR, + devInfo.ExtendedCSD, + devInfo.SCR) }; } @@ -1023,8 +1032,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_devInfo.UsbDescriptors, 0, _devInfo.UsbDescriptors.Length); diff --git a/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs b/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs index f1b79a03e..920e9cef4 100644 --- a/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs @@ -77,8 +77,10 @@ public sealed class FileSystemViewModel([NotNull] FileSystem metadata, string in string.Format(Localization.Core.Volume_last_backed_up_on_0, metadata.BackupDate); public string ClustersText { get; } = - string.Format(Localization.Core.Volume_has_0_clusters_of_1_bytes_each_total_of_2_bytes, metadata.Clusters, - metadata.ClusterSize, metadata.Clusters * metadata.ClusterSize); + string.Format(Localization.Core.Volume_has_0_clusters_of_1_bytes_each_total_of_2_bytes, + metadata.Clusters, + metadata.ClusterSize, + metadata.Clusters * metadata.ClusterSize); public string FreeClustersText { get; } = string.Format(Localization.Core.Volume_has_0_clusters_free_1, metadata.FreeClusters, diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 2b08ec239..7daa8c249 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -107,13 +107,10 @@ public sealed class ImageInfoViewModel : ViewModelBase MediaLogo = AssetLoader.Exists(mediaResource) ? new Bitmap(AssetLoader.Open(mediaResource)) - : - imageFormat.Info.MetadataMediaType == MetadataMediaType.BlockMedia + : imageFormat.Info.MetadataMediaType == MetadataMediaType.BlockMedia ? genericHddIcon - : - imageFormat.Info.MetadataMediaType == MetadataMediaType.OpticalDisc - ? - genericOpticalIcon + : imageFormat.Info.MetadataMediaType == MetadataMediaType.OpticalDisc + ? genericOpticalIcon : genericFolderIcon; ImagePathText = string.Format(UI.Path_0, imagePath); @@ -129,11 +126,13 @@ public sealed class ImageInfoViewModel : ViewModelBase SectorsText = string.Format(Localization.Core.Contains_a_media_of_0_sectors_with_a_maximum_sector_size_of_1_bytes_etc, - imageFormat.Info.Sectors, imageFormat.Info.SectorSize, + imageFormat.Info.Sectors, + imageFormat.Info.SectorSize, ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize).Humanize()); MediaTypeText = string.Format(Localization.Core.Contains_a_media_of_type_0_and_XML_type_1, - imageFormat.Info.MediaType, imageFormat.Info.MetadataMediaType); + imageFormat.Info.MediaType, + imageFormat.Info.MetadataMediaType); HasPartitionsText = imageFormat.Info.HasPartitions ? UI.Has_partitions : UI.Doesnt_have_partitions; HasSessionsText = imageFormat.Info.HasSessions ? UI.Has_sessions : UI.Doesnt_have_sessions; @@ -142,7 +141,8 @@ public sealed class ImageInfoViewModel : ViewModelBase { ApplicationText = !string.IsNullOrWhiteSpace(imageFormat.Info.ApplicationVersion) ? string.Format(Localization.Core.Was_created_with_0_version_1, - imageFormat.Info.Application, imageFormat.Info.ApplicationVersion) + imageFormat.Info.Application, + imageFormat.Info.ApplicationVersion) : string.Format(Localization.Core.Was_created_with_0, imageFormat.Info.Application); } @@ -161,7 +161,8 @@ public sealed class ImageInfoViewModel : ViewModelBase if(imageFormat.Info.MediaSequence != 0 && imageFormat.Info.LastMediaSequence != 0) { MediaSequenceText = string.Format(Localization.Core.Media_is_number_0_on_a_set_of_1_medias, - imageFormat.Info.MediaSequence, imageFormat.Info.LastMediaSequence); + imageFormat.Info.MediaSequence, + imageFormat.Info.LastMediaSequence); } if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle)) @@ -209,7 +210,8 @@ public sealed class ImageInfoViewModel : ViewModelBase imageFormat is not ITapeImage { IsTape: true }) { MediaGeometryText = string.Format(UI.Media_geometry_0_cylinders_1_heads_2_sectors_per_track, - imageFormat.Info.Cylinders, imageFormat.Info.Heads, + imageFormat.Info.Cylinders, + imageFormat.Info.Heads, imageFormat.Info.SectorsPerTrack); } @@ -249,22 +251,27 @@ public sealed class ImageInfoViewModel : ViewModelBase { errno = imageFormat.ReadMediaTag(MediaTagType.SCSI_MODESENSE_6, out scsiModeSense6); - if(errno == ErrorNumber.NoError) - scsiMode = Modes.DecodeMode6(scsiModeSense6, scsiDeviceType); + if(errno == ErrorNumber.NoError) scsiMode = Modes.DecodeMode6(scsiModeSense6, scsiDeviceType); } if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.SCSI_MODESENSE_10) == true) { errno = imageFormat.ReadMediaTag(MediaTagType.SCSI_MODESENSE_10, out scsiModeSense10); - if(errno == ErrorNumber.NoError) - scsiMode = Modes.DecodeMode10(scsiModeSense10, scsiDeviceType); + if(errno == ErrorNumber.NoError) scsiMode = Modes.DecodeMode10(scsiModeSense10, scsiDeviceType); } ScsiInfo = new ScsiInfo { - DataContext = new ScsiInfoViewModel(scsiInquiryData, scsiInquiry, null, scsiMode, scsiDeviceType, - scsiModeSense6, scsiModeSense10, null, view) + DataContext = new ScsiInfoViewModel(scsiInquiryData, + scsiInquiry, + null, + scsiMode, + scsiDeviceType, + scsiModeSense6, + scsiModeSense10, + null, + view) }; byte[] ataIdentify = null; @@ -407,15 +414,27 @@ public sealed class ImageInfoViewModel : ViewModelBase { errno = imageFormat.ReadMediaTag(MediaTagType.CD_MCN, out byte[] mcn); - if(errno == ErrorNumber.NoError) - mediaCatalogueNumber = Encoding.UTF8.GetString(mcn); + if(errno == ErrorNumber.NoError) mediaCatalogueNumber = Encoding.UTF8.GetString(mcn); } CompactDiscInfo = new CompactDiscInfo { - DataContext = new CompactDiscInfoViewModel(toc, atip, null, null, fullToc, pma, cdtext, decodedToc, - decodedAtip, null, decodedFullToc, decodedCdText, null, - mediaCatalogueNumber, null, view) + DataContext = new CompactDiscInfoViewModel(toc, + atip, + null, + null, + fullToc, + pma, + cdtext, + decodedToc, + decodedAtip, + null, + decodedFullToc, + decodedCdText, + null, + mediaCatalogueNumber, + null, + view) }; byte[] dvdPfi = null; @@ -429,8 +448,7 @@ public sealed class ImageInfoViewModel : ViewModelBase { errno = imageFormat.ReadMediaTag(MediaTagType.DVD_PFI, out dvdPfi); - if(errno == ErrorNumber.NoError) - decodedPfi = PFI.Decode(dvdPfi, imageFormat.Info.MediaType); + if(errno == ErrorNumber.NoError) decodedPfi = PFI.Decode(dvdPfi, imageFormat.Info.MediaType); } if(imageFormat.Info.ReadableMediaTags?.Contains(MediaTagType.DVD_DMI) == true) @@ -447,8 +465,14 @@ public sealed class ImageInfoViewModel : ViewModelBase DvdInfo = new DvdInfo { - DataContext = new DvdInfoViewModel(dvdPfi, dvdDmi, dvdCmi, hddvdCopyrightInformation, dvdBca, null, - decodedPfi, view) + DataContext = new DvdInfoViewModel(dvdPfi, + dvdDmi, + dvdCmi, + hddvdCopyrightInformation, + dvdBca, + null, + decodedPfi, + view) }; byte[] dvdRamDds = null; @@ -510,11 +534,22 @@ public sealed class ImageInfoViewModel : ViewModelBase DvdWritableInfo = new DvdWritableInfo { - DataContext = new DvdWritableInfoViewModel(dvdRamDds, dvdRamCartridgeStatus, dvdRamSpareArea, - lastBorderOutRmd, dvdPreRecordedInfo, dvdrMediaIdentifier, - dvdrPhysicalInformation, hddvdrMediumStatus, null, - dvdrLayerCapacity, dvdrDlMiddleZoneStart, dvdrDlJumpIntervalSize, - dvdrDlManualLayerJumpStartLba, null, dvdPlusAdip, dvdPlusDcb, + DataContext = new DvdWritableInfoViewModel(dvdRamDds, + dvdRamCartridgeStatus, + dvdRamSpareArea, + lastBorderOutRmd, + dvdPreRecordedInfo, + dvdrMediaIdentifier, + dvdrPhysicalInformation, + hddvdrMediumStatus, + null, + dvdrLayerCapacity, + dvdrDlMiddleZoneStart, + dvdrDlJumpIntervalSize, + dvdrDlManualLayerJumpStartLba, + null, + dvdPlusAdip, + dvdPlusDcb, view) }; @@ -549,9 +584,16 @@ public sealed class ImageInfoViewModel : ViewModelBase BlurayInfo = new BlurayInfo { - DataContext = new BlurayInfoViewModel(blurayDiscInformation, blurayBurstCuttingArea, blurayDds, - blurayCartridgeStatus, bluraySpareAreaInformation, blurayPowResources, - blurayTrackResources, null, null, view) + DataContext = new BlurayInfoViewModel(blurayDiscInformation, + blurayBurstCuttingArea, + blurayDds, + blurayCartridgeStatus, + bluraySpareAreaInformation, + blurayPowResources, + blurayTrackResources, + null, + null, + view) }; byte[] xboxDmi = null; @@ -565,8 +607,7 @@ public sealed class ImageInfoViewModel : ViewModelBase { errno = imageFormat.ReadMediaTag(MediaTagType.Xbox_SecuritySector, out xboxSecuritySector); - if(errno == ErrorNumber.NoError) - decodedXboxSecuritySector = SS.Decode(xboxSecuritySector); + if(errno == ErrorNumber.NoError) decodedXboxSecuritySector = SS.Decode(xboxSecuritySector); } XboxInfo = new XboxInfo @@ -654,8 +695,7 @@ public sealed class ImageInfoViewModel : ViewModelBase { if(opticalMediaImage.Sessions is { Count: > 0 }) { - foreach(Session session in opticalMediaImage.Sessions) - Sessions.Add(session); + foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session); } } catch @@ -667,8 +707,7 @@ public sealed class ImageInfoViewModel : ViewModelBase { if(opticalMediaImage.Tracks is { Count: > 0 }) { - foreach(Track track in opticalMediaImage.Tracks) - Tracks.Add(track); + foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track); } } catch @@ -677,8 +716,7 @@ public sealed class ImageInfoViewModel : ViewModelBase } } - if(imageFormat.DumpHardware is null) - return; + if(imageFormat.DumpHardware is null) return; foreach(DumpHardware dump in imageFormat.DumpHardware) { diff --git a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs index be82d0373..cb521fd9b 100644 --- a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs @@ -105,7 +105,8 @@ public sealed class MediaInfoViewModel : ViewModelBase if(scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0) { MediaSize = string.Format(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, - scsiInfo.Blocks, scsiInfo.BlockSize, + scsiInfo.Blocks, + scsiInfo.BlockSize, ByteSize.FromBytes(scsiInfo.Blocks * scsiInfo.BlockSize).ToString("0.000")); } @@ -144,47 +145,78 @@ public sealed class MediaInfoViewModel : ViewModelBase CompactDiscInfo = new CompactDiscInfo { - DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.DiscInformation, - scsiInfo.Session, scsiInfo.RawToc, scsiInfo.Pma, - scsiInfo.CdTextLeadIn, scsiInfo.DecodedToc, scsiInfo.DecodedAtip, - scsiInfo.DecodedSession, scsiInfo.FullToc, - scsiInfo.DecodedCdTextLeadIn, scsiInfo.DecodedDiscInformation, - scsiInfo.Mcn, scsiInfo.Isrcs, _view) + DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, + scsiInfo.Atip, + scsiInfo.DiscInformation, + scsiInfo.Session, + scsiInfo.RawToc, + scsiInfo.Pma, + scsiInfo.CdTextLeadIn, + scsiInfo.DecodedToc, + scsiInfo.DecodedAtip, + scsiInfo.DecodedSession, + scsiInfo.FullToc, + scsiInfo.DecodedCdTextLeadIn, + scsiInfo.DecodedDiscInformation, + scsiInfo.Mcn, + scsiInfo.Isrcs, + _view) }; DvdInfo = new DvdInfo { - DataContext = new DvdInfoViewModel(scsiInfo.DvdPfi, scsiInfo.DvdDmi, scsiInfo.DvdCmi, - scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca, scsiInfo.DvdAacs, - scsiInfo.DecodedPfi, _view) + DataContext = new DvdInfoViewModel(scsiInfo.DvdPfi, + scsiInfo.DvdDmi, + scsiInfo.DvdCmi, + scsiInfo.HddvdCopyrightInformation, + scsiInfo.DvdBca, + scsiInfo.DvdAacs, + scsiInfo.DecodedPfi, + _view) }; XboxInfo = new XboxInfo { - DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector, - scsiInfo.DecodedXboxSecuritySector, _view) + DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, + scsiInfo.DvdDmi, + scsiInfo.XboxSecuritySector, + scsiInfo.DecodedXboxSecuritySector, + _view) }; DvdWritableInfo = new DvdWritableInfo { - DataContext = new DvdWritableInfoViewModel(scsiInfo.DvdRamDds, scsiInfo.DvdRamCartridgeStatus, - scsiInfo.DvdRamSpareArea, scsiInfo.LastBorderOutRmd, - scsiInfo.DvdPreRecordedInfo, scsiInfo.DvdrMediaIdentifier, - scsiInfo.DvdrPhysicalInformation, scsiInfo.HddvdrMediumStatus, - scsiInfo.HddvdrLastRmd, scsiInfo.DvdrLayerCapacity, - scsiInfo.DvdrDlMiddleZoneStart, scsiInfo.DvdrDlJumpIntervalSize, + DataContext = new DvdWritableInfoViewModel(scsiInfo.DvdRamDds, + scsiInfo.DvdRamCartridgeStatus, + scsiInfo.DvdRamSpareArea, + scsiInfo.LastBorderOutRmd, + scsiInfo.DvdPreRecordedInfo, + scsiInfo.DvdrMediaIdentifier, + scsiInfo.DvdrPhysicalInformation, + scsiInfo.HddvdrMediumStatus, + scsiInfo.HddvdrLastRmd, + scsiInfo.DvdrLayerCapacity, + scsiInfo.DvdrDlMiddleZoneStart, + scsiInfo.DvdrDlJumpIntervalSize, scsiInfo.DvdrDlManualLayerJumpStartLba, - scsiInfo.DvdrDlRemapAnchorPoint, scsiInfo.DvdPlusAdip, - scsiInfo.DvdPlusDcb, _view) + scsiInfo.DvdrDlRemapAnchorPoint, + scsiInfo.DvdPlusAdip, + scsiInfo.DvdPlusDcb, + _view) }; BlurayInfo = new BlurayInfo { - DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea, - scsiInfo.BlurayDds, scsiInfo.BlurayCartridgeStatus, - scsiInfo.BluraySpareAreaInformation, scsiInfo.BlurayPowResources, - scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl, - scsiInfo.BlurayPac, _view) + DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, + scsiInfo.BlurayBurstCuttingArea, + scsiInfo.BlurayDds, + scsiInfo.BlurayCartridgeStatus, + scsiInfo.BluraySpareAreaInformation, + scsiInfo.BlurayPowResources, + scsiInfo.BlurayTrackResources, + scsiInfo.BlurayRawDfl, + scsiInfo.BlurayPac, + _view) }; } @@ -370,8 +402,7 @@ public sealed class MediaInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(data, 0, data.Length); @@ -400,21 +431,23 @@ public sealed class MediaInfoViewModel : ViewModelBase switch(_scsiInfo.MediaType) { case CommonTypes.MediaType.GDR or CommonTypes.MediaType.GDROM: - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - Localization.Core.GD_ROM_dump_support_is_not_yet_implemented, ButtonEnum.Ok, - Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + Localization.Core.GD_ROM_dump_support_is_not_yet_implemented, + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); return; case CommonTypes.MediaType.XGD or CommonTypes.MediaType.XGD2 or CommonTypes.MediaType.XGD3 when _scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true: - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - Localization.Core. - Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware, - ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + Localization.Core + .Dumping_Xbox_Game_Discs_requires_a_drive_with_Kreon_firmware, + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); return; } @@ -434,11 +467,12 @@ public sealed class MediaInfoViewModel : ViewModelBase // TODO: GD-ROM case CommonTypes.MediaType.GDR: case CommonTypes.MediaType.GDROM: - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - Localization.Core.GD_ROM_scan_support_is_not_yet_implemented, ButtonEnum.Ok, - Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + Localization.Core.GD_ROM_scan_support_is_not_yet_implemented, + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); return; @@ -447,10 +481,11 @@ public sealed class MediaInfoViewModel : ViewModelBase case CommonTypes.MediaType.XGD2: case CommonTypes.MediaType.XGD3: await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, - Localization.Core. - Scanning_Xbox_discs_is_not_yet_supported, - ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + Localization.Core + .Scanning_Xbox_discs_is_not_yet_supported, + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); return; } diff --git a/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs b/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs index b413c8a19..fb922030a 100644 --- a/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs @@ -43,7 +43,8 @@ public sealed class PartitionViewModel(Partition partition) string.Format(Localization.Core.Partition_start_sector_0_byte_1, partition.Start, partition.Offset); public string LengthText { get; } = string.Format(Localization.Core.Partition_length_0_sectors_1_bytes, - partition.Length, partition.Size); + partition.Length, + partition.Size); public string DescriptionLabelText { get; } = Localization.Core.Title_Partition_description; public string DescriptionText { get; } = partition.Description; diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index 7db67dedb..72e25eb20 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -73,8 +73,11 @@ public sealed class SubdirectoryViewModel { MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_trying_to_read_1_of_chosen_filesystem, - errno, model.Path), ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(view); + errno, + model.Path), + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(view); return; } @@ -85,9 +88,10 @@ public sealed class SubdirectoryViewModel if(errno != ErrorNumber.NoError) { - AaruConsole. - ErrorWriteLine(string.Format(UI.Error_0_trying_to_get_information_about_filesystem_entry_named_1, - errno, dirent)); + AaruConsole + .ErrorWriteLine(string.Format(UI.Error_0_trying_to_get_information_about_filesystem_entry_named_1, + errno, + dirent)); continue; } @@ -135,8 +139,7 @@ public sealed class SubdirectoryViewModel async Task ExecuteExtractFilesCommand() { - if(SelectedEntries.Count == 0) - return; + if(SelectedEntries.Count == 0) return; var saveFilesFolderDialog = new OpenFolderDialog { @@ -145,8 +148,7 @@ public sealed class SubdirectoryViewModel string result = await saveFilesFolderDialog.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; Statistics.AddCommand("extract-files"); @@ -268,11 +270,14 @@ public sealed class SubdirectoryViewModel string corrected = new(chars); mboxResult = await MessageBoxManager.GetMessageBoxStandard(UI.Unsupported_filename, - string. - Format(UI.Filename_0_not_supported_want_to_rename_to_1, - filename, corrected), - ButtonEnum.YesNoCancel, Icon.Warning). - ShowWindowDialogAsync(_view); + string + .Format(UI + .Filename_0_not_supported_want_to_rename_to_1, + filename, + corrected), + ButtonEnum.YesNoCancel, + Icon.Warning) + .ShowWindowDialogAsync(_view); switch(mboxResult) { @@ -293,11 +298,12 @@ public sealed class SubdirectoryViewModel if(File.Exists(outputPath)) { mboxResult = await MessageBoxManager.GetMessageBoxStandard(UI.Existing_file, - string. - Format(UI.File_named_0_exists_overwrite_Q, + string + .Format(UI.File_named_0_exists_overwrite_Q, filename), - ButtonEnum.YesNoCancel, Icon.Warning). - ShowWindowDialogAsync(_view); + ButtonEnum.YesNoCancel, + Icon.Warning) + .ShowWindowDialogAsync(_view); switch(mboxResult) { @@ -315,11 +321,10 @@ public sealed class SubdirectoryViewModel mboxResult = await MessageBoxManager.GetMessageBoxStandard(UI.Cannot_delete, UI.Could_note_delete_existe_file_continue_Q, ButtonEnum.YesNo, - Icon.Error). - ShowWindowDialogAsync(_view); + Icon.Error) + .ShowWindowDialogAsync(_view); - if(mboxResult == ButtonResult.No) - return; + if(mboxResult == ButtonResult.No) return; } break; @@ -341,14 +346,15 @@ public sealed class SubdirectoryViewModel if(error != ErrorNumber.NoError) { mboxResult = await MessageBoxManager.GetMessageBoxStandard(UI.Error_reading_file, - string. - Format(UI.Error_0_reading_file_continue_Q, - error), ButtonEnum.YesNo, - Icon.Error). - ShowWindowDialogAsync(_view); + string + .Format(UI + .Error_0_reading_file_continue_Q, + error), + ButtonEnum.YesNo, + Icon.Error) + .ShowWindowDialogAsync(_view); - if(mboxResult == ButtonResult.No) - return; + if(mboxResult == ButtonResult.No) return; continue; } @@ -358,11 +364,10 @@ public sealed class SubdirectoryViewModel fs.Write(outBuf, 0, outBuf.Length); fs.Close(); var fi = new FileInfo(outputPath); - #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { - if(file.Stat.CreationTimeUtc.HasValue) - fi.CreationTimeUtc = file.Stat.CreationTimeUtc.Value; + if(file.Stat.CreationTimeUtc.HasValue) fi.CreationTimeUtc = file.Stat.CreationTimeUtc.Value; } catch { @@ -371,8 +376,7 @@ public sealed class SubdirectoryViewModel try { - if(file.Stat.LastWriteTimeUtc.HasValue) - fi.LastWriteTimeUtc = file.Stat.LastWriteTimeUtc.Value; + if(file.Stat.LastWriteTimeUtc.HasValue) fi.LastWriteTimeUtc = file.Stat.LastWriteTimeUtc.Value; } catch { @@ -381,25 +385,24 @@ public sealed class SubdirectoryViewModel try { - if(file.Stat.AccessTimeUtc.HasValue) - fi.LastAccessTimeUtc = file.Stat.AccessTimeUtc.Value; + if(file.Stat.AccessTimeUtc.HasValue) fi.LastAccessTimeUtc = file.Stat.AccessTimeUtc.Value; } catch { // ignored } - #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } catch(IOException) { mboxResult = await MessageBoxManager.GetMessageBoxStandard(UI.Cannot_create_file, - UI. - Could_not_create_destination_file_continue_Q, - ButtonEnum.YesNo, Icon.Error). - ShowWindowDialogAsync(_view); + UI + .Could_not_create_destination_file_continue_Q, + ButtonEnum.YesNo, + Icon.Error) + .ShowWindowDialogAsync(_view); - if(mboxResult == ButtonResult.No) - return; + if(mboxResult == ButtonResult.No) return; } } } diff --git a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs index f3145aeb3..c01b51371 100644 --- a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs @@ -58,8 +58,7 @@ public sealed class AtaInfoViewModel : ViewModelBase _atapi = atapiIdentify; _view = view; - if(ataIdentify == null && atapiIdentify == null) - return; + if(ataIdentify == null && atapiIdentify == null) return; if(ataIdentify != null) { @@ -127,15 +126,13 @@ public sealed class AtaInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); if(_ata != null) - saveFs.Write(_ata, 0, _ata.Length); - else if(_atapi != null) - saveFs.Write(_atapi, 0, _atapi.Length); + saveFs.Write(_ata, 0, _ata.Length); + else if(_atapi != null) saveFs.Write(_atapi, 0, _atapi.Length); saveFs.Close(); } @@ -155,8 +152,7 @@ public sealed class AtaInfoViewModel : ViewModelBase string result = await dlgSaveText.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); var saveSw = new StreamWriter(saveFs); diff --git a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs index 16bd039d7..b858362dc 100644 --- a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs @@ -188,8 +188,7 @@ public sealed class BlurayInfoViewModel string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(data, 0, data.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs index a029afe93..baec03ae1 100644 --- a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs @@ -82,23 +82,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase if(decodedCompactDiscInformation.HasValue) CdInformationText = DiscInformation.Prettify000b(decodedCompactDiscInformation); - if(decodedToc.HasValue) - CdTocText = TOC.Prettify(decodedToc); + if(decodedToc.HasValue) CdTocText = TOC.Prettify(decodedToc); - if(fullToc.HasValue) - CdFullTocText = FullTOC.Prettify(fullToc); + if(fullToc.HasValue) CdFullTocText = FullTOC.Prettify(fullToc); - if(decodedSession.HasValue) - CdSessionText = Session.Prettify(decodedSession); + if(decodedSession.HasValue) CdSessionText = Session.Prettify(decodedSession); - if(decodedCdTextLeadIn.HasValue) - CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn); + if(decodedCdTextLeadIn.HasValue) CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn); - if(decodedAtip != null) - CdAtipText = ATIP.Prettify(atip); + if(decodedAtip != null) CdAtipText = ATIP.Prettify(atip); - if(!string.IsNullOrEmpty(mcn)) - McnText = mcn; + if(!string.IsNullOrEmpty(mcn)) McnText = mcn; if(isrcs is { Count: > 0 }) { @@ -168,8 +162,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_compactDiscInformationData, 0, _compactDiscInformationData.Length); @@ -192,8 +185,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_tocData, 0, _tocData.Length); @@ -216,8 +208,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_rawTocData, 0, _rawTocData.Length); @@ -240,8 +231,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_sessionData, 0, _sessionData.Length); @@ -264,8 +254,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_cdTextLeadInData, 0, _cdTextLeadInData.Length); @@ -288,8 +277,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_atipData, 0, _atipData.Length); @@ -312,8 +300,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_pmaData, 0, _pmaData.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs index fa1ac6e34..40cb35065 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs @@ -89,11 +89,9 @@ public sealed class DvdInfoViewModel } */ - if(decodedPfi.HasValue) - DvdPfiText = PFI.Prettify(decodedPfi); + if(decodedPfi.HasValue) DvdPfiText = PFI.Prettify(decodedPfi); - if(cmi != null) - DvdCmiText = CSS_CPRM.PrettifyLeadInCopyright(cmi); + if(cmi != null) DvdCmiText = CSS_CPRM.PrettifyLeadInCopyright(cmi); SaveDvdPfiVisible = pfi != null; SaveDvdDmiVisible = dmi != null; @@ -140,8 +138,7 @@ public sealed class DvdInfoViewModel string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(data, 0, data.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs index e3e921b65..b535dcf91 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs @@ -169,14 +169,11 @@ public sealed class DvdWritableInfoViewModel } */ - if(dds != null) - DvdRamDdsText = DDS.Prettify(dds); + if(dds != null) DvdRamDdsText = DDS.Prettify(dds); - if(cartridgeStatus != null) - DvdRamCartridgeStatusText = Cartridge.Prettify(cartridgeStatus); + if(cartridgeStatus != null) DvdRamCartridgeStatusText = Cartridge.Prettify(cartridgeStatus); - if(spareArea != null) - DvdRamSpareAreaInformationText = Spare.Prettify(spareArea); + if(spareArea != null) DvdRamSpareAreaInformationText = Spare.Prettify(spareArea); SaveDvdRamDdsVisible = dds != null; SaveDvdRamCartridgeStatusVisible = cartridgeStatus != null; @@ -267,8 +264,7 @@ public sealed class DvdWritableInfoViewModel string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(data, 0, data.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs index b3f796f19..ee8b339c7 100644 --- a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs @@ -55,8 +55,7 @@ public class PcmciaInfoViewModel : ViewModelBase internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view) { - if(pcmciaCis == null) - return; + if(pcmciaCis == null) return; _cis = pcmciaCis; CisList = new ObservableCollection(); @@ -166,8 +165,7 @@ public class PcmciaInfoViewModel : ViewModelBase get => _selectedCis; set { - if(_selectedCis == value) - return; + if(_selectedCis == value) return; PcmciaCisText = value?.Description; this.RaiseAndSetIfChanged(ref _selectedCis, value); @@ -191,8 +189,7 @@ public class PcmciaInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_cis, 0, _cis.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs index 0ecb3afa7..0fd358d9b 100644 --- a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs @@ -82,8 +82,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase SaveEvpdPageCommand = ReactiveCommand.Create(ExecuteSaveEvpdPageCommand); SaveMmcFeaturesCommand = ReactiveCommand.Create(ExecuteSaveMmcFeaturesCommand); - if(InquiryData == null || !scsiInquiry.HasValue) - return; + if(InquiryData == null || !scsiInquiry.HasValue) return; ScsiInquiryText = Decoders.SCSI.Inquiry.Prettify(scsiInquiry); @@ -513,51 +512,51 @@ public sealed class ScsiInfoViewModel : ViewModelBase evpdDecodedPage = EVPD.DecodePageB4(page.Value); break; - case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "quantum": evpdPageTitle = UI.Quantum_Firmware_Build_Information_page; evpdDecodedPage = EVPD.PrettifyPage_C0_Quantum(page.Value); break; - case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "seagate": evpdPageTitle = UI.Seagate_Firmware_Numbers_page; evpdDecodedPage = EVPD.PrettifyPage_C0_Seagate(page.Value); break; - case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + case 0xC0 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "ibm": evpdPageTitle = UI.IBM_Drive_Component_Revision_Levels_page; evpdDecodedPage = EVPD.PrettifyPage_C0_IBM(page.Value); break; - case 0xC1 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + case 0xC1 when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "ibm": evpdPageTitle = UI.IBM_Drive_Serial_Numbers_page; evpdDecodedPage = EVPD.PrettifyPage_C1_IBM(page.Value); break; case 0xC0 or 0xC1 - when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "certance": evpdPageTitle = UI.Certance_Drive_Component_Revision_Levels_page; evpdDecodedPage = EVPD.PrettifyPage_C0_C1_Certance(page.Value); break; case 0xC2 or 0xC3 or 0xC4 or 0xC5 or 0xC6 - when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "certance": evpdPageTitle = page.Key switch { @@ -573,9 +572,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase break; case 0xC0 or 0xC1 or 0xC2 or 0xC3 or 0xC4 or 0xC5 - when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "hp": evpdPageTitle = page.Key switch { @@ -591,9 +590,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase evpdDecodedPage = EVPD.PrettifyPage_C0_to_C5_HP(page.Value); break; - case 0xDF when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification). - ToLowerInvariant(). - Trim() == + case 0xDF when StringHandlers.CToString(scsiInquiry.Value.VendorIdentification) + .ToLowerInvariant() + .Trim() == "certance": evpdPageTitle = UI.Certance_drive_status_page; evpdDecodedPage = EVPD.PrettifyPage_DF_Certance(page.Value); @@ -601,13 +600,13 @@ public sealed class ScsiInfoViewModel : ViewModelBase break; default: { - if(page.Key == 0x00) - continue; + if(page.Key == 0x00) continue; evpdPageTitle = string.Format(UI.Page_0_h, page.Key); evpdDecodedPage = UI.Undecoded; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_undecoded_SCSI_VPD_page_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.Found_undecoded_SCSI_VPD_page_0, page.Key); break; @@ -623,14 +622,14 @@ public sealed class ScsiInfoViewModel : ViewModelBase } } - if(_configuration == null) - return; + if(_configuration == null) return; Features.SeparatedFeatures ftr = Features.Separate(_configuration); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_length_is_0, ftr.DataLength); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Core.GET_CONFIGURATION_current_profile_is_0, ftr.CurrentProfile); if(ftr.Descriptors != null) @@ -734,11 +733,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase get => _selectedModeSensePage; set { - if(value == _selectedModeSensePage) - return; + if(value == _selectedModeSensePage) return; - if(value is ScsiPageModel pageModel) - ModeSensePageText = pageModel.Description; + if(value is ScsiPageModel pageModel) ModeSensePageText = pageModel.Description; this.RaiseAndSetIfChanged(ref _selectedModeSensePage, value); } @@ -755,11 +752,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase get => _selectedEvpdPage; set { - if(value == _selectedEvpdPage) - return; + if(value == _selectedEvpdPage) return; - if(value is ScsiPageModel pageModel) - EvpdPageText = pageModel.Description; + if(value is ScsiPageModel pageModel) EvpdPageText = pageModel.Description; this.RaiseAndSetIfChanged(ref _selectedEvpdPage, value); } @@ -776,11 +771,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase get => _selectedMmcFeature; set { - if(value == _selectedMmcFeature) - return; + if(value == _selectedMmcFeature) return; - if(value is ScsiPageModel pageModel) - MmcFeatureText = pageModel.Description; + if(value is ScsiPageModel pageModel) MmcFeatureText = pageModel.Description; this.RaiseAndSetIfChanged(ref _selectedMmcFeature, value); } @@ -821,8 +814,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(InquiryData, 0, InquiryData.Length); @@ -845,8 +837,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveText.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); var saveSw = new StreamWriter(saveFs); @@ -869,8 +860,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_scsiModeSense6, 0, _scsiModeSense6.Length); @@ -893,8 +883,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_scsiModeSense10, 0, _scsiModeSense10.Length); @@ -904,8 +893,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase async Task ExecuteSaveEvpdPageCommand() { - if(SelectedEvpdPage is not ScsiPageModel pageModel) - return; + if(SelectedEvpdPage is not ScsiPageModel pageModel) return; var dlgSaveBinary = new SaveFileDialog(); @@ -920,8 +908,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(pageModel.Data, 0, pageModel.Data.Length); @@ -944,8 +931,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(_configuration, 0, _configuration.Length); diff --git a/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs index 1cbf1d833..76c39f263 100644 --- a/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs @@ -47,17 +47,13 @@ public sealed class SdMmcInfoViewModel { //Text = "MultiMediaCard"; - if(cid != null) - CidText = Decoders.MMC.Decoders.PrettifyCID(cid); + if(cid != null) CidText = Decoders.MMC.Decoders.PrettifyCID(cid); - if(csd != null) - CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd); + if(csd != null) CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd); - if(ocr != null) - OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr); + if(ocr != null) OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr); - if(extendedCsd != null) - ExtendedCsdText = Decoders.MMC.Decoders.PrettifyExtendedCSD(extendedCsd); + if(extendedCsd != null) ExtendedCsdText = Decoders.MMC.Decoders.PrettifyExtendedCSD(extendedCsd); } break; @@ -65,17 +61,13 @@ public sealed class SdMmcInfoViewModel { //Text = "SecureDigital"; - if(cid != null) - CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid); + if(cid != null) CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid); - if(csd != null) - CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd); + if(csd != null) CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd); - if(ocr != null) - OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr); + if(ocr != null) OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr); - if(scr != null) - ScrText = Decoders.SecureDigital.Decoders.PrettifySCR(scr); + if(scr != null) ScrText = Decoders.SecureDigital.Decoders.PrettifySCR(scr); } break; diff --git a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs index ae8b660d0..78c606851 100644 --- a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs @@ -69,13 +69,11 @@ public sealed class XboxInfoViewModel if(dmi != null) { if(DMI.IsXbox(dmi)) - XboxDmiText = DMI.PrettifyXbox(dmi); - else if(DMI.IsXbox360(dmi)) - XboxDmiText = DMI.PrettifyXbox360(dmi); + XboxDmiText = DMI.PrettifyXbox(dmi); + else if(DMI.IsXbox360(dmi)) XboxDmiText = DMI.PrettifyXbox360(dmi); } - if(decodedSecuritySector.HasValue) - XboxSsText = SS.Prettify(decodedSecuritySector); + if(decodedSecuritySector.HasValue) XboxSsText = SS.Prettify(decodedSecuritySector); SaveXboxSsVisible = securitySector != null; } @@ -117,8 +115,7 @@ public sealed class XboxInfoViewModel string result = await dlgSaveBinary.ShowAsync(_view); - if(result is null) - return; + if(result is null) return; var saveFs = new FileStream(result, FileMode.Create); saveFs.Write(data, 0, data.Length); diff --git a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs index 6d9ff476a..7b568d167 100644 --- a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs @@ -97,8 +97,7 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase { this.RaiseAndSetIfChanged(ref _selectedTag, value); - if(value is null) - return; + if(value is null) return; // TODO: Decoders should be able to handle tags with/without length header HexViewText = PrintHex.ByteArrayToHexArrayString(value.Data, HEX_COLUMNS); @@ -230,8 +229,7 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase break; } - if(DecodedText != null) - value.Decoded = DecodedText; + if(DecodedText != null) value.Decoded = DecodedText; } } diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index 6c5e4cbe7..d047d57a9 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -430,41 +430,29 @@ public sealed class ImageChecksumViewModel : ViewModelBase var enabledChecksums = new EnableChecksum(); - if(Adler32Checked) - enabledChecksums |= EnableChecksum.Adler32; + if(Adler32Checked) enabledChecksums |= EnableChecksum.Adler32; - if(Crc16Checked) - enabledChecksums |= EnableChecksum.Crc16; + if(Crc16Checked) enabledChecksums |= EnableChecksum.Crc16; - if(Crc32Checked) - enabledChecksums |= EnableChecksum.Crc32; + if(Crc32Checked) enabledChecksums |= EnableChecksum.Crc32; - if(Crc64Checked) - enabledChecksums |= EnableChecksum.Crc64; + if(Crc64Checked) enabledChecksums |= EnableChecksum.Crc64; - if(Md5Checked) - enabledChecksums |= EnableChecksum.Md5; + if(Md5Checked) enabledChecksums |= EnableChecksum.Md5; - if(Sha1Checked) - enabledChecksums |= EnableChecksum.Sha1; + if(Sha1Checked) enabledChecksums |= EnableChecksum.Sha1; - if(Sha256Checked) - enabledChecksums |= EnableChecksum.Sha256; + if(Sha256Checked) enabledChecksums |= EnableChecksum.Sha256; - if(Sha384Checked) - enabledChecksums |= EnableChecksum.Sha384; + if(Sha384Checked) enabledChecksums |= EnableChecksum.Sha384; - if(Sha512Checked) - enabledChecksums |= EnableChecksum.Sha512; + if(Sha512Checked) enabledChecksums |= EnableChecksum.Sha512; - if(SpamsumChecked) - enabledChecksums |= EnableChecksum.SpamSum; + if(SpamsumChecked) enabledChecksums |= EnableChecksum.SpamSum; - if(Fletcher16Checked) - enabledChecksums |= EnableChecksum.Fletcher16; + if(Fletcher16Checked) enabledChecksums |= EnableChecksum.Fletcher16; - if(Fletcher32Checked) - enabledChecksums |= EnableChecksum.Fletcher32; + if(Fletcher32Checked) enabledChecksums |= EnableChecksum.Fletcher32; Checksum mediaChecksum = null; ErrorNumber errno; @@ -475,8 +463,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase { Checksum trackChecksum = null; - if(ChecksumMediaChecked) - mediaChecksum = new Checksum(enabledChecksums); + if(ChecksumMediaChecked) mediaChecksum = new Checksum(enabledChecksums); ulong previousTrackEnd = 0; @@ -484,7 +471,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase { await Dispatcher.UIThread.InvokeAsync(() => { - ProgressText = string.Format(UI.Hashing_track_0_of_1, currentTrack.Sequence, + ProgressText = string.Format(UI.Hashing_track_0_of_1, + currentTrack.Sequence, opticalMediaImage.Tracks.Count); ProgressValue++; @@ -507,7 +495,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, i)); + errno, + i)); _cancel = true; @@ -518,11 +507,13 @@ public sealed class ImageChecksumViewModel : ViewModelBase } } - AaruConsole.DebugWriteLine(MODULE_NAME, UI.Track_0_starts_at_sector_1_and_ends_at_sector_2, - currentTrack.Sequence, currentTrack.StartSector, currentTrack.EndSector); + AaruConsole.DebugWriteLine(MODULE_NAME, + UI.Track_0_starts_at_sector_1_and_ends_at_sector_2, + currentTrack.Sequence, + currentTrack.StartSector, + currentTrack.EndSector); - if(ChecksumTracksChecked) - trackChecksum = new Checksum(enabledChecksums); + if(ChecksumTracksChecked) trackChecksum = new Checksum(enabledChecksums); ulong sectors = currentTrack.EndSector - currentTrack.StartSector + 1; ulong doneSectors = 0; @@ -545,13 +536,16 @@ public sealed class ImageChecksumViewModel : ViewModelBase if(sectors - doneSectors >= SECTORS_TO_READ) { - errno = opticalMediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, currentTrack.Sequence, + errno = opticalMediaImage.ReadSectors(doneSectors, + SECTORS_TO_READ, + currentTrack.Sequence, out sector); if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, doneSectors)); + errno, + doneSectors)); _cancel = true; @@ -572,13 +566,16 @@ public sealed class ImageChecksumViewModel : ViewModelBase } else { - errno = opticalMediaImage.ReadSectors(doneSectors, (uint)(sectors - doneSectors), - currentTrack.Sequence, out sector); + errno = opticalMediaImage.ReadSectors(doneSectors, + (uint)(sectors - doneSectors), + currentTrack.Sequence, + out sector); if(errno != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, - errno, doneSectors)); + errno, + doneSectors)); _cancel = true; @@ -599,20 +596,16 @@ public sealed class ImageChecksumViewModel : ViewModelBase doneSectors += sectors - doneSectors; } - if(ChecksumMediaChecked) - mediaChecksum?.Update(sector); + if(ChecksumMediaChecked) mediaChecksum?.Update(sector); - if(ChecksumTracksChecked) - trackChecksum?.Update(sector); + if(ChecksumTracksChecked) trackChecksum?.Update(sector); } await Dispatcher.UIThread.InvokeAsync(() => { - if(ChecksumTracksChecked != true) - return; + if(ChecksumTracksChecked != true) return; - if(trackChecksum == null) - return; + if(trackChecksum == null) return; foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End()) { @@ -644,7 +637,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase if(errno != ErrorNumber.NoError) { - AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, errno, + AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, + errno, i)); _cancel = true; @@ -658,8 +652,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - if(mediaChecksum == null) - return; + if(mediaChecksum == null) return; foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End()) { @@ -708,7 +701,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase if(errno != ErrorNumber.NoError) { - AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, errno, + AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, + errno, doneSectors)); _cancel = true; @@ -722,7 +716,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase { Progress2Value = (int)(doneSectorsToInvoke / SECTORS_TO_READ); - Progress2Text = string.Format(UI.Hashing_sectors_0_to_1, doneSectorsToInvoke, + Progress2Text = string.Format(UI.Hashing_sectors_0_to_1, + doneSectorsToInvoke, doneSectorsToInvoke + SECTORS_TO_READ); }); @@ -730,12 +725,14 @@ public sealed class ImageChecksumViewModel : ViewModelBase } else { - errno = _inputFormat.ReadSectors(doneSectors, (uint)(_inputFormat.Info.Sectors - doneSectors), + errno = _inputFormat.ReadSectors(doneSectors, + (uint)(_inputFormat.Info.Sectors - doneSectors), out sector); if(errno != ErrorNumber.NoError) { - AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, errno, + AaruConsole.ErrorWriteLine(string.Format(Localization.Core.Error_0_reading_sector_1, + errno, doneSectors)); _cancel = true; @@ -749,7 +746,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase { Progress2Value = (int)(doneSectorsToInvoke / SECTORS_TO_READ); - Progress2Text = string.Format(UI.Hashing_sectors_0_to_1, doneSectorsToInvoke, + Progress2Text = string.Format(UI.Hashing_sectors_0_to_1, + doneSectorsToInvoke, doneSectorsToInvoke + (_inputFormat.Info.Sectors - doneSectorsToInvoke)); }); @@ -773,11 +771,9 @@ public sealed class ImageChecksumViewModel : ViewModelBase }); } - if(ChecksumTracksChecked) - await Dispatcher.UIThread.InvokeAsync(() => { TrackChecksumsVisible = true; }); + if(ChecksumTracksChecked) await Dispatcher.UIThread.InvokeAsync(() => { TrackChecksumsVisible = true; }); - if(ChecksumMediaChecked) - await Dispatcher.UIThread.InvokeAsync(() => { MediaChecksumsVisible = true; }); + if(ChecksumMediaChecked) await Dispatcher.UIThread.InvokeAsync(() => { MediaChecksumsVisible = true; }); Statistics.AddCommand("checksum"); diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index 7b1148dcc..db41174d3 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -177,8 +177,7 @@ public sealed class ImageConvertViewModel : ViewModelBase foreach(IBaseWritableImage plugin in plugins.WritableImages.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; if(plugin.SupportedMediaTypes.Contains(inputFormat.Info.MediaType)) { @@ -597,9 +596,9 @@ public sealed class ImageConvertViewModel : ViewModelBase { if(SelectedPlugin is null) { - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Error_trying_to_find_selected_plugin, - icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, UI.Error_trying_to_find_selected_plugin, icon: Icon.Error) + .ShowWindowDialogAsync(_view); return; } @@ -614,9 +613,9 @@ public sealed class ImageConvertViewModel : ViewModelBase if(plugin is not IWritableImage outputFormat) { - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Error_trying_to_find_selected_plugin, - icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, UI.Error_trying_to_find_selected_plugin, icon: Icon.Error) + .ShowWindowDialogAsync(_view); return; } @@ -651,8 +650,7 @@ public sealed class ImageConvertViewModel : ViewModelBase ProgressMaxValue += _inputFormat.Info.ReadableMediaTags.Count; ProgressMaxValue++; - if(tracks != null) - ProgressMaxValue++; + if(tracks != null) ProgressMaxValue++; if(tracks == null) { @@ -674,8 +672,7 @@ public sealed class ImageConvertViewModel : ViewModelBase continue; } - if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) - continue; + if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) continue; ProgressMaxValue++; } @@ -700,31 +697,30 @@ public sealed class ImageConvertViewModel : ViewModelBase continue; } - if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) - continue; + if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) continue; ProgressMaxValue += tracks.Count; } } - if(_dumpHardware != null) - ProgressMaxValue++; + if(_dumpHardware != null) ProgressMaxValue++; - if(_aaruMetadata != null) - ProgressMaxValue++; + if(_aaruMetadata != null) ProgressMaxValue++; ProgressMaxValue++; }); foreach(MediaTagType mediaTag in _inputFormat.Info.ReadableMediaTags.Where(mediaTag => - !outputFormat.SupportedMediaTags.Contains(mediaTag) && !ForceChecked)) + !outputFormat.SupportedMediaTags.Contains(mediaTag) && !ForceChecked)) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Converting_image_will_lose_media_tag_0, - mediaTag), icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Converting_image_will_lose_media_tag_0, + mediaTag), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -732,7 +728,7 @@ public sealed class ImageConvertViewModel : ViewModelBase bool useLong = _inputFormat.Info.ReadableSectorTags.Count != 0; foreach(SectorTagType sectorTag in _inputFormat.Info.ReadableSectorTags.Where(sectorTag => - !outputFormat.SupportedSectorTags.Contains(sectorTag))) + !outputFormat.SupportedSectorTags.Contains(sectorTag))) { if(ForceChecked) { @@ -744,12 +740,14 @@ public sealed class ImageConvertViewModel : ViewModelBase continue; } - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Converting_image_will_lose_sector_tag_0, - sectorTag), icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Converting_image_will_lose_sector_tag_0, + sectorTag), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -795,16 +793,19 @@ public sealed class ImageConvertViewModel : ViewModelBase Progress2Indeterminate = true; }); - if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, _inputFormat.Info.Sectors, + if(!outputFormat.Create(DestinationText, + _inputFormat.Info.MediaType, + parsedOptions, + _inputFormat.Info.Sectors, _inputFormat.Info.SectorSize)) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_creating_output_image, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI.Error_0_creating_output_image, outputFormat.ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_creating_output_image, outputFormat.ErrorMessage); @@ -845,14 +846,15 @@ public sealed class ImageConvertViewModel : ViewModelBase { if(ForceChecked != true) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_setting_metadata_not_continuing, - outputFormat. - ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_setting_metadata_not_continuing, + outputFormat + .ErrorMessage), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_setting_metadata_not_continuing, outputFormat.ErrorMessage); @@ -876,14 +878,15 @@ public sealed class ImageConvertViewModel : ViewModelBase if(!outputOptical.SetTracks(tracks)) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_sending_tracks_list_to_output_image, - outputFormat. - ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_sending_tracks_list_to_output_image, + outputFormat + .ErrorMessage), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_sending_tracks_list_to_output_image, outputFormat.ErrorMessage); @@ -903,13 +906,11 @@ public sealed class ImageConvertViewModel : ViewModelBase Progress2Indeterminate = true; }); - if(ForceChecked && !outputFormat.SupportedMediaTags.Contains(mediaTag)) - continue; + if(ForceChecked && !outputFormat.SupportedMediaTags.Contains(mediaTag)) continue; errno = _inputFormat.ReadMediaTag(mediaTag, out byte[] tag); - if(errno == ErrorNumber.NoError && outputFormat.WriteMediaTag(tag, mediaTag)) - continue; + if(errno == ErrorNumber.NoError && outputFormat.WriteMediaTag(tag, mediaTag)) continue; if(ForceChecked) { @@ -924,26 +925,28 @@ public sealed class ImageConvertViewModel : ViewModelBase { if(errno == ErrorNumber.NoError) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_media_tag_not_continuing, - outputFormat. - ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_media_tag_not_continuing, + outputFormat + .ErrorMessage), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag_not_continuing, outputFormat.ErrorMessage); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_media_tag_not_continuing, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_media_tag_not_continuing, errno), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_reading_media_tag_not_continuing, errno); } @@ -959,7 +962,8 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { ProgressText = string.Format(UI.Setting_geometry_to_0_cylinders_1_heads_and_2_sectors_per_track, - _inputFormat.Info.Cylinders, _inputFormat.Info.Heads, + _inputFormat.Info.Cylinders, + _inputFormat.Info.Heads, _inputFormat.Info.SectorsPerTrack); ProgressValue++; @@ -967,7 +971,8 @@ public sealed class ImageConvertViewModel : ViewModelBase Progress2Indeterminate = true; }); - if(!outputFormat.SetGeometry(_inputFormat.Info.Cylinders, _inputFormat.Info.Heads, + if(!outputFormat.SetGeometry(_inputFormat.Info.Cylinders, + _inputFormat.Info.Heads, _inputFormat.Info.SectorsPerTrack)) { warning = true; @@ -987,8 +992,7 @@ public sealed class ImageConvertViewModel : ViewModelBase while(doneSectors < _inputFormat.Info.Sectors) { - if(_cancel) - break; + if(_cancel) break; byte[] sector; @@ -1003,7 +1007,9 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - Progress2Text = string.Format(UI.Converting_sectors_0_to_1_2_done, sectors, sectors + sectorsToDo, + Progress2Text = string.Format(UI.Converting_sectors_0_to_1_2_done, + sectors, + sectors + sectorsToDo, sectors / (double)_inputFormat.Info.Sectors); Progress2Value = (int)(sectors / SectorsValue); @@ -1035,14 +1041,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, doneSectors); @@ -1074,14 +1081,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, doneSectors); @@ -1096,23 +1104,26 @@ public sealed class ImageConvertViewModel : ViewModelBase { warning = true; - AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing, outputFormat.ErrorMessage, + AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing, + outputFormat.ErrorMessage, doneSectors); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_sector_1_not_continuing, - outputFormat. - ErrorMessage, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_sector_1_not_continuing, + outputFormat + .ErrorMessage, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing, - outputFormat.ErrorMessage, doneSectors); + outputFormat.ErrorMessage, + doneSectors); return; } @@ -1123,8 +1134,10 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - Progress2Text = string.Format(UI.Converting_sectors_0_to_1_2_done, _inputFormat.Info.Sectors, - _inputFormat.Info.Sectors, 1.0); + Progress2Text = string.Format(UI.Converting_sectors_0_to_1_2_done, + _inputFormat.Info.Sectors, + _inputFormat.Info.Sectors, + 1.0); Progress2Value = Progress2MaxValue; }); @@ -1135,31 +1148,28 @@ public sealed class ImageConvertViewModel : ViewModelBase HashSet subchannelExtents = new(); Dictionary smallestPregapLbaPerTrack = new(); - foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags. - Where(t => t == SectorTagType.CdTrackIsrc). - OrderBy(t => t)) + foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags.Where(t => t == SectorTagType.CdTrackIsrc) + .OrderBy(t => t)) { foreach(Track track in inputOptical.Tracks) { errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] isrc); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; isrcs[(byte)track.Sequence] = Encoding.UTF8.GetString(isrc); } } - foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags. - Where(t => t == SectorTagType.CdTrackFlags). - OrderBy(t => t)) + foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags + .Where(t => t == SectorTagType.CdTrackFlags) + .OrderBy(t => t)) { foreach(Track track in inputOptical.Tracks) { errno = _inputFormat.ReadSectorTag(track.Sequence, tag, out byte[] flags); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; trackFlags[(byte)track.Sequence] = flags[0]; } @@ -1167,8 +1177,7 @@ public sealed class ImageConvertViewModel : ViewModelBase for(ulong s = 0; s < _inputFormat.Info.Sectors; s++) { - if(s > int.MaxValue) - break; + if(s > int.MaxValue) break; subchannelExtents.Add((int)s); } @@ -1189,8 +1198,7 @@ public sealed class ImageConvertViewModel : ViewModelBase continue; } - if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) - continue; + if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) continue; await Dispatcher.UIThread.InvokeAsync(() => { @@ -1205,8 +1213,7 @@ public sealed class ImageConvertViewModel : ViewModelBase while(doneSectors < _inputFormat.Info.Sectors) { - if(_cancel) - break; + if(_cancel) break; byte[] sector; @@ -1222,7 +1229,8 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { Progress2Text = string.Format(UI.Converting_tag_0_for_sectors_1_to_2_3_done, - sectors / (double)_inputFormat.Info.Sectors, sectors, + sectors / (double)_inputFormat.Info.Sectors, + sectors, sectors + sectorsToDo, sectors / (double)_inputFormat.Info.Sectors); @@ -1242,13 +1250,27 @@ public sealed class ImageConvertViewModel : ViewModelBase if(tag == SectorTagType.CdSectorSubchannel && track != null) { bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw, - MmcSubchannel.Raw, sector, doneSectors, 1, null, isrcs, (byte)track.Sequence, - ref mcn, tracks.ToArray(), subchannelExtents, false, - outputFormat as IWritableOpticalImage, false, false, null, null, - smallestPregapLbaPerTrack, false, out _); + MmcSubchannel.Raw, + sector, + doneSectors, + 1, + null, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks.ToArray(), + subchannelExtents, + false, + outputFormat as IWritableOpticalImage, + false, + false, + null, + null, + smallestPregapLbaPerTrack, + false, + out _); - if(indexesChanged) - outputOptical.SetTracks(tracks.ToList()); + if(indexesChanged) outputOptical.SetTracks(tracks.ToList()); result = true; } @@ -1267,15 +1289,18 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, - errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, + errno, + doneSectors), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); - AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, + AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, + errno, doneSectors); return; @@ -1294,13 +1319,27 @@ public sealed class ImageConvertViewModel : ViewModelBase { bool indexesChanged = CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw, - MmcSubchannel.Raw, sector, doneSectors, sectorsToDo, null, isrcs, - (byte)track.Sequence, ref mcn, tracks.ToArray(), subchannelExtents, false, - outputFormat as IWritableOpticalImage, false, false, null, null, - smallestPregapLbaPerTrack, false, out _); + MmcSubchannel.Raw, + sector, + doneSectors, + sectorsToDo, + null, + isrcs, + (byte)track.Sequence, + ref mcn, + tracks.ToArray(), + subchannelExtents, + false, + outputFormat as IWritableOpticalImage, + false, + false, + null, + null, + smallestPregapLbaPerTrack, + false, + out _); - if(indexesChanged) - outputOptical.SetTracks(tracks.ToList()); + if(indexesChanged) outputOptical.SetTracks(tracks.ToList()); result = true; } @@ -1319,15 +1358,18 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, - errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, + errno, + doneSectors), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); - AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, + AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, + errno, doneSectors); return; @@ -1342,22 +1384,25 @@ public sealed class ImageConvertViewModel : ViewModelBase warning = true; AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing, - outputFormat.ErrorMessage, doneSectors); + outputFormat.ErrorMessage, + doneSectors); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_sector_1_not_continuing, - outputFormat. - ErrorMessage, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_sector_1_not_continuing, + outputFormat + .ErrorMessage, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing, - outputFormat.ErrorMessage, doneSectors); + outputFormat.ErrorMessage, + doneSectors); return; } @@ -1368,8 +1413,11 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - Progress2Text = string.Format(UI.Converting_tag_0_for_sectors_1_to_2_3_done, tag, - _inputFormat.Info.Sectors, _inputFormat.Info.Sectors, 1.0); + Progress2Text = string.Format(UI.Converting_tag_0_for_sectors_1_to_2_3_done, + tag, + _inputFormat.Info.Sectors, + _inputFormat.Info.Sectors, + 1.0); Progress2Value = Progress2MaxValue; }); @@ -1378,7 +1426,8 @@ public sealed class ImageConvertViewModel : ViewModelBase { foreach(KeyValuePair isrc in isrcs) { - outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key, + outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), + isrc.Key, SectorTagType.CdTrackIsrc); } } @@ -1388,14 +1437,15 @@ public sealed class ImageConvertViewModel : ViewModelBase foreach(KeyValuePair flags in trackFlags) { outputOptical.WriteSectorTag(new[] - { - flags.Value - }, flags.Key, SectorTagType.CdTrackFlags); + { + flags.Value + }, + flags.Key, + SectorTagType.CdTrackFlags); } } - if(mcn != null) - outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); + if(mcn != null) outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); } } else @@ -1416,8 +1466,7 @@ public sealed class ImageConvertViewModel : ViewModelBase while(doneSectors < trackSectors) { - if(_cancel) - break; + if(_cancel) break; byte[] sector; @@ -1434,7 +1483,8 @@ public sealed class ImageConvertViewModel : ViewModelBase { Progress2Text = string.Format(UI.Converting_sectors_0_to_1_in_track_2_3_done, sectors + track.StartSector, - sectors + sectorsToDo + track.StartSector, track.Sequence, + sectors + sectorsToDo + track.StartSector, + track.Sequence, (sectors + track.StartSector) / (double)_inputFormat.Info.Sectors); @@ -1447,14 +1497,16 @@ public sealed class ImageConvertViewModel : ViewModelBase { errno = sectorsToDo == 1 ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector) - : _inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo, + : _inputFormat.ReadSectorsLong(doneSectors + track.StartSector, + sectorsToDo, out sector); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 ? outputFormat.WriteSectorLong(sector, doneSectors + track.StartSector) - : outputFormat.WriteSectorsLong(sector, doneSectors + track.StartSector, + : outputFormat.WriteSectorsLong(sector, + doneSectors + track.StartSector, sectorsToDo); } else @@ -1469,13 +1521,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, - errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, + errno, + doneSectors), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1485,14 +1539,16 @@ public sealed class ImageConvertViewModel : ViewModelBase { errno = sectorsToDo == 1 ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector) - : _inputFormat.ReadSectors(doneSectors + track.StartSector, sectorsToDo, + : _inputFormat.ReadSectors(doneSectors + track.StartSector, + sectorsToDo, out sector); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors + track.StartSector) - : outputFormat.WriteSectors(sector, doneSectors + track.StartSector, + : outputFormat.WriteSectors(sector, + doneSectors + track.StartSector, sectorsToDo); } else @@ -1507,13 +1563,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_sector_1_not_continuing, - errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_sector_1_not_continuing, + errno, + doneSectors), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1527,19 +1585,21 @@ public sealed class ImageConvertViewModel : ViewModelBase warning = true; AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing, - outputFormat.ErrorMessage, doneSectors); + outputFormat.ErrorMessage, + doneSectors); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_sector_1_not_continuing, - outputFormat. - ErrorMessage, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_sector_1_not_continuing, + outputFormat + .ErrorMessage, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1551,14 +1611,17 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - Progress2Text = string.Format(UI.Converting_sectors_0_to_1_in_track_2_3_done, _inputFormat.Info.Sectors, - _inputFormat.Info.Sectors, tracks.Count, 1.0); + Progress2Text = string.Format(UI.Converting_sectors_0_to_1_in_track_2_3_done, + _inputFormat.Info.Sectors, + _inputFormat.Info.Sectors, + tracks.Count, + 1.0); Progress2Value = Progress2MaxValue; }); - foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags.OrderBy(t => t). - TakeWhile(_ => useLong && !_cancel)) + foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags.OrderBy(t => t) + .TakeWhile(_ => useLong && !_cancel)) { switch(tag) { @@ -1574,8 +1637,7 @@ public sealed class ImageConvertViewModel : ViewModelBase continue; } - if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) - continue; + if(ForceChecked && !outputFormat.SupportedSectorTags.Contains(tag)) continue; foreach(Track track in tracks.TakeWhile(_ => !_cancel)) { @@ -1612,13 +1674,14 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_media_tag_not_continuing, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_media_tag_not_continuing, errno), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1637,14 +1700,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_tag_not_continuing, - outputFormat. - ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_tag_not_continuing, + outputFormat + .ErrorMessage), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1655,8 +1719,7 @@ public sealed class ImageConvertViewModel : ViewModelBase while(doneSectors < trackSectors) { - if(_cancel) - break; + if(_cancel) break; uint sectorsToDo; @@ -1669,9 +1732,11 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - Progress2Text = string.Format(UI.Converting_tag_0_for_sectors_1_to_2_in_track_3_4_done, tag, + Progress2Text = string.Format(UI.Converting_tag_0_for_sectors_1_to_2_in_track_3_4_done, + tag, sectors + track.StartSector, - sectors + sectorsToDo + track.StartSector, track.Sequence, + sectors + sectorsToDo + track.StartSector, + track.Sequence, (sectors + track.StartSector) / (double)_inputFormat.Info.Sectors); @@ -1680,15 +1745,19 @@ public sealed class ImageConvertViewModel : ViewModelBase errno = sectorsToDo == 1 ? _inputFormat.ReadSectorTag(doneSectors + track.StartSector, tag, out sector) - : _inputFormat.ReadSectorsTag(doneSectors + track.StartSector, sectorsToDo, tag, + : _inputFormat.ReadSectorsTag(doneSectors + track.StartSector, + sectorsToDo, + tag, out sector); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 ? outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag) - : outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector, - sectorsToDo, tag); + : outputFormat.WriteSectorsTag(sector, + doneSectors + track.StartSector, + sectorsToDo, + tag); } else { @@ -1698,18 +1767,21 @@ public sealed class ImageConvertViewModel : ViewModelBase { warning = true; - AaruConsole.ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing, errno, + AaruConsole.ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing, + errno, doneSectors); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_reading_tag_for_sector_1_not_continuing, - errno, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_reading_tag_for_sector_1_not_continuing, + errno, + doneSectors), + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1722,19 +1794,21 @@ public sealed class ImageConvertViewModel : ViewModelBase warning = true; AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_for_sector_1_continuing, - outputFormat.ErrorMessage, doneSectors); + outputFormat.ErrorMessage, + doneSectors); } else { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_writing_tag_for_sector_1_not_continuing, - outputFormat. - ErrorMessage, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_writing_tag_for_sector_1_not_continuing, + outputFormat + .ErrorMessage, doneSectors), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1780,8 +1854,7 @@ public sealed class ImageConvertViewModel : ViewModelBase outputFormat.SetMetadata(_aaruMetadata); - if(!ret) - AaruConsole.WriteLine(UI.Error_0_writing_Aaru_Metadata_to_output_image, outputFormat.ErrorMessage); + if(!ret) AaruConsole.WriteLine(UI.Error_0_writing_Aaru_Metadata_to_output_image, outputFormat.ErrorMessage); } await Dispatcher.UIThread.InvokeAsync(() => @@ -1794,10 +1867,11 @@ public sealed class ImageConvertViewModel : ViewModelBase { await Dispatcher.UIThread.InvokeAsync(async () => { - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, UI.Operation_canceled_the_output_file_is_not_correct, - icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + UI.Operation_canceled_the_output_file_is_not_correct, + icon: Icon.Error) + .ShowWindowDialogAsync(_view); CloseVisible = true; StopVisible = false; @@ -1809,13 +1883,14 @@ public sealed class ImageConvertViewModel : ViewModelBase if(!outputFormat.Close()) { - await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, - string. - Format(UI.Error_0_closing_output_image_Contents_are_not_correct, + await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string + .Format(UI + .Error_0_closing_output_image_Contents_are_not_correct, outputFormat.ErrorMessage), - icon: Icon.Error). - ShowWindowDialogAsync(_view)); + icon: Icon.Error) + .ShowWindowDialogAsync(_view)); return; } @@ -1826,8 +1901,8 @@ public sealed class ImageConvertViewModel : ViewModelBase warning ? UI.Some_warnings_happened_Check_console : UI.Image_converted_successfully, - icon: warning ? Icon.Warning : Icon.Info). - ShowWindowDialogAsync(_view); + icon: warning ? Icon.Warning : Icon.Info) + .ShowWindowDialogAsync(_view); CloseVisible = true; StopVisible = false; @@ -1981,8 +2056,7 @@ public sealed class ImageConvertViewModel : ViewModelBase */ async Task ExecuteDestinationCommand() { - if(SelectedPlugin is null) - return; + if(SelectedPlugin is null) return; var dlgDestination = new SaveFileDialog { @@ -2004,8 +2078,7 @@ public sealed class ImageConvertViewModel : ViewModelBase return; } - if(string.IsNullOrEmpty(Path.GetExtension(result))) - result += SelectedPlugin.Plugin.KnownExtensions.First(); + if(string.IsNullOrEmpty(Path.GetExtension(result))) result += SelectedPlugin.Plugin.KnownExtensions.First(); DestinationText = result; } @@ -2065,8 +2138,7 @@ public sealed class ImageConvertViewModel : ViewModelBase string[] result = await dlgMetadata.ShowAsync(_view); - if(result is null || result.Length != 1) - return; + if(result is null || result.Length != 1) return; try { @@ -2081,9 +2153,9 @@ public sealed class ImageConvertViewModel : ViewModelBase } catch { - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_metadata_sidecar_file, - icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_metadata_sidecar_file, icon: Icon.Error) + .ShowWindowDialogAsync(_view); } } @@ -2114,16 +2186,15 @@ public sealed class ImageConvertViewModel : ViewModelBase string[] result = await dlgMetadata.ShowAsync(_view); - if(result is null || result.Length != 1) - return; + if(result is null || result.Length != 1) return; try { var fs = new FileStream(result[0], FileMode.Open); Resume resume = - (await JsonSerializer.DeserializeAsync(fs, typeof(ResumeJson), - ResumeJsonContext.Default) as ResumeJson)?.Resume; + (await JsonSerializer.DeserializeAsync(fs, typeof(ResumeJson), ResumeJsonContext.Default) as ResumeJson) + ?.Resume; fs.Close(); @@ -2134,16 +2205,17 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, UI.Resume_file_does_not_contain_dump_hardware_information, - icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + UI.Resume_file_does_not_contain_dump_hardware_information, + icon: Icon.Error) + .ShowWindowDialogAsync(_view); } } catch { - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_resume_file, icon: Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_resume_file, icon: Icon.Error) + .ShowWindowDialogAsync(_view); } } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs index 4cabb29e1..872f848e7 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs @@ -333,15 +333,15 @@ public sealed class ImageEntropyViewModel : ViewModelBase if(trackEntropy.UniqueSectors != null) { - AaruConsole.WriteLine(UI.Track_0_has_1_unique_sectors_2, trackEntropy.Track, + AaruConsole.WriteLine(UI.Track_0_has_1_unique_sectors_2, + trackEntropy.Track, trackEntropy.UniqueSectors, (double)trackEntropy.UniqueSectors / trackEntropy.Sectors); } } } - if(WholeDiscChecked != true) - return; + if(WholeDiscChecked != true) return; _entropy = entropyCalculator.CalculateMediaEntropy(DuplicatedSectorsChecked); @@ -374,16 +374,15 @@ public sealed class ImageEntropyViewModel : ViewModelBase } } - if(WholeDiscChecked != true) - return; + if(WholeDiscChecked != true) return; MediaEntropyText = string.Format(UI.Entropy_for_disk_is_0, _entropy.Entropy); MediaEntropyVisible = true; - if(_entropy.UniqueSectors == null) - return; + if(_entropy.UniqueSectors == null) return; - MediaUniqueSectorsText = string.Format(UI.Disk_has_0_unique_sectors_1, _entropy.UniqueSectors, + MediaUniqueSectorsText = string.Format(UI.Disk_has_0_unique_sectors_1, + _entropy.UniqueSectors, (double)_entropy.UniqueSectors / _entropy.Sectors); MediaUniqueSectorsVisible = true; @@ -413,8 +412,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase return; } - if(ProgressIndeterminate) - ProgressIndeterminate = false; + if(ProgressIndeterminate) ProgressIndeterminate = false; ProgressMax = maximum; ProgressValue = current; @@ -432,8 +430,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase return; } - if(Progress2Indeterminate) - Progress2Indeterminate = false; + if(Progress2Indeterminate) Progress2Indeterminate = false; Progress2Max = maximum; Progress2Value = current; diff --git a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs index da60d7026..a1b9fbe0e 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs @@ -256,10 +256,13 @@ public sealed class ImageSidecarViewModel : ViewModelBase var jsonFs = new FileStream(DestinationText, FileMode.Create); - await JsonSerializer.SerializeAsync(jsonFs, new MetadataJson - { - AaruMetadata = sidecar - }, typeof(MetadataJson), MetadataJsonContext.Default); + await JsonSerializer.SerializeAsync(jsonFs, + new MetadataJson + { + AaruMetadata = sidecar + }, + typeof(MetadataJson), + MetadataJsonContext.Default); jsonFs.Close(); @@ -343,8 +346,7 @@ public sealed class ImageSidecarViewModel : ViewModelBase return; } - if(string.IsNullOrEmpty(Path.GetExtension(result))) - result += ".json"; + if(string.IsNullOrEmpty(Path.GetExtension(result))) result += ".json"; DestinationText = result; } diff --git a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs index 46e17f02d..a428c6f48 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs @@ -376,8 +376,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase ProgressVisible = true; ProgressMaxValue = 0; - if(VerifyImageChecked || VerifySectorsChecked) - ProgressMaxValue = 1; + if(VerifyImageChecked || VerifySectorsChecked) ProgressMaxValue = 1; if(formatHasTracks && inputOptical != null) ProgressMaxValue += inputOptical.Tracks.Count; @@ -469,7 +468,8 @@ public sealed class ImageVerifyViewModel : ViewModelBase { await Dispatcher.UIThread.InvokeAsync(() => { - ProgressText = string.Format(UI.Verifying_track_0_of_1, currentTrack.Sequence, + ProgressText = string.Format(UI.Verifying_track_0_of_1, + currentTrack.Sequence, inputOptical.Tracks.Count); ProgressValue++; @@ -498,8 +498,10 @@ public sealed class ImageVerifyViewModel : ViewModelBase { Progress2Value = all / 512d; - Progress2Text = string.Format(UI.Checking_sector_0_of_1_on_track_2, all, - _inputFormat.Info.Sectors, currentTrack.Sequence); + Progress2Text = string.Format(UI.Checking_sector_0_of_1_on_track_2, + all, + _inputFormat.Info.Sectors, + currentTrack.Sequence); }); List tempFailingLbas; @@ -507,12 +509,18 @@ public sealed class ImageVerifyViewModel : ViewModelBase if(remainingSectors < 512) { - inputOptical.VerifySectors(currentSector, (uint)remainingSectors, currentTrack.Sequence, - out tempFailingLbas, out tempUnknownLbas); + inputOptical.VerifySectors(currentSector, + (uint)remainingSectors, + currentTrack.Sequence, + out tempFailingLbas, + out tempUnknownLbas); } else { - inputOptical.VerifySectors(currentSector, 512, currentTrack.Sequence, out tempFailingLbas, + inputOptical.VerifySectors(currentSector, + 512, + currentTrack.Sequence, + out tempFailingLbas, out tempUnknownLbas); } @@ -571,12 +579,16 @@ public sealed class ImageVerifyViewModel : ViewModelBase if(remainingSectors < 512) { - verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors, out tempFailingLbas, + verifiableSectorsImage.VerifySectors(currentSector, + (uint)remainingSectors, + out tempFailingLbas, out tempUnknownLbas); } else { - verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas, + verifiableSectorsImage.VerifySectors(currentSector, + 512, + out tempFailingLbas, out tempUnknownLbas); } diff --git a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index be4cddc5b..326a6958b 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -147,12 +147,13 @@ public sealed class MainWindowViewModel : ViewModelBase new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/inode-directory.png"))); _usbIcon = - new Bitmap(AssetLoader. - Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png"))); + new + Bitmap(AssetLoader.Open(new + Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png"))); _removableIcon = - new Bitmap(AssetLoader. - Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png"))); + new + Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png"))); _sdIcon = new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-flash-sd-mmc.png"))); @@ -193,8 +194,9 @@ public sealed class MainWindowViewModel : ViewModelBase { get { - Window mainWindow = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?. - MainWindow; + Window mainWindow = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime) + ?.MainWindow; + return mainWindow is not null && NativeMenu.GetIsNativeMenuExported(mainWindow); } } @@ -231,8 +233,7 @@ public sealed class MainWindowViewModel : ViewModelBase get => _treeViewSelectedItem; set { - if(value == _treeViewSelectedItem) - return; + if(value == _treeViewSelectedItem) return; this.RaiseAndSetIfChanged(ref _treeViewSelectedItem, value); @@ -281,7 +282,8 @@ public sealed class MainWindowViewModel : ViewModelBase return; case Devices.Remote.Device remoteDev: - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, + Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); @@ -375,8 +377,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteCalculateEntropyCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; var imageEntropyWindow = new ImageEntropy(); imageEntropyWindow.DataContext = new ImageEntropyViewModel(imageModel.Image, imageEntropyWindow); @@ -388,8 +389,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteVerifyImageCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; var imageVerifyWindow = new ImageVerify(); imageVerifyWindow.DataContext = new ImageVerifyViewModel(imageModel.Image, imageVerifyWindow); @@ -401,8 +401,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteChecksumImageCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; var imageChecksumWindow = new ImageChecksum(); imageChecksumWindow.DataContext = new ImageChecksumViewModel(imageModel.Image, imageChecksumWindow); @@ -414,8 +413,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteConvertImageCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; var imageConvertWindow = new ImageConvert(); @@ -429,14 +427,16 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteCreateSidecarCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; var imageSidecarWindow = new ImageSidecar(); // TODO: Pass thru chosen default encoding imageSidecarWindow.DataContext = - new ImageSidecarViewModel(imageModel.Image, imageModel.Path, imageModel.Filter.Id, null, + new ImageSidecarViewModel(imageModel.Image, + imageModel.Path, + imageModel.Filter.Id, + null, imageSidecarWindow); imageSidecarWindow.Show(); @@ -444,8 +444,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteViewImageSectorsCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; new ViewSector { @@ -455,8 +454,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteDecodeImageMediaTagsCommand() { - if(TreeViewSelectedItem is not ImageModel imageModel) - return; + if(TreeViewSelectedItem is not ImageModel imageModel) return; new DecodeMediaTags { @@ -497,8 +495,8 @@ public sealed class MainWindowViewModel : ViewModelBase !ctx.Partitions.Any() && !ctx.SeenDevices.Any()) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Warning, UI.There_are_no_statistics). - ShowWindowDialogAsync(_view); + MessageBoxManager.GetMessageBoxStandard(UI.Title_Warning, UI.There_are_no_statistics) + .ShowWindowDialogAsync(_view); return; } @@ -540,14 +538,15 @@ public sealed class MainWindowViewModel : ViewModelBase string[] result = await dlgOpenImage.ShowAsync(_view); - if(result?.Length != 1) - return; + if(result?.Length != 1) return; IFilter inputFilter = PluginRegister.Singleton.GetFilter(result[0]); if(inputFilter == null) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Cannot_open_specified_file, ButtonEnum.Ok, + MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, + UI.Cannot_open_specified_file, + ButtonEnum.Ok, Icon.Error); return; @@ -557,7 +556,9 @@ public sealed class MainWindowViewModel : ViewModelBase { if(ImageFormat.Detect(inputFilter) is not IMediaImage imageFormat) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Image_format_not_identified, ButtonEnum.Ok, + MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, + UI.Image_format_not_identified, + ButtonEnum.Ok, Icon.Error); return; @@ -573,7 +574,8 @@ public sealed class MainWindowViewModel : ViewModelBase { MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_opening_image_format, opened), - ButtonEnum.Ok, Icon.Error); + ButtonEnum.Ok, + Icon.Error); AaruConsole.ErrorWriteLine(UI.Unable_to_open_image_format); AaruConsole.ErrorWriteLine(UI.No_error_given); @@ -588,13 +590,10 @@ public sealed class MainWindowViewModel : ViewModelBase Path = result[0], Icon = AssetLoader.Exists(mediaResource) ? new Bitmap(AssetLoader.Open(mediaResource)) - : - imageFormat.Info.MetadataMediaType == MetadataMediaType.BlockMedia + : imageFormat.Info.MetadataMediaType == MetadataMediaType.BlockMedia ? _genericHddIcon - : - imageFormat.Info.MetadataMediaType == MetadataMediaType.OpticalDisc - ? - _genericOpticalIcon + : imageFormat.Info.MetadataMediaType == MetadataMediaType.OpticalDisc + ? _genericOpticalIcon : _genericFolderIcon, FileName = Path.GetFileName(result[0]), Image = imageFormat, @@ -627,8 +626,8 @@ public sealed class MainWindowViewModel : ViewModelBase Name = scheme }; - foreach(CommonTypes.Partition partition in partitions.Where(p => p.Scheme == scheme). - OrderBy(p => p.Start)) + foreach(CommonTypes.Partition partition in partitions.Where(p => p.Scheme == scheme) + .OrderBy(p => p.Start)) { var partitionModel = new PartitionModel { @@ -650,23 +649,26 @@ public sealed class MainWindowViewModel : ViewModelBase foreach(string pluginName in idPlugins) { - if(!plugins.Filesystems.TryGetValue(pluginName, out IFilesystem fs)) - continue; - if(fs is null) - continue; + if(!plugins.Filesystems.TryGetValue(pluginName, out IFilesystem fs)) continue; + if(fs is null) continue; - fs.GetInformation(imageFormat, partition, null, out string information, + fs.GetInformation(imageFormat, + partition, + null, + out string information, out CommonTypes.AaruMetadata.FileSystem fsMetadata); var rofs = fs as IReadOnlyFilesystem; if(rofs != null) { - ErrorNumber error = rofs.Mount(imageFormat, partition, null, - new Dictionary(), null); + ErrorNumber error = rofs.Mount(imageFormat, + partition, + null, + new Dictionary(), + null); - if(error != ErrorNumber.NoError) - rofs = null; + if(error != ErrorNumber.NoError) rofs = null; } var filesystemModel = new FileSystemModel @@ -725,23 +727,26 @@ public sealed class MainWindowViewModel : ViewModelBase foreach(string pluginName in idPlugins) { - if(!plugins.Filesystems.TryGetValue(pluginName, out IFilesystem fs)) - continue; - if(fs is null) - continue; + if(!plugins.Filesystems.TryGetValue(pluginName, out IFilesystem fs)) continue; + if(fs is null) continue; - fs.GetInformation(imageFormat, wholePart, null, out string information, + fs.GetInformation(imageFormat, + wholePart, + null, + out string information, out CommonTypes.AaruMetadata.FileSystem fsMetadata); var rofs = fs as IReadOnlyFilesystem; if(rofs != null) { - ErrorNumber error = rofs.Mount(imageFormat, wholePart, null, - new Dictionary(), null); + ErrorNumber error = rofs.Mount(imageFormat, + wholePart, + null, + new Dictionary(), + null); - if(error != ErrorNumber.NoError) - rofs = null; + if(error != ErrorNumber.NoError) rofs = null; } var filesystemModel = new FileSystemModel @@ -783,7 +788,9 @@ public sealed class MainWindowViewModel : ViewModelBase } catch(Exception ex) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Unable_to_open_image_format, ButtonEnum.Ok, + MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, + UI.Unable_to_open_image_format, + ButtonEnum.Ok, Icon.Error); AaruConsole.ErrorWriteLine(UI.Unable_to_open_image_format); @@ -793,7 +800,9 @@ public sealed class MainWindowViewModel : ViewModelBase } catch(Exception ex) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Exception_reading_file, ButtonEnum.Ok, + MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, + UI.Exception_reading_file, + ButtonEnum.Ok, Icon.Error); AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message)); @@ -809,22 +818,24 @@ public sealed class MainWindowViewModel : ViewModelBase void RefreshDevices() { - if(!DevicesSupported) - return; + if(!DevicesSupported) return; try { AaruConsole.WriteLine(UI.Refreshing_devices); _devicesRoot.Devices.Clear(); - foreach(Devices.DeviceInfo device in Device.ListDevices(). - Where(d => d.Supported). - OrderBy(d => d.Vendor). - ThenBy(d => d.Model)) + foreach(Devices.DeviceInfo device in Device.ListDevices() + .Where(d => d.Supported) + .OrderBy(d => d.Vendor) + .ThenBy(d => d.Model)) { AaruConsole.DebugWriteLine(MODULE_NAME, UI.Found_supported_device_model_0_by_manufacturer_1_on_bus_2_and_path_3, - device.Model, device.Vendor, device.Bus, device.Path); + device.Model, + device.Vendor, + device.Bus, + device.Path); var deviceModel = new DeviceModel { @@ -839,8 +850,10 @@ public sealed class MainWindowViewModel : ViewModelBase { if(dev is Devices.Remote.Device remoteDev) { - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, + Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, + remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); } diff --git a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs index 2d5846fb7..1356e417c 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs @@ -172,8 +172,7 @@ public sealed class MediaDumpViewModel : ViewModelBase foreach(IWritableImage plugin in plugins.WritableImages.Values) { - if(plugin is null) - continue; + if(plugin is null) continue; if(plugin.SupportedMediaTypes.Contains(mediaType)) { @@ -184,15 +183,15 @@ public sealed class MediaDumpViewModel : ViewModelBase } } - Encodings.AddRange(Encoding.GetEncodings(). - Select(info => new EncodingModel + Encodings.AddRange(Encoding.GetEncodings() + .Select(info => new EncodingModel { Name = info.Name, DisplayName = info.GetEncoding().EncodingName })); - Encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings(). - Select(info => new EncodingModel + Encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings() + .Select(info => new EncodingModel { Name = info.Name, DisplayName = info.DisplayName @@ -452,11 +451,9 @@ public sealed class MediaDumpViewModel : ViewModelBase { this.RaiseAndSetIfChanged(ref _useResume, value); - if(!value) - return; + if(!value) return; - if(_outputPrefix != null) - CheckResumeFile().GetAwaiter().GetResult(); + if(_outputPrefix != null) CheckResumeFile().GetAwaiter().GetResult(); } } @@ -542,8 +539,8 @@ public sealed class MediaDumpViewModel : ViewModelBase var fs = new FileStream(result[0], FileMode.Open); _sidecar = - (JsonSerializer.Deserialize(fs, typeof(MetadataJson), MetadataJsonContext.Default) as MetadataJson)? - .AaruMetadata; + (JsonSerializer.Deserialize(fs, typeof(MetadataJson), MetadataJsonContext.Default) as MetadataJson) + ?.AaruMetadata; fs.Close(); } @@ -553,10 +550,9 @@ public sealed class MediaDumpViewModel : ViewModelBase _ = MessageBoxManager. // ReSharper restore AssignmentIsFullyDiscarded - GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_metadata_sidecar_file, ButtonEnum.Ok, - Icon.Error). - ShowWindowDialogAsync(_view). - Result; + GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_metadata_sidecar_file, ButtonEnum.Ok, Icon.Error) + .ShowWindowDialogAsync(_view) + .Result; ExistingMetadata = false; } @@ -673,8 +669,7 @@ public sealed class MediaDumpViewModel : ViewModelBase async Task ExecuteDestinationCommand() { - if(SelectedPlugin is null) - return; + if(SelectedPlugin is null) return; var dlgDestination = new SaveFileDialog { @@ -697,8 +692,7 @@ public sealed class MediaDumpViewModel : ViewModelBase return; } - if(string.IsNullOrEmpty(Path.GetExtension(result))) - result += SelectedPlugin.Plugin.KnownExtensions.First(); + if(string.IsNullOrEmpty(Path.GetExtension(result))) result += SelectedPlugin.Plugin.KnownExtensions.First(); Destination = result; @@ -728,26 +722,28 @@ public sealed class MediaDumpViewModel : ViewModelBase else if(File.Exists(_outputPrefix + ".resume.xml")) { // Should be covered by virtue of being the same exact class as the JSON above - #pragma warning disable IL2026 +#pragma warning disable IL2026 var xs = new XmlSerializer(typeof(Resume)); - #pragma warning restore IL2026 +#pragma warning restore IL2026 var sr = new StreamReader(_outputPrefix + ".resume.xml"); // Should be covered by virtue of being the same exact class as the JSON above - #pragma warning disable IL2026 +#pragma warning disable IL2026 _resume = (Resume)xs.Deserialize(sr); - #pragma warning restore IL2026 +#pragma warning restore IL2026 sr.Close(); } } catch { - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_resume_file_cannot_use_it, ButtonEnum.Ok, - Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + UI.Incorrect_resume_file_cannot_use_it, + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); Resume = false; @@ -757,11 +753,12 @@ public sealed class MediaDumpViewModel : ViewModelBase if(_resume == null || _resume.NextBlock <= _resume.LastBlock || _resume.BadBlocks.Count != 0 && !_resume.Tape) return; - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Warning, - UI.Media_already_dumped_correctly_please_choose_another_destination, ButtonEnum.Ok, - Icon.Warning). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Warning, + UI.Media_already_dumped_correctly_please_choose_another_destination, + ButtonEnum.Ok, + Icon.Warning) + .ShowWindowDialogAsync(_view); Resume = false; } @@ -796,8 +793,10 @@ public sealed class MediaDumpViewModel : ViewModelBase return; case Devices.Remote.Device remoteDev: - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, + Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, + remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); break; @@ -873,11 +872,45 @@ public sealed class MediaDumpViewModel : ViewModelBase var errorLog = new ErrorLog(_outputPrefix + ".error.log"); - _dumper = new Dump(Resume, _dev, _devicePath, SelectedPlugin.Plugin, (ushort)Retries, Force, false, Persistent, - StopOnError, _resume, dumpLog, encoding, _outputPrefix, Destination, parsedOptions, _sidecar, - (uint)Skipped, ExistingMetadata == false, Trim == false, Track1Pregap, true, false, - DumpSubchannel.Any, 0, false, false, false, false, false, true, errorLog, false, 64, true, - true, false, 10, true, 1080); + _dumper = new Dump(Resume, + _dev, + _devicePath, + SelectedPlugin.Plugin, + (ushort)Retries, + Force, + false, + Persistent, + StopOnError, + _resume, + dumpLog, + encoding, + _outputPrefix, + Destination, + parsedOptions, + _sidecar, + (uint)Skipped, + ExistingMetadata == false, + Trim == false, + Track1Pregap, + true, + false, + DumpSubchannel.Any, + 0, + false, + false, + false, + false, + false, + true, + errorLog, + false, + 64, + true, + true, + false, + 10, + true, + 1080); new Thread(DoWork).Start(); } @@ -955,8 +988,8 @@ public sealed class MediaDumpViewModel : ViewModelBase { ErrorMessage(text); - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error) + .ShowWindowDialogAsync(_view); await WorkFinished(); }); diff --git a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs index 6be438ddd..7b18ecff2 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs @@ -109,6 +109,7 @@ public sealed class MediaScanViewModel : ViewModelBase StartVisible = true; CloseVisible = true; BlockMapList = new ObservableCollection<(ulong block, double duration)>(); + // ChartPoints = new ObservableCollection(); StepsX = double.NaN; StepsY = double.NaN; @@ -136,6 +137,7 @@ public sealed class MediaScanViewModel : ViewModelBase } public ObservableCollection<(ulong block, double duration)> BlockMapList { get; } + // public ObservableCollection ChartPoints { get; } public ulong Blocks @@ -329,6 +331,7 @@ public sealed class MediaScanViewModel : ViewModelBase CloseVisible = false; ProgressVisible = true; ResultsVisible = true; + // ChartPoints.Clear(); new Thread(DoWork).Start(); } @@ -345,10 +348,12 @@ public sealed class MediaScanViewModel : ViewModelBase switch(dev) { case null: - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_opening_device, devErrno), - ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string.Format(UI.Error_0_opening_device, devErrno), + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); StopVisible = false; StartVisible = true; @@ -357,8 +362,10 @@ public sealed class MediaScanViewModel : ViewModelBase return; case Devices.Remote.Device remoteDev: - Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion, + Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, + remoteDev.RemoteOperatingSystemVersion, remoteDev.RemoteArchitecture); break; @@ -366,10 +373,12 @@ public sealed class MediaScanViewModel : ViewModelBase if(dev.Error) { - await MessageBoxManager. - GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_opening_device, dev.LastError), - ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager + .GetMessageBoxStandard(UI.Title_Error, + string.Format(UI.Error_0_opening_device, dev.LastError), + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(_view); StopVisible = false; StartVisible = true; @@ -454,8 +463,7 @@ public sealed class MediaScanViewModel : ViewModelBase ChartPoints.Add(new DataPoint(sector, currentSpeed)); */ - if(currentSpeed > MaxY) - MaxY = currentSpeed + currentSpeed / 10d; + if(currentSpeed > MaxY) MaxY = currentSpeed + currentSpeed / 10d; }); [SuppressMessage("ReSharper", "AsyncVoidMethod")] @@ -599,8 +607,8 @@ public sealed class MediaScanViewModel : ViewModelBase { ProgressText = text; - await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error). - ShowWindowDialogAsync(_view); + await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error) + .ShowWindowDialogAsync(_view); await WorkFinished(); }); diff --git a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs index 3115961de..7a53ccca6 100644 --- a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs @@ -143,38 +143,38 @@ public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase ctx = AaruContext.Create(Settings.Settings.LocalDbPath); ctx.Database.EnsureCreated(); - ctx.Database. - ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); + ctx.Database + .ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); foreach(string migration in ctx.Database.GetPendingMigrations()) { - ctx.Database. - ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ - migration}', '0.0.0')"); + ctx.Database + .ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ + migration}', '0.0.0')"); } ctx.SaveChanges(); } // Remove duplicates - foreach(var duplicate in ctx.SeenDevices.AsEnumerable(). - GroupBy(a => new + foreach(var duplicate in ctx.SeenDevices.AsEnumerable() + .GroupBy(a => new { a.Manufacturer, a.Model, a.Revision, a.Bus - }). - Where(a => a.Count() > 1). - Distinct(). - Select(a => a.Key)) + }) + .Where(a => a.Count() > 1) + .Distinct() + .Select(a => a.Key)) { - ctx.RemoveRange(ctx.SeenDevices. - Where(d => d.Manufacturer == duplicate.Manufacturer && + ctx.RemoveRange(ctx.SeenDevices + .Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model && d.Revision == duplicate.Revision && - d.Bus == duplicate.Bus). - Skip(1)); + d.Bus == duplicate.Bus) + .Skip(1)); } // Remove nulls diff --git a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs index 589ed742d..3ae097c15 100644 --- a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs @@ -85,8 +85,7 @@ public sealed class ViewSectorViewModel : ViewModelBase ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out byte[] sector) : _inputFormat.ReadSector((ulong)SectorNumber, out sector); - if(errno == ErrorNumber.NoError) - PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS); + if(errno == ErrorNumber.NoError) PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS); } } diff --git a/Aaru.Gui/Views/Dialogs/About.xaml b/Aaru.Gui/Views/Dialogs/About.xaml index 824d41a87..89054b68c 100644 --- a/Aaru.Gui/Views/Dialogs/About.xaml +++ b/Aaru.Gui/Views/Dialogs/About.xaml @@ -31,12 +31,20 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Dialogs.About" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> @@ -49,20 +57,33 @@ - - + + - + - - + - + @@ -74,17 +95,31 @@ - - - - @@ -92,14 +127,19 @@ - + - + - + @@ -111,10 +151,13 @@ - + - diff --git a/Aaru.Gui/Views/Dialogs/About.xaml.cs b/Aaru.Gui/Views/Dialogs/About.xaml.cs index f0fc11a2b..11776f9e6 100644 --- a/Aaru.Gui/Views/Dialogs/About.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/About.xaml.cs @@ -41,9 +41,9 @@ public sealed class About : Window public About() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Dialogs/Console.xaml b/Aaru.Gui/Views/Dialogs/Console.xaml index f809db605..4e61b065f 100644 --- a/Aaru.Gui/Views/Dialogs/Console.xaml +++ b/Aaru.Gui/Views/Dialogs/Console.xaml @@ -31,12 +31,19 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="600" + Height="450" + x:Class="Aaru.Gui.Views.Dialogs.Console" + Icon="/Assets/aaru-logo.png" + Title="{Binding Title}"> @@ -47,20 +54,32 @@ - - - - - + - + diff --git a/Aaru.Gui/Views/Dialogs/Console.xaml.cs b/Aaru.Gui/Views/Dialogs/Console.xaml.cs index 09b7d87c9..0c602fac3 100644 --- a/Aaru.Gui/Views/Dialogs/Console.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/Console.xaml.cs @@ -41,9 +41,9 @@ public sealed class Console : Window public Console() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Dialogs/Encodings.xaml b/Aaru.Gui/Views/Dialogs/Encodings.xaml index a86ea2e11..0979f0753 100644 --- a/Aaru.Gui/Views/Dialogs/Encodings.xaml +++ b/Aaru.Gui/Views/Dialogs/Encodings.xaml @@ -31,30 +31,47 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Dialogs.Encodings" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> - + - + - - - - diff --git a/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs b/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs index 0166ad617..85dc5248a 100644 --- a/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs @@ -41,9 +41,9 @@ public sealed class Encodings : Window public Encodings() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml index cbe3bb6b1..ef64aa2eb 100644 --- a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml +++ b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml @@ -31,23 +31,37 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Dialogs.LicenseDialog" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> - + - - - diff --git a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs index 8358eab51..b066d369a 100644 --- a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs @@ -41,9 +41,9 @@ public sealed class LicenseDialog : Window public LicenseDialog() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml index 844c15d0e..ba0e04c8c 100644 --- a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml +++ b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml @@ -31,33 +31,53 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="600" + Height="450" + x:Class="Aaru.Gui.Views.Dialogs.PluginsDialog" + Icon="/Assets/aaru-logo.png" + Title="{Binding Title}" + Padding="10"> - + - + - + - - - - @@ -66,15 +86,24 @@ - + - - - - @@ -88,30 +117,53 @@ - - + + - - - - + - - + - - - - + @@ -126,30 +178,53 @@ - - + + - - - - + - - + - - - - + @@ -164,38 +239,64 @@ - - + + - - - - + - - + - - - - + - - diff --git a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs index a468c5da7..ea6d8054e 100644 --- a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs @@ -41,9 +41,9 @@ public sealed class PluginsDialog : Window public PluginsDialog() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml b/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml index 686cc4ace..2e0c5e75d 100644 --- a/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml +++ b/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml @@ -31,12 +31,20 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:dialogs="clr-namespace:Aaru.Gui.ViewModels.Dialogs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="675" + Height="432" + x:Class="Aaru.Gui.Views.Dialogs.SettingsDialog" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> @@ -45,7 +53,9 @@ - @@ -85,7 +95,8 @@ - + @@ -120,7 +131,10 @@ - diff --git a/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs index a12b04f56..8d9414678 100644 --- a/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs @@ -41,9 +41,9 @@ public sealed class StatisticsDialog : Window public StatisticsDialog() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Panels/DeviceInfo.xaml b/Aaru.Gui/Views/Panels/DeviceInfo.xaml index 18f9b7b35..8acc33f9a 100644 --- a/Aaru.Gui/Views/Panels/DeviceInfo.xaml +++ b/Aaru.Gui/Views/Panels/DeviceInfo.xaml @@ -31,11 +31,15 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:panels="clr-namespace:Aaru.Gui.ViewModels.Panels" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Panels.DeviceInfo"> @@ -49,31 +53,40 @@ - + - + - + + - + - + - + - + - + @@ -85,23 +98,28 @@ - + - + - + - + - + diff --git a/Aaru.Gui/Views/Panels/MediaInfo.xaml b/Aaru.Gui/Views/Panels/MediaInfo.xaml index 24b3e4c77..0b6247af8 100644 --- a/Aaru.Gui/Views/Panels/MediaInfo.xaml +++ b/Aaru.Gui/Views/Panels/MediaInfo.xaml @@ -31,17 +31,25 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:panels="clr-namespace:Aaru.Gui.ViewModels.Panels" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Panels.MediaInfo"> - - + + @@ -50,18 +58,23 @@ - + - - + + - + - - diff --git a/Aaru.Gui/Views/Panels/Partition.xaml b/Aaru.Gui/Views/Panels/Partition.xaml index d9daa3cb6..9f7e314bb 100644 --- a/Aaru.Gui/Views/Panels/Partition.xaml +++ b/Aaru.Gui/Views/Panels/Partition.xaml @@ -31,18 +31,25 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:panels="clr-namespace:Aaru.Gui.ViewModels.Panels" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Panels.Partition"> - - + + \ No newline at end of file diff --git a/Aaru.Gui/Views/Panels/Subdirectory.xaml b/Aaru.Gui/Views/Panels/Subdirectory.xaml index 34bdee671..b00786a60 100644 --- a/Aaru.Gui/Views/Panels/Subdirectory.xaml +++ b/Aaru.Gui/Views/Panels/Subdirectory.xaml @@ -31,15 +31,21 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:panels="clr-namespace:Aaru.Gui.ViewModels.Panels" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Panels.Subdirectory"> - + - - - - diff --git a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml index 85c1c9f79..cde72296b 100644 --- a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml +++ b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml @@ -31,11 +31,15 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:tabs="clr-namespace:Aaru.Gui.ViewModels.Tabs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Tabs.CompactDiscInfo"> @@ -45,7 +49,8 @@ - + @@ -56,7 +61,8 @@ - + @@ -67,7 +73,8 @@ - + @@ -78,7 +85,8 @@ - + @@ -89,7 +97,8 @@ - + @@ -100,7 +109,8 @@ - + @@ -111,19 +121,25 @@ - - + + + - - + + - diff --git a/Aaru.Gui/Views/Tabs/DvdInfo.xaml b/Aaru.Gui/Views/Tabs/DvdInfo.xaml index 4922bf0da..90453ca79 100644 --- a/Aaru.Gui/Views/Tabs/DvdInfo.xaml +++ b/Aaru.Gui/Views/Tabs/DvdInfo.xaml @@ -31,35 +31,51 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:tabs="clr-namespace:Aaru.Gui.ViewModels.Tabs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Tabs.DvdInfo"> - - - - - - - - - - diff --git a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml index 16f73f2dc..823e545e7 100644 --- a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml +++ b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml @@ -31,31 +31,42 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:tabs="clr-namespace:Aaru.Gui.ViewModels.Tabs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Tabs.DvdWritableInfo"> - - + + - - + - - - - - - - - - - diff --git a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml index 91682bb30..e6219cac0 100644 --- a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml +++ b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml @@ -31,22 +31,29 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:tabs="clr-namespace:Aaru.Gui.ViewModels.Tabs" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Tabs.PcmciaInfo"> - + - + - + diff --git a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml index 43c5c36d0..58639523a 100644 --- a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml +++ b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml @@ -31,19 +31,28 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:windows="clr-namespace:Aaru.Gui.ViewModels.Windows" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Windows.DecodeMediaTags" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> - + @@ -56,13 +65,15 @@ - + - + diff --git a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs index cc490eaae..74615177b 100644 --- a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs +++ b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs @@ -41,9 +41,9 @@ public sealed class DecodeMediaTags : Window public DecodeMediaTags() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ImageChecksum.xaml b/Aaru.Gui/Views/Windows/ImageChecksum.xaml index 0a48000c4..9f8407087 100644 --- a/Aaru.Gui/Views/Windows/ImageChecksum.xaml +++ b/Aaru.Gui/Views/Windows/ImageChecksum.xaml @@ -31,103 +31,138 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - - - - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - + + + - + - - + + - - + + - + - + - + - - - diff --git a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs index 4dbe4bcf3..9925d4a51 100644 --- a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs @@ -42,9 +42,9 @@ public sealed class ImageChecksum : Window public ImageChecksum() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ImageConvert.xaml b/Aaru.Gui/Views/Windows/ImageConvert.xaml index a3b803ed6..c375924c0 100644 --- a/Aaru.Gui/Views/Windows/ImageConvert.xaml +++ b/Aaru.Gui/Views/Windows/ImageConvert.xaml @@ -31,19 +31,27 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - - + + - @@ -52,15 +60,21 @@ - - - + - + @@ -68,7 +82,8 @@ - @@ -82,7 +97,8 @@ - @@ -96,7 +112,8 @@ - @@ -126,7 +143,9 @@ - + @@ -185,7 +207,8 @@ - @@ -193,7 +216,8 @@ - + - - diff --git a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs index c42be9f8c..7c69d6bc0 100644 --- a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs @@ -42,9 +42,9 @@ public sealed class ImageConvert : Window public ImageConvert() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ImageEntropy.xaml b/Aaru.Gui/Views/Windows/ImageEntropy.xaml index 47a55de54..b88787798 100644 --- a/Aaru.Gui/Views/Windows/ImageEntropy.xaml +++ b/Aaru.Gui/Views/Windows/ImageEntropy.xaml @@ -31,60 +31,85 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - - - + + - - - - - - - + + + + + - - - + + + - - + + - - + - - - - diff --git a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs index 56b313310..95a23637b 100644 --- a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs @@ -42,9 +42,9 @@ public sealed class ImageEntropy : Window public ImageEntropy() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ImageSidecar.xaml b/Aaru.Gui/Views/Windows/ImageSidecar.xaml index 20b9d26fb..30bf84279 100644 --- a/Aaru.Gui/Views/Windows/ImageSidecar.xaml +++ b/Aaru.Gui/Views/Windows/ImageSidecar.xaml @@ -31,44 +31,64 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:windows="clr-namespace:Aaru.Gui.ViewModels.Windows" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Windows.ImageSidecar" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> - - - - - + + + - - + - - - - diff --git a/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs b/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs index e150ae558..1497afe2e 100644 --- a/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs @@ -41,9 +41,9 @@ public sealed class ImageSidecar : Window public ImageSidecar() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ImageVerify.xaml b/Aaru.Gui/Views/Windows/ImageVerify.xaml index f792c7212..5ae356121 100644 --- a/Aaru.Gui/Views/Windows/ImageVerify.xaml +++ b/Aaru.Gui/Views/Windows/ImageVerify.xaml @@ -31,73 +31,97 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - - - + + - - + - + - + - + - + - - - + + + - + - - + - - - - diff --git a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs index 10778f761..a30833754 100644 --- a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs @@ -42,9 +42,9 @@ public sealed class ImageVerify : Window public ImageVerify() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/MainWindow.xaml b/Aaru.Gui/Views/Windows/MainWindow.xaml index 143086032..92b5f9443 100644 --- a/Aaru.Gui/Views/Windows/MainWindow.xaml +++ b/Aaru.Gui/Views/Windows/MainWindow.xaml @@ -31,37 +31,55 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:windows="clr-namespace:Aaru.Gui.ViewModels.Windows" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + x:Class="Aaru.Gui.Views.Windows.MainWindow" + Icon="/Assets/aaru-logo.png" + Title="Aaru.Gui"> - - + + - - - + + - + - - - + + + - @@ -69,9 +87,11 @@ - + - + @@ -79,18 +99,24 @@ Command="{Binding RefreshDevicesCommand}" /> - + - + - + - + @@ -115,51 +141,75 @@ Header="{Binding DecodeImageMediaTagsLabel}" /> - + - + - + - + - + - + - + - + - + - + - + - + - - + diff --git a/Aaru.Gui/Views/Windows/MainWindow.xaml.cs b/Aaru.Gui/Views/Windows/MainWindow.xaml.cs index 1896311fb..bc854dab5 100644 --- a/Aaru.Gui/Views/Windows/MainWindow.xaml.cs +++ b/Aaru.Gui/Views/Windows/MainWindow.xaml.cs @@ -43,9 +43,9 @@ public sealed class MainWindow : Window public MainWindow() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/MediaDump.xaml b/Aaru.Gui/Views/Windows/MediaDump.xaml index 24b963335..0a1ee306f 100644 --- a/Aaru.Gui/Views/Windows/MediaDump.xaml +++ b/Aaru.Gui/Views/Windows/MediaDump.xaml @@ -31,19 +31,26 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - - + - @@ -52,8 +59,10 @@ - - @@ -63,17 +72,24 @@ - + - + - + @@ -85,7 +101,8 @@ - @@ -96,30 +113,41 @@ - + - - + + + - - + - - - - diff --git a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs index 20662171f..5a3f49b26 100644 --- a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs @@ -42,9 +42,9 @@ public sealed class MediaDump : Window public MediaDump() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/MediaScan.xaml b/Aaru.Gui/Views/Windows/MediaScan.xaml index ce88efa87..3a119877e 100644 --- a/Aaru.Gui/Views/Windows/MediaScan.xaml +++ b/Aaru.Gui/Views/Windows/MediaScan.xaml @@ -31,12 +31,17 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + x:Class="Aaru.Gui.Views.Windows.MediaScan" + Icon="/Assets/aaru-logo.png" + Title="{Binding Title}"> @@ -49,11 +54,16 @@ - - - - - + + + + + @@ -85,21 +95,28 @@ --> - - + + - - - - diff --git a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs index 90c7ff0da..828c2315b 100644 --- a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs @@ -42,9 +42,9 @@ public sealed class MediaScan : Window public MediaScan() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/SplashWindow.xaml b/Aaru.Gui/Views/Windows/SplashWindow.xaml index 8b2f3b707..c0d14a281 100644 --- a/Aaru.Gui/Views/Windows/SplashWindow.xaml +++ b/Aaru.Gui/Views/Windows/SplashWindow.xaml @@ -31,11 +31,17 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - @@ -44,9 +50,19 @@ - - - + + + \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs b/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs index d87d338a5..b211a1ab7 100644 --- a/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs +++ b/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs @@ -43,9 +43,9 @@ public sealed class SplashWindow : Window public SplashWindow() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Gui/Views/Windows/ViewSector.xaml b/Aaru.Gui/Views/Windows/ViewSector.xaml index 0360db084..0c3b26144 100644 --- a/Aaru.Gui/Views/Windows/ViewSector.xaml +++ b/Aaru.Gui/Views/Windows/ViewSector.xaml @@ -31,12 +31,20 @@ // Copyright © 2011‐2023 Natalia Portillo // ****************************************************************************/ --> - + xmlns:windows="clr-namespace:Aaru.Gui.ViewModels.Windows" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" + Width="480" + Height="320" + x:Class="Aaru.Gui.Views.Windows.ViewSector" + Icon="/Assets/aaru-logo.png" + CanResize="False" + Title="{Binding Title}"> @@ -45,9 +53,11 @@ - + - + \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/ViewSector.xaml.cs b/Aaru.Gui/Views/Windows/ViewSector.xaml.cs index 8bc7fb65e..de7a9579c 100644 --- a/Aaru.Gui/Views/Windows/ViewSector.xaml.cs +++ b/Aaru.Gui/Views/Windows/ViewSector.xaml.cs @@ -41,9 +41,9 @@ public sealed class ViewSector : Window public ViewSector() { InitializeComponent(); - #if DEBUG +#if DEBUG this.AttachDevTools(); - #endif +#endif } void InitializeComponent() => AvaloniaXamlLoader.Load(this); diff --git a/Aaru.Helpers/ArrayFill.cs b/Aaru.Helpers/ArrayFill.cs index cbac721e8..70645f324 100644 --- a/Aaru.Helpers/ArrayFill.cs +++ b/Aaru.Helpers/ArrayFill.cs @@ -35,10 +35,11 @@ public static partial class ArrayHelpers /// Array /// Value /// Array type - public static void ArrayFill(T[] destinationArray, T value) => ArrayFill(destinationArray, new[] - { - value - }); + public static void ArrayFill(T[] destinationArray, T value) => ArrayFill(destinationArray, + new[] + { + value + }); /// Fills an array with the contents of the specified array /// Array @@ -71,8 +72,7 @@ public static partial class ArrayHelpers { var sb = new StringBuilder(); - for(long i = 0; i < array.LongLength; i++) - sb.Append($"{array[i]:x2}"); + for(long i = 0; i < array.LongLength; i++) sb.Append($"{array[i]:x2}"); return upper ? sb.ToString().ToUpper() : sb.ToString(); } diff --git a/Aaru.Helpers/BigEndianBitConverter.cs b/Aaru.Helpers/BigEndianBitConverter.cs index cb1225bea..c387e5e55 100644 --- a/Aaru.Helpers/BigEndianBitConverter.cs +++ b/Aaru.Helpers/BigEndianBitConverter.cs @@ -315,9 +315,12 @@ public static class BigEndianBitConverter public static Guid ToGuid(byte[] value, int startIndex) => new(ToUInt32(value, 0 + startIndex), ToUInt16(value, 4 + startIndex), ToUInt16(value, 6 + startIndex), - value[8 + startIndex + 0], value[8 + startIndex + 1], - value[8 + startIndex + 2], value[8 + startIndex + 3], - value[8 + startIndex + 5], value[8 + startIndex + 5], - value[8 + startIndex + 6], - value[8 + startIndex + 7]); + value[8 + startIndex + 0], + value[8 + startIndex + 1], + value[8 + startIndex + 2], + value[8 + startIndex + 3], + value[8 + startIndex + 5], + value[8 + startIndex + 5], + value[8 + startIndex + 6], + value[8 + startIndex + 7]); } \ No newline at end of file diff --git a/Aaru.Helpers/CompareBytes.cs b/Aaru.Helpers/CompareBytes.cs index a06aaed9f..970757ada 100644 --- a/Aaru.Helpers/CompareBytes.cs +++ b/Aaru.Helpers/CompareBytes.cs @@ -61,8 +61,7 @@ public static partial class ArrayHelpers for(long i = 0; i < leastBytes; i++) { - if(compareArray1[i] == compareArray2[i]) - continue; + if(compareArray1[i] == compareArray2[i]) continue; different = true; diff --git a/Aaru.Helpers/DateHandlers.cs b/Aaru.Helpers/DateHandlers.cs index ba80926df..12e2c8236 100644 --- a/Aaru.Helpers/DateHandlers.cs +++ b/Aaru.Helpers/DateHandlers.cs @@ -111,69 +111,75 @@ public static class DateHandlers fourCharValue[2] = vdDateTime[2]; fourCharValue[3] = vdDateTime[3]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "year = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "year = \"{0}\"", StringHandlers.CToString(fourCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(fourCharValue, Encoding.ASCII), out int year)) - year = 0; + if(!int.TryParse(StringHandlers.CToString(fourCharValue, Encoding.ASCII), out int year)) year = 0; twoCharValue[0] = vdDateTime[4]; twoCharValue[1] = vdDateTime[5]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "month = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "month = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int month)) - month = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int month)) month = 0; twoCharValue[0] = vdDateTime[6]; twoCharValue[1] = vdDateTime[7]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "day = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "day = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) - day = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) day = 0; twoCharValue[0] = vdDateTime[8]; twoCharValue[1] = vdDateTime[9]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "hour = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "hour = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hour)) - hour = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hour)) hour = 0; twoCharValue[0] = vdDateTime[10]; twoCharValue[1] = vdDateTime[11]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "minute = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "minute = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int minute)) - minute = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int minute)) minute = 0; twoCharValue[0] = vdDateTime[12]; twoCharValue[1] = vdDateTime[13]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "second = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "second = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int second)) - second = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int second)) second = 0; twoCharValue[0] = vdDateTime[14]; twoCharValue[1] = vdDateTime[15]; - AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "hundredths = \"{0}\"", + AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, + "hundredths = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII)); - if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hundredths)) - hundredths = 0; + if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hundredths)) hundredths = 0; AaruConsole.DebugWriteLine(ISO9660_MODULE_NAME, "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", - year, month, day, hour, minute, second, hundredths * 10); + year, + month, + day, + hour, + minute, + second, + hundredths * 10); var difference = (sbyte)vdDateTime[16]; @@ -215,8 +221,12 @@ public static class DateHandlers int day = (dateRecord & 0x01F0) >> 4; int month = dateRecord & 0x000F; - AaruConsole.DebugWriteLine(PASCAL_MODULE_NAME, "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", - dateRecord, year, month, day); + AaruConsole.DebugWriteLine(PASCAL_MODULE_NAME, + "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", + dateRecord, + year, + month, + day); return new DateTime(year, month, day); } @@ -234,11 +244,19 @@ public static class DateHandlers int minute = (time & 0x7E0) >> 5; int second = (time & 0x1F) * 2; - AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", date, year, - month, day); + AaruConsole.DebugWriteLine(DOS_MODULE_NAME, + "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", + date, + year, + month, + day); - AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", time, - hour, minute, second); + AaruConsole.DebugWriteLine(DOS_MODULE_NAME, + "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", + time, + hour, + minute, + second); DateTime dosDate; @@ -311,8 +329,8 @@ public static class DateHandlers break; } - return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)).AddTicks(ticks). - DateTime; + return new DateTimeOffset(year, month, day, hour, minute, second, new TimeSpan(0, offset, 0)).AddTicks(ticks) + .DateTime; } /// Converts a Solaris high resolution timestamp to .NET DateTime @@ -325,8 +343,7 @@ public static class DateHandlers /// .NET DateTime public static DateTime Os9ToDateTime(byte[] date) { - if(date == null || date.Length != 3 && date.Length != 5) - return DateTime.MinValue; + if(date == null || date.Length != 3 && date.Length != 5) return DateTime.MinValue; DateTime os9Date; @@ -349,8 +366,12 @@ public static class DateHandlers /// .NET DateTime public static DateTime LifToDateTime(byte[] date) => date is not { Length: 6 } ? new DateTime(1970, 1, 1, 0, 0, 0) - : LifToDateTime(date[0], date[1], date[2], date[3], - date[4], date[5]); + : LifToDateTime(date[0], + date[1], + date[2], + date[3], + date[4], + date[5]); /// Converts a LIF timestamp to .NET DateTime /// Yer diff --git a/Aaru.Helpers/IO/ForcedSeekStream.cs b/Aaru.Helpers/IO/ForcedSeekStream.cs index fd48c2f49..bf764106e 100644 --- a/Aaru.Helpers/IO/ForcedSeekStream.cs +++ b/Aaru.Helpers/IO/ForcedSeekStream.cs @@ -59,8 +59,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream _backFile = Path.GetTempFileName(); _backStream = new FileStream(_backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None); - if(length == 0) - CalculateLength(); + if(length == 0) CalculateLength(); } /// Initializes a new instance of the class. @@ -116,8 +115,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream void SetPosition(long position) { - if(position == _backStream.Position) - return; + if(position == _backStream.Position) return; if(position < _backStream.Length) { @@ -126,8 +124,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream return; } - if(position > _streamLength) - position = _streamLength; + if(position > _streamLength) position = _streamLength; _backStream.Position = _backStream.Length; long toPosition = position - _backStream.Position; @@ -177,11 +174,9 @@ public sealed class ForcedSeekStream : Stream where T : Stream /// public override int Read(byte[] buffer, int offset, int count) { - if(_backStream.Position + count > _streamLength) - count = (int)(_streamLength - _backStream.Position); + if(_backStream.Position + count > _streamLength) count = (int)(_streamLength - _backStream.Position); - if(_backStream.Position + count <= _backStream.Length) - return _backStream.EnsureRead(buffer, offset, count); + if(_backStream.Position + count <= _backStream.Length) return _backStream.EnsureRead(buffer, offset, count); long oldPosition = _backStream.Position; SetPosition(_backStream.Position + count); @@ -193,11 +188,9 @@ public sealed class ForcedSeekStream : Stream where T : Stream /// public override int ReadByte() { - if(_backStream.Position + 1 > _streamLength) - return -1; + if(_backStream.Position + 1 > _streamLength) return -1; - if(_backStream.Position + 1 <= _backStream.Length) - return _backStream.ReadByte(); + if(_backStream.Position + 1 <= _backStream.Length) return _backStream.ReadByte(); SetPosition(_backStream.Position + 1); SetPosition(_backStream.Position - 1); @@ -211,18 +204,15 @@ public sealed class ForcedSeekStream : Stream where T : Stream switch(origin) { case SeekOrigin.Begin: - if(offset < 0) - throw new IOException(Localization.Cannot_seek_before_stream_start); + if(offset < 0) throw new IOException(Localization.Cannot_seek_before_stream_start); SetPosition(offset); break; case SeekOrigin.End: - if(offset > 0) - throw new IOException(Localization.Cannot_seek_after_stream_end); + if(offset > 0) throw new IOException(Localization.Cannot_seek_after_stream_end); - if(_streamLength == 0) - CalculateLength(); + if(_streamLength == 0) CalculateLength(); SetPosition(_streamLength + offset); diff --git a/Aaru.Helpers/IO/OffsetStream.cs b/Aaru.Helpers/IO/OffsetStream.cs index 07fa54a2e..772d46a7e 100644 --- a/Aaru.Helpers/IO/OffsetStream.cs +++ b/Aaru.Helpers/IO/OffsetStream.cs @@ -63,8 +63,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -106,8 +105,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -138,8 +136,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -174,8 +171,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -211,8 +207,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -254,8 +249,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -296,8 +290,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -333,8 +326,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -366,8 +358,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -395,8 +386,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -427,8 +417,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -458,8 +447,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -488,8 +476,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -517,8 +504,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -545,8 +531,7 @@ public sealed class OffsetStream : Stream if(start < 0) throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number); - if(end < 0) - throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); + if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number); _streamStart = start; _streamEnd = end; @@ -594,8 +579,7 @@ public sealed class OffsetStream : Stream /// public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - if(_baseStream.Position + count > _streamEnd) - count = (int)(_streamEnd - _baseStream.Position); + if(_baseStream.Position + count > _streamEnd) count = (int)(_streamEnd - _baseStream.Position); return _baseStream.BeginRead(buffer, offset, count, callback, state); } @@ -603,8 +587,7 @@ public sealed class OffsetStream : Stream /// public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - if(_baseStream.Position + count > _streamEnd) - throw new IOException(Localization.Cannot_write_past_stream_end); + if(_baseStream.Position + count > _streamEnd) throw new IOException(Localization.Cannot_write_past_stream_end); return _baseStream.BeginWrite(buffer, offset, count, callback, state); } @@ -624,8 +607,7 @@ public sealed class OffsetStream : Stream /// public override void WriteByte(byte value) { - if(_baseStream.Position + 1 > _streamEnd) - throw new IOException(Localization.Cannot_write_past_stream_end); + if(_baseStream.Position + 1 > _streamEnd) throw new IOException(Localization.Cannot_write_past_stream_end); _baseStream.WriteByte(value); } @@ -636,8 +618,7 @@ public sealed class OffsetStream : Stream /// public override int Read(byte[] buffer, int offset, int count) { - if(_baseStream.Position + count > _streamEnd + 1) - count = (int)(_streamEnd - _baseStream.Position); + if(_baseStream.Position + count > _streamEnd + 1) count = (int)(_streamEnd - _baseStream.Position); return _baseStream.EnsureRead(buffer, offset, count); } @@ -648,8 +629,7 @@ public sealed class OffsetStream : Stream switch(origin) { case SeekOrigin.Begin: - if(offset + _streamStart > _streamEnd) - throw new IOException(Localization.Cannot_seek_after_stream_end); + if(offset + _streamStart > _streamEnd) throw new IOException(Localization.Cannot_seek_after_stream_end); return _baseStream.Seek(offset + _streamStart, SeekOrigin.Begin) - _streamStart; case SeekOrigin.End: @@ -672,8 +652,7 @@ public sealed class OffsetStream : Stream /// public override void Write(byte[] buffer, int offset, int count) { - if(_baseStream.Position + count > _streamEnd) - throw new IOException(Localization.Cannot_write_past_stream_end); + if(_baseStream.Position + count > _streamEnd) throw new IOException(Localization.Cannot_write_past_stream_end); _baseStream.Write(buffer, offset, count); } diff --git a/Aaru.Helpers/IO/SplitJoinStream.cs b/Aaru.Helpers/IO/SplitJoinStream.cs index 34981ec06..bcf1e78e0 100644 --- a/Aaru.Helpers/IO/SplitJoinStream.cs +++ b/Aaru.Helpers/IO/SplitJoinStream.cs @@ -44,8 +44,7 @@ public class SplitJoinStream : Stream set { - if(value >= _streamLength) - throw new IOException(Localization.Cannot_set_position_past_stream_end); + if(value >= _streamLength) throw new IOException(Localization.Cannot_set_position_past_stream_end); _position = value; } @@ -56,11 +55,9 @@ public class SplitJoinStream : Stream /// The specified stream is non-readable or non-seekable public void Add(Stream stream) { - if(!stream.CanSeek) - throw new ArgumentException(Localization.Non_seekable_streams_are_not_supported); + if(!stream.CanSeek) throw new ArgumentException(Localization.Non_seekable_streams_are_not_supported); - if(!stream.CanRead) - throw new ArgumentException(Localization.Non_readable_streams_are_not_supported); + if(!stream.CanRead) throw new ArgumentException(Localization.Non_readable_streams_are_not_supported); _baseStreams[_streamLength] = stream; _streamLength += stream.Length; @@ -232,8 +229,7 @@ public class SplitJoinStream : Stream { string filePath = Path.Combine(basePath, string.Format(counterFormat, counterStart)); - if(!File.Exists(filePath)) - break; + if(!File.Exists(filePath)) break; Add(filePath, FileMode.Open, access); @@ -266,8 +262,7 @@ public class SplitJoinStream : Stream /// public override void Close() { - foreach(Stream stream in _baseStreams.Values) - stream.Close(); + foreach(Stream stream in _baseStreams.Values) stream.Close(); _baseStreams.Clear(); _position = 0; @@ -284,13 +279,11 @@ public class SplitJoinStream : Stream /// public override int ReadByte() { - if(_position >= _streamLength) - return -1; + if(_position >= _streamLength) return -1; KeyValuePair baseStream = _baseStreams.FirstOrDefault(s => s.Key >= _position); - if(baseStream.Value == null) - return -1; + if(baseStream.Value == null) return -1; baseStream.Value.Position = _position - baseStream.Key; _position++; @@ -313,8 +306,7 @@ public class SplitJoinStream : Stream { KeyValuePair baseStream = _baseStreams.LastOrDefault(s => s.Key <= _position); - if(baseStream.Value == null) - break; + if(baseStream.Value == null) break; baseStream.Value.Position = _position - baseStream.Key; @@ -338,15 +330,13 @@ public class SplitJoinStream : Stream switch(origin) { case SeekOrigin.Begin: - if(offset >= _streamLength) - throw new IOException(Localization.Cannot_seek_after_stream_end); + if(offset >= _streamLength) throw new IOException(Localization.Cannot_seek_after_stream_end); _position = offset; break; case SeekOrigin.End: - if(_position - offset < 0) - throw new IOException(Localization.Cannot_seek_before_stream_start); + if(_position - offset < 0) throw new IOException(Localization.Cannot_seek_before_stream_start); _position -= offset; diff --git a/Aaru.Helpers/Marshal.cs b/Aaru.Helpers/Marshal.cs index 738c75f7c..5754f77bc 100644 --- a/Aaru.Helpers/Marshal.cs +++ b/Aaru.Helpers/Marshal.cs @@ -328,20 +328,25 @@ public static class Marshal var flt = (float)(fi.GetValue(str) ?? default(float)); byte[] flt_b = BitConverter.GetBytes(flt); - fi.SetValue(str, BitConverter.ToSingle(new[] - { - flt_b[3], flt_b[2], flt_b[1], flt_b[0] - }, 0)); + fi.SetValue(str, + BitConverter.ToSingle(new[] + { + flt_b[3], flt_b[2], flt_b[1], flt_b[0] + }, + 0)); } else if(fi.FieldType == typeof(double)) { var dbl = (double)(fi.GetValue(str) ?? default(double)); byte[] dbl_b = BitConverter.GetBytes(dbl); - fi.SetValue(str, BitConverter.ToDouble(new[] - { - dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0] - }, 0)); + fi.SetValue(str, + BitConverter.ToDouble(new[] + { + dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], + dbl_b[1], dbl_b[0] + }, + 0)); } else if(fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte)) { @@ -443,13 +448,11 @@ public static class Marshal { outBuf = null; - if(hex is null or "") - return -1; + if(hex is null or "") return -1; var off = 0; - if(hex[0] == '0' && (hex[1] == 'x' || hex[1] == 'X')) - off = 2; + if(hex[0] == '0' && (hex[1] == 'x' || hex[1] == 'X')) off = 2; outBuf = new byte[(hex.Length - off) / 2]; var count = 0; @@ -458,8 +461,7 @@ public static class Marshal { char c = hex[i]; - if(c is < '0' or > '9' and < 'A' or > 'F' and < 'a' or > 'f') - break; + if(c is < '0' or > '9' and < 'A' or > 'F' and < 'a' or > 'f') break; c -= c switch { @@ -472,8 +474,7 @@ public static class Marshal c = hex[i + 1]; - if(c is < '0' or > '9' and < 'A' or > 'F' and < 'a' or > 'f') - break; + if(c is < '0' or > '9' and < 'A' or > 'F' and < 'a' or > 'f') break; c -= c switch { diff --git a/Aaru.Helpers/PrintHex.cs b/Aaru.Helpers/PrintHex.cs index 0f3c92b87..525ecf086 100644 --- a/Aaru.Helpers/PrintHex.cs +++ b/Aaru.Helpers/PrintHex.cs @@ -51,8 +51,7 @@ public static class PrintHex /// String containing hexadecimal values public static string ByteArrayToHexArrayString(byte[] array, int width = 16, bool color = false) { - if(array is null) - return null; + if(array is null) return null; // TODO: Color list // TODO: Allow to change width @@ -74,23 +73,18 @@ public static class PrintHex break; } - if(offsetLength < str.Length) - offsetLength = str.Length; + if(offsetLength < str.Length) offsetLength = str.Length; - while(str.Length < offsetLength) - str += ' '; + while(str.Length < offsetLength) str += ' '; - if(color) - sb.Append("\u001b[36m"); + if(color) sb.Append("\u001b[36m"); sb.Append(str); sb.Append(" "); - for(var i = 0; i < width; i++) - sb.Append($" {i:X2}"); + for(var i = 0; i < width; i++) sb.Append($" {i:X2}"); - if(color) - sb.Append("\u001b[0m"); + if(color) sb.Append("\u001b[0m"); sb.AppendLine(); @@ -100,13 +94,11 @@ public static class PrintHex for(var i = 0; i < rows; i++) { - if(color) - sb.Append("\u001b[36m"); + if(color) sb.Append("\u001b[36m"); sb.AppendFormat(format, b); - if(color) - sb.Append("\u001b[0m"); + if(color) sb.Append("\u001b[0m"); sb.Append(" "); int lastBytes = i == rows - 1 ? last : width; @@ -118,8 +110,7 @@ public static class PrintHex b++; } - for(var j = 0; j < lastSpaces; j++) - sb.Append(" "); + for(var j = 0; j < lastSpaces; j++) sb.Append(" "); b -= lastBytes; sb.Append(" "); diff --git a/Aaru.Helpers/StringHandlers.cs b/Aaru.Helpers/StringHandlers.cs index 07348633b..ee11aa387 100644 --- a/Aaru.Helpers/StringHandlers.cs +++ b/Aaru.Helpers/StringHandlers.cs @@ -53,8 +53,7 @@ public static class StringHandlers /// Start decoding at this position public static string CToString(byte[] cString, Encoding encoding, bool twoBytes = false, int start = 0) { - if(cString == null) - return null; + if(cString == null) return null; var len = 0; @@ -78,8 +77,7 @@ public static class StringHandlers len++; } - if(twoBytes && len % 2 > 0) - len--; + if(twoBytes && len % 2 > 0) len--; var dest = new byte[len]; Array.Copy(cString, start, dest, 0, len); @@ -99,16 +97,14 @@ public static class StringHandlers /// Start decoding at this position public static string PascalToString(byte[] pascalString, Encoding encoding, int start = 0) { - if(pascalString == null) - return null; + if(pascalString == null) return null; byte length = pascalString[start]; var len = 0; for(int i = start + 1; i < length + 1 && i < pascalString.Length; i++) { - if(pascalString[i] == 0) - break; + if(pascalString[i] == 0) break; len++; } @@ -132,18 +128,15 @@ public static class StringHandlers /// Start decoding at this position public static string SpacePaddedToString(byte[] spacePaddedString, Encoding encoding, int start = 0) { - if(spacePaddedString == null) - return null; + if(spacePaddedString == null) return null; int len = start; for(int i = spacePaddedString.Length; i >= start; i--) { - if(i == start) - return ""; + if(i == start) return ""; - if(spacePaddedString[i - 1] == 0x20) - continue; + if(spacePaddedString[i - 1] == 0x20) continue; len = i; @@ -161,8 +154,7 @@ public static class StringHandlers byte compId = dstring[0]; var temp = ""; - if(compId != 8 && compId != 16) - return null; + if(compId != 8 && compId != 16) return null; for(var byteIndex = 1; byteIndex < dstring.Length;) { @@ -173,11 +165,9 @@ public static class StringHandlers else unicode = 0; - if(byteIndex < dstring.Length) - unicode |= dstring[byteIndex++]; + if(byteIndex < dstring.Length) unicode |= dstring[byteIndex++]; - if(unicode == 0) - break; + if(unicode == 0) break; temp += Encoding.Unicode.GetString(BitConverter.GetBytes(unicode)); } diff --git a/Aaru.Images/A2R/A2R.cs b/Aaru.Images/A2R/A2R.cs index eac58366d..5af2e77a5 100644 --- a/Aaru.Images/A2R/A2R.cs +++ b/Aaru.Images/A2R/A2R.cs @@ -65,28 +65,27 @@ public sealed partial class A2R : IFluxImage, IMediaImage, IWritableImage, IWrit Dictionary _meta; FileStream _writingStream; - public A2R() => - _imageInfo = new ImageInfo - { - ReadableSectorTags = new List(), - ReadableMediaTags = new List(), - HasPartitions = false, - HasSessions = false, - Version = null, - Application = null, - ApplicationVersion = null, - Creator = null, - Comments = null, - MediaManufacturer = null, - MediaModel = null, - MediaSerialNumber = null, - MediaBarcode = null, - MediaPartNumber = null, - MediaSequence = 0, - LastMediaSequence = 0, - DriveManufacturer = null, - DriveModel = null, - DriveSerialNumber = null, - DriveFirmwareRevision = null - }; + public A2R() => _imageInfo = new ImageInfo + { + ReadableSectorTags = new List(), + ReadableMediaTags = new List(), + HasPartitions = false, + HasSessions = false, + Version = null, + Application = null, + ApplicationVersion = null, + Creator = null, + Comments = null, + MediaManufacturer = null, + MediaModel = null, + MediaSerialNumber = null, + MediaBarcode = null, + MediaPartNumber = null, + MediaSequence = 0, + LastMediaSequence = 0, + DriveManufacturer = null, + DriveModel = null, + DriveSerialNumber = null, + DriveFirmwareRevision = null + }; } \ No newline at end of file diff --git a/Aaru.Images/A2R/Helpers.cs b/Aaru.Images/A2R/Helpers.cs index 3eb0a95df..6d6a63c7b 100644 --- a/Aaru.Images/A2R/Helpers.cs +++ b/Aaru.Images/A2R/Helpers.cs @@ -52,8 +52,7 @@ public sealed partial class A2R /// A2R format location static long HeadTrackSubToA2RLocation(uint head, ushort track, byte subTrack, MediaType mediaType) { - if(mediaType == MediaType.Apple32SS) - return head + track * 4 + subTrack; + if(mediaType == MediaType.Apple32SS) return head + track * 4 + subTrack; return head + track * 2; } @@ -69,8 +68,7 @@ public sealed partial class A2R /// A2R format location static long HeadTrackSubToA2RLocation(uint head, ushort track, byte subTrack, A2rDriveType driveType) { - if(driveType == A2rDriveType.SS_525_40trk_quarterStep) - return head + track * 4 + subTrack; + if(driveType == A2rDriveType.SS_525_40trk_quarterStep) return head + track * 4 + subTrack; return head + track * 2; } diff --git a/Aaru.Images/A2R/Identify.cs b/Aaru.Images/A2R/Identify.cs index 921a18449..75ba68d72 100644 --- a/Aaru.Images/A2R/Identify.cs +++ b/Aaru.Images/A2R/Identify.cs @@ -49,8 +49,7 @@ public sealed partial class A2R Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 8) - return false; + if(stream.Length < 8) return false; var hdr = new byte[4]; diff --git a/Aaru.Images/A2R/Properties.cs b/Aaru.Images/A2R/Properties.cs index 702e4e6e8..5dcaf7337 100644 --- a/Aaru.Images/A2R/Properties.cs +++ b/Aaru.Images/A2R/Properties.cs @@ -48,6 +48,7 @@ public sealed partial class A2R #region IFluxImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/A2R/Read.cs b/Aaru.Images/A2R/Read.cs index 3b3c3f37b..c4abfcc8b 100644 --- a/Aaru.Images/A2R/Read.cs +++ b/Aaru.Images/A2R/Read.cs @@ -62,21 +62,24 @@ public sealed partial class A2R _header = Marshal.ByteArrayToStructureLittleEndian(hdr); - AaruConsole.DebugWriteLine(MODULE_NAME, "header.signature = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "header.signature = \"{0}\"", StringHandlers.CToString(_header.signature)); AaruConsole.DebugWriteLine(MODULE_NAME, "header.version = {0}", _header.version); AaruConsole.DebugWriteLine(MODULE_NAME, "header.highBitTest = {0:X2}", _header.highBitTest); - AaruConsole.DebugWriteLine(MODULE_NAME, "header.lineTest = {0:X2} {1:X2} {2:X2}", _header.lineTest[0], - _header.lineTest[1], _header.lineTest[2]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "header.lineTest = {0:X2} {1:X2} {2:X2}", + _header.lineTest[0], + _header.lineTest[1], + _header.lineTest[2]); var infoMagic = new byte[4]; _a2RStream.EnsureRead(infoMagic, 0, 4); // There must be an INFO chunk after the header (at byte 16) - if(!_infoChunkSignature.SequenceEqual(infoMagic)) - return ErrorNumber.UnrecognizedFormat; + if(!_infoChunkSignature.SequenceEqual(infoMagic)) return ErrorNumber.UnrecognizedFormat; _a2RStream.Seek(-4, SeekOrigin.Current); @@ -88,15 +91,18 @@ public sealed partial class A2R _a2RStream.EnsureRead(infoChnk, 0, Marshal.SizeOf()); _infoChunkV2 = Marshal.ByteArrayToStructureLittleEndian(infoChnk); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.header.chunkId = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.header.chunkId = \"{0}\"", StringHandlers.CToString(_infoChunkV2.header.chunkId)); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.header.chunkSize = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.header.chunkSize = {0}", _infoChunkV2.header.chunkSize); AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.version = {0}", _infoChunkV2.version); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.creator = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.creator = \"{0}\"", StringHandlers.CToString(_infoChunkV2.creator).TrimEnd()); AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.diskType = {0}", _infoChunkV2.diskType); @@ -134,15 +140,18 @@ public sealed partial class A2R _a2RStream.EnsureRead(infoChk, 0, Marshal.SizeOf()); _infoChunkV3 = Marshal.ByteArrayToStructureLittleEndian(infoChk); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.header.chunkId = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.header.chunkId = \"{0}\"", StringHandlers.CToString(_infoChunkV3.header.chunkId)); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.header.chunkSize = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.header.chunkSize = {0}", _infoChunkV3.header.chunkSize); AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.version = {0}", _infoChunkV3.version); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.creator = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.creator = \"{0}\"", StringHandlers.CToString(_infoChunkV3.creator).TrimEnd()); AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.driveType = {0}", _infoChunkV3.driveType); @@ -151,7 +160,8 @@ public sealed partial class A2R AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.synchronized = {0}", _infoChunkV3.synchronized); - AaruConsole.DebugWriteLine(MODULE_NAME, "infoChunk.hardSectorCount = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "infoChunk.hardSectorCount = {0}", _infoChunkV3.hardSectorCount); _imageInfo.Creator = Encoding.ASCII.GetString(_infoChunkV3.creator).TrimEnd(); @@ -232,14 +242,15 @@ public sealed partial class A2R _a2RStream.EnsureRead(location, 0, 2); capture.location = BitConverter.ToUInt16(location); - A2RLocationToHeadTrackSub(capture.location, _imageInfo.MediaType, out capture.head, - out capture.track, out capture.subTrack); + A2RLocationToHeadTrackSub(capture.location, + _imageInfo.MediaType, + out capture.head, + out capture.track, + out capture.subTrack); - if(capture.head + 1 > _imageInfo.Heads) - _imageInfo.Heads = capture.head + 1; + if(capture.head + 1 > _imageInfo.Heads) _imageInfo.Heads = capture.head + 1; - if(capture.track + 1 > _imageInfo.Cylinders) - _imageInfo.Cylinders = (uint)(capture.track + 1); + if(capture.track + 1 > _imageInfo.Cylinders) _imageInfo.Cylinders = (uint)(capture.track + 1); capture.numberOfIndexSignals = (byte)_a2RStream.ReadByte(); capture.indexSignals = new uint[capture.numberOfIndexSignals]; @@ -277,15 +288,14 @@ public sealed partial class A2R string[] metaFields = metaData.Split('\n'); - foreach(string[] keyValue in metaFields.Select(field => field.Split('\t')). - Where(keyValue => keyValue.Length == 2)) + foreach(string[] keyValue in metaFields.Select(field => field.Split('\t')) + .Where(keyValue => keyValue.Length == 2)) _meta.Add(keyValue[0], keyValue[1]); if(_meta.TryGetValue("image_date", out string imageDate)) _imageInfo.CreationTime = DateTime.Parse(imageDate); - if(_meta.TryGetValue("title", out string title)) - _imageInfo.MediaTitle = title; + if(_meta.TryGetValue("title", out string title)) _imageInfo.MediaTitle = title; break; case var slvd when slvd.SequenceEqual(_slvdChunkSignature): @@ -308,14 +318,15 @@ public sealed partial class A2R numberOfIndexSignals = 1 }; - A2RLocationToHeadTrackSub(capture.location, _imageInfo.MediaType, out capture.head, - out capture.track, out capture.subTrack); + A2RLocationToHeadTrackSub(capture.location, + _imageInfo.MediaType, + out capture.head, + out capture.track, + out capture.subTrack); - if(capture.head + 1 > _imageInfo.Heads) - _imageInfo.Heads = capture.head + 1; + if(capture.head + 1 > _imageInfo.Heads) _imageInfo.Heads = capture.head + 1; - if(capture.track + 1 > _imageInfo.Cylinders) - _imageInfo.Cylinders = (uint)(capture.track + 1); + if(capture.track + 1 > _imageInfo.Cylinders) _imageInfo.Cylinders = (uint)(capture.track + 1); var dataSize = new byte[4]; _a2RStream.EnsureRead(dataSize, 0, 4); @@ -388,13 +399,11 @@ public sealed partial class A2R ErrorNumber error = ReadFluxResolution(head, track, subTrack, captureIndex, out indexResolution, out dataResolution); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; error = ReadFluxDataCapture(head, track, subTrack, captureIndex, out dataBuffer); - if(error != ErrorNumber.NoError) - return error; + if(error != ErrorNumber.NoError) return error; error = ReadFluxIndexCapture(head, track, subTrack, captureIndex, out indexBuffer); @@ -437,8 +446,7 @@ public sealed partial class A2R StreamCapture capture = StreamCaptureAtIndex(head, track, subTrack, captureIndex); - if(capture.captureType == 2) - return ErrorNumber.NotImplemented; + if(capture.captureType == 2) return ErrorNumber.NotImplemented; Stream stream = _a2RFilter.GetDataForkStream(); var br = new BinaryReader(stream); @@ -456,8 +464,7 @@ public sealed partial class A2R List captures = _a2RCaptures.FindAll(c => c.head == head && c.track == track); - if(captures.Count <= 0) - return ErrorNumber.OutOfRange; + if(captures.Count <= 0) return ErrorNumber.OutOfRange; length = (byte)(captures.Max(static c => c.subTrack) + 1); diff --git a/Aaru.Images/A2R/Write.cs b/Aaru.Images/A2R/Write.cs index dd01c5aa8..a6dc03802 100644 --- a/Aaru.Images/A2R/Write.cs +++ b/Aaru.Images/A2R/Write.cs @@ -87,14 +87,16 @@ public sealed partial class A2R _writingStream.WriteByte(IsCaptureTypeTiming(dataResolution, dataBuffer) ? (byte)1 : (byte)3); - _writingStream. - Write(BitConverter.GetBytes((ushort)HeadTrackSubToA2RLocation(head, track, subTrack, _infoChunkV3.driveType)), - 0, 2); + _writingStream.Write(BitConverter.GetBytes((ushort)HeadTrackSubToA2RLocation(head, + track, + subTrack, + _infoChunkV3.driveType)), + 0, + 2); List a2RIndices = FluxRepresentationsToUInt32List(indexBuffer); - if(a2RIndices[0] == 0) - a2RIndices.RemoveAt(0); + if(a2RIndices[0] == 0) a2RIndices.RemoveAt(0); _writingStream.WriteByte((byte)a2RIndices.Count); @@ -321,8 +323,8 @@ public sealed partial class A2R _writingStream.Write(_metaChunkSignature, 0, 4); - byte[] metaString = Encoding.UTF8.GetBytes(_meta.Select(static m => $"{m.Key}\t{m.Value}"). - Aggregate(static (concat, str) => $"{concat}\n{str}") + + byte[] metaString = Encoding.UTF8.GetBytes(_meta.Select(static m => $"{m.Key}\t{m.Value}") + .Aggregate(static (concat, str) => $"{concat}\n{str}") + '\n'); _writingStream.Write(BitConverter.GetBytes((uint)metaString.Length), 0, 4); diff --git a/Aaru.Images/AaruFormat/CdEcc.cs b/Aaru.Images/AaruFormat/CdEcc.cs index 8117dfccf..670a5aac1 100644 --- a/Aaru.Images/AaruFormat/CdEcc.cs +++ b/Aaru.Images/AaruFormat/CdEcc.cs @@ -45,8 +45,7 @@ public sealed partial class AaruFormat void EccInit() { - if(_initedEdc) - return; + if(_initedEdc) return; _eccFTable = new byte[256]; _eccBTable = new byte[256]; @@ -59,8 +58,7 @@ public sealed partial class AaruFormat _eccFTable[i] = (byte)j; _eccBTable[i ^ j] = (byte)i; - for(j = 0; j < 8; j++) - edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); + for(j = 0; j < 8; j++) edc = edc >> 1 ^ ((edc & 1) > 0 ? 0xD8018001 : 0); _edcTable[i] = edc; } @@ -70,8 +68,7 @@ public sealed partial class AaruFormat bool SuffixIsCorrect(byte[] sector) { - if(!_initedEdc) - EccInit(); + if(!_initedEdc) EccInit(); if(sector[0x814] != 0x00 || // reserved (8 bytes) sector[0x815] != 0x00 || @@ -85,21 +82,18 @@ public sealed partial class AaruFormat bool correctEccP = CheckEcc(sector, sector, 86, 24, 2, 86, sector, 0xC, 0x10, 0x81C); - if(!correctEccP) - return false; + if(!correctEccP) return false; bool correctEccQ = CheckEcc(sector, sector, 52, 43, 86, 88, sector, 0xC, 0x10, 0x81C + 0xAC); - if(!correctEccQ) - return false; + if(!correctEccQ) return false; var storedEdc = BitConverter.ToUInt32(sector, 0x810); uint edc = 0; var size = 0x810; var pos = 0; - for(; size > 0; size--) - edc = edc >> 8 ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; + for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; uint calculatedEdc = edc; @@ -108,28 +102,24 @@ public sealed partial class AaruFormat bool SuffixIsCorrectMode2(byte[] sector) { - if(!_initedEdc) - EccInit(); + if(!_initedEdc) EccInit(); var zeroAddress = new byte[4]; bool correctEccP = CheckEcc(zeroAddress, sector, 86, 24, 2, 86, sector, 0, 0x10, 0x81C); - if(!correctEccP) - return false; + if(!correctEccP) return false; bool correctEccQ = CheckEcc(zeroAddress, sector, 52, 43, 86, 88, sector, 0, 0x10, 0x81C + 0xAC); - if(!correctEccQ) - return false; + if(!correctEccQ) return false; var storedEdc = BitConverter.ToUInt32(sector, 0x818); uint edc = 0; var size = 0x808; var pos = 0x10; - for(; size > 0; size--) - edc = edc >> 8 ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; + for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; uint calculatedEdc = edc; @@ -154,8 +144,7 @@ public sealed partial class AaruFormat byte temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; - if(idx >= size) - idx -= size; + if(idx >= size) idx -= size; eccA ^= temp; eccB ^= temp; @@ -164,8 +153,7 @@ public sealed partial class AaruFormat eccA = _eccBTable[_eccFTable[eccA] ^ eccB]; - if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) - return false; + if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) return false; } return true; @@ -189,8 +177,7 @@ public sealed partial class AaruFormat byte temp = idx < 4 ? address[idx + addressOffset] : data[idx + dataOffset - 4]; idx += minorInc; - if(idx >= size) - idx -= size; + if(idx >= size) idx -= size; eccA ^= temp; eccB ^= temp; @@ -273,8 +260,7 @@ public sealed partial class AaruFormat { byte[] computedEdc; - if(!_initedEdc) - EccInit(); + if(!_initedEdc) EccInit(); switch(type) { @@ -346,13 +332,11 @@ public sealed partial class AaruFormat uint ComputeEdc(uint edc, byte[] src, int size, int srcOffset = 0) { - if(!_initedEdc) - EccInit(); + if(!_initedEdc) EccInit(); int pos = srcOffset; - for(; size > 0; size--) - edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; + for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; return edc; } diff --git a/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs b/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs index 798e42216..46c6d1351 100644 --- a/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs +++ b/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs @@ -40,8 +40,7 @@ public sealed partial class AaruFormat { static byte[] ClauniaSubchannelTransform(byte[] interleaved) { - if(interleaved == null) - return null; + if(interleaved == null) return null; var p = new int[interleaved.Length / 8]; var q = new int[interleaved.Length / 8]; @@ -159,13 +158,16 @@ public sealed partial class AaruFormat stopwatch.Stop(); TimeSpan sequentialize = stopwatch.Elapsed; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_deinterleave_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_deinterleave_subchannel, deinterleave.TotalMilliseconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_sequentialize_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_sequentialize_subchannel, sequentialize.TotalMilliseconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_transform_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_transform_subchannel, deinterleave.TotalMilliseconds + sequentialize.TotalMilliseconds); return sequential; @@ -173,8 +175,7 @@ public sealed partial class AaruFormat static byte[] ClauniaSubchannelUntransform(byte[] sequential) { - if(sequential == null) - return null; + if(sequential == null) return null; var p = new int[sequential.Length / 8]; var q = new int[sequential.Length / 8]; @@ -292,13 +293,16 @@ public sealed partial class AaruFormat stopwatch.Stop(); TimeSpan interleave = stopwatch.Elapsed; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_desequentialize_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_desequentialize_subchannel, desequentialize.TotalMilliseconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_interleave_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_interleave_subchannel, interleave.TotalMilliseconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_ms_to_untransform_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_ms_to_untransform_subchannel, interleave.TotalMilliseconds + desequentialize.TotalMilliseconds); return interleaved; diff --git a/Aaru.Images/AaruFormat/Helpers.cs b/Aaru.Images/AaruFormat/Helpers.cs index e586fa944..b11ac3a2d 100644 --- a/Aaru.Images/AaruFormat/Helpers.cs +++ b/Aaru.Images/AaruFormat/Helpers.cs @@ -53,8 +53,7 @@ public sealed partial class AaruFormat if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) _imageInfo.DriveManufacturer = VendorString.Prettify(decoded.Manufacturer); - if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) - _imageInfo.DriveModel = decoded.ProductName; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) _imageInfo.DriveModel = decoded.ProductName; if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) { @@ -74,8 +73,7 @@ public sealed partial class AaruFormat if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) _imageInfo.DriveManufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); - if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) - _imageInfo.DriveModel = decoded.ProductName; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) _imageInfo.DriveModel = decoded.ProductName; if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) { @@ -114,8 +112,7 @@ public sealed partial class AaruFormat Identify.IdentifyDevice? nullableIdentify = CommonTypes.Structs.Devices.ATA.Identify.Decode(ataIdentify); - if(!nullableIdentify.HasValue) - return; + if(!nullableIdentify.HasValue) return; Identify.IdentifyDevice identify = nullableIdentify.Value; @@ -127,11 +124,9 @@ public sealed partial class AaruFormat _imageInfo.DriveModel = separated[0]; else { - if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) - _imageInfo.DriveManufacturer = separated[0]; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) _imageInfo.DriveManufacturer = separated[0]; - if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) - _imageInfo.DriveModel = separated[^1]; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) _imageInfo.DriveModel = separated[^1]; } } @@ -251,11 +246,9 @@ public sealed partial class AaruFormat // Gets a DDT entry ulong GetDdtEntry(ulong sectorAddress) { - if(_inMemoryDdt) - return _userDataDdt[sectorAddress]; + if(_inMemoryDdt) return _userDataDdt[sectorAddress]; - if(_ddtEntryCache.TryGetValue(sectorAddress, out ulong entry)) - return entry; + if(_ddtEntryCache.TryGetValue(sectorAddress, out ulong entry)) return entry; long oldPosition = _imageStream.Position; _imageStream.Position = _outMemoryDdtPosition + Marshal.SizeOf(); @@ -265,8 +258,7 @@ public sealed partial class AaruFormat _imageStream.Position = oldPosition; entry = BitConverter.ToUInt64(temp, 0); - if(_ddtEntryCache.Count >= MAX_DDT_ENTRY_CACHE) - _ddtEntryCache.Clear(); + if(_ddtEntryCache.Count >= MAX_DDT_ENTRY_CACHE) _ddtEntryCache.Clear(); _ddtEntryCache.Add(sectorAddress, entry); @@ -296,15 +288,15 @@ public sealed partial class AaruFormat // Converts between image data type and Aaru media tag type static MediaTagType GetMediaTagTypeForDataType(DataType type) => type switch { - DataType.CompactDiscPartialToc => MediaTagType. - CD_TOC, - DataType.CompactDiscSessionInfo => - MediaTagType.CD_SessionInfo, - DataType.CompactDiscToc => MediaTagType. - CD_FullTOC, + DataType.CompactDiscPartialToc => MediaTagType + .CD_TOC, + DataType.CompactDiscSessionInfo => MediaTagType + .CD_SessionInfo, + DataType.CompactDiscToc => MediaTagType + .CD_FullTOC, DataType.CompactDiscPma => MediaTagType.CD_PMA, - DataType.CompactDiscAtip => MediaTagType. - CD_ATIP, + DataType.CompactDiscAtip => MediaTagType + .CD_ATIP, DataType.CompactDiscLeadInCdText => MediaTagType.CD_TEXT, DataType.DvdPfi => MediaTagType.DVD_PFI, @@ -313,194 +305,194 @@ public sealed partial class AaruFormat MediaTagType.DVD_DiscKey, DataType.DvdBca => MediaTagType.DVD_BCA, DataType.DvdDmi => MediaTagType.DVD_DMI, - DataType.DvdMediaIdentifier => MediaTagType. - DVD_MediaIdentifier, - DataType.DvdMediaKeyBlock => MediaTagType. - DVD_MKB, + DataType.DvdMediaIdentifier => MediaTagType + .DVD_MediaIdentifier, + DataType.DvdMediaKeyBlock => MediaTagType + .DVD_MKB, DataType.DvdRamDds => MediaTagType.DVDRAM_DDS, - DataType.DvdRamMediumStatus => MediaTagType. - DVDRAM_MediumStatus, - DataType.DvdRamSpareArea => MediaTagType. - DVDRAM_SpareArea, + DataType.DvdRamMediumStatus => MediaTagType + .DVDRAM_MediumStatus, + DataType.DvdRamSpareArea => MediaTagType + .DVDRAM_SpareArea, DataType.DvdRRmd => MediaTagType.DVDR_RMD, - DataType.DvdRPrerecordedInfo => MediaTagType. - DVDR_PreRecordedInfo, - DataType.DvdRMediaIdentifier => MediaTagType. - DVDR_MediaIdentifier, + DataType.DvdRPrerecordedInfo => MediaTagType + .DVDR_PreRecordedInfo, + DataType.DvdRMediaIdentifier => MediaTagType + .DVDR_MediaIdentifier, DataType.DvdRPfi => MediaTagType.DVDR_PFI, DataType.DvdAdip => MediaTagType.DVD_ADIP, DataType.HdDvdCpi => MediaTagType.HDDVD_CPI, - DataType.HdDvdMediumStatus => MediaTagType. - HDDVD_MediumStatus, - DataType.DvdDlLayerCapacity => MediaTagType. - DVDDL_LayerCapacity, - DataType.DvdDlMiddleZoneAddress => - MediaTagType.DVDDL_MiddleZoneAddress, - DataType.DvdDlJumpIntervalSize => MediaTagType. - DVDDL_JumpIntervalSize, + DataType.HdDvdMediumStatus => MediaTagType + .HDDVD_MediumStatus, + DataType.DvdDlLayerCapacity => MediaTagType + .DVDDL_LayerCapacity, + DataType.DvdDlMiddleZoneAddress => MediaTagType + .DVDDL_MiddleZoneAddress, + DataType.DvdDlJumpIntervalSize => MediaTagType + .DVDDL_JumpIntervalSize, DataType.DvdDlManualLayerJumpLba => MediaTagType.DVDDL_ManualLayerJumpLBA, DataType.BlurayDi => MediaTagType.BD_DI, DataType.BlurayBca => MediaTagType.BD_BCA, DataType.BlurayDds => MediaTagType.BD_DDS, - DataType.BlurayCartridgeStatus => MediaTagType. - BD_CartridgeStatus, - DataType.BluraySpareArea => MediaTagType. - BD_SpareArea, - DataType.AacsVolumeIdentifier => MediaTagType. - AACS_VolumeIdentifier, - DataType.AacsSerialNumber => MediaTagType. - AACS_SerialNumber, - DataType.AacsMediaIdentifier => MediaTagType. - AACS_MediaIdentifier, - DataType.AacsMediaKeyBlock => MediaTagType. - AACS_MKB, - DataType.AacsDataKeys => MediaTagType. - AACS_DataKeys, - DataType.AacsLbaExtents => MediaTagType. - AACS_LBAExtents, - DataType.CprmMediaKeyBlock => MediaTagType. - AACS_CPRM_MKB, - DataType.HybridRecognizedLayers => - MediaTagType.Hybrid_RecognizedLayers, - DataType.ScsiMmcWriteProtection => - MediaTagType.MMC_WriteProtection, - DataType.ScsiMmcDiscInformation => - MediaTagType.MMC_DiscInformation, + DataType.BlurayCartridgeStatus => MediaTagType + .BD_CartridgeStatus, + DataType.BluraySpareArea => MediaTagType + .BD_SpareArea, + DataType.AacsVolumeIdentifier => MediaTagType + .AACS_VolumeIdentifier, + DataType.AacsSerialNumber => MediaTagType + .AACS_SerialNumber, + DataType.AacsMediaIdentifier => MediaTagType + .AACS_MediaIdentifier, + DataType.AacsMediaKeyBlock => MediaTagType + .AACS_MKB, + DataType.AacsDataKeys => MediaTagType + .AACS_DataKeys, + DataType.AacsLbaExtents => MediaTagType + .AACS_LBAExtents, + DataType.CprmMediaKeyBlock => MediaTagType + .AACS_CPRM_MKB, + DataType.HybridRecognizedLayers => MediaTagType + .Hybrid_RecognizedLayers, + DataType.ScsiMmcWriteProtection => MediaTagType + .MMC_WriteProtection, + DataType.ScsiMmcDiscInformation => MediaTagType + .MMC_DiscInformation, DataType.ScsiMmcTrackResourcesInformation => MediaTagType.MMC_TrackResourcesInformation, DataType.ScsiMmcPowResourcesInformation => MediaTagType.MMC_POWResourcesInformation, - DataType.ScsiInquiry => MediaTagType. - SCSI_INQUIRY, - DataType.ScsiModePage2A => MediaTagType. - SCSI_MODEPAGE_2A, - DataType.AtaIdentify => MediaTagType. - ATA_IDENTIFY, - DataType.AtapiIdentify => MediaTagType. - ATAPI_IDENTIFY, + DataType.ScsiInquiry => MediaTagType + .SCSI_INQUIRY, + DataType.ScsiModePage2A => MediaTagType + .SCSI_MODEPAGE_2A, + DataType.AtaIdentify => MediaTagType + .ATA_IDENTIFY, + DataType.AtapiIdentify => MediaTagType + .ATAPI_IDENTIFY, DataType.PcmciaCis => MediaTagType.PCMCIA_CIS, - DataType.SecureDigitalCid => MediaTagType. - SD_CID, - DataType.SecureDigitalCsd => MediaTagType. - SD_CSD, - DataType.SecureDigitalScr => MediaTagType. - SD_SCR, - DataType.SecureDigitalOcr => MediaTagType. - SD_OCR, - DataType.MultiMediaCardCid => MediaTagType. - MMC_CID, - DataType.MultiMediaCardCsd => MediaTagType. - MMC_CSD, - DataType.MultiMediaCardOcr => MediaTagType. - MMC_OCR, + DataType.SecureDigitalCid => MediaTagType + .SD_CID, + DataType.SecureDigitalCsd => MediaTagType + .SD_CSD, + DataType.SecureDigitalScr => MediaTagType + .SD_SCR, + DataType.SecureDigitalOcr => MediaTagType + .SD_OCR, + DataType.MultiMediaCardCid => MediaTagType + .MMC_CID, + DataType.MultiMediaCardCsd => MediaTagType + .MMC_CSD, + DataType.MultiMediaCardOcr => MediaTagType + .MMC_OCR, DataType.MultiMediaCardExtendedCsd => MediaTagType.MMC_ExtendedCSD, - DataType.XboxSecuritySector => MediaTagType. - Xbox_SecuritySector, - DataType.FloppyLeadOut => MediaTagType. - Floppy_LeadOut, - DataType.DvdDiscControlBlock => MediaTagType. - DCB, + DataType.XboxSecuritySector => MediaTagType + .Xbox_SecuritySector, + DataType.FloppyLeadOut => MediaTagType + .Floppy_LeadOut, + DataType.DvdDiscControlBlock => MediaTagType + .DCB, DataType.CompactDiscFirstTrackPregap => MediaTagType.CD_FirstTrackPregap, - DataType.CompactDiscLeadOut => MediaTagType. - CD_LeadOut, - DataType.ScsiModeSense6 => MediaTagType. - SCSI_MODESENSE_6, - DataType.ScsiModeSense10 => MediaTagType. - SCSI_MODESENSE_10, - DataType.UsbDescriptors => MediaTagType. - USB_Descriptors, + DataType.CompactDiscLeadOut => MediaTagType + .CD_LeadOut, + DataType.ScsiModeSense6 => MediaTagType + .SCSI_MODESENSE_6, + DataType.ScsiModeSense10 => MediaTagType + .SCSI_MODESENSE_10, + DataType.UsbDescriptors => MediaTagType + .USB_Descriptors, DataType.XboxDmi => MediaTagType.Xbox_DMI, DataType.XboxPfi => MediaTagType.Xbox_PFI, DataType.CompactDiscMediaCatalogueNumber => MediaTagType.CD_MCN, - DataType.CompactDiscLeadIn => MediaTagType. - CD_LeadIn, - DataType.DvdDiscKeyDecrypted => MediaTagType. - DVD_DiscKey_Decrypted, + DataType.CompactDiscLeadIn => MediaTagType + .CD_LeadIn, + DataType.DvdDiscKeyDecrypted => MediaTagType + .DVD_DiscKey_Decrypted, _ => throw new ArgumentOutOfRangeException() }; // Converts between Aaru media tag type and image data type static DataType GetDataTypeForMediaTag(MediaTagType tag) => tag switch { - MediaTagType.CD_TOC => DataType. - CompactDiscPartialToc, - MediaTagType.CD_SessionInfo => DataType. - CompactDiscSessionInfo, + MediaTagType.CD_TOC => DataType + .CompactDiscPartialToc, + MediaTagType.CD_SessionInfo => DataType + .CompactDiscSessionInfo, MediaTagType.CD_FullTOC => DataType.CompactDiscToc, MediaTagType.CD_PMA => DataType.CompactDiscPma, MediaTagType.CD_ATIP => DataType.CompactDiscAtip, - MediaTagType.CD_TEXT => DataType. - CompactDiscLeadInCdText, + MediaTagType.CD_TEXT => DataType + .CompactDiscLeadInCdText, MediaTagType.DVD_PFI => DataType.DvdPfi, MediaTagType.DVD_CMI => DataType.DvdLeadInCmi, MediaTagType.DVD_DiscKey => DataType.DvdDiscKey, MediaTagType.DVD_BCA => DataType.DvdBca, MediaTagType.DVD_DMI => DataType.DvdDmi, - MediaTagType.DVD_MediaIdentifier => DataType. - DvdMediaIdentifier, + MediaTagType.DVD_MediaIdentifier => DataType + .DvdMediaIdentifier, MediaTagType.DVD_MKB => DataType.DvdMediaKeyBlock, MediaTagType.DVDRAM_DDS => DataType.DvdRamDds, - MediaTagType.DVDRAM_MediumStatus => DataType. - DvdRamMediumStatus, - MediaTagType.DVDRAM_SpareArea => DataType. - DvdRamSpareArea, + MediaTagType.DVDRAM_MediumStatus => DataType + .DvdRamMediumStatus, + MediaTagType.DVDRAM_SpareArea => DataType + .DvdRamSpareArea, MediaTagType.DVDR_RMD => DataType.DvdRRmd, - MediaTagType.DVDR_PreRecordedInfo => DataType. - DvdRPrerecordedInfo, - MediaTagType.DVDR_MediaIdentifier => DataType. - DvdRMediaIdentifier, + MediaTagType.DVDR_PreRecordedInfo => DataType + .DvdRPrerecordedInfo, + MediaTagType.DVDR_MediaIdentifier => DataType + .DvdRMediaIdentifier, MediaTagType.DVDR_PFI => DataType.DvdRPfi, MediaTagType.DVD_ADIP => DataType.DvdAdip, MediaTagType.HDDVD_CPI => DataType.HdDvdCpi, - MediaTagType.HDDVD_MediumStatus => DataType. - HdDvdMediumStatus, - MediaTagType.DVDDL_LayerCapacity => DataType. - DvdDlLayerCapacity, - MediaTagType.DVDDL_MiddleZoneAddress => DataType. - DvdDlMiddleZoneAddress, - MediaTagType.DVDDL_JumpIntervalSize => DataType. - DvdDlJumpIntervalSize, - MediaTagType.DVDDL_ManualLayerJumpLBA => DataType. - DvdDlManualLayerJumpLba, + MediaTagType.HDDVD_MediumStatus => DataType + .HdDvdMediumStatus, + MediaTagType.DVDDL_LayerCapacity => DataType + .DvdDlLayerCapacity, + MediaTagType.DVDDL_MiddleZoneAddress => DataType + .DvdDlMiddleZoneAddress, + MediaTagType.DVDDL_JumpIntervalSize => DataType + .DvdDlJumpIntervalSize, + MediaTagType.DVDDL_ManualLayerJumpLBA => DataType + .DvdDlManualLayerJumpLba, MediaTagType.BD_DI => DataType.BlurayDi, MediaTagType.BD_BCA => DataType.BlurayBca, MediaTagType.BD_DDS => DataType.BlurayDds, - MediaTagType.BD_CartridgeStatus => DataType. - BlurayCartridgeStatus, - MediaTagType.BD_SpareArea => DataType. - BluraySpareArea, - MediaTagType.AACS_VolumeIdentifier => DataType. - AacsVolumeIdentifier, - MediaTagType.AACS_SerialNumber => DataType. - AacsSerialNumber, - MediaTagType.AACS_MediaIdentifier => DataType. - AacsMediaIdentifier, + MediaTagType.BD_CartridgeStatus => DataType + .BlurayCartridgeStatus, + MediaTagType.BD_SpareArea => DataType + .BluraySpareArea, + MediaTagType.AACS_VolumeIdentifier => DataType + .AacsVolumeIdentifier, + MediaTagType.AACS_SerialNumber => DataType + .AacsSerialNumber, + MediaTagType.AACS_MediaIdentifier => DataType + .AacsMediaIdentifier, MediaTagType.AACS_MKB => DataType.AacsMediaKeyBlock, MediaTagType.AACS_DataKeys => DataType.AacsDataKeys, - MediaTagType.AACS_LBAExtents => DataType. - AacsLbaExtents, - MediaTagType.AACS_CPRM_MKB => DataType. - CprmMediaKeyBlock, - MediaTagType.Hybrid_RecognizedLayers => DataType. - HybridRecognizedLayers, - MediaTagType.MMC_WriteProtection => DataType. - ScsiMmcWriteProtection, - MediaTagType.MMC_DiscInformation => DataType. - ScsiMmcDiscInformation, + MediaTagType.AACS_LBAExtents => DataType + .AacsLbaExtents, + MediaTagType.AACS_CPRM_MKB => DataType + .CprmMediaKeyBlock, + MediaTagType.Hybrid_RecognizedLayers => DataType + .HybridRecognizedLayers, + MediaTagType.MMC_WriteProtection => DataType + .ScsiMmcWriteProtection, + MediaTagType.MMC_DiscInformation => DataType + .ScsiMmcDiscInformation, MediaTagType.MMC_TrackResourcesInformation => DataType.ScsiMmcTrackResourcesInformation, - MediaTagType.MMC_POWResourcesInformation => - DataType.ScsiMmcPowResourcesInformation, + MediaTagType.MMC_POWResourcesInformation => DataType + .ScsiMmcPowResourcesInformation, MediaTagType.SCSI_INQUIRY => DataType.ScsiInquiry, - MediaTagType.SCSI_MODEPAGE_2A => DataType. - ScsiModePage2A, + MediaTagType.SCSI_MODEPAGE_2A => DataType + .ScsiModePage2A, MediaTagType.ATA_IDENTIFY => DataType.AtaIdentify, - MediaTagType.ATAPI_IDENTIFY => DataType. - AtapiIdentify, + MediaTagType.ATAPI_IDENTIFY => DataType + .AtapiIdentify, MediaTagType.PCMCIA_CIS => DataType.PcmciaCis, MediaTagType.SD_CID => DataType.SecureDigitalCid, MediaTagType.SD_CSD => DataType.SecureDigitalCsd, @@ -509,33 +501,34 @@ public sealed partial class AaruFormat MediaTagType.MMC_CID => DataType.MultiMediaCardCid, MediaTagType.MMC_CSD => DataType.MultiMediaCardCsd, MediaTagType.MMC_OCR => DataType.MultiMediaCardOcr, - MediaTagType.MMC_ExtendedCSD => DataType. - MultiMediaCardExtendedCsd, - MediaTagType.Xbox_SecuritySector => DataType. - XboxSecuritySector, - MediaTagType.Floppy_LeadOut => DataType. - FloppyLeadOut, + MediaTagType.MMC_ExtendedCSD => DataType + .MultiMediaCardExtendedCsd, + MediaTagType.Xbox_SecuritySector => DataType + .XboxSecuritySector, + MediaTagType.Floppy_LeadOut => DataType + .FloppyLeadOut, MediaTagType.DCB => DataType.DvdDiscControlBlock, - MediaTagType.CD_FirstTrackPregap => DataType. - CompactDiscFirstTrackPregap, - MediaTagType.CD_LeadOut => DataType. - CompactDiscLeadOut, - MediaTagType.SCSI_MODESENSE_6 => DataType. - ScsiModeSense6, - MediaTagType.SCSI_MODESENSE_10 => DataType. - ScsiModeSense10, - MediaTagType.USB_Descriptors => DataType. - UsbDescriptors, + MediaTagType.CD_FirstTrackPregap => DataType + .CompactDiscFirstTrackPregap, + MediaTagType.CD_LeadOut => DataType + .CompactDiscLeadOut, + MediaTagType.SCSI_MODESENSE_6 => DataType + .ScsiModeSense6, + MediaTagType.SCSI_MODESENSE_10 => DataType + .ScsiModeSense10, + MediaTagType.USB_Descriptors => DataType + .UsbDescriptors, MediaTagType.Xbox_DMI => DataType.XboxDmi, MediaTagType.Xbox_PFI => DataType.XboxPfi, - MediaTagType.CD_MCN => DataType. - CompactDiscMediaCatalogueNumber, + MediaTagType.CD_MCN => DataType + .CompactDiscMediaCatalogueNumber, MediaTagType.CD_LeadIn => DataType.CompactDiscLeadIn, - MediaTagType.DVD_DiscKey_Decrypted => DataType. - DvdDiscKeyDecrypted, + MediaTagType.DVD_DiscKey_Decrypted => DataType + .DvdDiscKeyDecrypted, _ => throw new ArgumentOutOfRangeException(nameof(tag), - tag, null) + tag, + null) }; } \ No newline at end of file diff --git a/Aaru.Images/AaruFormat/Identify.cs b/Aaru.Images/AaruFormat/Identify.cs index 2a3a57bc3..daecf0741 100644 --- a/Aaru.Images/AaruFormat/Identify.cs +++ b/Aaru.Images/AaruFormat/Identify.cs @@ -46,8 +46,7 @@ public sealed partial class AaruFormat _imageStream = imageFilter.GetDataForkStream(); _imageStream.Seek(0, SeekOrigin.Begin); - if(_imageStream.Length < Marshal.SizeOf()) - return false; + if(_imageStream.Length < Marshal.SizeOf()) return false; _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); diff --git a/Aaru.Images/AaruFormat/Properties.cs b/Aaru.Images/AaruFormat/Properties.cs index 27419ab3d..62bced291 100644 --- a/Aaru.Images/AaruFormat/Properties.cs +++ b/Aaru.Images/AaruFormat/Properties.cs @@ -64,6 +64,7 @@ public sealed partial class AaruFormat OpticalImageCapabilities.CanStoreHiddenTracks; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs index 9ede50985..549156121 100644 --- a/Aaru.Images/AaruFormat/Read.cs +++ b/Aaru.Images/AaruFormat/Read.cs @@ -73,8 +73,7 @@ public sealed partial class AaruFormat _imageStream = imageFilter.GetDataForkStream(); _imageStream.Seek(0, SeekOrigin.Begin); - if(_imageStream.Length < Marshal.SizeOf()) - return ErrorNumber.InvalidArgument; + if(_imageStream.Length < Marshal.SizeOf()) return ErrorNumber.InvalidArgument; _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); @@ -115,7 +114,9 @@ public sealed partial class AaruFormat _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); IndexHeader2 idxHeader2 = Marshal.SpanToStructureLittleEndian(_structureBytes); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Index_at_0_contains_1_entries, _header.indexOffset, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Index_at_0_contains_1_entries, + _header.indexOffset, idxHeader2.entries); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); @@ -131,14 +132,18 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Block_type_0_with_data_type_1_is_indexed_to_be_at_2, - entry.blockType, entry.dataType, entry.offset); + entry.blockType, + entry.dataType, + entry.offset); _index.Add(entry); } } else { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Index_at_0_contains_1_entries, _header.indexOffset, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Index_at_0_contains_1_entries, + _header.indexOffset, idxHeader.entries); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); @@ -154,7 +159,9 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Block_type_0_with_data_type_1_is_indexed_to_be_at_2, - entry.blockType, entry.dataType, entry.offset); + entry.blockType, + entry.dataType, + entry.offset); _index.Add(entry); } @@ -176,8 +183,7 @@ public sealed partial class AaruFormat { case BlockType.DataBlock: // NOP block, skip - if(entry.dataType == DataType.NoData) - break; + if(entry.dataType == DataType.NoData) break; _imageStream.Position = (long)entry.offset; @@ -207,19 +213,24 @@ public sealed partial class AaruFormat if(blockHeader.type != entry.dataType) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_block_with_data_type_0_at_position_1_but_found_data_type_2, - entry.dataType, entry.offset, blockHeader.type); + Localization + .Expected_block_with_data_type_0_at_position_1_but_found_data_type_2, + entry.dataType, + entry.offset, + blockHeader.type); break; } byte[] data; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_data_block_type_0_at_position_1, - entry.dataType, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_data_block_type_0_at_position_1, + entry.dataType, + entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); // Decompress media tag @@ -230,9 +241,10 @@ public sealed partial class AaruFormat entry.dataType != DataType.CdSectorSubchannel) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Invalid_compression_type_0_for_block_with_data_type_1_continuing, - blockHeader.compression, entry.dataType); + Localization + .Invalid_compression_type_0_for_block_with_data_type_1_continuing, + blockHeader.compression, + entry.dataType); break; } @@ -249,9 +261,10 @@ public sealed partial class AaruFormat if(decompressedLength != blockHeader.length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, - blockHeader.length, decompressedLength); + Localization + .Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, + blockHeader.length, + decompressedLength); return ErrorNumber.InOutError; } @@ -261,10 +274,12 @@ public sealed partial class AaruFormat decompressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_decompress_block, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_decompress_block, decompressStopwatch.Elapsed.TotalSeconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } else if(blockHeader.compression == CompressionType.None) @@ -272,7 +287,8 @@ public sealed partial class AaruFormat data = new byte[blockHeader.length]; _imageStream.EnsureRead(data, 0, (int)blockHeader.length); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } else @@ -290,9 +306,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(blockCrc, 0) != blockHeader.crc64 && blockHeader.crc64 != 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(blockCrc, 0), blockHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(blockCrc, 0), + blockHeader.crc64); break; } @@ -316,7 +333,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -345,7 +363,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -355,7 +374,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -367,14 +387,16 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; case DataType.CompactDiscMode2Subheader: _mode2Subheaders = data; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -387,7 +409,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorTitleKey)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorTitleKey); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -400,7 +423,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorNumber)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorNumber); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -410,7 +434,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorIed)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorIed); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -420,7 +445,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorEdc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -430,7 +456,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdTitleKeyDecrypted)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdTitleKeyDecrypted); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -440,8 +467,8 @@ public sealed partial class AaruFormat if(_mediaTags.ContainsKey(mediaTagType)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Media_tag_type_0_duplicated_removing_previous_entry, + Localization + .Media_tag_type_0_duplicated_removing_previous_entry, mediaTagType); _mediaTags.Remove(mediaTagType); @@ -449,7 +476,8 @@ public sealed partial class AaruFormat _mediaTags.Add(mediaTagType, data); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -462,8 +490,7 @@ public sealed partial class AaruFormat DdtHeader ddtHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); _imageInfo.ImageSize += ddtHeader.cmpLength; - if(ddtHeader.identifier != BlockType.DeDuplicationTable) - break; + if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; switch(entry.dataType) { @@ -471,7 +498,8 @@ public sealed partial class AaruFormat _imageInfo.Sectors = ddtHeader.entries; _shift = ddtHeader.shift; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); // Check for DDT compression @@ -493,9 +521,10 @@ public sealed partial class AaruFormat if(decompressedLength != ddtHeader.length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, - ddtHeader.length, decompressedLength); + Localization + .Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, + ddtHeader.length, + decompressedLength); return ErrorNumber.InOutError; } @@ -508,7 +537,8 @@ public sealed partial class AaruFormat Localization.Took_0_seconds_to_decompress_DDT, ddtStopwatch.Elapsed.TotalSeconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -516,15 +546,15 @@ public sealed partial class AaruFormat _inMemoryDdt = false; _outMemoryDdtPosition = (long)entry.offset; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; default: - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_unsupported_compression_algorithm_0, - (ushort)ddtHeader.compression)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_unsupported_compression_algorithm_0, + (ushort)ddtHeader.compression)); return ErrorNumber.NotSupported; } @@ -537,7 +567,8 @@ public sealed partial class AaruFormat { var decompressedDdt = new byte[ddtHeader.length]; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); // Check for DDT compression @@ -560,9 +591,10 @@ public sealed partial class AaruFormat if(decompressedLength != ddtHeader.length) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, - ddtHeader.length, decompressedLength); + Localization + .Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, + ddtHeader.length, + decompressedLength); return ErrorNumber.InOutError; } @@ -571,22 +603,23 @@ public sealed partial class AaruFormat Localization.Took_0_seconds_to_decompress_DDT, ddtStopwatch.Elapsed.TotalSeconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; case CompressionType.None: _imageStream.EnsureRead(decompressedDdt, 0, decompressedDdt.Length); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; default: - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_unsupported_compression_algorithm_0, - (ushort)ddtHeader.compression)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_unsupported_compression_algorithm_0, + (ushort)ddtHeader.compression)); return ErrorNumber.NotSupported; } @@ -607,7 +640,8 @@ public sealed partial class AaruFormat break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -626,14 +660,16 @@ public sealed partial class AaruFormat { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Geometry_set_to_0_cylinders_1_heads_2_sectors_per_track, - _geometryBlock.cylinders, _geometryBlock.heads, + _geometryBlock.cylinders, + _geometryBlock.heads, _geometryBlock.sectorsPerTrack); _imageInfo.Cylinders = _geometryBlock.cylinders; _imageInfo.Heads = _geometryBlock.heads; _imageInfo.SectorsPerTrack = _geometryBlock.sectorsPerTrack; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } @@ -655,7 +691,8 @@ public sealed partial class AaruFormat break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_metadata_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_metadata_block_at_position_0, entry.offset); var metadata = new byte[metadataBlock.blockSize]; @@ -667,14 +704,17 @@ public sealed partial class AaruFormat _imageInfo.MediaSequence = metadataBlock.mediaSequence; _imageInfo.LastMediaSequence = metadataBlock.lastMediaSequence; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_sequence_as_0_of_1, - _imageInfo.MediaSequence, _imageInfo.LastMediaSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_sequence_as_0_of_1, + _imageInfo.MediaSequence, + _imageInfo.LastMediaSequence); } if(metadataBlock.creatorLength > 0 && metadataBlock.creatorLength + metadataBlock.creatorOffset <= metadata.Length) { - _imageInfo.Creator = Encoding.Unicode.GetString(metadata, (int)metadataBlock.creatorOffset, + _imageInfo.Creator = Encoding.Unicode.GetString(metadata, + (int)metadataBlock.creatorOffset, (int)(metadataBlock.creatorLength - 2)); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_creator_0, _imageInfo.Creator); @@ -683,7 +723,8 @@ public sealed partial class AaruFormat if(metadataBlock.commentsOffset > 0 && metadataBlock.commentsLength + metadataBlock.commentsOffset <= metadata.Length) { - _imageInfo.Comments = Encoding.Unicode.GetString(metadata, (int)metadataBlock.commentsOffset, + _imageInfo.Comments = Encoding.Unicode.GetString(metadata, + (int)metadataBlock.commentsOffset, (int)(metadataBlock.commentsLength - 2)); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_comments_0, _imageInfo.Comments); @@ -693,10 +734,12 @@ public sealed partial class AaruFormat metadataBlock.mediaTitleLength + metadataBlock.mediaTitleOffset <= metadata.Length) { _imageInfo.MediaTitle = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaTitleOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaTitleOffset, (int)(metadataBlock.mediaTitleLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_title_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_title_0, _imageInfo.MediaTitle); } @@ -704,10 +747,12 @@ public sealed partial class AaruFormat metadataBlock.mediaManufacturerLength + metadataBlock.mediaManufacturerOffset <= metadata.Length) { _imageInfo.MediaManufacturer = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaManufacturerOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaManufacturerOffset, (int)(metadataBlock.mediaManufacturerLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_manufacturer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_manufacturer_0, _imageInfo.MediaManufacturer); } @@ -715,10 +760,12 @@ public sealed partial class AaruFormat metadataBlock.mediaModelLength + metadataBlock.mediaModelOffset <= metadata.Length) { _imageInfo.MediaModel = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaModelOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaModelOffset, (int)(metadataBlock.mediaModelLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_model_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_model_0, _imageInfo.MediaModel); } @@ -726,10 +773,12 @@ public sealed partial class AaruFormat metadataBlock.mediaSerialNumberLength + metadataBlock.mediaSerialNumberOffset <= metadata.Length) { _imageInfo.MediaSerialNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaSerialNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaSerialNumberOffset, (int)(metadataBlock.mediaSerialNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_serial_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_serial_number_0, _imageInfo.MediaSerialNumber); } @@ -737,10 +786,12 @@ public sealed partial class AaruFormat metadataBlock.mediaBarcodeLength + metadataBlock.mediaBarcodeOffset <= metadata.Length) { _imageInfo.MediaBarcode = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaBarcodeOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaBarcodeOffset, (int)(metadataBlock.mediaBarcodeLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_barcode_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_barcode_0, _imageInfo.MediaBarcode); } @@ -748,10 +799,12 @@ public sealed partial class AaruFormat metadataBlock.mediaPartNumberLength + metadataBlock.mediaPartNumberOffset <= metadata.Length) { _imageInfo.MediaPartNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaPartNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaPartNumberOffset, (int)(metadataBlock.mediaPartNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_part_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_part_number_0, _imageInfo.MediaPartNumber); } @@ -759,10 +812,12 @@ public sealed partial class AaruFormat metadataBlock.driveManufacturerLength + metadataBlock.driveManufacturerOffset <= metadata.Length) { _imageInfo.DriveManufacturer = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveManufacturerOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveManufacturerOffset, (int)(metadataBlock.driveManufacturerLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_manufacturer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_manufacturer_0, _imageInfo.DriveManufacturer); } @@ -770,10 +825,12 @@ public sealed partial class AaruFormat metadataBlock.driveModelLength + metadataBlock.driveModelOffset <= metadata.Length) { _imageInfo.DriveModel = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveModelOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveModelOffset, (int)(metadataBlock.driveModelLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_model_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_model_0, _imageInfo.DriveModel); } @@ -781,10 +838,12 @@ public sealed partial class AaruFormat metadataBlock.driveSerialNumberLength + metadataBlock.driveSerialNumberOffset <= metadata.Length) { _imageInfo.DriveSerialNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveSerialNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveSerialNumberOffset, (int)(metadataBlock.driveSerialNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_serial_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_serial_number_0, _imageInfo.DriveSerialNumber); } @@ -793,14 +852,17 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.DriveFirmwareRevision = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveFirmwareRevisionOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveFirmwareRevisionOffset, (int)(metadataBlock.driveFirmwareRevisionLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_firmware_revision_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_firmware_revision_0, _imageInfo.DriveFirmwareRevision); } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -827,9 +889,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(trksCrc, 0) != tracksHeader.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(trksCrc, 0), tracksHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(trksCrc, 0), + tracksHeader.crc64); break; } @@ -840,8 +903,10 @@ public sealed partial class AaruFormat _trackFlags = new Dictionary(); _trackIsrcs = new Dictionary(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_0_tracks_at_position_1, - tracksHeader.entries, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_0_tracks_at_position_1, + tracksHeader.entries, + entry.offset); for(ushort i = 0; i < tracksHeader.entries; i++) { @@ -863,8 +928,7 @@ public sealed partial class AaruFormat Filter = imageFilter }); - if(trackEntry.type == TrackType.Data) - continue; + if(trackEntry.type == TrackType.Data) continue; _trackFlags.Add(trackEntry.sequence, trackEntry.flags); @@ -881,7 +945,8 @@ public sealed partial class AaruFormat _imageInfo.HasPartitions = true; _imageInfo.HasSessions = true; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -894,13 +959,14 @@ public sealed partial class AaruFormat CicmMetadataBlock cicmBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(cicmBlock.identifier != BlockType.CicmBlock) - break; + if(cicmBlock.identifier != BlockType.CicmBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CICM_XML_metadata_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CICM_XML_metadata_block_at_position_0, entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); var cicmBytes = new byte[cicmBlock.length]; @@ -908,18 +974,18 @@ public sealed partial class AaruFormat var cicmMs = new MemoryStream(cicmBytes); // The converter to AaruMetadata basically overcomes this (should?) - #pragma warning disable IL2026 +#pragma warning disable IL2026 var cicmXs = new XmlSerializer(typeof(CICMMetadataType)); - #pragma warning restore IL2026 +#pragma warning restore IL2026 try { var sr = new StreamReader(cicmMs); // The converter to AaruMetadata basically overcomes this (should?) - #pragma warning disable IL2026 +#pragma warning disable IL2026 AaruMetadata = (CICMMetadataType)cicmXs.Deserialize(sr); - #pragma warning restore IL2026 +#pragma warning restore IL2026 sr.Close(); } catch(XmlException ex) @@ -927,12 +993,14 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Exception_0_processing_CICM_XML_metadata_block, ex.Message); + AaruConsole.WriteException(ex); AaruMetadata = null; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -945,13 +1013,14 @@ public sealed partial class AaruFormat AaruMetadataJsonBlock aaruMetadataBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(aaruMetadataBlock.identifier != BlockType.AaruMetadataJsonBlock) - break; + if(aaruMetadataBlock.identifier != BlockType.AaruMetadataJsonBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_Aaru_Metadata_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_Aaru_Metadata_block_at_position_0, entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); var jsonBytes = new byte[aaruMetadataBlock.length]; @@ -965,14 +1034,17 @@ public sealed partial class AaruFormat } catch(JsonException ex) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Exception_0_processing_Aaru_Metadata_block, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Exception_0_processing_Aaru_Metadata_block, ex.Message); + AaruConsole.WriteException(ex); AaruMetadata = null; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -985,13 +1057,14 @@ public sealed partial class AaruFormat DumpHardwareHeader dumpBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(dumpBlock.identifier != BlockType.DumpHardwareBlock) - break; + if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_dump_hardware_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_dump_hardware_block_at_position_0, entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); _structureBytes = new byte[dumpBlock.length]; @@ -1001,9 +1074,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(dumpCrc, 0) != dumpBlock.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(dumpCrc, 0), dumpBlock.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(dumpCrc, 0), + dumpBlock.crc64); break; } @@ -1107,14 +1181,13 @@ public sealed partial class AaruFormat dump.Extents = dump.Extents.OrderBy(t => t.Start).ToList(); - if(dump.Extents.Count > 0) - DumpHardware.Add(dump); + if(dump.Extents.Count > 0) DumpHardware.Add(dump); } - if(DumpHardware.Count == 0) - DumpHardware = null; + if(DumpHardware.Count == 0) DumpHardware = null; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1127,10 +1200,10 @@ public sealed partial class AaruFormat TapePartitionHeader partitionHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(partitionHeader.identifier != BlockType.TapePartitionBlock) - break; + if(partitionHeader.identifier != BlockType.TapePartitionBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_tape_partition_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_tape_partition_block_at_position_0, entry.offset); var tapePartitionBytes = new byte[partitionHeader.length]; @@ -1162,10 +1235,10 @@ public sealed partial class AaruFormat TapeFileHeader fileHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(fileHeader.identifier != BlockType.TapeFileBlock) - break; + if(fileHeader.identifier != BlockType.TapeFileBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_tape_file_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_tape_file_block_at_position_0, entry.offset); var tapeFileBytes = new byte[fileHeader.length]; @@ -1199,8 +1272,8 @@ public sealed partial class AaruFormat if(indexesHeader.identifier != BlockType.CompactDiscIndexesBlock) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_identifier_for_compact_disc_indexes_block_at_position_0, + Localization + .Incorrect_identifier_for_compact_disc_indexes_block_at_position_0, entry.offset); break; @@ -1213,9 +1286,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(idsxCrc, 0) != indexesHeader.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(idsxCrc, 0), indexesHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(idsxCrc, 0), + indexesHeader.crc64); break; } @@ -1224,20 +1298,23 @@ public sealed partial class AaruFormat compactDiscIndexes = new List(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_0_compact_disc_indexes_at_position_1, - indexesHeader.entries, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_0_compact_disc_indexes_at_position_1, + indexesHeader.entries, + entry.offset); for(ushort i = 0; i < indexesHeader.entries; i++) { _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); - compactDiscIndexes.Add(Marshal. - ByteArrayToStructureLittleEndian< + compactDiscIndexes.Add(Marshal + .ByteArrayToStructureLittleEndian< CompactDiscIndexEntry>(_structureBytes)); } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1276,8 +1353,7 @@ public sealed partial class AaruFormat _blockHeaderCache = new Dictionary(); _currentCacheSize = 0; - if(!_inMemoryDdt) - _ddtEntryCache = new Dictionary(); + if(!_inMemoryDdt) _ddtEntryCache = new Dictionary(); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); @@ -1303,7 +1379,8 @@ public sealed partial class AaruFormat Dictionary leadOutStarts = new(); // Lead-out starts foreach(FullTOC.TrackDataDescriptor trk in - decodedFullToc.Value.TrackDescriptors.Where(trk => trk.ADR is 1 or 4 && trk.POINT == 0xA2)) + decodedFullToc.Value.TrackDescriptors.Where(trk => trk.ADR is 1 or 4 && + trk.POINT == 0xA2)) { int phour, pmin, psec, pframe; @@ -1349,8 +1426,8 @@ public sealed partial class AaruFormat { var lastTrackInSession = new Track(); - foreach(Track trk in Tracks.Where(trk => trk.Session == leadOuts.Key). - Where(trk => trk.Sequence > lastTrackInSession.Sequence)) + foreach(Track trk in Tracks.Where(trk => trk.Session == leadOuts.Key) + .Where(trk => trk.Sequence > lastTrackInSession.Sequence)) lastTrackInSession = trk; if(lastTrackInSession.Sequence == 0 || @@ -1367,18 +1444,14 @@ public sealed partial class AaruFormat { foreach(Track track in Tracks) { - if(track.Sequence <= 1) - continue; + if(track.Sequence <= 1) continue; - uint firstTrackNumberInSameSession = Tracks. - Where(t => t.Session == track.Session). - Min(t => t.Sequence); + uint firstTrackNumberInSameSession = + Tracks.Where(t => t.Session == track.Session).Min(t => t.Sequence); - if(firstTrackNumberInSameSession != track.Sequence) - continue; + if(firstTrackNumberInSameSession != track.Sequence) continue; - if(track.Pregap == 150) - continue; + if(track.Pregap == 150) continue; long dif = (long)track.Pregap - 150; track.Pregap = (ulong)((long)track.Pregap - dif); @@ -1393,8 +1466,8 @@ public sealed partial class AaruFormat if(sessionPregapFixed) { - AaruConsole.ErrorWriteLine(Localization. - This_image_has_a_corrupted_track_list_a_best_effort_has_been_tried_but_may_require_manual_editing_or_redump); + AaruConsole.ErrorWriteLine(Localization + .This_image_has_a_corrupted_track_list_a_best_effort_has_been_tried_but_may_require_manual_editing_or_redump); } } @@ -1501,8 +1574,7 @@ public sealed partial class AaruFormat { ErrorNumber errno = ReadSector(trk.StartSector, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; trk.BytesPerSector = sector.Length; @@ -1512,8 +1584,7 @@ public sealed partial class AaruFormat ? 2352 : sector.Length; - if(_sectorSubchannel == null) - continue; + if(_sectorSubchannel == null) continue; trk.SubchannelFile = trk.File; trk.SubchannelFilter = trk.Filter; @@ -1528,13 +1599,12 @@ public sealed partial class AaruFormat if(compactDiscIndexes != null) { - foreach(CompactDiscIndexEntry compactDiscIndex in compactDiscIndexes.OrderBy(i => i.Track). - ThenBy(i => i.Index)) + foreach(CompactDiscIndexEntry compactDiscIndex in compactDiscIndexes.OrderBy(i => i.Track) + .ThenBy(i => i.Index)) { Track track = Tracks.FirstOrDefault(t => t.Sequence == compactDiscIndex.Track); - if(track is null) - continue; + if(track is null) continue; track.Indexes[compactDiscIndex.Index] = compactDiscIndex.Lba; } @@ -1549,24 +1619,52 @@ public sealed partial class AaruFormat SetMetadataFromTags(); - if(_sectorSuffixDdt != null) - EccInit(); + if(_sectorSuffixDdt != null) EccInit(); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NoError; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NoError; - if(_imageInfo.MediaType is MediaType.CD or MediaType.CDDA or MediaType.CDG or MediaType.CDEG or MediaType.CDI - or MediaType.CDROM or MediaType.CDROMXA or MediaType.CDPLUS or MediaType.CDMO - or MediaType.CDR or MediaType.CDRW or MediaType.CDMRW or MediaType.VCD or MediaType.SVCD - or MediaType.PCD or MediaType.DTSCD or MediaType.CDMIDI or MediaType.CDV - or MediaType.CDIREADY or MediaType.FMTOWNS or MediaType.PS1CD or MediaType.PS2CD - or MediaType.MEGACD or MediaType.SATURNCD or MediaType.GDROM or MediaType.GDR - or MediaType.MilCD or MediaType.SuperCDROM2 or MediaType.JaguarCD or MediaType.ThreeDO - or MediaType.PCFX or MediaType.NeoGeoCD or MediaType.CDTV or MediaType.CD32 - or MediaType.Playdia or MediaType.Pippin or MediaType.VideoNow - or MediaType.VideoNowColor or MediaType.VideoNowXp or MediaType.CVD) + if(_imageInfo.MediaType is MediaType.CD + or MediaType.CDDA + or MediaType.CDG + or MediaType.CDEG + or MediaType.CDI + or MediaType.CDROM + or MediaType.CDROMXA + or MediaType.CDPLUS + or MediaType.CDMO + or MediaType.CDR + or MediaType.CDRW + or MediaType.CDMRW + or MediaType.VCD + or MediaType.SVCD + or MediaType.PCD + or MediaType.DTSCD + or MediaType.CDMIDI + or MediaType.CDV + or MediaType.CDIREADY + or MediaType.FMTOWNS + or MediaType.PS1CD + or MediaType.PS2CD + or MediaType.MEGACD + or MediaType.SATURNCD + or MediaType.GDROM + or MediaType.GDR + or MediaType.MilCD + or MediaType.SuperCDROM2 + or MediaType.JaguarCD + or MediaType.ThreeDO + or MediaType.PCFX + or MediaType.NeoGeoCD + or MediaType.CDTV + or MediaType.CD32 + or MediaType.Playdia + or MediaType.Pippin + or MediaType.VideoNow + or MediaType.VideoNowColor + or MediaType.VideoNowXp + or MediaType.CVD) return ErrorNumber.NoError; { @@ -1593,8 +1691,7 @@ public sealed partial class AaruFormat { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; ulong ddtEntry = GetDdtEntry(sectorAddress); var offsetMask = (uint)((1 << _shift) - 1); @@ -1651,7 +1748,8 @@ public sealed partial class AaruFormat { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, - blockHeader.length, decompressedLength); + blockHeader.length, + decompressedLength); return ErrorNumber.InOutError; } @@ -1669,7 +1767,8 @@ public sealed partial class AaruFormat { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, - blockHeader.length, decompressedLength); + blockHeader.length, + decompressedLength); return ErrorNumber.InOutError; } @@ -1711,8 +1810,7 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); @@ -1726,8 +1824,7 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); @@ -1741,11 +1838,9 @@ public sealed partial class AaruFormat { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -1753,8 +1848,7 @@ public sealed partial class AaruFormat { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -1777,11 +1871,9 @@ public sealed partial class AaruFormat { Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector); - if(trk is null) - return ErrorNumber.SectorNotFound; + if(trk is null) return ErrorNumber.SectorNotFound; - if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) - return ErrorNumber.SectorNotFound; + if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) return ErrorNumber.SectorNotFound; switch(tag) { @@ -1802,8 +1894,7 @@ public sealed partial class AaruFormat case SectorTagType.DvdTitleKeyDecrypted: break; case SectorTagType.CdTrackFlags: - if(!_trackFlags.TryGetValue((byte)sectorAddress, out byte flags)) - return ErrorNumber.NoData; + if(!_trackFlags.TryGetValue((byte)sectorAddress, out byte flags)) return ErrorNumber.NoData; buffer = new[] { @@ -1812,8 +1903,7 @@ public sealed partial class AaruFormat return ErrorNumber.NoError; case SectorTagType.CdTrackIsrc: - if(!_trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc)) - return ErrorNumber.NoData; + if(!_trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc)) return ErrorNumber.NoData; buffer = Encoding.UTF8.GetBytes(isrc); @@ -2070,8 +2160,7 @@ public sealed partial class AaruFormat else return ErrorNumber.NoData; - if(dataSource == null) - return ErrorNumber.NotSupported; + if(dataSource == null) return ErrorNumber.NotSupported; buffer = new byte[sectorSize * length]; @@ -2084,8 +2173,11 @@ public sealed partial class AaruFormat for(var i = 0; i < length; i++) { - Array.Copy(dataSource, (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip) + sectorOffset), - buffer, i * sectorSize, sectorSize); + Array.Copy(dataSource, + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip) + sectorOffset), + buffer, + i * sectorSize, + sectorSize); } return ErrorNumber.NoError; @@ -2096,13 +2188,11 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); - if(trk?.Sequence != track) - return ErrorNumber.SectorNotFound; + if(trk?.Sequence != track) return ErrorNumber.SectorNotFound; return trk.StartSector + sectorAddress + length > trk.EndSector + 1 ? ErrorNumber.OutOfRange @@ -2115,17 +2205,14 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); return trk?.Sequence != track ? ErrorNumber.SectorNotFound - : - trk.StartSector + sectorAddress + length > trk.EndSector + 1 - ? - ErrorNumber.OutOfRange + : trk.StartSector + sectorAddress + length > trk.EndSector + 1 + ? ErrorNumber.OutOfRange : ReadSectorsTag(trk.StartSector + sectorAddress, length, tag, out buffer); } @@ -2139,11 +2226,9 @@ public sealed partial class AaruFormat case MetadataMediaType.OpticalDisc: Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector); - if(trk is null) - return ErrorNumber.SectorNotFound; + if(trk is null) return ErrorNumber.SectorNotFound; - if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) - return ErrorNumber.SectorNotFound; + if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) return ErrorNumber.SectorNotFound; if((_sectorSuffix == null || _sectorPrefix == null) && (_sectorSuffixDdt == null || _sectorPrefixDdt == null)) @@ -2152,8 +2237,7 @@ public sealed partial class AaruFormat buffer = new byte[2352]; ErrorNumber errno = ReadSector(sectorAddress, out byte[] data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; switch(trk.Type) { @@ -2180,8 +2264,7 @@ public sealed partial class AaruFormat { uint prefixPosition = ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; - if(prefixPosition > _sectorPrefixMs.Length) - return ErrorNumber.InvalidArgument; + if(prefixPosition > _sectorPrefixMs.Length) return ErrorNumber.InvalidArgument; _sectorPrefixMs.Position = prefixPosition; @@ -2206,8 +2289,7 @@ public sealed partial class AaruFormat { uint suffixPosition = ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; - if(suffixPosition > _sectorSuffixMs.Length) - return ErrorNumber.InvalidArgument; + if(suffixPosition > _sectorSuffixMs.Length) return ErrorNumber.InvalidArgument; _sectorSuffixMs.Position = suffixPosition; @@ -2236,8 +2318,7 @@ public sealed partial class AaruFormat { uint prefixPosition = ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; - if(prefixPosition > _sectorPrefixMs.Length) - return ErrorNumber.InvalidArgument; + if(prefixPosition > _sectorPrefixMs.Length) return ErrorNumber.InvalidArgument; _sectorPrefixMs.Position = prefixPosition; @@ -2337,8 +2418,7 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); @@ -2359,14 +2439,11 @@ public sealed partial class AaruFormat case MetadataMediaType.OpticalDisc: Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector); - if(trk is null) - return ErrorNumber.SectorNotFound; + if(trk is null) return ErrorNumber.SectorNotFound; - if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) - return ErrorNumber.SectorNotFound; + if(trk.Sequence == 0 && trk.StartSector == 0 && trk.EndSector == 0) return ErrorNumber.SectorNotFound; - if(sectorAddress + length > trk.EndSector + 1) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > trk.EndSector + 1) return ErrorNumber.OutOfRange; switch(trk.Type) { @@ -2382,8 +2459,7 @@ public sealed partial class AaruFormat buffer = new byte[2352 * length]; errno = ReadSectors(sectorAddress, length, out data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; for(uint i = 0; i < length; i++) { @@ -2391,8 +2467,11 @@ public sealed partial class AaruFormat Array.Copy(data, (int)(i * 2048), buffer, (int)(i * 2352) + 16, 2048); - Array.Copy(_sectorSuffix, (int)((sectorAddress + i) * 288), buffer, - (int)(i * 2352) + 2064, 288); + Array.Copy(_sectorSuffix, + (int)((sectorAddress + i) * 288), + buffer, + (int)(i * 2352) + 2064, + 288); } return ErrorNumber.NoError; @@ -2407,8 +2486,7 @@ public sealed partial class AaruFormat { errno = ReadSectorLong(sectorAddress + i, out byte[] temp); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(temp, 0, buffer, 2352 * i, 2352); } @@ -2424,8 +2502,7 @@ public sealed partial class AaruFormat buffer = new byte[2352 * length]; errno = ReadSectors(sectorAddress, length, out data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; for(uint i = 0; i < length; i++) { @@ -2446,8 +2523,7 @@ public sealed partial class AaruFormat { errno = ReadSectorLong(sectorAddress + i, out byte[] temp); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(temp, 0, buffer, 2352 * i, 2352); } @@ -2466,8 +2542,7 @@ public sealed partial class AaruFormat case MediaType.AppleSonyDS: case MediaType.AppleWidget: case MediaType.PriamDataTower: - if(_sectorSubchannel == null) - return ReadSector(sectorAddress, out buffer); + if(_sectorSubchannel == null) return ReadSector(sectorAddress, out buffer); uint tagSize = 0; @@ -2493,15 +2568,17 @@ public sealed partial class AaruFormat uint sectorSize = 512 + tagSize; errno = ReadSectors(sectorAddress, length, out data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; buffer = new byte[(sectorSize + 512) * length]; for(uint i = 0; i < length; i++) { - Array.Copy(_sectorSubchannel, (int)((sectorAddress + i) * tagSize), buffer, - (int)(i * sectorSize + 512), tagSize); + Array.Copy(_sectorSubchannel, + (int)((sectorAddress + i) * tagSize), + buffer, + (int)(i * sectorSize + 512), + tagSize); Array.Copy(data, (int)((sectorAddress + i) * 512), buffer, (int)(i * 512), 512); } @@ -2520,17 +2597,14 @@ public sealed partial class AaruFormat { buffer = null; - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return ErrorNumber.NotSupported; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return ErrorNumber.NotSupported; Track trk = Tracks.FirstOrDefault(t => t.Sequence == track); return trk?.Sequence != track ? ErrorNumber.SectorNotFound - : - trk.StartSector + sectorAddress + length > trk.EndSector + 1 - ? - ErrorNumber.OutOfRange + : trk.StartSector + sectorAddress + length > trk.EndSector + 1 + ? ErrorNumber.OutOfRange : ReadSectorsLong(trk.StartSector + sectorAddress, length, out buffer); } diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs index 333ea370b..3c8a4f823 100644 --- a/Aaru.Images/AaruFormat/Verify.cs +++ b/Aaru.Images/AaruFormat/Verify.cs @@ -62,7 +62,9 @@ public sealed partial class AaruFormat return false; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Index_at_0_contains_1_entries, _header.indexOffset, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Index_at_0_contains_1_entries, + _header.indexOffset, idxHeader.entries); _structureBytes = new byte[Marshal.SizeOf() * idxHeader.entries]; @@ -71,8 +73,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != idxHeader.crc64) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Expected_index_CRC_0_X16_but_got_1_X16, - idxHeader.crc64, BitConverter.ToUInt64(verifyCrc, 0)); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Expected_index_CRC_0_X16_but_got_1_X16, + idxHeader.crc64, + BitConverter.ToUInt64(verifyCrc, 0)); return false; } @@ -87,8 +91,11 @@ public sealed partial class AaruFormat _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Block_type_0_with_data_type_1_is_indexed_to_be_at_2, - entry.blockType, entry.dataType, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Block_type_0_with_data_type_1_is_indexed_to_be_at_2, + entry.blockType, + entry.dataType, + entry.offset); vrIndex.Add(entry); } @@ -113,8 +120,10 @@ public sealed partial class AaruFormat crcVerify = new Crc64Context(); readBytes = 0; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Verifying_data_block_type_0_at_position_1, - entry.dataType, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Verifying_data_block_type_0_at_position_1, + entry.dataType, + entry.offset); while(readBytes + verifySize < blockHeader.cmpLength) { @@ -132,8 +141,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != blockHeader.cmpCrc64) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Expected_block_CRC_0_X16_but_got_1_X16, - blockHeader.cmpCrc64, BitConverter.ToUInt64(verifyCrc, 0)); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Expected_block_CRC_0_X16_but_got_1_X16, + blockHeader.cmpCrc64, + BitConverter.ToUInt64(verifyCrc, 0)); return false; } @@ -149,7 +160,8 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Verifying_deduplication_table_type_0_at_position_1, - entry.dataType, entry.offset); + entry.dataType, + entry.offset); while(readBytes + verifySize < ddtHeader.cmpLength) { @@ -167,8 +179,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != ddtHeader.cmpCrc64) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Expected_DDT_CRC_0_but_got_1, - ddtHeader.cmpCrc64, BitConverter.ToUInt64(verifyCrc, 0)); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Expected_DDT_CRC_0_but_got_1, + ddtHeader.cmpCrc64, + BitConverter.ToUInt64(verifyCrc, 0)); return false; } @@ -179,8 +193,10 @@ public sealed partial class AaruFormat _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); TracksHeader trkHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Track_block_at_0_contains_1_entries, - _header.indexOffset, trkHeader.entries); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Track_block_at_0_contains_1_entries, + _header.indexOffset, + trkHeader.entries); _structureBytes = new byte[Marshal.SizeOf() * trkHeader.entries]; _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); @@ -188,8 +204,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != trkHeader.crc64) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Expected_index_CRC_0_X16_but_got_1_X16, - trkHeader.crc64, BitConverter.ToUInt64(verifyCrc, 0)); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Expected_index_CRC_0_X16_but_got_1_X16, + trkHeader.crc64, + BitConverter.ToUInt64(verifyCrc, 0)); return false; } @@ -212,8 +230,7 @@ public sealed partial class AaruFormat /// public bool? VerifySector(ulong sectorAddress) { - if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) - return null; + if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) return null; ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer); @@ -230,16 +247,14 @@ public sealed partial class AaruFormat // Right now only CompactDisc sectors are verifiable if(_imageInfo.MetadataMediaType != MetadataMediaType.OpticalDisc) { - for(ulong i = sectorAddress; i < sectorAddress + length; i++) - unknownLbas.Add(i); + for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i); return null; } ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -264,8 +279,7 @@ public sealed partial class AaruFormat } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -280,8 +294,7 @@ public sealed partial class AaruFormat failingLbas = new List(); unknownLbas = new List(); - for(ulong i = sectorAddress; i < sectorAddress + length; i++) - unknownLbas.Add(i); + for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i); return null; } @@ -291,8 +304,7 @@ public sealed partial class AaruFormat ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -315,8 +327,7 @@ public sealed partial class AaruFormat } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index 6bd951252..1ccead4d2 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -221,7 +221,9 @@ public sealed partial class AaruFormat _shift++; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Got_a_shift_of_0_for_1_sectors_per_block, _shift, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Got_a_shift_of_0_for_1_sectors_per_block, + _shift, oldSectorsPerBlock); _imageInfo = new ImageInfo @@ -269,7 +271,8 @@ public sealed partial class AaruFormat if(_header.mediaType != mediaType) { ErrorMessage = string.Format(Localization.Cannot_write_a_media_with_type_0_to_an_image_with_type_1, - mediaType, _header.mediaType); + mediaType, + _header.mediaType); return false; } @@ -329,7 +332,9 @@ public sealed partial class AaruFormat return false; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Index_at_0_contains_1_entries, _header.indexOffset, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Index_at_0_contains_1_entries, + _header.indexOffset, idxHeader.entries); for(ushort i = 0; i < idxHeader.entries; i++) @@ -340,7 +345,9 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Block_type_0_with_data_type_1_is_indexed_to_be_at_2, - entry.blockType, entry.dataType, entry.offset); + entry.blockType, + entry.dataType, + entry.offset); _index.Add(entry); } @@ -358,8 +365,7 @@ public sealed partial class AaruFormat { case BlockType.DataBlock: // NOP block, skip - if(entry.dataType == DataType.NoData) - break; + if(entry.dataType == DataType.NoData) break; _imageStream.Position = (long)entry.offset; @@ -369,8 +375,7 @@ public sealed partial class AaruFormat _imageInfo.ImageSize += blockHeader.cmpLength; // Unused, skip - if(entry.dataType == DataType.UserData) - break; + if(entry.dataType == DataType.UserData) break; if(blockHeader.identifier != entry.blockType) { @@ -384,19 +389,24 @@ public sealed partial class AaruFormat if(blockHeader.type != entry.dataType) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Expected_block_with_data_type_0_at_position_1_but_found_data_type_2, - entry.dataType, entry.offset, blockHeader.type); + Localization + .Expected_block_with_data_type_0_at_position_1_but_found_data_type_2, + entry.dataType, + entry.offset, + blockHeader.type); break; } byte[] data; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_data_block_type_0_at_position_1, - entry.dataType, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_data_block_type_0_at_position_1, + entry.dataType, + entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); // Decompress media tag @@ -407,9 +417,10 @@ public sealed partial class AaruFormat entry.dataType != DataType.CdSectorSubchannel) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Invalid_compression_type_0_for_block_with_data_type_1_continuing, - blockHeader.compression, entry.dataType); + Localization + .Invalid_compression_type_0_for_block_with_data_type_1_continuing, + blockHeader.compression, + entry.dataType); break; } @@ -426,9 +437,10 @@ public sealed partial class AaruFormat if(decompressedLength != blockHeader.length) { ErrorMessage = - string. - Format(Localization.Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, - blockHeader.length, decompressedLength); + string.Format(Localization + .Error_decompressing_block_should_be_0_bytes_but_got_1_bytes, + blockHeader.length, + decompressedLength); return false; } @@ -438,10 +450,12 @@ public sealed partial class AaruFormat decompressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_decompress_block, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_decompress_block, decompressStopwatch.Elapsed.TotalSeconds); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } else if(blockHeader.compression == CompressionType.None) @@ -449,7 +463,8 @@ public sealed partial class AaruFormat data = new byte[blockHeader.length]; _imageStream.EnsureRead(data, 0, (int)blockHeader.length); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } else @@ -467,9 +482,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(blockCrc, 0) != blockHeader.crc64 && blockHeader.crc64 != 0) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(blockCrc, 0), blockHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(blockCrc, 0), + blockHeader.crc64); break; } @@ -493,7 +509,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -522,7 +539,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -532,7 +550,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -544,14 +563,16 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; case DataType.CompactDiscMode2Subheader: _mode2Subheaders = data; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -564,7 +585,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorTitleKey)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorTitleKey); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -574,7 +596,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdTitleKeyDecrypted)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdTitleKeyDecrypted); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -587,7 +610,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorNumber)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorNumber); - AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine("Aaru Format plugin", + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -597,7 +621,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorIed)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorIed); - AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine("Aaru Format plugin", + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -607,7 +632,8 @@ public sealed partial class AaruFormat if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.DvdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.DvdSectorEdc); - AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine("Aaru Format plugin", + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -617,8 +643,8 @@ public sealed partial class AaruFormat if(_mediaTags.ContainsKey(mediaTagType)) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Media_tag_type_0_duplicated_removing_previous_entry, + Localization + .Media_tag_type_0_duplicated_removing_previous_entry, mediaTagType); _mediaTags.Remove(mediaTagType); @@ -626,7 +652,8 @@ public sealed partial class AaruFormat _mediaTags.Add(mediaTagType, data); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -642,15 +669,15 @@ public sealed partial class AaruFormat DdtHeader ddtHeader = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); - if(ddtHeader.identifier != BlockType.DeDuplicationTable) - break; + if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; if(ddtHeader.entries != _imageInfo.Sectors && !IsTape) { ErrorMessage = - string. - Format(Localization.Trying_to_write_a_media_with_0_sectors_to_an_image_with_1_sectors_not_continuing, - _imageInfo.Sectors, ddtHeader.entries); + string.Format(Localization + .Trying_to_write_a_media_with_0_sectors_to_an_image_with_1_sectors_not_continuing, + _imageInfo.Sectors, + ddtHeader.entries); return false; } @@ -678,9 +705,10 @@ public sealed partial class AaruFormat if(decompressedLength != ddtHeader.length) { ErrorMessage = - string. - Format(Localization.Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, - ddtHeader.length, decompressedLength); + string.Format(Localization + .Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, + ddtHeader.length, + decompressedLength); return false; } @@ -725,15 +753,15 @@ public sealed partial class AaruFormat DdtHeader ddtHeader = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); - if(ddtHeader.identifier != BlockType.DeDuplicationTable) - break; + if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; if(ddtHeader.entries != _imageInfo.Sectors) { ErrorMessage = - string. - Format(Localization.Trying_to_write_a_media_with_0_sectors_to_an_image_with_1_sectors_not_continuing, - _imageInfo.Sectors, ddtHeader.entries); + string.Format(Localization + .Trying_to_write_a_media_with_0_sectors_to_an_image_with_1_sectors_not_continuing, + _imageInfo.Sectors, + ddtHeader.entries); return false; } @@ -760,9 +788,10 @@ public sealed partial class AaruFormat if(decompressedLength != ddtHeader.length) { ErrorMessage = - string. - Format(Localization.Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, - ddtHeader.length, decompressedLength); + string.Format(Localization + .Error_decompressing_DDT_should_be_0_bytes_but_got_1_bytes, + ddtHeader.length, + decompressedLength); return false; } @@ -811,16 +840,18 @@ public sealed partial class AaruFormat if(_geometryBlock.identifier == BlockType.GeometryBlock) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Geometry_set_to_0_cylinders_1_heads_2_sectors_per_track, - _geometryBlock.cylinders, _geometryBlock.heads, + Localization + .Geometry_set_to_0_cylinders_1_heads_2_sectors_per_track, + _geometryBlock.cylinders, + _geometryBlock.heads, _geometryBlock.sectorsPerTrack); _imageInfo.Cylinders = _geometryBlock.cylinders; _imageInfo.Heads = _geometryBlock.heads; _imageInfo.SectorsPerTrack = _geometryBlock.sectorsPerTrack; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); } @@ -843,7 +874,8 @@ public sealed partial class AaruFormat break; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_metadata_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_metadata_block_at_position_0, entry.offset); var metadata = new byte[metadataBlock.blockSize]; @@ -855,15 +887,18 @@ public sealed partial class AaruFormat _imageInfo.MediaSequence = metadataBlock.mediaSequence; _imageInfo.LastMediaSequence = metadataBlock.lastMediaSequence; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_sequence_as_0_of_1, - _imageInfo.MediaSequence, _imageInfo.LastMediaSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_sequence_as_0_of_1, + _imageInfo.MediaSequence, + _imageInfo.LastMediaSequence); } if(metadataBlock.creatorLength > 0 && metadataBlock.creatorLength + metadataBlock.creatorOffset <= metadata.Length) { _imageInfo.Creator = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.creatorOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.creatorOffset, (int)(metadataBlock.creatorLength - 2)); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_creator_0, _imageInfo.Creator); @@ -873,10 +908,12 @@ public sealed partial class AaruFormat metadataBlock.commentsLength + metadataBlock.commentsOffset <= metadata.Length) { _imageInfo.Comments = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.commentsOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.commentsOffset, (int)(metadataBlock.commentsLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_comments_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_comments_0, _imageInfo.Comments); } @@ -884,10 +921,12 @@ public sealed partial class AaruFormat metadataBlock.mediaTitleLength + metadataBlock.mediaTitleOffset <= metadata.Length) { _imageInfo.MediaTitle = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaTitleOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaTitleOffset, (int)(metadataBlock.mediaTitleLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_title_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_title_0, _imageInfo.MediaTitle); } @@ -896,10 +935,12 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.MediaManufacturer = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaManufacturerOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaManufacturerOffset, (int)(metadataBlock.mediaManufacturerLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_manufacturer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_manufacturer_0, _imageInfo.MediaManufacturer); } @@ -907,10 +948,12 @@ public sealed partial class AaruFormat metadataBlock.mediaModelLength + metadataBlock.mediaModelOffset <= metadata.Length) { _imageInfo.MediaModel = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaModelOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaModelOffset, (int)(metadataBlock.mediaModelLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_model_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_model_0, _imageInfo.MediaModel); } @@ -919,10 +962,12 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.MediaSerialNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaSerialNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaSerialNumberOffset, (int)(metadataBlock.mediaSerialNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_serial_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_serial_number_0, _imageInfo.MediaSerialNumber); } @@ -930,10 +975,12 @@ public sealed partial class AaruFormat metadataBlock.mediaBarcodeLength + metadataBlock.mediaBarcodeOffset <= metadata.Length) { _imageInfo.MediaBarcode = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaBarcodeOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaBarcodeOffset, (int)(metadataBlock.mediaBarcodeLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_barcode_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_barcode_0, _imageInfo.MediaBarcode); } @@ -941,10 +988,12 @@ public sealed partial class AaruFormat metadataBlock.mediaPartNumberLength + metadataBlock.mediaPartNumberOffset <= metadata.Length) { _imageInfo.MediaPartNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaPartNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.mediaPartNumberOffset, (int)(metadataBlock.mediaPartNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_media_part_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_media_part_number_0, _imageInfo.MediaPartNumber); } @@ -953,10 +1002,12 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.DriveManufacturer = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveManufacturerOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveManufacturerOffset, (int)(metadataBlock.driveManufacturerLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_manufacturer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_manufacturer_0, _imageInfo.DriveManufacturer); } @@ -964,10 +1015,12 @@ public sealed partial class AaruFormat metadataBlock.driveModelLength + metadataBlock.driveModelOffset <= metadata.Length) { _imageInfo.DriveModel = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveModelOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveModelOffset, (int)(metadataBlock.driveModelLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_model_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_model_0, _imageInfo.DriveModel); } @@ -976,10 +1029,12 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.DriveSerialNumber = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveSerialNumberOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveSerialNumberOffset, (int)(metadataBlock.driveSerialNumberLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_serial_number_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_serial_number_0, _imageInfo.DriveSerialNumber); } @@ -988,14 +1043,17 @@ public sealed partial class AaruFormat metadata.Length) { _imageInfo.DriveFirmwareRevision = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveFirmwareRevisionOffset, + Encoding.Unicode.GetString(metadata, + (int)metadataBlock.driveFirmwareRevisionOffset, (int)(metadataBlock.driveFirmwareRevisionLength - 2)); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_drive_firmware_revision_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_drive_firmware_revision_0, _imageInfo.DriveFirmwareRevision); } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1023,9 +1081,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(trksCrc, 0) != tracksHeader.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(trksCrc, 0), tracksHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(trksCrc, 0), + tracksHeader.crc64); break; } @@ -1036,8 +1095,10 @@ public sealed partial class AaruFormat _trackFlags = new Dictionary(); _trackIsrcs = new Dictionary(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_0_tracks_at_position_1, - tracksHeader.entries, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_0_tracks_at_position_1, + tracksHeader.entries, + entry.offset); for(ushort i = 0; i < tracksHeader.entries; i++) { @@ -1058,8 +1119,7 @@ public sealed partial class AaruFormat FileType = "BINARY" }); - if(trackEntry.type == TrackType.Data) - continue; + if(trackEntry.type == TrackType.Data) continue; _trackFlags.Add(trackEntry.sequence, trackEntry.flags); @@ -1076,7 +1136,8 @@ public sealed partial class AaruFormat _imageInfo.HasPartitions = true; _imageInfo.HasSessions = true; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1089,8 +1150,7 @@ public sealed partial class AaruFormat CicmMetadataBlock cicmBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(cicmBlock.identifier != BlockType.CicmBlock) - break; + if(cicmBlock.identifier != BlockType.CicmBlock) break; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CICM_XML_metadata_block_at_position_0, @@ -1101,18 +1161,18 @@ public sealed partial class AaruFormat var cicmMs = new MemoryStream(cicmBytes); // The converter to AaruMetadata basically overcomes this (should?) - #pragma warning disable IL2026 +#pragma warning disable IL2026 var cicmXs = new XmlSerializer(typeof(CICMMetadataType)); - #pragma warning restore IL2026 +#pragma warning restore IL2026 try { var sr = new StreamReader(cicmMs); // The converter to AaruMetadata basically overcomes this (should?) - #pragma warning disable IL2026 +#pragma warning disable IL2026 AaruMetadata = (CICMMetadataType)cicmXs.Deserialize(sr); - #pragma warning restore IL2026 +#pragma warning restore IL2026 sr.Close(); } catch(XmlException ex) @@ -1120,6 +1180,7 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Exception_0_processing_CICM_XML_metadata_block, ex.Message); + AaruConsole.WriteException(ex); AaruMetadata = null; @@ -1135,13 +1196,14 @@ public sealed partial class AaruFormat AaruMetadataJsonBlock aaruMetadataBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(aaruMetadataBlock.identifier != BlockType.AaruMetadataJsonBlock) - break; + if(aaruMetadataBlock.identifier != BlockType.AaruMetadataJsonBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_Aaru_Metadata_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_Aaru_Metadata_block_at_position_0, entry.offset); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); var jsonBytes = new byte[aaruMetadataBlock.length]; @@ -1150,7 +1212,8 @@ public sealed partial class AaruFormat try { AaruMetadata = - (JsonSerializer.Deserialize(jsonBytes, typeof(MetadataJson), + (JsonSerializer.Deserialize(jsonBytes, + typeof(MetadataJson), MetadataJsonContext.Default) as MetadataJson)?.AaruMetadata; } catch(JsonException ex) @@ -1162,7 +1225,8 @@ public sealed partial class AaruFormat AaruMetadata = null; } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1175,10 +1239,10 @@ public sealed partial class AaruFormat DumpHardwareHeader dumpBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(dumpBlock.identifier != BlockType.DumpHardwareBlock) - break; + if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_dump_hardware_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_dump_hardware_block_at_position_0, entry.offset); _structureBytes = new byte[dumpBlock.length]; @@ -1188,9 +1252,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(dumpCrc, 0) != dumpBlock.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(dumpCrc, 0), dumpBlock.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(dumpCrc, 0), + dumpBlock.crc64); break; } @@ -1294,12 +1359,10 @@ public sealed partial class AaruFormat dump.Extents = dump.Extents.OrderBy(t => t.Start).ToList(); - if(dump.Extents.Count > 0) - DumpHardware.Add(dump); + if(dump.Extents.Count > 0) DumpHardware.Add(dump); } - if(DumpHardware.Count == 0) - DumpHardware = null; + if(DumpHardware.Count == 0) DumpHardware = null; break; @@ -1311,10 +1374,10 @@ public sealed partial class AaruFormat TapePartitionHeader partitionHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(partitionHeader.identifier != BlockType.TapePartitionBlock) - break; + if(partitionHeader.identifier != BlockType.TapePartitionBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_tape_partition_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_tape_partition_block_at_position_0, entry.offset); var tapePartitionBytes = new byte[partitionHeader.length]; @@ -1347,10 +1410,10 @@ public sealed partial class AaruFormat TapeFileHeader fileHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(fileHeader.identifier != BlockType.TapeFileBlock) - break; + if(fileHeader.identifier != BlockType.TapeFileBlock) break; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_tape_file_block_at_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_tape_file_block_at_position_0, entry.offset); var tapeFileBytes = new byte[fileHeader.length]; @@ -1384,8 +1447,8 @@ public sealed partial class AaruFormat if(indexesHeader.identifier != BlockType.CompactDiscIndexesBlock) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_identifier_for_compact_disc_indexes_block_at_position_0, + Localization + .Incorrect_identifier_for_compact_disc_indexes_block_at_position_0, entry.offset); break; @@ -1398,9 +1461,10 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(idsxCrc, 0) != indexesHeader.crc64) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, - BitConverter.ToUInt64(idsxCrc, 0), indexesHeader.crc64); + Localization + .Incorrect_CRC_found_0_X16_found_expected_1_X16_continuing, + BitConverter.ToUInt64(idsxCrc, 0), + indexesHeader.crc64); break; } @@ -1409,20 +1473,23 @@ public sealed partial class AaruFormat compactDiscIndexes = new List(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_0_compact_disc_indexes_at_position_1, - indexesHeader.entries, entry.offset); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_0_compact_disc_indexes_at_position_1, + indexesHeader.entries, + entry.offset); for(ushort i = 0; i < indexesHeader.entries; i++) { _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length); - compactDiscIndexes.Add(Marshal. - ByteArrayToStructureLittleEndian< + compactDiscIndexes.Add(Marshal + .ByteArrayToStructureLittleEndian< CompactDiscIndexEntry>(_structureBytes)); } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Memory_snapshot_0_bytes, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Memory_snapshot_0_bytes, GC.GetTotalMemory(false)); break; @@ -1447,8 +1514,7 @@ public sealed partial class AaruFormat _sectorPrefixDdt = null; } - if(!_inMemoryDdt) - _ddtEntryCache = new Dictionary(); + if(!_inMemoryDdt) _ddtEntryCache = new Dictionary(); // Initialize tracks, sessions and partitions if(_imageInfo.MetadataMediaType == MetadataMediaType.OpticalDisc) @@ -1467,7 +1533,8 @@ public sealed partial class AaruFormat Dictionary leadOutStarts = new(); // Lead-out starts foreach(FullTOC.TrackDataDescriptor trk in - decodedFullToc.Value.TrackDescriptors.Where(trk => trk.ADR is 1 or 4 && trk.POINT == 0xA2)) + decodedFullToc.Value.TrackDescriptors.Where(trk => trk.ADR is 1 or 4 && + trk.POINT == 0xA2)) { int phour, pmin, psec, pframe; @@ -1513,8 +1580,8 @@ public sealed partial class AaruFormat { var lastTrackInSession = new Track(); - foreach(Track trk in Tracks.Where(trk => trk.Session == leadOuts.Key). - Where(trk => trk.Sequence > lastTrackInSession.Sequence)) + foreach(Track trk in Tracks.Where(trk => trk.Session == leadOuts.Key) + .Where(trk => trk.Sequence > lastTrackInSession.Sequence)) lastTrackInSession = trk; if(lastTrackInSession.Sequence == 0 || @@ -1620,8 +1687,7 @@ public sealed partial class AaruFormat { ErrorNumber errno = ReadSector(trk.StartSector, out byte[] sector); - if(errno != ErrorNumber.NoError) - continue; + if(errno != ErrorNumber.NoError) continue; trk.BytesPerSector = sector.Length; @@ -1631,8 +1697,7 @@ public sealed partial class AaruFormat ? 2352 : sector.Length; - if(_sectorSubchannel == null) - continue; + if(_sectorSubchannel == null) continue; trk.SubchannelFile = trk.File; trk.SubchannelFilter = trk.Filter; @@ -1647,13 +1712,12 @@ public sealed partial class AaruFormat if(compactDiscIndexes != null) { - foreach(CompactDiscIndexEntry compactDiscIndex in compactDiscIndexes.OrderBy(i => i.Track). - ThenBy(i => i.Index)) + foreach(CompactDiscIndexEntry compactDiscIndex in compactDiscIndexes.OrderBy(i => i.Track) + .ThenBy(i => i.Index)) { Track track = Tracks.FirstOrDefault(t => t.Sequence == compactDiscIndex.Track); - if(track is null) - continue; + if(track is null) continue; track.Indexes[compactDiscIndex.Index] = compactDiscIndex.Lba; } @@ -1715,17 +1779,13 @@ public sealed partial class AaruFormat _imageStream.WriteByte(0); } - if(doMd5) - _md5Provider = new Md5Context(); + if(doMd5) _md5Provider = new Md5Context(); - if(doSha1) - _sha1Provider = new Sha1Context(); + if(doSha1) _sha1Provider = new Sha1Context(); - if(doSha256) - _sha256Provider = new Sha256Context(); + if(doSha256) _sha256Provider = new Sha256Context(); - if(doSpamsum) - _spamsumProvider = new SpamSumContext(); + if(doSpamsum) _spamsumProvider = new SpamSumContext(); } AaruConsole.DebugWriteLine(MODULE_NAME, Localization.In_memory_DDT_0, _inMemoryDdt); @@ -1748,8 +1808,7 @@ public sealed partial class AaruFormat return false; } - if(_mediaTags.ContainsKey(tag)) - _mediaTags.Remove(tag); + if(_mediaTags.ContainsKey(tag)) _mediaTags.Remove(tag); _mediaTags.Add(tag, data); @@ -1793,15 +1852,13 @@ public sealed partial class AaruFormat _lastWrittenBlock = sectorAddress; } - if(sectorAddress == 0) - _alreadyWrittenZero = true; + if(sectorAddress == 0) _alreadyWrittenZero = true; byte[] hash = null; _writtenSectors++; // Compute hash only if asked to deduplicate, or the sector is empty (those will always be deduplicated) - if(_deduplicate || ArrayHelpers.ArrayIsNullOrEmpty(data)) - hash = _checksumProvider.ComputeHash(data); + if(_deduplicate || ArrayHelpers.ArrayIsNullOrEmpty(data)) hash = _checksumProvider.ComputeHash(data); string hashString = null; @@ -1809,8 +1866,7 @@ public sealed partial class AaruFormat { var hashSb = new StringBuilder(); - foreach(byte h in hash) - hashSb.Append(h.ToString("x2")); + foreach(byte h in hash) hashSb.Append(h.ToString("x2")); hashString = hashSb.ToString(); @@ -1862,23 +1918,31 @@ public sealed partial class AaruFormat uint currentSamples = _currentBlockOffset * SAMPLES_PER_SECTOR; uint flacBlockSize = _currentBlockOffset * SAMPLES_PER_SECTOR; - if(flacBlockSize > MAX_FLAKE_BLOCK) - flacBlockSize = MAX_FLAKE_BLOCK; + if(flacBlockSize > MAX_FLAKE_BLOCK) flacBlockSize = MAX_FLAKE_BLOCK; - if(flacBlockSize < MIN_FLAKE_BLOCK) - flacBlockSize = MIN_FLAKE_BLOCK; + if(flacBlockSize < MIN_FLAKE_BLOCK) flacBlockSize = MIN_FLAKE_BLOCK; long remaining = currentSamples % flacBlockSize; // Fill FLAC block if(remaining != 0) { - for(var r = 0; r < remaining * 4; r++) - _writingBuffer[_writingBufferPosition + r] = 0; + for(var r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0; } - compressedLength = FLAC.EncodeBuffer(_writingBuffer, _compressedBuffer, flacBlockSize, true, false, - "hamming", 12, 15, true, false, 0, 8, "Aaru"); + compressedLength = FLAC.EncodeBuffer(_writingBuffer, + _compressedBuffer, + flacBlockSize, + true, + false, + "hamming", + 12, + 15, + true, + false, + 0, + 8, + "Aaru"); if(compressedLength >= _writingBufferPosition) _currentBlockHeader.compression = CompressionType.None; @@ -1887,8 +1951,15 @@ public sealed partial class AaruFormat } case CompressionType.Lzma: { - compressedLength = LZMA.EncodeBuffer(_writingBuffer, _compressedBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + compressedLength = LZMA.EncodeBuffer(_writingBuffer, + _compressedBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); cmpCrc64Context.Update(lzmaProperties); @@ -1982,8 +2053,7 @@ public sealed partial class AaruFormat var ddtEntry = (ulong)((_imageStream.Position << _shift) + _currentBlockOffset); - if(hash != null) - _deduplicationTable.Add(hashString, ddtEntry); + if(hash != null) _deduplicationTable.Add(hashString, ddtEntry); Array.Copy(data, 0, _writingBuffer, _writingBufferPosition, data.Length); _writingBufferPosition += data.Length; @@ -2021,8 +2091,7 @@ public sealed partial class AaruFormat var tmp = new byte[sectorSize]; Array.Copy(data, i * sectorSize, tmp, 0, sectorSize); - if(!WriteSector(tmp, sectorAddress + i)) - return false; + if(!WriteSector(tmp, sectorAddress + i)) return false; } ErrorMessage = ""; @@ -2055,26 +2124,24 @@ public sealed partial class AaruFormat return false; } - if(track.Sequence == 0 && track.StartSector == 0 && track.EndSector == 0) - track.Type = TrackType.Data; + if(track.Sequence == 0 && track.StartSector == 0 && track.EndSector == 0) track.Type = TrackType.Data; - if(data.Length == 2064 && + if(data.Length == 2064 && (_imageInfo.MediaType == MediaType.DVDROM || - _imageInfo.MediaType == MediaType.PS2DVD || - _imageInfo.MediaType == MediaType.SACD || - _imageInfo.MediaType == MediaType.PS3DVD || - _imageInfo.MediaType == MediaType.DVDR || - _imageInfo.MediaType == MediaType.DVDRW || - _imageInfo.MediaType == MediaType.DVDPR || - _imageInfo.MediaType == MediaType.DVDPRW || - _imageInfo.MediaType == MediaType.DVDPRWDL || - _imageInfo.MediaType == MediaType.DVDRDL || - _imageInfo.MediaType == MediaType.DVDPRDL || - _imageInfo.MediaType == MediaType.DVDRAM || - _imageInfo.MediaType == MediaType.DVDRWDL || - _imageInfo.MediaType == MediaType.DVDDownload || - _imageInfo.MediaType == MediaType.Nuon - )) + _imageInfo.MediaType == MediaType.PS2DVD || + _imageInfo.MediaType == MediaType.SACD || + _imageInfo.MediaType == MediaType.PS3DVD || + _imageInfo.MediaType == MediaType.DVDR || + _imageInfo.MediaType == MediaType.DVDRW || + _imageInfo.MediaType == MediaType.DVDPR || + _imageInfo.MediaType == MediaType.DVDPRW || + _imageInfo.MediaType == MediaType.DVDPRWDL || + _imageInfo.MediaType == MediaType.DVDRDL || + _imageInfo.MediaType == MediaType.DVDPRDL || + _imageInfo.MediaType == MediaType.DVDRAM || + _imageInfo.MediaType == MediaType.DVDRWDL || + _imageInfo.MediaType == MediaType.DVDDownload || + _imageInfo.MediaType == MediaType.Nuon)) { sector = new byte[2048]; _sectorId ??= new byte[_imageInfo.Sectors * 4]; @@ -2464,8 +2531,7 @@ public sealed partial class AaruFormat sector = new byte[512]; Array.Copy(data, 0, sector, 0, 512); - if(newTag == null) - return WriteSector(sector, sectorAddress); + if(newTag == null) return WriteSector(sector, sectorAddress); _sectorSubchannel ??= new byte[newTag.Length * (int)_imageInfo.Sectors]; @@ -2520,8 +2586,7 @@ public sealed partial class AaruFormat { Array.Copy(data, 2064 * i, sector, 0, 2064); - if(!WriteSectorLong(sector, sectorAddress + i)) - return false; + if(!WriteSectorLong(sector, sectorAddress + i)) return false; } ErrorMessage = ""; @@ -2542,8 +2607,7 @@ public sealed partial class AaruFormat { Array.Copy(data, 2352 * i, sector, 0, 2352); - if(!WriteSectorLong(sector, sectorAddress + i)) - return false; + if(!WriteSectorLong(sector, sectorAddress + i)) return false; } ErrorMessage = ""; @@ -2565,9 +2629,8 @@ public sealed partial class AaruFormat if(data.Length % 524 == 0) sectorSize = 524; else if(data.Length % 532 == 0) - sectorSize = 532; - else if(data.Length % 536 == 0) - sectorSize = 536; + sectorSize = 532; + else if(data.Length % 536 == 0) sectorSize = 536; if(sectorSize == 0) { @@ -2582,8 +2645,7 @@ public sealed partial class AaruFormat { Array.Copy(data, sectorSize * i, sector, 0, sectorSize); - if(!WriteSectorLong(sector, sectorAddress + i)) - return false; + if(!WriteSectorLong(sector, sectorAddress + i)) return false; } ErrorMessage = ""; @@ -2650,23 +2712,31 @@ public sealed partial class AaruFormat uint currentSamples = _currentBlockOffset * SAMPLES_PER_SECTOR; uint flacBlockSize = _currentBlockOffset * SAMPLES_PER_SECTOR; - if(flacBlockSize > MAX_FLAKE_BLOCK) - flacBlockSize = MAX_FLAKE_BLOCK; + if(flacBlockSize > MAX_FLAKE_BLOCK) flacBlockSize = MAX_FLAKE_BLOCK; - if(flacBlockSize < MIN_FLAKE_BLOCK) - flacBlockSize = MIN_FLAKE_BLOCK; + if(flacBlockSize < MIN_FLAKE_BLOCK) flacBlockSize = MIN_FLAKE_BLOCK; long remaining = currentSamples % flacBlockSize; // Fill FLAC block if(remaining != 0) { - for(var r = 0; r < remaining * 4; r++) - _writingBuffer[_writingBufferPosition + r] = 0; + for(var r = 0; r < remaining * 4; r++) _writingBuffer[_writingBufferPosition + r] = 0; } - compressedLength = FLAC.EncodeBuffer(_writingBuffer, _compressedBuffer, flacBlockSize, true, false, - "hamming", 12, 15, true, false, 0, 8, "Aaru"); + compressedLength = FLAC.EncodeBuffer(_writingBuffer, + _compressedBuffer, + flacBlockSize, + true, + false, + "hamming", + 12, + 15, + true, + false, + 0, + 8, + "Aaru"); if(compressedLength >= _writingBufferPosition) _currentBlockHeader.compression = CompressionType.None; @@ -2675,8 +2745,15 @@ public sealed partial class AaruFormat } case CompressionType.Lzma: { - compressedLength = LZMA.EncodeBuffer(_writingBuffer, _compressedBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + compressedLength = LZMA.EncodeBuffer(_writingBuffer, + _compressedBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); cmpCrc64Context.Update(lzmaProperties); @@ -2731,8 +2808,11 @@ public sealed partial class AaruFormat if(_deduplicate) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Of_0_sectors_written_1_are_unique_2, _writtenSectors, - _deduplicationTable.Count, (double)_deduplicationTable.Count / _writtenSectors); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Of_0_sectors_written_1_are_unique_2, + _writtenSectors, + _deduplicationTable.Count, + (double)_deduplicationTable.Count / _writtenSectors); } IndexEntry idxEntry; @@ -2759,7 +2839,9 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_tag_type_0_to_position_1, mediaTag.Key, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_tag_type_0_to_position_1, + mediaTag.Key, idxEntry.offset); Crc64Context.Data(mediaTag.Value, out byte[] tagCrc); @@ -2780,11 +2862,17 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - int cmpLen = LZMA.EncodeBuffer(mediaTag.Value, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, - 0, 2, 273); + int cmpLen = LZMA.EncodeBuffer(mediaTag.Value, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); - if(cmpLen + LZMA_PROPERTIES_LENGTH > mediaTag.Value.Length) - doNotCompress = true; + if(cmpLen + LZMA_PROPERTIES_LENGTH > mediaTag.Value.Length) doNotCompress = true; break; case CompressionType.None: @@ -2810,8 +2898,7 @@ public sealed partial class AaruFormat tagData = cmpBuffer; var crc64Ctx = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - crc64Ctx.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) crc64Ctx.Update(lzmaProperties); crc64Ctx.Update(tagData); tagCrc = crc64Ctx.Final(); @@ -2819,8 +2906,7 @@ public sealed partial class AaruFormat tagBlock.cmpCrc64 = BitConverter.ToUInt64(tagCrc, 0); tagBlock.compression = _compressionAlgorithm; - if(_compressionAlgorithm == CompressionType.Lzma) - tagBlock.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) tagBlock.cmpLength += LZMA_PROPERTIES_LENGTH; } _structureBytes = new byte[Marshal.SizeOf()]; @@ -2877,17 +2963,13 @@ public sealed partial class AaruFormat if(!string.IsNullOrWhiteSpace(dump.Manufacturer)) dumpManufacturer = Encoding.UTF8.GetBytes(dump.Manufacturer); - if(!string.IsNullOrWhiteSpace(dump.Model)) - dumpModel = Encoding.UTF8.GetBytes(dump.Model); + if(!string.IsNullOrWhiteSpace(dump.Model)) dumpModel = Encoding.UTF8.GetBytes(dump.Model); - if(!string.IsNullOrWhiteSpace(dump.Revision)) - dumpRevision = Encoding.UTF8.GetBytes(dump.Revision); + if(!string.IsNullOrWhiteSpace(dump.Revision)) dumpRevision = Encoding.UTF8.GetBytes(dump.Revision); - if(!string.IsNullOrWhiteSpace(dump.Firmware)) - dumpFirmware = Encoding.UTF8.GetBytes(dump.Firmware); + if(!string.IsNullOrWhiteSpace(dump.Firmware)) dumpFirmware = Encoding.UTF8.GetBytes(dump.Firmware); - if(!string.IsNullOrWhiteSpace(dump.Serial)) - dumpSerial = Encoding.UTF8.GetBytes(dump.Serial); + if(!string.IsNullOrWhiteSpace(dump.Serial)) dumpSerial = Encoding.UTF8.GetBytes(dump.Serial); if(!string.IsNullOrWhiteSpace(dump.Software?.Name)) dumpSoftwareName = Encoding.UTF8.GetBytes(dump.Software.Name); @@ -2977,7 +3059,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_dump_hardware_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_dump_hardware_block_to_position_0, idxEntry.offset); Crc64Context.Data(dumpMs.ToArray(), out byte[] dumpCrc); @@ -3005,10 +3088,13 @@ public sealed partial class AaruFormat { var jsonMs = new MemoryStream(); - JsonSerializer.Serialize(jsonMs, new MetadataJson - { - AaruMetadata = AaruMetadata - }, typeof(MetadataJson), MetadataJsonContext.Default); + JsonSerializer.Serialize(jsonMs, + new MetadataJson + { + AaruMetadata = AaruMetadata + }, + typeof(MetadataJson), + MetadataJsonContext.Default); idxEntry = new IndexEntry { @@ -3017,7 +3103,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_Aaru_Metadata_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_Aaru_Metadata_block_to_position_0, idxEntry.offset); var jsonBlock = new AaruMetadataJsonBlock @@ -3127,7 +3214,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_checksum_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_checksum_block_to_position_0, idxEntry.offset); _structureBytes = new byte[Marshal.SizeOf()]; @@ -3147,8 +3235,7 @@ public sealed partial class AaruFormat _userDataDdt = new ulong[latestBlock + 1]; - foreach(KeyValuePair block in _tapeDdt) - _userDataDdt[block.Key] = block.Value; + foreach(KeyValuePair block in _tapeDdt) _userDataDdt[block.Key] = block.Value; _inMemoryDdt = true; _tapeDdt.Clear(); @@ -3160,7 +3247,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_tape_partitions_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_tape_partitions_to_position_0, idxEntry.offset); var tapePartitionEntries = new TapePartitionEntry[TapePartitions.Count]; @@ -3256,9 +3344,8 @@ public sealed partial class AaruFormat var ddtHeader = new DdtHeader { - identifier = BlockType.DeDuplicationTable, - type = DataType.UserData, - + identifier = BlockType.DeDuplicationTable, + type = DataType.UserData, compression = _compressionAlgorithm, shift = _shift, entries = (ulong)_userDataDdt.LongLength, @@ -3282,7 +3369,14 @@ public sealed partial class AaruFormat break; case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(ddtEntries, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, 0, 2, + cmpLen = LZMA.EncodeBuffer(ddtEntries, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, 273); break; @@ -3337,7 +3431,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_CD_sector_prefix_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_CD_sector_prefix_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorPrefix, out byte[] blockCrc); @@ -3371,8 +3466,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorPrefix, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorPrefix, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3388,8 +3490,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -3403,7 +3504,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_prefix, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_prefix, compressStopwatch.Elapsed.TotalSeconds); } @@ -3428,7 +3530,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_CD_sector_suffix_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_CD_sector_suffix_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorSuffix, out blockCrc); @@ -3460,8 +3563,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorSuffix, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorSuffix, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3477,8 +3587,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -3492,7 +3601,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_suffix, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_suffix, compressStopwatch.Elapsed.TotalSeconds); } @@ -3515,7 +3625,7 @@ public sealed partial class AaruFormat _sectorPrefixMs != null && _sectorPrefixDdt != null) { - #if DEBUG +#if DEBUG uint notDumpedPrefixes = 0; uint correctPrefixes = 0; uint writtenPrefixes = 0; @@ -3540,8 +3650,7 @@ public sealed partial class AaruFormat break; default: { - if((_sectorPrefixDdt[i] & CD_DFIX_MASK) > 0) - writtenPrefixes++; + if((_sectorPrefixDdt[i] & CD_DFIX_MASK) > 0) writtenPrefixes++; break; } @@ -3574,8 +3683,7 @@ public sealed partial class AaruFormat break; default: { - if((_sectorSuffixDdt[i] & CD_DFIX_MASK) > 0) - writtenSuffixes++; + if((_sectorSuffixDdt[i] & CD_DFIX_MASK) > 0) writtenSuffixes++; break; } @@ -3583,26 +3691,35 @@ public sealed partial class AaruFormat } AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - _0_1_prefixes_are_correct_2_3_prefixes_have_not_been_dumped_4_5_prefixes_have_been_written_to_image, - correctPrefixes, correctPrefixes / _imageInfo.Sectors, notDumpedPrefixes, - notDumpedPrefixes / _imageInfo.Sectors, writtenPrefixes, - writtenPrefixes / _imageInfo.Sectors); + Localization + ._0_1_prefixes_are_correct_2_3_prefixes_have_not_been_dumped_4_5_prefixes_have_been_written_to_image, + correctPrefixes, + correctPrefixes / _imageInfo.Sectors, + notDumpedPrefixes, + notDumpedPrefixes / _imageInfo.Sectors, + writtenPrefixes, + writtenPrefixes / _imageInfo.Sectors); AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - _0_1_suffixes_are_correct_2_3_suffixes_have_not_been_dumped_4_5_suffixes_have_been_written_to_image, - correctSuffixes, correctSuffixes / _imageInfo.Sectors, notDumpedSuffixes, - notDumpedSuffixes / _imageInfo.Sectors, writtenSuffixes, - writtenSuffixes / _imageInfo.Sectors); + Localization + ._0_1_suffixes_are_correct_2_3_suffixes_have_not_been_dumped_4_5_suffixes_have_been_written_to_image, + correctSuffixes, + correctSuffixes / _imageInfo.Sectors, + notDumpedSuffixes, + notDumpedSuffixes / _imageInfo.Sectors, + writtenSuffixes, + writtenSuffixes / _imageInfo.Sectors); AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - _0_1_MODE_2_Form_1_are_correct_2_3_MODE_2_Form_2_are_correct_4_5_MODE_2_Form_2_have_empty_CRC, - correctMode2Form1, correctMode2Form1 / _imageInfo.Sectors, - correctMode2Form2, correctMode2Form2 / _imageInfo.Sectors, - emptyMode2Form1, emptyMode2Form1 / _imageInfo.Sectors); - #endif + Localization + ._0_1_MODE_2_Form_1_are_correct_2_3_MODE_2_Form_2_are_correct_4_5_MODE_2_Form_2_have_empty_CRC, + correctMode2Form1, + correctMode2Form1 / _imageInfo.Sectors, + correctMode2Form2, + correctMode2Form2 / _imageInfo.Sectors, + emptyMode2Form1, + emptyMode2Form1 / _imageInfo.Sectors); +#endif idxEntry = new IndexEntry { @@ -3636,8 +3753,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(ddtEntries, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, - 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(ddtEntries, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3653,13 +3777,11 @@ public sealed partial class AaruFormat ddtHeader.cmpLength = (uint)blockStream.Length; - if(_compressionAlgorithm == CompressionType.Lzma) - ddtHeader.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) ddtHeader.cmpLength += LZMA_PROPERTIES_LENGTH; var cmpCrc64Context = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc64Context.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc64Context.Update(lzmaProperties); cmpCrc64Context.Update(blockStream.ToArray()); ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); @@ -3712,8 +3834,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(ddtEntries, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, - 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(ddtEntries, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3729,13 +3858,11 @@ public sealed partial class AaruFormat ddtHeader.cmpLength = (uint)blockStream.Length; - if(_compressionAlgorithm == CompressionType.Lzma) - ddtHeader.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) ddtHeader.cmpLength += LZMA_PROPERTIES_LENGTH; cmpCrc64Context = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc64Context.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc64Context.Update(lzmaProperties); cmpCrc64Context.Update(blockStream.ToArray()); ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); @@ -3800,8 +3927,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(sectorPrefixBuffer, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(sectorPrefixBuffer, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3817,8 +3951,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -3832,7 +3965,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_prefix, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_prefix, compressStopwatch.Elapsed.TotalSeconds); } @@ -3895,8 +4029,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(sectorSuffixBuffer, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(sectorSuffixBuffer, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -3912,8 +4053,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -3927,7 +4067,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_suffix, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_suffix, compressStopwatch.Elapsed.TotalSeconds); } @@ -3994,8 +4135,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_mode2Subheaders, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_mode2Subheaders, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4011,8 +4159,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -4059,7 +4206,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_CD_subchannel_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_CD_subchannel_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorSubchannel, out byte[] blockCrc); @@ -4094,8 +4242,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(transformedSubchannel, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(transformedSubchannel, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4111,8 +4266,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -4129,7 +4283,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_subchannel, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_subchannel, compressStopwatch.Elapsed.TotalSeconds); } @@ -4161,7 +4316,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_DVD_CPR_MAI_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_DVD_CPR_MAI_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorCprMai, out byte[] blockCrc); @@ -4195,8 +4351,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorCprMai, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorCprMai, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4212,8 +4375,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -4227,7 +4389,8 @@ public sealed partial class AaruFormat compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_CPR_MAI, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_CPR_MAI, compressStopwatch.Elapsed.TotalSeconds); } @@ -4256,7 +4419,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_DVD_ID_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_DVD_ID_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorId, out byte[] blockCrc); @@ -4290,8 +4454,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorId, cmpBuffer, out lzmaProperties, 9, _dictionarySize, - 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorId, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4307,22 +4478,21 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); idBlock.cmpLength = (uint)blockStream.Length; - if(_compressionAlgorithm == CompressionType.Lzma) - idBlock.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) idBlock.cmpLength += LZMA_PROPERTIES_LENGTH; idBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); idBlock.compression = _compressionAlgorithm; compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_ID, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_ID, compressStopwatch.Elapsed.TotalSeconds); } @@ -4350,7 +4520,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_DVD_IED_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_DVD_IED_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorIed, out byte[] blockCrc); @@ -4384,8 +4555,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorIed, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorIed, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4401,22 +4579,21 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); iedBlock.cmpLength = (uint)blockStream.Length; - if(_compressionAlgorithm == CompressionType.Lzma) - iedBlock.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) iedBlock.cmpLength += LZMA_PROPERTIES_LENGTH; iedBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); iedBlock.compression = _compressionAlgorithm; compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_IED, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_IED, compressStopwatch.Elapsed.TotalSeconds); } @@ -4444,7 +4621,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_DVD_EDC_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_DVD_EDC_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorEdc, out byte[] blockCrc); @@ -4478,8 +4656,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorEdc, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorEdc, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4495,22 +4680,21 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); edcBlock.cmpLength = (uint)blockStream.Length; - if(_compressionAlgorithm == CompressionType.Lzma) - edcBlock.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_compressionAlgorithm == CompressionType.Lzma) edcBlock.cmpLength += LZMA_PROPERTIES_LENGTH; edcBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); edcBlock.compression = _compressionAlgorithm; compressStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds_to_compress_EDC, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds_to_compress_EDC, compressStopwatch.Elapsed.TotalSeconds); } @@ -4573,8 +4757,15 @@ public sealed partial class AaruFormat switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(_sectorDecryptedTitleKey, cmpBuffer, out lzmaProperties, 9, - _dictionarySize, 4, 0, 2, 273); + cmpLen = LZMA.EncodeBuffer(_sectorDecryptedTitleKey, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273); break; case CompressionType.None: @@ -4590,8 +4781,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -4687,7 +4877,9 @@ public sealed partial class AaruFormat _structureBytes = new byte[Marshal.SizeOf()]; System.Runtime.InteropServices.Marshal.StructureToPtr(entry, _structurePointer, true); - System.Runtime.InteropServices.Marshal.Copy(_structurePointer, _structureBytes, 0, + System.Runtime.InteropServices.Marshal.Copy(_structurePointer, + _structureBytes, + 0, _structureBytes.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(_structurePointer); @@ -4703,7 +4895,8 @@ public sealed partial class AaruFormat crc64 = BitConverter.ToUInt64(trksCrc, 0) }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_tracks_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_tracks_to_position_0, _imageStream.Position); _index.RemoveAll(t => t is { blockType: BlockType.TracksBlock, dataType: DataType.NoData }); @@ -4730,13 +4923,15 @@ public sealed partial class AaruFormat foreach(CompactDiscIndexEntry entry in compactDiscIndexEntries) { _structurePointer = - System.Runtime.InteropServices.Marshal. - AllocHGlobal(Marshal.SizeOf()); + System.Runtime.InteropServices.Marshal + .AllocHGlobal(Marshal.SizeOf()); _structureBytes = new byte[Marshal.SizeOf()]; System.Runtime.InteropServices.Marshal.StructureToPtr(entry, _structurePointer, true); - System.Runtime.InteropServices.Marshal.Copy(_structurePointer, _structureBytes, 0, + System.Runtime.InteropServices.Marshal.Copy(_structurePointer, + _structureBytes, + 0, _structureBytes.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(_structurePointer); @@ -4752,7 +4947,8 @@ public sealed partial class AaruFormat crc64 = BitConverter.ToUInt64(cdixCrc, 0) }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_compact_disc_indexes_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_compact_disc_indexes_to_position_0, _imageStream.Position); _index.RemoveAll(t => t is @@ -4778,8 +4974,12 @@ public sealed partial class AaruFormat break; case MetadataMediaType.BlockMedia: if(_sectorSubchannel != null && - _imageInfo.MediaType is MediaType.AppleFileWare or MediaType.AppleSonySS or MediaType.AppleSonyDS - or MediaType.AppleProfile or MediaType.AppleWidget or MediaType.PriamDataTower) + _imageInfo.MediaType is MediaType.AppleFileWare + or MediaType.AppleSonySS + or MediaType.AppleSonyDS + or MediaType.AppleProfile + or MediaType.AppleWidget + or MediaType.PriamDataTower) { DataType tagType = DataType.NoData; @@ -4809,7 +5009,8 @@ public sealed partial class AaruFormat offset = (ulong)_imageStream.Position }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Writing_apple_sector_tag_block_to_position_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Writing_apple_sector_tag_block_to_position_0, idxEntry.offset); Crc64Context.Data(_sectorSubchannel, out byte[] blockCrc); @@ -4856,8 +5057,15 @@ public sealed partial class AaruFormat int cmpLen = _compressionAlgorithm switch { - CompressionType.Lzma => LZMA.EncodeBuffer(_sectorSubchannel, cmpBuffer, - out lzmaProperties, 9, _dictionarySize, 4, 0, 2, 273), + CompressionType.Lzma => LZMA.EncodeBuffer(_sectorSubchannel, + cmpBuffer, + out lzmaProperties, + 9, + _dictionarySize, + 4, + 0, + 2, + 273), _ => throw new ArgumentOutOfRangeException() }; @@ -4865,8 +5073,7 @@ public sealed partial class AaruFormat var cmpCrc = new Crc64Context(); - if(_compressionAlgorithm == CompressionType.Lzma) - cmpCrc.Update(lzmaProperties); + if(_compressionAlgorithm == CompressionType.Lzma) cmpCrc.Update(lzmaProperties); cmpCrc.Update(blockStream.ToArray()); blockCrc = cmpCrc.Final(); @@ -4920,9 +5127,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.Comments)) @@ -4934,9 +5143,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaTitle)) @@ -4948,9 +5159,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaManufacturer)) @@ -4962,9 +5175,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaModel)) @@ -4976,9 +5191,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaSerialNumber)) @@ -4990,9 +5207,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaBarcode)) @@ -5004,9 +5223,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.MediaPartNumber)) @@ -5018,9 +5239,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) @@ -5032,9 +5255,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) @@ -5046,9 +5271,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.DriveSerialNumber)) @@ -5060,9 +5287,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } if(!string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) @@ -5074,9 +5303,11 @@ public sealed partial class AaruFormat blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); blockStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); } // Check if we set up any metadata earlier, then write its block @@ -5276,8 +5507,7 @@ public sealed partial class AaruFormat track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); - if(track is { Sequence: 0, StartSector: 0, EndSector: 0 }) - track.Type = TrackType.Data; + if(track is { Sequence: 0, StartSector: 0, EndSector: 0 }) track.Type = TrackType.Data; break; } @@ -5300,8 +5530,7 @@ public sealed partial class AaruFormat case SectorTagType.CdTrackIsrc: { - if(data != null) - _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); + if(data != null) _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); return true; } diff --git a/Aaru.Images/Alcohol120/Identify.cs b/Aaru.Images/Alcohol120/Identify.cs index 5b86eb0e6..dd61a23fe 100644 --- a/Aaru.Images/Alcohol120/Identify.cs +++ b/Aaru.Images/Alcohol120/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class Alcohol120 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 88) - return false; + if(stream.Length < 88) return false; var hdr = new byte[88]; stream.EnsureRead(hdr, 0, 88); diff --git a/Aaru.Images/Alcohol120/Properties.cs b/Aaru.Images/Alcohol120/Properties.cs index 79996a493..14498f47d 100644 --- a/Aaru.Images/Alcohol120/Properties.cs +++ b/Aaru.Images/Alcohol120/Properties.cs @@ -60,6 +60,7 @@ public sealed partial class Alcohol120 OpticalImageCapabilities.CanStoreMultipleTracks; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -83,8 +84,7 @@ public sealed partial class Alcohol120 { get { - if(_writingTracks != null && _alcTracks == null) - return _writingTracks; + if(_writingTracks != null && _alcTracks == null) return _writingTracks; List tracks = new(); _alcTracks ??= new Dictionary(); @@ -96,8 +96,7 @@ public sealed partial class Alcohol120 where alcTrack.point >= session.StartTrack && alcTrack.point <= session.EndTrack select session.Sequence).FirstOrDefault(); - if(!_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra)) - continue; + if(!_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra)) continue; var aaruTrack = new CommonTypes.Structs.Track { @@ -115,8 +114,7 @@ public sealed partial class Alcohol120 BytesPerSector = TrackModeToCookedBytesPerSector(alcTrack.mode) }; - if(alcExtra.pregap > 0) - aaruTrack.Indexes.Add(0, (int)(alcTrack.startLba - alcExtra.pregap)); + if(alcExtra.pregap > 0) aaruTrack.Indexes.Add(0, (int)(alcTrack.startLba - alcExtra.pregap)); aaruTrack.Indexes.Add(1, (int)alcTrack.startLba); diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index 78d0c2bb5..0587bbf7b 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -56,8 +56,7 @@ public sealed partial class Alcohol120 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 88) - return ErrorNumber.InvalidArgument; + if(stream.Length < 88) return ErrorNumber.InvalidArgument; _isDvd = false; var hdr = new byte[88]; @@ -92,8 +91,7 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine(MODULE_NAME, "header.sessionOffset = {0}", _header.sessionOffset); AaruConsole.DebugWriteLine(MODULE_NAME, "header.dpmOffset = {0}", _header.dpmOffset); - if(_header.version[0] > MAXIMUM_SUPPORTED_VERSION) - return ErrorNumber.NotSupported; + if(_header.version[0] > MAXIMUM_SUPPORTED_VERSION) return ErrorNumber.NotSupported; stream.Seek(_header.sessionOffset, SeekOrigin.Begin); _alcSessions = new Dictionary(); @@ -143,8 +141,7 @@ public sealed partial class Alcohol120 stream.EnsureRead(trkHdr, 0, 80); Track track = Marshal.ByteArrayToStructureLittleEndian(trkHdr); - if(track.mode is TrackMode.Mode2F1Alt or TrackMode.Mode2F1Alt) - oldIncorrectImage = true; + if(track.mode is TrackMode.Mode2F1Alt or TrackMode.Mode2F1Alt) oldIncorrectImage = true; // Solve our own mistake here, sorry, but anyway seems Alcohol doesn't support DDCD if(track is { zero: > 0, point: >= 1 and <= 99 }) @@ -154,72 +151,125 @@ public sealed partial class Alcohol120 oldIncorrectImage = true; } - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].mode = {0}", track.mode, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].mode = {0}", + track.mode, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].subMode = {0}", track.subMode, - track.point, session.sessionSequence); - - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].adrCtl = {0}", track.adrCtl, - track.point, session.sessionSequence); - - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].tno = {0}", track.tno, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].subMode = {0}", + track.subMode, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].point = {0:X2}", track.point, - track.point, session.sessionSequence); - - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].min = {0}", track.min, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].adrCtl = {0}", + track.adrCtl, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].sec = {0}", track.sec, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].tno = {0}", + track.tno, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].frame = {0}", track.frame, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].point = {0:X2}", + track.point, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].zero = {0}", track.zero, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].min = {0}", + track.min, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].pmin = {0}", track.pmin, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].sec = {0}", + track.sec, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].psec = {0}", track.psec, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].frame = {0}", + track.frame, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].pframe = {0}", track.pframe, - track.point, session.sessionSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].zero = {0}", + track.zero, + track.point, + session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].extraOffset = {0}", track.extraOffset, - track.point, session.sessionSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].pmin = {0}", + track.pmin, + track.point, + session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].sectorSize = {0}", track.sectorSize, - track.point, session.sessionSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].psec = {0}", + track.psec, + track.point, + session.sessionSequence); + + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].pframe = {0}", + track.pframe, + track.point, + session.sessionSequence); + + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].extraOffset = {0}", + track.extraOffset, + track.point, + session.sessionSequence); + + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].sectorSize = {0}", + track.sectorSize, + track.point, + session.sessionSequence); //for(int j = 0; j < track.unknown.Length; j++) // AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].unknown[{2}] = {0}", track.unknown[j], i, j, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].startLba = {0}", track.startLba, - track.point, session.sessionSequence); - - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].startOffset = {0}", track.startOffset, - track.point, session.sessionSequence); - - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].files = {0}", track.files, track.point, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].startLba = {0}", + track.startLba, + track.point, session.sessionSequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].footerOffset = {0}", - track.footerOffset, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].startOffset = {0}", + track.startOffset, + track.point, + session.sessionSequence); + + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].files = {0}", + track.files, + track.point, + session.sessionSequence); + + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{2}].track[{1}].footerOffset = {0}", + track.footerOffset, + track.point, + session.sessionSequence); //for(int j = 0; j < track.unknown2.Length; j++) // AaruConsole.DebugWriteLine(MODULE_NAME, "session[{2}].track[{1}].unknown2[{2}] = {0}", track.unknown2[j], i, j, session.sessionSequence); - if(track.subMode == SubchannelMode.Interleaved) - track.sectorSize -= 96; + if(track.subMode == SubchannelMode.Interleaved) track.sectorSize -= 96; if(track is { point: 1, startLba: > 0 }) { - AaruConsole.ErrorWriteLine(Localization. - The_disc_this_image_represents_contained_a_hidden_track_in_the_first_pregap_that_this_image_format_cannot_store_This_dump_is_therefore_incorrect); + AaruConsole.ErrorWriteLine(Localization + .The_disc_this_image_represents_contained_a_hidden_track_in_the_first_pregap_that_this_image_format_cannot_store_This_dump_is_therefore_incorrect); track1Index1 = track.startLba; track.startLba = 0; @@ -227,11 +277,9 @@ public sealed partial class Alcohol120 sesToc.TryAdd(track.point, track); - if(track.point < 0xA0) - _alcTracks.Add(track.point, track); + if(track.point < 0xA0) _alcTracks.Add(track.point, track); - if(footerOff == 0) - footerOff = track.footerOffset; + if(footerOff == 0) footerOff = track.footerOffset; _isDvd |= track.mode == TrackMode.DVD; } @@ -345,17 +393,13 @@ public sealed partial class Alcohol120 { var session = new CommonTypes.Structs.Session(); - if(!_alcTracks.TryGetValue(alcSes.firstTrack, out Track startingTrack)) - break; + if(!_alcTracks.TryGetValue(alcSes.firstTrack, out Track startingTrack)) break; - if(!_alcTracks.TryGetValue(alcSes.lastTrack, out Track endingTrack)) - break; + if(!_alcTracks.TryGetValue(alcSes.lastTrack, out Track endingTrack)) break; - if(!_alcTrackExtras.TryGetValue(alcSes.firstTrack, out _)) - break; + if(!_alcTrackExtras.TryGetValue(alcSes.firstTrack, out _)) break; - if(!_alcTrackExtras.TryGetValue(alcSes.lastTrack, out TrackExtra endingTrackExtra)) - break; + if(!_alcTrackExtras.TryGetValue(alcSes.lastTrack, out TrackExtra endingTrackExtra)) break; session.StartSector = startingTrack.startLba; session.StartTrack = alcSes.firstTrack; @@ -365,8 +409,7 @@ public sealed partial class Alcohol120 Sessions.Add(session); - if(session.EndSector > _imageInfo.Sectors) - _imageInfo.Sectors = session.EndSector + 1; + if(session.EndSector > _imageInfo.Sectors) _imageInfo.Sectors = session.EndSector + 1; } if(_isDvd) @@ -420,9 +463,8 @@ public sealed partial class Alcohol120 }; if(DMI.IsXbox(_dmi)) - _imageInfo.MediaType = MediaType.XGD; - else if(DMI.IsXbox360(_dmi)) - _imageInfo.MediaType = MediaType.XGD2; + _imageInfo.MediaType = MediaType.XGD; + else if(DMI.IsXbox360(_dmi)) _imageInfo.MediaType = MediaType.XGD2; var tmp = new byte[2048]; Array.Copy(_dmi, 4, tmp, 0, 2048); @@ -542,8 +584,7 @@ public sealed partial class Alcohol120 if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; break; case TrackMode.Mode2: @@ -556,8 +597,7 @@ public sealed partial class Alcohol120 if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(_imageInfo.SectorSize < 2336) - _imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) _imageInfo.SectorSize = 2336; break; case TrackMode.Mode2F2: @@ -574,8 +614,7 @@ public sealed partial class Alcohol120 if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2324) - _imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) _imageInfo.SectorSize = 2324; break; case TrackMode.DVD: @@ -640,17 +679,17 @@ public sealed partial class Alcohol120 var tocMs = new MemoryStream(); tocMs.Write(new byte[] - { - 0, 0 - }, 0, 2); // Reserved for TOC session numbers + { + 0, 0 + }, + 0, + 2); // Reserved for TOC session numbers foreach(KeyValuePair> sessionToc in _alcToc) { - if(sessionToc.Key < firstSession) - firstSession = (byte)sessionToc.Key; + if(sessionToc.Key < firstSession) firstSession = (byte)sessionToc.Key; - if(sessionToc.Key > lastSession) - lastSession = (byte)sessionToc.Key; + if(sessionToc.Key > lastSession) lastSession = (byte)sessionToc.Key; foreach(Track sessionTrack in sessionToc.Value.Values) { @@ -685,8 +724,8 @@ public sealed partial class Alcohol120 if(oldIncorrectImage) { - AaruConsole.WriteLine(Localization. - Incorrect_Alcohol_120_image_created_by_an_old_version_of_Aaru_Convert_image_to_correct_it); + AaruConsole.WriteLine(Localization + .Incorrect_Alcohol_120_image_created_by_an_old_version_of_Aaru_Convert_image_to_correct_it); } return ErrorNumber.NoError; @@ -746,16 +785,13 @@ public sealed partial class Alcohol120 foreach(KeyValuePair kvp in _offsetMap) { - if(sectorAddress < kvp.Value) - continue; + if(sectorAddress < kvp.Value) continue; foreach(Track track in _alcTracks.Values) { - if(track.point != kvp.Key || !_alcTrackExtras.TryGetValue(track.point, out TrackExtra extra)) - continue; + if(track.point != kvp.Key || !_alcTrackExtras.TryGetValue(track.point, out TrackExtra extra)) continue; - if(sectorAddress - kvp.Value >= extra.sectors + extra.pregap) - continue; + if(sectorAddress - kvp.Value >= extra.sectors + extra.pregap) continue; return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key, out buffer); } @@ -771,16 +807,13 @@ public sealed partial class Alcohol120 foreach(KeyValuePair kvp in _offsetMap) { - if(sectorAddress < kvp.Value) - continue; + if(sectorAddress < kvp.Value) continue; foreach(Track track in _alcTracks.Values) { - if(track.point != kvp.Key || !_alcTrackExtras.TryGetValue(track.point, out TrackExtra extra)) - continue; + if(track.point != kvp.Key || !_alcTrackExtras.TryGetValue(track.point, out TrackExtra extra)) continue; - if(sectorAddress - kvp.Value >= extra.sectors + extra.pregap) - continue; + if(sectorAddress - kvp.Value >= extra.sectors + extra.pregap) continue; return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer); } @@ -798,8 +831,7 @@ public sealed partial class Alcohol120 !_alcTrackExtras.TryGetValue((int)track, out TrackExtra alcExtra)) return ErrorNumber.OutOfRange; - if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -873,8 +905,7 @@ public sealed partial class Alcohol120 if(alcTrack.point == 1 && alcExtra.pregap > 150) { - if(sectorAddress + 150 < alcExtra.pregap) - return ErrorNumber.NoError; + if(sectorAddress + 150 < alcExtra.pregap) return ErrorNumber.NoError; sectorAddress -= alcExtra.pregap - 150; } @@ -882,8 +913,7 @@ public sealed partial class Alcohol120 uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip); var fileOffset = (long)alcTrack.startOffset; - if(alcTrack.startOffset >= pregapBytes) - fileOffset = (long)(alcTrack.startOffset - pregapBytes); + if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); _imageStream = _alcImage.GetDataForkStream(); var br = new BinaryReader(_imageStream); @@ -929,22 +959,19 @@ public sealed partial class Alcohol120 { buffer = null; - if(tag == SectorTagType.CdTrackFlags) - track = (uint)sectorAddress; + if(tag == SectorTagType.CdTrackFlags) track = (uint)sectorAddress; if(!_alcTracks.TryGetValue((int)track, out Track alcTrack) || !_alcTrackExtras.TryGetValue((int)track, out TrackExtra alcExtra)) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; uint sectorSkip; - if(alcTrack.mode == TrackMode.DVD) - return ErrorNumber.NotSupported; + if(alcTrack.mode == TrackMode.DVD) return ErrorNumber.NotSupported; switch(tag) { @@ -1300,8 +1327,7 @@ public sealed partial class Alcohol120 break; case SubchannelMode.Interleaved: - if(tag != SectorTagType.CdSectorSubchannel) - sectorSkip += 96; + if(tag != SectorTagType.CdSectorSubchannel) sectorSkip += 96; break; default: @@ -1312,8 +1338,7 @@ public sealed partial class Alcohol120 if(alcTrack.point == 1 && alcExtra.pregap > 150) { - if(sectorAddress + 150 < alcExtra.pregap) - return ErrorNumber.NoError; + if(sectorAddress + 150 < alcExtra.pregap) return ErrorNumber.NoError; sectorAddress -= alcExtra.pregap - 150; } @@ -1321,8 +1346,7 @@ public sealed partial class Alcohol120 uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip); var fileOffset = (long)alcTrack.startOffset; - if(alcTrack.startOffset >= pregapBytes) - fileOffset = (long)(alcTrack.startOffset - pregapBytes); + if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); _imageStream = _alcImage.GetDataForkStream(); var br = new BinaryReader(_imageStream); @@ -1361,16 +1385,14 @@ public sealed partial class Alcohol120 foreach(KeyValuePair kvp in _offsetMap) { - if(sectorAddress < kvp.Value) - continue; + if(sectorAddress < kvp.Value) continue; foreach(Track alcTrack in _alcTracks.Values) { if(alcTrack.point != kvp.Key || !_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra)) continue; - if(sectorAddress - kvp.Value >= alcExtra.sectors + alcExtra.pregap) - continue; + if(sectorAddress - kvp.Value >= alcExtra.sectors + alcExtra.pregap) continue; return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key, out buffer); } @@ -1388,8 +1410,7 @@ public sealed partial class Alcohol120 !_alcTrackExtras.TryGetValue((int)track, out TrackExtra alcExtra)) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > alcExtra.sectors + alcExtra.pregap) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -1419,15 +1440,13 @@ public sealed partial class Alcohol120 return ErrorNumber.NotSupported; } - if(alcTrack.subMode == SubchannelMode.Interleaved) - sectorSkip = 96; + if(alcTrack.subMode == SubchannelMode.Interleaved) sectorSkip = 96; buffer = new byte[sectorSize * length]; if(alcTrack.point == 1 && alcExtra.pregap > 150) { - if(sectorAddress + 150 < alcExtra.pregap) - return ErrorNumber.NoError; + if(sectorAddress + 150 < alcExtra.pregap) return ErrorNumber.NoError; sectorAddress -= alcExtra.pregap - 150; } @@ -1435,8 +1454,7 @@ public sealed partial class Alcohol120 uint pregapBytes = alcExtra.pregap * (sectorSize + sectorSkip); var fileOffset = (long)alcTrack.startOffset; - if(alcTrack.startOffset >= pregapBytes) - fileOffset = (long)(alcTrack.startOffset - pregapBytes); + if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); _imageStream = _alcImage.GetDataForkStream(); var br = new BinaryReader(_imageStream); @@ -1476,8 +1494,7 @@ public sealed partial class Alcohol120 where alcTrack.point >= ses.StartTrack || alcTrack.point <= ses.EndTrack select ses.Sequence).FirstOrDefault(); - if(!_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra) || session != sessionNo) - continue; + if(!_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra) || session != sessionNo) continue; var aaruTrack = new CommonTypes.Structs.Track { @@ -1495,8 +1512,7 @@ public sealed partial class Alcohol120 BytesPerSector = TrackModeToCookedBytesPerSector(alcTrack.mode) }; - if(alcExtra.pregap > 0) - aaruTrack.Indexes.Add(0, (int)(alcTrack.startLba - alcExtra.pregap)); + if(alcExtra.pregap > 0) aaruTrack.Indexes.Add(0, (int)(alcTrack.startLba - alcExtra.pregap)); aaruTrack.Indexes.Add(1, (int)alcTrack.startLba); diff --git a/Aaru.Images/Alcohol120/Verify.cs b/Aaru.Images/Alcohol120/Verify.cs index 47e390d09..a546008b2 100644 --- a/Aaru.Images/Alcohol120/Verify.cs +++ b/Aaru.Images/Alcohol120/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class Alcohol120 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class Alcohol120 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class Alcohol120 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class Alcohol120 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index 2f68cf7a2..3ea3a792a 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -73,9 +73,11 @@ public sealed partial class Alcohol120 _descriptorStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None); _imageStream = - new - FileStream(Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)) + ".mdf", - FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + new FileStream(Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)) + + ".mdf", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, + FileShare.None); } catch(IOException ex) { @@ -158,7 +160,8 @@ public sealed partial class Alcohol120 case MediaTagType.CD_FullTOC: if(_isDvd) { - ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, tag, + ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, + tag, _imageInfo.MediaType); return false; @@ -170,7 +173,8 @@ public sealed partial class Alcohol120 case MediaTagType.DVD_PFI: if(!_isDvd) { - ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, tag, + ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, + tag, _imageInfo.MediaType); return false; @@ -182,7 +186,8 @@ public sealed partial class Alcohol120 case MediaTagType.DVD_DMI: if(!_isDvd) { - ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, tag, + ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, + tag, _imageInfo.MediaType); return false; @@ -194,7 +199,8 @@ public sealed partial class Alcohol120 case MediaTagType.DVD_BCA: if(!_isDvd) { - ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, tag, + ErrorMessage = string.Format(Localization.Unsupported_media_tag_0_for_medium_type_1, + tag, _imageInfo.MediaType); return false; @@ -251,9 +257,9 @@ public sealed partial class Alcohol120 return false; } - _imageStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -311,9 +317,9 @@ public sealed partial class Alcohol120 switch(track.SubchannelType) { case TrackSubchannelType.None: - _imageStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -322,9 +328,9 @@ public sealed partial class Alcohol120 return true; case TrackSubchannelType.Raw: case TrackSubchannelType.RawInterleaved: - _imageStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), + SeekOrigin.Begin); for(uint i = 0; i < length; i++) { @@ -371,9 +377,10 @@ public sealed partial class Alcohol120 var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); - _imageStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + subchannelSize)), + SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -418,9 +425,10 @@ public sealed partial class Alcohol120 for(uint i = 0; i < length; i++) { - _imageStream. - Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (i + sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + subchannelSize)), + SeekOrigin.Begin); _imageStream.Write(data, (int)(i * track.RawBytesPerSector), track.RawBytesPerSector); } @@ -444,13 +452,11 @@ public sealed partial class Alcohol120 CommonTypes.Structs.Track firstTrackInSession = tracks.FirstOrDefault(t => t.Session == tmpTracks[i].Session); - if(firstTrackInSession is null) - continue; + if(firstTrackInSession is null) continue; if(tmpTracks[i].Sequence == firstTrackInSession.Sequence) { - if(tmpTracks[i].Sequence > 1) - tmpTracks[i].StartSector += 150; + if(tmpTracks[i].Sequence > 1) tmpTracks[i].StartSector += 150; continue; } @@ -571,8 +577,7 @@ public sealed partial class Alcohol120 extraCount += _writingTracks.Count(t => t.Session == i); - if(i >= sessions) - continue; + if(i >= sessions) continue; currentExtraOffset += Marshal.SizeOf() * 2; extraCount += 2; @@ -589,34 +594,35 @@ public sealed partial class Alcohol120 if(_isDvd) { - _alcSessions.Add(1, new Session - { - sessionEnd = (int)(_writingTracks[0].EndSector - _writingTracks[0].StartSector + 1), - sessionSequence = 1, - allBlocks = 1, - nonTrackBlocks = 3, - firstTrack = 1, - lastTrack = 1, - trackOffset = 4220 - }); + _alcSessions.Add(1, + new Session + { + sessionEnd = (int)(_writingTracks[0].EndSector - _writingTracks[0].StartSector + 1), + sessionSequence = 1, + allBlocks = 1, + nonTrackBlocks = 3, + firstTrack = 1, + lastTrack = 1, + trackOffset = 4220 + }); footerOffset = 4300; - if(_bca != null) - footerOffset += _bca.Length; + if(_bca != null) footerOffset += _bca.Length; - _alcTracks.Add(1, new Track - { - mode = TrackMode.DVD, - adrCtl = 20, - point = 1, - extraOffset = (uint)(_writingTracks[0].EndSector - _writingTracks[0].StartSector + 1), - sectorSize = 2048, - files = 1, - footerOffset = (uint)footerOffset, - unknown = new byte[18], - unknown2 = new byte[24] - }); + _alcTracks.Add(1, + new Track + { + mode = TrackMode.DVD, + adrCtl = 20, + point = 1, + extraOffset = (uint)(_writingTracks[0].EndSector - _writingTracks[0].StartSector + 1), + sectorSize = 2048, + files = 1, + footerOffset = (uint)footerOffset, + unknown = new byte[18], + unknown2 = new byte[24] + }); _alcToc.Add(1, _alcTracks); } @@ -627,21 +633,23 @@ public sealed partial class Alcohol120 CommonTypes.Structs.Track firstTrack = _writingTracks.First(t => t.Session == i); CommonTypes.Structs.Track lastTrack = _writingTracks.Last(t => t.Session == i); - _alcSessions.Add(i, new Session - { - sessionStart = (int)firstTrack.StartSector - 150, - sessionEnd = (int)lastTrack.EndSector + 1, - sessionSequence = (ushort)i, - allBlocks = (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i) ?? - _writingTracks.Count(t => t.Session == i) + 3), - nonTrackBlocks = - (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i && - t.POINT is >= 0xA0 and <= 0xAF) ?? - 3), - firstTrack = (ushort)firstTrack.Sequence, - lastTrack = (ushort)lastTrack.Sequence, - trackOffset = (uint)currentTrackOffset - }); + _alcSessions.Add(i, + new Session + { + sessionStart = (int)firstTrack.StartSector - 150, + sessionEnd = (int)lastTrack.EndSector + 1, + sessionSequence = (ushort)i, + allBlocks = + (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i) ?? + _writingTracks.Count(t => t.Session == i) + 3), + nonTrackBlocks = + (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i && + t.POINT is >= 0xA0 and <= 0xAF) ?? + 3), + firstTrack = (ushort)firstTrack.Sequence, + lastTrack = (ushort)lastTrack.Sequence, + trackOffset = (uint)currentTrackOffset + }); Dictionary thisSessionTracks = new(); _trackFlags.TryGetValue((byte)firstTrack.Sequence, out byte firstTrackControl); @@ -659,26 +667,27 @@ public sealed partial class Alcohol120 true) { foreach(FullTOC.TrackDataDescriptor tocTrk in - decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && - t.POINT is >= 0xA0 and <= 0xAF)) + decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && + t.POINT is >= 0xA0 and <= 0xAF)) { - thisSessionTracks.Add(tocTrk.POINT, new Track - { - adrCtl = (byte)((tocTrk.ADR << 4) + tocTrk.CONTROL), - tno = tocTrk.TNO, - point = tocTrk.POINT, - min = tocTrk.Min, - sec = tocTrk.Sec, - frame = tocTrk.Frame, - zero = tocTrk.Zero, - pmin = tocTrk.PMIN, - psec = tocTrk.PSEC, - pframe = tocTrk.PFRAME, - mode = TrackMode.NoData, - unknown = new byte[18], - unknown2 = new byte[24], - extraOffset = (uint)currentExtraOffset - }); + thisSessionTracks.Add(tocTrk.POINT, + new Track + { + adrCtl = (byte)((tocTrk.ADR << 4) + tocTrk.CONTROL), + tno = tocTrk.TNO, + point = tocTrk.POINT, + min = tocTrk.Min, + sec = tocTrk.Sec, + frame = tocTrk.Frame, + zero = tocTrk.Zero, + pmin = tocTrk.PMIN, + psec = tocTrk.PSEC, + pframe = tocTrk.PFRAME, + mode = TrackMode.NoData, + unknown = new byte[18], + unknown2 = new byte[24], + extraOffset = (uint)currentExtraOffset + }); currentTrackOffset += Marshal.SizeOf(); currentExtraOffset += Marshal.SizeOf(); @@ -686,51 +695,59 @@ public sealed partial class Alcohol120 } else { - thisSessionTracks.Add(0xA0, new Track - { - adrCtl = (byte)((1 << 4) + firstTrackControl), - pmin = (byte)firstTrack.Sequence, - mode = TrackMode.NoData, - point = 0xA0, - unknown = new byte[18], - unknown2 = new byte[24], - psec = (byte)(_imageInfo.MediaType == MediaType.CDI ? 0x10 : - _writingTracks.Any(t => t.Type is TrackType.CdMode2Form1 or TrackType.CdMode2Form2 - or TrackType.CdMode2Formless) ? 0x20 : 0), - extraOffset = (uint)currentExtraOffset - }); + thisSessionTracks.Add(0xA0, + new Track + { + adrCtl = (byte)((1 << 4) + firstTrackControl), + pmin = (byte)firstTrack.Sequence, + mode = TrackMode.NoData, + point = 0xA0, + unknown = new byte[18], + unknown2 = new byte[24], + psec = (byte)(_imageInfo.MediaType == MediaType.CDI + ? 0x10 + : _writingTracks.Any(t => t.Type is TrackType + .CdMode2Form1 + or TrackType.CdMode2Form2 + or TrackType.CdMode2Formless) + ? 0x20 + : 0), + extraOffset = (uint)currentExtraOffset + }); - thisSessionTracks.Add(0xA1, new Track - { - adrCtl = (byte)((1 << 4) + lastTrackControl), - pmin = (byte)lastTrack.Sequence, - mode = TrackMode.NoData, - point = 0xA1, - unknown = new byte[18], - unknown2 = new byte[24], - extraOffset = (uint)currentExtraOffset - }); + thisSessionTracks.Add(0xA1, + new Track + { + adrCtl = (byte)((1 << 4) + lastTrackControl), + pmin = (byte)lastTrack.Sequence, + mode = TrackMode.NoData, + point = 0xA1, + unknown = new byte[18], + unknown2 = new byte[24], + extraOffset = (uint)currentExtraOffset + }); - thisSessionTracks.Add(0xA2, new Track - { - adrCtl = (byte)((1 << 4) + firstTrackControl), - zero = 0, - pmin = leadinPmsf.minute, - psec = leadinPmsf.second, - pframe = leadinPmsf.frame, - mode = TrackMode.NoData, - point = 0xA2, - unknown = new byte[18], - unknown2 = new byte[24], - extraOffset = (uint)currentExtraOffset - }); + thisSessionTracks.Add(0xA2, + new Track + { + adrCtl = (byte)((1 << 4) + firstTrackControl), + zero = 0, + pmin = leadinPmsf.minute, + psec = leadinPmsf.second, + pframe = leadinPmsf.frame, + mode = TrackMode.NoData, + point = 0xA2, + unknown = new byte[18], + unknown2 = new byte[24], + extraOffset = (uint)currentExtraOffset + }); currentExtraOffset += Marshal.SizeOf() * 3; currentTrackOffset += Marshal.SizeOf() * 3; } - foreach(CommonTypes.Structs.Track track in _writingTracks.Where(t => t.Session == i). - OrderBy(t => t.Sequence)) + foreach(CommonTypes.Structs.Track track in _writingTracks.Where(t => t.Session == i) + .OrderBy(t => t.Sequence)) { var alcTrk = new Track(); @@ -756,8 +773,7 @@ public sealed partial class Alcohol120 (byte minute, byte second, byte frame) msf = LbaToMsf((ulong)track.Indexes[1]); _trackFlags.TryGetValue((byte)track.Sequence, out byte trackControl); - if(trackControl == 0 && track.Type != TrackType.Audio) - trackControl = (byte)CdFlags.DataTrack; + if(trackControl == 0 && track.Type != TrackType.Audio) trackControl = (byte)CdFlags.DataTrack; alcTrk.adrCtl = (byte)((1 << 4) + trackControl); alcTrk.point = (byte)track.Sequence; @@ -830,25 +846,26 @@ public sealed partial class Alcohol120 if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT >= 0xB0) == true) { foreach(FullTOC.TrackDataDescriptor tocTrk in - decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && t.POINT >= 0xB0)) + decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && t.POINT >= 0xB0)) { - thisSessionTracks.Add(tocTrk.POINT, new Track - { - adrCtl = (byte)((tocTrk.ADR << 4) + tocTrk.CONTROL), - tno = tocTrk.TNO, - point = tocTrk.POINT, - min = tocTrk.Min, - sec = tocTrk.Sec, - frame = tocTrk.Frame, - zero = tocTrk.Zero, - pmin = tocTrk.PMIN, - psec = tocTrk.PSEC, - pframe = tocTrk.PFRAME, - mode = TrackMode.NoData, - unknown = new byte[18], - unknown2 = new byte[24], - extraOffset = (uint)currentExtraOffset - }); + thisSessionTracks.Add(tocTrk.POINT, + new Track + { + adrCtl = (byte)((tocTrk.ADR << 4) + tocTrk.CONTROL), + tno = tocTrk.TNO, + point = tocTrk.POINT, + min = tocTrk.Min, + sec = tocTrk.Sec, + frame = tocTrk.Frame, + zero = tocTrk.Zero, + pmin = tocTrk.PMIN, + psec = tocTrk.PSEC, + pframe = tocTrk.PFRAME, + mode = TrackMode.NoData, + unknown = new byte[18], + unknown2 = new byte[24], + extraOffset = (uint)currentExtraOffset + }); currentExtraOffset += Marshal.SizeOf(); currentTrackOffset += Marshal.SizeOf(); @@ -862,31 +879,33 @@ public sealed partial class Alcohol120 (byte minute, byte second, byte frame) leadoutPmsf = LbaToMsf(_writingTracks.OrderBy(t => t.Session).ThenBy(t => t.Sequence).Last().StartSector); - thisSessionTracks.Add(0xB0, new Track - { - point = 0xB0, - adrCtl = 0x50, - zero = 0, - min = leadoutAmsf.minute, - sec = leadoutAmsf.second, - frame = leadoutAmsf.frame, - pmin = leadoutPmsf.minute, - psec = leadoutPmsf.second, - pframe = leadoutPmsf.frame, - unknown = new byte[18], - unknown2 = new byte[24] - }); + thisSessionTracks.Add(0xB0, + new Track + { + point = 0xB0, + adrCtl = 0x50, + zero = 0, + min = leadoutAmsf.minute, + sec = leadoutAmsf.second, + frame = leadoutAmsf.frame, + pmin = leadoutPmsf.minute, + psec = leadoutPmsf.second, + pframe = leadoutPmsf.frame, + unknown = new byte[18], + unknown2 = new byte[24] + }); - thisSessionTracks.Add(0xC0, new Track - { - point = 0xC0, - adrCtl = 0x50, - min = 128, - pmin = 97, - psec = 25, - unknown = new byte[18], - unknown2 = new byte[24] - }); + thisSessionTracks.Add(0xC0, + new Track + { + point = 0xC0, + adrCtl = 0x50, + min = 128, + pmin = 97, + psec = 25, + unknown = new byte[18], + unknown2 = new byte[24] + }); currentTrackOffset += Marshal.SizeOf() * 2; } @@ -927,9 +946,11 @@ public sealed partial class Alcohol120 break; case 2048: _descriptorStream.Write(new byte[] - { - 0x08, 0x02, 0x00, 0x00 - }, 0, 4); + { + 0x08, 0x02, 0x00, 0x00 + }, + 0, + 4); _descriptorStream.Write(_dmi, 0, 2048); @@ -1021,9 +1042,11 @@ public sealed partial class Alcohol120 // Write filename null termination _descriptorStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); _descriptorStream.Flush(); _descriptorStream.Close(); @@ -1100,9 +1123,10 @@ public sealed partial class Alcohol120 return false; } - _imageStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + + track.RawBytesPerSector, + SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -1159,9 +1183,11 @@ public sealed partial class Alcohol120 for(uint i = 0; i < length; i++) { - _imageStream. - Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, - SeekOrigin.Begin); + _imageStream.Seek((long)(track.FileOffset + + (i + sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + 96)) + + track.RawBytesPerSector, + SeekOrigin.Begin); _imageStream.Write(data, (int)(i * 96), 96); } diff --git a/Aaru.Images/Anex86/Identify.cs b/Aaru.Images/Anex86/Identify.cs index e841ddc4c..5064ed2be 100644 --- a/Aaru.Images/Anex86/Identify.cs +++ b/Aaru.Images/Anex86/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class Anex86 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < Marshal.SizeOf
()) - return false; + if(stream.Length < Marshal.SizeOf
()) return false; var hdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(hdrB, 0, hdrB.Length); diff --git a/Aaru.Images/Anex86/Properties.cs b/Aaru.Images/Anex86/Properties.cs index 95bdb0b73..c3e14b5cf 100644 --- a/Aaru.Images/Anex86/Properties.cs +++ b/Aaru.Images/Anex86/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class Anex86 #region IWritableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/Anex86/Read.cs b/Aaru.Images/Anex86/Read.cs index def6cfc9c..806c63e14 100644 --- a/Aaru.Images/Anex86/Read.cs +++ b/Aaru.Images/Anex86/Read.cs @@ -49,8 +49,7 @@ public sealed partial class Anex86 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < Marshal.SizeOf
()) - return ErrorNumber.InvalidArgument; + if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; var hdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(hdrB, 0, hdrB.Length); @@ -61,8 +60,7 @@ public sealed partial class Anex86 (ushort)_header.spt, (uint)_header.bps, MediaEncoding.MFM, false)); - if(_imageInfo.MediaType == MediaType.Unknown) - _imageInfo.MediaType = MediaType.GENERIC_HDD; + if(_imageInfo.MediaType == MediaType.Unknown) _imageInfo.MediaType = MediaType.GENERIC_HDD; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.MediaType_0, _imageInfo.MediaType); @@ -90,11 +88,9 @@ public sealed partial class Anex86 { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; diff --git a/Aaru.Images/Anex86/Write.cs b/Aaru.Images/Anex86/Write.cs index a1d94c755..0f8389cac 100644 --- a/Aaru.Images/Anex86/Write.cs +++ b/Aaru.Images/Anex86/Write.cs @@ -202,9 +202,15 @@ public sealed partial class Anex86 return false; } - if(_imageInfo.MediaType is MediaType.Unknown or MediaType.GENERIC_HDD or MediaType.FlashDrive - or MediaType.CompactFlash or MediaType.CompactFlashType2 or MediaType.PCCardTypeI - or MediaType.PCCardTypeII or MediaType.PCCardTypeIII or MediaType.PCCardTypeIV && + if(_imageInfo.MediaType is MediaType.Unknown + or MediaType.GENERIC_HDD + or MediaType.FlashDrive + or MediaType.CompactFlash + or MediaType.CompactFlashType2 + or MediaType.PCCardTypeI + or MediaType.PCCardTypeII + or MediaType.PCCardTypeIII + or MediaType.PCCardTypeIV && _header.cylinders == 0) { _header.cylinders = (int)(_imageInfo.Sectors / 8 / 33); @@ -223,8 +229,7 @@ public sealed partial class Anex86 _header.cylinders = (int)_imageInfo.Sectors / _header.heads / _header.spt; - if(_header.cylinders == 0 && _header is { heads: 0, spt: 0 }) - break; + if(_header.cylinders == 0 && _header is { heads: 0, spt: 0 }) break; } } diff --git a/Aaru.Images/Apple2MG/Identify.cs b/Aaru.Images/Apple2MG/Identify.cs index 80482586c..c08117a11 100644 --- a/Aaru.Images/Apple2MG/Identify.cs +++ b/Aaru.Images/Apple2MG/Identify.cs @@ -46,35 +46,27 @@ public sealed partial class Apple2Mg Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 65) - return false; + if(stream.Length < 65) return false; var header = new byte[64]; stream.EnsureRead(header, 0, 64); Header hdr = Marshal.SpanToStructureLittleEndian
(header); - if(hdr.Magic != MAGIC) - return false; + if(hdr.Magic != MAGIC) return false; - if(hdr.DataOffset > stream.Length) - return false; + if(hdr.DataOffset > stream.Length) return false; // There seems to be incorrect endian in some images on the wild - if(hdr.DataSize == 0x00800C00) - hdr.DataSize = 0x000C8000; + if(hdr.DataSize == 0x00800C00) hdr.DataSize = 0x000C8000; - if(hdr.DataOffset + hdr.DataSize > stream.Length) - return false; + if(hdr.DataOffset + hdr.DataSize > stream.Length) return false; - if(hdr.CommentOffset > stream.Length) - return false; + if(hdr.CommentOffset > stream.Length) return false; - if(hdr.CommentOffset + hdr.CommentSize > stream.Length) - return false; + if(hdr.CommentOffset + hdr.CommentSize > stream.Length) return false; - if(hdr.CreatorSpecificOffset > stream.Length) - return false; + if(hdr.CreatorSpecificOffset > stream.Length) return false; return hdr.CreatorSpecificOffset + hdr.CreatorSpecificSize <= stream.Length; } diff --git a/Aaru.Images/Apple2MG/Properties.cs b/Aaru.Images/Apple2MG/Properties.cs index 68ff9babd..6f1292070 100644 --- a/Aaru.Images/Apple2MG/Properties.cs +++ b/Aaru.Images/Apple2MG/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class Apple2Mg #region IWritableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/Apple2MG/Read.cs b/Aaru.Images/Apple2MG/Read.cs index e317a0552..18d47f765 100644 --- a/Aaru.Images/Apple2MG/Read.cs +++ b/Aaru.Images/Apple2MG/Read.cs @@ -88,10 +88,12 @@ public sealed partial class Apple2Mg AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.commentSize = {0}", _imageHeader.CommentSize); - AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.creatorSpecificOffset = 0x{0:X8}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "ImageHeader.creatorSpecificOffset = 0x{0:X8}", _imageHeader.CreatorSpecificOffset); - AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.creatorSpecificSize = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "ImageHeader.creatorSpecificSize = {0}", _imageHeader.CreatorSpecificSize); AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.reserved1 = 0x{0:X8}", _imageHeader.Reserved1); @@ -117,8 +119,7 @@ public sealed partial class Apple2Mg nibPlugin.Open(noFilter); ErrorNumber errno = nibPlugin.ReadSectors(0, (uint)nibPlugin.Info.Sectors, out _decodedImage); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; _imageInfo.Sectors = nibPlugin.Info.Sectors; _imageInfo.SectorSize = nibPlugin.Info.SectorSize; @@ -140,8 +141,11 @@ public sealed partial class Apple2Mg _decodedImage = new byte[_imageHeader.DataSize]; - offsets = _imageHeader.ImageFormat == SectorOrder.Dos ? isDos ? _deinterleave : _interleave : - isDos ? _interleave : _deinterleave; + offsets = _imageHeader.ImageFormat == SectorOrder.Dos + ? isDos ? _deinterleave : _interleave + : isDos + ? _interleave + : _deinterleave; for(var t = 0; t < 35; t++) { @@ -281,17 +285,18 @@ public sealed partial class Apple2Mg { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; if(_decodedImage != null) { - Array.Copy(_decodedImage, (long)(sectorAddress * _imageInfo.SectorSize), buffer, 0, + Array.Copy(_decodedImage, + (long)(sectorAddress * _imageInfo.SectorSize), + buffer, + 0, length * _imageInfo.SectorSize); } else diff --git a/Aaru.Images/AppleDOS/Properties.cs b/Aaru.Images/AppleDOS/Properties.cs index a6a89e816..00c6f0ed4 100644 --- a/Aaru.Images/AppleDOS/Properties.cs +++ b/Aaru.Images/AppleDOS/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class AppleDos #region IWritableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/AppleDOS/Read.cs b/Aaru.Images/AppleDOS/Read.cs index f5466be7a..76756fe5e 100644 --- a/Aaru.Images/AppleDOS/Read.cs +++ b/Aaru.Images/AppleDOS/Read.cs @@ -71,8 +71,11 @@ public sealed partial class AppleDos _deinterleaved = new byte[tmp.Length]; - int[] offsets = _extension == ".do" ? isDos ? _deinterleave : _interleave : - isDos ? _interleave : _deinterleave; + int[] offsets = _extension == ".do" + ? isDos ? _deinterleave : _interleave + : isDos + ? _interleave + : _deinterleave; for(var t = 0; t < 35; t++) { @@ -104,11 +107,9 @@ public sealed partial class AppleDos { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; diff --git a/Aaru.Images/AppleDOS/Write.cs b/Aaru.Images/AppleDOS/Write.cs index 23c28d285..c6c3aa453 100644 --- a/Aaru.Images/AppleDOS/Write.cs +++ b/Aaru.Images/AppleDOS/Write.cs @@ -189,12 +189,17 @@ public sealed partial class AppleDos tmp = new byte[_deinterleaved.Length]; - int[] offsets = _extension == ".do" ? isDos ? _deinterleave : _interleave : - isDos ? _interleave : _deinterleave; + int[] offsets = _extension == ".do" + ? isDos ? _deinterleave : _interleave + : isDos + ? _interleave + : _deinterleave; for(var t = 0; t < 35; t++) - for(var s = 0; s < 16; s++) - Array.Copy(_deinterleaved, t * 16 * 256 + offsets[s] * 256, tmp, t * 16 * 256 + s * 256, 256); + { + for(var s = 0; s < 16; s++) + Array.Copy(_deinterleaved, t * 16 * 256 + offsets[s] * 256, tmp, t * 16 * 256 + s * 256, 256); + } } _writingStream.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Images/AppleNIB/Identify.cs b/Aaru.Images/AppleNIB/Identify.cs index f4f7b9710..df6a3f1b4 100644 --- a/Aaru.Images/AppleNIB/Identify.cs +++ b/Aaru.Images/AppleNIB/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class AppleNib Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 512) - return false; + if(stream.Length < 512) return false; var test = new byte[512]; stream.EnsureRead(test, 0, 512); diff --git a/Aaru.Images/AppleNIB/Properties.cs b/Aaru.Images/AppleNIB/Properties.cs index 59d8d7eb8..10001582a 100644 --- a/Aaru.Images/AppleNIB/Properties.cs +++ b/Aaru.Images/AppleNIB/Properties.cs @@ -42,6 +42,7 @@ public sealed partial class AppleNib #region IMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/AppleNIB/Read.cs b/Aaru.Images/AppleNIB/Read.cs index 77c8d445c..bac532c6b 100644 --- a/Aaru.Images/AppleNIB/Read.cs +++ b/Aaru.Images/AppleNIB/Read.cs @@ -52,8 +52,7 @@ public sealed partial class AppleNib Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 512) - return ErrorNumber.InvalidArgument; + if(stream.Length < 512) return ErrorNumber.InvalidArgument; var buffer = new byte[stream.Length]; stream.EnsureRead(buffer, 0, buffer.Length); @@ -70,8 +69,7 @@ public sealed partial class AppleNib for(var i = 1; i < tracks.Count; i++) allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length; - if(allTracksEqual) - spt = tracks[0].sectors.Length; + if(allTracksEqual) spt = tracks[0].sectors.Length; bool skewed = spt == 16; ulong[] skewing = _proDosSkewing; @@ -95,8 +93,7 @@ public sealed partial class AppleNib sector0[0x36] == 0 && sector0[0x37] == 1) { - if(isDos) - skewing = _dosSkewing; + if(isDos) skewing = _dosSkewing; AaruConsole.DebugWriteLine(MODULE_NAME, skewing.SequenceEqual(_dosSkewing) @@ -117,7 +114,9 @@ public sealed partial class AppleNib AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Hardware_sector_0_of_track_1_goes_to_logical_sector_2, - sectorNo, i, skewing[sectorNo] + (ulong)(i * spt)); + sectorNo, + i, + skewing[sectorNo] + (ulong)(i * spt)); rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector); _imageInfo.Sectors++; @@ -188,8 +187,7 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; return _cookedSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } @@ -199,11 +197,9 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -211,8 +207,7 @@ public sealed partial class AppleNib { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -227,11 +222,9 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(tag != SectorTagType.FloppyAddressMark) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; return _addressFields.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.NoData; } @@ -241,14 +234,11 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; - if(tag != SectorTagType.FloppyAddressMark) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; var ms = new MemoryStream(); @@ -256,8 +246,7 @@ public sealed partial class AppleNib { ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -272,8 +261,7 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; return _longSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } @@ -283,11 +271,9 @@ public sealed partial class AppleNib { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -295,8 +281,7 @@ public sealed partial class AppleNib { ErrorNumber errno = ReadSectorLong(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } diff --git a/Aaru.Images/Apridisk/Compression.cs b/Aaru.Images/Apridisk/Compression.cs index 05b4c76bf..7e77d4887 100644 --- a/Aaru.Images/Apridisk/Compression.cs +++ b/Aaru.Images/Apridisk/Compression.cs @@ -50,8 +50,7 @@ public sealed partial class Apridisk var blklen = BitConverter.ToUInt16(compressed, readp); readp += 2; - for(var i = 0; i < blklen; i++) - buffer.WriteByte(compressed[readp]); + for(var i = 0; i < blklen; i++) buffer.WriteByte(compressed[readp]); uLen += blklen; readp++; diff --git a/Aaru.Images/Apridisk/Identify.cs b/Aaru.Images/Apridisk/Identify.cs index 89685fa66..a353c34e3 100644 --- a/Aaru.Images/Apridisk/Identify.cs +++ b/Aaru.Images/Apridisk/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class Apridisk Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < _signature.Length) - return false; + if(stream.Length < _signature.Length) return false; var sigB = new byte[_signature.Length]; stream.EnsureRead(sigB, 0, _signature.Length); diff --git a/Aaru.Images/Apridisk/Properties.cs b/Aaru.Images/Apridisk/Properties.cs index 39f008cee..bfcc77dc3 100644 --- a/Aaru.Images/Apridisk/Properties.cs +++ b/Aaru.Images/Apridisk/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class Apridisk #region IWritableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/Apridisk/Read.cs b/Aaru.Images/Apridisk/Read.cs index ebbc28659..44f0fd5a0 100644 --- a/Aaru.Images/Apridisk/Read.cs +++ b/Aaru.Images/Apridisk/Read.cs @@ -100,20 +100,20 @@ public sealed partial class Apridisk AaruConsole.DebugWriteLine(MODULE_NAME, record.compression == CompressType.Compressed - ? Localization. - Found_compressed_sector_record_at_0_for_cylinder_1_head_2_sector_3 - : Localization. - Found_uncompressed_sector_record_at_0_for_cylinder_1_head_2_sector_3, - stream.Position, record.cylinder, record.head, record.sector); + ? Localization + .Found_compressed_sector_record_at_0_for_cylinder_1_head_2_sector_3 + : Localization + .Found_uncompressed_sector_record_at_0_for_cylinder_1_head_2_sector_3, + stream.Position, + record.cylinder, + record.head, + record.sector); - if(record.cylinder > totalCylinders) - totalCylinders = record.cylinder; + if(record.cylinder > totalCylinders) totalCylinders = record.cylinder; - if(record.head > totalHeads) - totalHeads = record.head; + if(record.head > totalHeads) totalHeads = record.head; - if(record.sector > maxSector) - maxSector = record.sector; + if(record.sector > maxSector) maxSector = record.sector; stream.Seek(record.headerSize - recordSize + record.dataSize, SeekOrigin.Current); @@ -126,8 +126,7 @@ public sealed partial class Apridisk totalCylinders++; totalHeads++; - if(totalCylinders <= 0 || totalHeads <= 0) - return ErrorNumber.NotSupported; + if(totalCylinders <= 0 || totalHeads <= 0) return ErrorNumber.NotSupported; _sectorsData = new byte[totalCylinders][][][]; @@ -139,7 +138,9 @@ public sealed partial class Apridisk AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_0_cylinders_and_1_heads_with_a_maximum_sector_number_of_2, - totalCylinders, totalHeads, maxSector); + totalCylinders, + totalHeads, + maxSector); // Create heads for(var i = 0; i < totalCylinders; i++) @@ -147,8 +148,7 @@ public sealed partial class Apridisk _sectorsData[i] = new byte[totalHeads][][]; spts[i] = new uint[totalHeads]; - for(var j = 0; j < totalHeads; j++) - _sectorsData[i][j] = new byte[maxSector + 1][]; + for(var j = 0; j < totalHeads; j++) _sectorsData[i][j] = new byte[maxSector + 1][]; } _imageInfo.SectorSize = uint.MaxValue; @@ -189,8 +189,7 @@ public sealed partial class Apridisk else _sectorsData[record.cylinder][record.head][record.sector] = data; - if(realLength < _imageInfo.SectorSize) - _imageInfo.SectorSize = realLength; + if(realLength < _imageInfo.SectorSize) _imageInfo.SectorSize = realLength; headerSizes += record.headerSize + record.dataSize; @@ -198,7 +197,8 @@ public sealed partial class Apridisk } } - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_a_minimum_of_0_bytes_per_sector, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_a_minimum_of_0_bytes_per_sector, _imageInfo.SectorSize); // Count sectors per track @@ -208,14 +208,14 @@ public sealed partial class Apridisk { for(ushort head = 0; head < _imageInfo.Heads; head++) { - if(spts[cyl][head] < spt) - spt = spts[cyl][head]; + if(spts[cyl][head] < spt) spt = spts[cyl][head]; } } _imageInfo.SectorsPerTrack = spt; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_a_minimum_of_0_sectors_per_track, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_a_minimum_of_0_sectors_per_track, _imageInfo.SectorsPerTrack); _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, @@ -238,14 +238,11 @@ public sealed partial class Apridisk buffer = null; (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= _sectorsData.Length) - return ErrorNumber.SectorNotFound; + if(cylinder >= _sectorsData.Length) return ErrorNumber.SectorNotFound; - if(head >= _sectorsData[cylinder].Length) - return ErrorNumber.SectorNotFound; + if(head >= _sectorsData[cylinder].Length) return ErrorNumber.SectorNotFound; - if(sector > _sectorsData[cylinder][head].Length) - return ErrorNumber.SectorNotFound; + if(sector > _sectorsData[cylinder][head].Length) return ErrorNumber.SectorNotFound; buffer = _sectorsData[cylinder][head][sector]; @@ -257,11 +254,9 @@ public sealed partial class Apridisk { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -269,8 +264,7 @@ public sealed partial class Apridisk { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } diff --git a/Aaru.Images/Apridisk/Write.cs b/Aaru.Images/Apridisk/Write.cs index c74e76026..04764a411 100644 --- a/Aaru.Images/Apridisk/Write.cs +++ b/Aaru.Images/Apridisk/Write.cs @@ -188,8 +188,7 @@ public sealed partial class Apridisk { for(byte s = 0; s < _imageInfo.SectorsPerTrack; s++) { - if(_sectorsData[c][h][s] == null || _sectorsData[c][h][s].Length == 0) - continue; + if(_sectorsData[c][h][s] == null || _sectorsData[c][h][s].Length == 0) continue; var record = new Record { @@ -302,8 +301,7 @@ public sealed partial class Apridisk { _sectorsData[c] = new byte[heads][][]; - for(byte h = 0; h < heads; h++) - _sectorsData[c][h] = new byte[sectorsPerTrack][]; + for(byte h = 0; h < heads; h++) _sectorsData[c][h] = new byte[sectorsPerTrack][]; } _imageInfo.Cylinders = cylinders; diff --git a/Aaru.Images/BLU/Identify.cs b/Aaru.Images/BLU/Identify.cs index a5081cc58..5288d04a1 100644 --- a/Aaru.Images/BLU/Identify.cs +++ b/Aaru.Images/BLU/Identify.cs @@ -49,8 +49,7 @@ public sealed partial class Blu Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 0x200) - return false; + if(stream.Length < 0x200) return false; var header = new byte[0x17]; stream.EnsureRead(header, 0, 0x17); @@ -67,8 +66,7 @@ public sealed partial class Blu for(var i = 0; i < 0xD; i++) { - if(tmpHdr.DeviceName[i] < 0x20) - return false; + if(tmpHdr.DeviceName[i] < 0x20) return false; } return (tmpHdr.BytesPerBlock & 0xFE00) == 0x200; diff --git a/Aaru.Images/BLU/Properties.cs b/Aaru.Images/BLU/Properties.cs index 550f60982..4a314d1da 100644 --- a/Aaru.Images/BLU/Properties.cs +++ b/Aaru.Images/BLU/Properties.cs @@ -46,6 +46,7 @@ public sealed partial class Blu #region IWritableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/BLU/Read.cs b/Aaru.Images/BLU/Read.cs index d67b6c02a..ac4782d9f 100644 --- a/Aaru.Images/BLU/Read.cs +++ b/Aaru.Images/BLU/Read.cs @@ -64,7 +64,8 @@ public sealed partial class Blu _imageHeader.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF; _imageHeader.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15); - AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.deviceName = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "ImageHeader.deviceName = \"{0}\"", StringHandlers.CToString(_imageHeader.DeviceName)); AaruConsole.DebugWriteLine(MODULE_NAME, "ImageHeader.deviceType = {0}", _imageHeader.DeviceType); @@ -73,12 +74,10 @@ public sealed partial class Blu for(var i = 0; i < 0xD; i++) { - if(_imageHeader.DeviceName[i] < 0x20) - return ErrorNumber.InvalidArgument; + if(_imageHeader.DeviceName[i] < 0x20) return ErrorNumber.InvalidArgument; } - if((_imageHeader.BytesPerBlock & 0xFE00) != 0x200) - return ErrorNumber.InvalidArgument; + if((_imageHeader.BytesPerBlock & 0xFE00) != 0x200) return ErrorNumber.InvalidArgument; stream.Seek(0, SeekOrigin.Begin); header = new byte[_imageHeader.BytesPerBlock]; @@ -148,8 +147,7 @@ public sealed partial class Blu _imageInfo.MetadataMediaType = MetadataMediaType.BlockMedia; - if(_bptag > 0) - _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); + if(_bptag > 0) _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); AaruConsole.VerboseWriteLine(Localization.BLU_image_contains_a_disk_of_type_0, _imageInfo.MediaType); @@ -168,11 +166,9 @@ public sealed partial class Blu { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); const int read = 0x200; @@ -199,17 +195,13 @@ public sealed partial class Blu { buffer = null; - if(tag != SectorTagType.AppleSectorTag) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSectorTag) return ErrorNumber.NotSupported; - if(_bptag == 0) - return ErrorNumber.NoData; + if(_bptag == 0) return ErrorNumber.NoData; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.SectorNotFound; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.SectorNotFound; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.SectorNotFound; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.SectorNotFound; var ms = new MemoryStream(); const int seek = 0x200; @@ -240,11 +232,9 @@ public sealed partial class Blu { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageHeader.BytesPerBlock]; Stream stream = _bluImageFilter.GetDataForkStream(); diff --git a/Aaru.Images/BLU/Verify.cs b/Aaru.Images/BLU/Verify.cs index 259f2387a..203bb715f 100644 --- a/Aaru.Images/BLU/Verify.cs +++ b/Aaru.Images/BLU/Verify.cs @@ -51,8 +51,7 @@ public sealed partial class Blu failingLbas = new List(); unknownLbas = new List(); - for(ulong i = sectorAddress; i < sectorAddress + length; i++) - unknownLbas.Add(i); + for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i); return null; } diff --git a/Aaru.Images/BLU/Write.cs b/Aaru.Images/BLU/Write.cs index d23707d48..3420a90fd 100644 --- a/Aaru.Images/BLU/Write.cs +++ b/Aaru.Images/BLU/Write.cs @@ -424,7 +424,8 @@ public sealed partial class Blu _writingStream.Write(blockSize, 1, 2); _writingStream.Seek(512, SeekOrigin.Begin); - _writingStream.Write(markerTag, 0, + _writingStream.Write(markerTag, + 0, markerTag.Length >= longSectorSize - 512 ? longSectorSize - 512 : markerTag.Length); _writingStream.Flush(); diff --git a/Aaru.Images/BlindWrite4/Identify.cs b/Aaru.Images/BlindWrite4/Identify.cs index ebcc2f1f1..84ff4099c 100644 --- a/Aaru.Images/BlindWrite4/Identify.cs +++ b/Aaru.Images/BlindWrite4/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class BlindWrite4 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 19) - return false; + if(stream.Length < 19) return false; var signature = new byte[19]; stream.EnsureRead(signature, 0, 19); diff --git a/Aaru.Images/BlindWrite4/Properties.cs b/Aaru.Images/BlindWrite4/Properties.cs index 8cbfa1864..0cbfe8fe5 100644 --- a/Aaru.Images/BlindWrite4/Properties.cs +++ b/Aaru.Images/BlindWrite4/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class BlindWrite4 #region IOpticalMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/BlindWrite4/Read.cs b/Aaru.Images/BlindWrite4/Read.cs index 37197fc74..c995366f0 100644 --- a/Aaru.Images/BlindWrite4/Read.cs +++ b/Aaru.Images/BlindWrite4/Read.cs @@ -57,8 +57,7 @@ public sealed partial class BlindWrite4 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 19) - return ErrorNumber.InvalidArgument; + if(stream.Length < 19) return ErrorNumber.InvalidArgument; var tmpArray = new byte[19]; var tmpUShort = new byte[2]; @@ -67,8 +66,7 @@ public sealed partial class BlindWrite4 stream.EnsureRead(tmpArray, 0, 19); - if(!_bw4Signature.SequenceEqual(tmpArray)) - return ErrorNumber.InvalidArgument; + if(!_bw4Signature.SequenceEqual(tmpArray)) return ErrorNumber.InvalidArgument; _header = new Header { @@ -393,60 +391,54 @@ public sealed partial class BlindWrite4 _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile)); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.DataFile.ToLower(CultureInfo. - CurrentCulture))); + _header.DataFile + .ToLower(CultureInfo.CurrentCulture))); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.DataFile.ToUpper(CultureInfo. - CurrentCulture))); + _header.DataFile + .ToUpper(CultureInfo.CurrentCulture))); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last())); + { + '\\' + }, + StringSplitOptions + .RemoveEmptyEntries) + .Last())); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToLower(CultureInfo.CurrentCulture))); + { + '\\' + }, + StringSplitOptions + .RemoveEmptyEntries) + .Last() + .ToLower(CultureInfo.CurrentCulture))); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; _dataFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToUpper(CultureInfo.CurrentCulture))); + { + '\\' + }, + StringSplitOptions + .RemoveEmptyEntries) + .Last() + .ToUpper(CultureInfo.CurrentCulture))); - if(_dataFilter != null) - break; + if(_dataFilter != null) break; AaruConsole.ErrorWriteLine(string.Format(Localization.Data_file_0_not_found, _header.DataFile)); @@ -466,31 +458,34 @@ public sealed partial class BlindWrite4 ((((PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile)) ?? PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.SubchannelFile.ToLower(CultureInfo. - CurrentCulture)))) ?? + _header.SubchannelFile + .ToLower(CultureInfo.CurrentCulture)))) ?? PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.SubchannelFile.ToUpper(CultureInfo. - CurrentCulture)))) ?? - PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last()))) ?? - PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last(). - ToLower(CultureInfo.CurrentCulture)))) ?? - PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last(). - ToUpper(CultureInfo.CurrentCulture))); + _header.SubchannelFile + .ToUpper(CultureInfo.CurrentCulture)))) ?? + PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, + _header.SubchannelFile.Split(new[] + { + '\\' + }, + StringSplitOptions.RemoveEmptyEntries) + .Last()))) ?? + PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, + _header.SubchannelFile.Split(new[] + { + '\\' + }, + StringSplitOptions.RemoveEmptyEntries) + .Last() + .ToLower(CultureInfo.CurrentCulture)))) ?? + PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, + _header.SubchannelFile.Split(new[] + { + '\\' + }, + StringSplitOptions.RemoveEmptyEntries) + .Last() + .ToUpper(CultureInfo.CurrentCulture))); } Tracks = new List(); @@ -519,59 +514,56 @@ public sealed partial class BlindWrite4 PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename)); - if(track.Filter != null) - break; + if(track.Filter != null) break; track.Filter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - bwTrack.filename.ToLower(CultureInfo. - CurrentCulture))); + bwTrack.filename + .ToLower(CultureInfo + .CurrentCulture))); - if(track.Filter != null) - break; + if(track.Filter != null) break; track.Filter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - bwTrack.filename.ToUpper(CultureInfo. - CurrentCulture))); + bwTrack.filename + .ToUpper(CultureInfo + .CurrentCulture))); - if(track.Filter != null) - break; + if(track.Filter != null) break; track.Filter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename.Split(new[] { '\\' }, - StringSplitOptions. - RemoveEmptyEntries). - Last())); + StringSplitOptions + .RemoveEmptyEntries) + .Last())); - if(track.Filter != null) - break; + if(track.Filter != null) break; track.Filter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename.Split(new[] { '\\' }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToLower(CultureInfo. - CurrentCulture))); + StringSplitOptions + .RemoveEmptyEntries) + .Last() + .ToLower(CultureInfo + .CurrentCulture))); - if(track.Filter != null) - break; + if(track.Filter != null) break; track.Filter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename.Split(new[] { '\\' }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToUpper(CultureInfo. - CurrentCulture))); + StringSplitOptions + .RemoveEmptyEntries) + .Last() + .ToUpper(CultureInfo + .CurrentCulture))); track.Filter = _dataFilter; } while(true); @@ -608,8 +600,7 @@ public sealed partial class BlindWrite4 track.Sequence = bwTrack.point; track.Session = bwTrack.session; - if(track.Session > maxSession) - maxSession = track.Session; + if(track.Session > maxSession) maxSession = track.Session; track.SubchannelFilter = _subFilter; track.SubchannelFile = _subFilter?.Filename; @@ -656,8 +647,7 @@ public sealed partial class BlindWrite4 if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; track.BytesPerSector = 2048; @@ -671,8 +661,7 @@ public sealed partial class BlindWrite4 if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(_imageInfo.SectorSize < 2336) - _imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) _imageInfo.SectorSize = 2336; track.BytesPerSector = 2336; @@ -686,8 +675,7 @@ public sealed partial class BlindWrite4 break; } - if(bwTrack.pregap != 0) - track.Indexes.Add(0, bwTrack.pregap); + if(bwTrack.pregap != 0) track.Indexes.Add(0, bwTrack.pregap); track.Indexes.Add(1, bwTrack.startSector); @@ -715,8 +703,7 @@ public sealed partial class BlindWrite4 _trackFlags.TryAdd(track.Sequence, (byte)(bwTrack.adrCtl & 0x0F)); - if(bwTrack.lastSector > _imageInfo.Sectors) - _imageInfo.Sectors = bwTrack.lastSector + 1; + if(bwTrack.lastSector > _imageInfo.Sectors) _imageInfo.Sectors = bwTrack.lastSector + 1; } else { @@ -743,17 +730,13 @@ public sealed partial class BlindWrite4 foreach(Track track in Tracks.Where(track => track.Session == i)) { - if(track.Sequence < session.StartTrack) - session.StartTrack = track.Sequence; + if(track.Sequence < session.StartTrack) session.StartTrack = track.Sequence; - if(track.Sequence > session.EndTrack) - session.StartTrack = track.Sequence; + if(track.Sequence > session.EndTrack) session.StartTrack = track.Sequence; - if(track.StartSector < session.StartSector) - session.StartSector = track.StartSector; + if(track.StartSector < session.StartSector) session.StartSector = track.StartSector; - if(track.EndSector > session.EndSector) - session.EndSector = track.EndSector; + if(track.EndSector > session.EndSector) session.EndSector = track.EndSector; } Sessions.Add(session); @@ -762,8 +745,7 @@ public sealed partial class BlindWrite4 // As long as subchannel is written for any track, it is present for all tracks if(Tracks.Any(t => t.SubchannelType == TrackSubchannelType.Packed)) { - foreach(Track track in Tracks) - track.SubchannelType = TrackSubchannelType.Packed; + foreach(Track track in Tracks) track.SubchannelType = TrackSubchannelType.Packed; } _imageInfo.MediaType = MediaType.CD; @@ -834,8 +816,7 @@ public sealed partial class BlindWrite4 { case MediaTagType.CD_MCN: { - if(_imageInfo.MediaSerialNumber == null) - return ErrorNumber.NoData; + if(_imageInfo.MediaSerialNumber == null) return ErrorNumber.NoData; buffer = Encoding.ASCII.GetBytes(_imageInfo.MediaSerialNumber); @@ -901,11 +882,9 @@ public sealed partial class BlindWrite4 buffer = null; Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -956,9 +935,9 @@ public sealed partial class BlindWrite4 _imageStream = aaruTrack.Filter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.FileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.FileOffset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(mode2) { @@ -1000,18 +979,15 @@ public sealed partial class BlindWrite4 buffer = null; Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; uint sectorOffset = 0; uint sectorSize = 0; uint sectorSkip = 0; - if(aaruTrack.Type == CommonTypes.Enums.TrackType.Data) - return ErrorNumber.NotSupported; + if(aaruTrack.Type == CommonTypes.Enums.TrackType.Data) return ErrorNumber.NotSupported; switch(tag) { @@ -1025,8 +1001,7 @@ public sealed partial class BlindWrite4 case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(!_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) - return ErrorNumber.NoData; + if(!_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) return ErrorNumber.NoData; buffer = new[] { @@ -1172,9 +1147,11 @@ public sealed partial class BlindWrite4 var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)(tag == SectorTagType.CdSectorSubchannel ? aaruTrack.SubchannelOffset : aaruTrack.FileOffset) + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)(tag == SectorTagType.CdSectorSubchannel + ? aaruTrack.SubchannelOffset + : aaruTrack.FileOffset) + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); @@ -1189,8 +1166,7 @@ public sealed partial class BlindWrite4 } } - if(tag == SectorTagType.CdSectorSubchannel) - buffer = Subchannel.Interleave(buffer); + if(tag == SectorTagType.CdSectorSubchannel) buffer = Subchannel.Interleave(buffer); return ErrorNumber.NoError; } @@ -1226,11 +1202,9 @@ public sealed partial class BlindWrite4 buffer = null; Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; uint sectorSize; diff --git a/Aaru.Images/BlindWrite4/Structs.cs b/Aaru.Images/BlindWrite4/Structs.cs index 1afa98dd5..d0cc53ab7 100644 --- a/Aaru.Images/BlindWrite4/Structs.cs +++ b/Aaru.Images/BlindWrite4/Structs.cs @@ -60,7 +60,7 @@ public sealed partial class BlindWrite4 public byte[] Unknown4; // On memory only - #pragma warning disable 649 +#pragma warning disable 649 public string VolumeIdentifier; public string SystemIdentifier; public string Comments; @@ -68,7 +68,7 @@ public sealed partial class BlindWrite4 public IFilter SubchannelFilter; public string DataFile; public string SubchannelFile; - #pragma warning restore 649 +#pragma warning restore 649 } #endregion diff --git a/Aaru.Images/BlindWrite4/Verify.cs b/Aaru.Images/BlindWrite4/Verify.cs index bc5f7b747..6e0f8f320 100644 --- a/Aaru.Images/BlindWrite4/Verify.cs +++ b/Aaru.Images/BlindWrite4/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class BlindWrite4 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class BlindWrite4 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class BlindWrite4 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class BlindWrite4 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/BlindWrite5/Identify.cs b/Aaru.Images/BlindWrite5/Identify.cs index 24827e786..589738c2c 100644 --- a/Aaru.Images/BlindWrite5/Identify.cs +++ b/Aaru.Images/BlindWrite5/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class BlindWrite5 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 276) - return false; + if(stream.Length < 276) return false; var signature = new byte[16]; stream.EnsureRead(signature, 0, 16); diff --git a/Aaru.Images/BlindWrite5/Properties.cs b/Aaru.Images/BlindWrite5/Properties.cs index 4d920e759..c4bf7b19a 100644 --- a/Aaru.Images/BlindWrite5/Properties.cs +++ b/Aaru.Images/BlindWrite5/Properties.cs @@ -44,6 +44,7 @@ public sealed partial class BlindWrite5 #region IOpticalMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index 81a46a66f..cbacdde51 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -65,8 +65,7 @@ public sealed partial class BlindWrite5 Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 276) - return ErrorNumber.InvalidArgument; + if(stream.Length < 276) return ErrorNumber.InvalidArgument; var hdr = new byte[260]; stream.EnsureRead(hdr, 0, 260); @@ -105,7 +104,8 @@ public sealed partial class BlindWrite5 for(var i = 0; i < _header.unknown6.Length; i++) AaruConsole.DebugWriteLine(MODULE_NAME, "header.unknown6[{1}] = 0x{0:X2}", _header.unknown6[i], i); - AaruConsole.DebugWriteLine(MODULE_NAME, "header.manufacturer = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "header.manufacturer = {0}", StringHandlers.CToString(_header.manufacturer)); AaruConsole.DebugWriteLine(MODULE_NAME, "header.product = {0}", StringHandlers.CToString(_header.product)); @@ -132,7 +132,8 @@ public sealed partial class BlindWrite5 if(decoded2A is not null) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.mode_page_2A_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.mode_page_2A_0, Modes.PrettifyModePage_2A(decoded2A)); } else @@ -141,8 +142,7 @@ public sealed partial class BlindWrite5 _unkBlock = new byte[_header.unkBlkLen]; - if(_unkBlock.Length > 0) - stream.EnsureRead(_unkBlock, 0, _unkBlock.Length); + if(_unkBlock.Length > 0) stream.EnsureRead(_unkBlock, 0, _unkBlock.Length); var temp = new byte[_header.pmaLen]; @@ -236,7 +236,8 @@ public sealed partial class BlindWrite5 { stream.EnsureRead(_discInformation, 0, _discInformation.Length); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Disc_information_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Disc_information_0, PrintHex.ByteArrayToHexArrayString(_discInformation, 40)); } else @@ -349,95 +350,173 @@ public sealed partial class BlindWrite5 stream.Seek(-8, SeekOrigin.Current); } - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].type = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].type = {2}", + ses, + tSeq, session.Tracks[tSeq].type); for(var i = 0; i < session.Tracks[tSeq].unknown1.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", ses, - tSeq, i, session.Tracks[tSeq].unknown1[i]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown1[i]); } - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown2 = 0x{2:X8}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown2 = 0x{2:X8}", + ses, + tSeq, session.Tracks[tSeq].unknown2); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].subchannel = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].subchannel = {2}", + ses, + tSeq, session.Tracks[tSeq].subchannel); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown3 = 0x{2:X2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown3 = 0x{2:X2}", + ses, + tSeq, session.Tracks[tSeq].unknown3); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].ctl = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].ctl = {2}", + ses, + tSeq, session.Tracks[tSeq].ctl); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].adr = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].adr = {2}", + ses, + tSeq, session.Tracks[tSeq].adr); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].point = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].point = {2}", + ses, + tSeq, session.Tracks[tSeq].point); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown4 = 0x{2:X2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown4 = 0x{2:X2}", + ses, + tSeq, session.Tracks[tSeq].tno); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].min = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].min = {2}", + ses, + tSeq, session.Tracks[tSeq].min); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].sec = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].sec = {2}", + ses, + tSeq, session.Tracks[tSeq].sec); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].frame = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].frame = {2}", + ses, + tSeq, session.Tracks[tSeq].frame); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].zero = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].zero = {2}", + ses, + tSeq, session.Tracks[tSeq].zero); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].pmin = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].pmin = {2}", + ses, + tSeq, session.Tracks[tSeq].pmin); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].psec = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].psec = {2}", + ses, + tSeq, session.Tracks[tSeq].psec); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].pframe = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].pframe = {2}", + ses, + tSeq, session.Tracks[tSeq].pframe); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown5 = 0x{2:X2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown5 = 0x{2:X2}", + ses, + tSeq, session.Tracks[tSeq].unknown5); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].pregap = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].pregap = {2}", + ses, + tSeq, session.Tracks[tSeq].pregap); for(var i = 0; i < session.Tracks[tSeq].unknown6.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", ses, - tSeq, i, session.Tracks[tSeq].unknown6[i]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown6[i]); } - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].startLba = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].startLba = {2}", + ses, + tSeq, session.Tracks[tSeq].startLba); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].sectors = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].sectors = {2}", + ses, + tSeq, session.Tracks[tSeq].sectors); for(var i = 0; i < session.Tracks[tSeq].unknown7.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", ses, - tSeq, i, session.Tracks[tSeq].unknown7[i]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown7[i]); } - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].session = {2}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].session = {2}", + ses, + tSeq, session.Tracks[tSeq].session); - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown8 = 0x{2:X4}", ses, tSeq, + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown8 = 0x{2:X4}", + ses, + tSeq, session.Tracks[tSeq].unknown8); - if(session.Tracks[tSeq].type is TrackType.Dvd or TrackType.NotData) - continue; + if(session.Tracks[tSeq].type is TrackType.Dvd or TrackType.NotData) continue; { for(var i = 0; i < session.Tracks[tSeq].unknown9.Length; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", ses, - tSeq, i, session.Tracks[tSeq].unknown9[i]); + AaruConsole.DebugWriteLine(MODULE_NAME, + "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", + ses, + tSeq, + i, + session.Tracks[tSeq].unknown9[i]); } } } @@ -459,8 +538,8 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Correctly_arrived_end_of_image); else { - AaruConsole.ErrorWriteLine(Localization. - BlindWrite5_image_ends_after_expected_position_Probably_new_version_with_different_data_Errors_may_occur); + AaruConsole.ErrorWriteLine(Localization + .BlindWrite5_image_ends_after_expected_position_Probably_new_version_with_different_data_Errors_may_occur); } _filePaths = new List(); @@ -492,6 +571,7 @@ public sealed partial class BlindWrite5 { chars.FileFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, path)); + chars.FilePath = path; } else @@ -521,56 +601,56 @@ public sealed partial class BlindWrite5 path = Path.Combine(_dataPath, dataFile.Filename); if(PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToLower(CultureInfo. - CurrentCulture))) != + path.ToLower(CultureInfo + .CurrentCulture))) != null) { chars.FilePath = path.ToLower(CultureInfo.CurrentCulture); chars.FileFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToLower(CultureInfo. - CurrentCulture))); + path.ToLower(CultureInfo + .CurrentCulture))); } else if(PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToUpper(CultureInfo. - CurrentCulture))) != + path.ToUpper(CultureInfo + .CurrentCulture))) != null) { chars.FilePath = path.ToUpper(CultureInfo.CurrentCulture); chars.FileFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToUpper(CultureInfo. - CurrentCulture))); + path.ToUpper(CultureInfo + .CurrentCulture))); } else if(PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - dataFile.Filename. - ToLower(CultureInfo. - CurrentCulture))) != + dataFile.Filename + .ToLower(CultureInfo + .CurrentCulture))) != null) { chars.FilePath = dataFile.Filename.ToLower(CultureInfo.CurrentCulture); chars.FileFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - dataFile.Filename. - ToLower(CultureInfo. - CurrentCulture))); + dataFile.Filename + .ToLower(CultureInfo + .CurrentCulture))); } else if(PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - dataFile.Filename. - ToUpper(CultureInfo. - CurrentCulture))) != + dataFile.Filename + .ToUpper(CultureInfo + .CurrentCulture))) != null) { chars.FilePath = dataFile.Filename.ToUpper(CultureInfo.CurrentCulture); chars.FileFilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - dataFile.Filename. - ToUpper(CultureInfo. - CurrentCulture))); + dataFile.Filename + .ToUpper(CultureInfo + .CurrentCulture))); } else if(PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, dataFile.Filename)) != @@ -632,9 +712,11 @@ public sealed partial class BlindWrite5 var fullTocStream = new MemoryStream(); fullTocStream.Write(new byte[] - { - 0, 0 - }, 0, 2); + { + 0, 0 + }, + 0, + 2); ulong offsetBytes = 0; _offsetMap = new Dictionary(); @@ -657,11 +739,9 @@ public sealed partial class BlindWrite5 EndTrack = ses.LastTrack }); - if(ses.Sequence < firstSession) - firstSession = (byte)ses.Sequence; + if(ses.Sequence < firstSession) firstSession = (byte)ses.Sequence; - if(ses.Sequence > lastSession) - lastSession = (byte)ses.Sequence; + if(ses.Sequence > lastSession) lastSession = (byte)ses.Sequence; foreach(TrackDescriptor trk in ses.Tracks) { @@ -678,8 +758,7 @@ public sealed partial class BlindWrite5 fullTocStream.WriteByte(trk.psec); fullTocStream.WriteByte(trk.pframe); - if(trk.point >= 0xA0) - continue; + if(trk.point >= 0xA0) continue; var track = new Track(); var partition = new Partition(); @@ -692,8 +771,7 @@ public sealed partial class BlindWrite5 track.BytesPerSector = 2352; track.RawBytesPerSector = 2352; - if(_imageInfo.SectorSize < 2352) - _imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) _imageInfo.SectorSize = 2352; break; case TrackType.Mode1: @@ -722,8 +800,7 @@ public sealed partial class BlindWrite5 track.BytesPerSector = 2048; track.RawBytesPerSector = 2352; - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; break; case TrackType.Mode2: @@ -736,8 +813,7 @@ public sealed partial class BlindWrite5 track.BytesPerSector = 2336; track.RawBytesPerSector = 2352; - if(_imageInfo.SectorSize < 2336) - _imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) _imageInfo.SectorSize = 2336; break; case TrackType.Mode2F2: @@ -756,16 +832,14 @@ public sealed partial class BlindWrite5 track.BytesPerSector = 2336; track.RawBytesPerSector = 2352; - if(_imageInfo.SectorSize < 2324) - _imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) _imageInfo.SectorSize = 2324; break; case TrackType.Dvd: track.BytesPerSector = 2048; track.RawBytesPerSector = 2048; - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; isDvd = true; @@ -776,11 +850,10 @@ public sealed partial class BlindWrite5 track.StartSector = (ulong)(trk.startLba + trk.pregap); track.EndSector = (ulong)(trk.sectors + trk.startLba) - 1; - var fileCharsForThisTrack = _filePaths. - Where(chars => trk.startLba >= chars.StartLba && - trk.startLba + trk.sectors <= - chars.StartLba + chars.Sectors). - ToList(); + var fileCharsForThisTrack = _filePaths + .Where(chars => trk.startLba >= chars.StartLba && + trk.startLba + trk.sectors <= chars.StartLba + chars.Sectors) + .ToList(); if(fileCharsForThisTrack.Count == 0 && _filePaths.Any(f => Path.GetExtension(f.FilePath).ToLowerInvariant() == ".b00")) @@ -793,7 +866,8 @@ public sealed partial class BlindWrite5 var lowerCaseFileName = false; string basePath; - bool version5 = string.Compare(Path.GetExtension(imageFilter.Filename), ".B5T", + bool version5 = string.Compare(Path.GetExtension(imageFilter.Filename), + ".B5T", StringComparison.OrdinalIgnoreCase) == 0; @@ -837,8 +911,9 @@ public sealed partial class BlindWrite5 basePath = _dataPath; lowerCaseFileName = true; } - else if(File.Exists(Path.Combine(_dataPath, $"{filename.ToLower(CultureInfo.CurrentCulture)}.{ - firstExtensionLower}"))) + else if(File.Exists(Path.Combine(_dataPath, + $"{filename.ToLower(CultureInfo.CurrentCulture)}.{ + firstExtensionLower}"))) { basePath = _dataPath; lowerCaseFileName = true; @@ -870,23 +945,27 @@ public sealed partial class BlindWrite5 lowerCaseExtension = true; } - else if(File.Exists(Path.Combine(imageFilter.ParentFolder, _dataPath, + else if(File.Exists(Path.Combine(imageFilter.ParentFolder, + _dataPath, $"{filename}.{firstExtension}"))) basePath = Path.Combine(imageFilter.ParentFolder, _dataPath); - else if(File.Exists(Path.Combine(imageFilter.ParentFolder, _dataPath, + else if(File.Exists(Path.Combine(imageFilter.ParentFolder, + _dataPath, $"{filename}.{firstExtensionLower}"))) { basePath = Path.Combine(imageFilter.ParentFolder, _dataPath); lowerCaseExtension = true; } - else if(File.Exists(Path.Combine(imageFilter.ParentFolder, _dataPath, + else if(File.Exists(Path.Combine(imageFilter.ParentFolder, + _dataPath, $"{filename.ToLower(CultureInfo.CurrentCulture)}.{firstExtension }"))) { basePath = Path.Combine(imageFilter.ParentFolder, _dataPath); lowerCaseFileName = true; } - else if(File.Exists(Path.Combine(imageFilter.ParentFolder, _dataPath, + else if(File.Exists(Path.Combine(imageFilter.ParentFolder, + _dataPath, $"{filename.ToLower(CultureInfo.CurrentCulture)}.{ firstExtensionLower}"))) { @@ -903,7 +982,8 @@ public sealed partial class BlindWrite5 _dataPath.ToLower(CultureInfo.CurrentCulture)); } else if(File.Exists(Path.Combine(imageFilter.ParentFolder, - _dataPath.ToLower(CultureInfo.CurrentCulture), $"{filename}.b00"))) + _dataPath.ToLower(CultureInfo.CurrentCulture), + $"{filename}.b00"))) { basePath = Path.Combine(imageFilter.ParentFolder, _dataPath.ToLower(CultureInfo.CurrentCulture)); @@ -945,8 +1025,9 @@ public sealed partial class BlindWrite5 basePath = ""; lowerCaseFileName = true; } - else if(File.Exists(Path.Combine("", $"{filename.ToLower(CultureInfo.CurrentCulture)}.{ - firstExtensionLower}"))) + else if(File.Exists(Path.Combine("", + $"{filename.ToLower(CultureInfo.CurrentCulture)}.{ + firstExtensionLower}"))) { basePath = ""; lowerCaseFileName = true; @@ -961,16 +1042,16 @@ public sealed partial class BlindWrite5 var splitStream = new SplitJoinStream(); - if(lowerCaseFileName) - filename = filename.ToLower(CultureInfo.CurrentCulture); + if(lowerCaseFileName) filename = filename.ToLower(CultureInfo.CurrentCulture); string extension = lowerCaseExtension ? "b{0:D2}" : "B{0:D2}"; try { - splitStream. - Add(Path.Combine(basePath, $"{filename}.{(lowerCaseExtension ? firstExtensionLower : firstExtension)}"), - FileMode.Open, FileAccess.Read); + splitStream.Add(Path.Combine(basePath, + $"{filename}.{(lowerCaseExtension ? firstExtensionLower : firstExtension)}"), + FileMode.Open, + FileAccess.Read); splitStream.AddRange(basePath, $"{filename}.{extension}"); } @@ -1057,8 +1138,7 @@ public sealed partial class BlindWrite5 { track.Indexes[0] = (int)track.StartSector - (int)trk.pregap; - if(track.Indexes[0] < 0) - track.Indexes[0] = 0; + if(track.Indexes[0] < 0) track.Indexes[0] = 0; } track.Indexes[1] = (int)track.StartSector; @@ -1075,11 +1155,9 @@ public sealed partial class BlindWrite5 offsetBytes += partition.Size; - if(track.StartSector >= trk.pregap) - track.StartSector -= trk.pregap; + if(track.StartSector >= trk.pregap) track.StartSector -= trk.pregap; - if(track.EndSector > _imageInfo.Sectors) - _imageInfo.Sectors = track.EndSector + 1; + if(track.EndSector > _imageInfo.Sectors) _imageInfo.Sectors = track.EndSector + 1; Tracks.Add(track); Partitions.Add(partition); @@ -1178,9 +1256,8 @@ public sealed partial class BlindWrite5 }; if(DMI.IsXbox(_dmi)) - _imageInfo.MediaType = MediaType.XGD; - else if(DMI.IsXbox360(_dmi)) - _imageInfo.MediaType = MediaType.XGD2; + _imageInfo.MediaType = MediaType.XGD; + else if(DMI.IsXbox360(_dmi)) _imageInfo.MediaType = MediaType.XGD2; } } else if(_imageInfo.MediaType is MediaType.CD or MediaType.CDROM) @@ -1295,24 +1372,19 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine(MODULE_NAME, "ImageInfo.mediaType = {0}", _imageInfo.MediaType); - if(_mode2A != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A); + if(_mode2A != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A); - if(_pma != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_PMA); + if(_pma != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_PMA); - if(_atip != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_ATIP); + if(_atip != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_ATIP); - if(_cdtext != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); + 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); + else if(isBd) _imageInfo.ReadableMediaTags.Add(MediaTagType.BD_BCA); } byte[] tmp; @@ -1333,8 +1405,7 @@ public sealed partial class BlindWrite5 _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); } - if(_fullToc != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); + if(_fullToc != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); if(_imageInfo is { MediaType: MediaType.XGD2, Sectors: 25063 or 4229664 or 4246304 }) @@ -1457,11 +1528,9 @@ public sealed partial class BlindWrite5 // TODO: Cross data files Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba @@ -1470,8 +1539,7 @@ public sealed partial class BlindWrite5 where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); - if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) - return ErrorNumber.SectorNotFound; + if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) return ErrorNumber.SectorNotFound; uint sectorOffset; uint sectorSize; @@ -1542,9 +1610,9 @@ public sealed partial class BlindWrite5 _imageStream = chars.FileFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.FileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.FileOffset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(mode2) { @@ -1587,11 +1655,9 @@ public sealed partial class BlindWrite5 // TODO: Cross data files Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba @@ -1600,11 +1666,9 @@ public sealed partial class BlindWrite5 where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); - if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) - return ErrorNumber.SectorNotFound; + if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) return ErrorNumber.SectorNotFound; - if(aaruTrack.Type == CommonTypes.Enums.TrackType.Data) - return ErrorNumber.NotSupported; + if(aaruTrack.Type == CommonTypes.Enums.TrackType.Data) return ErrorNumber.NotSupported; switch(tag) { @@ -1618,8 +1682,7 @@ public sealed partial class BlindWrite5 case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(!_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) - return ErrorNumber.NoData; + if(!_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) return ErrorNumber.NoData; buffer = new[] { @@ -2055,9 +2118,9 @@ public sealed partial class BlindWrite5 _imageStream = aaruTrack.Filter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.FileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.FileOffset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); @@ -2072,8 +2135,7 @@ public sealed partial class BlindWrite5 } } - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NoError; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NoError; buffer = chars.Subchannel switch { @@ -2118,11 +2180,9 @@ public sealed partial class BlindWrite5 // TODO: Cross data files Track aaruTrack = Tracks.FirstOrDefault(bwTrack => bwTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba @@ -2131,8 +2191,7 @@ public sealed partial class BlindWrite5 where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); - if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) - return ErrorNumber.SectorNotFound; + if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) return ErrorNumber.SectorNotFound; uint sectorOffset; uint sectorSize; diff --git a/Aaru.Images/BlindWrite5/Verify.cs b/Aaru.Images/BlindWrite5/Verify.cs index 533f117d2..3b8dcbc82 100644 --- a/Aaru.Images/BlindWrite5/Verify.cs +++ b/Aaru.Images/BlindWrite5/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class BlindWrite5 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class BlindWrite5 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class BlindWrite5 unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class BlindWrite5 } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/ByteAddressable/AtariLynx.cs b/Aaru.Images/ByteAddressable/AtariLynx.cs index 65b164508..a4a083a48 100644 --- a/Aaru.Images/ByteAddressable/AtariLynx.cs +++ b/Aaru.Images/ByteAddressable/AtariLynx.cs @@ -41,6 +41,7 @@ public class AtariLynx : IByteAddressableImage public Guid Id => new("809A6835-0486-4FD3-BD8B-2EF40C3EF97B"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -50,14 +51,12 @@ public class AtariLynx : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if((stream.Length - 64) % 65536 != 0) - return false; + if((stream.Length - 64) % 65536 != 0) return false; stream.Position = 0; var magicBytes = new byte[4]; @@ -71,22 +70,19 @@ public class AtariLynx : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if((stream.Length - 64) % 65536 != 0) - return ErrorNumber.InvalidArgument; + if((stream.Length - 64) % 65536 != 0) return ErrorNumber.InvalidArgument; stream.Position = 0x0; var magicBytes = new byte[4]; stream.EnsureRead(magicBytes, 0, 4); var magic = BitConverter.ToUInt32(magicBytes, 0); - if(magic != 0x584E594C) - return ErrorNumber.InvalidArgument; + if(magic != 0x584E594C) return ErrorNumber.InvalidArgument; var headerBytes = new byte[64]; stream.Position = 0; @@ -108,8 +104,7 @@ public class AtariLynx : IByteAddressableImage HandyHeader header = Marshal.ByteArrayToStructureBigEndian(headerBytes, 0, 64); - if(header.Version != 256) - return ErrorNumber.NotSupported; + if(header.Version != 256) return ErrorNumber.NotSupported; _imageInfo.MediaTitle = StringHandlers.CToString(header.Name); _imageInfo.MediaManufacturer = StringHandlers.CToString(header.Manufacturer); @@ -119,11 +114,11 @@ public class AtariLynx : IByteAddressableImage sb.AppendFormat(Localization.Name_0, _imageInfo.MediaTitle).AppendLine(); sb.AppendFormat(Localization.Manufacturer_0, _imageInfo.MediaManufacturer).AppendLine(); - sb.AppendFormat(Localization.Bank_zero_size_0_pages_1_bytes, header.Bank0Length, header.Bank0Length * 65536). - AppendLine(); + sb.AppendFormat(Localization.Bank_zero_size_0_pages_1_bytes, header.Bank0Length, header.Bank0Length * 65536) + .AppendLine(); - sb.AppendFormat(Localization.Bank_one_size_0_pages_1_bytes, header.Bank1Length, header.Bank1Length * 65536). - AppendLine(); + sb.AppendFormat(Localization.Bank_one_size_0_pages_1_bytes, header.Bank1Length, header.Bank1Length * 65536) + .AppendLine(); sb.AppendFormat(Localization.Rotation_0, header.Rotation).AppendLine(); @@ -235,8 +230,7 @@ public class AtariLynx : IByteAddressableImage return false; } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaTitle)) - _imageInfo.MediaTitle = imageInfo.MediaTitle[..32]; + if(!string.IsNullOrWhiteSpace(imageInfo.MediaTitle)) _imageInfo.MediaTitle = imageInfo.MediaTitle[..32]; if(!string.IsNullOrWhiteSpace(imageInfo.MediaManufacturer)) _imageInfo.MediaManufacturer = imageInfo.MediaManufacturer[..16]; @@ -345,8 +339,7 @@ public class AtariLynx : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -382,16 +375,13 @@ public class AtariLynx : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -464,8 +454,7 @@ public class AtariLynx : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -509,16 +498,13 @@ public class AtariLynx : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/GameBoy.cs b/Aaru.Images/ByteAddressable/GameBoy.cs index f87d7406d..410e31033 100644 --- a/Aaru.Images/ByteAddressable/GameBoy.cs +++ b/Aaru.Images/ByteAddressable/GameBoy.cs @@ -41,6 +41,7 @@ public class GameBoy : IByteAddressableImage public Guid Id => new("04AFDB93-587E-413B-9B52-10D4A92966CF"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -50,14 +51,12 @@ public class GameBoy : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length % 32768 != 0) - return false; + if(stream.Length % 32768 != 0) return false; stream.Position = 0x104; var magicBytes = new byte[8]; @@ -70,22 +69,19 @@ public class GameBoy : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length % 512 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 512 != 0) return ErrorNumber.InvalidArgument; stream.Position = 0x104; var magicBytes = new byte[8]; stream.EnsureRead(magicBytes, 0, 8); var magic = BitConverter.ToUInt64(magicBytes, 0); - if(magic != 0x0B000DCC6666EDCE) - return ErrorNumber.InvalidArgument; + if(magic != 0x0B000DCC6666EDCE) return ErrorNumber.InvalidArgument; _data = new byte[imageFilter.DataForkLength]; stream.Position = 0; @@ -117,15 +113,13 @@ public class GameBoy : IByteAddressableImage sb.AppendLine(Localization.Requires_Game_Boy_Color); else { - if((header.Name[^1] & 0xC0) == 0xC0) - sb.AppendLine(Localization.Contains_features_for_Game_Boy_Color); + if((header.Name[^1] & 0xC0) == 0xC0) sb.AppendLine(Localization.Contains_features_for_Game_Boy_Color); - if(header.Sgb == 0x03) - sb.AppendLine(Localization.Contains_features_for_Super_Game_Boy); + if(header.Sgb == 0x03) sb.AppendLine(Localization.Contains_features_for_Super_Game_Boy); } - sb.AppendFormat(Localization.Region_0, header.Country == 0 ? Localization.Japan : Localization.World). - AppendLine(); + sb.AppendFormat(Localization.Region_0, header.Country == 0 ? Localization.Japan : Localization.World) + .AppendLine(); sb.AppendFormat(Localization.Cartridge_type_0, DecodeCartridgeType(header.RomType)).AppendLine(); sb.AppendFormat(Localization.ROM_size_0_bytes, DecodeRomSize(header.RomSize)).AppendLine(); @@ -490,16 +484,13 @@ public class GameBoy : IByteAddressableImage mappings = new LinearMemoryMap(); - if(header.SramSize > 0) - hasSaveRam = true; + if(header.SramSize > 0) hasSaveRam = true; var devices = 1; - if(hasSaveRam) - devices++; + if(hasSaveRam) devices++; - if(hasMapper) - devices++; + if(hasMapper) devices++; mappings.Devices = new LinearMemoryDevice[devices]; @@ -561,8 +552,7 @@ public class GameBoy : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -598,16 +588,13 @@ public class GameBoy : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -690,8 +677,7 @@ public class GameBoy : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -735,16 +721,13 @@ public class GameBoy : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; @@ -1032,11 +1015,11 @@ public class GameBoy : IByteAddressableImage 0x1B => Localization.ROM_MBC5_RAM_and_battery, 0x1C => Localization.ROM_MBC5_and_vibration_motor, 0x1D => Localization.ROM_MBC5_RAM_and_vibration_motor, - 0x1E => Localization. - ROM_MBC5_RAM_battery_and_vibration_motor, + 0x1E => Localization + .ROM_MBC5_RAM_battery_and_vibration_motor, 0x20 => Localization.ROM_and_MBC6, - 0x22 => Localization. - ROM_MBC7_RAM_battery_light_sensor_and_vibration_motor, + 0x22 => Localization + .ROM_MBC7_RAM_battery_light_sensor_and_vibration_motor, 0xFC => Localization.Pocket_Camera, 0xFD => Localization.ROM_and_TAMA5, 0xFE => Localization.ROM_and_HuC_3, diff --git a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs index 473ca6943..826be91d3 100644 --- a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs +++ b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs @@ -41,6 +41,7 @@ public class GameBoyAdvance : IByteAddressableImage public Guid Id => new("0040DDEB-3902-4402-9028-62915C5AA81F"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -50,14 +51,12 @@ public class GameBoyAdvance : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length % 32768 != 0) - return false; + if(stream.Length % 32768 != 0) return false; stream.Position = 4; var magicBytes = new byte[8]; @@ -70,22 +69,19 @@ public class GameBoyAdvance : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length % 512 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 512 != 0) return ErrorNumber.InvalidArgument; stream.Position = 4; var magicBytes = new byte[8]; stream.EnsureRead(magicBytes, 0, 8); var magic = BitConverter.ToUInt64(magicBytes, 0); - if(magic != 0x21A29A6951AEFF24) - return ErrorNumber.InvalidArgument; + if(magic != 0x21A29A6951AEFF24) return ErrorNumber.InvalidArgument; _data = new byte[imageFilter.DataForkLength]; stream.Position = 0; @@ -291,8 +287,7 @@ public class GameBoyAdvance : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -328,16 +323,13 @@ public class GameBoyAdvance : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -415,8 +407,7 @@ public class GameBoyAdvance : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -460,16 +451,13 @@ public class GameBoyAdvance : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/MasterSystem.cs b/Aaru.Images/ByteAddressable/MasterSystem.cs index bca5f143a..ed486e64c 100644 --- a/Aaru.Images/ByteAddressable/MasterSystem.cs +++ b/Aaru.Images/ByteAddressable/MasterSystem.cs @@ -43,6 +43,7 @@ public class MasterSystem : IByteAddressableImage public Guid Id => new("B0C02927-890D-41D0-8E95-C5D9A2A74131"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -52,30 +53,26 @@ public class MasterSystem : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length % 8192 != 0) - return false; + if(stream.Length % 8192 != 0) return false; stream.Position = 0x7ff0; var magicBytes = new byte[8]; stream.EnsureRead(magicBytes, 0, 8); var magic = BitConverter.ToUInt64(magicBytes, 0); - if(magic == 0x4147455320524D54) - return true; + if(magic == 0x4147455320524D54) return true; stream.Position = 0x3ff0; magicBytes = new byte[8]; stream.EnsureRead(magicBytes, 0, 8); magic = BitConverter.ToUInt64(magicBytes, 0); - if(magic == 0x4147455320524D54) - return true; + if(magic == 0x4147455320524D54) return true; stream.Position = 0x1ff0; magicBytes = new byte[8]; @@ -88,14 +85,12 @@ public class MasterSystem : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length % 8192 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 8192 != 0) return ErrorNumber.InvalidArgument; var headerPosition = 0; @@ -395,8 +390,7 @@ public class MasterSystem : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -432,16 +426,13 @@ public class MasterSystem : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -514,8 +505,7 @@ public class MasterSystem : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -559,16 +549,13 @@ public class MasterSystem : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/NES.cs b/Aaru.Images/ByteAddressable/NES.cs index 57db614dc..bc4be0689 100644 --- a/Aaru.Images/ByteAddressable/NES.cs +++ b/Aaru.Images/ByteAddressable/NES.cs @@ -57,6 +57,7 @@ public class Nes : IByteAddressableImage public Guid Id => new("D597A3F4-2B1C-441C-8487-0BCABC509302"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -66,14 +67,12 @@ public class Nes : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length < 16) - return false; + if(stream.Length < 16) return false; stream.Position = 0; var magicBytes = new byte[4]; @@ -86,25 +85,21 @@ public class Nes : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length < 16) - return ErrorNumber.InvalidArgument; + if(stream.Length < 16) return ErrorNumber.InvalidArgument; stream.Position = 0; var header = new byte[16]; stream.EnsureRead(header, 0, 8); var magic = BitConverter.ToUInt32(header, 0); - if(magic != 0x1A53454E) - return ErrorNumber.InvalidArgument; + if(magic != 0x1A53454E) return ErrorNumber.InvalidArgument; - if((header[7] & 0x0C) == 0x08) - _nes20 = true; + if((header[7] & 0x0C) == 0x08) _nes20 = true; _prgLen = header[4] * 16384; _chrLen = header[5] * 8192; @@ -144,17 +139,13 @@ public class Nes : IByteAddressableImage else _chrLen += (header[9] >> 4) * 8192; - if((header[10] & 0xF) > 0) - _prgRamLen = 64 << (header[10] & 0xF); + if((header[10] & 0xF) > 0) _prgRamLen = 64 << (header[10] & 0xF); - if((header[10] & 0xF0) > 0) - _prgNvramLen = 64 << ((header[10] & 0xF0) >> 4); + if((header[10] & 0xF0) > 0) _prgNvramLen = 64 << ((header[10] & 0xF0) >> 4); - if((header[11] & 0xF) > 0) - _chrRamLen = 64 << (header[11] & 0xF); + if((header[11] & 0xF) > 0) _chrRamLen = 64 << (header[11] & 0xF); - if((header[11] & 0xF0) > 0) - _chrNvramLen = 64 << ((header[11] & 0xF0) >> 4); + if((header[11] & 0xF0) > 0) _chrNvramLen = 64 << ((header[11] & 0xF0) >> 4); _nesHeaderInfo.TimingMode = (NesTimingMode)(header[12] & 0x3); @@ -196,8 +187,7 @@ public class Nes : IByteAddressableImage sb.AppendFormat(Localization.Trainer_size_0_bytes, trainerLen).AppendLine(); sb.AppendFormat(Localization.Mapper_0, _nesHeaderInfo.Mapper).AppendLine(); - if(_nesHeaderInfo.BatteryPresent) - sb.AppendLine(Localization.Has_battery_backed_RAM); + if(_nesHeaderInfo.BatteryPresent) sb.AppendLine(Localization.Has_battery_backed_RAM); if(_nesHeaderInfo.FourScreenMode) sb.AppendLine(Localization.Uses_four_screen_VRAM); @@ -348,17 +338,13 @@ public class Nes : IByteAddressableImage header[5] = (byte)(_chrLen / 8192 & 0xFF); header[6] = (byte)((_nesHeaderInfo.Mapper & 0xF) << 4); - if(_nesHeaderInfo.FourScreenMode) - header[6] |= 0x8; + if(_nesHeaderInfo.FourScreenMode) header[6] |= 0x8; - if(_trainer) - header[6] |= 0x4; + if(_trainer) header[6] |= 0x4; - if(_nesHeaderInfo.BatteryPresent) - header[6] |= 0x2; + if(_nesHeaderInfo.BatteryPresent) header[6] |= 0x2; - if(_nesHeaderInfo.NametableMirroring) - header[6] |= 0x1; + if(_nesHeaderInfo.NametableMirroring) header[6] |= 0x1; header[7] = (byte)(_mapper & 0xF0 | 0x8); header[7] |= (byte)_nesHeaderInfo.ConsoleType; @@ -381,14 +367,11 @@ public class Nes : IByteAddressableImage header[14] = 0; - if(_instRomLen > 0) - header[14]++; + if(_instRomLen > 0) header[14]++; - if(_promLen > 0) - header[14]++; + if(_promLen > 0) header[14]++; - if(_nesHeaderInfo.ExtendedConsoleType == NesExtendedConsoleType.VT369) - header[14]++; + if(_nesHeaderInfo.ExtendedConsoleType == NesExtendedConsoleType.VT369) header[14]++; switch(_nesHeaderInfo.Mapper) { @@ -633,8 +616,7 @@ public class Nes : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -670,16 +652,13 @@ public class Nes : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -719,6 +698,7 @@ public class Nes : IByteAddressableImage { Regex regex; Match match; + switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -838,8 +818,7 @@ public class Nes : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -883,16 +862,13 @@ public class Nes : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/Nintendo64.cs b/Aaru.Images/ByteAddressable/Nintendo64.cs index eebe6216f..5e8796c35 100644 --- a/Aaru.Images/ByteAddressable/Nintendo64.cs +++ b/Aaru.Images/ByteAddressable/Nintendo64.cs @@ -71,12 +71,17 @@ public class Nintendo64 : IByteAddressableImage public List DumpHardware => null; /// - public string Format => !_opened ? "Nintendo 64 cartridge dump" : _interleaved ? "Doctor V64" : "Mr. Backup Z64"; + public string Format => !_opened + ? "Nintendo 64 cartridge dump" + : _interleaved + ? "Doctor V64" + : "Mr. Backup Z64"; /// public Guid Id => new("EF1B4319-48A0-4EEC-B8E8-D0EA36F8CC92"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -86,14 +91,12 @@ public class Nintendo64 : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length % 512 != 0) - return false; + if(stream.Length % 512 != 0) return false; stream.Position = 0; var magicBytes = new byte[4]; @@ -119,14 +122,12 @@ public class Nintendo64 : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this, maybe more - if(stream.Length % 512 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 512 != 0) return ErrorNumber.InvalidArgument; stream.Position = 0; var magicBytes = new byte[4]; @@ -265,8 +266,7 @@ public class Nintendo64 : IByteAddressableImage string extension = Path.GetExtension(path).ToLowerInvariant(); - if(extension == ".v64") - _interleaved = true; + if(extension == ".v64") _interleaved = true; try { @@ -573,8 +573,7 @@ public class Nintendo64 : IByteAddressableImage Length = (ulong)_data.Length }; - if(saveLength <= 0) - return ErrorNumber.NoError; + if(saveLength <= 0) return ErrorNumber.NoError; mappings.Devices[1].Type = saveType; @@ -611,8 +610,7 @@ public class Nintendo64 : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -648,16 +646,13 @@ public class Nintendo64 : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -737,8 +732,7 @@ public class Nintendo64 : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -782,16 +776,13 @@ public class Nintendo64 : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs index 20614bd1e..21dc628fe 100644 --- a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs +++ b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs @@ -71,14 +71,19 @@ public class SegaMegaDrive : IByteAddressableImage public List DumpHardware => null; /// - public string Format => !_opened ? "Mega Drive cartridge dump" : - _smd ? "Super Magic Drive" : - _interleaved ? "Multi Game Doctor 2" : "Magicom"; + public string Format => !_opened + ? "Mega Drive cartridge dump" + : _smd + ? "Super Magic Drive" + : _interleaved + ? "Multi Game Doctor 2" + : "Magicom"; /// public Guid Id => new("7B1CE2E7-3BC4-4283-BFA4-F292D646DF15"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -88,14 +93,12 @@ public class SegaMegaDrive : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); stream.Position = 0; - if(stream.Length % 512 != 0) - return false; + if(stream.Length % 512 != 0) return false; var buffer = new byte[4]; @@ -103,8 +106,7 @@ public class SegaMegaDrive : IByteAddressableImage stream.EnsureRead(buffer, 0, 4); // SEGA - if(buffer[0] == 0x53 && buffer[1] == 0x45 && buffer[2] == 0x47 && buffer[3] == 0x41) - return true; + if(buffer[0] == 0x53 && buffer[1] == 0x45 && buffer[2] == 0x47 && buffer[3] == 0x41) return true; // EA if(buffer[0] == 0x45 && buffer[1] == 0x41) @@ -113,16 +115,14 @@ public class SegaMegaDrive : IByteAddressableImage stream.EnsureRead(buffer, 0, 2); // SG - if(buffer[0] == 0x53 && buffer[1] == 0x47) - return true; + if(buffer[0] == 0x53 && buffer[1] == 0x47) return true; } stream.Position = 512 + 128; stream.EnsureRead(buffer, 0, 4); // EA - if(buffer[0] != 0x45 || buffer[1] != 0x41) - return false; + if(buffer[0] != 0x45 || buffer[1] != 0x41) return false; stream.Position = 8832; stream.EnsureRead(buffer, 0, 2); @@ -134,14 +134,12 @@ public class SegaMegaDrive : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); stream.Position = 0; - if(stream.Length % 512 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 512 != 0) return ErrorNumber.InvalidArgument; var buffer = new byte[4]; @@ -182,8 +180,7 @@ public class SegaMegaDrive : IByteAddressableImage } } - if(!found) - return ErrorNumber.InvalidArgument; + if(!found) return ErrorNumber.InvalidArgument; _data = new byte[_smd ? stream.Length - 512 : stream.Length]; stream.Position = _smd ? 512 : 0; @@ -241,38 +238,40 @@ public class SegaMegaDrive : IByteAddressableImage var sb = new StringBuilder(); - sb.AppendFormat(Localization.System_type_0, StringHandlers.SpacePaddedToString(header.SystemType, encoding)). - AppendLine(); + sb.AppendFormat(Localization.System_type_0, StringHandlers.SpacePaddedToString(header.SystemType, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Copyright_string_0, - StringHandlers.SpacePaddedToString(header.Copyright, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Copyright_string_0, StringHandlers.SpacePaddedToString(header.Copyright, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Domestic_title_0, - StringHandlers.SpacePaddedToString(header.DomesticTitle, encoding)). - AppendLine(); + StringHandlers.SpacePaddedToString(header.DomesticTitle, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Overseas_title_0, - StringHandlers.SpacePaddedToString(header.OverseasTitle, encoding)). - AppendLine(); + StringHandlers.SpacePaddedToString(header.OverseasTitle, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.Serial_number_0, - StringHandlers.SpacePaddedToString(header.SerialNumber, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Serial_number_0, StringHandlers.SpacePaddedToString(header.SerialNumber, encoding)) + .AppendLine(); sb.AppendFormat(Localization.Checksum_0_X4, header.Checksum).AppendLine(); sb.AppendFormat(Localization.Devices_supported_0, - StringHandlers.SpacePaddedToString(header.DeviceSupport, encoding)). - AppendLine(); + StringHandlers.SpacePaddedToString(header.DeviceSupport, encoding)) + .AppendLine(); - sb.AppendFormat(Localization.ROM_starts_at_0_and_ends_at_1_2_bytes, header.RomStart, header.RomEnd, - header.RomEnd - header.RomStart + 1). - AppendLine(); + sb.AppendFormat(Localization.ROM_starts_at_0_and_ends_at_1_2_bytes, + header.RomStart, + header.RomEnd, + header.RomEnd - header.RomStart + 1) + .AppendLine(); - sb.AppendFormat(Localization.RAM_starts_at_0_and_ends_at_1_2_bytes, header.RamStart, header.RamEnd, - header.RamEnd - header.RamStart + 1). - AppendLine(); + sb.AppendFormat(Localization.RAM_starts_at_0_and_ends_at_1_2_bytes, + header.RamStart, + header.RamEnd, + header.RamEnd - header.RamStart + 1) + .AppendLine(); if(header.ExtraRamPresent[0] == 0x52 && header.ExtraRamPresent[1] == 0x41) { @@ -297,8 +296,8 @@ public class SegaMegaDrive : IByteAddressableImage break; case 0xF0: - sb.AppendLine(Localization. - Extra_RAM_uses_8_bit_access_even_addresses_and_persists_when_powered_off); + sb.AppendLine(Localization + .Extra_RAM_uses_8_bit_access_even_addresses_and_persists_when_powered_off); break; case 0xF8: @@ -311,12 +310,13 @@ public class SegaMegaDrive : IByteAddressableImage break; } - sb.AppendFormat(Localization.Extra_RAM_starts_at_0_and_ends_at_1_2_bytes, header.ExtraRamStart, + sb.AppendFormat(Localization.Extra_RAM_starts_at_0_and_ends_at_1_2_bytes, + header.ExtraRamStart, header.ExtraRamEnd, (header.ExtraRamType & 0x10) == 0x10 ? (header.ExtraRamEnd - header.ExtraRamStart + 2) / 2 - : header.ExtraRamEnd - header.ExtraRamStart + 1). - AppendLine(); + : header.ExtraRamEnd - header.ExtraRamStart + 1) + .AppendLine(); } else sb.AppendLine(Localization.Extra_RAM_not_present); @@ -326,8 +326,8 @@ public class SegaMegaDrive : IByteAddressableImage if(!string.IsNullOrWhiteSpace(modemSupport)) sb.AppendFormat(Localization.Modem_support_0, modemSupport).AppendLine(); - sb.AppendFormat(Localization.Region_support_0, StringHandlers.SpacePaddedToString(header.Region, encoding)). - AppendLine(); + sb.AppendFormat(Localization.Region_support_0, StringHandlers.SpacePaddedToString(header.Region, encoding)) + .AppendLine(); _imageInfo.ImageSize = (ulong)stream.Length; _imageInfo.LastModificationTime = imageFilter.LastWriteTime; @@ -560,8 +560,7 @@ public class SegaMegaDrive : IByteAddressableImage Length = header.RomEnd - header.RomStart + 1 }; - if(!extraRam) - return ErrorNumber.NoError; + if(!extraRam) return ErrorNumber.NoError; mappings.Devices[1].PhysicalAddress = new LinearMemoryAddressing { @@ -665,8 +664,7 @@ public class SegaMegaDrive : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -702,16 +700,13 @@ public class SegaMegaDrive : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -789,8 +784,7 @@ public class SegaMegaDrive : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -834,16 +828,13 @@ public class SegaMegaDrive : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; diff --git a/Aaru.Images/ByteAddressable/SuperNintendo.cs b/Aaru.Images/ByteAddressable/SuperNintendo.cs index c28cc57a3..a2cee7d3a 100644 --- a/Aaru.Images/ByteAddressable/SuperNintendo.cs +++ b/Aaru.Images/ByteAddressable/SuperNintendo.cs @@ -27,6 +27,7 @@ public class SuperNintendo : IByteAddressableImage #region IByteAddressableImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -36,18 +37,15 @@ public class SuperNintendo : IByteAddressableImage /// public bool Identify(IFilter imageFilter) { - if(imageFilter == null) - return false; + if(imageFilter == null) return false; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length % 32768 != 0) - return false; + if(stream.Length % 32768 != 0) return false; // Too many false positives at bigger sizes - if(stream.Length > 16 * 1048576) - return false; + if(stream.Length > 16 * 1048576) return false; // Check exact sizes, too many positives otherwise if(stream.Length != 262144 && @@ -74,8 +72,7 @@ public class SuperNintendo : IByteAddressableImage stream.EnsureRead(headerBytes, 0, 48); header = Marshal.ByteArrayToStructureLittleEndian
(headerBytes); - if((header.Mode & 0xF) == 0x5 || (header.Mode & 0xF) == 0xA) - return true; + if((header.Mode & 0xF) == 0x5 || (header.Mode & 0xF) == 0xA) return true; break; } @@ -86,8 +83,7 @@ public class SuperNintendo : IByteAddressableImage stream.EnsureRead(headerBytes, 0, 48); header = Marshal.ByteArrayToStructureLittleEndian
(headerBytes); - if((header.Mode & 0xF) == 0x1 || (header.Mode & 0xF) == 0xA) - return true; + if((header.Mode & 0xF) == 0x1 || (header.Mode & 0xF) == 0xA) return true; break; } @@ -106,14 +102,12 @@ public class SuperNintendo : IByteAddressableImage /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; Stream stream = imageFilter.GetDataForkStream(); // Not sure but seems to be a multiple of at least this - if(stream.Length % 32768 != 0) - return ErrorNumber.InvalidArgument; + if(stream.Length % 32768 != 0) return ErrorNumber.InvalidArgument; var found = false; var headerBytes = new byte[48]; @@ -127,8 +121,7 @@ public class SuperNintendo : IByteAddressableImage stream.EnsureRead(headerBytes, 0, 48); _header = Marshal.ByteArrayToStructureLittleEndian
(headerBytes); - if((_header.Mode & 0xF) == 0x5 || (_header.Mode & 0xF) == 0xA) - found = true; + if((_header.Mode & 0xF) == 0x5 || (_header.Mode & 0xF) == 0xA) found = true; break; } @@ -139,8 +132,7 @@ public class SuperNintendo : IByteAddressableImage stream.EnsureRead(headerBytes, 0, 48); _header = Marshal.ByteArrayToStructureLittleEndian
(headerBytes); - if((_header.Mode & 0xF) == 0x1 || (_header.Mode & 0xF) == 0xA) - found = true; + if((_header.Mode & 0xF) == 0x1 || (_header.Mode & 0xF) == 0xA) found = true; break; } @@ -158,8 +150,7 @@ public class SuperNintendo : IByteAddressableImage } } - if(!found) - return ErrorNumber.InvalidArgument; + if(!found) return ErrorNumber.InvalidArgument; _data = new byte[imageFilter.DataForkLength]; stream.Position = 0; @@ -195,8 +186,7 @@ public class SuperNintendo : IByteAddressableImage sb.AppendFormat(Localization.Manufacturer_0, _imageInfo.MediaManufacturer).AppendLine(); sb.AppendFormat(Localization.Region_0, DecodeRegion(_header.Region)).AppendLine(); - if(_header.OldMakerCode == 0x33) - sb.AppendFormat(Localization.Game_code_0, _header.GameCode).AppendLine(); + if(_header.OldMakerCode == 0x33) sb.AppendFormat(Localization.Game_code_0, _header.GameCode).AppendLine(); sb.AppendFormat(Localization.Revision_0, _header.Revision).AppendLine(); @@ -218,8 +208,8 @@ public class SuperNintendo : IByteAddressableImage if(_header.ExpansionRamSize > 0) { - sb.AppendFormat(Localization.Expansion_RAM_size_0_bytes, (1 << _header.ExpansionRamSize) * 1024). - AppendLine(); + sb.AppendFormat(Localization.Expansion_RAM_size_0_bytes, (1 << _header.ExpansionRamSize) * 1024) + .AppendLine(); } } @@ -385,14 +375,11 @@ public class SuperNintendo : IByteAddressableImage var devices = 1; - if(hasRam) - devices++; + if(hasRam) devices++; - if(hasExtraRam) - devices++; + if(hasExtraRam) devices++; - if(hasFlash) - devices++; + if(hasFlash) devices++; mappings = new LinearMemoryMap { @@ -484,8 +471,7 @@ public class SuperNintendo : IByteAddressableImage b = _data[position]; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -521,16 +507,13 @@ public class SuperNintendo : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToRead > buffer.Length) - bytesRead = buffer.Length - offset; + if(offset + bytesToRead > buffer.Length) bytesRead = buffer.Length - offset; - if(position + bytesToRead > _data.Length) - bytesToRead = (int)(_data.Length - position); + if(position + bytesToRead > _data.Length) bytesToRead = (int)(_data.Length - position); Array.Copy(_data, position, buffer, offset, bytesToRead); - if(advance) - Position = position + bytesToRead; + if(advance) Position = position + bytesToRead; bytesRead = bytesToRead; @@ -627,8 +610,7 @@ public class SuperNintendo : IByteAddressableImage _data[position] = b; - if(advance) - Position = position + 1; + if(advance) Position = position + 1; return ErrorNumber.NoError; } @@ -672,16 +654,13 @@ public class SuperNintendo : IByteAddressableImage return ErrorNumber.InvalidArgument; } - if(offset + bytesToWrite > buffer.Length) - bytesToWrite = buffer.Length - offset; + if(offset + bytesToWrite > buffer.Length) bytesToWrite = buffer.Length - offset; - if(position + bytesToWrite > _data.Length) - bytesToWrite = (int)(_data.Length - position); + if(position + bytesToWrite > _data.Length) bytesToWrite = (int)(_data.Length - position); Array.Copy(buffer, offset, _data, position, bytesToWrite); - if(advance) - Position = position + bytesToWrite; + if(advance) Position = position + bytesToWrite; bytesWritten = bytesToWrite; @@ -692,8 +671,7 @@ public class SuperNintendo : IByteAddressableImage static string DecodeCoprocessor(byte chipset, byte subtype) { - if((chipset & 0xF) < 3) - return Localization.None_coprocessor; + if((chipset & 0xF) < 3) return Localization.None_coprocessor; return ((chipset & 0xF0) >> 4) switch { @@ -806,8 +784,7 @@ public class SuperNintendo : IByteAddressableImage static string DecodeManufacturer(byte oldMakerCode, string makerCode) { // TODO: Add full table - if(oldMakerCode != 0x33) - makerCode = $"{(oldMakerCode >> 4) * 36 + (oldMakerCode & 0x0f)}"; + if(oldMakerCode != 0x33) makerCode = $"{(oldMakerCode >> 4) * 36 + (oldMakerCode & 0x0f)}"; return makerCode switch { diff --git a/Aaru.Images/CDRDAO/Identify.cs b/Aaru.Images/CDRDAO/Identify.cs index 1077ea316..b0403851a 100644 --- a/Aaru.Images/CDRDAO/Identify.cs +++ b/Aaru.Images/CDRDAO/Identify.cs @@ -58,13 +58,11 @@ public sealed partial class Cdrdao for(var i = 0; i < 512; i++) { - if(i >= imageFilter.GetDataForkStream().Length) - break; + if(i >= imageFilter.GetDataForkStream().Length) break; if(testArray[i] == 0) { - if(twoConsecutiveNulls) - return false; + if(twoConsecutiveNulls) return false; twoConsecutiveNulls = true; } @@ -88,8 +86,7 @@ public sealed partial class Cdrdao Match cm = cr.Match(line ?? ""); // Skip comments at start of file - if(cm.Success) - continue; + if(cm.Success) continue; return dm.Success; } diff --git a/Aaru.Images/CDRDAO/Properties.cs b/Aaru.Images/CDRDAO/Properties.cs index 9e950eafa..1bb84a816 100644 --- a/Aaru.Images/CDRDAO/Properties.cs +++ b/Aaru.Images/CDRDAO/Properties.cs @@ -60,6 +60,7 @@ public sealed partial class Cdrdao OpticalImageCapabilities.CanStoreIndexes; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CDRDAO/Read.cs b/Aaru.Images/CDRDAO/Read.cs index 1ccf87171..25f602bd7 100644 --- a/Aaru.Images/CDRDAO/Read.cs +++ b/Aaru.Images/CDRDAO/Read.cs @@ -53,8 +53,7 @@ public sealed partial class Cdrdao /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; _cdrdaoFilter = imageFilter; @@ -126,12 +125,12 @@ public sealed partial class Cdrdao matchComment = regexComment.Match(line); // Skip comments at start of file - if(matchComment.Success) - continue; + if(matchComment.Success) continue; if(!matchDiskType.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Not_a_CDRDAO_TOC_or_TOC_type_not_in_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Not_a_CDRDAO_TOC_or_TOC_type_not_in_line_0, lineNumber); return ErrorNumber.InvalidArgument; @@ -182,17 +181,20 @@ public sealed partial class Cdrdao if(matchComment.Success) { // Ignore "// Track X" comments - if(matchComment.Groups["comment"].Value.StartsWith(" Track ", StringComparison.Ordinal)) - continue; + if(matchComment.Groups["comment"].Value.StartsWith(" Track ", StringComparison.Ordinal)) continue; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_comment_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_comment_1_at_line_0, + lineNumber, matchComment.Groups["comment"].Value.Trim()); commentBuilder.AppendLine(matchComment.Groups["comment"].Value.Trim()); } else if(matchDiskType.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_1_at_line_0, + lineNumber, matchDiskType.Groups["type"].Value); _discimage.Disktypestr = matchDiskType.Groups["type"].Value; @@ -208,7 +210,9 @@ public sealed partial class Cdrdao } else if(matchMcn.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CATALOG_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CATALOG_1_at_line_0, + lineNumber, matchMcn.Groups["catalog"].Value); _discimage.Mcn = matchMcn.Groups["catalog"].Value; @@ -219,12 +223,15 @@ public sealed partial class Cdrdao { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_TRACK_type_1_with_no_subchannel_at_line_0, - lineNumber, matchTrack.Groups["type"].Value); + lineNumber, + matchTrack.Groups["type"].Value); } else { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_TRACK_type_1_subchannel_2_at_line_0, - lineNumber, matchTrack.Groups["type"].Value, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_TRACK_type_1_subchannel_2_at_line_0, + lineNumber, + matchTrack.Groups["type"].Value, matchTrack.Groups["subchan"].Value); } @@ -293,9 +300,9 @@ public sealed partial class Cdrdao break; default: { - AaruConsole. - ErrorWriteLine(string.Format(Localization.Track_subchannel_mode_0_is_unsupported, - matchTrack.Groups["subchan"].Value)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Track_subchannel_mode_0_is_unsupported, + matchTrack.Groups["subchan"].Value)); return ErrorNumber.NotSupported; } @@ -308,36 +315,45 @@ public sealed partial class Cdrdao } else if(matchCopy.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_1_COPY_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_1_COPY_at_line_0, + lineNumber, matchCopy.Groups["no"].Value); currentTrack.FlagDcp |= inTrack && matchCopy.Groups["no"].Value == ""; } else if(matchEmphasis.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_1_PRE_EMPHASIS_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_1_PRE_EMPHASIS_at_line_0, + lineNumber, matchEmphasis.Groups["no"].Value); currentTrack.FlagPre |= inTrack && matchEmphasis.Groups["no"].Value == ""; } else if(matchStereo.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_1_CHANNEL_AUDIO_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_1_CHANNEL_AUDIO_at_line_0, + lineNumber, matchStereo.Groups["num"].Value); currentTrack.Flag4Ch |= inTrack && matchStereo.Groups["num"].Value == "FOUR"; } else if(matchIsrc.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_ISRC_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_ISRC_1_at_line_0, + lineNumber, matchIsrc.Groups["isrc"].Value); - if(inTrack) - currentTrack.Isrc = matchIsrc.Groups["isrc"].Value; + if(inTrack) currentTrack.Isrc = matchIsrc.Groups["isrc"].Value; } else if(matchIndex.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_INDEX_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_INDEX_1_at_line_0, + lineNumber, matchIndex.Groups["address"].Value); string[] lengthString = matchFile.Groups["length"].Value.Split(':'); @@ -350,7 +366,9 @@ public sealed partial class Cdrdao } else if(matchPregap.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_START_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_START_1_at_line_0, + lineNumber, matchPregap.Groups["address"].Value); currentTrack.Indexes.Add(0, currentTrack.StartSector); @@ -368,7 +386,9 @@ public sealed partial class Cdrdao } else if(matchZeroPregap.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_PREGAP_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_PREGAP_1_at_line_0, + lineNumber, matchZeroPregap.Groups["length"].Value); currentTrack.Indexes.Add(0, currentTrack.StartSector); @@ -380,19 +400,25 @@ public sealed partial class Cdrdao } else if(matchZeroData.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_ZERO_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_ZERO_1_at_line_0, + lineNumber, matchZeroData.Groups["length"].Value); } else if(matchZeroAudio.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_SILENCE_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_SILENCE_1_at_line_0, + lineNumber, matchZeroAudio.Groups["length"].Value); } else { if(matchAudioFile.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_AUDIOFILE_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_AUDIOFILE_1_at_line_0, + lineNumber, matchAudioFile.Groups["filename"].Value); @@ -400,8 +426,8 @@ public sealed partial class Cdrdao { Datafilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - matchAudioFile.Groups["filename"]. - Value)), + matchAudioFile.Groups["filename"] + .Value)), Datafile = matchAudioFile.Groups["filename"].Value, Offset = matchAudioFile.Groups["base_offset"].Value != "" ? ulong.Parse(matchAudioFile.Groups["base_offset"].Value) @@ -441,15 +467,17 @@ public sealed partial class Cdrdao } else if(matchFile.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_DATAFILE_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_DATAFILE_1_at_line_0, + lineNumber, matchFile.Groups["filename"].Value); currentTrack.Trackfile = new CdrdaoTrackFile { Datafilter = PluginRegister.Singleton.GetFilter(Path.Combine(imageFilter.ParentFolder, - matchFile.Groups["filename"]. - Value)), + matchFile.Groups["filename"] + .Value)), Datafile = matchAudioFile.Groups["filename"].Value, Offset = matchFile.Groups["base_offset"].Value != "" ? ulong.Parse(matchFile.Groups["base_offset"].Value) @@ -476,7 +504,9 @@ public sealed partial class Cdrdao } else if(matchTitle.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_TITLE_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_TITLE_1_at_line_0, + lineNumber, matchTitle.Groups["title"].Value); if(inTrack) @@ -486,7 +516,9 @@ public sealed partial class Cdrdao } else if(matchPerformer.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_PERFORMER_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_PERFORMER_1_at_line_0, + lineNumber, matchPerformer.Groups["performer"].Value); if(inTrack) @@ -496,7 +528,9 @@ public sealed partial class Cdrdao } else if(matchSongwriter.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_SONGWRITER_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_SONGWRITER_1_at_line_0, + lineNumber, matchSongwriter.Groups["songwriter"].Value); if(inTrack) @@ -506,7 +540,9 @@ public sealed partial class Cdrdao } else if(matchComposer.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_COMPOSER_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_COMPOSER_1_at_line_0, + lineNumber, matchComposer.Groups["composer"].Value); if(inTrack) @@ -516,7 +552,9 @@ public sealed partial class Cdrdao } else if(matchArranger.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_ARRANGER_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_ARRANGER_1_at_line_0, + lineNumber, matchArranger.Groups["arranger"].Value); if(inTrack) @@ -526,7 +564,9 @@ public sealed partial class Cdrdao } else if(matchMessage.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_MESSAGE_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_MESSAGE_1_at_line_0, + lineNumber, matchMessage.Groups["message"].Value); if(inTrack) @@ -536,19 +576,21 @@ public sealed partial class Cdrdao } else if(matchDiscId.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_DISC_ID_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_DISC_ID_1_at_line_0, + lineNumber, matchDiscId.Groups["discid"].Value); - if(!inTrack) - _discimage.DiskId = matchDiscId.Groups["discid"].Value; + if(!inTrack) _discimage.DiskId = matchDiscId.Groups["discid"].Value; } else if(matchUpc.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_UPC_EAN_1_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_UPC_EAN_1_at_line_0, + lineNumber, matchUpc.Groups["catalog"].Value); - if(!inTrack) - _discimage.Barcode = matchUpc.Groups["catalog"].Value; + if(!inTrack) _discimage.Barcode = matchUpc.Groups["catalog"].Value; } // Ignored fields @@ -635,24 +677,31 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Track_information); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Disc_contains_0_tracks, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Disc_contains_0_tracks, _discimage.Tracks.Count); for(var i = 0; i < _discimage.Tracks.Count; i++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Track_0_information, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Track_0_information, _discimage.Tracks[i].Sequence); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization._0_bytes_per_sector, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization._0_bytes_per_sector, _discimage.Tracks[i].Bps); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Pregap_0_sectors, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Pregap_0_sectors, _discimage.Tracks[i].Pregap); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Data_0_sectors_starting_at_sector_1, - _discimage.Tracks[i].Sectors, _discimage.Tracks[i].StartSector); + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Data_0_sectors_starting_at_sector_1, + _discimage.Tracks[i].Sectors, + _discimage.Tracks[i].StartSector); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Postgap_0_sectors, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Postgap_0_sectors, _discimage.Tracks[i].Postgap); if(_discimage.Tracks[i].Flag4Ch) @@ -675,7 +724,9 @@ public sealed partial class Cdrdao foreach(KeyValuePair kvp in _discimage.Tracks[i].Indexes) { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t\t" + Localization.Index_0_starts_at_sector_1, kvp.Key, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t\t" + Localization.Index_0_starts_at_sector_1, + kvp.Key, kvp.Value); } @@ -688,7 +739,8 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Arranger_is_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Arranger_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Arranger_0, _discimage.Tracks[i].Arranger); } @@ -696,7 +748,8 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Composer_is_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Composer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Composer_0, _discimage.Tracks[i].Composer); } @@ -704,7 +757,8 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Performer_is_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Performer_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Performer_0, _discimage.Tracks[i].Performer); } @@ -712,7 +766,8 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Songwriter_is_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Songwriter_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Songwriter_0, _discimage.Tracks[i].Songwriter); } @@ -779,17 +834,20 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Partition_sequence_0, partition.Sequence); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_name_0, partition.Name); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_description_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_description_0, partition.Description); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_type_0, partition.Type); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_starting_sector_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_starting_sector_0, partition.Start); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_sectors_0, partition.Length); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_starting_offset_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_starting_offset_0, partition.Offset); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_size_in_bytes_0, partition.Size); @@ -812,8 +870,7 @@ public sealed partial class Cdrdao else _imageInfo.SectorSize = 2352; // All others - if(_discimage.Mcn != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + if(_discimage.Mcn != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); _imageInfo.Application = "CDRDAO"; @@ -928,8 +985,7 @@ public sealed partial class Cdrdao { case MediaTagType.CD_MCN: { - if(_discimage.Mcn == null) - return ErrorNumber.NoData; + if(_discimage.Mcn == null) return ErrorNumber.NoData; buffer = Encoding.ASCII.GetBytes(_discimage.Mcn); @@ -1004,11 +1060,9 @@ public sealed partial class Cdrdao break; } - if(aaruTrack.Sequence == 0) - return ErrorNumber.SectorNotFound; + if(aaruTrack.Sequence == 0) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -1073,17 +1127,16 @@ public sealed partial class Cdrdao return ErrorNumber.NotSupported; } - if(aaruTrack.Subchannel) - sectorSkip += 96; + if(aaruTrack.Subchannel) sectorSkip += 96; buffer = new byte[sectorSize * length]; _imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.Trackfile.Offset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(mode2) { @@ -1115,8 +1168,7 @@ public sealed partial class Cdrdao } // cdrdao audio tracks are endian swapped corresponding to Aaru - if(aaruTrack.Tracktype != CDRDAO_TRACK_TYPE_AUDIO) - return ErrorNumber.NoError; + if(aaruTrack.Tracktype != CDRDAO_TRACK_TYPE_AUDIO) return ErrorNumber.NoError; var swapped = new byte[buffer.Length]; @@ -1137,8 +1189,7 @@ public sealed partial class Cdrdao { buffer = null; - if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc) - track = (uint)sectorAddress; + if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc) track = (uint)sectorAddress; var aaruTrack = new CdrdaoTrack { @@ -1152,18 +1203,15 @@ public sealed partial class Cdrdao break; } - if(aaruTrack.Sequence == 0) - return ErrorNumber.SectorNotFound; + if(aaruTrack.Sequence == 0) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset = 0; uint sectorSize = 0; uint sectorSkip = 0; - if(!aaruTrack.Subchannel && tag == SectorTagType.CdSectorSubchannel) - return ErrorNumber.NoData; + if(!aaruTrack.Subchannel && tag == SectorTagType.CdSectorSubchannel) return ErrorNumber.NoData; switch(tag) { @@ -1180,17 +1228,13 @@ public sealed partial class Cdrdao { CdFlags flags = 0; - if(aaruTrack.Tracktype != CDRDAO_TRACK_TYPE_AUDIO) - flags |= CdFlags.DataTrack; + if(aaruTrack.Tracktype != CDRDAO_TRACK_TYPE_AUDIO) flags |= CdFlags.DataTrack; - if(aaruTrack.FlagDcp) - flags |= CdFlags.CopyPermitted; + if(aaruTrack.FlagDcp) flags |= CdFlags.CopyPermitted; - if(aaruTrack.FlagPre) - flags |= CdFlags.PreEmphasis; + if(aaruTrack.FlagPre) flags |= CdFlags.PreEmphasis; - if(aaruTrack.Flag4Ch) - flags |= CdFlags.FourChannel; + if(aaruTrack.Flag4Ch) flags |= CdFlags.FourChannel; buffer = new[] { @@ -1200,8 +1244,7 @@ public sealed partial class Cdrdao return ErrorNumber.NoError; } case SectorTagType.CdTrackIsrc: - if(aaruTrack.Isrc == null) - return ErrorNumber.NoData; + if(aaruTrack.Isrc == null) return ErrorNumber.NoData; buffer = Encoding.UTF8.GetBytes(aaruTrack.Isrc); @@ -1214,8 +1257,7 @@ public sealed partial class Cdrdao { case CDRDAO_TRACK_TYPE_MODE1: case CDRDAO_TRACK_TYPE_MODE2_FORM1: - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NoData; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NoData; sectorOffset = 2048; sectorSize = 96; @@ -1223,16 +1265,14 @@ public sealed partial class Cdrdao break; case CDRDAO_TRACK_TYPE_MODE2_FORM2: case CDRDAO_TRACK_TYPE_MODE2_MIX: - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NoData; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NoData; sectorOffset = 2336; sectorSize = 96; break; case CDRDAO_TRACK_TYPE_AUDIO: - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NoData; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NoData; sectorOffset = 2352; sectorSize = 96; @@ -1304,8 +1344,7 @@ public sealed partial class Cdrdao break; } case CDRDAO_TRACK_TYPE_MODE2_RAW: // Requires reading sector - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NotImplemented; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NotImplemented; sectorOffset = 2352; sectorSize = 96; @@ -1320,9 +1359,9 @@ public sealed partial class Cdrdao _imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.Trackfile.Offset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); @@ -1381,11 +1420,9 @@ public sealed partial class Cdrdao break; } - if(aaruTrack.Sequence == 0) - return ErrorNumber.SectorNotFound; + if(aaruTrack.Sequence == 0) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -1433,8 +1470,7 @@ public sealed partial class Cdrdao return ErrorNumber.NotSupported; } - if(aaruTrack.Subchannel) - sectorSkip += 96; + if(aaruTrack.Subchannel) sectorSkip += 96; buffer = new byte[sectorSize * length]; @@ -1523,7 +1559,8 @@ public sealed partial class Cdrdao for(uint i = 0; i < length; i++) { - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Formless, + _sectorBuilder.ReconstructPrefix(ref fullSector, + TrackType.CdMode2Formless, (long)(sectorAddress + i)); Array.Copy(buffer, i * 2336, fullSector, 16, 2336); diff --git a/Aaru.Images/CDRDAO/Verify.cs b/Aaru.Images/CDRDAO/Verify.cs index 72c4244cb..28123079f 100644 --- a/Aaru.Images/CDRDAO/Verify.cs +++ b/Aaru.Images/CDRDAO/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class Cdrdao unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class Cdrdao } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class Cdrdao unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class Cdrdao } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 83ae9674c..4f47549c8 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -199,9 +199,9 @@ public sealed partial class Cdrdao data = swapped; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -275,9 +275,9 @@ public sealed partial class Cdrdao switch(track.SubchannelType) { case TrackSubchannelType.None: - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -286,9 +286,9 @@ public sealed partial class Cdrdao return true; case TrackSubchannelType.Raw: case TrackSubchannelType.RawInterleaved: - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), + SeekOrigin.Begin); for(uint i = 0; i < length; i++) { @@ -358,9 +358,10 @@ public sealed partial class Cdrdao var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + subchannelSize)), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -428,9 +429,10 @@ public sealed partial class Cdrdao for(uint i = 0; i < length; i++) { - trackStream. - Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (i + sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + subchannelSize)), + SeekOrigin.Begin); trackStream.Write(data, (int)(i * track.RawBytesPerSector), track.RawBytesPerSector); } @@ -457,8 +459,7 @@ public sealed partial class Cdrdao if(_writingTracks != null && _writingStreams != null) { - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) - oldTrack.Close(); + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); } ulong currentOffset = 0; @@ -469,7 +470,8 @@ public sealed partial class Cdrdao if(track.SubchannelType is TrackSubchannelType.Q16 or TrackSubchannelType.Q16Interleaved) { ErrorMessage = string.Format(Localization.Unsupported_subchannel_type_0_for_track_1, - track.SubchannelType, track.Sequence); + track.SubchannelType, + track.Sequence); return false; } @@ -494,17 +496,20 @@ public sealed partial class Cdrdao foreach(Track track in _writingTracks) { _writingStreams.Add(track.Sequence, - new FileStream(track.File, FileMode.OpenOrCreate, FileAccess.ReadWrite, + new FileStream(track.File, + FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None)); } } else { - var jointStream = new FileStream(_writingBaseName + ".bin", FileMode.OpenOrCreate, FileAccess.ReadWrite, + var jointStream = new FileStream(_writingBaseName + ".bin", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); - foreach(Track track in _writingTracks) - _writingStreams.Add(track.Sequence, jointStream); + foreach(Track track in _writingTracks) _writingStreams.Add(track.Sequence, jointStream); } return true; @@ -537,8 +542,9 @@ public sealed partial class Cdrdao bool data = _writingTracks.Count(t => t.Type != TrackType.Audio) > 0; bool mode2 = - _writingTracks.Count(t => t.Type is TrackType.CdMode2Form1 or TrackType.CdMode2Form2 - or TrackType.CdMode2Formless) > + _writingTracks.Count(t => t.Type is TrackType.CdMode2Form1 + or TrackType.CdMode2Form2 + or TrackType.CdMode2Formless) > 0; if(mode2) @@ -551,18 +557,17 @@ public sealed partial class Cdrdao if(!string.IsNullOrWhiteSpace(_discimage.Comment)) { string[] commentLines = _discimage.Comment.Split(new[] - { - '\n' - }, StringSplitOptions.RemoveEmptyEntries); + { + '\n' + }, + StringSplitOptions.RemoveEmptyEntries); - foreach(string line in commentLines) - _descriptorStream.WriteLine("// {0}", line); + foreach(string line in commentLines) _descriptorStream.WriteLine("// {0}", line); } _descriptorStream.WriteLine(); - if(!string.IsNullOrEmpty(_discimage.Mcn)) - _descriptorStream.WriteLine("CATALOG {0}", _discimage.Mcn); + if(!string.IsNullOrEmpty(_discimage.Mcn)) _descriptorStream.WriteLine("CATALOG {0}", _discimage.Mcn); foreach(Track track in _writingTracks) { @@ -610,7 +615,10 @@ public sealed partial class Cdrdao (byte minute, byte second, byte frame) msf = LbaToMsf(track.EndSector - track.StartSector + 1); _descriptorStream.WriteLine("DATAFILE \"{0}\" #{1} {2:D2}:{3:D2}:{4:D2} // length in bytes: {5}", - Path.GetFileName(track.File), track.FileOffset, msf.minute, msf.second, + Path.GetFileName(track.File), + track.FileOffset, + msf.minute, + msf.second, msf.frame, (track.EndSector - track.StartSector + 1) * (ulong)(track.RawBytesPerSector + @@ -689,8 +697,7 @@ public sealed partial class Cdrdao } case SectorTagType.CdTrackIsrc: { - if(data != null) - _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); + if(data != null) _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); return true; } @@ -721,9 +728,10 @@ public sealed partial class Cdrdao return false; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + + track.RawBytesPerSector, + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -790,9 +798,11 @@ public sealed partial class Cdrdao for(uint i = 0; i < length; i++) { - trackStream. - Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (i + sectorAddress - track.StartSector) * + (ulong)(track.RawBytesPerSector + 96)) + + track.RawBytesPerSector, + SeekOrigin.Begin); trackStream.Write(data, (int)(i * 96), 96); } diff --git a/Aaru.Images/CDRWin/Identify.cs b/Aaru.Images/CDRWin/Identify.cs index 9bc6bea34..684fbb08a 100644 --- a/Aaru.Images/CDRWin/Identify.cs +++ b/Aaru.Images/CDRWin/Identify.cs @@ -61,13 +61,11 @@ public sealed partial class CdrWin for(var i = 0; i < 512; i++) { - if(i >= imageFilter.GetDataForkStream().Length) - break; + if(i >= imageFilter.GetDataForkStream().Length) break; if(testArray[i] == 0) { - if(twoConsecutiveNulls) - return false; + if(twoConsecutiveNulls) return false; twoConsecutiveNulls = true; } diff --git a/Aaru.Images/CDRWin/Properties.cs b/Aaru.Images/CDRWin/Properties.cs index 810673b9f..83c2131fe 100644 --- a/Aaru.Images/CDRWin/Properties.cs +++ b/Aaru.Images/CDRWin/Properties.cs @@ -62,6 +62,7 @@ public sealed partial class CdrWin OpticalImageCapabilities.CanStoreIndexes; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -131,8 +132,7 @@ public sealed partial class CdrWin else aaruTrack.StartSector += previousStartSector; - foreach((ushort index, int position) in cdrTrack.Indexes) - aaruTrack.Indexes[index] = position; + foreach((ushort index, int position) in cdrTrack.Indexes) aaruTrack.Indexes[index] = position; previousTrackFile = cdrTrack.TrackFile.DataFilter.Filename; diff --git a/Aaru.Images/CDRWin/Read.cs b/Aaru.Images/CDRWin/Read.cs index 0531d5da2..2190bb6fc 100644 --- a/Aaru.Images/CDRWin/Read.cs +++ b/Aaru.Images/CDRWin/Read.cs @@ -57,8 +57,7 @@ public sealed partial class CdrWin /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.InvalidArgument; + if(imageFilter == null) return ErrorNumber.InvalidArgument; _cdrwinFilter = imageFilter; @@ -141,15 +140,15 @@ public sealed partial class CdrWin matchTrack = regexTrack.Match(line); - if(!matchTrack.Success) - continue; + if(!matchTrack.Success) continue; var trackSeq = uint.Parse(matchTrack.Groups[1].Value); if(trackCount + 1 != trackSeq) { AaruConsole.ErrorWriteLine(string.Format(Localization.Found_TRACK_0_out_of_order_in_line_1, - trackSeq, lineNumber)); + trackSeq, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -237,30 +236,39 @@ public sealed partial class CdrWin if(matchTruripTrackCrc32.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CRC32_for_1_2_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CRC32_for_1_2_at_line_0, + lineNumber, matchTruripTrackCrc32.Groups[1].Value == "Trk" ? Localization.track - : Localization.gap, matchTruripTrackCrc32.Groups[2].Value); + : Localization.gap, + matchTruripTrackCrc32.Groups[2].Value); continue; } if(matchTruripTrackMd5.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_MD5_for_1_2_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_MD5_for_1_2_at_line_0, + lineNumber, matchTruripTrackMd5.Groups[1].Value == "Trk" ? Localization.track - : Localization.gap, matchTruripTrackMd5.Groups[2].Value); + : Localization.gap, + matchTruripTrackMd5.Groups[2].Value); continue; } if(matchTruripTrackSha1.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_SHA1_for_1_2_at_line_0, lineNumber, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_SHA1_for_1_2_at_line_0, + lineNumber, matchTruripTrackSha1.Groups[1].Value == "Trk" ? Localization.track - : Localization.gap, matchTruripTrackSha1.Groups[2].Value); + : Localization.gap, + matchTruripTrackSha1.Groups[2].Value); continue; } @@ -268,12 +276,13 @@ public sealed partial class CdrWin if(matchTruripTrackUnknownHash.Success) { AaruConsole.DebugWriteLine(MODULE_NAME, - Localization. - Found_unknown_hash_for_1_2_at_line_0_Please_report_this_disc_image, + Localization + .Found_unknown_hash_for_1_2_at_line_0_Please_report_this_disc_image, lineNumber, matchTruripTrackUnknownHash.Groups[1].Value == "Trk" ? Localization.track - : Localization.gap, matchTruripTrackUnknownHash.Groups[2].Value); + : Localization.gap, + matchTruripTrackUnknownHash.Groups[2].Value); continue; } @@ -287,7 +296,8 @@ public sealed partial class CdrWin ulong.TryParse(matchDumpExtent.Groups["start"].Value, out ulong extentStart) && ulong.TryParse(matchDumpExtent.Groups["end"].Value, out ulong extentEnd)) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_METADATA_DUMP_EXTENT_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_METADATA_DUMP_EXTENT_at_line_0, lineNumber); DumpHardware ??= new List(); @@ -338,27 +348,30 @@ public sealed partial class CdrWin Start = extentStart, End = extentEnd } - }.OrderBy(e => e.Start). - ToList(); + }.OrderBy(e => e.Start) + .ToList(); } } else if(matchDicMediaType.Success && !inTrack) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_METADATA_DIC_MEDIA_TYPE_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_METADATA_DIC_MEDIA_TYPE_at_line_0, lineNumber); _discImage.AaruMediaType = matchDicMediaType.Groups[1].Value; } else if(matchAaruMediaType.Success && !inTrack) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_METADATA_AARU_MEDIA_TYPE_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_METADATA_AARU_MEDIA_TYPE_at_line_0, lineNumber); _discImage.AaruMediaType = matchAaruMediaType.Groups[1].Value; } else if(matchDiskType.Success && !inTrack) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_ORIGINAL_MEDIA_TYPE_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_ORIGINAL_MEDIA_TYPE_at_line_0, lineNumber); _discImage.OriginalMediaType = matchDiskType.Groups[1].Value; @@ -371,7 +384,8 @@ public sealed partial class CdrWin } else if(matchRedumpSdArea.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_SINGLE_DENSITY_AREA_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_SINGLE_DENSITY_AREA_at_line_0, lineNumber); _discImage.IsRedumpGigadisc = true; @@ -379,7 +393,8 @@ public sealed partial class CdrWin } else if(matchRedumpHdArea.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_HIGH_DENSITY_AREA_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_HIGH_DENSITY_AREA_at_line_0, lineNumber); _discImage.IsRedumpGigadisc = true; @@ -401,7 +416,8 @@ public sealed partial class CdrWin } else if(matchApplicationVersion.Success && !inTrack) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_Ripping_Tool_Version_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_REM_Ripping_Tool_Version_at_line_0, lineNumber); _imageInfo.ApplicationVersion = matchApplicationVersion.Groups[1].Value; @@ -416,7 +432,8 @@ public sealed partial class CdrWin { AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_REM_Gap_Append_Method_1_2_HASHES_at_line_0, - lineNumber, matchTruripTrack.Groups[1].Value, + lineNumber, + matchTruripTrack.Groups[1].Value, matchTruripTrack.Groups[2].Value); inTruripTrackHash = true; @@ -471,10 +488,9 @@ public sealed partial class CdrWin _discImage.Barcode = matchBarCode.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_barcode_field_in_incorrect_place_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_barcode_field_in_incorrect_place_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -487,10 +503,9 @@ public sealed partial class CdrWin _discImage.CdTextFile = matchCdText.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_CD_Text_file_field_in_incorrect_place_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_CD_Text_file_field_in_incorrect_place_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -512,10 +527,9 @@ public sealed partial class CdrWin _discImage.DiscId = matchDiskId.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_CDDB_ID_field_in_incorrect_place_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_CDDB_ID_field_in_incorrect_place_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -643,7 +657,8 @@ public sealed partial class CdrWin } // File does exist, process it - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.File_0_found, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.File_0_found, currentFile.DataFilter.Filename); switch(currentFile.FileType) @@ -674,10 +689,9 @@ public sealed partial class CdrWin if(!inTrack) { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_FLAGS_field_in_incorrect_place_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_FLAGS_field_in_incorrect_place_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -713,9 +727,9 @@ public sealed partial class CdrWin if(index != 0 && index != 1 && currentTrack.Indexes.Count == 0) { - AaruConsole. - ErrorWriteLine(string.Format(Localization.Found_INDEX_0_before_INDEX_00_or_INDEX_01, - index)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_INDEX_0_before_INDEX_00_or_INDEX_01, + index)); return ErrorNumber.InvalidArgument; } @@ -730,14 +744,16 @@ public sealed partial class CdrWin currentFile.Offset += cueTracks[currentTrack.Sequence - 2].Sectors * cueTracks[currentTrack.Sequence - 2].Bps; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Sets_currentFile_offset_to_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Sets_currentFile_offset_to_0, currentFile.Offset); AaruConsole.DebugWriteLine(MODULE_NAME, "cueTracks[currentTrack.sequence-2].sectors = {0}", cueTracks[currentTrack.Sequence - 2].Sectors); - AaruConsole.DebugWriteLine(MODULE_NAME, "cueTracks[currentTrack.sequence-2].bps = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "cueTracks[currentTrack.sequence-2].bps = {0}", cueTracks[currentTrack.Sequence - 2].Bps); } } @@ -745,7 +761,8 @@ public sealed partial class CdrWin if((index == 0 || index == 1 && !currentTrack.Indexes.ContainsKey(0)) && currentTrack.Sequence == 1) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Sets_currentFile_offset_to_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Sets_currentFile_offset_to_0, offset * currentTrack.Bps); currentFile.Offset = (ulong)(offset * currentTrack.Bps); @@ -797,10 +814,9 @@ public sealed partial class CdrWin _discImage.Mcn = matchMcn.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_CATALOG_field_in_incorrect_place_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_CATALOG_field_in_incorrect_place_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -822,9 +838,9 @@ public sealed partial class CdrWin currentTrack.Postgap = CdrWinMsfToLba(matchPostgap.Groups[1].Value); else { - AaruConsole. - ErrorWriteLine(string.Format(Localization.Found_POSTGAP_field_before_a_track_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_POSTGAP_field_before_a_track_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -835,9 +851,9 @@ public sealed partial class CdrWin if(!inTrack) { - AaruConsole. - ErrorWriteLine(string.Format(Localization.Found_PREGAP_field_before_a_track_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_PREGAP_field_before_a_track_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -868,10 +884,9 @@ public sealed partial class CdrWin if(currentFile.DataFilter == null) { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Found_TRACK_field_before_a_file_is_defined_at_line_0, - lineNumber)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Found_TRACK_field_before_a_file_is_defined_at_line_0, + lineNumber)); return ErrorNumber.InvalidArgument; } @@ -892,7 +907,8 @@ public sealed partial class CdrWin Sequence = uint.Parse(matchTrack.Groups[1].Value) }; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Setting_currentTrack_sequence_to_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Setting_currentTrack_sequence_to_0, currentTrack.Sequence); currentFile.Sequence = currentTrack.Sequence; @@ -903,8 +919,8 @@ public sealed partial class CdrWin } else if(line.Contains("INDEX 01 00:-2:00")) { - AaruConsole.ErrorWriteLine(Localization. - This_image_from_PowerISO_is_damaged_beyond_possible_recovery_Will_not_open); + AaruConsole.ErrorWriteLine(Localization + .This_image_from_PowerISO_is_damaged_beyond_possible_recovery_Will_not_open); return ErrorNumber.InvalidArgument; } @@ -913,7 +929,8 @@ public sealed partial class CdrWin else // Non-empty unknown field { AaruConsole.ErrorWriteLine(string.Format(Localization.Found_unknown_field_defined_at_line_0_1, - lineNumber, line)); + lineNumber, + line)); return ErrorNumber.NotSupported; } @@ -940,8 +957,8 @@ public sealed partial class CdrWin if(cueTracks.Any(t => t.Session > 1 || t.TrackFile.DataFilter.Path != firstFile) || cueTracks[0].Indexes.ContainsKey(0)) { - AaruConsole.ErrorWriteLine(Localization. - The_data_files_are_not_correct_according_to_the_cuesheet_file_cannot_continue_with_this_file); + AaruConsole.ErrorWriteLine(Localization + .The_data_files_are_not_correct_according_to_the_cuesheet_file_cannot_continue_with_this_file); return ErrorNumber.InvalidArgument; } @@ -949,13 +966,12 @@ public sealed partial class CdrWin cueTracks[0].Pregap = cueTracks[0].Indexes[1]; int reduceOffset = cueTracks[0].Pregap * cueTracks[0].Bps; - foreach(CdrWinTrack track in cueTracks) - track.TrackFile.Offset -= (ulong)reduceOffset; + foreach(CdrWinTrack track in cueTracks) track.TrackFile.Offset -= (ulong)reduceOffset; if(currentFile.DataFilter.Length - (long)cueTracks[currentTrack.Sequence - 1].TrackFile.Offset < 0) { - AaruConsole.ErrorWriteLine(Localization. - The_data_files_are_not_correct_according_to_the_cuesheet_file_cannot_continue_with_this_file); + AaruConsole.ErrorWriteLine(Localization + .The_data_files_are_not_correct_according_to_the_cuesheet_file_cannot_continue_with_this_file); return ErrorNumber.InvalidArgument; } @@ -968,8 +984,8 @@ public sealed partial class CdrWin _lostPregap = (uint)cueTracks[0].Pregap; cueTracks[0].Sectors += _lostPregap; - AaruConsole.ErrorWriteLine(Localization. - The_data_files_are_missing_a_pregap_or_hidden_track_contents_will_do_best_effort_to_make_the_rest_of_the_image_readable); + AaruConsole.ErrorWriteLine(Localization + .The_data_files_are_missing_a_pregap_or_hidden_track_contents_will_do_best_effort_to_make_the_rest_of_the_image_readable); } var sessions = new Session[currentSession]; @@ -985,8 +1001,7 @@ public sealed partial class CdrWin for(var i = 0; i < cueTracks.Length; i++) { - if(cueTracks[i].Session != s) - continue; + if(cueTracks[i].Session != s) continue; if(!firstTrackRead) { @@ -996,8 +1011,7 @@ public sealed partial class CdrWin sessionSectors += cueTracks[i].Sectors; - if(i > lastSessionTrack) - lastSessionTrack = i; + if(i > lastSessionTrack) lastSessionTrack = i; } if(s > 1) @@ -1029,8 +1043,7 @@ public sealed partial class CdrWin firstSessionTrack.Indexes.TryGetValue(0, out firstSessionTrack.Pregap); - if(firstSessionTrack.Pregap < 150) - firstSessionTrack.Pregap = 150; + if(firstSessionTrack.Pregap < 150) firstSessionTrack.Pregap = 150; if(cueTracks.Any(i => i.TrackFile.DataFilter.Filename != cueTracks.First().TrackFile.DataFilter.Filename)) @@ -1102,8 +1115,8 @@ public sealed partial class CdrWin _imageInfo.Application = "MagicISO"; _discImage.MediaType = MediaType.DVDROM; - AaruConsole.ErrorWriteLine(Localization. - This_image_is_most_probably_corrupted_beyond_repair_It_is_highly_recommended_to_dump_it_with_another_software); + AaruConsole.ErrorWriteLine(Localization + .This_image_is_most_probably_corrupted_beyond_repair_It_is_highly_recommended_to_dump_it_with_another_software); } } @@ -1214,7 +1227,8 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.CD_TEXT_binary_file_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.CD_TEXT_binary_file_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.CD_TEXT_binary_file_0, _discImage.CdTextFile); } @@ -1224,7 +1238,8 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.ISOBuster_disc_type_not_set); else { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.ISOBuster_disc_type_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.ISOBuster_disc_type_0, _discImage.OriginalMediaType); } @@ -1252,7 +1267,8 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Track_information); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Disc_contains_0_tracks, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Disc_contains_0_tracks, _discImage.Tracks.Count); foreach(CdrWinTrack t in _discImage.Tracks) @@ -1268,25 +1284,27 @@ public sealed partial class CdrWin if(t.Flag4Ch) AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_is_flagged_as_quadraphonic); - if(t.FlagDcp) - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_allows_digital_copy); + if(t.FlagDcp) AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_allows_digital_copy); if(t.FlagPre) AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_has_pre_emphasis_applied); - if(t.FlagScms) - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_has_SCMS); + if(t.FlagScms) AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_has_SCMS); AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Track_resides_in_file_0_type_defined_as_1_starting_at_byte_2, - t.TrackFile.DataFilter.Filename, t.TrackFile.FileType, t.TrackFile.Offset); + t.TrackFile.DataFilter.Filename, + t.TrackFile.FileType, + t.TrackFile.Offset); AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Indexes); foreach(KeyValuePair kvp in t.Indexes) { - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t\t" + Localization.Index_0_starts_at_sector_1, kvp.Key, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t\t" + Localization.Index_0_starts_at_sector_1, + kvp.Key, kvp.Value); } @@ -1326,8 +1344,7 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Title_0, t.Title); } - foreach(CdrWinTrack track in _discImage.Tracks) - _imageInfo.ImageSize += track.Bps * track.Sectors; + foreach(CdrWinTrack track in _discImage.Tracks) _imageInfo.ImageSize += track.Bps * track.Sectors; var currentSector = 0; var currentFileStartSector = 0; @@ -1363,8 +1380,8 @@ public sealed partial class CdrWin for(var s = 0; s < sessions.Length; s++) { - if(!_discImage.Tracks[(int)sessions[s].StartTrack - 1]. - Indexes.TryGetValue(0, out int sessionTrackStart)) + if(!_discImage.Tracks[(int)sessions[s].StartTrack - 1] + .Indexes.TryGetValue(0, out int sessionTrackStart)) _discImage.Tracks[(int)sessions[s].StartTrack - 1].Indexes.TryGetValue(1, out sessionTrackStart); sessions[s].StartSector = (ulong)(sessionTrackStart > 0 ? sessionTrackStart : 0); @@ -1376,30 +1393,34 @@ public sealed partial class CdrWin sessions[s].EndSector += _discImage.Tracks[(int)sessions[s].EndTrack - 1].Sectors - 1; } - for(var s = 1; s <= sessions.Length; s++) - _discImage.Sessions.Add(sessions[s - 1]); + for(var s = 1; s <= sessions.Length; s++) _discImage.Sessions.Add(sessions[s - 1]); _imageInfo.Sectors = _discImage.Sessions.MaxBy(s => s.EndSector).EndSector + 1; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Session_information); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Disc_contains_0_sessions, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Disc_contains_0_sessions, _discImage.Sessions.Count); for(var i = 0; i < _discImage.Sessions.Count; i++) { AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Session_0_information, i + 1); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Starting_track_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Starting_track_0, _discImage.Sessions[i].StartTrack); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Starting_sector_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Starting_sector_0, _discImage.Sessions[i].StartSector); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Ending_track_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Ending_track_0, _discImage.Sessions[i].EndTrack); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t\t" + Localization.Ending_sector_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t\t" + Localization.Ending_sector_0, _discImage.Sessions[i].EndSector); } @@ -1468,17 +1489,20 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Partition_sequence_0, partition.Sequence); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_name_0, partition.Name); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_description_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_description_0, partition.Description); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_type_0, partition.Type); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_starting_sector_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_starting_sector_0, partition.Start); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_sectors_0, partition.Length); - AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_starting_offset_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + "\t" + Localization.Partition_starting_offset_0, partition.Offset); AaruConsole.DebugWriteLine(MODULE_NAME, "\t" + Localization.Partition_size_in_bytes_0, partition.Size); @@ -1496,11 +1520,9 @@ public sealed partial class CdrWin else _imageInfo.SectorSize = 2352; // All others - if(_discImage.Mcn != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + if(_discImage.Mcn != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); - if(_discImage.CdTextFile != null) - _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); + if(_discImage.CdTextFile != null) _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); if(_imageInfo.Application is null) { @@ -1617,13 +1639,19 @@ public sealed partial class CdrWin var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = mediaTypeAsInt is >= 10 and <= 39 or 112 or 113 or >= 150 and <= 152 or 154 or 155 - or >= 171 and <= 179 or >= 740 and <= 749; + _isCd = mediaTypeAsInt is >= 10 and <= 39 + or 112 + or 113 + or >= 150 and <= 152 + or 154 + or 155 + or >= 171 and <= 179 + or >= 740 and <= 749; if(currentSession > 1 && leadouts.Count == 0 && !_discImage.IsRedumpGigadisc && _isCd) { - AaruConsole.ErrorWriteLine(Localization. - This_image_is_missing_vital_multi_session_data_and_cannot_be_read_correctly); + AaruConsole.ErrorWriteLine(Localization + .This_image_is_missing_vital_multi_session_data_and_cannot_be_read_correctly); return ErrorNumber.InvalidArgument; } @@ -1631,8 +1659,7 @@ public sealed partial class CdrWin if(_discImage.Tracks.All(t => t.Isrc == null)) _imageInfo.ReadableSectorTags.Remove(SectorTagType.CdTrackIsrc); - if(_isCd) - return ErrorNumber.NoError; + if(_isCd) return ErrorNumber.NoError; _imageInfo.ReadableSectorTags.Remove(SectorTagType.CdSectorSync); _imageInfo.ReadableSectorTags.Remove(SectorTagType.CdSectorHeader); @@ -1653,8 +1680,7 @@ public sealed partial class CdrWin for(var s = 0; s < sessions.Length; s++) { - if(sessions[s].Sequence <= 1 || track.Sequence != sessions[s].StartTrack) - continue; + if(sessions[s].Sequence <= 1 || track.Sequence != sessions[s].StartTrack) continue; track.TrackFile.Offset += 307200; track.Sectors -= 150; @@ -1684,8 +1710,7 @@ public sealed partial class CdrWin { case MediaTagType.CD_MCN: { - if(_discImage.Mcn == null) - return ErrorNumber.NoData; + if(_discImage.Mcn == null) return ErrorNumber.NoData; buffer = Encoding.ASCII.GetBytes(_discImage.Mcn); @@ -1757,11 +1782,9 @@ public sealed partial class CdrWin buffer = null; CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -1843,15 +1866,13 @@ public sealed partial class CdrWin if(sectorAddress < _lostPregap) { // If we need to mix lost with present data - if(sectorAddress + length <= _lostPregap) - return ErrorNumber.NoError; + if(sectorAddress + length <= _lostPregap) return ErrorNumber.NoError; ulong pregapPos = _lostPregap - sectorAddress; ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(presentData, 0, buffer, (long)(pregapPos * sectorSize), presentData.Length); @@ -1874,10 +1895,11 @@ public sealed partial class CdrWin ulong pregapPos = (ulong)(aaruTrack.Indexes[1] - aaruTrack.Indexes[0]) - sectorAddress; ErrorNumber errno = ReadSectors((ulong)(aaruTrack.Indexes[1] - aaruTrack.Indexes[0]), - (uint)(length - pregapPos), track, out byte[] presentData); + (uint)(length - pregapPos), + track, + out byte[] presentData); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(presentData, 0, buffer, (long)(pregapPos * sectorSize), presentData.Length); @@ -1890,9 +1912,9 @@ public sealed partial class CdrWin _imageStream = aaruTrack.TrackFile.DataFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.TrackFile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.TrackFile.Offset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(mode2) { @@ -1932,16 +1954,13 @@ public sealed partial class CdrWin { buffer = null; - if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc) - track = (uint)sectorAddress; + if(tag is SectorTagType.CdTrackFlags or SectorTagType.CdTrackIsrc) track = (uint)sectorAddress; CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset = 0; uint sectorSize = 0; @@ -1965,14 +1984,11 @@ public sealed partial class CdrWin if(aaruTrack.TrackType != CDRWIN_TRACK_TYPE_AUDIO && aaruTrack.TrackType != CDRWIN_TRACK_TYPE_CDG) flags |= CdFlags.DataTrack; - if(aaruTrack.FlagDcp) - flags |= CdFlags.CopyPermitted; + if(aaruTrack.FlagDcp) flags |= CdFlags.CopyPermitted; - if(aaruTrack.FlagPre) - flags |= CdFlags.PreEmphasis; + if(aaruTrack.FlagPre) flags |= CdFlags.PreEmphasis; - if(aaruTrack.Flag4Ch) - flags |= CdFlags.FourChannel; + if(aaruTrack.Flag4Ch) flags |= CdFlags.FourChannel; buffer = new[] { @@ -1982,8 +1998,7 @@ public sealed partial class CdrWin return ErrorNumber.NoError; } case SectorTagType.CdTrackIsrc: - if(aaruTrack.Isrc == null) - return ErrorNumber.NoData; + if(aaruTrack.Isrc == null) return ErrorNumber.NoData; buffer = Encoding.UTF8.GetBytes(aaruTrack.Isrc); @@ -2122,8 +2137,7 @@ public sealed partial class CdrWin return ErrorNumber.NotImplemented; case CDRWIN_TRACK_TYPE_CDG: { - if(tag != SectorTagType.CdSectorSubchannel) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.CdSectorSubchannel) return ErrorNumber.NotSupported; sectorOffset = 2352; sectorSize = 96; @@ -2143,15 +2157,13 @@ public sealed partial class CdrWin if(sectorAddress < _lostPregap) { // If we need to mix lost with present data - if(sectorAddress + length <= _lostPregap) - return ErrorNumber.NoError; + if(sectorAddress + length <= _lostPregap) return ErrorNumber.NoError; ulong pregapPos = _lostPregap - sectorAddress; ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(presentData, 0, buffer, (long)(pregapPos * sectorSize), presentData.Length); @@ -2164,9 +2176,9 @@ public sealed partial class CdrWin _imageStream = aaruTrack.TrackFile.DataFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.TrackFile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.TrackFile.Offset + + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); @@ -2213,16 +2225,13 @@ public sealed partial class CdrWin { buffer = null; - if(!_isCd) - return ReadSectors(sectorAddress, length, track, out buffer); + if(!_isCd) return ReadSectors(sectorAddress, length, track, out buffer); CdrWinTrack aaruTrack = _discImage.Tracks.FirstOrDefault(cdrwinTrack => cdrwinTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length > aaruTrack.Sectors) - return ErrorNumber.OutOfRange; + if(length > aaruTrack.Sectors) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -2287,15 +2296,13 @@ public sealed partial class CdrWin if(sectorAddress < _lostPregap) { // If we need to mix lost with present data - if(sectorAddress + length <= _lostPregap) - return ErrorNumber.NoError; + if(sectorAddress + length <= _lostPregap) return ErrorNumber.NoError; ulong pregapPos = _lostPregap - sectorAddress; ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(presentData, 0, buffer, (long)(pregapPos * sectorSize), presentData.Length); @@ -2318,10 +2325,11 @@ public sealed partial class CdrWin ulong pregapPos = (ulong)(aaruTrack.Indexes[1] - aaruTrack.Indexes[0]) - sectorAddress; ErrorNumber errno = ReadSectorsLong((ulong)(aaruTrack.Indexes[1] - aaruTrack.Indexes[0]), - (uint)(length - pregapPos), track, out byte[] presentData); + (uint)(length - pregapPos), + track, + out byte[] presentData); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; Array.Copy(presentData, 0, buffer, (long)(pregapPos * sectorSize), presentData.Length); @@ -2416,7 +2424,8 @@ public sealed partial class CdrWin for(uint i = 0; i < length; i++) { - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Formless, + _sectorBuilder.ReconstructPrefix(ref fullSector, + TrackType.CdMode2Formless, (long)(sectorAddress + i)); Array.Copy(buffer, i * 2336, fullSector, 16, 2336); diff --git a/Aaru.Images/CDRWin/Verify.cs b/Aaru.Images/CDRWin/Verify.cs index 04e118508..93ef11df8 100644 --- a/Aaru.Images/CDRWin/Verify.cs +++ b/Aaru.Images/CDRWin/Verify.cs @@ -49,18 +49,17 @@ public sealed partial class CdrWin /// public bool? VerifyMediaImage() { - if(_discImage.DiscHashes.Count == 0) - return null; + if(_discImage.DiscHashes.Count == 0) return null; // Read up to 1 MiB at a time for verification const int verifySize = 1024 * 1024; long readBytes; byte[] verifyBytes; - IFilter[] filters = _discImage.Tracks.OrderBy(t => t.Sequence). - Select(t => t.TrackFile.DataFilter). - Distinct(). - ToArray(); + IFilter[] filters = _discImage.Tracks.OrderBy(t => t.Sequence) + .Select(t => t.TrackFile.DataFilter) + .Distinct() + .ToArray(); if(_discImage.DiscHashes.TryGetValue("sha1", out string sha1)) { @@ -172,8 +171,7 @@ public sealed partial class CdrWin unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -196,8 +194,7 @@ public sealed partial class CdrWin } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -210,8 +207,7 @@ public sealed partial class CdrWin unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -234,8 +230,7 @@ public sealed partial class CdrWin } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index c1b6660a2..c7fcd800a 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -112,7 +112,13 @@ public sealed partial class CdrWin var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = mediaTypeAsInt is >= 10 and <= 39 or 112 or 113 or >= 150 and <= 152 or 154 or 155 or >= 171 and <= 179 + _isCd = mediaTypeAsInt is >= 10 and <= 39 + or 112 + or 113 + or >= 150 and <= 152 + or 154 + or 155 + or >= 171 and <= 179 or >= 740 and <= 749; if(_isCd) @@ -144,8 +150,10 @@ public sealed partial class CdrWin return true; case MediaTagType.CD_TEXT when _isCd: - var cdTextStream = new FileStream(_writingBaseName + "_cdtext.bin", FileMode.Create, - FileAccess.ReadWrite, FileShare.None); + var cdTextStream = new FileStream(_writingBaseName + "_cdtext.bin", + FileMode.Create, + FileAccess.ReadWrite, + FileShare.None); cdTextStream.Write(data, 0, data.Length); _discImage.CdTextFile = Path.GetFileName(cdTextStream.Name); @@ -202,9 +210,9 @@ public sealed partial class CdrWin return false; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -261,9 +269,9 @@ public sealed partial class CdrWin return false; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -306,9 +314,9 @@ public sealed partial class CdrWin return false; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -358,9 +366,9 @@ public sealed partial class CdrWin return false; } - trackStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + trackStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -386,8 +394,7 @@ public sealed partial class CdrWin if(_writingTracks != null && _writingStreams != null) { - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) - oldTrack.Close(); + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); } _writingTracks = new List(); @@ -409,17 +416,20 @@ public sealed partial class CdrWin foreach(Track track in _writingTracks) { _writingStreams.Add(track.Sequence, - new FileStream(track.File, FileMode.OpenOrCreate, FileAccess.ReadWrite, + new FileStream(track.File, + FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None)); } } else { - var jointStream = new FileStream(_writingBaseName + ".bin", FileMode.OpenOrCreate, FileAccess.ReadWrite, + var jointStream = new FileStream(_writingBaseName + ".bin", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); - foreach(Track track in _writingTracks) - _writingStreams.Add(track.Sequence, jointStream); + foreach(Track track in _writingTracks) _writingStreams.Add(track.Sequence, jointStream); } return true; @@ -454,12 +464,12 @@ public sealed partial class CdrWin if(!string.IsNullOrWhiteSpace(_discImage.Comment)) { string[] commentLines = _discImage.Comment.Split(new[] - { - '\n' - }, StringSplitOptions.RemoveEmptyEntries); + { + '\n' + }, + StringSplitOptions.RemoveEmptyEntries); - foreach(string line in commentLines) - _descriptorStream.WriteLine("REM {0}", line); + foreach(string line in commentLines) _descriptorStream.WriteLine("REM {0}", line); } _descriptorStream.WriteLine("REM ORIGINAL MEDIA-TYPE: {0}", MediaTypeToCdrwinType(_imageInfo.MediaType)); @@ -500,14 +510,11 @@ public sealed partial class CdrWin if(!string.IsNullOrEmpty(_discImage.CdTextFile)) _descriptorStream.WriteLine("CDTEXTFILE \"{0}\"", Path.GetFileName(_discImage.CdTextFile)); - if(!string.IsNullOrEmpty(_discImage.Title)) - _descriptorStream.WriteLine("TITLE {0}", _discImage.Title); + if(!string.IsNullOrEmpty(_discImage.Title)) _descriptorStream.WriteLine("TITLE {0}", _discImage.Title); - if(!string.IsNullOrEmpty(_discImage.Mcn)) - _descriptorStream.WriteLine("CATALOG {0}", _discImage.Mcn); + if(!string.IsNullOrEmpty(_discImage.Mcn)) _descriptorStream.WriteLine("CATALOG {0}", _discImage.Mcn); - if(!string.IsNullOrEmpty(_discImage.Barcode)) - _descriptorStream.WriteLine("UPC_EAN {0}", _discImage.Barcode); + if(!string.IsNullOrEmpty(_discImage.Barcode)) _descriptorStream.WriteLine("UPC_EAN {0}", _discImage.Barcode); if(!_separateTracksWriting) _descriptorStream.WriteLine("FILE \"{0}\" BINARY", Path.GetFileName(_writingStreams.First().Value.Name)); @@ -530,11 +537,9 @@ public sealed partial class CdrWin break; } - if(track.Session > currentSession) - _descriptorStream.WriteLine("REM SESSION {0}", ++currentSession); + if(track.Session > currentSession) _descriptorStream.WriteLine("REM SESSION {0}", ++currentSession); - if(_separateTracksWriting) - _descriptorStream.WriteLine("FILE \"{0}\" BINARY", Path.GetFileName(track.File)); + if(_separateTracksWriting) _descriptorStream.WriteLine("FILE \"{0}\" BINARY", Path.GetFileName(track.File)); (byte minute, byte second, byte frame) msf = LbaToMsf(track.StartSector); _descriptorStream.WriteLine(" TRACK {0:D2} {1}", track.Sequence, GetTrackMode(track)); @@ -562,19 +567,27 @@ public sealed partial class CdrWin { if(track.Sequence > _writingTracks.Where(t => t.Session == track.Session).Min(t => t.Sequence)) { - _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", 0, msf.minute, msf.second, + _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", + 0, + msf.minute, + msf.second, msf.frame); } - if(track.Sequence > 1) - msf = LbaToMsf(track.StartSector + track.Pregap); + if(track.Sequence > 1) msf = LbaToMsf(track.StartSector + track.Pregap); - _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", 1, msf.minute, msf.second, + _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", + 1, + msf.minute, + msf.second, msf.frame); } else { - _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", 1, msf.minute, msf.second, + _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", + 1, + msf.minute, + msf.second, msf.frame); } @@ -584,20 +597,21 @@ public sealed partial class CdrWin { msf = LbaToMsf((ulong)index.Value); - _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", index.Key, msf.minute, - msf.second, msf.frame); + _descriptorStream.WriteLine(" INDEX {0:D2} {1:D2}:{2:D2}:{3:D2}", + index.Key, + msf.minute, + msf.second, + msf.frame); } } ushort lastSession = _writingTracks.Max(t => t.Session); - if(currentSession >= lastSession) - continue; + if(currentSession >= lastSession) continue; Track lastTrackInSession = _writingTracks.Where(t => t.Session == currentSession).MaxBy(t => t.Sequence); - if(track.Sequence != lastTrackInSession.Sequence) - continue; + if(track.Sequence != lastTrackInSession.Sequence) continue; msf = LbaToMsf(track.EndSector + 1); _descriptorStream.WriteLine("REM LEAD-OUT {0:D2}:{1:D2}:{2:D2}", msf.minute, msf.second, msf.frame); @@ -657,8 +671,7 @@ public sealed partial class CdrWin } case SectorTagType.CdTrackIsrc when _isCd: { - if(data != null) - _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); + if(data != null) _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); return true; } diff --git a/Aaru.Images/CHD/Helpers.cs b/Aaru.Images/CHD/Helpers.cs index dd0370152..84f1981a5 100644 --- a/Aaru.Images/CHD/Helpers.cs +++ b/Aaru.Images/CHD/Helpers.cs @@ -64,8 +64,7 @@ public sealed partial class Chd ErrorNumber GetHunk(ulong hunkNo, out byte[] buffer) { - if(_hunkCache.TryGetValue(hunkNo, out buffer)) - return ErrorNumber.NoError; + if(_hunkCache.TryGetValue(hunkNo, out buffer)) return ErrorNumber.NoError; switch(_mapVersion) { @@ -94,10 +93,10 @@ public sealed partial class Chd if(read != _sectorsPerHunk * _imageInfo.SectorSize) { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1, - read, _sectorsPerHunk * _imageInfo.SectorSize)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1, + read, + _sectorsPerHunk * _imageInfo.SectorSize)); return ErrorNumber.InOutError; } @@ -138,10 +137,10 @@ public sealed partial class Chd if(read != _bytesPerHunk) { - AaruConsole. - ErrorWriteLine(string. - Format(Localization.Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1, - read, _bytesPerHunk)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Unable_to_decompress_hunk_correctly_got_0_bytes_expected_1, + read, + _bytesPerHunk)); return ErrorNumber.InOutError; } @@ -152,8 +151,8 @@ public sealed partial class Chd // TODO: Guess wth is MAME doing with these hunks else { - AaruConsole.ErrorWriteLine(Localization. - Compressed_CD_GD_ROM_hunks_are_not_yet_supported); + AaruConsole.ErrorWriteLine(Localization + .Compressed_CD_GD_ROM_hunks_are_not_yet_supported); return ErrorNumber.NotImplemented; } @@ -178,8 +177,7 @@ public sealed partial class Chd buffer = new byte[_bytesPerHunk]; byte[] mini = BigEndianBitConverter.GetBytes(entry.offset); - for(var i = 0; i < _bytesPerHunk; i++) - buffer[i] = mini[i % 8]; + for(var i = 0; i < _bytesPerHunk; i++) buffer[i] = mini[i % 8]; break; case EntryFlagsV3.SelfHunk: @@ -221,8 +219,7 @@ public sealed partial class Chd return ErrorNumber.NotSupported; } - if(_hunkCache.Count >= _maxBlockCache) - _hunkCache.Clear(); + if(_hunkCache.Count >= _maxBlockCache) _hunkCache.Clear(); _hunkCache.Add(hunkNo, buffer); diff --git a/Aaru.Images/CHD/Properties.cs b/Aaru.Images/CHD/Properties.cs index e99857b2c..4086f2716 100644 --- a/Aaru.Images/CHD/Properties.cs +++ b/Aaru.Images/CHD/Properties.cs @@ -45,6 +45,7 @@ public sealed partial class Chd #region IOpticalMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; @@ -71,8 +72,7 @@ public sealed partial class Chd { get { - if(_isHdd) - return null; + if(_isHdd) return null; // TODO: Implement return null; diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index 1f321c518..28ec384cf 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -63,8 +63,7 @@ public sealed partial class Chd var magic = new byte[8]; stream.EnsureRead(magic, 0, 8); - if(!_chdTag.SequenceEqual(magic)) - return ErrorNumber.InvalidArgument; + if(!_chdTag.SequenceEqual(magic)) return ErrorNumber.InvalidArgument; // Read length var buffer = new byte[4]; @@ -102,7 +101,8 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV1.sectors = {0}", hdrV1.sectors); AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV1.md5 = {0}", ArrayHelpers.ByteArrayToHex(hdrV1.md5)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV1.parentmd5 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV1.parentmd5 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV1.parentmd5) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV1.parentmd5)); @@ -135,7 +135,8 @@ public sealed partial class Chd hunkMapStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds, hunkMapStopwatch.Elapsed.TotalSeconds); _imageInfo.MediaType = MediaType.GENERIC_HDD; @@ -177,7 +178,8 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV2.sectors = {0}", hdrV2.sectors); AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV2.md5 = {0}", ArrayHelpers.ByteArrayToHex(hdrV2.md5)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV2.parentmd5 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV2.parentmd5 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV2.parentmd5) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV2.parentmd5)); @@ -213,7 +215,8 @@ public sealed partial class Chd hunkMapStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds, hunkMapStopwatch.Elapsed.TotalSeconds); _imageInfo.MediaType = MediaType.GENERIC_HDD; @@ -253,7 +256,8 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV3.metaoffset = {0}", hdrV3.metaoffset); AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV3.md5 = {0}", ArrayHelpers.ByteArrayToHex(hdrV3.md5)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV3.parentmd5 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV3.parentmd5 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV3.parentmd5) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV3.parentmd5)); @@ -262,7 +266,8 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV3.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV3.sha1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV3.parentsha1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV3.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV3.parentsha1) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV3.parentsha1)); @@ -275,7 +280,8 @@ public sealed partial class Chd hunkMapStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds, hunkMapStopwatch.Elapsed.TotalSeconds); nextMetaOff = hdrV3.metaoffset; @@ -310,12 +316,14 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV4.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV4.sha1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV4.parentsha1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV4.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV4.parentsha1) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV4.parentsha1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV4.rawsha1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV4.rawsha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV4.rawsha1)); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reading_Hunk_map); @@ -326,7 +334,8 @@ public sealed partial class Chd hunkMapStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds, hunkMapStopwatch.Elapsed.TotalSeconds); nextMetaOff = hdrV4.metaoffset; @@ -356,16 +365,20 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.length = {0} bytes", hdrV5.length); AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.version = {0}", hdrV5.version); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.compressor0 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.compressor0 = \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor0))); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.compressor1 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.compressor1 = \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor1))); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.compressor2 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.compressor2 = \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor2))); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.compressor3 = \"{0}\"", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.compressor3 = \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor3))); AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.logicalbytes = {0}", hdrV5.logicalbytes); @@ -376,12 +389,14 @@ public sealed partial class Chd AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV5.sha1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.parentsha1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV5.parentsha1) ? "null" : ArrayHelpers.ByteArrayToHex(hdrV5.parentsha1)); - AaruConsole.DebugWriteLine(MODULE_NAME, "hdrV5.rawsha1 = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "hdrV5.rawsha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV5.rawsha1)); // TODO: Implement compressed CHD v5 @@ -415,14 +430,18 @@ public sealed partial class Chd Array.Copy(hunkSector.hunkEntry, 0, _hunkTableSmall, i * 512 / 4, 512 / 4); else { - Array.Copy(hunkSector.hunkEntry, 0, _hunkTableSmall, i * 512 / 4, - _hunkTableSmall.Length - i * 512 / 4); + Array.Copy(hunkSector.hunkEntry, + 0, + _hunkTableSmall, + i * 512 / 4, + _hunkTableSmall.Length - i * 512 / 4); } } hunkMapStopwatch.Stop(); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Took_0_seconds, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Took_0_seconds, hunkMapStopwatch.Elapsed.TotalSeconds); } else @@ -476,7 +495,8 @@ public sealed partial class Chd var meta = new byte[header.flagsAndLength & 0xFFFFFF]; stream.EnsureRead(meta, 0, meta.Length); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_metadata_0_, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_metadata_0_, Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(header.tag))); switch(header.tag) @@ -485,8 +505,8 @@ public sealed partial class Chd case HARD_DISK_METADATA: if(_isCdrom || _isGdrom) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_hard_disk_and_a_CGD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_hard_disk_and_a_CGD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } @@ -510,16 +530,16 @@ public sealed partial class Chd case CDROM_OLD_METADATA: if(_isHdd) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } if(_isGdrom) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } @@ -527,8 +547,7 @@ public sealed partial class Chd var chdTracksNumber = BigEndianBitConverter.ToUInt32(meta, 0); // Byteswapped - if(chdTracksNumber > 99) - chdTracksNumber = BigEndianBitConverter.ToUInt32(meta, 0); + if(chdTracksNumber > 99) chdTracksNumber = BigEndianBitConverter.ToUInt32(meta, 0); currentSector = 0; @@ -636,8 +655,7 @@ public sealed partial class Chd aaruTrack.Sequence = i + 1; aaruTrack.Session = 1; - if(aaruTrack.Sequence == 1) - aaruTrack.Indexes.Add(0, -150); + if(aaruTrack.Sequence == 1) aaruTrack.Indexes.Add(0, -150); aaruTrack.Indexes.Add(1, (int)currentSector); currentSector += chdTrack.frames + chdTrack.extraFrames; @@ -652,16 +670,16 @@ public sealed partial class Chd case CDROM_TRACK_METADATA: if(_isHdd) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } if(_isGdrom) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } @@ -784,8 +802,7 @@ public sealed partial class Chd aaruTrack.Sequence = trackNo; aaruTrack.Session = 1; - if(aaruTrack.Sequence == 1) - aaruTrack.Indexes.Add(0, -150); + if(aaruTrack.Sequence == 1) aaruTrack.Indexes.Add(0, -150); aaruTrack.Indexes.Add(1, (int)currentSector); currentSector += frames; @@ -799,16 +816,16 @@ public sealed partial class Chd case CDROM_TRACK_METADATA2: if(_isHdd) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_hard_disk_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } if(_isGdrom) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_GD_ROM_and_a_CD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } @@ -985,16 +1002,16 @@ public sealed partial class Chd case GDROM_METADATA: if(_isHdd) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_hard_disk_and_a_GD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_hard_disk_and_a_GD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } if(_isCdrom) { - AaruConsole.ErrorWriteLine(Localization. - Image_cannot_be_a_CD_ROM_and_a_GD_ROM_at_the_same_time_aborting); + AaruConsole.ErrorWriteLine(Localization + .Image_cannot_be_a_CD_ROM_and_a_GD_ROM_at_the_same_time_aborting); return ErrorNumber.NotSupported; } @@ -1341,8 +1358,7 @@ public sealed partial class Chd // TODO: Detect CompactFlash // TODO: Get manufacturer and drive name from CIS if applicable - if(_cis != null) - _imageInfo.MediaType = MediaType.PCCardTypeI; + if(_cis != null) _imageInfo.MediaType = MediaType.PCCardTypeI; _sectorBuilder = new SectorBuilder(); @@ -1354,8 +1370,7 @@ public sealed partial class Chd { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; var track = new Track(); uint sectorSize; @@ -1375,14 +1390,12 @@ public sealed partial class Chd ErrorNumber errno = GetHunk(hunkNo, out byte[] hunk); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(_sectorCache.Count >= _maxSectorCache) - _sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) _sectorCache.Clear(); _sectorCache.Add(sectorAddress, sector); } @@ -1492,11 +1505,9 @@ public sealed partial class Chd { buffer = null; - if(_isHdd) - return ErrorNumber.NotSupported; + if(_isHdd) return ErrorNumber.NotSupported; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; var track = new Track(); @@ -1512,14 +1523,12 @@ public sealed partial class Chd ErrorNumber errno = GetHunk(hunkNo, out byte[] hunk); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(_sectorCache.Count >= _maxSectorCache) - _sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) _sectorCache.Clear(); _sectorCache.Add(sectorAddress, sector); } @@ -1772,11 +1781,9 @@ public sealed partial class Chd { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -1784,8 +1791,7 @@ public sealed partial class Chd { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -1800,11 +1806,9 @@ public sealed partial class Chd { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -1812,8 +1816,7 @@ public sealed partial class Chd { ErrorNumber errno = ReadSectorTag(sectorAddress + i, tag, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -1828,11 +1831,9 @@ public sealed partial class Chd { buffer = null; - if(_isHdd) - return ReadSector(sectorAddress, out buffer); + if(_isHdd) return ReadSector(sectorAddress, out buffer); - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; var track = new Track(); @@ -1846,14 +1847,12 @@ public sealed partial class Chd ErrorNumber errno = GetHunk(hunkNo, out byte[] hunk); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(_sectorCache.Count >= _maxSectorCache) - _sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) _sectorCache.Clear(); _sectorCache.Add(sectorAddress, sector); } @@ -1930,11 +1929,9 @@ public sealed partial class Chd { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -1942,8 +1939,7 @@ public sealed partial class Chd { ErrorNumber errno = ReadSectorLong(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -1966,8 +1962,7 @@ public sealed partial class Chd return buffer == null ? ErrorNumber.NoData : ErrorNumber.NoError; case MediaTagType.PCMCIA_CIS: - if(_imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) - buffer = _cis?.Clone() as byte[]; + if(_imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) buffer = _cis?.Clone() as byte[]; return buffer == null ? ErrorNumber.NoData : ErrorNumber.NoError; default: diff --git a/Aaru.Images/CHD/Verify.cs b/Aaru.Images/CHD/Verify.cs index 96e00db9e..4564a27e7 100644 --- a/Aaru.Images/CHD/Verify.cs +++ b/Aaru.Images/CHD/Verify.cs @@ -45,8 +45,7 @@ public sealed partial class Chd /// public bool? VerifySector(ulong sectorAddress) { - if(_isHdd) - return null; + if(_isHdd) return null; ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer); @@ -60,13 +59,11 @@ public sealed partial class Chd unknownLbas = new List(); failingLbas = new List(); - if(_isHdd) - return null; + if(_isHdd) return null; ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -89,8 +86,7 @@ public sealed partial class Chd } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -102,13 +98,11 @@ public sealed partial class Chd unknownLbas = new List(); failingLbas = new List(); - if(_isHdd) - return null; + if(_isHdd) return null; ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -131,8 +125,7 @@ public sealed partial class Chd } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -154,8 +147,7 @@ public sealed partial class Chd { ErrorNumber errno = GetHunk(i, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; sha1Ctx.Update(buffer); } @@ -170,8 +162,7 @@ public sealed partial class Chd { ErrorNumber errno = GetHunk(i, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; md5Ctx.Update(buffer); } diff --git a/Aaru.Images/CPCDSK/Identify.cs b/Aaru.Images/CPCDSK/Identify.cs index 2f573cfff..3fc7deaf4 100644 --- a/Aaru.Images/CPCDSK/Identify.cs +++ b/Aaru.Images/CPCDSK/Identify.cs @@ -49,8 +49,7 @@ public sealed partial class Cpcdsk Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 512) - return false; + if(stream.Length < 512) return false; var headerB = new byte[256]; stream.EnsureRead(headerB, 0, 256); @@ -59,12 +58,10 @@ public sealed partial class Cpcdsk for(pos = 0; pos < 254; pos++) { - if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) - break; + if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break; } - if(pos >= 254) - return false; + if(pos >= 254) return false; string magic = Encoding.ASCII.GetString(headerB, 0, pos); diff --git a/Aaru.Images/CPCDSK/Properties.cs b/Aaru.Images/CPCDSK/Properties.cs index 19832a705..e907d4cf3 100644 --- a/Aaru.Images/CPCDSK/Properties.cs +++ b/Aaru.Images/CPCDSK/Properties.cs @@ -42,6 +42,7 @@ public sealed partial class Cpcdsk #region IMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CPCDSK/Read.cs b/Aaru.Images/CPCDSK/Read.cs index f92b7d995..5d4dd1402 100644 --- a/Aaru.Images/CPCDSK/Read.cs +++ b/Aaru.Images/CPCDSK/Read.cs @@ -55,8 +55,7 @@ public sealed partial class Cpcdsk Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 512) - return ErrorNumber.InvalidArgument; + if(stream.Length < 512) return ErrorNumber.InvalidArgument; var headerB = new byte[256]; stream.EnsureRead(headerB, 0, 256); @@ -65,12 +64,10 @@ public sealed partial class Cpcdsk for(pos = 0; pos < 254; pos++) { - if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) - break; + if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break; } - if(pos >= 254) - return ErrorNumber.InvalidArgument; + if(pos >= 254) return ErrorNumber.InvalidArgument; string magic = Encoding.ASCII.GetString(headerB, 0, pos); @@ -104,7 +101,10 @@ public sealed partial class Cpcdsk { for(var j = 0; j < header.sides; j++) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Track_0_Side_1_size_equals_2, i, j, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Track_0_Side_1_size_equals_2, + i, + j, header.tracksizeTable[i * header.sides + j] * 256); } } @@ -125,8 +125,7 @@ public sealed partial class Cpcdsk for(var j = 0; j < header.sides; j++) { // Track not stored in image - if(_extended && header.tracksizeTable[i * header.sides + j] == 0) - continue; + if(_extended && header.tracksizeTable[i * header.sides + j] == 0) continue; long trackPos = stream.Position; @@ -134,7 +133,8 @@ public sealed partial class Cpcdsk stream.EnsureRead(trackB, 0, 256); TrackInfo trackInfo = Marshal.ByteArrayToStructureLittleEndian(trackB); - if(string.Compare(TRACK_ID, Encoding.ASCII.GetString(trackInfo.magic), + if(string.Compare(TRACK_ID, + Encoding.ASCII.GetString(trackInfo.magic), StringComparison.InvariantCultureIgnoreCase) != 0) { @@ -143,11 +143,17 @@ public sealed partial class Cpcdsk return ErrorNumber.InvalidArgument; } - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].magic = \"{0}\"", - StringHandlers.CToString(trackInfo.magic), i, j); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].magic = \"{0}\"", + StringHandlers.CToString(trackInfo.magic), + i, + j); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].bps = {0}", SizeCodeToBytes(trackInfo.bps), - i, j); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].bps = {0}", + SizeCodeToBytes(trackInfo.bps), + i, + j); AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].dataRate = {0}", trackInfo.dataRate, i, j); @@ -157,8 +163,11 @@ public sealed partial class Cpcdsk AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].padding = {0}", trackInfo.padding, i, j); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].recordingMode = {0}", - trackInfo.recordingMode, i, j); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].recordingMode = {0}", + trackInfo.recordingMode, + i, + j); AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sectors = {0}", trackInfo.sectors, i, j); @@ -179,26 +188,54 @@ public sealed partial class Cpcdsk for(var k = 1; k <= trackInfo.sectors; k++) { - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].id = 0x{0:X2}", - trackInfo.sectorsInfo[k - 1].id, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].id = 0x{0:X2}", + trackInfo.sectorsInfo[k - 1].id, + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].len = {0}", - trackInfo.sectorsInfo[k - 1].len, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].len = {0}", + trackInfo.sectorsInfo[k - 1].len, + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].side = {0}", - trackInfo.sectorsInfo[k - 1].side, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].side = {0}", + trackInfo.sectorsInfo[k - 1].side, + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].size = {0}", - SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size), i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].size = {0}", + SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size), + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].st1 = 0x{0:X2}", - trackInfo.sectorsInfo[k - 1].st1, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].st1 = 0x{0:X2}", + trackInfo.sectorsInfo[k - 1].st1, + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].st2 = 0x{0:X2}", - trackInfo.sectorsInfo[k - 1].st2, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].st2 = 0x{0:X2}", + trackInfo.sectorsInfo[k - 1].st2, + i, + j, + k); - AaruConsole.DebugWriteLine(MODULE_NAME, "trackInfo[{1}:{2}].sector[{3}].track = {0}", - trackInfo.sectorsInfo[k - 1].track, i, j, k); + AaruConsole.DebugWriteLine(MODULE_NAME, + "trackInfo[{1}:{2}].sector[{3}].track = {0}", + trackInfo.sectorsInfo[k - 1].track, + i, + j, + k); int sectLen = _extended ? trackInfo.sectorsInfo[k - 1].len @@ -247,8 +284,7 @@ public sealed partial class Cpcdsk _addressMarks.Add(currentSector, s.Value); currentSector++; - if(s.Value.Length > _imageInfo.SectorSize) - _imageInfo.SectorSize = (uint)s.Value.Length; + if(s.Value.Length > _imageInfo.SectorSize) _imageInfo.SectorSize = (uint)s.Value.Length; } stream.Seek(trackPos, SeekOrigin.Begin); @@ -297,11 +333,9 @@ public sealed partial class Cpcdsk { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -309,8 +343,7 @@ public sealed partial class Cpcdsk { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } @@ -325,8 +358,7 @@ public sealed partial class Cpcdsk { buffer = null; - if(tag != SectorTagType.FloppyAddressMark) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; return _addressMarks.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } @@ -336,14 +368,11 @@ public sealed partial class Cpcdsk { buffer = null; - if(tag != SectorTagType.FloppyAddressMark) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -351,8 +380,7 @@ public sealed partial class Cpcdsk { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] addressMark); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(addressMark, 0, addressMark.Length); } diff --git a/Aaru.Images/CisCopy/Identify.cs b/Aaru.Images/CisCopy/Identify.cs index 79df6dcec..cbdd149ae 100644 --- a/Aaru.Images/CisCopy/Identify.cs +++ b/Aaru.Images/CisCopy/Identify.cs @@ -81,44 +81,36 @@ public sealed partial class CisCopy var cmpr = (Compression)stream.ReadByte(); - if(cmpr != Compression.None && cmpr != Compression.Normal && cmpr != Compression.High) - return false; + if(cmpr != Compression.None && cmpr != Compression.Normal && cmpr != Compression.High) return false; switch(type) { case DiskType.MD1DD8: - if(stream.Length > 40 * 1 * 8 * 512 + 82) - return false; + if(stream.Length > 40 * 1 * 8 * 512 + 82) return false; break; case DiskType.MD1DD: - if(stream.Length > 40 * 1 * 9 * 512 + 82) - return false; + if(stream.Length > 40 * 1 * 9 * 512 + 82) return false; break; case DiskType.MD2DD8: - if(stream.Length > 40 * 2 * 8 * 512 + 82) - return false; + if(stream.Length > 40 * 2 * 8 * 512 + 82) return false; break; case DiskType.MD2DD: - if(stream.Length > 40 * 2 * 9 * 512 + 82) - return false; + if(stream.Length > 40 * 2 * 9 * 512 + 82) return false; break; case DiskType.MF2DD: - if(stream.Length > 80 * 2 * 9 * 512 + 162) - return false; + if(stream.Length > 80 * 2 * 9 * 512 + 162) return false; break; case DiskType.MD2HD: - if(stream.Length > 80 * 2 * 15 * 512 + 162) - return false; + if(stream.Length > 80 * 2 * 15 * 512 + 162) return false; break; case DiskType.MF2HD: - if(stream.Length > 80 * 2 * 18 * 512 + 162) - return false; + if(stream.Length > 80 * 2 * 18 * 512 + 162) return false; break; } diff --git a/Aaru.Images/CisCopy/Properties.cs b/Aaru.Images/CisCopy/Properties.cs index 08821205c..278740fb1 100644 --- a/Aaru.Images/CisCopy/Properties.cs +++ b/Aaru.Images/CisCopy/Properties.cs @@ -56,6 +56,7 @@ public sealed partial class CisCopy public string Author => Authors.NataliaPortillo; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CisCopy/Read.cs b/Aaru.Images/CisCopy/Read.cs index a26a1bd3d..c63973897 100644 --- a/Aaru.Images/CisCopy/Read.cs +++ b/Aaru.Images/CisCopy/Read.cs @@ -113,8 +113,7 @@ public sealed partial class CisCopy var headStep = 1; - if(type is DiskType.MD1DD or DiskType.MD1DD8) - headStep = 2; + if(type is DiskType.MD1DD or DiskType.MD1DD8) headStep = 2; var decodedImage = new MemoryStream(); @@ -215,11 +214,9 @@ public sealed partial class CisCopy { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; diff --git a/Aaru.Images/CisCopy/Write.cs b/Aaru.Images/CisCopy/Write.cs index ac42b1d00..414d14aa7 100644 --- a/Aaru.Images/CisCopy/Write.cs +++ b/Aaru.Images/CisCopy/Write.cs @@ -143,15 +143,13 @@ public sealed partial class CisCopy var headStep = 1; - if(diskType is DiskType.MD1DD or DiskType.MD1DD8) - headStep = 2; + if(diskType is DiskType.MD1DD or DiskType.MD1DD8) headStep = 2; for(var i = 0; i < tracks; i += headStep) { _writingStream.WriteByte((byte)TrackType.Copied); - if(headStep == 2) - _writingStream.WriteByte(0); + if(headStep == 2) _writingStream.WriteByte(0); } _writingStream.WriteByte((byte)Compression.None); diff --git a/Aaru.Images/CloneCD/Identify.cs b/Aaru.Images/CloneCD/Identify.cs index 5defa68c4..ebf24478f 100644 --- a/Aaru.Images/CloneCD/Identify.cs +++ b/Aaru.Images/CloneCD/Identify.cs @@ -60,13 +60,11 @@ public sealed partial class CloneCd for(var i = 0; i < 512; i++) { - if(i >= imageFilter.GetDataForkStream().Length) - break; + if(i >= imageFilter.GetDataForkStream().Length) break; if(testArray[i] == 0) { - if(twoConsecutiveNulls) - return false; + if(twoConsecutiveNulls) return false; twoConsecutiveNulls = true; } diff --git a/Aaru.Images/CloneCD/Properties.cs b/Aaru.Images/CloneCD/Properties.cs index d4c975f27..5c902892f 100644 --- a/Aaru.Images/CloneCD/Properties.cs +++ b/Aaru.Images/CloneCD/Properties.cs @@ -61,6 +61,7 @@ public sealed partial class CloneCd OpticalImageCapabilities.CanStoreMultipleTracks; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CloneCD/Read.cs b/Aaru.Images/CloneCD/Read.cs index 4c2cc88d9..729ec7ada 100644 --- a/Aaru.Images/CloneCD/Read.cs +++ b/Aaru.Images/CloneCD/Read.cs @@ -53,8 +53,7 @@ public sealed partial class CloneCd /// public ErrorNumber Open(IFilter imageFilter) { - if(imageFilter == null) - return ErrorNumber.NoSuchFile; + if(imageFilter == null) return ErrorNumber.NoSuchFile; _ccdFilter = imageFilter; @@ -163,8 +162,7 @@ public sealed partial class CloneCd inTrack = trackIdMatch.Success; inCdText = cdtIdMatch.Success; - if(inTrack) - currentTrackEntry = Convert.ToByte(trackIdMatch.Groups["number"].Value, 10); + if(inTrack) currentTrackEntry = Convert.ToByte(trackIdMatch.Groups["number"].Value, 10); } else { @@ -172,8 +170,7 @@ public sealed partial class CloneCd { Match ccdVerMatch = ccdVerRegex.Match(line); - if(!ccdVerMatch.Success) - continue; + if(!ccdVerMatch.Success) continue; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_Version_at_line_0, lineNumber); @@ -181,9 +178,9 @@ public sealed partial class CloneCd if(_imageInfo.Version != "2" && _imageInfo.Version != "3") { - AaruConsole. - ErrorWriteLine(Localization.CloneCD_plugin_Warning_Unknown_CCD_image_version_0_may_not_work, - _imageInfo.Version); + AaruConsole.ErrorWriteLine(Localization + .CloneCD_plugin_Warning_Unknown_CCD_image_version_0_may_not_work, + _imageInfo.Version); } } else if(inDisk) @@ -196,26 +193,30 @@ public sealed partial class CloneCd if(discEntMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_TocEntries_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_TocEntries_at_line_0, lineNumber); } else if(discSessMatch.Success) AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_Sessions_at_line_0, lineNumber); else if(discScrMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_DataTracksScrambled_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_DataTracksScrambled_at_line_0, lineNumber); _scrambled |= discScrMatch.Groups["value"].Value == "1"; } else if(cdtLenMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CDTextLength_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CDTextLength_at_line_0, lineNumber); } else if(discCatMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_Catalog_at_line_0_smallcase, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_Catalog_at_line_0_smallcase, lineNumber); _catalog = discCatMatch.Groups["value"].Value; @@ -230,22 +231,24 @@ public sealed partial class CloneCd if(cdtEntsMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CD_Text_Entries_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CD_Text_Entries_at_line_0, lineNumber); } else if(cdtEntMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_CD_Text_Entry_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_CD_Text_Entry_at_line_0, lineNumber); - string[] bytes = cdtEntMatch.Groups["value"]. - Value.Split(new[] - { - ' ' - }, StringSplitOptions.RemoveEmptyEntries); + string[] bytes = cdtEntMatch.Groups["value"] + .Value.Split(new[] + { + ' ' + }, + StringSplitOptions.RemoveEmptyEntries); - foreach(string byt in bytes) - cdtMs.WriteByte(Convert.ToByte(byt, 16)); + foreach(string byt in bytes) cdtMs.WriteByte(Convert.ToByte(byt, 16)); } } @@ -257,12 +260,14 @@ public sealed partial class CloneCd if(sessPregMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_PreGapMode_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_PreGapMode_at_line_0, lineNumber); } else if(sessSubcMatch.Success) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Found_PreGapSubC_at_line_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Found_PreGapSubC_at_line_0, lineNumber); } } @@ -289,11 +294,9 @@ public sealed partial class CloneCd currentEntry.SessionNumber = Convert.ToByte(entSessMatch.Groups["value"].Value, 10); - if(currentEntry.SessionNumber < minSession) - minSession = currentEntry.SessionNumber; + if(currentEntry.SessionNumber < minSession) minSession = currentEntry.SessionNumber; - if(currentEntry.SessionNumber > maxSession) - maxSession = currentEntry.SessionNumber; + if(currentEntry.SessionNumber > maxSession) maxSession = currentEntry.SessionNumber; } else if(entPointMatch.Success) { @@ -383,8 +386,7 @@ public sealed partial class CloneCd } } - if(inEntry) - entries.Add(currentEntry); + if(inEntry) entries.Add(currentEntry); if(entries.Count == 0) { @@ -442,8 +444,7 @@ public sealed partial class CloneCd _dataStream = _dataFilter.GetDataForkStream(); - if(_subFilter != null) - _subStream = _subFilter.GetDataForkStream(); + if(_subFilter != null) _subStream = _subFilter.GetDataForkStream(); _trackFlags = new Dictionary(); @@ -517,8 +518,7 @@ public sealed partial class CloneCd { currentTrack.Indexes[0] = (int)currentTrack.StartSector - 150; - if(currentTrack.Indexes[0] < 0) - currentTrack.Indexes[0] = 0; + if(currentTrack.Indexes[0] < 0) currentTrack.Indexes[0] = 0; } currentTrack.Indexes[1] = (int)currentTrack.StartSector; @@ -566,7 +566,8 @@ public sealed partial class CloneCd if(_imageInfo.MediaManufacturer != "") { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Disc_manufactured_by_0, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Disc_manufactured_by_0, _imageInfo.MediaManufacturer); } } @@ -622,8 +623,7 @@ public sealed partial class CloneCd int indexDifference = tmpTrack.Indexes[1] - idx0; tmpTrack.FileOffset -= (ulong)(2352 * indexDifference); - if(_subFilter != null) - tmpTrack.SubchannelOffset -= (ulong)(96 * indexDifference); + if(_subFilter != null) tmpTrack.SubchannelOffset -= (ulong)(96 * indexDifference); } } @@ -640,8 +640,8 @@ public sealed partial class CloneCd if(trackIndexes.TryGetValue((byte)tmpTrack.Sequence, out Dictionary indexes)) { - foreach((byte index, int value) in indexes.OrderBy(i => i.Key). - Where(trackIndex => trackIndex.Key > 1)) + foreach((byte index, int value) in indexes.OrderBy(i => i.Key) + .Where(trackIndex => trackIndex.Key > 1)) // Untested as of 20210711 tmpTrack.Indexes[index] = value; @@ -663,11 +663,9 @@ public sealed partial class CloneCd _dataStream.EnsureRead(sectTest, 0, 2352); Array.Copy(sectTest, 0, syncTest, 0, 12); - if(!Sector.SyncMark.SequenceEqual(syncTest)) - continue; + if(!Sector.SyncMark.SequenceEqual(syncTest)) continue; - if(_scrambled) - sectTest = Sector.Scramble(sectTest); + if(_scrambled) sectTest = Sector.Scramble(sectTest); if(sectTest[15] == 1) { @@ -692,14 +690,12 @@ public sealed partial class CloneCd if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; break; } - if(sectTest[15] != 2) - continue; + if(sectTest[15] != 2) continue; var subHdr1 = new byte[4]; var subHdr2 = new byte[4]; @@ -727,8 +723,7 @@ public sealed partial class CloneCd if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2324) - _imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) _imageInfo.SectorSize = 2324; break; } @@ -757,8 +752,7 @@ public sealed partial class CloneCd if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; break; } @@ -772,16 +766,14 @@ public sealed partial class CloneCd if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(_imageInfo.SectorSize < 2336) - _imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) _imageInfo.SectorSize = 2336; break; } } else { - if(_imageInfo.SectorSize < 2352) - _imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) _imageInfo.SectorSize = 2352; } } @@ -806,8 +798,7 @@ public sealed partial class CloneCd foreach(Track track in Tracks) { - if(track.EndSector + 1 > _imageInfo.Sectors) - _imageInfo.Sectors = track.EndSector + 1; + if(track.EndSector + 1 > _imageInfo.Sectors) _imageInfo.Sectors = track.EndSector + 1; if(track.Session == currentSession.Sequence) { @@ -929,8 +920,7 @@ public sealed partial class CloneCd return buffer != null ? ErrorNumber.NoError : ErrorNumber.NoData; case MediaTagType.CD_TEXT: { - if(_cdtext is { Length: > 0 }) - buffer = _cdtext?.Clone() as byte[]; + if(_cdtext is { Length: > 0 }) buffer = _cdtext?.Clone() as byte[]; return buffer != null ? ErrorNumber.NoError : ErrorNumber.NoData; } @@ -976,16 +966,17 @@ public sealed partial class CloneCd { buffer = null; - foreach(KeyValuePair kvp in _offsetMap.Where(kvp => sectorAddress >= kvp.Value). - SelectMany(_ => Tracks, (kvp, track) => new - { - kvp, - track - }). - Where(t => t.track.Sequence == t.kvp.Key). - Where(t => sectorAddress - t.kvp.Value < - t.track.EndSector - t.track.StartSector + 1). - Select(t => t.kvp)) + foreach(KeyValuePair kvp in _offsetMap.Where(kvp => sectorAddress >= kvp.Value) + .SelectMany(_ => Tracks, + (kvp, track) => new + { + kvp, + track + }) + .Where(t => t.track.Sequence == t.kvp.Key) + .Where(t => sectorAddress - t.kvp.Value < + t.track.EndSector - t.track.StartSector + 1) + .Select(t => t.kvp)) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer); return ErrorNumber.SectorNotFound; @@ -997,11 +988,9 @@ public sealed partial class CloneCd buffer = null; Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress - 1 > aaruTrack.EndSector) - return ErrorNumber.OutOfRange; + if(length + sectorAddress - 1 > aaruTrack.EndSector) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -1084,19 +1073,15 @@ public sealed partial class CloneCd { buffer = null; - if(tag == SectorTagType.CdTrackFlags) - track = (uint)sectorAddress; + if(tag == SectorTagType.CdTrackFlags) track = (uint)sectorAddress; Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress - 1 > aaruTrack.EndSector) - return ErrorNumber.OutOfRange; + if(length + sectorAddress - 1 > aaruTrack.EndSector) return ErrorNumber.OutOfRange; - if(aaruTrack.Type == TrackType.Data) - return ErrorNumber.NotSupported; + if(aaruTrack.Type == TrackType.Data) return ErrorNumber.NotSupported; switch(tag) { @@ -1109,8 +1094,7 @@ public sealed partial class CloneCd case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(!_trackFlags.TryGetValue((byte)aaruTrack.Sequence, out byte flags)) - return ErrorNumber.NoData; + if(!_trackFlags.TryGetValue((byte)aaruTrack.Sequence, out byte flags)) return ErrorNumber.NoData; buffer = new[] { @@ -1384,11 +1368,9 @@ public sealed partial class CloneCd buffer = null; Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress - 1 > aaruTrack.EndSector) - return ErrorNumber.OutOfMemory; + if(length + sectorAddress - 1 > aaruTrack.EndSector) return ErrorNumber.OutOfMemory; buffer = new byte[2352 * length]; diff --git a/Aaru.Images/CloneCD/Verify.cs b/Aaru.Images/CloneCD/Verify.cs index 107f77b30..1435e1f95 100644 --- a/Aaru.Images/CloneCD/Verify.cs +++ b/Aaru.Images/CloneCD/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class CloneCd unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class CloneCd } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class CloneCd unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class CloneCd } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/CloneCD/Write.cs b/Aaru.Images/CloneCD/Write.cs index 002e60829..d987f9ccc 100644 --- a/Aaru.Images/CloneCD/Write.cs +++ b/Aaru.Images/CloneCD/Write.cs @@ -75,7 +75,9 @@ public sealed partial class CloneCd _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); - _dataStream = new FileStream(_writingBaseName + ".img", FileMode.OpenOrCreate, FileAccess.ReadWrite, + _dataStream = new FileStream(_writingBaseName + ".img", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); } catch(IOException ex) @@ -181,9 +183,9 @@ public sealed partial class CloneCd return false; } - _dataStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + _dataStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); _dataStream.Write(data, 0, data.Length); @@ -223,9 +225,9 @@ public sealed partial class CloneCd return false; } - _dataStream. - Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), - SeekOrigin.Begin); + _dataStream.Seek((long)(track.FileOffset + + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), + SeekOrigin.Begin); _dataStream.Write(data, 0, data.Length); @@ -325,8 +327,7 @@ public sealed partial class CloneCd _descriptorStream.WriteLine("DataTracksScrambled=0"); _descriptorStream.WriteLine("CDTextLength=0"); - if(!string.IsNullOrEmpty(_catalog)) - _descriptorStream.WriteLine("CATALOG={0}", _catalog); + if(!string.IsNullOrEmpty(_catalog)) _descriptorStream.WriteLine("CATALOG={0}", _catalog); for(var i = 1; i <= toc.LastCompleteSession; i++) { @@ -372,11 +373,9 @@ public sealed partial class CloneCd long plba = MsfToLba((toc.TrackDescriptors[i].PMIN, toc.TrackDescriptors[i].PSEC, toc.TrackDescriptors[i].PFRAME)); - if(alba > 405000) - alba = (alba - 405000 + 300) * -1; + if(alba > 405000) alba = (alba - 405000 + 300) * -1; - if(plba > 405000) - plba = (plba - 405000 + 300) * -1; + if(plba > 405000) plba = (plba - 405000 + 300) * -1; _descriptorStream.WriteLine("[Entry {0}]", i); _descriptorStream.WriteLine("Session={0}", toc.TrackDescriptors[i].SessionNumber); @@ -475,13 +474,16 @@ public sealed partial class CloneCd { try { - _subStream = new FileStream(_writingBaseName + ".sub", FileMode.OpenOrCreate, - FileAccess.ReadWrite, FileShare.None); + _subStream = new FileStream(_writingBaseName + ".sub", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, + FileShare.None); } catch(IOException ex) { ErrorMessage = string.Format(Localization.Could_not_create_subchannel_file_exception_0, ex.Message); + AaruConsole.WriteException(ex); return false; @@ -548,13 +550,16 @@ public sealed partial class CloneCd { try { - _subStream = new FileStream(_writingBaseName + ".sub", FileMode.OpenOrCreate, - FileAccess.ReadWrite, FileShare.None); + _subStream = new FileStream(_writingBaseName + ".sub", + FileMode.OpenOrCreate, + FileAccess.ReadWrite, + FileShare.None); } catch(IOException ex) { ErrorMessage = string.Format(Localization.Could_not_create_subchannel_file_exception_0, ex.Message); + AaruConsole.WriteException(ex); return false; diff --git a/Aaru.Images/CopyQM/Identify.cs b/Aaru.Images/CopyQM/Identify.cs index fd1e1288c..815c42d12 100644 --- a/Aaru.Images/CopyQM/Identify.cs +++ b/Aaru.Images/CopyQM/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class CopyQm Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 133) - return false; + if(stream.Length < 133) return false; var hdr = new byte[133]; stream.EnsureRead(hdr, 0, 133); diff --git a/Aaru.Images/CopyQM/Properties.cs b/Aaru.Images/CopyQM/Properties.cs index a00f16293..8b9be62a9 100644 --- a/Aaru.Images/CopyQM/Properties.cs +++ b/Aaru.Images/CopyQM/Properties.cs @@ -42,6 +42,7 @@ public sealed partial class CopyQm #region IMediaImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CopyQM/Read.cs b/Aaru.Images/CopyQM/Read.cs index 87d0c0c7d..45b380aa3 100644 --- a/Aaru.Images/CopyQM/Read.cs +++ b/Aaru.Images/CopyQM/Read.cs @@ -96,8 +96,7 @@ public sealed partial class CopyQm { var runLengthBytes = new byte[2]; - if(stream.EnsureRead(runLengthBytes, 0, 2) != 2) - break; + if(stream.EnsureRead(runLengthBytes, 0, 2) != 2) break; var runLength = BitConverter.ToInt16(runLengthBytes, 0); @@ -147,15 +146,18 @@ public sealed partial class CopyQm var sum = 0; - for(var i = 0; i < hdr.Length - 1; i++) - sum += hdr[i]; + for(var i = 0; i < hdr.Length - 1; i++) sum += hdr[i]; _headerChecksumOk = (-1 * sum & 0xFF) == _header.headerChecksum; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Calculated_header_checksum_equals_0_X2_1, -1 * sum & 0xFF, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Calculated_header_checksum_equals_0_X2_1, + -1 * sum & 0xFF, _headerChecksumOk); - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Calculated_data_CRC_equals_0_X8_1, _calculatedDataCrc, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Calculated_data_CRC_equals_0_X8_1, + _calculatedDataCrc, _calculatedDataCrc == _header.crc); _imageInfo.Application = "CopyQM"; @@ -211,11 +213,9 @@ public sealed partial class CopyQm { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; diff --git a/Aaru.Images/CopyTape/Identify.cs b/Aaru.Images/CopyTape/Identify.cs index 4afebfba8..67152fc3e 100644 --- a/Aaru.Images/CopyTape/Identify.cs +++ b/Aaru.Images/CopyTape/Identify.cs @@ -45,8 +45,7 @@ public sealed partial class CopyTape /// public bool Identify(IFilter imageFilter) { - if(imageFilter.DataForkLength <= 16) - return false; + if(imageFilter.DataForkLength <= 16) return false; var header = new byte[16]; @@ -59,19 +58,15 @@ public sealed partial class CopyTape var blockRx = new Regex(BLOCK_REGEX); Match blockMt = blockRx.Match(mark); - if(!blockMt.Success) - return false; + if(!blockMt.Success) return false; string blkSize = blockMt.Groups["blockSize"].Value; - if(string.IsNullOrWhiteSpace(blkSize)) - return false; + if(string.IsNullOrWhiteSpace(blkSize)) return false; - if(!uint.TryParse(blkSize, out uint blockSize)) - return false; + if(!uint.TryParse(blkSize, out uint blockSize)) return false; - if(blockSize == 0 || blockSize + 17 >= imageFilter.DataForkLength) - return false; + if(blockSize == 0 || blockSize + 17 >= imageFilter.DataForkLength) return false; strm.Position += blockSize; diff --git a/Aaru.Images/CopyTape/Properties.cs b/Aaru.Images/CopyTape/Properties.cs index c306b0bc7..48cc71167 100644 --- a/Aaru.Images/CopyTape/Properties.cs +++ b/Aaru.Images/CopyTape/Properties.cs @@ -46,6 +46,7 @@ public sealed partial class CopyTape #region IWritableTapeImage Members /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/CopyTape/Read.cs b/Aaru.Images/CopyTape/Read.cs index 9c847ab8e..7125ecd48 100644 --- a/Aaru.Images/CopyTape/Read.cs +++ b/Aaru.Images/CopyTape/Read.cs @@ -56,8 +56,7 @@ public sealed partial class CopyTape var filemarkRx = new Regex(FILEMARK_REGEX); var eotRx = new Regex(END_OF_TAPE_REGEX); - if(imageFilter.DataForkLength <= 16) - return ErrorNumber.InvalidArgument; + if(imageFilter.DataForkLength <= 16) return ErrorNumber.InvalidArgument; _imageStream = imageFilter.GetDataForkStream(); _imageStream.Position = 0; @@ -80,8 +79,7 @@ public sealed partial class CopyTape Match filemarkMt = filemarkRx.Match(mark); Match eotMt = eotRx.Match(mark); - if(eotMt.Success) - break; + if(eotMt.Success) break; if(filemarkMt.Success) { @@ -163,8 +161,7 @@ public sealed partial class CopyTape currentBlock++; _imageInfo.ImageSize += blockSize; - if(_imageInfo.SectorSize < blockSize) - _imageInfo.SectorSize = blockSize; + if(_imageInfo.SectorSize < blockSize) _imageInfo.SectorSize = blockSize; } _blockPositionCache = blockPositions.ToArray(); @@ -195,8 +192,7 @@ public sealed partial class CopyTape { buffer = null; - if(sectorAddress >= (ulong)_blockPositionCache.LongLength) - return ErrorNumber.OutOfRange; + if(sectorAddress >= (ulong)_blockPositionCache.LongLength) return ErrorNumber.OutOfRange; _imageStream.Position = _blockPositionCache[sectorAddress]; @@ -207,19 +203,15 @@ public sealed partial class CopyTape string mark = Encoding.ASCII.GetString(blockHeader); Match blockMt = blockRx.Match(mark); - if(!blockMt.Success) - return ErrorNumber.InvalidArgument; + if(!blockMt.Success) return ErrorNumber.InvalidArgument; string blkSize = blockMt.Groups["blockSize"].Value; - if(string.IsNullOrWhiteSpace(blkSize)) - return ErrorNumber.InvalidArgument; + if(string.IsNullOrWhiteSpace(blkSize)) return ErrorNumber.InvalidArgument; - if(!uint.TryParse(blkSize, out uint blockSize)) - return ErrorNumber.InvalidArgument; + if(!uint.TryParse(blkSize, out uint blockSize)) return ErrorNumber.InvalidArgument; - if(blockSize == 0 || blockSize + 17 > _imageStream.Length) - return ErrorNumber.InvalidArgument; + if(blockSize == 0 || blockSize + 17 > _imageStream.Length) return ErrorNumber.InvalidArgument; buffer = new byte[blockSize]; @@ -239,8 +231,7 @@ public sealed partial class CopyTape { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } diff --git a/Aaru.Images/CopyTape/Write.cs b/Aaru.Images/CopyTape/Write.cs index 4fd053c34..d218c3a99 100644 --- a/Aaru.Images/CopyTape/Write.cs +++ b/Aaru.Images/CopyTape/Write.cs @@ -130,8 +130,7 @@ public sealed partial class CopyTape _dataStream.Write(data, 0, data.Length); _dataStream.WriteByte(0x0A); - if(sectorAddress > _lastWrittenBlock) - _lastWrittenBlock = sectorAddress; + if(sectorAddress > _lastWrittenBlock) _lastWrittenBlock = sectorAddress; _dataStream.Seek(0, SeekOrigin.End); @@ -145,8 +144,7 @@ public sealed partial class CopyTape { bool ret = WriteSector(data, sectorAddress + i); - if(!ret) - return false; + if(!ret) return false; } return true; @@ -242,8 +240,7 @@ public sealed partial class CopyTape /// public bool AddPartition(TapePartition partition) { - if(partition.Number == 0) - return true; + if(partition.Number == 0) return true; ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/D88/Identify.cs b/Aaru.Images/D88/Identify.cs index dd2a53b84..acb8be84a 100644 --- a/Aaru.Images/D88/Identify.cs +++ b/Aaru.Images/D88/Identify.cs @@ -52,8 +52,7 @@ public sealed partial class D88 // Even if disk name is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p var shiftjis = Encoding.GetEncoding("shift_jis"); - if(stream.Length < Marshal.SizeOf
()) - return false; + if(stream.Length < Marshal.SizeOf
()) return false; var hdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(hdrB, 0, hdrB.Length); @@ -62,7 +61,8 @@ public sealed partial class D88 AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); - AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.reserved is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); @@ -71,24 +71,19 @@ public sealed partial class D88 AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.disk_size = {0}", hdr.disk_size); - if(hdr.disk_size != stream.Length) - return false; + if(hdr.disk_size != stream.Length) return false; - if(hdr.disk_type != DiskType.D2 && hdr.disk_type != DiskType.Dd2 && hdr.disk_type != DiskType.Hd2) - return false; + if(hdr.disk_type != DiskType.D2 && hdr.disk_type != DiskType.Dd2 && hdr.disk_type != DiskType.Hd2) return false; - if(!hdr.reserved.SequenceEqual(_reservedEmpty)) - return false; + if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false; var counter = 0; foreach(int t in hdr.track_table) { - if(t > 0) - counter++; + if(t > 0) counter++; - if(t < 0 || t > stream.Length) - return false; + if(t < 0 || t > stream.Length) return false; } AaruConsole.DebugWriteLine(MODULE_NAME, Localization._0_tracks, counter); diff --git a/Aaru.Images/D88/Properties.cs b/Aaru.Images/D88/Properties.cs index 429b1eb21..3258e5ade 100644 --- a/Aaru.Images/D88/Properties.cs +++ b/Aaru.Images/D88/Properties.cs @@ -48,6 +48,7 @@ public sealed partial class D88 public Guid Id => new("669EDC77-EC41-4720-A88C-49C38CFFBAA0"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/D88/Read.cs b/Aaru.Images/D88/Read.cs index 20b1040ec..a99b0c18c 100644 --- a/Aaru.Images/D88/Read.cs +++ b/Aaru.Images/D88/Read.cs @@ -56,8 +56,7 @@ public sealed partial class D88 // Even if disk name is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p var shiftjis = Encoding.GetEncoding("shift_jis"); - if(stream.Length < Marshal.SizeOf
()) - return ErrorNumber.InvalidArgument; + if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; var hdrB = new byte[Marshal.SizeOf
()]; stream.EnsureRead(hdrB, 0, hdrB.Length); @@ -65,7 +64,8 @@ public sealed partial class D88 AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); - AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.reserved is empty? = {0}", + AaruConsole.DebugWriteLine(MODULE_NAME, + "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); @@ -74,30 +74,25 @@ public sealed partial class D88 AaruConsole.DebugWriteLine(MODULE_NAME, "d88hdr.disk_size = {0}", hdr.disk_size); - if(hdr.disk_size != stream.Length) - return ErrorNumber.InvalidArgument; + if(hdr.disk_size != stream.Length) return ErrorNumber.InvalidArgument; if(hdr.disk_type != DiskType.D2 && hdr.disk_type != DiskType.Dd2 && hdr.disk_type != DiskType.Hd2) return ErrorNumber.InvalidArgument; - if(!hdr.reserved.SequenceEqual(_reservedEmpty)) - return ErrorNumber.InvalidArgument; + if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return ErrorNumber.InvalidArgument; var trkCounter = 0; foreach(int t in hdr.track_table) { - if(t > 0) - trkCounter++; + if(t > 0) trkCounter++; - if(t < 0 || t > stream.Length) - return ErrorNumber.InvalidArgument; + if(t < 0 || t > stream.Length) return ErrorNumber.InvalidArgument; } AaruConsole.DebugWriteLine(MODULE_NAME, Localization._0_tracks, trkCounter); - if(trkCounter == 0) - return ErrorNumber.InvalidArgument; + if(trkCounter == 0) return ErrorNumber.InvalidArgument; hdrB = new byte[Marshal.SizeOf()]; stream.Seek(hdr.track_table[0], SeekOrigin.Begin); @@ -130,8 +125,14 @@ public sealed partial class D88 if(sechdr.spt != spt || sechdr.n != bps) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Disk_tracks_are_not_same_size, sechdr.spt, spt, - sechdr.n, bps, i, 0); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Disk_tracks_are_not_same_size, + sechdr.spt, + spt, + sechdr.n, + bps, + i, + 0); allEqual = false; } @@ -148,11 +149,17 @@ public sealed partial class D88 sechdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - if(sechdr.spt == spt && sechdr.n == bps) - continue; + if(sechdr.spt == spt && sechdr.n == bps) continue; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Disk_tracks_are_not_same_size, sechdr.spt, spt, - sechdr.n, bps, i, j, sechdr.deleted_mark); + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Disk_tracks_are_not_same_size, + sechdr.spt, + spt, + sechdr.n, + bps, + i, + j, + sechdr.deleted_mark); allEqual = false; } @@ -161,8 +168,7 @@ public sealed partial class D88 stream.EnsureRead(secB, 0, secB.Length); sectors.Add(sechdr.r, secB); - foreach(KeyValuePair kvp in sectors) - _sectorsData.Add(kvp.Value); + foreach(KeyValuePair kvp in sectors) _sectorsData.Add(kvp.Value); } AaruConsole.DebugWriteLine(MODULE_NAME, Localization._0_sectors, _sectorsData.Count); @@ -227,8 +233,7 @@ public sealed partial class D88 break; case 480: - if(spt == 38) - _imageInfo.MediaType = MediaType.NEC_35_TD; + if(spt == 38) _imageInfo.MediaType = MediaType.NEC_35_TD; break; } @@ -352,11 +357,9 @@ public sealed partial class D88 { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); diff --git a/Aaru.Images/DART/DART.cs b/Aaru.Images/DART/DART.cs index 84ff80457..a1c8aa1d8 100644 --- a/Aaru.Images/DART/DART.cs +++ b/Aaru.Images/DART/DART.cs @@ -42,6 +42,7 @@ namespace Aaru.Images; public sealed partial class Dart : IMediaImage { const string MODULE_NAME = "DART plugin"; + // DART images are at most 1474560 bytes, so let's cache the whole byte[] _dataCache; uint _dataChecksum; diff --git a/Aaru.Images/DART/Identify.cs b/Aaru.Images/DART/Identify.cs index a21870b8d..f2b7e557c 100644 --- a/Aaru.Images/DART/Identify.cs +++ b/Aaru.Images/DART/Identify.cs @@ -45,8 +45,7 @@ public sealed partial class Dart { Stream stream = imageFilter.GetDataForkStream(); - if(stream.Length < 84) - return false; + if(stream.Length < 84) return false; stream.Seek(0, SeekOrigin.Begin); var headerB = new byte[Marshal.SizeOf
()]; @@ -54,43 +53,36 @@ public sealed partial class Dart stream.EnsureRead(headerB, 0, Marshal.SizeOf
()); Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); - if(header.srcCmp > COMPRESS_NONE) - return false; + if(header.srcCmp > COMPRESS_NONE) return false; int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { case DISK_MAC: - if(header.srcSize != SIZE_MAC_SS && header.srcSize != SIZE_MAC) - return false; + if(header.srcSize != SIZE_MAC_SS && header.srcSize != SIZE_MAC) return false; break; case DISK_LISA: - if(header.srcSize != SIZE_LISA) - return false; + if(header.srcSize != SIZE_LISA) return false; break; case DISK_APPLE2: - if(header.srcSize != SIZE_APPLE2) - return false; + if(header.srcSize != SIZE_APPLE2) return false; break; case DISK_MAC_HD: - if(header.srcSize != SIZE_MAC_HD) - return false; + if(header.srcSize != SIZE_MAC_HD) return false; expectedMaxSize += 64; break; case DISK_DOS: - if(header.srcSize != SIZE_DOS) - return false; + if(header.srcSize != SIZE_DOS) return false; break; case DISK_DOS_HD: - if(header.srcSize != SIZE_DOS_HD) - return false; + if(header.srcSize != SIZE_DOS_HD) return false; expectedMaxSize += 64; diff --git a/Aaru.Images/DART/Properties.cs b/Aaru.Images/DART/Properties.cs index 380a3268c..a58fa445b 100644 --- a/Aaru.Images/DART/Properties.cs +++ b/Aaru.Images/DART/Properties.cs @@ -48,6 +48,7 @@ public sealed partial class Dart public Guid Id => new("B3E06BF8-F98D-4F9B-BBE2-342C373BAF3E"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index ee8c42138..30967f546 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -54,8 +54,7 @@ public sealed partial class Dart { Stream stream = imageFilter.GetDataForkStream(); - if(stream.Length < 84) - return ErrorNumber.InvalidArgument; + if(stream.Length < 84) return ErrorNumber.InvalidArgument; stream.Seek(0, SeekOrigin.Begin); var headerB = new byte[Marshal.SizeOf
()]; @@ -63,43 +62,36 @@ public sealed partial class Dart stream.EnsureRead(headerB, 0, Marshal.SizeOf
()); Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); - if(header.srcCmp > COMPRESS_NONE) - return ErrorNumber.NotSupported; + if(header.srcCmp > COMPRESS_NONE) return ErrorNumber.NotSupported; int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { case DISK_MAC: - if(header.srcSize != SIZE_MAC_SS && header.srcSize != SIZE_MAC) - return ErrorNumber.InvalidArgument; + if(header.srcSize != SIZE_MAC_SS && header.srcSize != SIZE_MAC) return ErrorNumber.InvalidArgument; break; case DISK_LISA: - if(header.srcSize != SIZE_LISA) - return ErrorNumber.InvalidArgument; + if(header.srcSize != SIZE_LISA) return ErrorNumber.InvalidArgument; break; case DISK_APPLE2: - if(header.srcSize != DISK_APPLE2) - return ErrorNumber.InvalidArgument; + if(header.srcSize != DISK_APPLE2) return ErrorNumber.InvalidArgument; break; case DISK_MAC_HD: - if(header.srcSize != SIZE_MAC_HD) - return ErrorNumber.InvalidArgument; + if(header.srcSize != SIZE_MAC_HD) return ErrorNumber.InvalidArgument; expectedMaxSize += 64; break; case DISK_DOS: - if(header.srcSize != SIZE_DOS) - return ErrorNumber.InvalidArgument; + if(header.srcSize != SIZE_DOS) return ErrorNumber.InvalidArgument; break; case DISK_DOS_HD: - if(header.srcSize != SIZE_DOS_HD) - return ErrorNumber.InvalidArgument; + if(header.srcSize != SIZE_DOS_HD) return ErrorNumber.InvalidArgument; expectedMaxSize += 64; @@ -108,8 +100,7 @@ public sealed partial class Dart return ErrorNumber.InvalidArgument; } - if(stream.Length > expectedMaxSize) - return ErrorNumber.InvalidArgument; + if(stream.Length > expectedMaxSize) return ErrorNumber.InvalidArgument; var bLength = new short[header.srcType is DISK_MAC_HD or DISK_DOS_HD ? BLOCK_ARRAY_LEN_HIGH : BLOCK_ARRAY_LEN_LOW]; @@ -126,8 +117,7 @@ public sealed partial class Dart foreach(short l in bLength) { - if(l == 0) - continue; + if(l == 0) continue; var buffer = new byte[BUFFER_SIZE]; @@ -195,8 +185,7 @@ public sealed partial class Dart var major = $"{version.MajorVersion}"; var minor = $".{version.MinorVersion / 10}"; - if(version.MinorVersion % 10 > 0) - release = $".{version.MinorVersion % 10}"; + if(version.MinorVersion % 10 > 0) release = $".{version.MinorVersion % 10}"; string dev = version.DevStage switch { @@ -206,11 +195,9 @@ public sealed partial class Dart _ => null }; - if(dev == null && version.PreReleaseVersion > 0) - dev = "f"; + if(dev == null && version.PreReleaseVersion > 0) dev = "f"; - if(dev != null) - pre = $"{version.PreReleaseVersion}"; + if(dev != null) pre = $"{version.PreReleaseVersion}"; _imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; _imageInfo.Application = version.VersionString; @@ -262,7 +249,9 @@ public sealed partial class Dart } catch(InvalidCastException) {} - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Image_application_0_version_1, _imageInfo.Application, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Image_application_0_version_1, + _imageInfo.Application, _imageInfo.ApplicationVersion); _imageInfo.Sectors = (ulong)(header.srcSize * 2); @@ -321,11 +310,9 @@ public sealed partial class Dart { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; @@ -339,17 +326,13 @@ public sealed partial class Dart { buffer = null; - if(tag != SectorTagType.AppleSectorTag) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSectorTag) return ErrorNumber.NotSupported; - if(_tagCache == null || _tagCache.Length == 0) - return ErrorNumber.NoData; + if(_tagCache == null || _tagCache.Length == 0) return ErrorNumber.NoData; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * TAG_SECTOR_SIZE]; @@ -367,31 +350,33 @@ public sealed partial class Dart { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; ErrorNumber errno = ReadSectors(sectorAddress, length, out byte[] data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag, out byte[] tags); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; buffer = new byte[data.Length + tags.Length]; for(uint i = 0; i < length; i++) { - Array.Copy(data, i * _imageInfo.SectorSize, buffer, i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE), + Array.Copy(data, + i * _imageInfo.SectorSize, + buffer, + i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE), _imageInfo.SectorSize); - Array.Copy(tags, i * TAG_SECTOR_SIZE, buffer, - i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE) + _imageInfo.SectorSize, TAG_SECTOR_SIZE); + Array.Copy(tags, + i * TAG_SECTOR_SIZE, + buffer, + i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE) + _imageInfo.SectorSize, + TAG_SECTOR_SIZE); } return ErrorNumber.NoError; diff --git a/Aaru.Images/DIM/Identify.cs b/Aaru.Images/DIM/Identify.cs index 2c5f7ce24..ddf4dee61 100644 --- a/Aaru.Images/DIM/Identify.cs +++ b/Aaru.Images/DIM/Identify.cs @@ -49,8 +49,7 @@ public sealed partial class Dim Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < DATA_OFFSET) - return false; + if(stream.Length < DATA_OFFSET) return false; _comment = new byte[60]; _hdrId = new byte[13]; diff --git a/Aaru.Images/DIM/Properties.cs b/Aaru.Images/DIM/Properties.cs index 2bb12e481..5175f87c8 100644 --- a/Aaru.Images/DIM/Properties.cs +++ b/Aaru.Images/DIM/Properties.cs @@ -50,6 +50,7 @@ public sealed partial class Dim public Guid Id => new("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/DIM/Read.cs b/Aaru.Images/DIM/Read.cs index 0fcbf759a..3838d51bd 100644 --- a/Aaru.Images/DIM/Read.cs +++ b/Aaru.Images/DIM/Read.cs @@ -53,8 +53,7 @@ public sealed partial class Dim Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < DATA_OFFSET) - return ErrorNumber.InvalidArgument; + if(stream.Length < DATA_OFFSET) return ErrorNumber.InvalidArgument; long diskSize = stream.Length - DATA_OFFSET; @@ -67,8 +66,7 @@ public sealed partial class Dim stream.Seek(0xC2, SeekOrigin.Begin); stream.EnsureRead(_comment, 0, 60); - if(!_headerId.SequenceEqual(_hdrId)) - return ErrorNumber.InvalidArgument; + if(!_headerId.SequenceEqual(_hdrId)) return ErrorNumber.InvalidArgument; _imageInfo.MediaType = MediaType.Unknown; @@ -84,8 +82,7 @@ public sealed partial class Dim return ErrorNumber.NotSupported; } - if(diskSize / (2 * 8 * 1024) == 77) - _imageInfo.MediaType = MediaType.SHARP_525; + if(diskSize / (2 * 8 * 1024) == 77) _imageInfo.MediaType = MediaType.SHARP_525; _imageInfo.SectorSize = 1024; @@ -101,8 +98,7 @@ public sealed partial class Dim return ErrorNumber.NotSupported; } - if(diskSize / (2 * 9 * 512) == 80) - _imageInfo.MediaType = MediaType.SHARP_525_9; + if(diskSize / (2 * 9 * 512) == 80) _imageInfo.MediaType = MediaType.SHARP_525_9; _imageInfo.SectorSize = 512; @@ -118,8 +114,7 @@ public sealed partial class Dim return ErrorNumber.NotSupported; } - if(diskSize / (2 * 15 * 512) == 80) - _imageInfo.MediaType = MediaType.DOS_525_HD; + if(diskSize / (2 * 15 * 512) == 80) _imageInfo.MediaType = MediaType.DOS_525_HD; _imageInfo.SectorSize = 512; @@ -135,8 +130,7 @@ public sealed partial class Dim return ErrorNumber.NotSupported; } - if(diskSize / (2 * 9 * 512) == 80) - _imageInfo.MediaType = MediaType.SHARP_35_9; + if(diskSize / (2 * 9 * 512) == 80) _imageInfo.MediaType = MediaType.SHARP_35_9; _imageInfo.SectorSize = 512; @@ -152,8 +146,7 @@ public sealed partial class Dim return ErrorNumber.NotSupported; } - if(diskSize / (2 * 18 * 512) == 80) - _imageInfo.MediaType = MediaType.DOS_35_HD; + if(diskSize / (2 * 18 * 512) == 80) _imageInfo.MediaType = MediaType.DOS_35_HD; _imageInfo.SectorSize = 512; @@ -163,15 +156,13 @@ public sealed partial class Dim case DiskType.N88: if(diskSize % (2 * 26 * 256) == 0) { - if(diskSize % (2 * 26 * 256) == 77) - _imageInfo.MediaType = MediaType.NEC_8_DD; + if(diskSize % (2 * 26 * 256) == 77) _imageInfo.MediaType = MediaType.NEC_8_DD; _imageInfo.SectorSize = 256; } else if(diskSize % (2 * 26 * 128) == 0) { - if(diskSize % (2 * 26 * 128) == 77) - _imageInfo.MediaType = MediaType.NEC_8_SD; + if(diskSize % (2 * 26 * 128) == 77) _imageInfo.MediaType = MediaType.NEC_8_SD; _imageInfo.SectorSize = 256; } @@ -255,11 +246,9 @@ public sealed partial class Dim { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * _imageInfo.SectorSize]; diff --git a/Aaru.Images/DiscFerret/Properties.cs b/Aaru.Images/DiscFerret/Properties.cs index 64a29d418..ade46d54b 100644 --- a/Aaru.Images/DiscFerret/Properties.cs +++ b/Aaru.Images/DiscFerret/Properties.cs @@ -48,6 +48,7 @@ public sealed partial class DiscFerret public Guid Id => new("70EA7B9B-5323-42EB-9B40-8DDA37C5EB4D"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index 71408b41c..735acce9d 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -52,8 +52,7 @@ public sealed partial class DiscFerret stream.EnsureRead(magicB, 0, 4); var magic = BitConverter.ToUInt32(magicB, 0); - if(magic != DFI_MAGIC && magic != DFI_MAGIC2) - return ErrorNumber.InvalidArgument; + if(magic != DFI_MAGIC && magic != DFI_MAGIC2) return ErrorNumber.InvalidArgument; TrackOffsets = new SortedDictionary(); TrackLengths = new SortedDictionary(); @@ -104,11 +103,9 @@ public sealed partial class DiscFerret t++; } - if(blockHeader.cylinder > _imageInfo.Cylinders) - _imageInfo.Cylinders = blockHeader.cylinder; + if(blockHeader.cylinder > _imageInfo.Cylinders) _imageInfo.Cylinders = blockHeader.cylinder; - if(blockHeader.head > _imageInfo.Heads) - _imageInfo.Heads = blockHeader.head; + if(blockHeader.head > _imageInfo.Heads) _imageInfo.Heads = blockHeader.head; } _imageInfo.Heads++; diff --git a/Aaru.Images/DiscJuggler/Identify.cs b/Aaru.Images/DiscJuggler/Identify.cs index 0d2b6ecb7..099ee52d1 100644 --- a/Aaru.Images/DiscJuggler/Identify.cs +++ b/Aaru.Images/DiscJuggler/Identify.cs @@ -54,16 +54,14 @@ public sealed partial class DiscJuggler AaruConsole.DebugWriteLine(MODULE_NAME, "dscLen = {0}", dscLen); - if(dscLen >= _imageStream.Length) - return false; + if(dscLen >= _imageStream.Length) return false; var descriptor = new byte[dscLen]; _imageStream.Seek(-dscLen, SeekOrigin.End); _imageStream.EnsureRead(descriptor, 0, dscLen); // Sessions - if(descriptor.Length < 1 || descriptor[0] > 99 || descriptor[0] == 0) - return false; + if(descriptor.Length < 1 || descriptor[0] > 99 || descriptor[0] == 0) return false; // Seems all sessions start with this data if(descriptor[1] != 0x00 || diff --git a/Aaru.Images/DiscJuggler/Properties.cs b/Aaru.Images/DiscJuggler/Properties.cs index aa3acaa88..e9b216bfb 100644 --- a/Aaru.Images/DiscJuggler/Properties.cs +++ b/Aaru.Images/DiscJuggler/Properties.cs @@ -50,6 +50,7 @@ public sealed partial class DiscJuggler public Guid Id => new("2444DBC6-CD35-424C-A227-39B0C4DB01B2"); /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/DiscJuggler/Read.cs b/Aaru.Images/DiscJuggler/Read.cs index c3c3cdd1c..f986acda7 100644 --- a/Aaru.Images/DiscJuggler/Read.cs +++ b/Aaru.Images/DiscJuggler/Read.cs @@ -61,16 +61,14 @@ public sealed partial class DiscJuggler _imageStream.EnsureRead(dscLenB, 0, 4); var dscLen = BitConverter.ToInt32(dscLenB, 0); - if(dscLen >= _imageStream.Length) - return ErrorNumber.InvalidArgument; + if(dscLen >= _imageStream.Length) return ErrorNumber.InvalidArgument; var descriptor = new byte[dscLen]; _imageStream.Seek(-dscLen, SeekOrigin.End); _imageStream.EnsureRead(descriptor, 0, dscLen); // Sessions - if(descriptor[0] > 99 || descriptor[0] == 0) - return ErrorNumber.InvalidArgument; + if(descriptor[0] > 99 || descriptor[0] == 0) return ErrorNumber.InvalidArgument; var position = 1; @@ -139,8 +137,7 @@ public sealed partial class DiscJuggler break; } - if(!nextFound) - return Tracks.Count > 0 ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; + if(!nextFound) return Tracks.Count > 0 ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; position += 15; @@ -148,8 +145,7 @@ public sealed partial class DiscJuggler } // Too many tracks - if(descriptor[position + 1] > 99) - return ErrorNumber.InvalidArgument; + if(descriptor[position + 1] > 99) return ErrorNumber.InvalidArgument; byte maxT = descriptor[position + 1]; AaruConsole.DebugWriteLine(MODULE_NAME, "maxT = {0}", maxT); @@ -216,16 +212,14 @@ public sealed partial class DiscJuggler position++; AaruConsole.DebugWriteLine(MODULE_NAME, "\tc[{1}][{2}].Length = {0}", bLen, c, cb); - if(bLen <= 0) - continue; + if(bLen <= 0) continue; var textBlk = new byte[bLen]; Array.Copy(descriptor, position, textBlk, 0, bLen); position += bLen; // Track title - if(cb != 10) - continue; + if(cb != 10) continue; track.Description = Encoding.Default.GetString(textBlk, 0, bLen); @@ -247,17 +241,18 @@ public sealed partial class DiscJuggler position += 4; track.Sequence = BitConverter.ToUInt32(descriptor, position) + lastSessionTrack + 1; - AaruConsole.DebugWriteLine(MODULE_NAME, "\ttrack = {1} + {2} + 1 = {0}", track.Sequence, - BitConverter.ToUInt32(descriptor, position), lastSessionTrack); + AaruConsole.DebugWriteLine(MODULE_NAME, + "\ttrack = {1} + {2} + 1 = {0}", + track.Sequence, + BitConverter.ToUInt32(descriptor, position), + lastSessionTrack); // There's always an index 0 in the image track.Pregap = (ulong)track.Indexes[0]; - if(track.Sequence == 1) - track.Indexes[0] = -150; + if(track.Sequence == 1) track.Indexes[0] = -150; - if(track.Indexes[0] == 0) - track.Indexes.Remove(0); + if(track.Indexes[0] == 0) track.Indexes.Remove(0); position += 4; track.StartSector = BitConverter.ToUInt32(descriptor, position); @@ -278,8 +273,7 @@ public sealed partial class DiscJuggler { leftLen -= idx.Value; - if(idx.Key == 0 && track.Sequence == 1) - continue; + if(idx.Key == 0 && track.Sequence == 1) continue; track.Indexes[idx.Key] = (int)track.StartSector + leftLen; } @@ -348,8 +342,7 @@ public sealed partial class DiscJuggler { // Audio case 0: - if(_imageInfo.SectorSize < 2352) - _imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) _imageInfo.SectorSize = 2352; track.Type = TrackType.Audio; track.BytesPerSector = 2352; @@ -358,16 +351,14 @@ public sealed partial class DiscJuggler switch(readMode) { case 2: - if(firstTrack) - currentOffset += 150 * (ulong)track.RawBytesPerSector; + if(firstTrack) currentOffset += 150 * (ulong)track.RawBytesPerSector; track.FileOffset = currentOffset; currentOffset += trackLen * (ulong)track.RawBytesPerSector; break; case 3: - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -378,8 +369,7 @@ public sealed partial class DiscJuggler break; case 4: - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -399,8 +389,7 @@ public sealed partial class DiscJuggler // Mode 1 or DVD case 1: - if(_imageInfo.SectorSize < 2048) - _imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) _imageInfo.SectorSize = 2048; track.Type = TrackType.CdMode1; track.BytesPerSector = 2048; @@ -410,17 +399,16 @@ public sealed partial class DiscJuggler case 0: track.RawBytesPerSector = 2048; - if(firstTrack) - currentOffset += 150 * (ulong)track.RawBytesPerSector; + if(firstTrack) currentOffset += 150 * (ulong)track.RawBytesPerSector; track.FileOffset = currentOffset; currentOffset += trackLen * (ulong)track.RawBytesPerSector; break; case 1: - AaruConsole. - ErrorWriteLine(string.Format(Localization.Invalid_read_mode_0_for_this_track, - readMode)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Invalid_read_mode_0_for_this_track, + readMode)); return ErrorNumber.InvalidArgument; case 2: @@ -449,8 +437,7 @@ public sealed partial class DiscJuggler case 3: track.RawBytesPerSector = 2352; - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -481,8 +468,7 @@ public sealed partial class DiscJuggler case 4: track.RawBytesPerSector = 2352; - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -520,8 +506,7 @@ public sealed partial class DiscJuggler // Mode 2 case 2: - if(_imageInfo.SectorSize < 2336) - _imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) _imageInfo.SectorSize = 2336; track.Type = TrackType.CdMode2Formless; track.BytesPerSector = 2336; @@ -529,16 +514,15 @@ public sealed partial class DiscJuggler switch(readMode) { case 0: - AaruConsole. - ErrorWriteLine(string.Format(Localization.Invalid_read_mode_0_for_this_track, - readMode)); + AaruConsole.ErrorWriteLine(string.Format(Localization + .Invalid_read_mode_0_for_this_track, + readMode)); return ErrorNumber.InvalidArgument; case 1: track.RawBytesPerSector = 2336; - if(firstTrack) - currentOffset += 150 * (ulong)track.RawBytesPerSector; + if(firstTrack) currentOffset += 150 * (ulong)track.RawBytesPerSector; track.FileOffset = currentOffset; currentOffset += trackLen * (ulong)track.RawBytesPerSector; @@ -558,8 +542,7 @@ public sealed partial class DiscJuggler case 3: track.RawBytesPerSector = 2352; - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 16); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -578,8 +561,7 @@ public sealed partial class DiscJuggler case 4: track.RawBytesPerSector = 2352; - if(firstTrack) - currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); + if(firstTrack) currentOffset += 150 * (ulong)(track.RawBytesPerSector + 96); track.FileOffset = currentOffset; track.SubchannelFile = track.File; @@ -638,8 +620,7 @@ public sealed partial class DiscJuggler partition.Size = partition.Length * (ulong)track.BytesPerSector; - if(track.EndSector + 1 > _imageInfo.Sectors) - _imageInfo.Sectors = track.EndSector + 1; + if(track.EndSector + 1 > _imageInfo.Sectors) _imageInfo.Sectors = track.EndSector + 1; Partitions.Add(partition); _offsetMap.Add(track.Sequence, track.StartSector); @@ -648,8 +629,7 @@ public sealed partial class DiscJuggler addedATrack = true; } - if(!addedATrack) - continue; + if(!addedATrack) continue; lastSessionTrack = session.EndTrack; Sessions.Add(session); @@ -778,8 +758,7 @@ public sealed partial class DiscJuggler _isCd = mediumType == 152; - if(_isCd) - return ErrorNumber.NoError; + if(_isCd) return ErrorNumber.NoError; foreach(Track track in Tracks) { @@ -809,8 +788,7 @@ public sealed partial class DiscJuggler { case MediaTagType.CD_TEXT: { - if(_cdtext is { Length: > 0 }) - buffer = _cdtext?.Clone() as byte[]; + if(_cdtext is { Length: > 0 }) buffer = _cdtext?.Clone() as byte[]; return buffer != null ? ErrorNumber.NoError : ErrorNumber.NoData; } @@ -875,11 +853,9 @@ public sealed partial class DiscJuggler Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; uint sectorOffset; uint sectorSize; @@ -958,7 +934,10 @@ public sealed partial class DiscJuggler { var sector = new byte[aaruTrack.RawBytesPerSector]; - Array.Copy(buffer, (aaruTrack.RawBytesPerSector + sectorSkip) * i, sector, 0, + Array.Copy(buffer, + (aaruTrack.RawBytesPerSector + sectorSkip) * i, + sector, + 0, aaruTrack.RawBytesPerSector); sector = Sector.GetUserDataFromMode2(sector); @@ -990,19 +969,15 @@ public sealed partial class DiscJuggler { buffer = null; - if(tag == SectorTagType.CdTrackFlags) - track = (uint)sectorAddress; + if(tag == SectorTagType.CdTrackFlags) track = (uint)sectorAddress; Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; - if(aaruTrack.Type == TrackType.Data) - return ErrorNumber.NotSupported; + if(aaruTrack.Type == TrackType.Data) return ErrorNumber.NotSupported; switch(tag) { @@ -1016,8 +991,7 @@ public sealed partial class DiscJuggler case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(!_trackFlags.TryGetValue(track, out byte flag)) - return ErrorNumber.NoData; + if(!_trackFlags.TryGetValue(track, out byte flag)) return ErrorNumber.NoData; buffer = new[] { @@ -1036,8 +1010,7 @@ public sealed partial class DiscJuggler switch(aaruTrack.Type) { case TrackType.CdMode1: - if(aaruTrack.RawBytesPerSector != 2352) - return ErrorNumber.NotSupported; + if(aaruTrack.RawBytesPerSector != 2352) return ErrorNumber.NotSupported; switch(tag) { @@ -1117,8 +1090,7 @@ public sealed partial class DiscJuggler break; case TrackType.CdMode2Formless: - if(aaruTrack.RawBytesPerSector != 2352) - return ErrorNumber.NotSupported; + if(aaruTrack.RawBytesPerSector != 2352) return ErrorNumber.NotSupported; { switch(tag) @@ -1276,16 +1248,13 @@ public sealed partial class DiscJuggler { buffer = null; - if(!_isCd) - return ReadSectors(sectorAddress, length, track, out buffer); + if(!_isCd) return ReadSectors(sectorAddress, length, track, out buffer); Track aaruTrack = Tracks.FirstOrDefault(linqTrack => linqTrack.Sequence == track); - if(aaruTrack is null) - return ErrorNumber.SectorNotFound; + if(aaruTrack is null) return ErrorNumber.SectorNotFound; - if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) - return ErrorNumber.OutOfRange; + if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; var sectorSize = (uint)aaruTrack.RawBytesPerSector; uint sectorSkip = 0; @@ -1351,7 +1320,8 @@ public sealed partial class DiscJuggler for(uint i = 0; i < length; i++) { - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Formless, + _sectorBuilder.ReconstructPrefix(ref fullSector, + TrackType.CdMode2Formless, (long)(sectorAddress + i)); Array.Copy(buffer, i * 2336, fullSector, 16, 2336); diff --git a/Aaru.Images/DiscJuggler/Verify.cs b/Aaru.Images/DiscJuggler/Verify.cs index dcea19cc9..eef531a8c 100644 --- a/Aaru.Images/DiscJuggler/Verify.cs +++ b/Aaru.Images/DiscJuggler/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class DiscJuggler unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -81,8 +80,7 @@ public sealed partial class DiscJuggler } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } @@ -95,8 +93,7 @@ public sealed partial class DiscJuggler unknownLbas = new List(); ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); - if(errno != ErrorNumber.NoError) - return null; + if(errno != ErrorNumber.NoError) return null; var bps = (int)(buffer.Length / length); var sector = new byte[bps]; @@ -119,8 +116,7 @@ public sealed partial class DiscJuggler } } - if(unknownLbas.Count > 0) - return null; + if(unknownLbas.Count > 0) return null; return failingLbas.Count <= 0; } diff --git a/Aaru.Images/DiskCopy42/Helpers.cs b/Aaru.Images/DiskCopy42/Helpers.cs index e16b33abd..1a1e55d0e 100644 --- a/Aaru.Images/DiskCopy42/Helpers.cs +++ b/Aaru.Images/DiskCopy42/Helpers.cs @@ -38,8 +38,7 @@ public sealed partial class DiskCopy42 { uint dc42Chk = 0; - if((buffer.Length & 0x01) == 0x01) - return 0xFFFFFFFF; + if((buffer.Length & 0x01) == 0x01) return 0xFFFFFFFF; for(uint i = 0; i < buffer.Length; i += 2) { diff --git a/Aaru.Images/DiskCopy42/Identify.cs b/Aaru.Images/DiskCopy42/Identify.cs index d763fc245..c27076f1c 100644 --- a/Aaru.Images/DiskCopy42/Identify.cs +++ b/Aaru.Images/DiskCopy42/Identify.cs @@ -53,8 +53,7 @@ public sealed partial class DiskCopy42 stream.EnsureRead(buffer, 0, 0x58); // Incorrect pascal string length, not DC42 - if(buffer[0] > 63) - return false; + if(buffer[0] > 63) return false; var tmpHeader = new Header(); @@ -80,8 +79,7 @@ public sealed partial class DiskCopy42 AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_header.valid = {0}", tmpHeader.Valid); AaruConsole.DebugWriteLine(MODULE_NAME, "tmp_header.reserved = {0}", tmpHeader.Reserved); - if(tmpHeader.Valid != 1 || tmpHeader.Reserved != 0) - return false; + if(tmpHeader.Valid != 1 || tmpHeader.Reserved != 0) return false; // Some versions seem to incorrectly create little endian fields if(tmpHeader.DataSize + tmpHeader.TagSize + 0x54 != imageFilter.DataForkLength && @@ -105,7 +103,8 @@ public sealed partial class DiskCopy42 tmpHeader.Format != kSigmaFormatTwiggy && tmpHeader.Format != kNotStandardFormat) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Unknown_tmp_header_format_equals_0_value, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Unknown_tmp_header_format_equals_0_value, tmpHeader.Format); return false; @@ -120,14 +119,14 @@ public sealed partial class DiskCopy42 tmpHeader.FmtByte != kFmtNotStandard && tmpHeader.FmtByte != kMacOSXFmtByte) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Unknown_tmp_header_fmtByte_equals_0_value, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Unknown_tmp_header_fmtByte_equals_0_value, tmpHeader.FmtByte); return false; } - if(tmpHeader.FmtByte != kInvalidFmtByte) - return true; + if(tmpHeader.FmtByte != kInvalidFmtByte) return true; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Image_says_its_unformatted); diff --git a/Aaru.Images/DiskCopy42/Read.cs b/Aaru.Images/DiskCopy42/Read.cs index e7a3a43fd..8addf8683 100644 --- a/Aaru.Images/DiskCopy42/Read.cs +++ b/Aaru.Images/DiskCopy42/Read.cs @@ -59,8 +59,7 @@ public sealed partial class DiskCopy42 IsWriting = false; // Incorrect pascal string length, not DC42 - if(buffer[0] > 63) - return ErrorNumber.InvalidArgument; + if(buffer[0] > 63) return ErrorNumber.InvalidArgument; header = new Header(); @@ -85,8 +84,7 @@ public sealed partial class DiskCopy42 AaruConsole.DebugWriteLine(MODULE_NAME, "header.valid = {0}", header.Valid); AaruConsole.DebugWriteLine(MODULE_NAME, "header.reserved = {0}", header.Reserved); - if(header.Valid != 1 || header.Reserved != 0) - return ErrorNumber.InvalidArgument; + if(header.Valid != 1 || header.Reserved != 0) return ErrorNumber.InvalidArgument; // Some versions seem to incorrectly create little endian fields if(header.DataSize + header.TagSize + 0x54 != imageFilter.DataForkLength && header.Format != kSigmaFormatTwiggy) @@ -123,7 +121,8 @@ public sealed partial class DiskCopy42 header.FmtByte != kFmtNotStandard && header.FmtByte != kMacOSXFmtByte) { - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Unknown_tmp_header_fmtByte_equals_0_value, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Unknown_tmp_header_fmtByte_equals_0_value, header.FmtByte); return ErrorNumber.NotSupported; @@ -240,11 +239,16 @@ public sealed partial class DiskCopy42 _ => sectorsToCopy }; - Array.Copy(data, header.DataSize / 2 + copiedSectors * 512, twiggyCache, - twiggyCache.Length - copiedSectors * 512 - sectorsToCopy * 512, sectorsToCopy * 512); + Array.Copy(data, + header.DataSize / 2 + copiedSectors * 512, + twiggyCache, + twiggyCache.Length - copiedSectors * 512 - sectorsToCopy * 512, + sectorsToCopy * 512); - Array.Copy(tags, header.TagSize / 2 + copiedSectors * bptag, twiggyCacheTags, - twiggyCacheTags.Length - copiedSectors * bptag - sectorsToCopy * bptag, + Array.Copy(tags, + header.TagSize / 2 + copiedSectors * bptag, + twiggyCacheTags, + twiggyCacheTags.Length - copiedSectors * bptag - sectorsToCopy * bptag, sectorsToCopy * bptag); copiedSectors += sectorsToCopy; @@ -274,8 +278,7 @@ public sealed partial class DiskCopy42 var major = $"{version.MajorVersion}"; var minor = $".{version.MinorVersion / 10}"; - if(version.MinorVersion % 10 > 0) - release = $".{version.MinorVersion % 10}"; + if(version.MinorVersion % 10 > 0) release = $".{version.MinorVersion % 10}"; string dev = version.DevStage switch { @@ -285,11 +288,9 @@ public sealed partial class DiskCopy42 _ => null }; - if(dev == null && version.PreReleaseVersion > 0) - dev = "f"; + if(dev == null && version.PreReleaseVersion > 0) dev = "f"; - if(dev != null) - pre = $"{version.PreReleaseVersion}"; + if(dev != null) pre = $"{version.PreReleaseVersion}"; imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; imageInfo.Application = version.VersionString; @@ -320,7 +321,9 @@ public sealed partial class DiskCopy42 } catch(InvalidCastException) {} - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Image_application_0_version_1, imageInfo.Application, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Image_application_0_version_1, + imageInfo.Application, imageInfo.ApplicationVersion); imageInfo.MetadataMediaType = MetadataMediaType.BlockMedia; @@ -405,18 +408,19 @@ public sealed partial class DiskCopy42 { buffer = null; - if(sectorAddress > imageInfo.Sectors - 1) - return ErrorNumber.SectorNotFound; + if(sectorAddress > imageInfo.Sectors - 1) return ErrorNumber.SectorNotFound; - if(sectorAddress + length > imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * imageInfo.SectorSize]; if(twiggy) { - Array.Copy(twiggyCache, (int)sectorAddress * imageInfo.SectorSize, buffer, 0, - length * imageInfo.SectorSize); + Array.Copy(twiggyCache, + (int)sectorAddress * imageInfo.SectorSize, + buffer, + 0, + length * imageInfo.SectorSize); } else { @@ -433,17 +437,13 @@ public sealed partial class DiskCopy42 { buffer = null; - if(tag != SectorTagType.AppleSectorTag) - return ErrorNumber.NotSupported; + if(tag != SectorTagType.AppleSectorTag) return ErrorNumber.NotSupported; - if(header.TagSize == 0) - return ErrorNumber.NoData; + if(header.TagSize == 0) return ErrorNumber.NoData; - if(sectorAddress > imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > imageInfo.Sectors) return ErrorNumber.OutOfRange; buffer = new byte[length * bptag]; @@ -468,27 +468,26 @@ public sealed partial class DiskCopy42 { buffer = null; - if(sectorAddress > imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > imageInfo.Sectors) return ErrorNumber.OutOfRange; ErrorNumber errno = ReadSectors(sectorAddress, length, out byte[] data); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; errno = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag, out byte[] tags); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; buffer = new byte[data.Length + tags.Length]; for(uint i = 0; i < length; i++) { - Array.Copy(data, i * imageInfo.SectorSize, buffer, i * (imageInfo.SectorSize + bptag), + Array.Copy(data, + i * imageInfo.SectorSize, + buffer, + i * (imageInfo.SectorSize + bptag), imageInfo.SectorSize); Array.Copy(tags, i * bptag, buffer, i * (imageInfo.SectorSize + bptag) + imageInfo.SectorSize, bptag); diff --git a/Aaru.Images/DiskCopy42/Verify.cs b/Aaru.Images/DiskCopy42/Verify.cs index e6ddc9fb8..a3db4e45d 100644 --- a/Aaru.Images/DiskCopy42/Verify.cs +++ b/Aaru.Images/DiskCopy42/Verify.cs @@ -57,8 +57,7 @@ public sealed partial class DiskCopy42 AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Calculated_data_checksum_equals_0_X8, dataChk); AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Stored_data_checksum_equals_0_X8, header.DataChecksum); - if(header.TagSize <= 0) - return dataChk == header.DataChecksum && tagsChk == header.TagChecksum; + if(header.TagSize <= 0) return dataChk == header.DataChecksum && tagsChk == header.TagChecksum; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Reading_tags); Stream tagStream = dc42ImageFilter.GetDataForkStream(); diff --git a/Aaru.Images/DiskCopy42/Write.cs b/Aaru.Images/DiskCopy42/Write.cs index 16b8a1f00..0509ddb13 100644 --- a/Aaru.Images/DiskCopy42/Write.cs +++ b/Aaru.Images/DiskCopy42/Write.cs @@ -54,8 +54,7 @@ public sealed partial class DiskCopy42 var tags = false; var macosx = false; - if(options != null && options.TryGetValue("macosx", out string tmpOption)) - bool.TryParse(tmpOption, out macosx); + if(options != null && options.TryGetValue("macosx", out string tmpOption)) bool.TryParse(tmpOption, out macosx); if(sectorSize != 512) { @@ -188,8 +187,7 @@ public sealed partial class DiskCopy42 header.Valid = 1; header.DataSize = (uint)(sectors * 512); - if(tags) - header.TagSize = (uint)(sectors * 12); + if(tags) header.TagSize = (uint)(sectors * 12); imageInfo = new ImageInfo { @@ -386,8 +384,7 @@ public sealed partial class DiskCopy42 } // No tags where written - if(writingStream.Length == 0x54 + header.DataSize) - header.TagSize = 0; + if(writingStream.Length == 0x54 + header.DataSize) header.TagSize = 0; writingStream.Seek(0x54, SeekOrigin.Begin); var data = new byte[header.DataSize]; @@ -400,8 +397,7 @@ public sealed partial class DiskCopy42 writingStream.Seek(0, SeekOrigin.Begin); - if(header.DiskName.Length > 63) - header.DiskName = header.DiskName[..63]; + if(header.DiskName.Length > 63) header.DiskName = header.DiskName[..63]; writingStream.WriteByte((byte)header.DiskName.Length); Encoding macRoman = new MacRoman(); diff --git a/Aaru.Images/DiskDupe/Helpers.cs b/Aaru.Images/DiskDupe/Helpers.cs index dd066f541..46311557b 100644 --- a/Aaru.Images/DiskDupe/Helpers.cs +++ b/Aaru.Images/DiskDupe/Helpers.cs @@ -47,21 +47,18 @@ public sealed partial class DiskDupe stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 256) - return false; + if(stream.Length < 256) return false; // read and check signature fHeader.signature = new byte[10]; stream.EnsureRead(fHeader.signature, 0, 10); - if(!fHeader.signature.SequenceEqual(_headerMagic)) - return false; + if(!fHeader.signature.SequenceEqual(_headerMagic)) return false; // read and check disk type byte fHeader.diskType = (byte)stream.ReadByte(); - if(fHeader.diskType is < 1 or > 4) - return false; + if(fHeader.diskType is < 1 or > 4) return false; // seek to start of the trackmap stream.Seek(TRACKMAP_OFFSET, SeekOrigin.Begin); @@ -70,8 +67,10 @@ public sealed partial class DiskDupe var trackMap = new TrackInfo[numTracks]; var trackOffsets = new long[numTracks]; - AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Identified_image_with_CHS_equals_0_1_2, - _diskTypes[fHeader.diskType].cyl, _diskTypes[fHeader.diskType].hd, + AaruConsole.DebugWriteLine(MODULE_NAME, + Localization.Identified_image_with_CHS_equals_0_1_2, + _diskTypes[fHeader.diskType].cyl, + _diskTypes[fHeader.diskType].hd, _diskTypes[fHeader.diskType].spt); // read the trackmap and store the track offsets diff --git a/Aaru.Images/DiskDupe/Properties.cs b/Aaru.Images/DiskDupe/Properties.cs index 442f19d14..b43dd3646 100644 --- a/Aaru.Images/DiskDupe/Properties.cs +++ b/Aaru.Images/DiskDupe/Properties.cs @@ -55,6 +55,7 @@ public sealed partial class DiskDupe public string Format => "DDI disk image"; /// + // ReSharper disable once ConvertToAutoProperty public ImageInfo Info => _imageInfo; diff --git a/Aaru.Images/DiskDupe/Read.cs b/Aaru.Images/DiskDupe/Read.cs index 8bf725b31..df3115cec 100644 --- a/Aaru.Images/DiskDupe/Read.cs +++ b/Aaru.Images/DiskDupe/Read.cs @@ -53,12 +53,12 @@ public sealed partial class DiskDupe TrackInfo[] trackMap = null; long[] trackOffsets = null; - if(!TryReadHeader(stream, ref fHeader, ref trackMap, ref trackOffsets)) - return ErrorNumber.InvalidArgument; + if(!TryReadHeader(stream, ref fHeader, ref trackMap, ref trackOffsets)) return ErrorNumber.InvalidArgument; AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Detected_DiskDupe_DDI_image_with_0_tracks_and_1_sectors_per_track, - _diskTypes[fHeader.diskType].cyl, _diskTypes[fHeader.diskType].spt); + _diskTypes[fHeader.diskType].cyl, + _diskTypes[fHeader.diskType].spt); _imageInfo.Cylinders = _diskTypes[fHeader.diskType].cyl; _imageInfo.Heads = _diskTypes[fHeader.diskType].hd; @@ -92,11 +92,9 @@ public sealed partial class DiskDupe var trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); var sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(trackNum > 2 * _imageInfo.Cylinders) - return ErrorNumber.SectorNotFound; + if(trackNum > 2 * _imageInfo.Cylinders) return ErrorNumber.SectorNotFound; buffer = new byte[_imageInfo.SectorSize]; @@ -118,11 +116,9 @@ public sealed partial class DiskDupe { buffer = null; - if(sectorAddress > _imageInfo.Sectors - 1) - return ErrorNumber.OutOfRange; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - if(sectorAddress + length > _imageInfo.Sectors) - return ErrorNumber.OutOfRange; + if(sectorAddress + length > _imageInfo.Sectors) return ErrorNumber.OutOfRange; var ms = new MemoryStream(); @@ -130,8 +126,7 @@ public sealed partial class DiskDupe { ErrorNumber errno = ReadSector(sectorAddress + i, out byte[] sector); - if(errno != ErrorNumber.NoError) - return errno; + if(errno != ErrorNumber.NoError) return errno; ms.Write(sector, 0, sector.Length); } diff --git a/Aaru.Images/DriDiskCopy/Identify.cs b/Aaru.Images/DriDiskCopy/Identify.cs index 7ba59252e..3fda20adb 100644 --- a/Aaru.Images/DriDiskCopy/Identify.cs +++ b/Aaru.Images/DriDiskCopy/Identify.cs @@ -47,8 +47,7 @@ public sealed partial class DriDiskCopy { Stream stream = imageFilter.GetDataForkStream(); - if((stream.Length - Marshal.SizeOf