From 762e3eb6d25b0a5ec81bacad2da442c11850e47d Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 7 Mar 2022 07:36:44 +0000 Subject: [PATCH] General cleanup and refactor. --- .editorconfig | 5 +- .github/CODE_OF_CONDUCT.md | 4 +- Aaru.Archives/Aaru.Archives.csproj | 170 +- Aaru.Archives/Register.cs | 4 +- Aaru.Checksums | 2 +- Aaru.CommonTypes | 2 +- Aaru.Compression/ADC.cs | 57 +- Aaru.Compression/Aaru.Compression.csproj | 248 +- Aaru.Compression/AppleRle.cs | 27 +- Aaru.Compression/BZip2.cs | 12 +- Aaru.Compression/FLAC.cs | 30 +- Aaru.Compression/LZFSE.cs | 8 +- Aaru.Compression/LZIP.cs | 8 +- Aaru.Compression/LZMA.cs | 8 +- Aaru.Compression/Native.cs | 4 +- Aaru.Compression/TeleDiskLzh.cs | 26 +- Aaru.Compression/ZSTD.cs | 8 +- Aaru.Console | 2 +- Aaru.Core/Aaru.Core.csproj | 443 +- Aaru.Core/Checksum.cs | 13 +- Aaru.Core/DataFile.cs | 13 +- Aaru.Core/Devices/Dumping/ATA.cs | 45 +- .../Devices/Dumping/CompactDisc/CdiReady.cs | 87 +- Aaru.Core/Devices/Dumping/CompactDisc/Data.cs | 138 +- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 147 +- .../Devices/Dumping/CompactDisc/Error.cs | 128 +- .../Devices/Dumping/CompactDisc/LeadOuts.cs | 100 +- .../Devices/Dumping/CompactDisc/Offset.cs | 30 +- .../Devices/Dumping/CompactDisc/Plextor.cs | 10 +- .../Devices/Dumping/CompactDisc/Pregap.cs | 187 +- .../Devices/Dumping/CompactDisc/Subchannel.cs | 16 +- Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs | 18 +- .../Devices/Dumping/CompactDisc/Tracks.cs | 47 +- Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs | 89 +- Aaru.Core/Devices/Dumping/Dump.cs | 15 +- .../Devices/Dumping/LinearMemory/Retrode.cs | 41 +- Aaru.Core/Devices/Dumping/MMC.cs | 67 +- Aaru.Core/Devices/Dumping/Metadata.cs | 20 +- Aaru.Core/Devices/Dumping/MiniDisc.cs | 36 +- .../PlayStationPortable/MemoryStick.cs | 27 +- .../PlayStationPortable.cs | 35 +- .../Dumping/PlayStationPortable/UMD.cs | 45 +- Aaru.Core/Devices/Dumping/ResumeSupport.cs | 12 +- Aaru.Core/Devices/Dumping/SCSI.cs | 33 +- Aaru.Core/Devices/Dumping/SSC.cs | 99 +- Aaru.Core/Devices/Dumping/Sbc/Data.cs | 23 +- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 99 +- Aaru.Core/Devices/Dumping/Sbc/Error.cs | 49 +- Aaru.Core/Devices/Dumping/Sbc/Optical.cs | 16 +- Aaru.Core/Devices/Dumping/Sbc/Trim.cs | 13 +- Aaru.Core/Devices/Dumping/SecureDigital.cs | 86 +- Aaru.Core/Devices/Dumping/XGD.cs | 57 +- Aaru.Core/Devices/Info/DeviceInfo.cs | 57 +- Aaru.Core/Devices/Info/Properties.cs | 4 +- Aaru.Core/Devices/Reader.cs | 10 +- Aaru.Core/Devices/ReaderATA.cs | 31 +- Aaru.Core/Devices/ReaderSCSI.cs | 63 +- Aaru.Core/Devices/Report/ATA.cs | 127 +- Aaru.Core/Devices/Report/DeviceReport.cs | 4 +- Aaru.Core/Devices/Report/FireWire.cs | 6 +- Aaru.Core/Devices/Report/GdRomSwapTrick.cs | 305 +- Aaru.Core/Devices/Report/MMC.cs | 414 +- Aaru.Core/Devices/Report/PCMCIA.cs | 4 +- Aaru.Core/Devices/Report/SSC.cs | 37 +- Aaru.Core/Devices/Report/Scsi.cs | 92 +- Aaru.Core/Devices/Report/SecureDigital.cs | 8 +- Aaru.Core/Devices/Report/USB.cs | 4 +- Aaru.Core/Devices/Scanning/ATA.cs | 19 +- Aaru.Core/Devices/Scanning/MediaScan.cs | 4 +- Aaru.Core/Devices/Scanning/NVMe.cs | 2 +- Aaru.Core/Devices/Scanning/SCSI.cs | 49 +- Aaru.Core/Devices/Scanning/ScanResults.cs | 4 +- Aaru.Core/Devices/Scanning/SecureDigital.cs | 57 +- Aaru.Core/Entropy.cs | 14 +- Aaru.Core/Error.cs | 4 +- Aaru.Core/Filesystems.cs | 4 +- Aaru.Core/GetPluginBase.cs | 4 +- Aaru.Core/ImageFormat.cs | 4 +- Aaru.Core/ImageInfo.cs | 33 +- Aaru.Core/Logging/DumpLog.cs | 11 +- Aaru.Core/Logging/ErrorLog.cs | 56 +- Aaru.Core/Logging/IBGLog.cs | 9 +- Aaru.Core/Logging/MHDDLog.cs | 32 +- Aaru.Core/Logging/SubchannelLog.cs | 73 +- Aaru.Core/Media/CompactDisc.cs | 285 +- Aaru.Core/Media/Detection/MMC.cs | 386 +- Aaru.Core/Media/Info/CompactDisc.cs | 103 +- Aaru.Core/Media/Info/ScsiInfo.cs | 105 +- Aaru.Core/Options.cs | 20 +- Aaru.Core/Partitions.cs | 25 +- Aaru.Core/PrintScsiModePages.cs | 8 +- Aaru.Core/Remote.cs | 23 +- Aaru.Core/Sidecar/AudioMedia.cs | 4 +- Aaru.Core/Sidecar/BlockMedia.cs | 34 +- Aaru.Core/Sidecar/BlockTape.cs | 14 +- Aaru.Core/Sidecar/Events.cs | 7 +- Aaru.Core/Sidecar/Files.cs | 4 +- Aaru.Core/Sidecar/Helpers.cs | 14 +- Aaru.Core/Sidecar/LinearMedia.cs | 4 +- Aaru.Core/Sidecar/OpticalDisc.cs | 15 +- Aaru.Core/Sidecar/Sidecar.cs | 4 +- Aaru.Core/Spectre.cs | 10 +- Aaru.Core/Statistics.cs | 298 +- Aaru.Database/Aaru.Database.csproj | 390 +- Aaru.Database/Context.cs | 4 +- Aaru.Database/ContextFactory.cs | 4 +- Aaru.Database/Models/BaseModel.cs | 4 +- Aaru.Database/Models/CdOffset.cs | 4 +- Aaru.Database/Models/Device.cs | 4 +- Aaru.Database/Models/NesHeaderInfo.cs | 4 +- Aaru.Database/Models/Report.cs | 4 +- Aaru.Database/Models/UsbProduct.cs | 4 +- Aaru.Database/Models/UsbVendor.cs | 4 +- Aaru.Decoders | 2 +- Aaru.Decryption | 2 +- Aaru.Devices/Aaru.Devices.csproj | 319 +- Aaru.Devices/Command.cs | 94 +- Aaru.Devices/Device/AtaCommands/Ata28.cs | 46 +- Aaru.Devices/Device/AtaCommands/Ata48.cs | 29 +- Aaru.Devices/Device/AtaCommands/AtaCHS.cs | 61 +- Aaru.Devices/Device/AtaCommands/Atapi.cs | 9 +- Aaru.Devices/Device/AtaCommands/Cfa.cs | 31 +- Aaru.Devices/Device/AtaCommands/MCPT.cs | 9 +- Aaru.Devices/Device/AtaCommands/Smart.cs | 48 +- Aaru.Devices/Device/Commands.cs | 43 +- Aaru.Devices/Device/Constructor.cs | 106 +- Aaru.Devices/Device/Destructor.cs | 4 +- Aaru.Devices/Device/DeviceException.cs | 4 +- Aaru.Devices/Device/List.cs | 14 +- Aaru.Devices/Device/MmcCommands/MMC.cs | 33 +- .../Device/MmcCommands/SecureDigital.cs | 4 +- Aaru.Devices/Device/ScsiCommands/Adaptec.cs | 24 +- .../Device/ScsiCommands/ArchiveCorp.cs | 8 +- Aaru.Devices/Device/ScsiCommands/Certance.cs | 6 +- Aaru.Devices/Device/ScsiCommands/Fujitsu.cs | 16 +- Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs | 10 +- Aaru.Devices/Device/ScsiCommands/HP.cs | 11 +- Aaru.Devices/Device/ScsiCommands/Kreon.cs | 18 +- Aaru.Devices/Device/ScsiCommands/MMC.cs | 66 +- Aaru.Devices/Device/ScsiCommands/MediaTek.cs | 6 +- Aaru.Devices/Device/ScsiCommands/MiniDisc.cs | 18 +- Aaru.Devices/Device/ScsiCommands/NEC.cs | 6 +- Aaru.Devices/Device/ScsiCommands/Optical.cs | 6 +- Aaru.Devices/Device/ScsiCommands/Pioneer.cs | 15 +- Aaru.Devices/Device/ScsiCommands/Plasmon.cs | 12 +- Aaru.Devices/Device/ScsiCommands/Plextor.cs | 44 +- Aaru.Devices/Device/ScsiCommands/SBC.cs | 32 +- Aaru.Devices/Device/ScsiCommands/SMC.cs | 8 +- Aaru.Devices/Device/ScsiCommands/SPC.cs | 77 +- Aaru.Devices/Device/ScsiCommands/SSC.cs | 93 +- Aaru.Devices/Device/ScsiCommands/SyQuest.cs | 26 +- Aaru.Devices/Device/Variables.cs | 4 +- Aaru.Devices/Enums.cs | 106 +- Aaru.Devices/Linux/Command.cs | 49 +- Aaru.Devices/Linux/Enums.cs | 37 +- Aaru.Devices/Linux/Extern.cs | 9 +- Aaru.Devices/Linux/ListDevices.cs | 12 +- Aaru.Devices/Linux/Structs.cs | 8 +- Aaru.Devices/Remote/Enums.cs | 44 +- Aaru.Devices/Remote/Remote.cs | 108 +- Aaru.Devices/Remote/Structs.cs | 8 +- Aaru.Devices/Windows/Command.cs | 53 +- Aaru.Devices/Windows/Enums.cs | 143 +- Aaru.Devices/Windows/Extern.cs | 30 +- Aaru.Devices/Windows/ListDevices.cs | 30 +- Aaru.Devices/Windows/Structs.cs | 36 +- Aaru.Devices/Windows/Usb.cs | 110 +- Aaru.Devices/Windows/UsbFunctions.cs | 20 +- Aaru.Dto | 2 +- Aaru.Filesystems/AODOS.cs | 10 +- Aaru.Filesystems/APFS.cs | 7 +- Aaru.Filesystems/Aaru.Filesystems.csproj | 577 +- Aaru.Filesystems/Acorn.cs | 57 +- Aaru.Filesystems/AmigaDOS.cs | 39 +- Aaru.Filesystems/AppleCommon/Consts.cs | 2 +- Aaru.Filesystems/AppleCommon/Enums.cs | 22 +- Aaru.Filesystems/AppleCommon/Info.cs | 17 +- Aaru.Filesystems/AppleCommon/Structs.cs | 6 +- Aaru.Filesystems/AppleDOS/AppleDOS.cs | 4 +- Aaru.Filesystems/AppleDOS/Dir.cs | 16 +- Aaru.Filesystems/AppleDOS/File.cs | 15 +- Aaru.Filesystems/AppleDOS/Info.cs | 18 +- Aaru.Filesystems/AppleDOS/Structs.cs | 4 +- Aaru.Filesystems/AppleDOS/Super.cs | 4 +- Aaru.Filesystems/AppleDOS/Xattr.cs | 5 +- Aaru.Filesystems/AppleHFS/AppleHFS.cs | 6 +- Aaru.Filesystems/AppleHFS/Consts.cs | 4 +- Aaru.Filesystems/AppleHFS/Enums.cs | 3 +- Aaru.Filesystems/AppleHFS/Info.cs | 12 +- Aaru.Filesystems/AppleHFS/Structs.cs | 4 +- Aaru.Filesystems/AppleHFSPlus.cs | 29 +- Aaru.Filesystems/AppleMFS/AppleMFS.cs | 4 +- Aaru.Filesystems/AppleMFS/Consts.cs | 4 +- Aaru.Filesystems/AppleMFS/Dir.cs | 9 +- Aaru.Filesystems/AppleMFS/File.cs | 16 +- Aaru.Filesystems/AppleMFS/Info.cs | 11 +- Aaru.Filesystems/AppleMFS/Structs.cs | 9 +- Aaru.Filesystems/AppleMFS/Super.cs | 20 +- Aaru.Filesystems/AppleMFS/Xattr.cs | 5 +- Aaru.Filesystems/AtheOS.cs | 21 +- Aaru.Filesystems/BFS.cs | 21 +- Aaru.Filesystems/BTRFS.cs | 18 +- Aaru.Filesystems/CBM.cs | 16 +- Aaru.Filesystems/CPM/CPM.cs | 4 +- Aaru.Filesystems/CPM/Definitions.cs | 8 +- Aaru.Filesystems/CPM/Dir.cs | 17 +- Aaru.Filesystems/CPM/File.cs | 4 +- Aaru.Filesystems/CPM/Info.cs | 107 +- Aaru.Filesystems/CPM/Structs.cs | 6 +- Aaru.Filesystems/CPM/Super.cs | 78 +- Aaru.Filesystems/CPM/Xattr.cs | 4 +- Aaru.Filesystems/CPM/cpmdefs.xml | 43690 ++++++++-------- Aaru.Filesystems/Cram.cs | 28 +- Aaru.Filesystems/ECMA67.cs | 7 +- Aaru.Filesystems/EFS.cs | 45 +- Aaru.Filesystems/F2FS.cs | 11 +- Aaru.Filesystems/FAT/BPB.cs | 79 +- Aaru.Filesystems/FAT/Consts.cs | 53 +- Aaru.Filesystems/FAT/Dir.cs | 35 +- Aaru.Filesystems/FAT/FAT.cs | 4 +- Aaru.Filesystems/FAT/File.cs | 34 +- Aaru.Filesystems/FAT/Info.cs | 134 +- Aaru.Filesystems/FAT/Structs.cs | 6 +- Aaru.Filesystems/FAT/Super.cs | 109 +- Aaru.Filesystems/FAT/Xattr.cs | 35 +- Aaru.Filesystems/FATX/Consts.cs | 11 +- Aaru.Filesystems/FATX/Dir.cs | 23 +- Aaru.Filesystems/FATX/FATX.cs | 4 +- Aaru.Filesystems/FATX/File.cs | 21 +- Aaru.Filesystems/FATX/Info.cs | 12 +- Aaru.Filesystems/FATX/Structs.cs | 4 +- Aaru.Filesystems/FATX/Super.cs | 31 +- Aaru.Filesystems/FFS.cs | 50 +- Aaru.Filesystems/Fossil.cs | 9 +- Aaru.Filesystems/HAMMER.cs | 25 +- Aaru.Filesystems/HPFS.cs | 11 +- Aaru.Filesystems/HPOFS/HPOFS.cs | 6 +- Aaru.Filesystems/HPOFS/Info.cs | 13 +- Aaru.Filesystems/HPOFS/Structs.cs | 4 +- Aaru.Filesystems/ISO9660/Consts/AAIP.cs | 4 +- Aaru.Filesystems/ISO9660/Consts/Amiga.cs | 30 +- Aaru.Filesystems/ISO9660/Consts/Apple.cs | 11 +- Aaru.Filesystems/ISO9660/Consts/CDi.cs | 17 +- Aaru.Filesystems/ISO9660/Consts/ElTorito.cs | 30 +- Aaru.Filesystems/ISO9660/Consts/HighSierra.cs | 4 +- Aaru.Filesystems/ISO9660/Consts/ISO.cs | 31 +- Aaru.Filesystems/ISO9660/Consts/Internal.cs | 11 +- Aaru.Filesystems/ISO9660/Consts/RRIP.cs | 53 +- Aaru.Filesystems/ISO9660/Consts/SUSP.cs | 4 +- Aaru.Filesystems/ISO9660/Consts/XA.cs | 30 +- Aaru.Filesystems/ISO9660/Consts/Ziso.cs | 4 +- Aaru.Filesystems/ISO9660/Date.cs | 4 +- Aaru.Filesystems/ISO9660/Dir.cs | 81 +- Aaru.Filesystems/ISO9660/File.cs | 27 +- Aaru.Filesystems/ISO9660/ISO9660.cs | 4 +- Aaru.Filesystems/ISO9660/Info.cs | 130 +- Aaru.Filesystems/ISO9660/Mode2.cs | 32 +- Aaru.Filesystems/ISO9660/PathTable.cs | 22 +- Aaru.Filesystems/ISO9660/Structs/Amiga.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/Apple.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/CDi.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/ElTorito.cs | 4 +- .../ISO9660/Structs/HighSierra.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/ISO.cs | 10 +- Aaru.Filesystems/ISO9660/Structs/Internal.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/Joliet.cs | 22 +- Aaru.Filesystems/ISO9660/Structs/RRIP.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/SUSP.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/XA.cs | 4 +- Aaru.Filesystems/ISO9660/Structs/Ziso.cs | 4 +- Aaru.Filesystems/ISO9660/Super.cs | 40 +- Aaru.Filesystems/ISO9660/Xattr.cs | 4 +- Aaru.Filesystems/JFS.cs | 54 +- Aaru.Filesystems/LIF.cs | 7 +- Aaru.Filesystems/LisaFS/Consts.cs | 4 +- Aaru.Filesystems/LisaFS/Dir.cs | 8 +- Aaru.Filesystems/LisaFS/Extent.cs | 35 +- Aaru.Filesystems/LisaFS/File.cs | 19 +- Aaru.Filesystems/LisaFS/Info.cs | 17 +- Aaru.Filesystems/LisaFS/LisaFS.cs | 4 +- Aaru.Filesystems/LisaFS/Structs.cs | 6 +- Aaru.Filesystems/LisaFS/Super.cs | 8 +- Aaru.Filesystems/LisaFS/Xattr.cs | 4 +- Aaru.Filesystems/Locus.cs | 56 +- Aaru.Filesystems/MicroDOS.cs | 22 +- Aaru.Filesystems/MinixFS.cs | 29 +- Aaru.Filesystems/NILFS2.cs | 27 +- Aaru.Filesystems/NTFS.cs | 18 +- Aaru.Filesystems/Nintendo.cs | 71 +- Aaru.Filesystems/ODS.cs | 16 +- Aaru.Filesystems/Opera/Consts.cs | 11 +- Aaru.Filesystems/Opera/Dir.cs | 21 +- Aaru.Filesystems/Opera/File.cs | 8 +- Aaru.Filesystems/Opera/Info.cs | 16 +- Aaru.Filesystems/Opera/Opera.cs | 4 +- Aaru.Filesystems/Opera/Structs.cs | 4 +- Aaru.Filesystems/Opera/Super.cs | 6 +- Aaru.Filesystems/PCEngine.cs | 9 +- Aaru.Filesystems/PCFX.cs | 16 +- Aaru.Filesystems/PFS.cs | 18 +- Aaru.Filesystems/ProDOS.cs | 67 +- Aaru.Filesystems/QNX4.cs | 10 +- Aaru.Filesystems/QNX6.cs | 7 +- Aaru.Filesystems/RBF.cs | 35 +- Aaru.Filesystems/RT11.cs | 18 +- Aaru.Filesystems/ReFS.cs | 11 +- Aaru.Filesystems/Register.cs | 4 +- Aaru.Filesystems/Reiser.cs | 11 +- Aaru.Filesystems/Reiser4.cs | 11 +- Aaru.Filesystems/SFS.cs | 20 +- Aaru.Filesystems/SolarFS.cs | 11 +- Aaru.Filesystems/Squash.cs | 23 +- Aaru.Filesystems/SysV.cs | 118 +- Aaru.Filesystems/UCSDPascal/Consts.cs | 4 +- Aaru.Filesystems/UCSDPascal/Dir.cs | 4 +- Aaru.Filesystems/UCSDPascal/File.cs | 20 +- Aaru.Filesystems/UCSDPascal/Info.cs | 26 +- Aaru.Filesystems/UCSDPascal/Structs.cs | 4 +- Aaru.Filesystems/UCSDPascal/Super.cs | 30 +- Aaru.Filesystems/UCSDPascal/UCSDPascal.cs | 4 +- Aaru.Filesystems/UDF.cs | 66 +- Aaru.Filesystems/UNICOS.cs | 27 +- Aaru.Filesystems/UNIXBFS.cs | 11 +- Aaru.Filesystems/VMfs.cs | 23 +- Aaru.Filesystems/VxFS.cs | 15 +- Aaru.Filesystems/XFS.cs | 31 +- Aaru.Filesystems/Xia.cs | 27 +- Aaru.Filesystems/ZFS.cs | 176 +- Aaru.Filesystems/dump.cs | 18 +- Aaru.Filesystems/exFAT.cs | 13 +- Aaru.Filesystems/ext2FS.cs | 72 +- Aaru.Filesystems/extFS.cs | 13 +- Aaru.Filters/Aaru.Filters.csproj | 232 +- Aaru.Filters/AppleDouble.cs | 73 +- Aaru.Filters/AppleSingle.cs | 77 +- Aaru.Filters/BZip2.cs | 11 +- Aaru.Filters/ForcedSeekStream.cs | 20 +- Aaru.Filters/GZip.cs | 34 +- Aaru.Filters/LZip.cs | 20 +- Aaru.Filters/MacBinary.cs | 38 +- Aaru.Filters/OffsetStream.cs | 7 +- Aaru.Filters/PCExchange.cs | 29 +- Aaru.Filters/Register.cs | 4 +- Aaru.Filters/SplitJoinStream.cs | 18 +- Aaru.Filters/XZ.cs | 26 +- Aaru.Filters/ZZZNoFilter.cs | 4 +- Aaru.Gui/Aaru.Gui.csproj | 900 +- Aaru.Gui/App.xaml.cs | 30 +- Aaru.Gui/Assets/Logos/Media/XGD2.svg | 4 +- Aaru.Gui/Assets/Logos/Media/XGD3.svg | 4 +- Aaru.Gui/Assets/Logos/Media/XGD4.svg | 4 +- Aaru.Gui/ConsoleHandler.cs | 8 +- Aaru.Gui/Controls/BlockMap.cs | 20 +- Aaru.Gui/Main.cs | 4 +- Aaru.Gui/Models/DeviceModel.cs | 4 +- Aaru.Gui/Models/DevicesRootModel.cs | 4 +- Aaru.Gui/Models/FileModel.cs | 4 +- Aaru.Gui/Models/FileSystemModel.cs | 4 +- Aaru.Gui/Models/ImageModel.cs | 4 +- Aaru.Gui/Models/ImagePluginModel.cs | 4 +- Aaru.Gui/Models/ImagesRootModel.cs | 4 +- Aaru.Gui/Models/MediaModel.cs | 4 +- Aaru.Gui/Models/MediaTagModel.cs | 4 +- Aaru.Gui/Models/PartitionModel.cs | 4 +- Aaru.Gui/Models/PartitionSchemeModel.cs | 4 +- Aaru.Gui/Models/PluginModel.cs | 4 +- Aaru.Gui/Models/SubdirectoryModel.cs | 4 +- Aaru.Gui/ResourceHandler.cs | 6 +- Aaru.Gui/ViewLocator.cs | 6 +- Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs | 4 +- .../ViewModels/Dialogs/ConsoleViewModel.cs | 11 +- .../ViewModels/Dialogs/EncodingsViewModel.cs | 7 +- .../ViewModels/Dialogs/LicenseViewModel.cs | 4 +- .../ViewModels/Dialogs/PluginsViewModel.cs | 4 +- .../ViewModels/Dialogs/SettingsViewModel.cs | 45 +- .../ViewModels/Dialogs/StatisticsViewModel.cs | 35 +- .../ViewModels/Panels/DeviceInfoViewModel.cs | 31 +- .../ViewModels/Panels/FileSystemViewModel.cs | 4 +- .../ViewModels/Panels/ImageInfoViewModel.cs | 27 +- .../ViewModels/Panels/MediaInfoViewModel.cs | 32 +- .../ViewModels/Panels/PartitionViewModel.cs | 4 +- .../Panels/SubdirectoryViewModel.cs | 21 +- Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs | 14 +- .../ViewModels/Tabs/BlurayInfoViewModel.cs | 7 +- .../Tabs/CompactDiscInfoViewModel.cs | 10 +- Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs | 9 +- .../Tabs/DvdWritableInfoViewModel.cs | 11 +- .../ViewModels/Tabs/PcmciaInfoViewModel.cs | 4 +- Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs | 52 +- .../ViewModels/Tabs/SdMmcInfoViewModel.cs | 23 +- Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs | 4 +- Aaru.Gui/ViewModels/ViewModelBase.cs | 4 +- .../Windows/DecodeMediaTagsViewModel.cs | 4 +- .../Windows/ImageChecksumViewModel.cs | 15 +- .../Windows/ImageConvertViewModel.cs | 61 +- .../Windows/ImageEntropyViewModel.cs | 61 +- .../Windows/ImageSidecarViewModel.cs | 34 +- .../Windows/ImageVerifyViewModel.cs | 15 +- .../ViewModels/Windows/MainWindowViewModel.cs | 54 +- .../ViewModels/Windows/MediaDumpViewModel.cs | 48 +- .../ViewModels/Windows/MediaScanViewModel.cs | 24 +- .../Windows/SplashWindowViewModel.cs | 38 +- .../ViewModels/Windows/ViewSectorViewModel.cs | 4 +- Aaru.Gui/Views/Dialogs/About.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/Console.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/Encodings.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs | 4 +- Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs | 4 +- .../Views/Dialogs/StatisticsDialog.xaml.cs | 4 +- Aaru.Gui/Views/Panels/DeviceInfo.xaml.cs | 4 +- Aaru.Gui/Views/Panels/FileSystem.xaml.cs | 4 +- Aaru.Gui/Views/Panels/ImageInfo.xaml.cs | 4 +- Aaru.Gui/Views/Panels/MediaInfo.xaml.cs | 4 +- Aaru.Gui/Views/Panels/Partition.xaml.cs | 4 +- Aaru.Gui/Views/Panels/Subdirectory.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/AtaInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/BlurayInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/DvdInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/PcmciaInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/ScsiInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/SdMmcInfo.xaml.cs | 4 +- Aaru.Gui/Views/Tabs/XboxInfo.xaml.cs | 4 +- .../Views/Windows/DecodeMediaTags.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageConvert.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ImageVerify.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MainWindow.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MediaDump.xaml.cs | 4 +- Aaru.Gui/Views/Windows/MediaScan.xaml.cs | 4 +- Aaru.Gui/Views/Windows/SplashWindow.xaml.cs | 4 +- Aaru.Gui/Views/Windows/ViewSector.xaml.cs | 4 +- Aaru.Helpers | 2 +- Aaru.Images/AaruFormat/AaruFormat.cs | 4 +- Aaru.Images/AaruFormat/CdEcc.cs | 35 +- .../AaruFormat/ClauniaSubchannelTransform.cs | 48 +- Aaru.Images/AaruFormat/Enums.cs | 14 +- Aaru.Images/AaruFormat/Helpers.cs | 15 +- Aaru.Images/AaruFormat/Identify.cs | 4 +- Aaru.Images/AaruFormat/Properties.cs | 12 +- Aaru.Images/AaruFormat/Read.cs | 201 +- Aaru.Images/AaruFormat/Structs.cs | 4 +- Aaru.Images/AaruFormat/Tape.cs | 4 +- Aaru.Images/AaruFormat/Verify.cs | 33 +- Aaru.Images/Alcohol120/Alcohol120.cs | 4 +- Aaru.Images/Alcohol120/Enums.cs | 29 +- Aaru.Images/Alcohol120/Helpers.cs | 4 +- Aaru.Images/Alcohol120/Identify.cs | 6 +- Aaru.Images/Alcohol120/Properties.cs | 35 +- Aaru.Images/Alcohol120/Read.cs | 131 +- Aaru.Images/Alcohol120/Structs.cs | 4 +- Aaru.Images/Alcohol120/Verify.cs | 16 +- Aaru.Images/Alcohol120/Write.cs | 70 +- Aaru.Images/Anex86/Anex86.cs | 4 +- Aaru.Images/Anex86/Identify.cs | 6 +- Aaru.Images/Anex86/Properties.cs | 13 +- Aaru.Images/Anex86/Read.cs | 11 +- Aaru.Images/Anex86/Structs.cs | 4 +- Aaru.Images/Anex86/Unsupported.cs | 4 +- Aaru.Images/Anex86/Write.cs | 10 +- Aaru.Images/Apple2MG/Apple2MG.cs | 4 +- Aaru.Images/Apple2MG/Constants.cs | 4 +- Aaru.Images/Apple2MG/Enums.cs | 4 +- Aaru.Images/Apple2MG/Helpers.cs | 4 +- Aaru.Images/Apple2MG/Identify.cs | 6 +- Aaru.Images/Apple2MG/Properties.cs | 6 +- Aaru.Images/Apple2MG/Read.cs | 38 +- Aaru.Images/Apple2MG/Structs.cs | 4 +- Aaru.Images/Apple2MG/Unsupported.cs | 4 +- Aaru.Images/Apple2MG/Write.cs | 20 +- Aaru.Images/AppleDOS/AppleDOS.cs | 4 +- Aaru.Images/AppleDOS/Identify.cs | 4 +- Aaru.Images/AppleDOS/Properties.cs | 6 +- Aaru.Images/AppleDOS/Read.cs | 16 +- Aaru.Images/AppleDOS/Unsupported.cs | 4 +- Aaru.Images/AppleDOS/Write.cs | 20 +- Aaru.Images/AppleNIB/AppleNIB.cs | 4 +- Aaru.Images/AppleNIB/Constants.cs | 4 +- Aaru.Images/AppleNIB/Identify.cs | 6 +- Aaru.Images/AppleNIB/Properties.cs | 6 +- Aaru.Images/AppleNIB/Read.cs | 28 +- Aaru.Images/AppleNIB/Unsupported.cs | 4 +- Aaru.Images/Apridisk/Apridisk.cs | 4 +- Aaru.Images/Apridisk/Compression.cs | 10 +- Aaru.Images/Apridisk/Enums.cs | 7 +- Aaru.Images/Apridisk/Helpers.cs | 6 +- Aaru.Images/Apridisk/Identify.cs | 6 +- Aaru.Images/Apridisk/Properties.cs | 16 +- Aaru.Images/Apridisk/Read.cs | 26 +- Aaru.Images/Apridisk/Structs.cs | 4 +- Aaru.Images/Apridisk/Unsupported.cs | 4 +- Aaru.Images/Apridisk/Write.cs | 6 +- Aaru.Images/BLU/BLU.cs | 4 +- Aaru.Images/BLU/Identify.cs | 8 +- Aaru.Images/BLU/Properties.cs | 6 +- Aaru.Images/BLU/Read.cs | 35 +- Aaru.Images/BLU/Unsupported.cs | 4 +- Aaru.Images/BLU/Verify.cs | 4 +- Aaru.Images/BLU/Write.cs | 28 +- Aaru.Images/BlindWrite4/BlindWrite4.cs | 4 +- Aaru.Images/BlindWrite4/Constants.cs | 3 +- Aaru.Images/BlindWrite4/Enums.cs | 4 +- Aaru.Images/BlindWrite4/Identify.cs | 6 +- Aaru.Images/BlindWrite4/Properties.cs | 6 +- Aaru.Images/BlindWrite4/Read.cs | 138 +- Aaru.Images/BlindWrite4/Structs.cs | 4 +- Aaru.Images/BlindWrite4/Verify.cs | 16 +- Aaru.Images/BlindWrite5/BlindWrite5.cs | 4 +- Aaru.Images/BlindWrite5/Enums.cs | 16 +- Aaru.Images/BlindWrite5/Helpers.cs | 4 +- Aaru.Images/BlindWrite5/Identify.cs | 8 +- Aaru.Images/BlindWrite5/Properties.cs | 6 +- Aaru.Images/BlindWrite5/Read.cs | 224 +- Aaru.Images/BlindWrite5/Structs.cs | 4 +- Aaru.Images/BlindWrite5/Verify.cs | 16 +- Aaru.Images/ByteAddressable/AtariLynx.cs | 23 +- Aaru.Images/ByteAddressable/GameBoy.cs | 143 +- Aaru.Images/ByteAddressable/GameBoyAdvance.cs | 18 +- Aaru.Images/ByteAddressable/MasterSystem.cs | 48 +- Aaru.Images/ByteAddressable/NES.cs | 54 +- Aaru.Images/ByteAddressable/Nintendo64.cs | 78 +- Aaru.Images/ByteAddressable/SegaMegaDrive.cs | 74 +- Aaru.Images/ByteAddressable/SuperNintendo.cs | 114 +- Aaru.Images/CDRDAO/CDRDAO.cs | 4 +- Aaru.Images/CDRDAO/Helpers.cs | 4 +- Aaru.Images/CDRDAO/Identify.cs | 10 +- Aaru.Images/CDRDAO/Properties.cs | 25 +- Aaru.Images/CDRDAO/Read.cs | 128 +- Aaru.Images/CDRDAO/Structs.cs | 4 +- Aaru.Images/CDRDAO/Verify.cs | 16 +- Aaru.Images/CDRDAO/Write.cs | 57 +- Aaru.Images/CDRWin/CDRWin.cs | 4 +- Aaru.Images/CDRWin/Helpers.cs | 12 +- Aaru.Images/CDRWin/Identify.cs | 10 +- Aaru.Images/CDRWin/Properties.cs | 42 +- Aaru.Images/CDRWin/Read.cs | 232 +- Aaru.Images/CDRWin/Structs.cs | 10 +- Aaru.Images/CDRWin/Verify.cs | 23 +- Aaru.Images/CDRWin/Write.cs | 52 +- Aaru.Images/CHD/CHD.cs | 4 +- Aaru.Images/CHD/Constants.cs | 4 +- Aaru.Images/CHD/Enums.cs | 28 +- Aaru.Images/CHD/Helpers.cs | 17 +- Aaru.Images/CHD/Identify.cs | 6 +- Aaru.Images/CHD/Properties.cs | 4 +- Aaru.Images/CHD/Read.cs | 154 +- Aaru.Images/CHD/Structs.cs | 4 +- Aaru.Images/CHD/Verify.cs | 16 +- Aaru.Images/CPCDSK/CPCDSK.cs | 4 +- Aaru.Images/CPCDSK/Helpers.cs | 4 +- Aaru.Images/CPCDSK/Identify.cs | 8 +- Aaru.Images/CPCDSK/Properties.cs | 6 +- Aaru.Images/CPCDSK/Read.cs | 70 +- Aaru.Images/CPCDSK/Structs.cs | 4 +- Aaru.Images/CPCDSK/Unsupported.cs | 4 +- Aaru.Images/CisCopy/CisCopy.cs | 4 +- Aaru.Images/CisCopy/Enums.cs | 20 +- Aaru.Images/CisCopy/Identify.cs | 22 +- Aaru.Images/CisCopy/Properties.cs | 6 +- Aaru.Images/CisCopy/Read.cs | 20 +- Aaru.Images/CisCopy/Unsupported.cs | 4 +- Aaru.Images/CisCopy/Write.cs | 8 +- Aaru.Images/CloneCD/CloneCD.cs | 4 +- Aaru.Images/CloneCD/Helpers.cs | 5 +- Aaru.Images/CloneCD/Identify.cs | 10 +- Aaru.Images/CloneCD/Properties.cs | 26 +- Aaru.Images/CloneCD/Read.cs | 116 +- Aaru.Images/CloneCD/Verify.cs | 16 +- Aaru.Images/CloneCD/Write.cs | 36 +- Aaru.Images/CopyQM/Constants.cs | 4 +- Aaru.Images/CopyQM/CopyQM.cs | 4 +- Aaru.Images/CopyQM/Identify.cs | 8 +- Aaru.Images/CopyQM/Properties.cs | 6 +- Aaru.Images/CopyQM/Read.cs | 41 +- Aaru.Images/CopyQM/Structs.cs | 4 +- Aaru.Images/CopyQM/Unsupported.cs | 4 +- Aaru.Images/CopyTape/CopyTape.cs | 4 +- Aaru.Images/CopyTape/Identify.cs | 6 +- Aaru.Images/CopyTape/Properties.cs | 51 +- Aaru.Images/CopyTape/Read.cs | 20 +- Aaru.Images/CopyTape/Unsupported.cs | 4 +- Aaru.Images/CopyTape/Write.cs | 4 +- Aaru.Images/D88/Constants.cs | 4 +- Aaru.Images/D88/D88.cs | 4 +- Aaru.Images/D88/Enums.cs | 11 +- Aaru.Images/D88/Identify.cs | 14 +- Aaru.Images/D88/Properties.cs | 6 +- Aaru.Images/D88/Read.cs | 23 +- Aaru.Images/D88/Structs.cs | 4 +- Aaru.Images/D88/Unsupported.cs | 4 +- Aaru.Images/DART/Constants.cs | 6 +- Aaru.Images/DART/DART.cs | 4 +- Aaru.Images/DART/Identify.cs | 8 +- Aaru.Images/DART/Properties.cs | 6 +- Aaru.Images/DART/Read.cs | 22 +- Aaru.Images/DART/Structs.cs | 4 +- Aaru.Images/DART/Unsupported.cs | 4 +- Aaru.Images/DIM/DIM.cs | 4 +- Aaru.Images/DIM/Enums.cs | 8 +- Aaru.Images/DIM/Identify.cs | 4 +- Aaru.Images/DIM/Properties.cs | 4 +- Aaru.Images/DIM/Read.cs | 21 +- Aaru.Images/DIM/Unsupported.cs | 4 +- Aaru.Images/DiscFerret/DiscFerret.cs | 4 +- Aaru.Images/DiscFerret/Identify.cs | 8 +- Aaru.Images/DiscFerret/Properties.cs | 6 +- Aaru.Images/DiscFerret/Read.cs | 19 +- Aaru.Images/DiscFerret/Structs.cs | 4 +- Aaru.Images/DiscFerret/Verify.cs | 4 +- Aaru.Images/DiscJuggler/DiscJuggler.cs | 4 +- Aaru.Images/DiscJuggler/Helpers.cs | 4 +- Aaru.Images/DiscJuggler/Identify.cs | 10 +- Aaru.Images/DiscJuggler/Properties.cs | 6 +- Aaru.Images/DiscJuggler/Read.cs | 108 +- Aaru.Images/DiscJuggler/Verify.cs | 16 +- Aaru.Images/DiskCopy42/DiskCopy42.cs | 4 +- Aaru.Images/DiskCopy42/Identify.cs | 14 +- Aaru.Images/DiskCopy42/Properties.cs | 6 +- Aaru.Images/DiskCopy42/Read.cs | 45 +- Aaru.Images/DiskCopy42/Unsupported.cs | 4 +- Aaru.Images/DiskCopy42/Verify.cs | 10 +- Aaru.Images/DiskCopy42/Write.cs | 26 +- Aaru.Images/DiskDupe/DiskDupe.cs | 10 +- Aaru.Images/DiskDupe/Helpers.cs | 8 +- Aaru.Images/DiskDupe/Identify.cs | 4 +- Aaru.Images/DiskDupe/Properties.cs | 6 +- Aaru.Images/DiskDupe/Read.cs | 10 +- Aaru.Images/DiskDupe/Structs.cs | 14 +- Aaru.Images/DiskDupe/Unsupported.cs | 4 +- Aaru.Images/DriDiskCopy/DriDiskCopy.cs | 4 +- Aaru.Images/DriDiskCopy/Enums.cs | 4 +- Aaru.Images/DriDiskCopy/Identify.cs | 14 +- Aaru.Images/DriDiskCopy/Properties.cs | 16 +- Aaru.Images/DriDiskCopy/Read.cs | 15 +- Aaru.Images/DriDiskCopy/Structs.cs | 4 +- Aaru.Images/DriDiskCopy/Unsupported.cs | 4 +- Aaru.Images/DriDiskCopy/Write.cs | 10 +- Aaru.Images/GDI/GDI.cs | 4 +- Aaru.Images/GDI/Identify.cs | 16 +- Aaru.Images/GDI/Properties.cs | 4 +- Aaru.Images/GDI/Read.cs | 69 +- Aaru.Images/GDI/Structs.cs | 4 +- Aaru.Images/GDI/Unsupported.cs | 4 +- Aaru.Images/GDI/Verify.cs | 16 +- Aaru.Images/HDCopy/HDCopy.cs | 14 +- Aaru.Images/HDCopy/Helpers.cs | 30 +- Aaru.Images/HDCopy/Identify.cs | 4 +- Aaru.Images/HDCopy/Properties.cs | 6 +- Aaru.Images/HDCopy/Read.cs | 24 +- Aaru.Images/HDCopy/Structs.cs | 4 +- Aaru.Images/HDCopy/Unsupported.cs | 4 +- Aaru.Images/IMD/Constants.cs | 4 +- Aaru.Images/IMD/Enums.cs | 12 +- Aaru.Images/IMD/IMD.cs | 4 +- Aaru.Images/IMD/Identify.cs | 6 +- Aaru.Images/IMD/Properties.cs | 6 +- Aaru.Images/IMD/Read.cs | 41 +- Aaru.Images/IMD/Unsupported.cs | 4 +- Aaru.Images/KryoFlux/Constants.cs | 4 +- Aaru.Images/KryoFlux/Enums.cs | 31 +- Aaru.Images/KryoFlux/Identify.cs | 6 +- Aaru.Images/KryoFlux/KryoFlux.cs | 4 +- Aaru.Images/KryoFlux/Properties.cs | 6 +- Aaru.Images/KryoFlux/Read.cs | 19 +- Aaru.Images/KryoFlux/Structs.cs | 4 +- Aaru.Images/KryoFlux/Verify.cs | 4 +- Aaru.Images/MaxiDisk/Enums.cs | 20 +- Aaru.Images/MaxiDisk/Identify.cs | 13 +- Aaru.Images/MaxiDisk/MaxiDisk.cs | 4 +- Aaru.Images/MaxiDisk/Properties.cs | 6 +- Aaru.Images/MaxiDisk/Read.cs | 15 +- Aaru.Images/MaxiDisk/Structs.cs | 4 +- Aaru.Images/MaxiDisk/Unsupported.cs | 4 +- Aaru.Images/MaxiDisk/Write.cs | 10 +- Aaru.Images/NDIF/Constants.cs | 4 +- Aaru.Images/NDIF/Identify.cs | 6 +- Aaru.Images/NDIF/NDIF.cs | 4 +- Aaru.Images/NDIF/Properties.cs | 6 +- Aaru.Images/NDIF/Read.cs | 38 +- Aaru.Images/NDIF/Structs.cs | 4 +- Aaru.Images/NDIF/Unsupported.cs | 4 +- Aaru.Images/NHDr0/Identify.cs | 6 +- Aaru.Images/NHDr0/NHDr0.cs | 4 +- Aaru.Images/NHDr0/Properties.cs | 6 +- Aaru.Images/NHDr0/Read.cs | 11 +- Aaru.Images/NHDr0/Structs.cs | 4 +- Aaru.Images/NHDr0/Unsupported.cs | 4 +- Aaru.Images/NHDr0/Write.cs | 10 +- Aaru.Images/Nero/Enums.cs | 16 +- Aaru.Images/Nero/Helpers.cs | 4 +- Aaru.Images/Nero/Identify.cs | 6 +- Aaru.Images/Nero/Nero.cs | 13 +- Aaru.Images/Nero/Properties.cs | 6 +- Aaru.Images/Nero/Read.cs | 350 +- Aaru.Images/Nero/Structs.cs | 6 +- Aaru.Images/Nero/Verify.cs | 16 +- Aaru.Images/Parallels/Constants.cs | 4 +- Aaru.Images/Parallels/Identify.cs | 6 +- Aaru.Images/Parallels/Parallels.cs | 10 +- Aaru.Images/Parallels/Properties.cs | 6 +- Aaru.Images/Parallels/Read.cs | 14 +- Aaru.Images/Parallels/Structs.cs | 4 +- Aaru.Images/Parallels/Unsupported.cs | 4 +- Aaru.Images/Parallels/Write.cs | 14 +- Aaru.Images/PartClone/Identify.cs | 8 +- Aaru.Images/PartClone/PartClone.cs | 4 +- Aaru.Images/PartClone/Properties.cs | 6 +- Aaru.Images/PartClone/Read.cs | 16 +- Aaru.Images/PartClone/Structs.cs | 4 +- Aaru.Images/PartClone/Unsupported.cs | 4 +- Aaru.Images/Partimage/Constants.cs | 4 +- Aaru.Images/Partimage/Enums.cs | 10 +- Aaru.Images/Partimage/Identify.cs | 6 +- Aaru.Images/Partimage/Partimage.cs | 8 +- Aaru.Images/Partimage/Properties.cs | 6 +- Aaru.Images/Partimage/Read.cs | 22 +- Aaru.Images/Partimage/Structs.cs | 4 +- Aaru.Images/Partimage/Unsupported.cs | 4 +- Aaru.Images/QCOW/Identify.cs | 6 +- Aaru.Images/QCOW/Properties.cs | 6 +- Aaru.Images/QCOW/QCOW.cs | 4 +- Aaru.Images/QCOW/Read.cs | 20 +- Aaru.Images/QCOW/Structs.cs | 4 +- Aaru.Images/QCOW/Unsupported.cs | 4 +- Aaru.Images/QCOW/Write.cs | 28 +- Aaru.Images/QCOW2/Constants.cs | 4 +- Aaru.Images/QCOW2/Identify.cs | 6 +- Aaru.Images/QCOW2/Properties.cs | 6 +- Aaru.Images/QCOW2/QCOW2.cs | 4 +- Aaru.Images/QCOW2/Read.cs | 25 +- Aaru.Images/QCOW2/Structs.cs | 4 +- Aaru.Images/QCOW2/Unsupported.cs | 4 +- Aaru.Images/QCOW2/Write.cs | 30 +- Aaru.Images/QED/Constants.cs | 4 +- Aaru.Images/QED/Helpers.cs | 2 +- Aaru.Images/QED/Identify.cs | 6 +- Aaru.Images/QED/Properties.cs | 6 +- Aaru.Images/QED/QED.cs | 4 +- Aaru.Images/QED/Read.cs | 63 +- Aaru.Images/QED/Structs.cs | 4 +- Aaru.Images/QED/Unsupported.cs | 4 +- Aaru.Images/QED/Write.cs | 28 +- Aaru.Images/RayDIM/Enums.cs | 11 +- Aaru.Images/RayDIM/Identify.cs | 12 +- Aaru.Images/RayDIM/Properties.cs | 6 +- Aaru.Images/RayDIM/RayDIM.cs | 4 +- Aaru.Images/RayDIM/Read.cs | 13 +- Aaru.Images/RayDIM/Structs.cs | 4 +- Aaru.Images/RayDIM/Unsupported.cs | 4 +- Aaru.Images/RayDIM/Write.cs | 10 +- Aaru.Images/RsIde/Enums.cs | 4 +- Aaru.Images/RsIde/Helpers.cs | 14 +- Aaru.Images/RsIde/Identify.cs | 6 +- Aaru.Images/RsIde/Properties.cs | 6 +- Aaru.Images/RsIde/Read.cs | 11 +- Aaru.Images/RsIde/RsIde.cs | 4 +- Aaru.Images/RsIde/Structs.cs | 4 +- Aaru.Images/RsIde/Unsupported.cs | 4 +- Aaru.Images/RsIde/Write.cs | 38 +- Aaru.Images/SaveDskF/Identify.cs | 6 +- Aaru.Images/SaveDskF/Properties.cs | 16 +- Aaru.Images/SaveDskF/Read.cs | 19 +- Aaru.Images/SaveDskF/SaveDskF.cs | 4 +- Aaru.Images/SaveDskF/Structs.cs | 4 +- Aaru.Images/SaveDskF/Unsupported.cs | 4 +- Aaru.Images/SaveDskF/Write.cs | 10 +- Aaru.Images/SuperCardPro/Enums.cs | 34 +- Aaru.Images/SuperCardPro/Helpers.cs | 10 +- Aaru.Images/SuperCardPro/Identify.cs | 6 +- Aaru.Images/SuperCardPro/Properties.cs | 6 +- Aaru.Images/SuperCardPro/Read.cs | 24 +- Aaru.Images/SuperCardPro/Structs.cs | 4 +- Aaru.Images/SuperCardPro/SuperCardPro.cs | 4 +- Aaru.Images/SuperCardPro/Verify.cs | 10 +- Aaru.Images/T98/Identify.cs | 12 +- Aaru.Images/T98/Properties.cs | 6 +- Aaru.Images/T98/Read.cs | 17 +- Aaru.Images/T98/T98.cs | 4 +- Aaru.Images/T98/Unsupported.cs | 4 +- Aaru.Images/T98/Write.cs | 10 +- Aaru.Images/TeleDisk/Constants.cs | 4 +- Aaru.Images/TeleDisk/Helpers.cs | 57 +- Aaru.Images/TeleDisk/Identify.cs | 8 +- Aaru.Images/TeleDisk/Properties.cs | 6 +- Aaru.Images/TeleDisk/Read.cs | 90 +- Aaru.Images/TeleDisk/TeleDisk.cs | 4 +- Aaru.Images/TeleDisk/Unsupported.cs | 4 +- Aaru.Images/TeleDisk/Verify.cs | 4 +- Aaru.Images/UDIF/Constants.cs | 4 +- Aaru.Images/UDIF/Identify.cs | 8 +- Aaru.Images/UDIF/Properties.cs | 6 +- Aaru.Images/UDIF/Read.cs | 34 +- Aaru.Images/UDIF/Structs.cs | 4 +- Aaru.Images/UDIF/UDIF.cs | 8 +- Aaru.Images/UDIF/Unsupported.cs | 4 +- Aaru.Images/UDIF/Write.cs | 6 +- Aaru.Images/UkvFdi/Enums.cs | 12 +- Aaru.Images/UkvFdi/Helpers.cs | 6 +- Aaru.Images/UkvFdi/Identify.cs | 6 +- Aaru.Images/UkvFdi/Properties.cs | 6 +- Aaru.Images/UkvFdi/Read.cs | 36 +- Aaru.Images/UkvFdi/Structs.cs | 4 +- Aaru.Images/UkvFdi/UkvFdi.cs | 4 +- Aaru.Images/UkvFdi/Unsupported.cs | 4 +- Aaru.Images/VDI/Enums.cs | 4 +- Aaru.Images/VDI/Identify.cs | 6 +- Aaru.Images/VDI/Properties.cs | 6 +- Aaru.Images/VDI/Read.cs | 12 +- Aaru.Images/VDI/Structs.cs | 4 +- Aaru.Images/VDI/Unsupported.cs | 4 +- Aaru.Images/VDI/VDI.cs | 4 +- Aaru.Images/VDI/Write.cs | 14 +- Aaru.Images/VHD/Constants.cs | 4 +- Aaru.Images/VHD/Helpers.cs | 4 +- Aaru.Images/VHD/Identify.cs | 12 +- Aaru.Images/VHD/Properties.cs | 6 +- Aaru.Images/VHD/Read.cs | 121 +- Aaru.Images/VHD/Structs.cs | 4 +- Aaru.Images/VHD/Unsupported.cs | 4 +- Aaru.Images/VHD/VHD.cs | 4 +- Aaru.Images/VHD/Write.cs | 10 +- Aaru.Images/VHDX/Constants.cs | 22 +- Aaru.Images/VHDX/Helpers.cs | 6 +- Aaru.Images/VHDX/Identify.cs | 6 +- Aaru.Images/VHDX/Properties.cs | 6 +- Aaru.Images/VHDX/Read.cs | 53 +- Aaru.Images/VHDX/Structs.cs | 4 +- Aaru.Images/VHDX/Unsupported.cs | 4 +- Aaru.Images/VHDX/VHDX.cs | 10 +- Aaru.Images/VMware/Constants.cs | 4 +- Aaru.Images/VMware/Identify.cs | 10 +- Aaru.Images/VMware/Properties.cs | 10 +- Aaru.Images/VMware/Read.cs | 47 +- Aaru.Images/VMware/Structs.cs | 4 +- Aaru.Images/VMware/Unsupported.cs | 4 +- Aaru.Images/VMware/VMware.cs | 4 +- Aaru.Images/VMware/Write.cs | 7 +- Aaru.Images/Virtual98/Identify.cs | 6 +- Aaru.Images/Virtual98/Properties.cs | 6 +- Aaru.Images/Virtual98/Read.cs | 14 +- Aaru.Images/Virtual98/Structs.cs | 4 +- Aaru.Images/Virtual98/Unsupported.cs | 4 +- Aaru.Images/Virtual98/Virtual98.cs | 4 +- Aaru.Images/Virtual98/Write.cs | 13 +- Aaru.Images/WCDiskImage/Identify.cs | 6 +- Aaru.Images/WCDiskImage/Properties.cs | 6 +- Aaru.Images/WCDiskImage/Read.cs | 28 +- Aaru.Images/WCDiskImage/Structs.cs | 4 +- Aaru.Images/WCDiskImage/Unsupported.cs | 4 +- Aaru.Images/WCDiskImage/WCDiskImage.cs | 10 +- Aaru.Images/ZZZRawImage/Constants.cs | 4 +- Aaru.Images/ZZZRawImage/Helpers.cs | 4 +- Aaru.Images/ZZZRawImage/Identify.cs | 12 +- Aaru.Images/ZZZRawImage/Properties.cs | 11 +- Aaru.Images/ZZZRawImage/Read.cs | 42 +- Aaru.Images/ZZZRawImage/Verify.cs | 16 +- Aaru.Images/ZZZRawImage/Write.cs | 7 +- Aaru.Images/ZZZRawImage/ZZZRawImage.cs | 4 +- Aaru.Partitions/Aaru.Partitions.csproj | 259 +- Aaru.Partitions/Acorn.cs | 14 +- Aaru.Partitions/AppleMap.cs | 63 +- Aaru.Partitions/Apricot.cs | 34 +- Aaru.Partitions/Atari.cs | 57 +- Aaru.Partitions/BSD.cs | 23 +- Aaru.Partitions/DEC.cs | 7 +- Aaru.Partitions/DragonFlyBSD.cs | 8 +- Aaru.Partitions/GPT.cs | 16 +- Aaru.Partitions/Human68k.cs | 6 +- Aaru.Partitions/MBR.cs | 63 +- Aaru.Partitions/NeXT.cs | 39 +- Aaru.Partitions/PC98.cs | 11 +- Aaru.Partitions/Plan9.cs | 4 +- Aaru.Partitions/RDB.cs | 75 +- Aaru.Partitions/Register.cs | 4 +- Aaru.Partitions/RioKarma.cs | 11 +- Aaru.Partitions/SGI.cs | 57 +- Aaru.Partitions/Sun.cs | 125 +- Aaru.Partitions/UNIX.cs | 236 +- Aaru.Partitions/VTOC.cs | 57 +- Aaru.Partitions/XENIX.cs | 13 +- Aaru.Partitions/Xbox.cs | 11 +- Aaru.Settings/Aaru.Settings.csproj | 202 +- Aaru.Settings/Settings.cs | 34 +- Aaru.Tests.Devices/ATA.cs | 15 +- Aaru.Tests.Devices/ATA/Ata28.cs | 332 +- Aaru.Tests.Devices/ATA/Ata48.cs | 314 +- Aaru.Tests.Devices/ATA/AtaCHS.cs | 360 +- Aaru.Tests.Devices/ATA/Atapi.cs | 52 +- Aaru.Tests.Devices/ATA/Cfa.cs | 134 +- Aaru.Tests.Devices/ATA/MCPT.cs | 43 +- Aaru.Tests.Devices/ATA/Smart.cs | 194 +- Aaru.Tests.Devices/Aaru.Tests.Devices.csproj | 274 +- Aaru.Tests.Devices/Command.cs | 15 +- Aaru.Tests.Devices/DecodeATARegisters.cs | 10 +- Aaru.Tests.Devices/Device.cs | 32 +- Aaru.Tests.Devices/Main.cs | 37 +- Aaru.Tests.Devices/NVMe.cs | 9 +- Aaru.Tests.Devices/SCSI.cs | 15 +- Aaru.Tests.Devices/SCSI/Adaptec.cs | 195 +- Aaru.Tests.Devices/SCSI/ArchiveCorp.cs | 104 +- Aaru.Tests.Devices/SCSI/Certance.cs | 59 +- Aaru.Tests.Devices/SCSI/Fujitsu.cs | 66 +- Aaru.Tests.Devices/SCSI/HL-DT-ST.cs | 65 +- Aaru.Tests.Devices/SCSI/HP.cs | 91 +- Aaru.Tests.Devices/SCSI/Kreon.cs | 132 +- Aaru.Tests.Devices/SCSI/MMC.cs | 620 +- Aaru.Tests.Devices/SCSI/NEC.cs | 65 +- Aaru.Tests.Devices/SCSI/Pioneer.cs | 208 +- Aaru.Tests.Devices/SCSI/Plasmon.cs | 139 +- Aaru.Tests.Devices/SCSI/Plextor.cs | 577 +- Aaru.Tests.Devices/SCSI/SBC.cs | 531 +- Aaru.Tests.Devices/SCSI/SMC.cs | 90 +- Aaru.Tests.Devices/SCSI/SPC.cs | 478 +- Aaru.Tests.Devices/SCSI/SSC.cs | 791 +- Aaru.Tests.Devices/SCSI/SyQuest.cs | 176 +- Aaru.Tests.Devices/SCSI_MMC/GdRom.cs | 191 +- Aaru.Tests.Devices/SCSI_MMC/LeadOutTrap.cs | 181 +- Aaru.Tests.Devices/SCSI_MMC/MediaTek.cs | 59 +- Aaru.Tests.Devices/SCSI_MMC/SCSI_MMC.cs | 15 +- Aaru.Tests.Devices/SecureDigital.cs | 15 +- .../SecureDigital/MultiMediaCard.cs | 274 +- .../SecureDigital/SecureDigital.cs | 274 +- Aaru.Tests/Aaru.Tests.csproj | 48 +- Aaru.Tests/Checksums/Adler32.cs | 44 +- Aaru.Tests/Checksums/CRC16CCITT.cs | 50 +- Aaru.Tests/Checksums/CRC16IBM.cs | 44 +- Aaru.Tests/Checksums/CRC32.cs | 44 +- Aaru.Tests/Checksums/CRC64.cs | 44 +- Aaru.Tests/Checksums/MD5.cs | 20 +- Aaru.Tests/Checksums/SHA1.cs | 20 +- Aaru.Tests/Checksums/SHA256.cs | 20 +- Aaru.Tests/Checksums/SHA384.cs | 20 +- Aaru.Tests/Checksums/SHA512.cs | 20 +- Aaru.Tests/Checksums/SpamSum.cs | 20 +- Aaru.Tests/Consts.cs | 2 +- Aaru.Tests/Devices/IomegaJaz.cs | 8 +- Aaru.Tests/Devices/LS120.cs | 8 +- Aaru.Tests/Devices/MultiMediaCard/CID.cs | 17 +- Aaru.Tests/Devices/MultiMediaCard/CSD.cs | 20 +- .../Devices/MultiMediaCard/ExtendedCSD.cs | 72 +- Aaru.Tests/Devices/PocketZip.cs | 8 +- Aaru.Tests/Devices/SecureDigital/CID.cs | 17 +- Aaru.Tests/Devices/SecureDigital/CSD.cs | 20 +- Aaru.Tests/Devices/SecureDigital/SCR.cs | 18 +- Aaru.Tests/Encoding.cs | 4 +- Aaru.Tests/Filesystems/ADFS.cs | 4 +- Aaru.Tests/Filesystems/AFFS/APM.cs | 4 +- Aaru.Tests/Filesystems/AFFS/MBR+RDB.cs | 4 +- Aaru.Tests/Filesystems/AFFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/AFFS/RDB.cs | 4 +- Aaru.Tests/Filesystems/AFFS/Whole.cs | 7 +- Aaru.Tests/Filesystems/AFFS2/APM.cs | 4 +- Aaru.Tests/Filesystems/AFFS2/RDB.cs | 4 +- Aaru.Tests/Filesystems/AFS/MBR.cs | 11 +- Aaru.Tests/Filesystems/AFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/AOFS/MBR+RDB.cs | 4 +- Aaru.Tests/Filesystems/AOFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/AOFS/RDB.cs | 4 +- Aaru.Tests/Filesystems/AOFS/Whole.cs | 7 +- Aaru.Tests/Filesystems/Atheos.cs | 4 +- Aaru.Tests/Filesystems/BeFS/APM.cs | 12 +- Aaru.Tests/Filesystems/BeFS/GPT.cs | 12 +- Aaru.Tests/Filesystems/BeFS/MBR.cs | 12 +- Aaru.Tests/Filesystems/BeFS/Whole.cs | 7 +- Aaru.Tests/Filesystems/COHERENT/MBR.cs | 4 +- Aaru.Tests/Filesystems/COHERENT/Whole.cs | 4 +- Aaru.Tests/Filesystems/CPM/AMSDOS.cs | 7 +- Aaru.Tests/Filesystems/CPM/AmstradCPM.cs | 7 +- Aaru.Tests/Filesystems/CPM/AmstradCPMPlus.cs | 7 +- Aaru.Tests/Filesystems/CPM/Attache.cs | 10 +- Aaru.Tests/Filesystems/CPM/Bondwell.cs | 7 +- Aaru.Tests/Filesystems/CPM/Excalibur64.cs | 7 +- Aaru.Tests/Filesystems/CPM/KayproII.cs | 7 +- Aaru.Tests/Filesystems/CPM/ParaDOS.cs | 7 +- Aaru.Tests/Filesystems/CPM/Plus3DOS.cs | 7 +- Aaru.Tests/Filesystems/CPM/ROMDOS.cs | 7 +- .../Filesystems/CPM/SharpPersonalCPM.cs | 7 +- Aaru.Tests/Filesystems/CPM/XtalDOS.cs | 7 +- Aaru.Tests/Filesystems/DTFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/DTFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/EAFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/EAFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/F2FS.cs | 4 +- Aaru.Tests/Filesystems/FAT12/APM.cs | 4 +- Aaru.Tests/Filesystems/FAT12/GPT.cs | 4 +- Aaru.Tests/Filesystems/FAT12/Human.cs | 4 +- Aaru.Tests/Filesystems/FAT12/MBR.cs | 4 +- Aaru.Tests/Filesystems/FAT12/Whole.cs | 11273 ++-- Aaru.Tests/Filesystems/FAT16/APM.cs | 4 +- Aaru.Tests/Filesystems/FAT16/Atari.cs | 4 +- Aaru.Tests/Filesystems/FAT16/GPT.cs | 4 +- Aaru.Tests/Filesystems/FAT16/Human.cs | 4 +- Aaru.Tests/Filesystems/FAT16/MBR.cs | 4 +- Aaru.Tests/Filesystems/FAT16/RDB.cs | 4 +- Aaru.Tests/Filesystems/FAT16/Whole.cs | 4 +- Aaru.Tests/Filesystems/FAT32/APM.cs | 4 +- Aaru.Tests/Filesystems/FAT32/GPT.cs | 4 +- Aaru.Tests/Filesystems/FAT32/MBR.cs | 4 +- Aaru.Tests/Filesystems/FAT32/Whole.cs | 4 +- Aaru.Tests/Filesystems/FATX/Xbox.cs | 10 +- Aaru.Tests/Filesystems/FATX/Xbox360.cs | 4 +- Aaru.Tests/Filesystems/FilesystemTest.cs | 22 +- Aaru.Tests/Filesystems/HAMMER.cs | 4 +- Aaru.Tests/Filesystems/HFS+/APM.cs | 10 +- Aaru.Tests/Filesystems/HFS+/GPT.cs | 10 +- Aaru.Tests/Filesystems/HFS+/MBR.cs | 10 +- Aaru.Tests/Filesystems/HFS/APM.cs | 4 +- Aaru.Tests/Filesystems/HFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/HFS/Optical.cs | 4 +- Aaru.Tests/Filesystems/HFS/RDB.cs | 4 +- Aaru.Tests/Filesystems/HFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/HFSX/APM.cs | 4 +- Aaru.Tests/Filesystems/HFSX/GPT.cs | 4 +- Aaru.Tests/Filesystems/HFSX/MBR.cs | 4 +- Aaru.Tests/Filesystems/HPFS.cs | 4 +- Aaru.Tests/Filesystems/HPOFS.cs | 4 +- Aaru.Tests/Filesystems/HTFS/MBR.cs | 4 +- Aaru.Tests/Filesystems/HTFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/ISO9660.cs | 4 +- Aaru.Tests/Filesystems/JFS2.cs | 4 +- Aaru.Tests/Filesystems/LisaFS.cs | 11 +- Aaru.Tests/Filesystems/Locus.cs | 4 +- Aaru.Tests/Filesystems/MFS.cs | 11 +- Aaru.Tests/Filesystems/MINIX/V1/MBR.cs | 4 +- Aaru.Tests/Filesystems/MINIX/V1/Whole.cs | 4 +- Aaru.Tests/Filesystems/MINIX/V2/MBR.cs | 4 +- Aaru.Tests/Filesystems/MINIX/V2/Whole.cs | 4 +- Aaru.Tests/Filesystems/MINIX/V3/MBR.cs | 4 +- Aaru.Tests/Filesystems/MINIX/V3/Whole.cs | 4 +- Aaru.Tests/Filesystems/NILFS2.cs | 4 +- Aaru.Tests/Filesystems/NTFS/GPT.cs | 7 +- Aaru.Tests/Filesystems/NTFS/MBR.cs | 7 +- Aaru.Tests/Filesystems/PFS3/APM.cs | 4 +- Aaru.Tests/Filesystems/PFS3/RDB.cs | 4 +- Aaru.Tests/Filesystems/ProDOS/APM.cs | 7 +- Aaru.Tests/Filesystems/QNX4/MBR.cs | 12 +- Aaru.Tests/Filesystems/QNX4/Whole.cs | 7 +- Aaru.Tests/Filesystems/ReFS.cs | 4 +- .../Filesystems/ReadOnlyFilesystemTest.cs | 42 +- Aaru.Tests/Filesystems/Reiser3.cs | 11 +- Aaru.Tests/Filesystems/Reiser4.cs | 11 +- Aaru.Tests/Filesystems/SFS/APM.cs | 10 +- Aaru.Tests/Filesystems/SFS/MBR+RDB.cs | 7 +- Aaru.Tests/Filesystems/SFS/MBR.cs | 12 +- Aaru.Tests/Filesystems/SFS/RDB.cs | 10 +- Aaru.Tests/Filesystems/SysV/MBR.cs | 4 +- Aaru.Tests/Filesystems/SysV/RDB.cs | 4 +- Aaru.Tests/Filesystems/SysV/Whole.cs | 4 +- Aaru.Tests/Filesystems/UDF/1.02/Whole.cs | 7 +- Aaru.Tests/Filesystems/UDF/1.50/Optical.cs | 7 +- Aaru.Tests/Filesystems/UDF/1.50/Whole.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.00/Optical.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.00/Whole.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.01/Optical.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.01/Whole.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.50/Whole.cs | 7 +- Aaru.Tests/Filesystems/UDF/2.60/Whole.cs | 13 +- Aaru.Tests/Filesystems/UFS/APM.cs | 11 +- Aaru.Tests/Filesystems/UFS/MBR.cs | 11 +- Aaru.Tests/Filesystems/UFS/NeXT Floppy.cs | 11 +- Aaru.Tests/Filesystems/UFS/NeXT.cs | 11 +- Aaru.Tests/Filesystems/UFS/RDB.cs | 11 +- Aaru.Tests/Filesystems/UFS/Sun i86.cs | 4 +- Aaru.Tests/Filesystems/UFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/UNIXBFS/MBR.cs | 11 +- Aaru.Tests/Filesystems/UNIXBFS/RDB.cs | 11 +- Aaru.Tests/Filesystems/UNIXBFS/Whole.cs | 4 +- Aaru.Tests/Filesystems/XENIX/MBR.cs | 11 +- Aaru.Tests/Filesystems/XENIX/Whole.cs | 4 +- Aaru.Tests/Filesystems/XFS.cs | 4 +- Aaru.Tests/Filesystems/Xia.cs | 4 +- Aaru.Tests/Filesystems/ZFS.cs | 7 +- Aaru.Tests/Filesystems/btrfs.cs | 4 +- Aaru.Tests/Filesystems/exFAT/APM.cs | 7 +- Aaru.Tests/Filesystems/exFAT/GPT.cs | 7 +- Aaru.Tests/Filesystems/exFAT/MBR.cs | 7 +- Aaru.Tests/Filesystems/ext.cs | 4 +- Aaru.Tests/Filesystems/ext2.cs | 4 +- Aaru.Tests/Filters/AppleDoubleDave.cs | 9 +- Aaru.Tests/Filters/AppleDoubleDos.cs | 9 +- Aaru.Tests/Filters/AppleDoubleNetatalk.cs | 9 +- Aaru.Tests/Filters/AppleDoubleOsX.cs | 9 +- Aaru.Tests/Filters/AppleDoubleProDos.cs | 9 +- Aaru.Tests/Filters/AppleDoubleUnAr.cs | 9 +- Aaru.Tests/Filters/AppleDoubleUnix.cs | 9 +- Aaru.Tests/Filters/AppleSingle.cs | 12 +- Aaru.Tests/Filters/BZip2.cs | 7 +- Aaru.Tests/Filters/GZip.cs | 7 +- Aaru.Tests/Filters/LZip.cs | 7 +- Aaru.Tests/Filters/MacBinary1.cs | 12 +- Aaru.Tests/Filters/MacBinary2.cs | 12 +- Aaru.Tests/Filters/MacBinary3.cs | 12 +- Aaru.Tests/Filters/PCExchange.cs | 13 +- Aaru.Tests/Filters/XZ.cs | 7 +- Aaru.Tests/Helpers/Marshal.cs | 6 +- Aaru.Tests/Images/2MG.cs | 4 +- Aaru.Tests/Images/AaruFormat/Tape/V1.cs | 7 +- Aaru.Tests/Images/AaruFormat/V1.cs | 7 +- Aaru.Tests/Images/Alcohol120.cs | 7 +- Aaru.Tests/Images/Anex86.cs | 4 +- Aaru.Tests/Images/AppleDOS/DOS.cs | 7 +- Aaru.Tests/Images/AppleDOS/DOS32.cs | 4 +- Aaru.Tests/Images/AppleDOS/ProDOS.cs | 4 +- Aaru.Tests/Images/AppleNIB.cs | 4 +- Aaru.Tests/Images/Apridisk.cs | 4 +- Aaru.Tests/Images/BaseMediaImageTest.cs | 4 +- Aaru.Tests/Images/BlindWrite4.cs | 7 +- Aaru.Tests/Images/BlindWrite5.cs | 7 +- Aaru.Tests/Images/BlindWrite6.cs | 7 +- Aaru.Tests/Images/BlindWrite7.cs | 7 +- Aaru.Tests/Images/BlockMediaImageTest.cs | 36 +- Aaru.Tests/Images/CDRWin.cs | 4 +- Aaru.Tests/Images/CDRWin10.cs | 4 +- Aaru.Tests/Images/CPCDSK.cs | 4 +- Aaru.Tests/Images/CisCopy/Uncompressed.cs | 7 +- Aaru.Tests/Images/CloneCD.cs | 4 +- Aaru.Tests/Images/Commodore64/D64.cs | 7 +- Aaru.Tests/Images/Commodore64/D81.cs | 7 +- Aaru.Tests/Images/CopyQM.cs | 4 +- Aaru.Tests/Images/CopyTape.cs | 4 +- Aaru.Tests/Images/D88.cs | 4 +- Aaru.Tests/Images/DART.cs | 4 +- Aaru.Tests/Images/DiscJuggler.cs | 4 +- Aaru.Tests/Images/DiskCopy42.cs | 7 +- Aaru.Tests/Images/DiskCopy633/DiskCopy42.cs | 4 +- Aaru.Tests/Images/DiskCopy633/NDIF/ROCo.cs | 4 +- Aaru.Tests/Images/DiskCopy633/NDIF/RdWr.cs | 4 +- Aaru.Tests/Images/DiskCopy633/NDIF/Rdxx.cs | 4 +- Aaru.Tests/Images/DiskCopy65/UDCO.cs | 4 +- Aaru.Tests/Images/DiskCopy65/UDCo_obsolete.cs | 4 +- Aaru.Tests/Images/DiskCopy65/UDRAW.cs | 4 +- Aaru.Tests/Images/DiskCopy65/UDRO.cs | 4 +- Aaru.Tests/Images/DiskCopy65/UDRo_obsolete.cs | 4 +- Aaru.Tests/Images/DiskDupe.cs | 4 +- .../Images/DiskImagesFramework/DiskCopy42.cs | 4 +- .../Images/DiskImagesFramework/NDIF/ROCo.cs | 4 +- .../Images/DiskImagesFramework/NDIF/RdWr.cs | 4 +- .../Images/DiskImagesFramework/NDIF/Rdxx.cs | 4 +- .../Images/DiskImagesFramework/UDIF/IPOD.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDBZ.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDCO.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDRO.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDRW.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDTO.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UDZO.cs | 4 +- .../Images/DiskImagesFramework/UDIF/UFBI.cs | 4 +- .../Images/DiskImagesFramework/UDIF/ULMO.cs | 4 +- Aaru.Tests/Images/DiskUtilities/ImageDisk.cs | 4 +- Aaru.Tests/Images/DiskUtilities/Raw.cs | 4 +- Aaru.Tests/Images/DriDiskCopy.cs | 7 +- Aaru.Tests/Images/GameJack6.cs | 4 +- Aaru.Tests/Images/HDCopy.cs | 4 +- Aaru.Tests/Images/HxC/ImageDisk.cs | 4 +- Aaru.Tests/Images/HxC/Raw.cs | 4 +- Aaru.Tests/Images/HyperV.cs | 4 +- Aaru.Tests/Images/ImageDisk.cs | 4 +- Aaru.Tests/Images/IsoBuster/Cuesheet.cs | 4 +- Aaru.Tests/Images/KryoFlux/Raw.cs | 7 +- Aaru.Tests/Images/Lisa/Raw.cs | 4 +- Aaru.Tests/Images/MAME/v1.cs | 4 +- Aaru.Tests/Images/MAME/v3.cs | 4 +- Aaru.Tests/Images/MAME/v4.cs | 4 +- Aaru.Tests/Images/MAME/v5/compressed.cs | 4 +- Aaru.Tests/Images/MAME/v5/uncompressed.cs | 4 +- Aaru.Tests/Images/MagicISO/Cuesheet.cs | 4 +- Aaru.Tests/Images/MagicISO/Nero.cs | 4 +- Aaru.Tests/Images/MaxiDisk.cs | 4 +- Aaru.Tests/Images/NHDr0.cs | 4 +- Aaru.Tests/Images/Nero/V1.cs | 7 +- Aaru.Tests/Images/Nero/V2.cs | 7 +- Aaru.Tests/Images/OpticalMediaImageTest.cs | 49 +- Aaru.Tests/Images/PowerISO/Cuesheet.cs | 4 +- Aaru.Tests/Images/QEMU/HyperV.cs | 7 +- Aaru.Tests/Images/QEMU/Parallels.cs | 4 +- Aaru.Tests/Images/QEMU/QCOW.cs | 4 +- Aaru.Tests/Images/QEMU/QCOW2.cs | 4 +- Aaru.Tests/Images/QEMU/QCOW3.cs | 4 +- Aaru.Tests/Images/QEMU/QED.cs | 4 +- Aaru.Tests/Images/QEMU/Raw.cs | 4 +- Aaru.Tests/Images/QEMU/VMware5.cs | 4 +- Aaru.Tests/Images/QEMU/VMware6.cs | 4 +- Aaru.Tests/Images/QEMU/VirtualBox.cs | 4 +- Aaru.Tests/Images/QEMU/VirtualPC.cs | 4 +- Aaru.Tests/Images/RayDIM.cs | 4 +- Aaru.Tests/Images/RsIde.cs | 4 +- Aaru.Tests/Images/SaveDskF.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/DiskCopy42.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/DiskDup.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/NDIF/ROCo.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/NDIF/RdWr.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/NDIF/Rdxx.cs | 4 +- Aaru.Tests/Images/ShrinkWrap/Raw.cs | 4 +- Aaru.Tests/Images/TapeMediaImageTest.cs | 14 +- Aaru.Tests/Images/TeleDisk.cs | 4 +- Aaru.Tests/Images/Toast.cs | 4 +- Aaru.Tests/Images/UltraISO/Alcohol.cs | 7 +- Aaru.Tests/Images/UltraISO/CloneCD.cs | 4 +- Aaru.Tests/Images/UltraISO/Cuesheet.cs | 4 +- Aaru.Tests/Images/UltraISO/Nero.cs | 4 +- Aaru.Tests/Images/Virtual98.cs | 4 +- Aaru.Tests/Images/VirtualBox/VirtualPC.cs | 4 +- Aaru.Tests/Images/VirtualPC/Raw.cs | 4 +- Aaru.Tests/Images/VirtualPC/VirtualPC.cs | 4 +- Aaru.Tests/Images/cdrdao/cooked/nosub.cs | 4 +- Aaru.Tests/Images/cdrdao/cooked/rw.cs | 4 +- Aaru.Tests/Images/cdrdao/cooked/rw_raw.cs | 4 +- Aaru.Tests/Images/cdrdao/raw/nosub.cs | 4 +- Aaru.Tests/Images/cdrdao/raw/rw.cs | 4 +- Aaru.Tests/Images/cdrdao/raw/rw_raw.cs | 4 +- Aaru.Tests/Images/partclone.cs | 4 +- Aaru.Tests/Images/pce/DiskCopy42.cs | 4 +- Aaru.Tests/Images/pce/ImageDisk.cs | 4 +- Aaru.Tests/Images/pce/TeleDisk.cs | 7 +- Aaru.Tests/Images/pce/XDF.cs | 4 +- Aaru.Tests/Images/pce/raw.cs | 4 +- Aaru.Tests/Issues/176.cs | 3 +- Aaru.Tests/Issues/257.cs | 5 +- Aaru.Tests/Issues/263/AaruFormat.cs | 5 +- Aaru.Tests/Issues/263/Raw.cs | 5 +- Aaru.Tests/Issues/266.cs | 9 +- Aaru.Tests/Issues/286.cs | 5 +- Aaru.Tests/Issues/288/18Wheeler.cs | 5 +- Aaru.Tests/Issues/288/ArcadeHits.cs | 5 +- Aaru.Tests/Issues/288/Roadsters.cs | 5 +- Aaru.Tests/Issues/299.cs | 5 +- Aaru.Tests/Issues/300.cs | 9 +- Aaru.Tests/Issues/325.cs | 3 +- Aaru.Tests/Issues/338.cs | 3 +- Aaru.Tests/Issues/358.cs | 9 +- Aaru.Tests/Issues/360.cs | 5 +- Aaru.Tests/Issues/379.cs | 5 +- Aaru.Tests/Issues/398.cs | 5 +- Aaru.Tests/Issues/410.cs | 5 +- Aaru.Tests/Issues/411.cs | 5 +- Aaru.Tests/Issues/441.cs | 5 +- Aaru.Tests/Issues/448.cs | 4 +- Aaru.Tests/Issues/449.cs | 3 +- Aaru.Tests/Issues/450.cs | 5 +- Aaru.Tests/Issues/495.cs | 5 +- Aaru.Tests/Issues/531.cs | 5 +- Aaru.Tests/Issues/542/Sims.cs | 24 +- Aaru.Tests/Issues/542/SimsEP.cs | 24 +- Aaru.Tests/Issues/584.cs | 5 +- .../590/asus-driver-gpu-tweak-v1231-2014.cs | 9 +- Aaru.Tests/Issues/590/m5a99fx.cs | 9 +- Aaru.Tests/Issues/590/win3.cs | 12 +- Aaru.Tests/Issues/623.cs | 4 +- Aaru.Tests/Issues/624.cs | 4 +- Aaru.Tests/Issues/625.cs | 4 +- Aaru.Tests/Issues/FsExtractHashIssueTest.cs | 16 +- Aaru.Tests/Issues/FsExtractIssueTest.cs | 17 +- Aaru.Tests/Issues/ImageReadIssueTest.cs | 6 +- .../Issues/OpticalImageConvertIssueTest.cs | 45 +- .../Issues/OpticalImageReadIssueTest.cs | 13 +- Aaru.Tests/Partitions/Acorn.cs | 4 +- Aaru.Tests/Partitions/AppleMap.cs | 4 +- Aaru.Tests/Partitions/Atari.cs | 4 +- Aaru.Tests/Partitions/BSD.cs | 4 +- Aaru.Tests/Partitions/GPT.cs | 4 +- Aaru.Tests/Partitions/MBR.cs | 4 +- Aaru.Tests/Partitions/MINIX.cs | 4 +- Aaru.Tests/Partitions/PC98.cs | 4 +- Aaru.Tests/Partitions/PartitionSchemeTest.cs | 8 +- Aaru.Tests/Partitions/RDB.cs | 4 +- Aaru.Tests/Partitions/SGI.cs | 4 +- Aaru.Tests/Partitions/Sun.cs | 4 +- Aaru.Tests/Partitions/VTOC.cs | 4 +- Aaru.Tests/Partitions/Xbox.cs | 4 +- Aaru.Tests/Structs.cs | 4 +- .../WritableImages/AaruFormat/V1/FromAaru.cs | 9 +- Aaru.Tests/WritableImages/Alcohol/FromAaru.cs | 6 +- .../BaseWritableMediaImageTest.cs | 4 +- Aaru.Tests/WritableImages/CDRDAO/FromAaru.cs | 6 +- Aaru.Tests/WritableImages/CDRWin/FromAaru.cs | 6 +- Aaru.Tests/WritableImages/CloneCD/FromAaru.cs | 6 +- .../WritableOpticalMediaImageTest.cs | 68 +- Aaru.sln.DotSettings | 1 + Aaru/Aaru.csproj | 642 +- Aaru/Commands/Archive/ArchiveFamily.cs | 6 +- Aaru/Commands/Archive/Info.cs | 9 +- Aaru/Commands/Configure.cs | 70 +- Aaru/Commands/Database/DatabaseFamily.cs | 6 +- Aaru/Commands/Database/Statistics.cs | 32 +- Aaru/Commands/Database/Update.cs | 19 +- Aaru/Commands/Device/DeviceFamily.cs | 6 +- Aaru/Commands/Device/DeviceReport.cs | 271 +- Aaru/Commands/Device/Info.cs | 104 +- Aaru/Commands/Device/List.cs | 26 +- Aaru/Commands/Filesystem/ExtractFiles.cs | 38 +- Aaru/Commands/Filesystem/FilesystemFamily.cs | 6 +- Aaru/Commands/Filesystem/Info.cs | 32 +- Aaru/Commands/Filesystem/Ls.cs | 34 +- Aaru/Commands/Filesystem/Options.cs | 10 +- Aaru/Commands/Formats.cs | 26 +- Aaru/Commands/Image/Checksum.cs | 18 +- Aaru/Commands/Image/Compare.cs | 37 +- Aaru/Commands/Image/Convert.cs | 75 +- Aaru/Commands/Image/CreateSidecar.cs | 27 +- Aaru/Commands/Image/Decode.cs | 15 +- Aaru/Commands/Image/Entropy.cs | 25 +- Aaru/Commands/Image/ImageFamily.cs | 6 +- Aaru/Commands/Image/Info.cs | 14 +- Aaru/Commands/Image/Options.cs | 15 +- Aaru/Commands/Image/Print.cs | 24 +- Aaru/Commands/Image/Verify.cs | 29 +- Aaru/Commands/ListEncodings.cs | 12 +- Aaru/Commands/ListNamespaces.cs | 13 +- Aaru/Commands/Media/Dump.cs | 46 +- Aaru/Commands/Media/Info.cs | 60 +- Aaru/Commands/Media/MediaFamily.cs | 6 +- Aaru/Commands/Media/Scan.cs | 20 +- Aaru/Commands/Remote.cs | 8 +- Aaru/Main.cs | 28 +- Aaru/aaruformat.xml | 28 +- CICMMetadata | 2 +- CONTRIBUTING.md | 20 +- Changelog.md | 6 +- 1321 files changed, 44657 insertions(+), 45479 deletions(-) diff --git a/.editorconfig b/.editorconfig index 169707b1e..25aaa3207 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,3 @@ - [*] charset = utf-8 end_of_line = lf @@ -30,11 +29,11 @@ dotnet_naming_rule.unity_serialized_field_rule_1.style = lower_camel_case_style dotnet_naming_rule.unity_serialized_field_rule_1.symbols = unity_serialized_field_symbols_1 dotnet_naming_style.lower_camel_case_style.capitalization = camel_case dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = * -dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds = +dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds = dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = * -dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds = +dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds = dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:warning diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 90b1972ed..7361d1464 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -54,7 +54,7 @@ repercussions as determined by other members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][https://www.contributor-covenant.org], version 1.4, available -at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +This Code of Conduct is adapted from the [Contributor Covenant][https://www.contributor-covenant.org], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org diff --git a/Aaru.Archives/Aaru.Archives.csproj b/Aaru.Archives/Aaru.Archives.csproj index 6fffbe672..c7ae34a81 100644 --- a/Aaru.Archives/Aaru.Archives.csproj +++ b/Aaru.Archives/Aaru.Archives.csproj @@ -1,91 +1,89 @@ - - Debug - AnyCPU - 2.0 - {282271D0-CCC2-4ED7-BA38-EC06A84BB974} - Library - Aaru.Archives - Aaru.Archives - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Archives - $(Version) - net6 - 10 - Archive implementations used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru.Archives - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - true - bin\Release\net6 - prompt - 4 - false - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - + + Debug + AnyCPU + 2.0 + {282271D0-CCC2-4ED7-BA38-EC06A84BB974} + Library + Aaru.Archives + Aaru.Archives + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Archives + $(Version) + net6 + 10 + Archive implementations used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru.Archives + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + true + bin\Release\net6 + prompt + 4 + false + + + + + + + LICENSE.LGPL + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + diff --git a/Aaru.Archives/Register.cs b/Aaru.Archives/Register.cs index f6123d008..f5c059114 100644 --- a/Aaru.Archives/Register.cs +++ b/Aaru.Archives/Register.cs @@ -38,14 +38,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Archives; + using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Archives; - /// public sealed class Register : IPluginRegister { diff --git a/Aaru.Checksums b/Aaru.Checksums index db8c5c6a5..19c7f3d4f 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit db8c5c6a536f5be9fc3c685065456d3106f4cfd0 +Subproject commit 19c7f3d4ff80c9ff938cfd04f03b6f8f658a067d diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 27900ec14..8d40f3e39 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 27900ec14469d0a9135731c9c5a9d17761e91d2c +Subproject commit 8d40f3e395e751ff62e7678252e9eac6b21b27ff diff --git a/Aaru.Compression/ADC.cs b/Aaru.Compression/ADC.cs index cff6f5008..53c720269 100644 --- a/Aaru.Compression/ADC.cs +++ b/Aaru.Compression/ADC.cs @@ -35,27 +35,24 @@ // Copyright © 2016-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Compression; + using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace Aaru.Compression; - /// Implements the Apple version of RLE public static class ADC { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + const int PLAIN = 1; + const int TWO_BYTE = 2; + const int THREE_BYTE = 3; + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => true; [DllImport("libAaru.Compression.Native", SetLastError = true)] static extern int AARU_adc_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size); - const int PLAIN = 1; - const int TWO_BYTE = 2; - const int THREE_BYTE = 3; - [MethodImpl(MethodImplOptions.AggressiveInlining)] static int GetChunkType(byte byt) => (byt & 0x80) == 0x80 ? PLAIN @@ -65,21 +62,21 @@ public static class ADC [MethodImpl(MethodImplOptions.AggressiveInlining)] static int GetChunkSize(byte byt) => GetChunkType(byt) switch - { - PLAIN => (byt & 0x7F) + 1, - TWO_BYTE => ((byt & 0x3F) >> 2) + 3, - THREE_BYTE => (byt & 0x3F) + 4, - _ => -1 - }; + { + PLAIN => (byt & 0x7F) + 1, + TWO_BYTE => ((byt & 0x3F) >> 2) + 3, + THREE_BYTE => (byt & 0x3F) + 4, + _ => -1 + }; [MethodImpl(MethodImplOptions.AggressiveInlining)] static int GetOffset(ReadOnlySpan chunk) => GetChunkType(chunk[0]) switch - { - PLAIN => 0, - TWO_BYTE => ((chunk[0] & 0x03) << 8) + chunk[1], - THREE_BYTE => (chunk[1] << 8) + chunk[2], - _ => -1 - }; + { + PLAIN => 0, + TWO_BYTE => ((chunk[0] & 0x03) << 8) + chunk[1], + THREE_BYTE => (chunk[1] << 8) + chunk[2], + _ => -1 + }; /// Decompresses a byte buffer that's compressed with ADC /// Compressed buffer @@ -91,11 +88,11 @@ public static class ADC if(Native.IsSupported) return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length); - int inputPosition = 0; + var inputPosition = 0; int chunkSize; int offset; int chunkType; - int outPosition = 0; + var outPosition = 0; Span temp = stackalloc byte[3]; while(inputPosition < source.Length) @@ -130,20 +127,18 @@ public static class ADC { byte lastByte = destination[outPosition - 1]; - for(int i = 0; i < chunkSize; i++) + for(var i = 0; i < chunkSize; i++) { destination[outPosition] = lastByte; outPosition++; } } else - { - for(int i = 0; i < chunkSize; i++) + for(var i = 0; i < chunkSize; i++) { destination[outPosition] = destination[outPosition - offset - 1]; outPosition++; } - } break; case THREE_BYTE: @@ -160,26 +155,24 @@ public static class ADC { byte lastByte = destination[outPosition - 1]; - for(int i = 0; i < chunkSize; i++) + for(var i = 0; i < chunkSize; i++) { destination[outPosition] = lastByte; outPosition++; } } else - { - for(int i = 0; i < chunkSize; i++) + for(var i = 0; i < chunkSize; i++) { destination[outPosition] = destination[outPosition - offset - 1]; outPosition++; } - } break; } } - finished: + finished: return outPosition; } diff --git a/Aaru.Compression/Aaru.Compression.csproj b/Aaru.Compression/Aaru.Compression.csproj index a7d9e903d..585b33232 100644 --- a/Aaru.Compression/Aaru.Compression.csproj +++ b/Aaru.Compression/Aaru.Compression.csproj @@ -1,127 +1,127 @@  - - Debug - AnyCPU - {858398D1-7321-4763-8BAB-56BBFEC74E29} - Library - Properties - Aaru.Compression - Aaru.Compression - 512 - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru Data Preservation Suite - $(Version) - net6 - 10 - Compression algorithms used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - AnyCPU - true - full - false - bin\Debug\net6 - DEBUG;TRACE - prompt - 4 - true - - - AnyCPU - pdbonly - true - bin\Release\net6 - TRACE - prompt - 4 - true - - - - $(DefaultItemExcludes);cuetools.net/**/* - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + {858398D1-7321-4763-8BAB-56BBFEC74E29} + Library + Properties + Aaru.Compression + Aaru.Compression + 512 + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru Data Preservation Suite + $(Version) + net6 + 10 + Compression algorithms used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + AnyCPU + true + full + false + bin\Debug\net6 + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\net6 + TRACE + prompt + 4 + true + + + + $(DefaultItemExcludes);cuetools.net/**/* + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Compression/AppleRle.cs b/Aaru.Compression/AppleRle.cs index 569d15aac..0f3baad55 100644 --- a/Aaru.Compression/AppleRle.cs +++ b/Aaru.Compression/AppleRle.cs @@ -31,23 +31,20 @@ // Copyright © 2018-2019 David Ryskalczyk // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Compression; +using System.Runtime.InteropServices; + /// Implements the Apple version of RLE public static class AppleRle { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + const uint DART_CHUNK = 20960; + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => true; [DllImport("libAaru.Compression.Native", SetLastError = true)] static extern int AARU_apple_rle_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size); - const uint DART_CHUNK = 20960; - /// Decodes a buffer compressed with Apple RLE /// Encoded buffer /// Buffer where to write the decoded data @@ -57,10 +54,10 @@ public static class AppleRle if(Native.IsSupported) return AARU_apple_rle_decode_buffer(destination, destination.Length, source, source.Length); - int count = 0; - bool nextA = true; // true if A, false if B + var count = 0; + var nextA = true; // true if A, false if B byte repeatedByteA = 0, repeatedByteB = 0; - bool repeatMode = false; // true if we're repeating, false if we're just copying + var repeatMode = false; // true if we're repeating, false if we're just copying int inPosition = 0, outPosition = 0; while(inPosition <= source.Length && @@ -100,9 +97,9 @@ public static class AppleRle while(true) { - byte b1 = source[inPosition++]; - byte b2 = source[inPosition++]; - short s = (short)((b1 << 8) | b2); + byte b1 = source[inPosition++]; + byte b2 = source[inPosition++]; + var s = (short)((b1 << 8) | b2); if(s == 0 || s >= DART_CHUNK || @@ -114,7 +111,7 @@ public static class AppleRle repeatMode = true; repeatedByteA = source[inPosition++]; repeatedByteB = source[inPosition++]; - count = (-s * 2) - 1; + count = -s * 2 - 1; nextA = false; destination[outPosition++] = repeatedByteA; @@ -123,7 +120,7 @@ public static class AppleRle } repeatMode = false; - count = (s * 2) - 1; + count = s * 2 - 1; destination[outPosition++] = source[inPosition++]; diff --git a/Aaru.Compression/BZip2.cs b/Aaru.Compression/BZip2.cs index 35c8d3c3f..a8b30bd1a 100644 --- a/Aaru.Compression/BZip2.cs +++ b/Aaru.Compression/BZip2.cs @@ -26,17 +26,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Compression; + using System.IO; using System.Runtime.InteropServices; using Ionic.BZip2; -namespace Aaru.Compression; - public class BZip2 { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => true; [DllImport("libAaru.Compression.Native", SetLastError = true)] @@ -52,7 +50,7 @@ public class BZip2 /// The number of decoded bytes public static int DecodeBuffer(byte[] source, byte[] destination) { - uint destinationSize = (uint)destination.Length; + var destinationSize = (uint)destination.Length; if(Native.IsSupported) { @@ -74,7 +72,7 @@ public class BZip2 /// public static int EncodeBuffer(byte[] source, byte[] destination, int blockSize100k) { - uint destinationSize = (uint)destination.Length; + var destinationSize = (uint)destination.Length; if(Native.IsSupported) { diff --git a/Aaru.Compression/FLAC.cs b/Aaru.Compression/FLAC.cs index 4f2268a17..74e780142 100644 --- a/Aaru.Compression/FLAC.cs +++ b/Aaru.Compression/FLAC.cs @@ -26,18 +26,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Compression; + using System.IO; using System.Runtime.InteropServices; using CUETools.Codecs; using CUETools.Codecs.Flake; -namespace Aaru.Compression; - public class FLAC { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => true; [DllImport("libAaru.Compression.Native", SetLastError = true)] @@ -48,9 +46,8 @@ public class FLAC static extern nuint AARU_flac_encode_redbook_buffer(byte[] dst_buffer, nuint dst_size, byte[] src_buffer, nuint src_size, uint blocksize, int do_mid_side_stereo, int loose_mid_side_stereo, string apodization, - uint max_lpc_order, - uint qlp_coeff_precision, int do_qlp_coeff_prec_search, - int do_exhaustive_model_search, + uint max_lpc_order, uint qlp_coeff_precision, + int do_qlp_coeff_prec_search, int do_exhaustive_model_search, uint min_residual_partition_order, uint max_residual_partition_order, string application_id, uint application_id_len); @@ -81,19 +78,18 @@ public class FLAC /// Buffer to store the compressed data /// public static int EncodeBuffer(byte[] source, byte[] destination, uint blockSize, bool doMidSideStereo, - bool looseMidSideStereo, string apodization, uint max_lpc_order, uint qlpCoeffPrecision, - bool doQlpCoeffPrecSearch, bool doExhaustiveModelSearch, - uint minResidualPartitionOrder, uint maxResidualPartitionOrder, - string applicationID) + bool looseMidSideStereo, string apodization, uint max_lpc_order, + uint qlpCoeffPrecision, bool doQlpCoeffPrecSearch, bool doExhaustiveModelSearch, + uint minResidualPartitionOrder, uint maxResidualPartitionOrder, string applicationID) { 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, max_lpc_order, qlpCoeffPrecision, - doQlpCoeffPrecSearch ? 1 : 0, - doExhaustiveModelSearch ? 1 : 0, - minResidualPartitionOrder, maxResidualPartitionOrder, - applicationID, (uint)applicationID.Length); + looseMidSideStereo ? 1 : 0, apodization, max_lpc_order, + qlpCoeffPrecision, doQlpCoeffPrecSearch ? 1 : 0, + doExhaustiveModelSearch ? 1 : 0, minResidualPartitionOrder, + maxResidualPartitionOrder, applicationID, + (uint)applicationID.Length); var flakeWriterSettings = new EncoderSettings { diff --git a/Aaru.Compression/LZFSE.cs b/Aaru.Compression/LZFSE.cs index 7e39d2710..9992fc957 100644 --- a/Aaru.Compression/LZFSE.cs +++ b/Aaru.Compression/LZFSE.cs @@ -26,15 +26,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Compression; +using System.Runtime.InteropServices; + public class LZFSE { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => Native.IsSupported; [DllImport("libAaru.Compression.Native", SetLastError = true)] diff --git a/Aaru.Compression/LZIP.cs b/Aaru.Compression/LZIP.cs index d81daa073..f669fc2dc 100644 --- a/Aaru.Compression/LZIP.cs +++ b/Aaru.Compression/LZIP.cs @@ -26,15 +26,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Compression; +using System.Runtime.InteropServices; + public class LZIP { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => Native.IsSupported; [DllImport("libAaru.Compression.Native", SetLastError = true)] diff --git a/Aaru.Compression/LZMA.cs b/Aaru.Compression/LZMA.cs index cc37eba09..e855eac86 100644 --- a/Aaru.Compression/LZMA.cs +++ b/Aaru.Compression/LZMA.cs @@ -26,17 +26,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Compression; + using System.IO; using System.Runtime.InteropServices; using SharpCompress.Compressors.LZMA; -namespace Aaru.Compression; - public class LZMA { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => true; [DllImport("libAaru.Compression.Native", SetLastError = true)] diff --git a/Aaru.Compression/Native.cs b/Aaru.Compression/Native.cs index 59b88218f..83b2f00b8 100644 --- a/Aaru.Compression/Native.cs +++ b/Aaru.Compression/Native.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Compression; +using System.Runtime.InteropServices; + public static class Native { static bool _checked; diff --git a/Aaru.Compression/TeleDiskLzh.cs b/Aaru.Compression/TeleDiskLzh.cs index f62a774dc..3a6a6db7f 100644 --- a/Aaru.Compression/TeleDiskLzh.cs +++ b/Aaru.Compression/TeleDiskLzh.cs @@ -42,11 +42,11 @@ // Copyright © 1988 Kenji RIKITAKE // ****************************************************************************/ +namespace Aaru.Compression; + using System; using System.IO; -namespace Aaru.Compression; - /* * Based on Japanese version 29-NOV-1988 * LZSS coded by Haruhiko OKUMURA @@ -56,11 +56,6 @@ namespace Aaru.Compression; /// Implements the TeleDisk version of LZH public class TeleDiskLzh { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// - public static bool IsSupported => true; - const int BUFSZ = 512; /* LZSS Parameters */ @@ -73,8 +68,8 @@ public class TeleDiskLzh const int N_CHAR = 256 - THRESHOLD + F; /* character code (= 0..N_CHAR-1) */ - const int T = (N_CHAR * 2) - 1; /* Size of table */ - const int ROOT = T - 1; /* root position */ + const int T = N_CHAR * 2 - 1; /* Size of table */ + const int ROOT = T - 1; /* root position */ const int MAX_FREQ = 0x8000; /* @@ -158,6 +153,9 @@ public class TeleDiskLzh _inStream = dataStream; } + /// Set to true if this algorithm is supported, false otherwise. + public static bool IsSupported => true; + /* DeCompression split out initialization code to init_Decode() @@ -258,7 +256,7 @@ public class TeleDiskLzh if(NextWord() < 0) return -1; - short i = (short)_getbuf; + var i = (short)_getbuf; _getbuf <<= 1; _getlen--; @@ -333,7 +331,7 @@ public class TeleDiskLzh for(k = (short)(j - 1); f < _freq[k]; k--) {} k++; - ushort l = (ushort)((j - k) * 2); + var l = (ushort)((j - k) * 2); Array.ConstrainedCopy(_freq, k, _freq, k + 1, l); _freq[k] = f; @@ -396,7 +394,7 @@ public class TeleDiskLzh short DecodeChar() { - ushort c = (ushort)_son[ROOT]; + var c = (ushort)_son[ROOT]; /* * start searching tree from the root to leaves. @@ -428,8 +426,8 @@ public class TeleDiskLzh if((bit = (short)GetByte()) < 0) return -1; - ushort i = (ushort)bit; - ushort c = (ushort)(_dCode[i] << 6); + var i = (ushort)bit; + var c = (ushort)(_dCode[i] << 6); ushort j = _dLen[i]; /* input lower 6 bits directly */ diff --git a/Aaru.Compression/ZSTD.cs b/Aaru.Compression/ZSTD.cs index 20606b341..0ea2791cf 100644 --- a/Aaru.Compression/ZSTD.cs +++ b/Aaru.Compression/ZSTD.cs @@ -26,15 +26,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Compression; +using System.Runtime.InteropServices; + public class ZSTD { - /// - /// Set to true if this algorithm is supported, false otherwise. - /// + /// Set to true if this algorithm is supported, false otherwise. public static bool IsSupported => Native.IsSupported; [DllImport("libAaru.Compression.Native", SetLastError = true)] diff --git a/Aaru.Console b/Aaru.Console index 2deb65967..b9a1ad4cb 160000 --- a/Aaru.Console +++ b/Aaru.Console @@ -1 +1 @@ -Subproject commit 2deb65967aaf172e008256df54e51555c5ab17d0 +Subproject commit b9a1ad4cb15e20ae4d53d1aaddb59f7bd6c164c9 diff --git a/Aaru.Core/Aaru.Core.csproj b/Aaru.Core/Aaru.Core.csproj index 02a44e655..f1fb6140c 100644 --- a/Aaru.Core/Aaru.Core.csproj +++ b/Aaru.Core/Aaru.Core.csproj @@ -1,230 +1,219 @@  - - Debug - AnyCPU - 2.0 - {679659B8-25D0-4279-B632-56EF8F94ADC0} - Library - Aaru.Core - Aaru.Core - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Core - $(Version) - net6 - 10 - Contains core algorithms used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - GPL-3.0-or-later - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {679659B8-25D0-4279-B632-56EF8F94ADC0} + Library + Aaru.Core + Aaru.Core + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Core + $(Version) + net6 + 10 + Contains core algorithms used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + GPL-3.0-or-later + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + diff --git a/Aaru.Core/Checksum.cs b/Aaru.Core/Checksum.cs index 9cb023244..4afa8972b 100644 --- a/Aaru.Core/Checksum.cs +++ b/Aaru.Core/Checksum.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Threading; @@ -37,8 +39,6 @@ using Aaru.Checksums; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Core; - /// Enabled checksums [Flags] public enum EnableChecksum @@ -68,8 +68,7 @@ public enum EnableChecksum /// Enables Fletcher-32 Fletcher32 = 4096, /// Enables all known checksums - All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum | Fletcher16 | - Fletcher32 + All = Adler32 | Crc16 | Crc32 | Crc64 | Md5 | Sha1 | Sha256 | Sha384 | Sha512 | SpamSum | Fletcher16 | Fletcher32 } /// Checksums and hashes data, with different algorithms, multithreaded @@ -383,7 +382,7 @@ public sealed class Checksum /// Returns the checksum results public List End() { - List chks = new List(); + var chks = new List(); ChecksumType chk; @@ -719,8 +718,8 @@ public sealed class Checksum f16ThreadData.IsAlive || f32ThreadData.IsAlive) {} - List dataChecksums = new List(); - ChecksumType chk; + var dataChecksums = new List(); + ChecksumType chk; if(enabled.HasFlag(EnableChecksum.Adler32)) { diff --git a/Aaru.Core/DataFile.cs b/Aaru.Core/DataFile.cs index dcf40a524..609c11eb3 100644 --- a/Aaru.Core/DataFile.cs +++ b/Aaru.Core/DataFile.cs @@ -30,15 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System.Diagnostics.CodeAnalysis; using System.IO; using Aaru.Console; -namespace Aaru.Core; - /// Abstracts a datafile with a block based interface -[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global"), - SuppressMessage("ReSharper", "UnusedMember.Global")] +[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global"), SuppressMessage("ReSharper", "UnusedMember.Global")] public sealed class DataFile { readonly FileStream _dataFs; @@ -90,8 +89,7 @@ public sealed class DataFile /// Data /// Block /// Bytes per block - public void WriteAt(byte[] data, ulong block, uint blockSize) => - WriteAt(data, block, blockSize, 0, data.Length); + public void WriteAt(byte[] data, ulong block, uint blockSize) => WriteAt(data, block, blockSize, 0, data.Length); /// Writes data at specified block /// Data @@ -114,8 +112,7 @@ public sealed class DataFile /// First part of the file name /// Last part of the file name /// What is the data about? - public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting, - byte[] data) + public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting, byte[] data) { if(!string.IsNullOrEmpty(outputPrefix) && !string.IsNullOrEmpty(outputSuffix)) diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 03f10035c..9f0f68999 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -39,6 +41,7 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; using Aaru.Core.Devices.Report; using Aaru.Core.Logging; using Aaru.Decoders.ATA; @@ -48,8 +51,6 @@ using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify; using Tuple = Aaru.Decoders.PCMCIA.Tuple; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping ATA devices public partial class Dump { @@ -151,8 +152,8 @@ public partial class Dump UpdateStatus?.Invoke($"Device reports {physicalSectorSize} bytes per physical block."); _dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * blockSize); - _dumpLog.WriteLine("Device reports {0} cylinders {1} heads {2} sectors per track.", cylinders, - heads, sectors); + _dumpLog.WriteLine("Device reports {0} cylinders {1} heads {2} sectors per track.", cylinders, heads, + sectors); _dumpLog.WriteLine("Device can read {0} blocks at a time.", blocksToRead); _dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize); @@ -164,9 +165,9 @@ public partial class Dump DumpHardwareType 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) @@ -180,7 +181,7 @@ public partial class Dump IbgLog ibgLog; double duration; - bool ret = true; + var ret = true; if(_dev.IsUsb && _dev.UsbDescriptors != null && @@ -232,8 +233,8 @@ public partial class Dump _dumpLog.WriteLine("Error creating output image, not continuing."); _dumpLog.WriteLine(outputFormat.ErrorMessage); - StoppingErrorMessage?.Invoke("Error creating output image, not continuing." + - Environment.NewLine + outputFormat.ErrorMessage); + StoppingErrorMessage?.Invoke("Error creating output image, not continuing." + Environment.NewLine + + outputFormat.ErrorMessage); return; } @@ -259,7 +260,7 @@ public partial class Dump _dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock); } - bool newTrim = false; + var newTrim = false; start = DateTime.UtcNow; DateTime timeSpeedStart = DateTime.UtcNow; @@ -288,8 +289,8 @@ public partial class Dump currentSpeed > 0) minSpeed = currentSpeed; - UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", - (long)i, (long)blocks); + UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, + (long)blocks); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); @@ -410,11 +411,11 @@ public partial class Dump !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; InitProgress?.Invoke(); - repeatRetryLba: + repeatRetryLba: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -520,14 +521,12 @@ public partial class Dump ibgLog.Write(currentBlock, currentSpeed * 1024); DateTime writeStart = DateTime.Now; - outputFormat.WriteSector(cmdBuf, - (ulong)((((cy * heads) + hd) * sectors) + (sc - 1))); + outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1))); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; extents.Add(currentBlock); - _dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd, - sc); + _dumpLog.WriteLine("Error reading cylinder {0} head {1} sector {2}.", cy, hd, sc); } else { @@ -538,7 +537,7 @@ public partial class Dump DateTime writeStart = DateTime.Now; outputFormat.WriteSector(new byte[blockSize], - (ulong)((((cy * heads) + hd) * sectors) + (sc - 1))); + (ulong)((cy * heads + hd) * sectors + (sc - 1))); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; } @@ -590,7 +589,7 @@ public partial class Dump outputFormat.SetDumpHardware(_resume.Tries); // TODO: Non-removable - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -637,7 +636,7 @@ public partial class Dump UpdateStatus?.Invoke("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index c567b7b81..a91409655 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -41,12 +49,6 @@ using Aaru.Decoders.CD; using Aaru.Devices; using Schemas; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Detects if a sector contains data @@ -62,7 +64,7 @@ partial class Dump 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 }; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; Array.Copy(sector, 0, testMark, 0, 12); return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2); @@ -85,14 +87,14 @@ partial class Dump 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 }; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; - for(int i = 0; i <= 2336; i++) + for(var i = 0; i <= 2336; i++) { Array.Copy(sector, i, testMark, 0, 12); if(!syncMark.SequenceEqual(testMark) || - (sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)) + sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62) continue; // De-scramble M and S @@ -101,17 +103,17 @@ partial class Dump int frame = sector[i + 14]; // Convert to binary - minute = (minute / 16 * 10) + (minute & 0x0F); - second = (second / 16 * 10) + (second & 0x0F); - frame = (frame / 16 * 10) + (frame & 0x0F); + minute = minute / 16 * 10 + (minute & 0x0F); + second = second / 16 * 10 + (second & 0x0F); + frame = frame / 16 * 10 + (frame & 0x0F); // Calculate the first found LBA - int lba = (minute * 60 * 75) + (second * 75) + frame - 150; + int lba = minute * 60 * 75 + second * 75 + frame - 150; // Calculate the difference between the found LBA and the requested one int diff = wantedLba - lba; - offset = i + (2352 * diff); + offset = i + 2352 * diff; return true; } @@ -147,12 +149,12 @@ partial class Dump /// List of subchannels not yet dumped correctly /// List of smallest pregap relative address per track void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents, - IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, - ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, uint subSize, - MmcSubchannel supportedSubchannel, ref double totalDuration, Track[] tracks, - SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary isrcs, - ref string mcn, HashSet subchannelExtents, ulong blocks, bool cdiReadyReadAsAudio, - int offsetBytes, int sectorsForOffset, Dictionary smallestPregapLbaPerTrack) + IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed, + MhddLog mhddLog, ref double minSpeed, uint subSize, MmcSubchannel supportedSubchannel, + ref double totalDuration, Track[] tracks, SubchannelLog subLog, MmcSubchannel desiredSubchannel, + Dictionary isrcs, ref string mcn, HashSet subchannelExtents, ulong blocks, + bool cdiReadyReadAsAudio, int offsetBytes, int sectorsForOffset, + Dictionary smallestPregapLbaPerTrack) { ulong sectorSpeedStart = 0; // Used to calculate correct speed DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation @@ -189,7 +191,7 @@ partial class Dump break; } - uint firstSectorToRead = (uint)i; + var firstSectorToRead = (uint)i; blocksToRead = _maximumReadable; @@ -197,7 +199,6 @@ partial class Dump blocksToRead += (uint)sectorsForOffset; if(cdiReadyReadAsAudio) - { if(offsetBytes < 0) { if(i == 0) @@ -205,7 +206,6 @@ partial class Dump else firstSectorToRead -= (uint)sectorsForOffset; } - } if(currentSpeed > maxSpeed && currentSpeed > 0) @@ -228,16 +228,14 @@ partial class Dump // Overcome the track mode change drive error if(sense) - { for(uint r = 0; r < _maximumReadable; r++) { UpdateProgress?.Invoke($"Reading sector {i + r} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i + r, (long)blocks); - 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; @@ -255,8 +253,8 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); @@ -275,16 +273,14 @@ partial class Dump // Set tracks and go back if(indexesChanged) { - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i -= _maximumReadable; continue; } } else - { outputOptical.WriteSectorsLong(cmdBuf, i + r, 1); - } imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; } @@ -316,7 +312,6 @@ partial class Dump sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } - } if(!sense && !_dev.Error) @@ -332,22 +327,22 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * blocksToRead]; - byte[] sub = new byte[subSize * blocksToRead]; - byte[] tmpData = new byte[sectorSize]; + var data = new byte[sectorSize * blocksToRead]; + var sub = new byte[subSize * blocksToRead]; + var tmpData = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { if(cdiReadyReadAsAudio) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), tmpData, 0, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), tmpData, 0, sectorSize); tmpData = Sector.Scramble(tmpData); Array.Copy(tmpData, 0, data, sectorSize * b, sectorSize); } else - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); - Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize); + Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } outputOptical.WriteSectorsLong(data, i, blocksToRead); @@ -360,7 +355,7 @@ partial class Dump // Set tracks and go back if(indexesChanged) { - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i -= blocksToRead; continue; @@ -370,10 +365,10 @@ partial class Dump { if(cdiReadyReadAsAudio) { - byte[] tmpData = new byte[sectorSize]; - byte[] data = new byte[sectorSize * blocksToRead]; + var tmpData = new byte[sectorSize]; + var data = new byte[sectorSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), tmpData, 0, sectorSize); tmpData = Sector.Scramble(tmpData); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 18ac308d5..e16d869fb 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -45,12 +53,6 @@ using Aaru.Decoders.SCSI; using Aaru.Devices; using Schemas; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Reads all CD user data @@ -100,7 +102,7 @@ partial class Dump ulong sectorSpeedStart = 0; // Used to calculate correct speed DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation uint blocksToRead; // How many sectors to read at once - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer byte[] senseBuf = null; // Sense buffer double cmdDuration = 0; // Command execution time @@ -131,10 +133,10 @@ partial class Dump InitProgress?.Invoke(); - int currentReadSpeed = _speed; - bool crossingLeadOut = false; - bool failedCrossingLeadOut = false; - bool skippingLead = false; + int currentReadSpeed = _speed; + var crossingLeadOut = false; + var failedCrossingLeadOut = false; + var skippingLead = false; for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead) { @@ -156,7 +158,7 @@ partial class Dump if((long)i > lastSector) break; - uint firstSectorToRead = (uint)i; + var firstSectorToRead = (uint)i; Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => i >= t.StartSector); @@ -221,7 +223,6 @@ partial class Dump } if(_fixOffset && !inData) - { if(offsetBytes < 0) { if(i == 0) @@ -232,7 +233,6 @@ partial class Dump if(blocksToRead <= sectorsForOffset) blocksToRead += (uint)sectorsForOffset; } - } if(!inData && currentReadSpeed == 0xFFFF) @@ -249,8 +249,7 @@ partial class Dump { _dumpLog.WriteLine($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}."); - UpdateStatus?. - Invoke($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}."); + UpdateStatus?.Invoke($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}."); _speed *= _speedMultiplier; @@ -288,8 +287,8 @@ partial class Dump if(_supportsPlextorD8 && !inData) { - 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; } @@ -298,9 +297,8 @@ partial class Dump if(inData) { 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); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); if(sense) { @@ -309,13 +307,13 @@ partial class Dump // Try to workaround firmware if(decSense?.ASC == 0x64) { - bool goBackTrackTypeChange = false; + var goBackTrackTypeChange = false; // Go one for one as the drive does not tell us which one failed - for(int bi = 0; bi < blocksToRead; bi++) + for(var bi = 0; bi < blocksToRead; bi++) { - sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(firstSectorToRead + bi), - blockSize, 1, MmcSectorTypes.AllTypes, false, false, true, + 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); @@ -367,13 +365,13 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) || + if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || decSense?.ASC == 0x64) { 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); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, + true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + out double cmdDuration2); cmdDuration += cmdDuration2; } @@ -383,25 +381,17 @@ partial class Dump totalDuration += cmdDuration; } else if(read16) - { - 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); else if(read12) - { sense = _dev.Read12(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead, blockSize, 0, blocksToRead, false, _dev.Timeout, out cmdDuration); - } else if(read10) - { sense = _dev.Read10(out cmdBuf, out senseBuf, 0, false, false, false, false, firstSectorToRead, blockSize, 0, (ushort)blocksToRead, _dev.Timeout, out cmdDuration); - } else if(read6) - { sense = _dev.Read6(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, (byte)blocksToRead, _dev.Timeout, out cmdDuration); - } double elapsed; @@ -417,7 +407,7 @@ partial class Dump if(_supportsPlextorD8) { - int adjustment = 0; + var adjustment = 0; if(offsetBytes < 0) adjustment = -sectorsForOffset; @@ -431,7 +421,7 @@ partial class Dump if(!sense) { - uint sectorsForFix = (uint)(1 + sectorsForOffset); + var sectorsForFix = (uint)(1 + sectorsForOffset); FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref sectorsForFix, subSize, ref cmdBuf, blockSize, false); @@ -450,25 +440,17 @@ partial class Dump totalDuration += cmdDuration; } else if(read16) - { sense = _dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i + r, 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 + r), 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 + r), blockSize, 0, 1, _dev.Timeout, out cmdDuration); - } else if(read6) - { sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, 1, _dev.Timeout, out cmdDuration); - } if(!sense && !_dev.Error) @@ -480,8 +462,8 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); @@ -491,12 +473,12 @@ partial class Dump outputFormat.WriteSectorsLong(data, i + r, 1); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } @@ -505,10 +487,10 @@ 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); + desiredSubchannel, sub, i + r, 1, subLog, isrcs, (byte)track.Sequence, ref mcn, + tracks, subchannelExtents, _fixSubchannelPosition, + outputFormat as IWritableOpticalImage, _fixSubchannel, _fixSubchannelCrc, _dumpLog, + UpdateStatus, smallestPregapLbaPerTrack, true); // Set tracks and go back if(indexesChanged) @@ -525,10 +507,10 @@ partial class Dump outputFormat.WriteSectorsLong(cmdBuf, i + r, 1); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); @@ -603,7 +585,7 @@ partial class Dump { if(crossingLeadOut && failedCrossingLeadOut) { - byte[] tmp = new byte[cmdBuf.Length + blockSize]; + var tmp = new byte[cmdBuf.Length + blockSize]; Array.Copy(cmdBuf, 0, tmp, 0, cmdBuf.Length); } @@ -621,26 +603,26 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * blocksToRead]; - byte[] sub = new byte[subSize * blocksToRead]; + var data = new byte[sectorSize * blocksToRead]; + var sub = new byte[subSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); - Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize); + Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } if(supportsLongSectors) outputFormat.WriteSectorsLong(data, i, blocksToRead); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } @@ -649,8 +631,8 @@ 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, + desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn, + tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage, _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true); @@ -669,10 +651,10 @@ partial class Dump outputFormat.WriteSectorsLong(cmdBuf, i, blocksToRead); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); @@ -721,9 +703,7 @@ partial class Dump else { if(supportsLongSectors) - { outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip); - } else { if(cmdBuf.Length % sectorSize == 0) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index 5039351b6..0ad7052aa 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -49,12 +57,6 @@ using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - /// Implement dumping Compact Discs // TODO: Barcode @@ -84,22 +86,22 @@ sealed partial class Dump MhddLog mhddLog; // MHDD log double minSpeed = double.MaxValue; // Minimum speed bool newTrim; // Is trim a new one? - int offsetBytes = 0; // Read offset - bool read6 = false; // Device supports READ(6) - bool read10 = false; // Device supports READ(10) - bool read12 = false; // Device supports READ(12) - bool read16 = false; // Device supports READ(16) + var offsetBytes = 0; // Read offset + var read6 = false; // Device supports READ(6) + var read10 = false; // Device supports READ(10) + var read12 = false; // Device supports READ(12) + var read16 = false; // Device supports READ(16) bool readcd; // Device supports READ CD bool ret; // Image writing return status const uint sectorSize = 2352; // Full sector size - int sectorsForOffset = 0; // Sectors needed to fix offset - bool sense = true; // Sense indicator + var sectorsForOffset = 0; // Sectors needed to fix offset + var sense = true; // Sense indicator int sessions; // Number of sessions in disc DateTime start; // Start of operation SubchannelLog subLog = null; // Subchannel log uint subSize; // Subchannel size in bytes TrackSubchannelType subType; // Track subchannel type - bool supportsLongSectors = true; // Supports reading EDC and ECC + var supportsLongSectors = true; // Supports reading EDC and ECC bool supportsPqSubchannel; // Supports reading PQ subchannel bool supportsRwSubchannel; // Supports reading RW subchannel byte[] tmpBuf; // Temporary buffer @@ -111,11 +113,11 @@ sealed partial class Dump bool hiddenTrack; // Disc has a hidden track before track 1 MmcSubchannel supportedSubchannel; // Drive's maximum supported subchannel MmcSubchannel desiredSubchannel; // User requested subchannel - bool bcdSubchannel = false; // Subchannel positioning is in BCD + var bcdSubchannel = false; // Subchannel positioning is in BCD Dictionary isrcs = new(); string mcn = null; HashSet subchannelExtents = new(); - bool cdiReadyReadAsAudio = false; + var cdiReadyReadAsAudio = false; uint firstLba; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -247,8 +249,8 @@ sealed partial class Dump _dumpLog.WriteLine("Checking if drive supports reading without subchannel..."); UpdateStatus?.Invoke("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, + 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) @@ -268,8 +270,8 @@ sealed partial class Dump _dumpLog.WriteLine("Checking if drive supports READ(12)..."); UpdateStatus?.Invoke("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("Checking if drive supports READ(16)..."); UpdateStatus?.Invoke("Checking if drive supports READ(16)..."); @@ -368,9 +370,9 @@ 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) { @@ -417,8 +419,7 @@ sealed partial class Dump Invoke("WARNING: The drive has returned incorrect Q positioning when calculating pregaps. A best effort has been tried but they may be incorrect."); } - if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreRawData)) + if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreRawData)) { if(!_force) { @@ -436,8 +437,7 @@ sealed partial class Dump Invoke("Output format does not support storing raw data, this may end in a loss of data, continuing..."); } - if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreAudioTracks) && + if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreAudioTracks) && tracks.Any(track => track.Type == TrackType.Audio)) { _dumpLog.WriteLine("Output format does not support audio tracks, cannot continue..."); @@ -447,8 +447,7 @@ sealed partial class Dump return; } - if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStorePregaps) && + if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStorePregaps) && tracks.Where(track => track.Sequence != tracks.First(t => t.Session == track.Session).Sequence). Any(track => track.Pregap > 0)) { @@ -468,7 +467,7 @@ sealed partial class Dump Invoke("Output format does not support pregaps, this may end in a loss of data, continuing..."); } - for(int t = 1; t < tracks.Length; t++) + for(var t = 1; t < tracks.Length; t++) tracks[t - 1].EndSector = tracks[t].StartSector - 1; tracks[^1].EndSector = (ulong)lastSector; @@ -495,8 +494,7 @@ sealed partial class Dump // Read media tags ReadCdTags(ref dskType, mediaTags, out sessions, out firstTrackLastSession); - if(!(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreSessions) && + if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSessions) && sessions > 1) { // TODO: Disabled until 6.0 @@ -518,7 +516,6 @@ sealed partial class Dump // Check if output format supports all disc tags we have retrieved so far foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputOptical.SupportedMediaTags.Contains(tag))) - { if(_force) { _dumpLog.WriteLine("Output format does not support {0}, continuing...", tag); @@ -531,7 +528,6 @@ sealed partial class Dump return; } - } if(leadOutStarts.Any()) { @@ -549,7 +545,7 @@ sealed partial class Dump Tuple[] dataExtentsArray = dataExtents.ToArray(); - for(int i = 0; i < dataExtentsArray.Length - 1; i++) + for(var i = 0; i < dataExtentsArray.Length - 1; i++) leadOutExtents.Add(dataExtentsArray[i].Item2 + 1, dataExtentsArray[i + 1].Item1 - 1); } @@ -618,7 +614,7 @@ sealed partial class Dump continue; } - int bufOffset = 0; + var bufOffset = 0; while(cmdBuf[0 + bufOffset] != 0x00 || cmdBuf[1 + bufOffset] != 0xFF || @@ -719,7 +715,6 @@ sealed partial class Dump // Check if something prevents from dumping the first track pregap if(_dumpFirstTrackPregap && readcd) - { if(!outputOptical.SupportedMediaTags.Contains(MediaTagType.CD_FirstTrackPregap)) { if(_force) @@ -739,24 +734,23 @@ sealed partial class Dump _dumpFirstTrackPregap = false; } - } // Try how many blocks are readable at once while(true) { 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; } 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; @@ -779,8 +773,7 @@ sealed partial class Dump } else if(read6) { - sense = _dev.Read6(out cmdBuf, out _, firstLba, blockSize, (byte)_maximumReadable, _dev.Timeout, - out _); + sense = _dev.Read6(out cmdBuf, out _, firstLba, blockSize, (byte)_maximumReadable, _dev.Timeout, out _); if(_dev.Error || sense) _maximumReadable /= 2; @@ -835,11 +828,10 @@ sealed partial class Dump if(errno == ErrorNumber.NoError) mcn = Encoding.ASCII.GetString(mcnBytes); - if((outputOptical as IWritableOpticalImage).Tracks != null) - foreach(Track imgTrack in (outputOptical as IWritableOpticalImage).Tracks) + if(outputOptical.Tracks != null) + foreach(Track imgTrack in outputOptical.Tracks) { - errno = (outputOptical as IWritableOpticalImage).ReadSectorTag(imgTrack.Sequence, - SectorTagType.CdTrackIsrc, out byte[] isrcBytes); + errno = outputOptical.ReadSectorTag(imgTrack.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcBytes); if(errno == ErrorNumber.NoError) isrcs[(byte)imgTrack.Sequence] = Encoding.ASCII.GetString(isrcBytes); @@ -858,7 +850,7 @@ sealed partial class Dump } // Send track list to output plugin. This may fail if subchannel is set but unsupported. - ret = (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + ret = outputOptical.SetTracks(tracks.ToList()); if(!ret && desiredSubchannel == MmcSubchannel.None) @@ -866,16 +858,15 @@ sealed partial class Dump _dumpLog.WriteLine("Error sending tracks to output image, not continuing."); _dumpLog.WriteLine(outputOptical.ErrorMessage); - StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." + - Environment.NewLine + outputOptical.ErrorMessage); + StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." + Environment.NewLine + + outputOptical.ErrorMessage); return; } // If a subchannel is supported, check if output plugin allows us to write it. if(desiredSubchannel != MmcSubchannel.None && - !(outputOptical as IWritableOpticalImage).OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreSubchannelRw)) + !outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSubchannelRw)) { _dumpLog.WriteLine("Output image does not support subchannels, {0}continuing...", _force ? "" : "not "); @@ -1009,8 +1000,8 @@ 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); + Core.Media.Info.CompactDisc.GetOffset(cdOffset, _dbDev, _debug, _dev, dskType, _dumpLog, tracks, UpdateStatus, + out int? driveOffset, out int? combinedOffset, out _supportsPlextorD8); if(combinedOffset is null) { @@ -1096,9 +1087,7 @@ sealed partial class Dump audioExtents = new ExtentsULong(); foreach(Track audioTrack in tracks.Where(t => t.Type == TrackType.Audio)) - { audioExtents.Add(audioTrack.StartSector, audioTrack.EndSector); - } // Set speed if(_speedMultiplier >= 0) @@ -1138,8 +1127,7 @@ sealed partial class Dump { _dumpLog.WriteLine("Dumping CD-i Ready requires the drive to support the READ CD command."); - StoppingErrorMessage?. - Invoke("Dumping CD-i Ready requires the drive to support the READ CD command."); + StoppingErrorMessage?.Invoke("Dumping CD-i Ready requires the drive to support the READ CD command."); return; } @@ -1184,8 +1172,7 @@ sealed partial class Dump } else { - _dumpLog. - WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples)."); + _dumpLog.WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples)."); UpdateStatus?. Invoke($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples)."); @@ -1210,16 +1197,15 @@ sealed partial class Dump 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); + 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); + 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 /* @@ -1256,21 +1242,19 @@ sealed partial class Dump ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack); - 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); - } 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 if(!_aborted) @@ -1309,11 +1293,11 @@ sealed partial class Dump if(_generateSubchannels && outputOptical.SupportedSectorTags.Contains(SectorTagType.CdSectorSubchannel) && !_aborted) - Media.CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, blocks, subLog, _dumpLog, - InitProgress, UpdateProgress, EndProgress, outputOptical); + Core.Media.CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, blocks, subLog, _dumpLog, + InitProgress, UpdateProgress, EndProgress, outputOptical); // TODO: Disc ID - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -1331,8 +1315,7 @@ sealed partial class Dump foreach(KeyValuePair isrc in isrcs) { // TODO: Track tags - if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), isrc.Key, - SectorTagType.CdTrackIsrc)) + if(!outputOptical.WriteSectorTag(Encoding.ASCII.GetBytes(isrc.Value), isrc.Key, SectorTagType.CdTrackIsrc)) continue; UpdateStatus?.Invoke($"Setting ISRC for track {isrc.Key} to {isrc.Value}"); @@ -1367,7 +1350,7 @@ sealed partial class Dump trk.Indexes.Remove(0); } - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); _dumpLog.WriteLine("Closing output file."); UpdateStatus?.Invoke("Closing output file."); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index bf02420b2..5b1106703 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -45,12 +53,6 @@ using Aaru.Devices; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Retried errored sectors in CompactDisc @@ -72,14 +74,14 @@ partial class Dump /// Disc media catalogue number /// List of subchannels not yet dumped correctly /// List of smallest pregap relative address per track - void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, - ExtentsULong extents, int offsetBytes, bool readcd, int sectorsForOffset, uint subSize, + void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents, + int offsetBytes, bool readcd, int sectorsForOffset, uint subSize, MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary isrcs, ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack, bool supportsLongSectors) { - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration; // Command execution time const uint sectorSize = 2352; // Full sector size @@ -112,9 +114,9 @@ partial class Dump _retryPasses <= 0) return; - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -129,13 +131,12 @@ partial class Dump if(sense) { - sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + out _); if(!sense) { - Modes.DecodedMode? dcMode10 = - Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); + Modes.DecodedMode? dcMode10 = Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); if(dcMode10?.Pages != null) foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage => @@ -148,8 +149,8 @@ partial class Dump Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice); if(dcMode6?.Pages != null) - foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage.Page == 0x01 && + modePage.Subpage == 0x00)) currentModePage = modePage; } @@ -211,17 +212,15 @@ partial class Dump _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else - { runningPersistent = true; - } } InitProgress?.Invoke(); - cdRepeatRetry: - ulong[] tmpArray = _resume.BadBlocks.ToArray(); - List sectorsNotEvenPartial = new List(); + cdRepeatRetry: + ulong[] tmpArray = _resume.BadBlocks.ToArray(); + var sectorsNotEvenPartial = new List(); - for(int i = 0; i < tmpArray.Length; i++) + for(var i = 0; i < tmpArray.Length; i++) { ulong badSector = tmpArray[i]; @@ -237,20 +236,17 @@ partial class Dump forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : "")); - Track track = tracks.OrderBy(t => t.StartSector). - LastOrDefault(t => badSector >= t.StartSector); + Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); byte sectorsToReRead = 1; - uint badSectorToReRead = (uint)badSector; + var badSectorToReRead = (uint)badSector; if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0) { if(offsetBytes > 0) - { badSectorToReRead -= (uint)sectorsForOffset; - } sectorsToReRead = (byte)(sectorsForOffset + 1); } @@ -275,13 +271,13 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) || + if(decSense?.ASC == 0x11 && decSense?.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, out double cmdDuration2); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, + true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + out double cmdDuration2); cmdDuration += cmdDuration2; } @@ -290,16 +286,15 @@ 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); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); if(sense) { DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) || + if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || decSense?.ASC == 0x64) { sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead, @@ -337,8 +332,8 @@ 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 && @@ -355,8 +350,8 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); @@ -365,16 +360,20 @@ 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, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true); + 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); // Set tracks and go back if(!indexesChanged) continue; - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i--; } else @@ -448,7 +447,7 @@ partial class Dump InitProgress?.Invoke(); - for(int i = 0; i < sectorsNotEvenPartial.Count; i++) + for(var i = 0; i < sectorsNotEvenPartial.Count; i++) { ulong badSector = sectorsNotEvenPartial[i]; @@ -462,8 +461,7 @@ partial class Dump PulseProgress?.Invoke($"Trying to get partial data for sector {badSector}"); - Track track = tracks.OrderBy(t => t.StartSector). - LastOrDefault(t => badSector >= t.StartSector); + Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); if(readcd) { @@ -486,8 +484,8 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); @@ -497,15 +495,14 @@ 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); + desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.Sequence, ref mcn, + tracks, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, + _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true); // Set tracks and go back if(indexesChanged) { - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i--; } } @@ -563,7 +560,7 @@ partial class Dump Dictionary isrcs, ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) { - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration; // Command execution time byte[] senseBuf = null; // Sense buffer @@ -601,12 +598,12 @@ partial class Dump if(_aborted) return; - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; InitProgress?.Invoke(); - cdRepeatRetry: + cdRepeatRetry: _resume.BadSubchannels = new List(); _resume.BadSubchannels.AddRange(subchannelExtents); @@ -619,10 +616,9 @@ partial class Dump foreach(int bs in tmpArray) { - uint badSector = (uint)bs; + var badSector = (uint)bs; - Track track = tracks.OrderBy(t => t.StartSector). - LastOrDefault(t => badSector >= t.StartSector); + Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); if(_aborted) { @@ -646,9 +642,9 @@ partial class Dump else if(readcd) { 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); + track.Type == TrackType.Audio ? MmcSectorTypes.Cdda : MmcSectorTypes.AllTypes, + false, false, false, MmcHeaderCodes.None, false, false, MmcErrorField.None, + supportedSubchannel, _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index 15372aa79..d4a3e7306 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -41,12 +49,6 @@ using Aaru.Core.Logging; using Aaru.Devices; using Schemas; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Dumps inter-session lead-outs @@ -76,16 +78,16 @@ partial class Dump /// List of subchannels not yet dumped correctly /// List of smallest pregap relative address per track void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents, - IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, - ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, - bool read12, bool read16, bool readcd, MmcSubchannel supportedSubchannel, uint subSize, - ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, - Dictionary isrcs, ref string mcn, Track[] tracks, - HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) + IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed, + MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16, + bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration, + SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary isrcs, + ref string mcn, Track[] tracks, HashSet subchannelExtents, + Dictionary smallestPregapLbaPerTrack) { byte[] cmdBuf = null; // Data buffer const uint sectorSize = 2352; // Full sector size - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] senseBuf = null; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -119,9 +121,9 @@ partial class Dump 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; } @@ -129,14 +131,13 @@ partial class Dump 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); + sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration); if(!sense && !_dev.Error) @@ -149,14 +150,14 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * _maximumReadable]; - byte[] sub = new byte[subSize * _maximumReadable]; + var data = new byte[sectorSize * _maximumReadable]; + var sub = new byte[subSize * _maximumReadable]; - for(int b = 0; b < _maximumReadable; b++) + for(var b = 0; b < _maximumReadable; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); - Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize); + Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } outputOptical.WriteSectorsLong(data, i, _maximumReadable); @@ -169,7 +170,7 @@ partial class Dump // Set tracks and go back if(indexesChanged) { - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i--; continue; @@ -246,16 +247,16 @@ partial class Dump /// List of subchannels not yet dumped correctly /// List of smallest pregap relative address per track void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardwareType currentTry, ExtentsULong extents, - IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, - ref double maxSpeed, MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, - bool read12, bool read16, bool readcd, MmcSubchannel supportedSubchannel, uint subSize, - ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, - Dictionary isrcs, ref string mcn, Track[] tracks, - HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) + IbgLog ibgLog, ref double imageWriteDuration, ExtentsULong leadOutExtents, ref double maxSpeed, + MhddLog mhddLog, ref double minSpeed, bool read6, bool read10, bool read12, bool read16, + bool readcd, MmcSubchannel supportedSubchannel, uint subSize, ref double totalDuration, + SubchannelLog subLog, MmcSubchannel desiredSubchannel, Dictionary isrcs, + ref string mcn, Track[] tracks, HashSet subchannelExtents, + Dictionary smallestPregapLbaPerTrack) { byte[] cmdBuf = null; // Data buffer const uint sectorSize = 2352; // Full sector size - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] senseBuf = null; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -288,9 +289,9 @@ partial class Dump 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; } @@ -298,14 +299,13 @@ partial class Dump 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); + sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration); if(!sense && !_dev.Error) @@ -318,14 +318,14 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * _maximumReadable]; - byte[] sub = new byte[subSize * _maximumReadable]; + var data = new byte[sectorSize * _maximumReadable]; + var sub = new byte[subSize * _maximumReadable]; - for(int b = 0; b < _maximumReadable; b++) + for(var b = 0; b < _maximumReadable; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); - Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize); + Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } outputOptical.WriteSectorsLong(data, i, _maximumReadable); @@ -338,7 +338,7 @@ partial class Dump // Set tracks and go back if(indexesChanged) { - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); i--; continue; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs index e80f61e76..6b2b75f5e 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs @@ -30,8 +30,7 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using Aaru.Devices; + // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable InlineOutVariableDeclaration @@ -39,6 +38,9 @@ using Aaru.Devices; namespace Aaru.Core.Devices.Dumping; +using System; +using Aaru.Devices; + partial class Dump { /// Fix offset in audio/scrambled sectors @@ -51,27 +53,27 @@ partial class Dump /// Data buffer /// Block size in bytes /// Set if we failed to cross into the Lead-Out - static void FixOffsetData(int offsetBytes, uint sectorSize, int sectorsForOffset, - MmcSubchannel supportedSubchannel, ref uint blocksToRead, uint subSize, - ref byte[] cmdBuf, uint blockSize, bool failedCrossingLeadOut) + static void FixOffsetData(int offsetBytes, uint sectorSize, int sectorsForOffset, MmcSubchannel supportedSubchannel, + ref uint blocksToRead, uint subSize, ref byte[] cmdBuf, uint blockSize, + bool failedCrossingLeadOut) { if(cmdBuf.Length == 0) return; - int offsetFix = offsetBytes < 0 ? (int)((sectorSize * sectorsForOffset) + offsetBytes) : offsetBytes; + int offsetFix = offsetBytes < 0 ? (int)(sectorSize * sectorsForOffset + offsetBytes) : offsetBytes; byte[] tmpBuf; if(supportedSubchannel != MmcSubchannel.None) { // De-interleave subchannel - byte[] data = new byte[sectorSize * blocksToRead]; - byte[] sub = new byte[subSize * blocksToRead]; + var data = new byte[sectorSize * blocksToRead]; + var sub = new byte[subSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { - Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize); - Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize); + Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); + Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } if(failedCrossingLeadOut) @@ -95,10 +97,10 @@ partial class Dump // Re-interleave subchannel cmdBuf = new byte[blockSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { - Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)), sectorSize); - Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + (b * blockSize)), subSize); + Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + b * blockSize), sectorSize); + Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + b * blockSize), subSize); } } else diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs index 5b433deab..cbfb82cff 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using Aaru.Devices; -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Reads a sector using Plextor's D8h READ CDDA command with subchannel @@ -102,12 +102,12 @@ partial class Dump if(sense) return true; - cmdBuf = new byte[(2352 * blocksToRead) + (subSize * blocksToRead)]; + cmdBuf = new byte[2352 * blocksToRead + subSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(dataBuf, 2352 * b, cmdBuf, (2352 + subSize) * b, 2352); - Array.Copy(subBuf, subSize * b, cmdBuf, ((2352 + subSize) * b) + 2352, subSize); + Array.Copy(subBuf, subSize * b, cmdBuf, (2352 + subSize) * b + 2352, subSize); } return false; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs index 19f279853..60dc2d205 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -42,12 +50,6 @@ using Aaru.Console; using Aaru.Core.Logging; using Aaru.Devices; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { // TODO: Fix offset @@ -65,8 +67,8 @@ partial class Dump double cmdDuration; // Command execution time DateTime timeSpeedStart; // Time of start for speed calculation ulong sectorSpeedStart = 0; // Used to calculate correct speed - bool gotFirstTrackPregap = false; - int firstTrackPregapSectorsGood = 0; + var gotFirstTrackPregap = false; + var firstTrackPregapSectorsGood = 0; var firstTrackPregapMs = new MemoryStream(); _dumpLog.WriteLine("Reading first track pregap"); @@ -89,9 +91,9 @@ partial class Dump Invoke($"Trying to read first track pregap sector {firstTrackPregapBlock} ({currentSpeed:F3} MiB/sec.)"); // 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 @@ -142,17 +144,17 @@ partial class Dump /// Database entry for device /// Set if we found the drive does not return the exact subchannel we requested /// Set if dumping, otherwise media info - public static void SolveTrackPregaps(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus, - Track[] tracks, bool supportsPqSubchannel, bool supportsRwSubchannel, + public static void SolveTrackPregaps(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus, Track[] tracks, + bool supportsPqSubchannel, bool supportsRwSubchannel, Database.Models.Device dbDev, out bool inexactPositioning, bool dumping) { - bool sense = true; // Sense indicator - byte[] subBuf = null; - int posQ; - uint retries; - bool? bcd = null; - byte[] crc; - Dictionary pregaps = new Dictionary(); + var sense = true; // Sense indicator + byte[] subBuf = null; + int posQ; + uint retries; + bool? bcd = null; + byte[] crc; + var pregaps = new Dictionary(); inexactPositioning = false; if(!supportsPqSubchannel && @@ -193,14 +195,14 @@ partial class Dump foreach(Track t in tracks) pregaps[t.Sequence] = 0; - for(int t = 0; t < tracks.Length; t++) + for(var t = 0; t < tracks.Length; t++) { Track track = tracks[t]; - int trackRetries = 0; + var trackRetries = 0; // First track of each session has at least 150 sectors of pregap and is not always readable - if(tracks.Where(trk => trk.Session == track.Session).OrderBy(trk => trk.Sequence). - FirstOrDefault().Sequence == track.Sequence) + if(tracks.Where(trk => trk.Session == track.Session).OrderBy(trk => trk.Sequence).FirstOrDefault(). + Sequence == track.Sequence) { AaruConsole.DebugWriteLine("Pregap calculator", "Skipping track {0}", track.Sequence); @@ -230,27 +232,26 @@ partial class Dump AaruConsole.DebugWriteLine("Pregap calculator", "Track {0}", track.Sequence); int lba = (int)track.StartSector - 1; - bool pregapFound = false; + var pregapFound = false; Track previousTrack = tracks.FirstOrDefault(trk => trk.Sequence == track.Sequence - 1); - bool goneBack = false; - bool goFront = false; - bool forward = false; - bool crcOk = false; - bool previousPregapIsPreviousTrack = false; + var goneBack = false; + var goFront = false; + var forward = false; + var crcOk = false; + var previousPregapIsPreviousTrack = false; // Check if pregap is 0 for(retries = 0; retries < 10 && !pregapFound; retries++) { sense = supportsRwSubchannel - ? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf, - track.Type == TrackType.Audio) - : GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio); + ? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf, track.Type == TrackType.Audio) + : GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio); if(sense) { - AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba, - retries + 1, sense); + AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba, retries + 1, + sense); continue; } @@ -263,8 +264,8 @@ partial class Dump AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}", 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]); + 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]; @@ -285,7 +286,7 @@ partial class Dump subBuf[6] = 0; // Fix BCD numbering - for(int i = 1; i < 10; i++) + for(var i = 1; i < 10; i++) { if((subBuf[i] & 0xF0) > 0xA0) subBuf[i] &= 0x7F; @@ -300,13 +301,11 @@ partial class Dump crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11]; if(crcOk) - { AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}", - 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]); - } + 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; } @@ -317,7 +316,7 @@ partial class Dump if((subBuf[0] & 0xF) != 1) continue; - posQ = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150; + posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150; if(subBuf[1] != track.Sequence - 1 || subBuf[2] == 0 || @@ -343,16 +342,14 @@ partial class Dump sense = supportsRwSubchannel ? GetSectorForPregapRaw(dev, (uint)lba - 10, dbDev, out subBuf, track.Type == TrackType.Audio) - : GetSectorForPregapQ16(dev, (uint)lba - 10, out subBuf, - track.Type == TrackType.Audio); + : GetSectorForPregapQ16(dev, (uint)lba - 10, out subBuf, track.Type == TrackType.Audio); for(retries = 0; retries < 10; retries++) { sense = supportsRwSubchannel ? GetSectorForPregapRaw(dev, (uint)lba, dbDev, out subBuf, track.Type == TrackType.Audio) - : GetSectorForPregapQ16(dev, (uint)lba, out subBuf, - track.Type == TrackType.Audio); + : GetSectorForPregapQ16(dev, (uint)lba, out subBuf, track.Type == TrackType.Audio); if(sense) continue; @@ -387,7 +384,7 @@ partial class Dump subBuf[6] = 0; // Fix BCD numbering - for(int i = 1; i < 10; i++) + for(var i = 1; i < 10; i++) { if((subBuf[i] & 0xF0) > 0xA0) subBuf[i] &= 0x7F; @@ -406,9 +403,8 @@ partial class Dump AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}", 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]); + subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], + subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]); break; } @@ -428,10 +424,8 @@ partial class Dump { if(pregaps[track.Sequence] == 0) { - if((previousTrack.Type == TrackType.Audio && - track.Type != TrackType.Audio) || - (previousTrack.Type != TrackType.Audio && - track.Type == TrackType.Audio)) + if(previousTrack.Type == TrackType.Audio && track.Type != TrackType.Audio || + previousTrack.Type != TrackType.Audio && track.Type == TrackType.Audio) { dumpLog?. WriteLine("Could not read subchannel for this track, supposing 150 sectors."); @@ -537,7 +531,7 @@ partial class Dump previousPregapIsPreviousTrack = false; // Pregap according to Q position - posQ = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150; + posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150; int diff = posQ - lba; int pregapQ = (int)track.StartSector - lba; @@ -566,8 +560,8 @@ 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 calculator", "Pregap for track {0}: {1}", - track.Sequence, pregapQ); + AaruConsole.DebugWriteLine("Pregap calculator", "Pregap for track {0}: {1}", track.Sequence, + pregapQ); pregaps[track.Sequence] = pregapQ; } @@ -593,14 +587,14 @@ 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).OrderBy(t => t.Sequence).FirstOrDefault(). - Sequence == trk.Sequence) + if(tracks.Where(t => t.Session == trk.Session).OrderBy(t => t.Sequence).FirstOrDefault().Sequence == + trk.Sequence) continue; if(dumping) { // Minus five, to ensure dumping will fix if there is a pregap LBA 0 - int red = 5; + var red = 5; while(trk.Pregap > 0 && red > 0) @@ -652,21 +646,21 @@ partial class Dump 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, out _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + out _); } if(!sense) { - byte[] tmpBuf = new byte[96]; + var tmpBuf = new byte[96]; Array.Copy(cmdBuf, 2352, tmpBuf, 0, 96); subBuf = DeinterleaveQ(tmpBuf); } 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, out _); + 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, @@ -674,14 +668,11 @@ partial class Dump dev.Timeout, out _); if(!sense) - { subBuf = DeinterleaveQ(cmdBuf); - } else if(dbDev?.ATAPI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true || dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true || dev.Manufacturer.ToLowerInvariant() == "plextor") - sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout, - out _); + sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout, out _); { if(!sense) @@ -723,8 +714,8 @@ partial class Dump 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, out _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout, + out _); } if(!sense) @@ -735,8 +726,8 @@ 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, out _); + 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, @@ -755,10 +746,10 @@ partial class Dump /// De-interleaved Q subchannel static byte[] DeinterleaveQ(byte[] subchannel) { - int[] q = new int[subchannel.Length / 8]; + var q = new int[subchannel.Length / 8]; // De-interlace Q subchannel - for(int iq = 0; iq < subchannel.Length; iq += 8) + for(var iq = 0; iq < subchannel.Length; iq += 8) { q[iq / 8] = (subchannel[iq] & 0x40) << 1; q[iq / 8] += subchannel[iq + 1] & 0x40; @@ -770,12 +761,10 @@ partial class Dump q[iq / 8] += (subchannel[iq + 7] & 0x40) >> 6; } - byte[] deQ = new byte[q.Length]; + var deQ = new byte[q.Length]; - for(int iq = 0; iq < q.Length; iq++) - { + for(var iq = 0; iq < q.Length; iq++) deQ[iq] = (byte)q[iq]; - } return deQ; } @@ -784,29 +773,29 @@ partial class Dump /// Q subchannel static void BinaryToBcdQ(byte[] q) { - q[1] = (byte)(((q[1] / 10) << 4) + (q[1] % 10)); - q[2] = (byte)(((q[2] / 10) << 4) + (q[2] % 10)); - q[3] = (byte)(((q[3] / 10) << 4) + (q[3] % 10)); - q[4] = (byte)(((q[4] / 10) << 4) + (q[4] % 10)); - q[5] = (byte)(((q[5] / 10) << 4) + (q[5] % 10)); - q[6] = (byte)(((q[6] / 10) << 4) + (q[6] % 10)); - q[7] = (byte)(((q[7] / 10) << 4) + (q[7] % 10)); - q[8] = (byte)(((q[8] / 10) << 4) + (q[8] % 10)); - q[9] = (byte)(((q[9] / 10) << 4) + (q[9] % 10)); + q[1] = (byte)(((q[1] / 10) << 4) + q[1] % 10); + q[2] = (byte)(((q[2] / 10) << 4) + q[2] % 10); + q[3] = (byte)(((q[3] / 10) << 4) + q[3] % 10); + q[4] = (byte)(((q[4] / 10) << 4) + q[4] % 10); + q[5] = (byte)(((q[5] / 10) << 4) + q[5] % 10); + q[6] = (byte)(((q[6] / 10) << 4) + q[6] % 10); + q[7] = (byte)(((q[7] / 10) << 4) + q[7] % 10); + q[8] = (byte)(((q[8] / 10) << 4) + q[8] % 10); + q[9] = (byte)(((q[9] / 10) << 4) + q[9] % 10); } /// In place converts Q subchannel from BCD to binary numbering /// Q subchannel static void BcdToBinaryQ(byte[] q) { - q[1] = (byte)((q[1] / 16 * 10) + (q[1] & 0x0F)); - q[2] = (byte)((q[2] / 16 * 10) + (q[2] & 0x0F)); - q[3] = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F)); - q[4] = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F)); - q[5] = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F)); - q[6] = (byte)((q[6] / 16 * 10) + (q[6] & 0x0F)); - q[7] = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F)); - q[8] = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F)); - q[9] = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + q[1] = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F)); + q[2] = (byte)(q[2] / 16 * 10 + (q[2] & 0x0F)); + q[3] = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + q[4] = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + q[5] = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + q[6] = (byte)(q[6] / 16 * 10 + (q[6] & 0x0F)); + q[7] = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + q[8] = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + q[9] = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); } } \ No newline at end of file diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs index f15313215..80f9607d5 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs @@ -30,9 +30,7 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; -using Aaru.Core.Logging; -using Aaru.Devices; + // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable InlineOutVariableDeclaration @@ -40,6 +38,10 @@ using Aaru.Devices; namespace Aaru.Core.Devices.Dumping; +using Aaru.CommonTypes; +using Aaru.Core.Logging; +using Aaru.Devices; + partial class Dump { /// Check if the drive can read RW raw subchannel @@ -54,8 +56,8 @@ partial class Dump updateStatus?.Invoke("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, out _); + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout, + out _); } /// Check if the drive can read RW raw subchannel @@ -70,7 +72,7 @@ partial class Dump updateStatus?.Invoke("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, out _); + 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 2545878f9..e278b3705 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Tags.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -38,12 +46,6 @@ using Aaru.Decoders.CD; using Aaru.Decoders.SCSI.MMC; using Aaru.Devices; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Reads media tags from Compact Disc media @@ -83,8 +85,8 @@ partial class Dump _dumpLog.WriteLine("Reading Disc Information"); UpdateStatus?.Invoke("Reading Disc Information"); - sense = _dev.ReadDiscInformation(out cmdBuf, out _, MmcDiscInformationDataTypes.DiscInformation, - _dev.Timeout, out _); + sense = _dev.ReadDiscInformation(out cmdBuf, out _, MmcDiscInformationDataTypes.DiscInformation, _dev.Timeout, + out _); if(!sense) { diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs index 0392d520d..6c7f55c3c 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -40,12 +48,6 @@ using Aaru.Core.Logging; using Aaru.Decoders.CD; using Aaru.Devices; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Reads the TOC, processes it, returns the track list and last sector @@ -61,16 +63,15 @@ partial class Dump /// Update status handler /// List of tracks public static Track[] GetCdTracks(Device dev, DumpLog dumpLog, bool force, out long lastSector, - Dictionary leadOutStarts, - Dictionary mediaTags, + Dictionary leadOutStarts, Dictionary mediaTags, ErrorMessageHandler stoppingErrorMessage, out FullTOC.CDFullTOC? toc, Dictionary trackFlags, UpdateStatusHandler updateStatus) { - byte[] cmdBuf; // Data buffer - const uint sectorSize = 2352; // Full sector size - bool sense; // Sense indicator - List trackList = new List(); // Tracks in disc - byte[] tmpBuf; // Temporary buffer + byte[] cmdBuf; // Data buffer + const uint sectorSize = 2352; // Full sector size + bool sense; // Sense indicator + var trackList = new List(); // Tracks in disc + byte[] tmpBuf; // Temporary buffer toc = null; lastSector = 0; TrackType leadoutTrackType = TrackType.Audio; @@ -110,11 +111,10 @@ partial class Dump Sequence = trk.POINT, Session = trk.SessionNumber, Type = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack || - (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental - ? TrackType.Data : TrackType.Audio, + (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data + : TrackType.Audio, StartSector = - (ulong)((trk.PHOUR * 3600 * 75) + (trk.PMIN * 60 * 75) + (trk.PSEC * 75) + trk.PFRAME - - 150), + (ulong)(trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME - 150), BytesPerSector = (int)sectorSize, RawBytesPerSector = (int)sectorSize }); @@ -159,17 +159,15 @@ partial class Dump phour = trk.PHOUR; } - lastSector = (phour * 3600 * 75) + (pmin * 60 * 75) + (psec * 75) + pframe - 150; + lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150; leadOutStarts?.Add(trk.SessionNumber, lastSector + 1); } else if(trk.POINT == 0xA0 && trk.ADR == 1) - { leadoutTrackType = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data : TrackType.Audio; - } } else { @@ -191,8 +189,7 @@ partial class Dump } if(oldToc.HasValue) - foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors. - OrderBy(t => t.TrackNumber). + foreach(TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.OrderBy(t => t.TrackNumber). Where(trk => trk.ADR == 1 || trk.ADR == 4)) if(trk.TrackNumber >= 0x01 && trk.TrackNumber <= 0x63) @@ -202,8 +199,8 @@ partial class Dump Sequence = trk.TrackNumber, Session = 1, Type = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack || - (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental - ? TrackType.Data : TrackType.Audio, + (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data + : TrackType.Audio, StartSector = trk.TrackStartAddress, BytesPerSector = (int)sectorSize, RawBytesPerSector = (int)sectorSize @@ -247,7 +244,7 @@ partial class Dump if(!sense) { - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index 4dcadf4df..9200b331b 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -42,12 +50,6 @@ using Aaru.Decoders.SCSI; using Aaru.Devices; using Schemas; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Trims errored sectors in a CompactDisc @@ -74,17 +76,16 @@ partial class Dump /// Disc media catalogue number /// List of subchannels not yet dumped correctly /// List of smallest pregap relative address per track - void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, - ExtentsULong extents, bool newTrim, int offsetBytes, bool read6, bool read10, bool read12, - bool read16, bool readcd, int sectorsForOffset, uint subSize, - MmcSubchannel supportedSubchannel, bool supportsLongSectors, ref double totalDuration, - SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks, + void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry, ExtentsULong extents, + bool newTrim, int offsetBytes, bool read6, bool read10, bool read12, bool read16, bool readcd, + int sectorsForOffset, uint subSize, MmcSubchannel supportedSubchannel, bool supportsLongSectors, + ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary isrcs, ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) { DateTime start; DateTime end; - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration = 0; // Command execution time const uint sectorSize = 2352; // Full sector size @@ -123,10 +124,10 @@ partial class Dump _dumpLog.WriteLine("Trimming skipped sectors"); InitProgress?.Invoke(); - trimStart: + trimStart: ulong[] tmpArray = _resume.BadBlocks.ToArray(); - for(int b = 0; b < tmpArray.Length; b++) + for(var b = 0; b < tmpArray.Length; b++) { ulong badSector = tmpArray[b]; @@ -141,29 +142,26 @@ partial class Dump PulseProgress?.Invoke($"Trimming sector {badSector}"); - Track track = tracks.OrderBy(t => t.StartSector). - LastOrDefault(t => badSector >= t.StartSector); + Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); byte sectorsToTrim = 1; - uint badSectorToRead = (uint)badSector; + var badSectorToRead = (uint)badSector; if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0) { if(offsetBytes > 0) - { badSectorToRead -= (uint)sectorsForOffset; - } sectorsToTrim = (byte)(sectorsForOffset + 1); } - bool forceFixOffset = false; + var forceFixOffset = false; 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)) @@ -177,13 +175,13 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if((decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05) || + if(decSense?.ASC == 0x11 && decSense?.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, out double cmdDuration2); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, + true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, + out double cmdDuration2); cmdDuration += cmdDuration2; } @@ -192,9 +190,8 @@ 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); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration); if(sense) { @@ -219,14 +216,14 @@ partial class Dump 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, out cmdDuration); + sense = _dev.Read6(out cmdBuf, out senseBuf, badSectorToRead, blockSize, sectorsToTrim, _dev.Timeout, + out cmdDuration); totalDuration += cmdDuration; @@ -251,14 +248,14 @@ 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) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); @@ -269,16 +266,20 @@ 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, subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true); + 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); // Set tracks and go back if(!indexesChanged) continue; - (outputOptical as IWritableOpticalImage).SetTracks(tracks.ToList()); + outputOptical.SetTracks(tracks.ToList()); if(track.StartSector != trkStartBefore && !_resume.BadBlocks.Contains(track.StartSector)) diff --git a/Aaru.Core/Devices/Dumping/Dump.cs b/Aaru.Core/Devices/Dumping/Dump.cs index ce4b9652b..17c3692a0 100644 --- a/Aaru.Core/Devices/Dumping/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Dump.cs @@ -31,6 +31,8 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -44,10 +46,9 @@ using Aaru.CommonTypes.Metadata; using Aaru.Core.Logging; using Aaru.Database; using Aaru.Devices; +using Aaru.Settings; using Schemas; -namespace Aaru.Core.Devices.Dumping; - /// Subchannel requested to dump public enum DumpSubchannel { @@ -93,7 +94,6 @@ public partial class Dump readonly DumpSubchannel _subchannel; readonly bool _titleKeys; readonly bool _trim; - bool _useBufferedReads; bool _aborted; AaruContext _ctx; // Main database context Database.Models.Device _dbDev; // Device database entry @@ -107,6 +107,7 @@ public partial class Dump int _speed; int _speedMultiplier; bool _supportsPlextorD8; + bool _useBufferedReads; /// Initializes dumpers /// Should resume? @@ -201,7 +202,7 @@ public partial class Dump public void Start() { // Open main database - _ctx = AaruContext.Create(Settings.Settings.MainDbPath); + _ctx = AaruContext.Create(Settings.MainDbPath); // Search for device in main database _dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model && @@ -225,10 +226,12 @@ public partial class Dump switch(_dev.IsUsb) { - case true when _dev.UsbVendorId == 0x054C && _dev.UsbProductId is 0x01C8 or 0x01C9 or 0x02D2: PlayStationPortable(); + case true when _dev.UsbVendorId == 0x054C && _dev.UsbProductId is 0x01C8 or 0x01C9 or 0x02D2: + PlayStationPortable(); break; - case true when _dev.UsbVendorId ==0x0403 && _dev.UsbProductId ==0x97C1: Retrode(); + case true when _dev.UsbVendorId == 0x0403 && _dev.UsbProductId == 0x97C1: + Retrode(); break; default: diff --git a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs index 77018e593..67638df27 100644 --- a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs +++ b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs @@ -30,15 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Devices.Dumping; - public partial class Dump { static readonly byte[] _sfcExtension = @@ -90,7 +91,7 @@ public partial class Dump return; } - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(buffer, 0x36, tmp, 0, 8); @@ -103,11 +104,11 @@ public partial class Dump return; } - ushort fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); - ushort sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); - ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart); - ushort rootSize = (ushort)(((buffer[0x12] << 8) + buffer[0x11]) * 32 / 512); - byte sectorsPerCluster = buffer[0x0D]; + var fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); + var sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); + var rootStart = (ushort)(sectorsPerFat * 2 + fatStart); + var rootSize = (ushort)(((buffer[0x12] << 8) + buffer[0x11]) * 32 / 512); + byte sectorsPerCluster = buffer[0x0D]; UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}..."); _dumpLog.WriteLine("Reading root directory in sector {0}...", rootStart); @@ -122,14 +123,14 @@ public partial class Dump return; } - int romPos; - bool sfcFound = false; - bool genesisFound = false; - bool smsFound = false; - bool n64Found = false; - bool gbFound = false; - bool gbcFound = false; - bool gbaFound = false; + int romPos; + var sfcFound = false; + var genesisFound = false; + var smsFound = false; + var n64Found = false; + var gbFound = false; + var gbcFound = false; + var gbaFound = false; tmp = new byte[3]; for(romPos = 0; romPos < buffer.Length; romPos += 0x20) @@ -197,8 +198,8 @@ public partial class Dump return; } - ushort cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A); - uint romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C); + var cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A); + var romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C); MediaType mediaType = gbaFound ? MediaType.GameBoyAdvanceGamePak @@ -239,7 +240,7 @@ public partial class Dump return; } - uint startSector = (uint)(rootStart + rootSize + ((cluster - 2) * sectorsPerCluster)); + var startSector = (uint)(rootStart + rootSize + (cluster - 2) * sectorsPerCluster); uint romSectors = romSize / 512; uint romRemaining = romSize % 512; @@ -393,7 +394,7 @@ public partial class Dump _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", 512 * (double)(romSectors + 1) / 1024 / imageWriteDuration); - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index 817ffa25a..d0795045f 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -31,6 +31,12 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -43,17 +49,13 @@ using Aaru.Decoders.SCSI.MMC; using Aaru.Decryption; using Aaru.Decryption.DVD; using Aaru.Devices; +using Aaru.Settings; using Schemas; using DDS = Aaru.Decoders.DVD.DDS; using DMI = Aaru.Decoders.Xbox.DMI; -using DVDDecryption = Aaru.Decryption.DVD.Dump; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; using Spare = Aaru.Decoders.DVD.Spare; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - /// Implement dumping optical discs from MultiMedia devices partial class Dump { @@ -63,15 +65,14 @@ partial class Dump MediaType dskType = MediaType.Unknown; bool sense; byte[] tmpBuf; - bool compactDisc = true; - bool gotConfiguration = false; - bool isXbox = false; + var compactDisc = true; + var gotConfiguration = false; + var isXbox = false; DVDDecryption dvdDecrypt = null; _speedMultiplier = 1; // TODO: Log not only what is it reading, but if it was read correctly or not. - sense = _dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, _dev.Timeout, - out _); + sense = _dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, _dev.Timeout, out _); if(!sense) { @@ -206,8 +207,7 @@ partial class Dump Modes.DecodedMode? decMode = null; - sense = _dev.ModeSense6(out cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout, - out _); + sense = _dev.ModeSense6(out cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout, out _); if(sense || _dev.Error) { @@ -228,8 +228,8 @@ partial class Dump 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) { @@ -281,7 +281,7 @@ partial class Dump var scsiReader = new Reader(_dev, _dev.Timeout, null, _errorLog, _dumpRaw); ulong blocks = scsiReader.GetDeviceBlocks(); _dumpLog.WriteLine("Device reports disc has {0} blocks", blocks); - Dictionary mediaTags = new Dictionary(); + var mediaTags = new Dictionary(); if(dskType == MediaType.PD650) switch(blocks + 1) @@ -323,8 +323,7 @@ partial class Dump { _dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented."); - StoppingErrorMessage?. - Invoke("Dumping Nintendo GameCube or Wii discs is not yet implemented."); + StoppingErrorMessage?.Invoke("Dumping Nintendo GameCube or Wii discs is not yet implemented."); return; } @@ -441,9 +440,7 @@ partial class Dump DMI.IsXbox360(cmdBuf)) { if(DMI.IsXbox(cmdBuf)) - { dskType = MediaType.XGD; - } else if(DMI.IsXbox360(cmdBuf)) { dskType = MediaType.XGD2; @@ -519,7 +516,7 @@ partial class Dump UpdateStatus?.Invoke("Drive reports no copy protection on disc."); else { - if(!Settings.Settings.Current.EnableDecryption) + if(!Settings.Current.EnableDecryption) UpdateStatus?.Invoke("Drive reports the disc uses copy protection. " + "The dump will be incorrect unless decryption is enabled."); else @@ -531,9 +528,8 @@ partial class Dump dvdDecrypt = new DVDDecryption(_dev); sense = dvdDecrypt.ReadBusKey(out cmdBuf, out _, - CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?. - CopyrightType ?? CopyrightType.NoProtection, - _dev.Timeout, out _); + CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ?? + CopyrightType.NoProtection, _dev.Timeout, out _); if(!sense) { @@ -546,12 +542,10 @@ 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("Disc and drive authentication succeeded."); @@ -566,22 +560,18 @@ partial class Dump CSS_CPRM.DecodeRegionalPlaybackControlState(cmdBuf); if(rpc.HasValue) - { UpdateStatus?.Invoke(CSS.CheckRegion(rpc.Value, cmi.Value) ? "Disc and drive regions match." : "Disc and drive regions do not match. The dump will be incorrect"); - } } if(decodedDiscKey.HasValue) { - mediaTags.Add(MediaTagType.DVD_DiscKey, - decodedDiscKey.Value.Key); + mediaTags.Add(MediaTagType.DVD_DiscKey, decodedDiscKey.Value.Key); UpdateStatus?.Invoke("Decrypting disc key."); - CSS.DecryptDiscKey(decodedDiscKey.Value.Key, - out byte[] discKey); + CSS.DecryptDiscKey(decodedDiscKey.Value.Key, out byte[] discKey); if(discKey != null) { @@ -592,16 +582,13 @@ partial class Dump UpdateStatus?.Invoke("Decryption of disc key failed."); } } - } } } } else - { UpdateStatus?. Invoke($"Drive reports disc uses {(CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ?? CopyrightType.NoProtection).ToString()} copy protection. " + "This is not yet supported and the dump will be incorrect."); - } } } } @@ -702,8 +689,7 @@ partial class Dump _dumpLog.WriteLine("Reading Recordable Physical Information."); sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout, - out _); + MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout, out _); if(!sense) { @@ -840,8 +826,7 @@ partial class Dump _dumpLog.WriteLine("Reading Spare Area Information."); sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout, - out _); + MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout, out _); if(!sense) { @@ -897,7 +882,7 @@ partial class Dump Checksums = Checksum.GetChecksums(tag).ToArray() }; - byte[] tmp = new byte[tag.Length + 4]; + var tmp = new byte[tag.Length + 4]; Array.Copy(tag, 0, tmp, 4, tag.Length); tmp[0] = (byte)((tag.Length & 0xFF00) >> 8); tmp[1] = (byte)(tag.Length & 0xFF); diff --git a/Aaru.Core/Devices/Dumping/Metadata.cs b/Aaru.Core/Devices/Dumping/Metadata.cs index 2fe54bc0f..c47535df6 100644 --- a/Aaru.Core/Devices/Dumping/Metadata.cs +++ b/Aaru.Core/Devices/Dumping/Metadata.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.CommonTypes.Metadata; using Schemas; using MediaType = Aaru.CommonTypes.MediaType; -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Creates optical metadata sidecar @@ -60,9 +60,9 @@ partial class Dump int? discOffset) { _dumpLog.WriteLine("Creating sidecar."); - var filters = new FiltersList(); - IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var filters = new FiltersList(); + IFilter filter = filters.GetFilter(_outputPath); + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; totalChkDuration = 0; ErrorNumber opened = inputPlugin.Open(filter); @@ -106,9 +106,9 @@ partial class Dump if(sidecar.OpticalDisc[0].Track != null) filesystems.AddRange(from xmlTrack in sidecar.OpticalDisc[0].Track - where xmlTrack.FileSystemInformation != null - from partition in xmlTrack.FileSystemInformation - where partition.FileSystems != null from fileSystem in partition.FileSystems + where xmlTrack.FileSystemInformation != null + from partition in xmlTrack.FileSystemInformation where partition.FileSystems != null + from fileSystem in partition.FileSystems select (partition.StartSector, fileSystem.Type)); if(filesystems.Count > 0) @@ -134,8 +134,8 @@ partial class Dump } 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); UpdateStatus?.Invoke("Writing metadata sidecar"); diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 38c3f4ad2..09de36201 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -40,6 +46,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Metadata; +using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Core.Logging; using Aaru.Decoders.SCSI; @@ -48,10 +55,6 @@ using Schemas; using MediaType = Aaru.CommonTypes.MediaType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping MiniDisc Data devices partial class Dump { @@ -256,7 +259,7 @@ partial class Dump if(decMode?.Pages != null) { - bool setGeometry = false; + var setGeometry = false; foreach(Modes.ModePage page in decMode.Value.Pages) if(page.Page == 0x04 && @@ -322,7 +325,7 @@ partial class Dump _dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock); } - bool newTrim = false; + var newTrim = false; DateTime timeSpeedStart = DateTime.UtcNow; ulong sectorSpeedStart = 0; InitProgress?.Invoke(); @@ -456,8 +459,7 @@ partial class Dump PulseProgress?.Invoke($"Trimming sector {badSector}"); - sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, - out double _); + sense = _dev.Read6(out readBuffer, out _, (uint)badSector, blockSize, 1, _dev.Timeout, out double _); if(sense || _dev.Error) continue; @@ -479,9 +481,9 @@ partial class Dump !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -568,15 +570,14 @@ partial class Dump AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf)); - _dumpLog. - WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); + _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else runningPersistent = true; } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -657,7 +658,7 @@ partial class Dump outputFormat.SetDumpHardware(_resume.Tries); - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -694,7 +695,7 @@ partial class Dump _dumpLog.WriteLine("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) @@ -739,8 +740,7 @@ partial class Dump if(sidecar.BlockMedia[0].FileSystemInformation != null) filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation - where partition.FileSystems != null - from fileSystem in partition.FileSystems + where partition.FileSystems != null from fileSystem in partition.FileSystems select (partition.StartSector, fileSystem.Type)); if(filesystems.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index 4e1f2b74a..7c510b8fc 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -42,6 +44,7 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Metadata; +using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Core.Logging; using Aaru.Decoders.SCSI; @@ -50,8 +53,6 @@ using Schemas; using MediaType = Aaru.CommonTypes.MediaType; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Devices.Dumping; - public partial class Dump { [SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")] @@ -81,7 +82,7 @@ public partial class Dump return; } - uint blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); + var blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); blocks++; @@ -168,7 +169,7 @@ public partial class Dump if(_resume.NextBlock > 0) _dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock); - bool newTrim = false; + var newTrim = false; DateTime timeSpeedStart = DateTime.UtcNow; ulong sectorSpeedStart = 0; @@ -330,9 +331,9 @@ public partial class Dump !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -434,15 +435,14 @@ public partial class Dump AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf)); - _dumpLog. - WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); + _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else runningPersistent = true; } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -523,7 +523,7 @@ public partial class Dump currentTry.Extents = ExtentsConverter.ToMetadata(extents); - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -562,7 +562,7 @@ public partial class Dump _dumpLog.WriteLine("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) @@ -607,8 +607,7 @@ public partial class Dump if(sidecar.BlockMedia[0].FileSystemInformation != null) filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation - where partition.FileSystems != null - from fileSystem in partition.FileSystems + where partition.FileSystems != null from fileSystem in partition.FileSystems select (partition.StartSector, fileSystem.Type)); if(filesystems.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs index 1cc05fad5..c78ae9b91 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Linq; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SCSI; using Aaru.Devices; -namespace Aaru.Core.Devices.Dumping; - public partial class Dump { static readonly byte[] _fatSignature = @@ -69,8 +69,8 @@ public partial class Dump UpdateStatus?.Invoke("Checking if media is UMD or MemoryStick..."); _dumpLog.WriteLine("Checking if media is UMD or MemoryStick..."); - bool sense = _dev.ModeSense6(out byte[] buffer, out _, false, ScsiModeSensePageControl.Current, 0, - _dev.Timeout, out _); + bool sense = _dev.ModeSense6(out byte[] buffer, out _, false, ScsiModeSensePageControl.Current, 0, _dev.Timeout, + out _); if(sense) { @@ -98,8 +98,7 @@ public partial class Dump return; } - sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false, _dev.Timeout, - out _); + sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false, _dev.Timeout, out _); if(sense) { @@ -109,7 +108,7 @@ public partial class Dump return; } - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(buffer, 0x36, tmp, 0, 8); @@ -121,15 +120,15 @@ public partial class Dump return; } - ushort fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); - ushort sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); - ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart); + var fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); + var sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); + var rootStart = (ushort)(sectorsPerFat * 2 + fatStart); UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}..."); _dumpLog.WriteLine("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, out _); + sense = _dev.Read12(out buffer, out _, 0, false, true, false, false, rootStart, 512, 0, 1, false, _dev.Timeout, + out _); if(sense) { @@ -155,7 +154,7 @@ public partial class Dump UpdateStatus?.Invoke("Reading FAT..."); _dumpLog.WriteLine("Reading FAT..."); - byte[] fat = new byte[sectorsPerFat * 512]; + var fat = new byte[sectorsPerFat * 512]; uint position = 0; @@ -166,8 +165,8 @@ public partial class Dump 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) { @@ -185,11 +184,11 @@ public partial class Dump UpdateStatus?.Invoke("Traversing FAT..."); _dumpLog.WriteLine("Traversing FAT..."); - ushort previousCluster = BitConverter.ToUInt16(fat, 4); + var previousCluster = BitConverter.ToUInt16(fat, 4); - for(int i = 3; i < fat.Length / 2; i++) + for(var i = 3; i < fat.Length / 2; i++) { - ushort nextCluster = BitConverter.ToUInt16(fat, i * 2); + var nextCluster = BitConverter.ToUInt16(fat, i * 2); if(nextCluster == previousCluster + 1) { diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index e601bfef2..5b39cfc21 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -48,8 +50,6 @@ using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Devices.Dumping; - public partial class Dump { [SuppressMessage("ReSharper", "JoinDeclarationAndInitializer")] @@ -78,11 +78,11 @@ public partial class Dump return; } - ushort fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]); - ushort sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]); - ushort rootStart = (ushort)((sectorsPerFat * 2) + fatStart); - ushort rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512); - ushort umdStart = (ushort)(rootStart + rootSize); + var fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]); + var sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]); + var rootStart = (ushort)(sectorsPerFat * 2 + fatStart); + var rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512); + var umdStart = (ushort)(rootStart + rootSize); UpdateStatus?.Invoke($"Reading root directory in sector {rootStart}..."); _dumpLog.WriteLine("Reading root directory in sector {0}...", rootStart); @@ -98,7 +98,7 @@ public partial class Dump return; } - uint umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C); + var umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C); ulong blocks = umdSizeInBytes / blockSize; string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim(); @@ -156,9 +156,9 @@ public partial class Dump start = DateTime.UtcNow; double imageWriteDuration = 0; - (outputOptical as IWritableOpticalImage)?.SetTracks(new List + outputOptical?.SetTracks(new List { - new Track + new() { BytesPerSector = (int)blockSize, EndSector = blocks - 1, @@ -188,7 +188,7 @@ public partial class Dump if(_resume.NextBlock > 0) _dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock); - bool newTrim = false; + var newTrim = false; DateTime timeSpeedStart = DateTime.UtcNow; ulong sectorSpeedStart = 0; @@ -219,9 +219,8 @@ public partial class Dump UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, (long)blocks); - 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); totalDuration += cmdDuration; @@ -325,8 +324,7 @@ public partial class Dump PulseProgress?.Invoke($"Trimming sector {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 _); + (uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout, out double _); if(sense || _dev.Error) { @@ -351,9 +349,9 @@ public partial class Dump !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -439,15 +437,14 @@ public partial class Dump AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf)); - _dumpLog. - WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); + _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else runningPersistent = true; } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -464,7 +461,7 @@ public partial class Dump Invoke($"Retrying sector {badSector}, pass {pass}, {(runningPersistent ? "recovering partial data, " : "")}{(forward ? "forward" : "reverse")}"); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, - (uint)(umdStart + (badSector * 4)), 512, 0, 4, false, _dev.Timeout, + (uint)(umdStart + badSector * 4), 512, 0, 4, false, _dev.Timeout, out double cmdDuration); totalDuration += cmdDuration; @@ -530,7 +527,7 @@ public partial class Dump currentTry.Extents = ExtentsConverter.ToMetadata(extents); - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion(), diff --git a/Aaru.Core/Devices/Dumping/ResumeSupport.cs b/Aaru.Core/Devices/Dumping/ResumeSupport.cs index 5d8a92797..c507f9111 100644 --- a/Aaru.Core/Devices/Dumping/ResumeSupport.cs +++ b/Aaru.Core/Devices/Dumping/ResumeSupport.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Extents; @@ -38,10 +40,8 @@ using Schemas; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Devices.Dumping; - /// Implements resume support -internal static class ResumeSupport +static class ResumeSupport { /// Process resume /// If drive is LBA @@ -64,9 +64,9 @@ internal static class ResumeSupport /// progress dump /// internal static void Process(bool isLba, bool removable, ulong blocks, string manufacturer, string model, - string serial, PlatformID platform, ref Resume resume, - ref DumpHardwareType currentTry, ref ExtentsULong extents, string firmware, - bool @private, bool force, bool isTape = false) + string serial, PlatformID platform, ref Resume resume, ref DumpHardwareType currentTry, + ref ExtentsULong extents, string firmware, bool @private, bool force, + bool isTape = false) { if(@private) serial = null; diff --git a/Aaru.Core/Devices/Dumping/SCSI.cs b/Aaru.Core/Devices/Dumping/SCSI.cs index cbdc0dd75..6dce98819 100644 --- a/Aaru.Core/Devices/Dumping/SCSI.cs +++ b/Aaru.Core/Devices/Dumping/SCSI.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Dumping; + using System; using System.Threading; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SCSI; -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping SCSI and ATAPI devices public partial class Dump { @@ -46,12 +46,12 @@ public partial class Dump /// Dumps a SCSI Block Commands device or a Reduced Block Commands devices void Scsi() { - int resets = 0; + var resets = 0; if(_dev.IsRemovable) { InitProgress?.Invoke(); - deviceGotReset: + deviceGotReset: bool sense = _dev.ScsiTestUnitReady(out byte[] senseBuf, _dev.Timeout, out _); if(sense) @@ -63,8 +63,8 @@ public partial class Dump ErrorMessage?. Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h"); - _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); // Just retry, for 5 times if(decSense.Value.ASC == 0x29) @@ -77,7 +77,7 @@ public partial class Dump if(decSense.Value.ASC == 0x3A) { - int leftRetries = 5; + var leftRetries = 5; while(leftRetries > 0) { @@ -96,8 +96,7 @@ public partial class Dump Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h"); _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, - decSense.Value.ASCQ); + decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); } leftRetries--; @@ -113,7 +112,7 @@ public partial class Dump else if(decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01) { - int leftRetries = 50; + var leftRetries = 50; while(leftRetries > 0) { @@ -132,8 +131,7 @@ public partial class Dump Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h"); _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, - decSense.Value.ASCQ); + decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); } leftRetries--; @@ -163,7 +161,7 @@ public partial class Dump // These should be trapped by the OS but seems in some cases they're not else if(decSense.Value.ASC == 0x28) { - int leftRetries = 10; + var leftRetries = 10; while(leftRetries > 0) { @@ -182,8 +180,7 @@ public partial class Dump Invoke($"Device not ready. Sense {decSense.Value.SenseKey} ASC {decSense.Value.ASC:X2}h ASCQ {decSense.Value.ASCQ:X2}h"); _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, - decSense.Value.ASCQ); + decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); } leftRetries--; @@ -199,8 +196,7 @@ public partial class Dump } else { - StoppingErrorMessage?. - Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}"); + StoppingErrorMessage?.Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}"); return; } @@ -237,8 +233,7 @@ public partial class Dump if(_outputPlugin is IWritableOpticalImage) Mmc(); else - StoppingErrorMessage?. - Invoke("The specified plugin does not support storing optical disc images."); + StoppingErrorMessage?.Invoke("The specified plugin does not support storing optical disc images."); return; case PeripheralDeviceTypes.BridgingExpander diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index cbe02c2d9..b06d1f90f 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -51,10 +57,6 @@ using Schemas; using MediaType = Aaru.CommonTypes.MediaType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// Dumps the tape from a SCSI Streaming device @@ -117,7 +119,7 @@ partial class Dump // And yet, did not rewind! if(decSense.HasValue && - ((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00) || + (decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00 || decSense.Value.ASC != 0x00)) { StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." + @@ -133,8 +135,7 @@ partial class Dump } // Check position - sense = _dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, - out duration); + sense = _dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration); if(sense) { @@ -143,8 +144,8 @@ partial class Dump decSense = Sense.Decode(senseBuf); if(decSense.HasValue && - ((decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00) || - (decSense.Value.ASC != 0x20 && decSense.Value.SenseKey != SenseKeys.IllegalRequest))) + (decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00 || decSense.Value.ASC != 0x20 && + decSense.Value.SenseKey != SenseKeys.IllegalRequest)) { StoppingErrorMessage?.Invoke("Could not get position. Sense follows..." + Environment.NewLine + decSense.Value.Description); @@ -194,7 +195,7 @@ partial class Dump // And yet, did not rewind! if(decSense.HasValue && - ((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00) || + (decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x04 && decSense.Value.ASCQ != 0x00 || decSense.Value.ASC != 0x00)) { StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." + @@ -202,14 +203,13 @@ partial class Dump _dumpLog.WriteLine("Drive could not rewind, please correct. Sense follows..."); - _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); return; } - sense = _dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, - out duration); + sense = _dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration); if(sense) { @@ -246,8 +246,8 @@ partial class Dump UpdateStatus?.Invoke("Requesting MODE SENSE (10)."); - sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0xFF, 5, out duration); + sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, + out duration); if(!sense || _dev.Error) @@ -267,8 +267,8 @@ partial class Dump out duration); if(sense || _dev.Error) - sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, - 5, out duration); + 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); @@ -322,15 +322,15 @@ partial class Dump _dumpLog.WriteLine("SCSI density type: {0}.", scsiDensityCodeTape); _dumpLog.WriteLine("Media identified as {0}.", dskType); - bool endOfMedia = false; + var endOfMedia = false; ulong currentBlock = 0; uint currentFile = 0; byte currentPartition = 0; byte totalPartitions = 1; // TODO: Handle partitions. - bool fixedLen = false; + var fixedLen = false; uint transferLen = blockSize; - firstRead: + firstRead: sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout, out duration); @@ -371,15 +371,15 @@ 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) { decSense = Sense.Decode(senseBuf); - StoppingErrorMessage?.Invoke("Drive could not read. Sense follows..." + - Environment.NewLine + decSense.Value.Description); + StoppingErrorMessage?.Invoke("Drive could not read. Sense follows..." + Environment.NewLine + + decSense.Value.Description); _dumpLog.WriteLine("Drive could not read. Sense follows..."); @@ -417,8 +417,7 @@ partial class Dump UpdateStatus?.Invoke($"Blocksize changed to {blockSize} bytes at block {currentBlock}"); _dumpLog.WriteLine("Blocksize changed to {0} bytes at block {1}", blockSize, currentBlock); - sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, - out duration); + sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration); totalDuration += duration; @@ -445,8 +444,8 @@ partial class Dump _dumpLog.WriteLine("Drive could not read. Sense follows..."); - _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); return; } @@ -457,8 +456,8 @@ partial class Dump _dumpLog.WriteLine("Drive could not read. Sense follows..."); - _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine("Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); return; } @@ -512,8 +511,8 @@ partial class Dump return; } - bool canLocateLong = false; - bool canLocate = false; + var canLocateLong = false; + var canLocate = false; UpdateStatus?.Invoke("Positioning tape to block 1."); _dumpLog.WriteLine("Positioning tape to block 1"); @@ -713,8 +712,7 @@ partial class Dump { if(!_force) { - _dumpLog. - WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force."); + _dumpLog.WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force."); StoppingErrorMessage?. Invoke("Cannot reposition tape, unable to resume. If you want to continue use force."); @@ -743,7 +741,7 @@ partial class Dump // And yet, did not rewind! if(decSense.HasValue && - ((decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x00 && decSense.Value.ASCQ != 0x04) || + (decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x00 && decSense.Value.ASCQ != 0x04 || decSense.Value.ASC != 0x00)) { StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." + @@ -809,9 +807,7 @@ partial class Dump currentBlock = _resume.NextBlock; currentTapeFile = - outputTape.Files.FirstOrDefault(f => f.LastBlock == - outputTape?. - Files.Max(g => g.LastBlock)); + outputTape.Files.FirstOrDefault(f => f.LastBlock == outputTape?.Files.Max(g => g.LastBlock)); currentTapePartition = outputTape.TapePartitions.FirstOrDefault(p => p.LastBlock == @@ -925,8 +921,7 @@ partial class Dump ili && valid) { - blockSize = (uint)((int)blockSize - - BitConverter.ToInt32(BitConverter.GetBytes(information), 0)); + blockSize = (uint)((int)blockSize - BitConverter.ToInt32(BitConverter.GetBytes(information), 0)); if(!fixedLen) transferLen = blockSize; @@ -968,8 +963,7 @@ partial class Dump // For sure this is an end-of-tape/partition case SenseKeys.BlankCheck when decSense.Value.ASC == 0x00 && - (decSense.Value.ASCQ == 0x02 || decSense.Value.ASCQ == 0x05 || - eom): + (decSense.Value.ASCQ == 0x02 || decSense.Value.ASCQ == 0x05 || eom): // TODO: Detect end of partition endOfMedia = true; UpdateStatus?.Invoke("Found end-of-tape/partition..."); @@ -1033,8 +1027,8 @@ partial class Dump _dumpLog.WriteLine($"Drive could not read block ${currentBlock}. Sense follows..."); - _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", - decSense.Value.SenseKey, decSense.Value.ASC, decSense.Value.ASCQ); + _dumpLog.WriteLine("Device not ready. Sense {0}h ASC {1:X2}h ASCQ {2:X2}h", decSense.Value.SenseKey, + decSense.Value.ASC, decSense.Value.ASCQ); } // TODO: Reset device after X errors @@ -1116,9 +1110,9 @@ partial class Dump _retryPasses > 0 && (canLocate || canLocateLong)) { - int pass = 1; - bool forward = false; - bool runningPersistent = false; + var pass = 1; + var forward = false; + var runningPersistent = false; Modes.ModePage? currentModePage = null; @@ -1128,7 +1122,7 @@ partial class Dump } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badBlock in tmpArray) @@ -1269,7 +1263,7 @@ partial class Dump outputTape.SetDumpHardware(_resume.Tries); // TODO: Media Serial Number - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -1314,7 +1308,7 @@ partial class Dump _dumpLog.WriteLine("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) @@ -1359,8 +1353,7 @@ partial class Dump if(sidecar.BlockMedia[0].FileSystemInformation != null) filesystems.AddRange(from partition in sidecar.BlockMedia[0].FileSystemInformation - where partition.FileSystems != null - from fileSystem in partition.FileSystems + where partition.FileSystems != null from fileSystem in partition.FileSystems select (partition.StartSector, fileSystem.Type)); if(filesystems.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index 5cde02fbf..9a990cc2f 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -25,6 +25,14 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Linq; using Aaru.CommonTypes.Enums; @@ -34,14 +42,8 @@ using Aaru.Core.Logging; using Aaru.Decoders.DVD; using Aaru.Decryption; using Aaru.Decryption.DVD; +using Aaru.Settings; using Schemas; -using DVDDecryption = Aaru.Decryption.DVD.Dump; - -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; partial class Dump { @@ -107,8 +109,8 @@ partial class Dump if(!sense && !_dev.Error) { - if(Settings.Settings.Current.EnableDecryption && - discKey != null && + if(Settings.Current.EnableDecryption && + discKey != null && _titleKeys) { for(ulong j = 0; j < blocksToRead; j++) @@ -195,8 +197,7 @@ partial class Dump ErrorMessage?.Invoke($"Error retrieving CMI for sector {i}"); else { - errno = outputFormat.ReadSectorsTag(i, blocksToRead, - SectorTagType.DvdTitleKeyDecrypted, + errno = outputFormat.ReadSectorsTag(i, blocksToRead, SectorTagType.DvdTitleKeyDecrypted, out byte[] titleKey); if(errno != ErrorNumber.NoError) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index 558a82720..02e65aed7 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -31,6 +31,12 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -50,17 +56,13 @@ using Aaru.Decoders.DVD; using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; using Aaru.Devices; +using Aaru.Settings; using Schemas; using DeviceReport = Aaru.Core.Devices.Report.DeviceReport; -using DVDDecryption = Aaru.Decryption.DVD.Dump; using MediaType = Aaru.CommonTypes.MediaType; using TrackType = Aaru.CommonTypes.Enums.TrackType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping SCSI Block Commands and Reduced Block Commands devices partial class Dump { @@ -75,7 +77,7 @@ partial class Dump bool sense; byte scsiMediumType = 0; byte scsiDensityCode = 0; - bool containsFloppyPage = false; + var containsFloppyPage = false; const ushort sbcProfile = 0x0001; DateTime start; DateTime end; @@ -132,8 +134,8 @@ partial class Dump _dumpLog.WriteLine("Requesting MODE SENSE (10)."); UpdateStatus?.Invoke("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) @@ -155,8 +157,8 @@ partial class Dump 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 _); @@ -179,8 +181,7 @@ partial class Dump // TODO: Fix this containsFloppyPage = decMode.Value.Pages?.Aggregate(containsFloppyPage, (current, modePage) => - current | (modePage.Page == 0x05)) == - true; + current | (modePage.Page == 0x05)) == true; } } } @@ -344,9 +345,9 @@ partial class Dump UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time."); _dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead); - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); - var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); - bool imageCreated = false; + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); + var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); + var imageCreated = false; if(!opticalDisc) { @@ -369,7 +370,7 @@ partial class Dump start = DateTime.UtcNow; double imageWriteDuration = 0; - bool writeSingleOpticalTrack = true; + var writeSingleOpticalTrack = true; if(opticalDisc) { @@ -380,8 +381,7 @@ partial class Dump if(!sense) { - DiscInformation.StandardDiscInformation? discInformation = - DiscInformation.Decode000b(readBuffer); + DiscInformation.StandardDiscInformation? discInformation = DiscInformation.Decode000b(readBuffer); // This means the output image can store sessions that are not on a CD, like on a DVD or Blu-ray bool canStoreNotCdSessions = @@ -537,9 +537,8 @@ partial class Dump _dumpLog.WriteLine("Error sending tracks to output image, not continuing."); _dumpLog.WriteLine(opticalPlugin.ErrorMessage); - StoppingErrorMessage?. - Invoke("Error sending tracks to output image, not continuing." + - Environment.NewLine + opticalPlugin.ErrorMessage); + StoppingErrorMessage?.Invoke("Error sending tracks to output image, not continuing." + + Environment.NewLine + opticalPlugin.ErrorMessage); return; } @@ -571,7 +570,7 @@ partial class Dump } else if(decMode?.Pages != null) { - bool setGeometry = false; + var setGeometry = false; foreach(Modes.ModePage page in decMode.Value.Pages) if(page.Page == 0x04 && @@ -693,10 +692,10 @@ partial class Dump if(_resume?.BlankExtents != null) blankExtents = ExtentsConverter.FromMetadata(_resume.BlankExtents); - bool newTrim = false; + var newTrim = false; if(mediaTags.TryGetValue(MediaTagType.DVD_CMI, out byte[] cmi) && - Settings.Settings.Current.EnableDecryption && + Settings.Current.EnableDecryption && _titleKeys && dskType == MediaType.DVDROM && (CopyrightType)cmi[0] == CopyrightType.CSS) @@ -765,17 +764,16 @@ partial class Dump _retryPasses > 0) RetrySbcData(scsiReader, currentTry, extents, ref totalDuration, blankExtents); - if(_resume.MissingTitleKeys?.Count > 0 && - !_aborted && - _retryPasses > 0 && - Settings.Settings.Current.EnableDecryption && - _titleKeys && + if(_resume.MissingTitleKeys?.Count > 0 && + !_aborted && + _retryPasses > 0 && + Settings.Current.EnableDecryption && + _titleKeys && mediaTags.ContainsKey(MediaTagType.DVD_DiscKey_Decrypted)) RetryTitleKeys(dvdDecrypt, mediaTags[MediaTagType.DVD_DiscKey_Decrypted], ref totalDuration); #endregion Error handling if(opticalDisc) - { foreach(KeyValuePair tag in mediaTags) { if(tag.Value is null) @@ -793,12 +791,10 @@ partial class Dump // Cannot write tag to image StoppingErrorMessage?.Invoke($"Cannot write tag {tag.Key}."); - _dumpLog.WriteLine($"Cannot write tag {tag.Key}." + Environment.NewLine + - outputFormat.ErrorMessage); + _dumpLog.WriteLine($"Cannot write tag {tag.Key}." + Environment.NewLine + outputFormat.ErrorMessage); return; } - } else { if(!_dev.IsRemovable || @@ -878,8 +874,8 @@ partial class Dump 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) @@ -902,12 +898,12 @@ partial class Dump UpdateStatus?.Invoke("Requesting MODE SENSE (6)."); _dumpLog.WriteLine("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 _); @@ -923,8 +919,8 @@ partial class Dump { _dumpLog.WriteLine("Cannot write SCSI MODE SENSE (6)."); - StoppingErrorMessage?.Invoke("Cannot write SCSI MODE SENSE (6)." + - Environment.NewLine + outputFormat.ErrorMessage); + StoppingErrorMessage?.Invoke("Cannot write SCSI MODE SENSE (6)." + Environment.NewLine + + outputFormat.ErrorMessage); return; } @@ -944,7 +940,7 @@ partial class Dump // TODO: Media Serial Number // TODO: Non-removable drive information - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -986,7 +982,7 @@ partial class Dump _dumpLog.WriteLine("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) @@ -1117,8 +1113,8 @@ partial class Dump UpdateStatus?.Invoke("Requesting MODE SENSE (10)."); _dumpLog.WriteLine("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) @@ -1139,8 +1135,8 @@ partial class Dump UpdateStatus?.Invoke("Requesting MODE SENSE (6)."); _dumpLog.WriteLine("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, @@ -1177,17 +1173,14 @@ partial class Dump o.type }).Distinct()) { - UpdateStatus?. - Invoke($"Found filesystem {filesystem.type} at sector {filesystem.start}"); + UpdateStatus?.Invoke($"Found filesystem {filesystem.type} at sector {filesystem.start}"); - _dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type, - filesystem.start); + _dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type, filesystem.start); } sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(dskType); - (string type, string subType) xmlType = - CommonTypes.Metadata.MediaType.MediaTypeToString(dskType); + (string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType); sidecar.BlockMedia[0].DiskType = xmlType.type; sidecar.BlockMedia[0].DiskSubType = xmlType.subType; diff --git a/Aaru.Core/Devices/Dumping/Sbc/Error.cs b/Aaru.Core/Devices/Dumping/Sbc/Error.cs index cef558f67..ee3a79b8a 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Error.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Error.cs @@ -25,6 +25,14 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; @@ -37,13 +45,6 @@ using Aaru.Decryption; using Aaru.Decryption.DVD; using Aaru.Devices; using Schemas; -using DVDDecryption = Aaru.Decryption.DVD.Dump; - -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; partial class Dump { @@ -53,12 +54,12 @@ partial class Dump /// Total time spent in commands /// SCSI reader /// Blank extents - void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents, - ref double totalDuration, ExtentsULong blankExtents) + void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents, ref double totalDuration, + ExtentsULong blankExtents) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; bool sense; byte[] buffer; bool recoveredError; @@ -66,7 +67,7 @@ partial class Dump byte[] md6; byte[] md10; bool blankCheck; - bool newBlank = false; + var newBlank = false; var outputFormat = _outputPlugin as IWritableImage; if(_persistent) @@ -79,8 +80,8 @@ partial class Dump if(sense) { - sense = _dev.ModeSense10(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out buffer, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout, + out _); if(!sense) { @@ -97,8 +98,8 @@ partial class Dump Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(buffer, _dev.ScsiType); if(dcMode6?.Pages != null) - foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage.Page == 0x01 && + modePage.Subpage == 0x00)) currentModePage = modePage; } @@ -222,13 +223,11 @@ partial class Dump _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else - { runningPersistent = true; - } } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -263,7 +262,7 @@ partial class Dump continue; } - if((!sense && !_dev.Error) || recoveredError) + if(!sense && !_dev.Error || recoveredError) { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); @@ -272,9 +271,7 @@ partial class Dump _dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass); } else if(runningPersistent) - { outputFormat.WriteSector(buffer, badSector); - } } if(pass < _retryPasses && @@ -321,15 +318,15 @@ partial class Dump void RetryTitleKeys(DVDDecryption dvdDecrypt, byte[] discKey, ref double totalDuration) { - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; bool sense; byte[] buffer; var outputFormat = _outputPlugin as IWritableImage; InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.MissingTitleKeys.ToArray(); foreach(ulong missingKey in tmpArray) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 45b2c98f0..5b297f50b 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -1,3 +1,11 @@ + + +// ReSharper disable JoinDeclarationAndInitializer +// ReSharper disable InlineOutVariableDeclaration +// ReSharper disable TooWideLocalVariableScope + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Linq; using Aaru.CommonTypes.Extents; @@ -8,12 +16,6 @@ using Aaru.Decoders.SCSI; using Aaru.Helpers; using Schemas; -// ReSharper disable JoinDeclarationAndInitializer -// ReSharper disable InlineOutVariableDeclaration -// ReSharper disable TooWideLocalVariableScope - -namespace Aaru.Core.Devices.Dumping; - partial class Dump { /// @@ -52,7 +54,7 @@ partial class Dump byte[] buffer; ulong sectorSpeedStart = 0; DateTime timeSpeedStart = DateTime.UtcNow; - bool canMediumScan = true; + var canMediumScan = true; var outputFormat = _outputPlugin as IWritableImage; InitProgress?.Invoke(); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs index c7437ab40..a23eec5f7 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs @@ -24,9 +24,7 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Extents; -using Aaru.CommonTypes.Interfaces; -using Schemas; + // ReSharper disable JoinDeclarationAndInitializer // ReSharper disable InlineOutVariableDeclaration @@ -34,6 +32,10 @@ using Schemas; namespace Aaru.Core.Devices.Dumping; +using Aaru.CommonTypes.Extents; +using Aaru.CommonTypes.Interfaces; +using Schemas; + partial class Dump { /// Trims data when dumping from a SCSI Block Commands compliant device @@ -41,15 +43,14 @@ partial class Dump /// Correctly dump extents /// Resume information /// Blank extents - void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry, - ExtentsULong blankExtents) + void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry, ExtentsULong blankExtents) { ulong[] tmpArray = _resume.BadBlocks.ToArray(); bool sense; bool recoveredError; bool blankCheck; byte[] buffer; - bool newBlank = false; + var newBlank = false; var outputFormat = _outputPlugin as IWritableImage; foreach(ulong badSector in tmpArray) diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 163d55450..8a50cda18 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.IO; @@ -40,19 +46,17 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Metadata; +using Aaru.CommonTypes.Structs; using Aaru.Core.Logging; using Aaru.Decoders.MMC; using Aaru.Decoders.SecureDigital; using Schemas; using CSD = Aaru.Decoders.MMC.CSD; +using Decoders = Aaru.Decoders.MMC.Decoders; using DeviceType = Aaru.CommonTypes.Enums.DeviceType; using MediaType = Aaru.CommonTypes.MediaType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping a MultiMediaCard or SecureDigital flash card public partial class Dump { @@ -85,9 +89,9 @@ public partial class Dump byte[] ecsd = null; byte[] scr = null; uint physicalBlockSize = 0; - bool byteAddressed = true; + var byteAddressed = true; uint[] response; - bool supportsCmd23 = false; + var supportsCmd23 = false; var outputFormat = _outputPlugin as IWritableImage; Dictionary mediaTags = new(); @@ -102,7 +106,7 @@ public partial class Dump if(!sense) { - CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd); + CSD csdDecoded = Decoders.DecodeCSD(csd); blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)); blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength); @@ -119,7 +123,7 @@ public partial class Dump if(!sense) { - ExtendedCSD ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd); + ExtendedCSD ecsdDecoded = Decoders.DecodeExtendedCSD(ecsd); blocks = ecsdDecoded.SectorCount; blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512); @@ -173,7 +177,7 @@ public partial class Dump if(!sense) { - Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd); + Aaru.Decoders.SecureDigital.CSD csdDecoded = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(csd); blocks = (ulong)(csdDecoded.Structure == 0 ? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2) @@ -223,8 +227,8 @@ public partial class Dump } else { - supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.CommandSupport. - HasFlag(CommandSupport.SetBlockCount) ?? false; + supportsCmd23 = Aaru.Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.CommandSupport. + HasFlag(CommandSupport.SetBlockCount) ?? false; mediaTags.Add(MediaTagType.SD_SCR, null); } @@ -271,8 +275,7 @@ public partial class Dump if(supportsCmd23 && blocksToRead > 1) { - sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, - out duration); + sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, out duration); if(sense || _dev.Error) supportsCmd23 = false; @@ -292,8 +295,8 @@ public partial class Dump { while(true) { - error = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + error = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, + out duration); if(error) blocksToRead /= 2; @@ -307,19 +310,19 @@ public partial class Dump { _dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", _dev.LastError); - StoppingErrorMessage?. - Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); + StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); return; } } - if(_useBufferedReads && blocksToRead > 1 && !supportsCmd23) + if(_useBufferedReads && + blocksToRead > 1 && + !supportsCmd23) { while(true) { - error = _dev.BufferedOsRead(out cmdBuf, 0, blockSize * blocksToRead, - out duration); + error = _dev.BufferedOsRead(out cmdBuf, 0, blockSize * blocksToRead, out duration); if(error) blocksToRead /= 2; @@ -342,12 +345,14 @@ public partial class Dump } } - if(!_useBufferedReads && blocksToRead > 1 && !supportsCmd23) + if(!_useBufferedReads && + blocksToRead > 1 && + !supportsCmd23) { 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; @@ -365,8 +370,7 @@ public partial class Dump { _dumpLog.WriteLine("ERROR: Cannot get blocks to read, device error {0}.", _dev.LastError); - StoppingErrorMessage?. - Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); + StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); return; } @@ -374,15 +378,13 @@ public partial class Dump if(blocksToRead == 1) { - error = _dev.ReadSingleBlock(out cmdBuf, out _, 0, blockSize, byteAddressed, timeout, - out duration); + error = _dev.ReadSingleBlock(out cmdBuf, out _, 0, blockSize, byteAddressed, timeout, out duration); if(error) { _dumpLog.WriteLine("ERROR: Could not read from device, device error {0}.", _dev.LastError); - StoppingErrorMessage?. - Invoke($"Device error {_dev.LastError} trying to read from device."); + StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to read from device."); return; } @@ -421,7 +423,7 @@ public partial class Dump return; } - bool ret = true; + var ret = true; foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag))) { @@ -587,7 +589,7 @@ public partial class Dump start = DateTime.UtcNow; double imageWriteDuration = 0; - bool newTrim = false; + var newTrim = false; DateTime timeSpeedStart = DateTime.UtcNow; ulong sectorSpeedStart = 0; @@ -625,11 +627,10 @@ public partial class Dump 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); + 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) { @@ -754,12 +755,12 @@ public partial class Dump !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; InitProgress?.Invoke(); - repeatRetryLba: + repeatRetryLba: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -820,7 +821,7 @@ public partial class Dump outputFormat.SetDumpHardware(_resume.Tries); // TODO: Drive info - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() @@ -857,7 +858,7 @@ public partial class Dump _dumpLog.WriteLine("Creating sidecar."); var filters = new FiltersList(); IFilter filter = filters.GetFilter(_outputPath); - IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage; + var inputPlugin = ImageFormat.Detect(filter) as IMediaImage; ErrorNumber opened = inputPlugin.Open(filter); if(opened != ErrorNumber.NoError) @@ -908,8 +909,7 @@ public partial class Dump case DeviceType.SecureDigital: CommonTypes.Metadata.MediaType.MediaTypeToString(MediaType.SecureDigital); - sidecar.BlockMedia[0].Dimensions = - Dimensions.DimensionsFromMediaType(MediaType.SecureDigital); + sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(MediaType.SecureDigital); break; } diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index 4d41794ce..1d002bd55 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Dumping; + using System; using System.Collections.Generic; using System.Linq; @@ -51,10 +57,6 @@ using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using TrackType = Aaru.CommonTypes.Enums.TrackType; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Dumping; - /// Implements dumping an Xbox Game Disc using a Kreon drive partial class Dump { @@ -142,7 +144,7 @@ partial class Dump return; } - byte[] tmpBuf = new byte[ssBuf.Length - 4]; + var tmpBuf = new byte[ssBuf.Length - 4]; Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4); mediaTags.Add(MediaTagType.Xbox_SecuritySector, tmpBuf); @@ -175,8 +177,7 @@ partial class Dump } ulong totalSize = - (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) & - 0xFFFFFFFF; + (ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) & 0xFFFFFFFF; UpdateStatus?.Invoke("Reading Physical Format Information."); _dumpLog.WriteLine("Reading Physical Format Information."); @@ -225,8 +226,8 @@ partial class Dump UpdateStatus?.Invoke("Video partition is too big, did lock work? Trying cold values."); _dumpLog.WriteLine("Video partition is too big, did lock work? Trying cold values."); - totalSize = (ulong)((coldReadCapacity[0] << 24) + (coldReadCapacity[1] << 16) + - (coldReadCapacity[2] << 8) + coldReadCapacity[3]) & 0xFFFFFFFF; + totalSize = (ulong)((coldReadCapacity[0] << 24) + (coldReadCapacity[1] << 16) + (coldReadCapacity[2] << 8) + + coldReadCapacity[3]) & 0xFFFFFFFF; tmpBuf = new byte[coldPfi.Length - 4]; Array.Copy(coldPfi, 4, tmpBuf, 0, coldPfi.Length - 4); @@ -371,8 +372,8 @@ partial class Dump Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4); mediaTags.Add(MediaTagType.Xbox_DMI, tmpBuf); - totalSize = l0Video + l1Video + (middleZone * 2) + gameSize; - ulong layerBreak = l0Video + middleZone + (gameSize / 2); + totalSize = l0Video + l1Video + middleZone * 2 + gameSize; + ulong layerBreak = l0Video + middleZone + gameSize / 2; UpdateStatus?.Invoke($"Video layer 0 size: {l0Video} sectors"); UpdateStatus?.Invoke($"Video layer 1 size: {l1Video} sectors"); @@ -442,7 +443,7 @@ partial class Dump if(_skip < blocksToRead) _skip = blocksToRead; - bool ret = true; + var ret = true; foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag))) { @@ -503,7 +504,7 @@ partial class Dump (outputFormat as IWritableOpticalImage).SetTracks(new List { - new Track + new() { BytesPerSector = (int)blockSize, EndSector = blocks - 1, @@ -523,7 +524,7 @@ partial class Dump _dumpLog.WriteLine("Resuming from block {0}.", _resume.NextBlock); } - bool newTrim = false; + var newTrim = false; _dumpLog.WriteLine("Reading game partition."); UpdateStatus?.Invoke("Reading game partition."); @@ -531,7 +532,7 @@ partial class Dump ulong sectorSpeedStart = 0; InitProgress?.Invoke(); - for(int e = 0; e <= 16; e++) + for(var e = 0; e <= 16; e++) { if(_aborted) { @@ -554,13 +555,13 @@ partial class Dump if(xboxSs.Value.Extents[e].StartPSN <= xboxSs.Value.Layer0EndPSN) extentStart = xboxSs.Value.Extents[e].StartPSN - 0x30000; else - extentStart = ((xboxSs.Value.Layer0EndPSN + 1) * 2) - + extentStart = (xboxSs.Value.Layer0EndPSN + 1) * 2 - ((xboxSs.Value.Extents[e].StartPSN ^ 0xFFFFFF) + 1) - 0x30000; if(xboxSs.Value.Extents[e].EndPSN <= xboxSs.Value.Layer0EndPSN) extentEnd = xboxSs.Value.Extents[e].EndPSN - 0x30000; else - extentEnd = ((xboxSs.Value.Layer0EndPSN + 1) * 2) - + extentEnd = (xboxSs.Value.Layer0EndPSN + 1) * 2 - ((xboxSs.Value.Extents[e].EndPSN ^ 0xFFFFFF) + 1) - 0x30000; } @@ -601,8 +602,8 @@ partial class Dump UpdateProgress?.Invoke($"Reading sector {i} of {totalSize} ({currentSpeed:F3} MiB/sec.)", (long)i, (long)totalSize); - 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); totalDuration += cmdDuration; @@ -959,7 +960,7 @@ partial class Dump !_aborted && _retryPasses > 0) { - List tmpList = new List(); + var tmpList = new List(); foreach(ulong ur in _resume.BadBlocks) for(ulong i = ur; i < ur + blocksToRead; i++) @@ -967,9 +968,9 @@ partial class Dump tmpList.Sort(); - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; _resume.BadBlocks = tmpList; Modes.ModePage? currentModePage = null; @@ -1001,8 +1002,7 @@ partial class Dump } else { - Modes.DecodedMode? dcMode6 = - Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); + Modes.DecodedMode? dcMode6 = Modes.DecodeMode6(readBuffer, PeripheralDeviceTypes.MultiMediaDevice); if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => @@ -1065,15 +1065,14 @@ partial class Dump AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf)); - _dumpLog. - WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); + _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive."); } else runningPersistent = true; } InitProgress?.Invoke(); - repeatRetry: + repeatRetry: ulong[] tmpArray = _resume.BadBlocks.ToArray(); foreach(ulong badSector in tmpArray) @@ -1187,7 +1186,7 @@ partial class Dump outputFormat.SetDumpHardware(_resume.Tries); - var metadata = new CommonTypes.Structs.ImageInfo + var metadata = new ImageInfo { Application = "Aaru", ApplicationVersion = Version.GetVersion() diff --git a/Aaru.Core/Devices/Info/DeviceInfo.cs b/Aaru.Core/Devices/Info/DeviceInfo.cs index 61916737b..7d7cd3620 100644 --- a/Aaru.Core/Devices/Info/DeviceInfo.cs +++ b/Aaru.Core/Devices/Info/DeviceInfo.cs @@ -31,6 +31,10 @@ // Copyright © 2021-2022 Rebecca Wallander // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +namespace Aaru.Core.Devices.Info; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; @@ -42,11 +46,8 @@ using Aaru.Decoders.SCSI; using Aaru.Decryption; using Aaru.Devices; using Aaru.Helpers; -using DVDDecryption = Aaru.Decryption.DVD.Dump; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; -namespace Aaru.Core.Devices.Info; - /// Obtains and contains information about a device public partial class DeviceInfo { @@ -89,19 +90,16 @@ public partial class DeviceInfo AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status); AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error); - AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", - errorRegisters.SectorCount); + AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount); AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector); AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh); - AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", - errorRegisters.CylinderLow); + AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow); - AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", - errorRegisters.DeviceHead); + AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead); AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError); @@ -135,19 +133,16 @@ public partial class DeviceInfo AaruConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.Status); AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error); - AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", - errorRegisters.SectorCount); + AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.SectorCount); AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector); AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh); - AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", - errorRegisters.CylinderLow); + AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow); - AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", - errorRegisters.DeviceHead); + AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead); AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError); @@ -199,8 +194,8 @@ 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) @@ -208,8 +203,8 @@ public partial class DeviceInfo 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) @@ -222,8 +217,8 @@ public partial class DeviceInfo 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) @@ -324,8 +319,8 @@ public partial class DeviceInfo #region Plextor if(dev.Manufacturer == "PLEXTOR") { - bool plxtSense = true; - bool plxtDvd = false; + var plxtSense = true; + var plxtDvd = false; byte[] plxtBuf = null; switch(dev.Model) @@ -335,8 +330,7 @@ public partial class DeviceInfo case "DVDR PX-712A": plxtDvd = true; - plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, - out _); + plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, out _); break; case "DVDR PX-714A": @@ -349,8 +343,8 @@ 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; @@ -487,8 +481,7 @@ public partial class DeviceInfo if(plxtDvd) { - plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, - out _); + plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out _); if(!plxtSense) PlextorFeatures.VariRecDvd = true; @@ -515,8 +508,7 @@ public partial class DeviceInfo #endregion Plextor if(ScsiInquiry.Value.KreonPresent) - if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, - out _)) + if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, out _)) KreonFeatures = krFeatures; break; @@ -534,8 +526,7 @@ public partial class DeviceInfo sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, dev.Timeout, out _); if(sense) - AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", - Sense.PrettifySense(senseBuf)); + AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", Sense.PrettifySense(senseBuf)); else { DensitySupport = seqBuf; diff --git a/Aaru.Core/Devices/Info/Properties.cs b/Aaru.Core/Devices/Info/Properties.cs index 0f9271780..8a0d04188 100644 --- a/Aaru.Core/Devices/Info/Properties.cs +++ b/Aaru.Core/Devices/Info/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Info; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs.Devices.SCSI; @@ -40,8 +42,6 @@ using Aaru.Decoders.SCSI.SSC; using Aaru.Devices; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; -namespace Aaru.Core.Devices.Info; - public partial class DeviceInfo { /// Raw IDENTIFY DEVICE response diff --git a/Aaru.Core/Devices/Reader.cs b/Aaru.Core/Devices/Reader.cs index 1c35c8ed0..1240f79bc 100644 --- a/Aaru.Core/Devices/Reader.cs +++ b/Aaru.Core/Devices/Reader.cs @@ -30,16 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices; + using System; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs.Devices.ATA; using Aaru.Core.Logging; using Aaru.Devices; -namespace Aaru.Core.Devices; - /// Reduces common code used for scanning and dumping -internal sealed partial class Reader +sealed partial class Reader { readonly Device _dev; readonly ErrorLog _errorLog; @@ -140,8 +140,8 @@ internal sealed partial class Reader out bool blankCheck) => ReadBlocks(out buffer, block, BlocksToRead, out duration, out recoveredError, out blankCheck); - internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, - out bool recoveredError, out bool blankCheck) + internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError, + out bool blankCheck) { switch(_dev.Type) { diff --git a/Aaru.Core/Devices/ReaderATA.cs b/Aaru.Core/Devices/ReaderATA.cs index 178e5718d..d24ab9c07 100644 --- a/Aaru.Core/Devices/ReaderATA.cs +++ b/Aaru.Core/Devices/ReaderATA.cs @@ -30,15 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices; + using System; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Decoders.ATA; using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify; -namespace Aaru.Core.Devices; - -internal sealed partial class Reader +sealed partial class Reader { Identify.IdentifyDevice _ataId; bool _ataRead; @@ -74,9 +74,9 @@ internal sealed partial class Reader Blocks = (ulong)(Cylinders * Heads * Sectors); } - if((_ataId.CurrentCylinders != 0 && _ataId.CurrentHeads != 0 && _ataId.CurrentSectorsPerTrack != 0) || - _ataId.Cylinders <= 0 || - _ataId.Heads <= 0 || + if(_ataId.CurrentCylinders != 0 && _ataId.CurrentHeads != 0 && _ataId.CurrentSectorsPerTrack != 0 || + _ataId.Cylinders <= 0 || + _ataId.Heads <= 0 || _ataId.SectorsPerTrack <= 0) return; @@ -111,7 +111,7 @@ internal sealed partial class Reader GetDeviceBlocks(); bool sense; - int tries = 0; + var tries = 0; uint lba = 0; ushort cyl = 0; byte head = 0; @@ -139,15 +139,13 @@ internal sealed partial class Reader _ataReadDmaLba = !sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0; sense = _dev.ReadDma(out cmdBuf, out errorLba, true, lba, 1, _timeout, out _); - _ataReadDmaRetryLba = - !sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0; + _ataReadDmaRetryLba = !sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && cmdBuf.Length > 0; sense = _dev.Read(out cmdBuf, out AtaErrorRegistersLba48 errorLba48, lba, 1, _timeout, out _); _ataReadLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 && cmdBuf.Length > 0; sense = _dev.ReadDma(out cmdBuf, out errorLba48, lba, 1, _timeout, out _); - _ataReadDmaLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 && - cmdBuf.Length > 0; + _ataReadDmaLba48 = !sense && (errorLba48.Status & 0x27) == 0 && errorLba48.Error == 0 && cmdBuf.Length > 0; if(_ataRead || _ataReadRetry || @@ -159,9 +157,7 @@ internal sealed partial class Reader _ataReadDmaRetryLba || _ataReadLba48 || _ataReadDmaLba48) - { break; - } lba = (uint)rnd.Next(1, (int)Blocks); cyl = (ushort)rnd.Next(0, Cylinders); @@ -281,7 +277,7 @@ internal sealed partial class Reader return false; } - bool error = true; + var error = true; while(IsLba) { @@ -345,7 +341,7 @@ internal sealed partial class Reader bool AtaReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError) { - bool error = true; + var error = true; bool sense; AtaErrorRegistersLba28 errorLba; AtaErrorRegistersLba48 errorLba48; @@ -431,7 +427,7 @@ internal sealed partial class Reader bool AtaReadChs(out byte[] buffer, ushort cylinder, byte head, byte sector, out double duration, out bool recoveredError) { - bool error = true; + var error = true; bool sense; AtaErrorRegistersChs errorChs; byte status = 0, errorByte = 0; @@ -452,8 +448,7 @@ internal sealed partial class Reader } else if(_ataReadDma) { - sense = _dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sector, 1, _timeout, - out duration); + sense = _dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sector, 1, _timeout, out duration); error = !(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0 && buffer.Length > 0); status = errorChs.Status; diff --git a/Aaru.Core/Devices/ReaderSCSI.cs b/Aaru.Core/Devices/ReaderSCSI.cs index d2605b9ec..209226b5a 100644 --- a/Aaru.Core/Devices/ReaderSCSI.cs +++ b/Aaru.Core/Devices/ReaderSCSI.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices; + using System; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Console; using Aaru.Decoders.SCSI; -namespace Aaru.Core.Devices; - -internal sealed partial class Reader +sealed partial class Reader { // TODO: Raw reading bool _hldtstReadRaw; @@ -65,9 +65,9 @@ internal sealed partial class Reader return true; byte[] senseBuf; - int tries = 0; + var tries = 0; uint lba = 0; - bool mediumScan = false; + var mediumScan = false; if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice) { @@ -97,9 +97,7 @@ internal sealed partial class Reader _read10 || _read12 || _read16) - { break; - } lba = (uint)rnd.Next(1, (int)Blocks); @@ -226,8 +224,8 @@ internal 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 _); } } } @@ -249,8 +247,7 @@ internal sealed partial class Reader 600, 610, 630 }) { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, - out _); + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); if(!testSense && !_dev.Error) @@ -262,8 +259,8 @@ internal sealed partial class Reader break; } - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, - _timeout, out _); + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, + out _); if(testSense || _dev.Error) continue; @@ -288,8 +285,7 @@ internal sealed partial class Reader 1200 }) { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, - out _); + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); if(!testSense && !_dev.Error) @@ -301,8 +297,8 @@ internal sealed partial class Reader break; } - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, - _timeout, out _); + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, + out _); if(testSense || _dev.Error) continue; @@ -426,8 +422,7 @@ internal sealed partial class Reader 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); } @@ -436,8 +431,7 @@ internal sealed partial class Reader LongBlockSize = 0xFFFF - (information & 0xFFFF); _syqReadLong10 = - !_dev.SyQuestReadLong10(out _, out senseBuf, 0, LongBlockSize, _timeout, - out _); + !_dev.SyQuestReadLong10(out _, out senseBuf, 0, LongBlockSize, _timeout, out _); } } else @@ -476,8 +470,8 @@ internal sealed partial class Reader LongBlockSize = 0xFFFF - (information & 0xFFFF); _syqReadLong6 = - !_dev.SyQuestReadLong6(out _, out senseBuf, 0, LongBlockSize, - _timeout, out _); + !_dev.SyQuestReadLong6(out _, out senseBuf, 0, LongBlockSize, _timeout, + out _); } } } @@ -589,7 +583,7 @@ internal sealed partial class Reader if(!sense) { - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); @@ -619,24 +613,24 @@ internal sealed partial class Reader } 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; } 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; } else if(_read16) { - _dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0, BlocksToRead, false, - _timeout, out _); + _dev.Read16(out _, out _, 0, false, true, false, 0, LogicalBlockSize, 0, BlocksToRead, false, _timeout, + out _); if(_dev.Error) BlocksToRead /= 2; @@ -676,8 +670,7 @@ internal sealed partial class Reader if(CanReadRaw) if(_readLong16) - sense = _dev.ReadLong16(out buffer, out senseBuf, false, block, LongBlockSize, _timeout, - out duration); + 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); @@ -707,8 +700,8 @@ internal sealed partial class Reader 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; } @@ -731,7 +724,7 @@ internal sealed partial class Reader bool ScsiSeek(ulong block, out double duration) { - bool sense = true; + var sense = true; duration = 0; if(_seek6) diff --git a/Aaru.Core/Devices/Report/ATA.cs b/Aaru.Core/Devices/Report/ATA.cs index 85d5a2168..15337ce35 100644 --- a/Aaru.Core/Devices/Report/ATA.cs +++ b/Aaru.Core/Devices/Report/ATA.cs @@ -30,23 +30,23 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using System; using Aaru.CommonTypes.Metadata; using Aaru.Console; using Aaru.Decoders.ATA; using Aaru.Devices; -using Spectre.Console; +using global::Spectre.Console; using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify; -namespace Aaru.Core.Devices.Report; - public sealed partial class DeviceReport { /// Creates a report for media inserted into an ATA device /// Media report public TestedMedia ReportAtaMedia() { - bool sense = true; + var sense = true; AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersLba28 errorLba = new(); AtaErrorRegistersLba48 errorLba48 = new(); @@ -55,9 +55,8 @@ public sealed partial class DeviceReport var mediaTest = new TestedMedia { - MediumTypeName = - AnsiConsole.Ask("Please write a description of the media type and press enter: "), - Model = AnsiConsole.Ask("Please write the media model and press enter: "), + MediumTypeName = AnsiConsole.Ask("Please write a description of the media type and press enter: "), + Model = AnsiConsole.Ask("Please write the media model and press enter: "), MediaIsRecognized = true }; @@ -187,7 +186,7 @@ public sealed partial class DeviceReport mediaTest.Manufacturer = ataId.MediaManufacturer; } - ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0); + var checkCorrectRead = BitConverter.ToUInt64(buffer, 0); Spectre.ProgressSingleSpinner(ctx => { @@ -198,9 +197,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadSectorsData = readBuf; @@ -213,9 +211,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadSectorsRetryData = readBuf; @@ -228,9 +225,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDma = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadDmaData = readBuf; @@ -243,9 +239,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadDmaRetryData = readBuf; @@ -269,9 +264,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLbaData = readBuf; @@ -284,9 +278,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadRetryLbaData = readBuf; @@ -299,9 +292,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadDmaLbaData = readBuf; @@ -314,9 +306,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadDmaRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadDmaRetryLbaData = readBuf; @@ -340,9 +331,8 @@ public sealed partial class DeviceReport mediaTest.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLba48Data = readBuf; @@ -352,12 +342,11 @@ public sealed partial class DeviceReport sense = _dev.ReadDma(out readBuf, out errorLba48, 0, 1, _dev.Timeout, out _); }); - mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && - errorLba48.Error == 0 && readBuf.Length > 0; + mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && + readBuf.Length > 0; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadDmaLba48Data = readBuf; @@ -390,12 +379,10 @@ public sealed partial class DeviceReport }); mediaTest.SupportsReadLong = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && - readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLongData = readBuf; @@ -411,9 +398,8 @@ public sealed partial class DeviceReport readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLongRetryData = readBuf; @@ -421,17 +407,15 @@ public sealed partial class DeviceReport { ctx.AddTask("Trying READ LONG in LBA mode...").IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout, + out _); }); mediaTest.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && - readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLongLbaData = readBuf; @@ -439,17 +423,16 @@ public sealed partial class DeviceReport { ctx.AddTask("Trying READ LONG RETRY in LBA mode...").IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize ?? 0, _dev.Timeout, + out _); }); - mediaTest.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && - errorLba.Error == 0 && readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; + mediaTest.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != + checkCorrectRead; - AaruConsole.DebugWriteLine("ATA Report", - "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, - errorChs.Status, errorChs.Error, readBuf.Length); + AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", + sense, errorChs.Status, errorChs.Error, readBuf.Length); mediaTest.ReadLongRetryLbaData = readBuf; } @@ -462,7 +445,7 @@ public sealed partial class DeviceReport /// Creates a report of an ATA device public TestedMedia ReportAta(Identify.IdentifyDevice ataId) { - bool sense = true; + var sense = true; byte[] readBuf = Array.Empty(); AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersLba28 errorLba = new(); @@ -500,8 +483,7 @@ public sealed partial class DeviceReport Sectors = ataId.CurrentSectorsPerTrack }; - capabilities.Blocks = - (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack); + capabilities.Blocks = (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack); } if(ataId.Capabilities.HasFlag(Identify.CapabilitiesBit.LBASupport)) @@ -790,8 +772,8 @@ public sealed partial class DeviceReport }); capabilities.SupportsReadLongRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && - readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != - checkCorrectRead; + readBuf.Length > 0 && + BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.Status, errorChs.Error, readBuf.Length); @@ -802,13 +784,12 @@ public sealed partial class DeviceReport { ctx.AddTask("Trying READ LONG in LBA mode...").IsIndeterminate(); - sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, capabilities.LongBlockSize ?? 0, - _dev.Timeout, out _); + sense = _dev.ReadLong(out readBuf, out errorLba, false, 0, capabilities.LongBlockSize ?? 0, _dev.Timeout, + out _); }); capabilities.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && - readBuf.Length > 0 && - BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; + readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.Status, errorLba.Error, readBuf.Length); @@ -840,7 +821,7 @@ public sealed partial class DeviceReport /// IDENTIFY ATA DEVICE response without the private fields public static byte[] ClearIdentify(byte[] buffer) { - byte[] empty = new byte[512]; + var empty = new byte[512]; Array.Copy(empty, 0, buffer, 20, 20); Array.Copy(empty, 0, buffer, 216, 8); diff --git a/Aaru.Core/Devices/Report/DeviceReport.cs b/Aaru.Core/Devices/Report/DeviceReport.cs index 05342629a..09b02bb94 100644 --- a/Aaru.Core/Devices/Report/DeviceReport.cs +++ b/Aaru.Core/Devices/Report/DeviceReport.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Devices; - namespace Aaru.Core.Devices.Report; +using Aaru.Devices; + public sealed partial class DeviceReport { readonly Device _dev; diff --git a/Aaru.Core/Devices/Report/FireWire.cs b/Aaru.Core/Devices/Report/FireWire.cs index fa367c85e..1f3597dd8 100644 --- a/Aaru.Core/Devices/Report/FireWire.cs +++ b/Aaru.Core/Devices/Report/FireWire.cs @@ -30,15 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Metadata; - namespace Aaru.Core.Devices.Report; +using Aaru.CommonTypes.Metadata; + /// Implements creating a report for a FireWire device public sealed partial class DeviceReport { /// Fills a device report with parameters specific to a FireWire device - public FireWire FireWireReport() => new FireWire + public FireWire FireWireReport() => new() { Manufacturer = _dev.FireWireVendorName, Product = _dev.FireWireModelName, diff --git a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs index a1886ce30..559d80b55 100644 --- a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs +++ b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable InlineOutVariableDeclaration + +namespace Aaru.Core.Devices.Report; + using System; using System.Linq; using System.Threading; @@ -39,10 +45,6 @@ using Aaru.Decoders.CD; using Aaru.Decoders.SCSI; using Aaru.Devices; -// ReSharper disable InlineOutVariableDeclaration - -namespace Aaru.Core.Devices.Report; - public sealed partial class DeviceReport { /// Tries and checks reading a GD-ROM disc using the swap disc trick and adds the result to a device report @@ -59,7 +61,7 @@ public sealed partial class DeviceReport AaruConsole. Write("Have you previously tried with a GD-ROM disc and did the computer hang or crash? (Y/N): "); - pressedKey = System.Console.ReadKey(); + pressedKey = Console.ReadKey(); AaruConsole.WriteLine(); } @@ -77,11 +79,11 @@ public sealed partial class DeviceReport AaruConsole.WriteLine("Please insert trap disc inside..."); AaruConsole.WriteLine("Press any key to continue..."); - System.Console.ReadLine(); + Console.ReadLine(); AaruConsole.WriteLine("Sending READ FULL TOC to the device..."); - int retries = 0; + var retries = 0; bool sense; byte[] buffer; byte[] senseBuffer; @@ -144,8 +146,8 @@ public sealed partial class DeviceReport return; } - int min = 0, sec, frame; - bool tocIsNotBcd = false; + int min = 0, sec, frame; + var tocIsNotBcd = false; report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPMIN = leadOutTrack.PMIN; report.GdRomSwapDiscCapabilities.SwapDiscLeadOutPSEC = leadOutTrack.PSEC; @@ -169,12 +171,12 @@ public sealed partial class DeviceReport } else { - min += ((leadOutTrack.PMIN >> 4) * 10) + (leadOutTrack.PMIN & 0x0F); - sec = ((leadOutTrack.PSEC >> 4) * 10) + (leadOutTrack.PSEC & 0x0F); - frame = ((leadOutTrack.PFRAME >> 4) * 10) + (leadOutTrack.PFRAME & 0x0F); + min += (leadOutTrack.PMIN >> 4) * 10 + (leadOutTrack.PMIN & 0x0F); + sec = (leadOutTrack.PSEC >> 4) * 10 + (leadOutTrack.PSEC & 0x0F); + frame = (leadOutTrack.PFRAME >> 4) * 10 + (leadOutTrack.PFRAME & 0x0F); } - int sectors = (min * 60 * 75) + (sec * 75) + frame - 150; + int sectors = min * 60 * 75 + sec * 75 + frame - 150; AaruConsole.WriteLine("Trap disc shows {0} sectors...", sectors); @@ -196,7 +198,7 @@ public sealed partial class DeviceReport AaruConsole.WriteLine("Please MANUALLY get the trap disc out and put the GD-ROM disc inside..."); AaruConsole.WriteLine("Press any key to continue..."); - System.Console.ReadLine(); + Console.ReadLine(); AaruConsole.WriteLine("Waiting 5 seconds..."); Thread.Sleep(5000); @@ -314,11 +316,10 @@ 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 _); + MmcSectorTypes.Cdda, false, false, false, + MmcHeaderCodes.None, true, false, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000AudioData = lba100000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba100000AudioSense = lba100000AudioSenseBuffer; @@ -346,18 +347,15 @@ 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; - report.GdRomSwapDiscCapabilities.Lba50000AudioDecodedSense = - Sense.PrettifySense(lba50000AudioSenseBuffer); + report.GdRomSwapDiscCapabilities.Lba50000AudioDecodedSense = Sense.PrettifySense(lba50000AudioSenseBuffer); report.GdRomSwapDiscCapabilities.Lba50000AudioReadableCluster = (int)cluster; @@ -380,11 +378,10 @@ 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 _); + MmcSectorTypes.Cdda, false, false, false, + MmcHeaderCodes.None, true, false, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000AudioData = lba450000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba450000AudioSense = lba450000AudioSenseBuffer; @@ -413,11 +410,10 @@ 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 _); + MmcSectorTypes.Cdda, false, false, false, + MmcHeaderCodes.None, true, false, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000AudioData = lba400000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba400000AudioSense = lba400000AudioSenseBuffer; @@ -445,18 +441,15 @@ 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; - report.GdRomSwapDiscCapabilities.Lba45000AudioDecodedSense = - Sense.PrettifySense(lba45000AudioSenseBuffer); + report.GdRomSwapDiscCapabilities.Lba45000AudioDecodedSense = Sense.PrettifySense(lba45000AudioSenseBuffer); report.GdRomSwapDiscCapabilities.Lba45000AudioReadableCluster = (int)cluster; @@ -478,18 +471,15 @@ 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; - report.GdRomSwapDiscCapabilities.Lba44990AudioDecodedSense = - Sense.PrettifySense(lba44990AudioSenseBuffer); + report.GdRomSwapDiscCapabilities.Lba44990AudioDecodedSense = Sense.PrettifySense(lba44990AudioSenseBuffer); report.GdRomSwapDiscCapabilities.Lba44990AudioReadableCluster = (int)cluster; @@ -509,10 +499,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba100000AudioPqData = lba100000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba100000AudioPqSense = lba100000AudioPqSenseBuffer; @@ -538,10 +532,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba50000AudioPqData = lba50000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba50000AudioPqSense = lba50000AudioPqSenseBuffer; @@ -567,10 +564,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba450000AudioPqData = lba450000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba450000AudioPqSense = lba450000AudioPqSenseBuffer; @@ -596,10 +597,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba400000AudioPqData = lba400000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba400000AudioPqSense = lba400000AudioPqSenseBuffer; @@ -625,10 +630,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba45000AudioPqData = lba45000AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba45000AudioPqSense = lba45000AudioPqSenseBuffer; @@ -654,10 +662,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba44990AudioPqData = lba44990AudioPqBuffer; report.GdRomSwapDiscCapabilities.Lba44990AudioPqSense = lba44990AudioPqSenseBuffer; @@ -683,10 +694,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba100000AudioRwData = lba100000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba100000AudioRwSense = lba100000AudioRwSenseBuffer; @@ -712,10 +727,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba50000AudioRwData = lba50000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba50000AudioRwSense = lba50000AudioRwSenseBuffer; @@ -741,10 +759,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba450000AudioRwData = lba450000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba450000AudioRwSense = lba450000AudioRwSenseBuffer; @@ -770,10 +792,14 @@ public sealed partial class DeviceReport while(true) { - 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, out _); + 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, + out _); report.GdRomSwapDiscCapabilities.Lba400000AudioRwData = lba400000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba400000AudioRwSense = lba400000AudioRwSenseBuffer; @@ -799,10 +825,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba45000AudioRwData = lba45000AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba45000AudioRwSense = lba45000AudioRwSenseBuffer; @@ -828,10 +857,13 @@ public sealed partial class DeviceReport while(true) { - 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 _); + 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 _); report.GdRomSwapDiscCapabilities.Lba44990AudioRwData = lba44990AudioRwBuffer; report.GdRomSwapDiscCapabilities.Lba44990AudioRwSense = lba44990AudioRwSenseBuffer; @@ -1034,10 +1066,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + MmcSubchannel.Q16, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer; report.GdRomSwapDiscCapabilities.Lba100000PqSense = lba100000PqSenseBuffer; @@ -1092,10 +1126,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + MmcSubchannel.Q16, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer; report.GdRomSwapDiscCapabilities.Lba450000PqSense = lba450000PqSenseBuffer; @@ -1121,10 +1157,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, out _); + MmcSubchannel.Q16, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer; report.GdRomSwapDiscCapabilities.Lba400000PqSense = lba400000PqSenseBuffer; @@ -1208,10 +1246,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + MmcSubchannel.Raw, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer; report.GdRomSwapDiscCapabilities.Lba100000RwSense = lba100000RwSenseBuffer; @@ -1266,10 +1306,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + MmcSubchannel.Raw, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer; report.GdRomSwapDiscCapabilities.Lba450000RwSense = lba450000RwSenseBuffer; @@ -1295,10 +1337,12 @@ 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, + MmcSectorTypes.AllTypes, false, + false, true, + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, out _); + MmcSubchannel.Raw, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer; report.GdRomSwapDiscCapabilities.Lba400000RwSense = lba400000RwSenseBuffer; @@ -1395,7 +1439,7 @@ public sealed partial class DeviceReport Write("The next part of the test will read the whole high density area of a GD-ROM from the smallest known readable sector until the first error happens\n" + "Do you want to proceed? (Y/N): "); - pressedKey = System.Console.ReadKey(); + pressedKey = Console.ReadKey(); AaruConsole.WriteLine(); } @@ -1403,8 +1447,8 @@ public sealed partial class DeviceReport return; uint startingSector = 45000; - bool readAsAudio = false; - bool aborted = false; + var readAsAudio = false; + var aborted = false; MmcSubchannel subchannel = MmcSubchannel.None; uint blockSize = 2352; @@ -1519,7 +1563,7 @@ public sealed partial class DeviceReport subchannel = MmcSubchannel.Q16; } - System.Console.CancelKeyPress += (sender, e) => + Console.CancelKeyPress += (sender, e) => { e.Cancel = true; aborted = true; @@ -1541,7 +1585,7 @@ public sealed partial class DeviceReport byte[] lastSuccessfulPq = null; byte[] lastSuccessfulRw = null; - bool trackModeChange = false; + var trackModeChange = false; AaruConsole.WriteLine(); @@ -1558,12 +1602,13 @@ public sealed partial class DeviceReport AaruConsole.Write("\rReading 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) { diff --git a/Aaru.Core/Devices/Report/MMC.cs b/Aaru.Core/Devices/Report/MMC.cs index 6ec8da17d..62d6e9a57 100644 --- a/Aaru.Core/Devices/Report/MMC.cs +++ b/Aaru.Core/Devices/Report/MMC.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using System; using System.Linq; using System.Text; @@ -40,9 +42,7 @@ using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; using Aaru.Devices; using Aaru.Helpers; -using Spectre.Console; - -namespace Aaru.Core.Devices.Report; +using global::Spectre.Console; public sealed partial class DeviceReport { @@ -52,8 +52,8 @@ public sealed partial class DeviceReport while(offset + 4 < response.Length) { - ushort code = (ushort)((response[offset + 0] << 8) + response[offset + 1]); - byte[] data = new byte[response[offset + 3] + 4]; + var code = (ushort)((response[offset + 0] << 8) + response[offset + 1]); + var data = new byte[response[offset + 3] + 4]; if(code != 0x0108) { @@ -76,7 +76,7 @@ public sealed partial class DeviceReport /// MMC features report public MmcFeatures ReportMmcFeatures() { - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); Spectre.ProgressSingleSpinner(ctx => @@ -490,7 +490,7 @@ public sealed partial class DeviceReport if(ftr010C.HasValue) { - byte[] temp = new byte[4]; + var temp = new byte[4]; temp[0] = (byte)((ftr010C.Value.Century & 0xFF00) >> 8); temp[1] = (byte)(ftr010C.Value.Century & 0xFF); temp[2] = (byte)((ftr010C.Value.Year & 0xFF00) >> 8); @@ -520,8 +520,8 @@ 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), DateTimeKind.Utc); + 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 catch @@ -587,10 +587,10 @@ public sealed partial class DeviceReport /// Try HL-DT-ST vendor commands /// Try MediaTek vendor commands /// - public TestedMedia ReportMmcMedia(string mediaType, bool tryPlextor, bool tryPioneer, bool tryNec, - bool tryHldtst, bool tryMediaTekF106) + public TestedMedia ReportMmcMedia(string mediaType, bool tryPlextor, bool tryPioneer, bool tryNec, bool tryHldtst, + bool tryMediaTekF106) { - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); byte[] senseBuffer = Array.Empty(); var mediaTest = new TestedMedia(); @@ -622,7 +622,7 @@ public sealed partial class DeviceReport !_dev.Error) { mediaTest.SupportsReadCapacity16 = true; - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(buffer, 0, temp, 0, 8); Array.Reverse(temp); mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1; @@ -635,8 +635,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 && @@ -743,8 +743,8 @@ public sealed partial class DeviceReport mediaTest.CanReadDMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, - 0, _dev.Timeout, out _); + MmcDiscStructureFormat.DiscManufacturingInformation, 0, + _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDMI); @@ -879,8 +879,8 @@ public sealed partial class DeviceReport mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramDds, 0, - _dev.Timeout, out _); + MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS); @@ -913,8 +913,7 @@ public sealed partial class DeviceReport mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, - out _); + MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS); @@ -944,8 +943,8 @@ public sealed partial class DeviceReport mediaTest.CanReadPRI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PreRecordedInfo, 0, - _dev.Timeout, out _); + MmcDiscStructureFormat.PreRecordedInfo, 0, _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPRI); @@ -975,9 +974,8 @@ public sealed partial class DeviceReport mediaTest.CanReadRecordablePFI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat. - DvdrPhysicalInformation, 0, - _dev.Timeout, out _); + MmcDiscStructureFormat.DvdrPhysicalInformation, + 0, _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRecordablePFI); @@ -994,8 +992,7 @@ public sealed partial class DeviceReport mediaTest.CanReadADIP = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.Adip, 0, _dev.Timeout, - out _); + MmcDiscStructureFormat.Adip, 0, _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadADIP); @@ -1024,8 +1021,8 @@ public sealed partial class DeviceReport mediaTest.CanReadHDCMI = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdCopyrightInformation, - 0, _dev.Timeout, out _); + MmcDiscStructureFormat.HddvdCopyrightInformation, 0, + _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadHDCMI); @@ -1041,8 +1038,8 @@ public sealed partial class DeviceReport mediaTest.CanReadLayerCapacity = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrLayerCapacity, - 0, _dev.Timeout, out _); + MmcDiscStructureFormat.DvdrLayerCapacity, 0, + _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLayerCapacity); @@ -1064,8 +1061,8 @@ public sealed partial class DeviceReport mediaTest.CanReadDiscInformation = !_dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.DiscInformation, - 0, _dev.Timeout, out _); + MmcDiscStructureFormat.DiscInformation, 0, + _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDiscInformation); @@ -1117,8 +1114,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead10); @@ -1129,8 +1126,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead12); @@ -1141,8 +1138,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead16); @@ -1165,8 +1162,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead10); @@ -1177,8 +1174,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead12); @@ -1189,8 +1186,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsRead16); @@ -1222,11 +1219,10 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); @@ -1253,11 +1249,10 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); @@ -1284,9 +1279,9 @@ public sealed partial class DeviceReport ctx.AddTask("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, + 0x00000211, 2352, MmcSectorTypes.AllTypes, false, + false, MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _); }); @@ -1310,10 +1305,9 @@ public sealed partial class DeviceReport 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 @@ -1346,10 +1340,9 @@ public sealed partial class DeviceReport 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 Report", "Sense = {0}", sense); @@ -1374,16 +1367,15 @@ public sealed partial class DeviceReport mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false, false, false, - MmcHeaderCodes.None, true, false, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, out _); else mediaTest.CanReadLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLeadOut); @@ -1428,9 +1420,8 @@ public sealed partial class DeviceReport 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 _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); @@ -1438,9 +1429,8 @@ public sealed partial class DeviceReport 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 _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, + MmcSubchannel.Raw, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); @@ -1474,51 +1464,48 @@ public sealed partial class DeviceReport 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 _); + 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, MmcErrorField.C2PointersAndBlock, + 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 _); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadPQSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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 _); + 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, MmcErrorField.C2PointersAndBlock, + 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 _); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadRWSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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, MmcErrorField.C2Pointers, - MmcSubchannel.Rw, _dev.Timeout, - out _); + 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 _); 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, out _); @@ -1567,8 +1554,8 @@ public sealed partial class DeviceReport 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 _); + MmcErrorField.None, MmcSubchannel.Q16, _dev.Timeout, + out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); @@ -1577,8 +1564,8 @@ public sealed partial class DeviceReport 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 _); + MmcErrorField.None, MmcSubchannel.Raw, _dev.Timeout, + out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); @@ -1608,58 +1595,50 @@ 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 _); + 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, + 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 Report", "Sense = {0}", - !mediaTest.CanReadPQSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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 _); + 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, + 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 Report", "Sense = {0}", - !mediaTest.CanReadRWSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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 _); if(mediaTest.CanReadCorrectedSubchannelWithC2 == false) - mediaTest.CanReadCorrectedSubchannelWithC2 = !_dev.ReadCd(out buffer, out senseBuffer, - 16, 2714, 1, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - 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, out _); @@ -1707,9 +1686,8 @@ public sealed partial class DeviceReport 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 _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); @@ -1717,17 +1695,16 @@ public sealed partial class DeviceReport 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 _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, + MmcSubchannel.Raw, _dev.Timeout, out _); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); mediaTest.RWSubchannelData = buffer; mediaTest.CanReadCorrectedSubchannel = !_dev.ReadCd(out buffer, out senseBuffer, 16, 2144, 1, - MmcSectorTypes.AllTypes, false, false, - false, MmcHeaderCodes.None, true, false, + MmcSectorTypes.AllTypes, false, false, false, + MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.Rw, _dev.Timeout, out _); @@ -1749,55 +1726,50 @@ 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 _); + 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, MmcErrorField.C2PointersAndBlock, + 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 _); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadPQSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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 _); + 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, MmcErrorField.C2PointersAndBlock, + 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 _); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadRWSubchannelWithC2); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {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, out _); @@ -1961,8 +1933,8 @@ public sealed partial class DeviceReport if(tryMediaTekF106) { - bool triedLba0 = false; - bool triedLeadOut = false; + var triedLba0 = false; + var triedLeadOut = false; Spectre.ProgressSingleSpinner(ctx => { @@ -1971,9 +1943,8 @@ 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; } @@ -1992,8 +1963,8 @@ public sealed partial class DeviceReport 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, out _); + MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + out _); triedLba0 = true; } @@ -2009,8 +1980,7 @@ public sealed partial class DeviceReport } else if(mediaTest.SupportsRead12 == true) { - _dev.Read12(out _, out _, 0, false, true, false, false, 0, 2048, 0, 1, false, _dev.Timeout, - out _); + _dev.Read12(out _, out _, 0, false, true, false, false, 0, 2048, 0, 1, false, _dev.Timeout, out _); triedLba0 = true; } @@ -2050,8 +2020,8 @@ 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, + _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; @@ -2060,8 +2030,8 @@ 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, + _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; @@ -2073,15 +2043,15 @@ 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; } @@ -2098,8 +2068,7 @@ public sealed partial class DeviceReport mediaTest.CanReadF1_06LeadOut = !_dev.MediaTekReadDram(out buffer, out senseBuffer, 0, 0xB00, _dev.Timeout, out _); - mediaTest.ReadF1_06LeadOutData = - mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer; + mediaTest.ReadF1_06LeadOutData = mediaTest.CanReadF1_06LeadOut == true ? buffer : senseBuffer; // This means it has returned the same as previous read, so not really lead-out. if(mediaTest.CanReadF1_06 == true && @@ -2162,8 +2131,7 @@ public sealed partial class DeviceReport return null; } - AaruConsole.DebugWriteLine("SCSI Report", - "First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}", + AaruConsole.DebugWriteLine("SCSI Report", "First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}", firstSessionLeadOutTrack.PMIN, firstSessionLeadOutTrack.PSEC, firstSessionLeadOutTrack.PFRAME); @@ -2172,14 +2140,14 @@ public sealed partial class DeviceReport secondSessionFirstTrack.PFRAME); // Skip Lead-Out pre-gap - uint firstSessionLeadOutLba = (uint)((firstSessionLeadOutTrack.PMIN * 60 * 75) + - (firstSessionLeadOutTrack.PSEC * 75) + - firstSessionLeadOutTrack.PFRAME + 150); + var firstSessionLeadOutLba = (uint)(firstSessionLeadOutTrack.PMIN * 60 * 75 + + firstSessionLeadOutTrack.PSEC * 75 + + firstSessionLeadOutTrack.PFRAME + 150); // Skip second session track pre-gap - uint secondSessionLeadInLba = (uint)((secondSessionFirstTrack.PMIN * 60 * 75) + - (secondSessionFirstTrack.PSEC * 75) + - secondSessionFirstTrack.PFRAME - 300); + var secondSessionLeadInLba = (uint)(secondSessionFirstTrack.PMIN * 60 * 75 + + secondSessionFirstTrack.PSEC * 75 + + secondSessionFirstTrack.PFRAME - 300); Spectre.ProgressSingleSpinner(ctx => { @@ -2196,12 +2164,10 @@ public sealed partial class DeviceReport { mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, firstSessionLeadOutLba, 2368, 1, - MmcSectorTypes.AllTypes, false, - false, false, - MmcHeaderCodes.AllHeaders, true, + MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.AllHeaders, true, false, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + MmcSubchannel.Q16, _dev.Timeout, out _); if(mediaTest.CanReadingIntersessionLeadOut == false) mediaTest.CanReadingIntersessionLeadOut = !_dev.ReadCd(out buffer, out senseBuffer, @@ -2215,8 +2181,7 @@ public sealed partial class DeviceReport } }); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadingIntersessionLeadOut); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadOut); mediaTest.IntersessionLeadOutData = buffer; @@ -2236,25 +2201,22 @@ public sealed partial class DeviceReport 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 _); + 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, + MmcSectorTypes.AllTypes, false, false, + false, MmcHeaderCodes.AllHeaders, + true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _); } }); - AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", - !mediaTest.CanReadingIntersessionLeadIn); + AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadingIntersessionLeadIn); mediaTest.IntersessionLeadInData = buffer; } diff --git a/Aaru.Core/Devices/Report/PCMCIA.cs b/Aaru.Core/Devices/Report/PCMCIA.cs index 1ee78ef15..a948466c9 100644 --- a/Aaru.Core/Devices/Report/PCMCIA.cs +++ b/Aaru.Core/Devices/Report/PCMCIA.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using Aaru.CommonTypes.Metadata; using Aaru.Decoders.PCMCIA; -namespace Aaru.Core.Devices.Report; - /// Implements creating a report for a PCMCIA device public sealed partial class DeviceReport { diff --git a/Aaru.Core/Devices/Report/SSC.cs b/Aaru.Core/Devices/Report/SSC.cs index d5e49806e..853e8ef47 100644 --- a/Aaru.Core/Devices/Report/SSC.cs +++ b/Aaru.Core/Devices/Report/SSC.cs @@ -30,15 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using System; using System.Linq; using Aaru.CommonTypes.Metadata; using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.SSC; using Aaru.Devices; -using Spectre.Console; - -namespace Aaru.Core.Devices.Report; +using global::Spectre.Console; public sealed partial class DeviceReport { @@ -47,7 +47,7 @@ public sealed partial class DeviceReport public Ssc ReportScsiSsc() { var report = new Ssc(); - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); Spectre.ProgressSingleSpinner(ctx => @@ -82,9 +82,9 @@ public sealed partial class DeviceReport if(dsh.HasValue) { - SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length]; + var array = new SupportedDensity[dsh.Value.descriptors.Length]; - for(int i = 0; i < dsh.Value.descriptors.Length; i++) + for(var i = 0; i < dsh.Value.descriptors.Length; i++) array[i] = new SupportedDensity { BitsPerMm = dsh.Value.descriptors[i].bpmm, @@ -119,9 +119,9 @@ public sealed partial class DeviceReport if(!mtsh.HasValue) return report; - SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length]; + var array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length]; - for(int i = 0; i < mtsh.Value.descriptors.Length; i++) + for(var i = 0; i < mtsh.Value.descriptors.Length; i++) { array2[i] = new SscSupportedMedia { @@ -136,9 +136,9 @@ public sealed partial class DeviceReport if(mtsh.Value.descriptors[i].densityCodes == null) continue; - DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; + var array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; - for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++) + for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++) array3[j] = new DensityCode { Code = mtsh.Value.descriptors[i].densityCodes[j] @@ -157,7 +157,7 @@ public sealed partial class DeviceReport public TestedSequentialMedia ReportSscMedia() { var seqTest = new TestedSequentialMedia(); - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); Modes.DecodedMode? decMode = null; @@ -211,9 +211,9 @@ public sealed partial class DeviceReport if(dsh.HasValue) { - SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length]; + var array = new SupportedDensity[dsh.Value.descriptors.Length]; - for(int i = 0; i < dsh.Value.descriptors.Length; i++) + for(var i = 0; i < dsh.Value.descriptors.Length; i++) array[i] = new SupportedDensity { BitsPerMm = dsh.Value.descriptors[i].bpmm, @@ -236,8 +236,7 @@ public sealed partial class DeviceReport Spectre.ProgressSingleSpinner(ctx => { - ctx.AddTask("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media..."). - IsIndeterminate(); + ctx.AddTask("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...").IsIndeterminate(); sense = _dev.ReportDensitySupport(out buffer, out _, true, true, _dev.Timeout, out _); }); @@ -248,9 +247,9 @@ public sealed partial class DeviceReport if(mtsh.HasValue) { - SscSupportedMedia[] array = new SscSupportedMedia[mtsh.Value.descriptors.Length]; + var array = new SscSupportedMedia[mtsh.Value.descriptors.Length]; - for(int i = 0; i < mtsh.Value.descriptors.Length; i++) + for(var i = 0; i < mtsh.Value.descriptors.Length; i++) { array[i] = new SscSupportedMedia { @@ -265,9 +264,9 @@ public sealed partial class DeviceReport if(mtsh.Value.descriptors[i].densityCodes == null) continue; - DensityCode[] array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; + var array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length]; - for(int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++) + for(var j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++) array2[j] = new DensityCode { Code = mtsh.Value.descriptors[i].densityCodes[j] diff --git a/Aaru.Core/Devices/Report/Scsi.cs b/Aaru.Core/Devices/Report/Scsi.cs index ff89b362b..d832246c7 100644 --- a/Aaru.Core/Devices/Report/Scsi.cs +++ b/Aaru.Core/Devices/Report/Scsi.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using System; using System.Collections.Generic; using System.Linq; @@ -39,18 +41,16 @@ using Aaru.Console; using Aaru.Decoders.SCSI; using Aaru.Devices; using Aaru.Helpers; -using Spectre.Console; +using global::Spectre.Console; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; -namespace Aaru.Core.Devices.Report; - public sealed partial class DeviceReport { /// Creates a report for the SCSI INQUIRY response /// SCSI report public Scsi ReportScsiInquiry() { - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); Spectre.ProgressSingleSpinner(ctx => @@ -88,7 +88,7 @@ public sealed partial class DeviceReport return inquiry; // Clear Seagate serial number - for(int i = 36; i <= 43; i++) + for(var i = 36; i <= 43; i++) inquiry[i] = 0; return inquiry; @@ -99,7 +99,7 @@ public sealed partial class DeviceReport /// List of decoded SCSI EVPD pages public List ReportEvpdPages(string vendor) { - bool sense = false; + var sense = false; byte[] buffer = Array.Empty(); Spectre.ProgressSingleSpinner(ctx => @@ -122,8 +122,8 @@ public sealed partial class DeviceReport Spectre.ProgressSingleSpinner(ctx => { ProgressTask task = ctx. - AddTask("Querying SCSI EVPD pages...", - maxValue: evpdPages.Count(page => page != 0x80)).IsIndeterminate(); + AddTask("Querying SCSI EVPD pages...", maxValue: evpdPages.Count(page => page != 0x80)). + IsIndeterminate(); foreach(byte page in evpdPages.Where(page => page != 0x80)) { @@ -143,7 +143,7 @@ public sealed partial class DeviceReport break; case 0x80: - byte[] identify = new byte[512]; + var identify = new byte[512]; Array.Copy(buffer, 60, identify, 0, 512); identify = ClearIdentify(identify); Array.Copy(identify, 0, buffer, 60, 512); @@ -195,7 +195,7 @@ public sealed partial class DeviceReport if(pageResponse.Length < 6) return null; - int position = 4; + var position = 4; while(position < pageResponse.Length) { @@ -204,7 +204,7 @@ public sealed partial class DeviceReport if(length + position + 4 >= pageResponse.Length) length = (byte)(pageResponse.Length - position - 4); - byte[] empty = new byte[length]; + var empty = new byte[length]; Array.Copy(empty, 0, pageResponse, position + 4, length); position += 4 + length; @@ -238,10 +238,10 @@ public sealed partial class DeviceReport ScsiModeSensePageControl.Changeable }) { - bool saveBuffer = false; + var saveBuffer = false; - sense = _dev.ModeSense10(out mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF, - _dev.Timeout, out _); + sense = _dev.ModeSense10(out mode10Buffer, out _, false, true, pageControl, 0x3F, 0xFF, _dev.Timeout, + out _); if(sense || _dev.Error) { @@ -320,7 +320,7 @@ public sealed partial class DeviceReport ScsiModeSensePageControl.Changeable }) { - bool saveBuffer = false; + var saveBuffer = false; sense = _dev.ModeSense6(out mode6Buffer, out _, true, pageControl, 0x3F, 0xFF, _dev.Timeout, out _); if(sense || _dev.Error) @@ -466,7 +466,7 @@ public sealed partial class DeviceReport public TestedMedia ReportScsiMedia() { var mediaTest = new TestedMedia(); - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); byte[] senseBuffer = Array.Empty(); @@ -497,7 +497,7 @@ public sealed partial class DeviceReport !_dev.Error) { mediaTest.SupportsReadCapacity16 = true; - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(buffer, 0, temp, 0, 8); Array.Reverse(temp); mediaTest.Blocks = BitConverter.ToUInt64(temp, 0) + 1; @@ -510,8 +510,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 && @@ -673,10 +673,9 @@ public sealed partial class DeviceReport }) { sense = mediaTest.SupportsReadLong16 == true - ? _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.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + out _) : _dev.ReadLong10(out buffer, out senseBuffer, false, + false, 0, testSize, _dev.Timeout, out _); if(sense || _dev.Error) continue; @@ -700,10 +699,9 @@ public sealed partial class DeviceReport }) { sense = mediaTest.SupportsReadLong16 == true - ? _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.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout, + out _) : _dev.ReadLong10(out buffer, out senseBuffer, false, + false, 0, testSize, _dev.Timeout, out _); if(sense || _dev.Error) continue; @@ -718,9 +716,9 @@ public sealed partial class DeviceReport case 2048: { 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, out _); + ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 2380, _dev.Timeout, out _) + : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout, + out _); if(!sense && !_dev.Error) @@ -731,9 +729,9 @@ public sealed partial class DeviceReport case 4096: { 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, out _); + ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 4760, _dev.Timeout, out _) + : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout, + out _); if(!sense && !_dev.Error) @@ -744,9 +742,9 @@ public sealed partial class DeviceReport case 8192: { 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, out _); + ? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, 9424, _dev.Timeout, out _) + : _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout, + out _); if(!sense && !_dev.Error) @@ -772,7 +770,7 @@ public sealed partial class DeviceReport /// Media report public TestedMedia ReportScsi() { - bool sense = true; + var sense = true; byte[] buffer = Array.Empty(); byte[] senseBuffer = Array.Empty(); @@ -808,7 +806,7 @@ public sealed partial class DeviceReport !_dev.Error) { capabilities.SupportsReadCapacity16 = true; - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(buffer, 0, temp, 0, 8); Array.Reverse(temp); capabilities.Blocks = BitConverter.ToUInt64(temp, 0) + 1; @@ -821,8 +819,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 && @@ -869,8 +867,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !capabilities.SupportsRead10); @@ -880,9 +878,8 @@ public sealed partial class DeviceReport { ctx.AddTask("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 Report", "Sense = {0}", !capabilities.SupportsRead12); @@ -893,8 +890,7 @@ public sealed partial class DeviceReport ctx.AddTask("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.BlockSize ?? 512, 0, 1, false, _dev.Timeout, out _); }); AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !capabilities.SupportsRead16); @@ -969,7 +965,7 @@ public sealed partial class DeviceReport } } - if((capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true) || + if(capabilities.SupportsReadLong != true && capabilities.SupportsReadLong16 != true || capabilities.LongBlockSize != capabilities.BlockSize) return capabilities; diff --git a/Aaru.Core/Devices/Report/SecureDigital.cs b/Aaru.Core/Devices/Report/SecureDigital.cs index 33630c1da..884bcbbb0 100644 --- a/Aaru.Core/Devices/Report/SecureDigital.cs +++ b/Aaru.Core/Devices/Report/SecureDigital.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Report; + using System; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Metadata; using Aaru.Console; -using Spectre.Console; - -namespace Aaru.Core.Devices.Report; +using global::Spectre.Console; /// Implements creating a device report for a SecureDigital or MultiMediaCard flash card public sealed partial class DeviceReport @@ -45,7 +45,7 @@ public sealed partial class DeviceReport public MmcSd MmcSdReport() { var report = new MmcSd(); - bool sense = true; + var sense = true; byte[] cid = Array.Empty(); byte[] csd = Array.Empty(); byte[] ecsd = Array.Empty(); diff --git a/Aaru.Core/Devices/Report/USB.cs b/Aaru.Core/Devices/Report/USB.cs index 899cbff81..8cd4d8c6e 100644 --- a/Aaru.Core/Devices/Report/USB.cs +++ b/Aaru.Core/Devices/Report/USB.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Metadata; - namespace Aaru.Core.Devices.Report; +using Aaru.CommonTypes.Metadata; + /// Implements creating a report for a USB device public sealed partial class DeviceReport { diff --git a/Aaru.Core/Devices/Scanning/ATA.cs b/Aaru.Core/Devices/Scanning/ATA.cs index fbafddfc5..747fd2ec6 100644 --- a/Aaru.Core/Devices/Scanning/ATA.cs +++ b/Aaru.Core/Devices/Scanning/ATA.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Scanning; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs.Devices.ATA; using Aaru.Core.Logging; -namespace Aaru.Core.Devices.Scanning; - /// Implements scanning the media from an ATA device public sealed partial class MediaScan { @@ -210,12 +210,12 @@ public sealed partial class MediaScan InitProgress?.Invoke(); if(ataReader.CanSeekLba && _seekTest) - for(int i = 0; i < seekTimes; i++) + for(var i = 0; i < seekTimes; i++) { if(_aborted) break; - uint seekPos = (uint)rnd.Next((int)results.Blocks); + var seekPos = (uint)rnd.Next((int)results.Blocks); PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t"); @@ -326,17 +326,16 @@ public sealed partial class MediaScan InitProgress?.Invoke(); if(ataReader.CanSeek) - for(int i = 0; i < seekTimes; i++) + for(var i = 0; i < seekTimes; i++) { if(_aborted) break; - ushort seekCy = (ushort)rnd.Next(cylinders); - byte seekHd = (byte)rnd.Next(heads); - byte seekSc = (byte)rnd.Next(sectors); + var seekCy = (ushort)rnd.Next(cylinders); + var seekHd = (byte)rnd.Next(heads); + var seekSc = (byte)rnd.Next(sectors); - PulseProgress?. - Invoke($"\rSeeking to cylinder {seekCy}, head {seekHd}, sector {seekSc}...\t\t"); + PulseProgress?.Invoke($"\rSeeking to cylinder {seekCy}, head {seekHd}, sector {seekSc}...\t\t"); ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur); diff --git a/Aaru.Core/Devices/Scanning/MediaScan.cs b/Aaru.Core/Devices/Scanning/MediaScan.cs index 168ce0fc7..87355e90e 100644 --- a/Aaru.Core/Devices/Scanning/MediaScan.cs +++ b/Aaru.Core/Devices/Scanning/MediaScan.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Scanning; + using System; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.Devices; -namespace Aaru.Core.Devices.Scanning; - public sealed partial class MediaScan { readonly Device _dev; diff --git a/Aaru.Core/Devices/Scanning/NVMe.cs b/Aaru.Core/Devices/Scanning/NVMe.cs index 7888249c3..3015c3743 100644 --- a/Aaru.Core/Devices/Scanning/NVMe.cs +++ b/Aaru.Core/Devices/Scanning/NVMe.cs @@ -38,6 +38,6 @@ public sealed partial class MediaScan { StoppingErrorMessage?.Invoke("NVMe devices not yet supported."); - return default; + return default(ScanResults); } } \ No newline at end of file diff --git a/Aaru.Core/Devices/Scanning/SCSI.cs b/Aaru.Core/Devices/Scanning/SCSI.cs index 179e92838..d05281b5a 100644 --- a/Aaru.Core/Devices/Scanning/SCSI.cs +++ b/Aaru.Core/Devices/Scanning/SCSI.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Devices.Scanning; + using System; using System.Collections.Generic; using System.Threading; @@ -41,8 +43,6 @@ using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; using Aaru.Devices; -namespace Aaru.Core.Devices.Scanning; - /// Implements scanning the media from an SCSI device public sealed partial class MediaScan { @@ -55,8 +55,8 @@ public sealed partial class MediaScan bool sense; uint blockSize = 0; ushort currentProfile = 0x0001; - bool foundReadCommand = false; - bool readcd = false; + var foundReadCommand = false; + var readcd = false; results.Blocks = 0; @@ -74,7 +74,7 @@ public sealed partial class MediaScan { case 0x3A: { - int leftRetries = 5; + var leftRetries = 5; while(leftRetries > 0) { @@ -99,7 +99,7 @@ public sealed partial class MediaScan } case 0x04 when decSense.Value.ASCQ == 0x01: { - int leftRetries = 10; + var leftRetries = 10; while(leftRetries > 0) { @@ -127,7 +127,7 @@ public sealed partial class MediaScan // These should be trapped by the OS but seems in some cases they're not case 0x28: { - int leftRetries = 10; + var leftRetries = 10; while(leftRetries > 0) { @@ -232,7 +232,7 @@ public sealed partial class MediaScan return results; } - bool compactDisc = true; + var compactDisc = true; FullTOC.CDFullTOC? toc = null; if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) @@ -339,8 +339,7 @@ public sealed partial class MediaScan if(_dev.Error) { - StoppingErrorMessage?. - Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); + StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); return results; } @@ -373,19 +372,15 @@ public sealed partial class MediaScan currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (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); - } + 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 _); - } results.ProcessingTime += cmdDuration; @@ -414,13 +409,12 @@ public sealed partial class MediaScan if(readcd) { - AaruConsole.DebugWriteLine("Media-Scan", "READ CD error:\n{0}", - Sense.PrettifySense(senseBuf)); + AaruConsole.DebugWriteLine("Media-Scan", "READ CD error:\n{0}", Sense.PrettifySense(senseBuf)); senseDecoded = Sense.Decode(senseBuf); if(senseDecoded.HasValue) - { + // TODO: This error happens when changing from track type afaik. Need to solve that more cleanly // LOGICAL BLOCK ADDRESS OUT OF RANGE if((senseDecoded.Value.ASC != 0x21 || senseDecoded.Value.ASCQ != 0x00) && @@ -439,7 +433,6 @@ public sealed partial class MediaScan ibgLog.Write(i, 0); } - } } if(!senseDecoded.HasValue) @@ -519,8 +512,8 @@ public sealed partial class MediaScan currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", - (long)i, (long)results.Blocks); + UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, + (long)results.Blocks); sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration, out _, out _); results.ProcessingTime += cmdDuration; @@ -590,12 +583,12 @@ public sealed partial class MediaScan InitProgress?.Invoke(); - for(int i = 0; i < seekTimes; i++) + for(var i = 0; i < seekTimes; i++) { if(_aborted || !_seekTest) break; - uint seekPos = (uint)rnd.Next((int)results.Blocks); + var seekPos = (uint)rnd.Next((int)results.Blocks); PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t"); @@ -605,8 +598,8 @@ 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, out seekCur); + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, + out seekCur); else scsiReader.ReadBlock(out _, seekPos, out seekCur, out _, out _); diff --git a/Aaru.Core/Devices/Scanning/ScanResults.cs b/Aaru.Core/Devices/Scanning/ScanResults.cs index 4093c8671..b6f266833 100644 --- a/Aaru.Core/Devices/Scanning/ScanResults.cs +++ b/Aaru.Core/Devices/Scanning/ScanResults.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; - namespace Aaru.Core.Devices.Scanning; +using System.Collections.Generic; + /// Contains the results of a media scan public struct ScanResults { diff --git a/Aaru.Core/Devices/Scanning/SecureDigital.cs b/Aaru.Core/Devices/Scanning/SecureDigital.cs index eff52900b..2fc6f9c64 100644 --- a/Aaru.Core/Devices/Scanning/SecureDigital.cs +++ b/Aaru.Core/Devices/Scanning/SecureDigital.cs @@ -30,18 +30,21 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Devices.Scanning; + using System; using System.Collections.Generic; using Aaru.Core.Logging; using Aaru.Decoders.MMC; using Aaru.Decoders.SecureDigital; using CSD = Aaru.Decoders.MMC.CSD; +using Decoders = Aaru.Decoders.MMC.Decoders; using DeviceType = Aaru.CommonTypes.Enums.DeviceType; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Devices.Scanning; - /// Implements scanning a SecureDigital or MultiMediaCard flash card public sealed partial class MediaScan { @@ -56,8 +59,8 @@ public sealed partial class MediaScan const ushort sdProfile = 0x0001; ushort blocksToRead = 128; uint blockSize = 512; - bool byteAddressed = true; - bool supportsCmd23 = false; + var byteAddressed = true; + var supportsCmd23 = false; switch(_dev.Type) { @@ -67,7 +70,7 @@ public sealed partial class MediaScan if(!sense) { - CSD csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf); + CSD csd = Decoders.DecodeCSD(cmdBuf); results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)); blockSize = (uint)Math.Pow(2, csd.ReadBlockLength); @@ -80,7 +83,7 @@ public sealed partial class MediaScan if(!sense) { - ExtendedCSD ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf); + ExtendedCSD ecsd = Decoders.DecodeExtendedCSD(cmdBuf); results.Blocks = ecsd.SectorCount; blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512); @@ -104,11 +107,10 @@ public sealed partial class MediaScan if(!sense) { - Decoders.SecureDigital.CSD csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf); + Aaru.Decoders.SecureDigital.CSD csd = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf); - results.Blocks = (ulong)(csd.Structure == 0 - ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2) - : (csd.Size + 1) * 1024); + results.Blocks = (ulong)(csd.Structure == 0 ? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2) + : (csd.Size + 1) * 1024); blockSize = (uint)Math.Pow(2, csd.ReadBlockLength); @@ -125,8 +127,8 @@ public sealed partial class MediaScan sense = _dev.ReadScr(out cmdBuf, out _, timeout, out _); if(!sense) - supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.CommandSupport. - HasFlag(CommandSupport.SetBlockCount) ?? false; + supportsCmd23 = Aaru.Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.CommandSupport. + HasFlag(CommandSupport.SetBlockCount) ?? false; } break; @@ -142,13 +144,11 @@ public sealed partial class MediaScan if(supportsCmd23) { - sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, - out duration); + sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, 1, byteAddressed, timeout, out duration); if(sense || _dev.Error) { - UpdateStatus?. - Invoke("Environment does not support setting block count, downgrading to OS reading."); + UpdateStatus?.Invoke("Environment does not support setting block count, downgrading to OS reading."); supportsCmd23 = false; } @@ -168,8 +168,8 @@ public sealed partial class MediaScan { while(true) { - sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, - timeout, out duration); + sense = _dev.ReadWithBlockCount(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, + out duration); if(sense) blocksToRead /= 2; @@ -181,8 +181,7 @@ public sealed partial class MediaScan if(sense) { - StoppingErrorMessage?. - Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); + StoppingErrorMessage?.Invoke($"Device error {_dev.LastError} trying to guess ideal transfer length."); return results; } @@ -253,11 +252,10 @@ public sealed partial class MediaScan 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); + 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) { @@ -309,17 +307,16 @@ public sealed partial class MediaScan mhddLog.Close(); ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), - _devicePath); + blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); InitProgress?.Invoke(); - for(int i = 0; i < seekTimes; i++) + for(var i = 0; i < seekTimes; i++) { if(_aborted || !_seekTest) break; - uint seekPos = (uint)rnd.Next((int)results.Blocks); + var seekPos = (uint)rnd.Next((int)results.Blocks); PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t"); diff --git a/Aaru.Core/Entropy.cs b/Aaru.Core/Entropy.cs index e6182635f..cd5b37839 100644 --- a/Aaru.Core/Entropy.cs +++ b/Aaru.Core/Entropy.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Linq; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; -namespace Aaru.Core; - /// Media image entropy operations public sealed class Entropy { @@ -102,7 +102,7 @@ public sealed class Entropy Invoke($"Entropying track {currentTrack.Sequence} of {inputTracks.Max(t => t.Sequence)}", currentTrack.Sequence, inputTracks.Max(t => t.Sequence)); - ulong[] entTable = new ulong[256]; + var entTable = new ulong[256]; ulong trackSize = 0; List uniqueSectorsPerTrack = new(); @@ -177,7 +177,7 @@ public sealed class Entropy if(_inputFormat is not IMediaImage mediaImage) return entropy; - ulong[] entTable = new ulong[256]; + var entTable = new ulong[256]; ulong diskSize = 0; List uniqueSectors = new(); @@ -234,8 +234,8 @@ public sealed class Entropy if(_inputFormat is not IByteAddressableImage byteAddressableImage) return entropy; - ulong[] entTable = new ulong[256]; - byte[] data = new byte[byteAddressableImage.Info.Sectors]; + var entTable = new ulong[256]; + var data = new byte[byteAddressableImage.Info.Sectors]; entropy.Sectors = _inputFormat.Info.Sectors; AaruConsole.WriteLine("{0} bytes", entropy.Sectors); @@ -252,7 +252,7 @@ public sealed class Entropy if(bytesRead != data.Length) { - byte[] tmp = new byte[bytesRead]; + var tmp = new byte[bytesRead]; Array.Copy(data, 0, tmp, 0, bytesRead); data = tmp; } diff --git a/Aaru.Core/Error.cs b/Aaru.Core/Error.cs index d451cbb1e..a452f9ebd 100644 --- a/Aaru.Core/Error.cs +++ b/Aaru.Core/Error.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Interop; - namespace Aaru.Core; +using Aaru.CommonTypes.Interop; + /// Prints the description of a system error number. public static class Error { diff --git a/Aaru.Core/Filesystems.cs b/Aaru.Core/Filesystems.cs index 6287fa171..ece142203 100644 --- a/Aaru.Core/Filesystems.cs +++ b/Aaru.Core/Filesystems.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Core; - /// Core filesystem operations public static class Filesystems { diff --git a/Aaru.Core/GetPluginBase.cs b/Aaru.Core/GetPluginBase.cs index 391ddc82d..1027e0f10 100644 --- a/Aaru.Core/GetPluginBase.cs +++ b/Aaru.Core/GetPluginBase.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using Aaru.Checksums; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Core; - /// Plugin base operations public static class GetPluginBase { diff --git a/Aaru.Core/ImageFormat.cs b/Aaru.Core/ImageFormat.cs index 68f735f97..08d1aefea 100644 --- a/Aaru.Core/ImageFormat.cs +++ b/Aaru.Core/ImageFormat.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Linq; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.Core; - /// Core media image format operations public static class ImageFormat { diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index 896311e05..c54a100dd 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Linq; @@ -47,18 +49,17 @@ using Aaru.Decoders.CD; using Aaru.Decoders.DVD; using Aaru.Decoders.PCMCIA; using Aaru.Decoders.SCSI; +using Aaru.Decoders.SecureDigital; using Aaru.Decoders.Xbox; using Aaru.Helpers; +using global::Spectre.Console; using Schemas; -using Spectre.Console; using DDS = Aaru.Decoders.DVD.DDS; using DMI = Aaru.Decoders.Xbox.DMI; using Inquiry = Aaru.Decoders.SCSI.Inquiry; using Session = Aaru.CommonTypes.Structs.Session; using Tuple = Aaru.Decoders.PCMCIA.Tuple; -namespace Aaru.Core; - /// Image information operations public static class ImageInfo { @@ -394,7 +395,7 @@ public static class ImageInfo if(dataLen + 2 != toc.Length) { - byte[] tmp = new byte[toc.Length + 2]; + var tmp = new byte[toc.Length + 2]; Array.Copy(toc, 0, tmp, 2, toc.Length); tmp[0] = (byte)((toc.Length & 0xFF00) >> 8); tmp[1] = (byte)(toc.Length & 0xFF); @@ -418,7 +419,7 @@ public static class ImageInfo if(dataLen + 2 != pma.Length) { - byte[] tmp = new byte[pma.Length + 2]; + var tmp = new byte[pma.Length + 2]; Array.Copy(pma, 0, tmp, 2, pma.Length); tmp[0] = (byte)((pma.Length & 0xFF00) >> 8); tmp[1] = (byte)(pma.Length & 0xFF); @@ -441,7 +442,7 @@ public static class ImageInfo if(dataLen + 4 != atip.Length) { - byte[] tmp = new byte[atip.Length + 4]; + var tmp = new byte[atip.Length + 4]; Array.Copy(atip, 0, tmp, 4, atip.Length); tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24); tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16); @@ -466,7 +467,7 @@ public static class ImageInfo if(dataLen + 4 != cdtext.Length) { - byte[] tmp = new byte[cdtext.Length + 4]; + var tmp = new byte[cdtext.Length + 4]; Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); @@ -561,7 +562,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]Bluray Disc Definition Structure contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.Bluray.DDS.Prettify(dds)); + AaruConsole.Write("{0}", Aaru.Decoders.Bluray.DDS.Prettify(dds)); AaruConsole.WriteLine(); } } @@ -650,7 +651,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]SecureDigital CID contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCID(cid)); + AaruConsole.Write("{0}", Decoders.PrettifyCID(cid)); AaruConsole.WriteLine(); } } @@ -662,7 +663,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]SecureDigital CSD contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCSD(csd)); + AaruConsole.Write("{0}", Decoders.PrettifyCSD(csd)); AaruConsole.WriteLine(); } } @@ -674,7 +675,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]SecureDigital SCR contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifySCR(scr)); + AaruConsole.Write("{0}", Decoders.PrettifySCR(scr)); AaruConsole.WriteLine(); } } @@ -686,7 +687,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]SecureDigital OCR contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyOCR(ocr)); + AaruConsole.Write("{0}", Decoders.PrettifyOCR(ocr)); AaruConsole.WriteLine(); } } @@ -698,7 +699,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]MultiMediaCard CID contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCID(cid)); + AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCID(cid)); AaruConsole.WriteLine(); } } @@ -710,7 +711,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]MultiMediaCard CSD contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCSD(csd)); + AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCSD(csd)); AaruConsole.WriteLine(); } } @@ -722,7 +723,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]MultiMediaCard ExtendedCSD contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd)); + AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd)); AaruConsole.WriteLine(); } } @@ -734,7 +735,7 @@ public static class ImageInfo if(errno == ErrorNumber.NoError) { AaruConsole.WriteLine("[bold]MultiMediaCard OCR contained in image:[/]"); - AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyOCR(ocr)); + AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyOCR(ocr)); AaruConsole.WriteLine(); } } diff --git a/Aaru.Core/Logging/DumpLog.cs b/Aaru.Core/Logging/DumpLog.cs index 27ca8c17a..270ebcf00 100644 --- a/Aaru.Core/Logging/DumpLog.cs +++ b/Aaru.Core/Logging/DumpLog.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Logging; + using System; using System.IO; using System.Reflection; @@ -39,8 +41,6 @@ using Aaru.Devices; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Core.Logging; - /// Creates a dump log public sealed class DumpLog { @@ -91,7 +91,7 @@ public sealed class DumpLog { string[] args = Environment.GetCommandLineArgs(); - for(int i = 0; i < args.Length; i++) + for(var i = 0; i < args.Length; i++) { if(args[i].StartsWith("/dev", StringComparison.OrdinalIgnoreCase) || args[i].StartsWith("aaru://", StringComparison.OrdinalIgnoreCase)) @@ -120,8 +120,7 @@ public sealed class DumpLog _logSw.WriteLine("Server: {0}", dev.RemoteApplication); _logSw.WriteLine("Version: {0}", dev.RemoteVersion); - _logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem, - dev.RemoteOperatingSystemVersion); + _logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem, dev.RemoteOperatingSystemVersion); _logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture); _logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion); @@ -184,7 +183,7 @@ public sealed class DumpLog if(_logSw == null) return; - string text = string.Format(format, args); + var text = string.Format(format, args); _logSw.WriteLine("{0:s} {1}", DateTime.Now, text); _logSw.Flush(); } diff --git a/Aaru.Core/Logging/ErrorLog.cs b/Aaru.Core/Logging/ErrorLog.cs index 14272e81b..d9d697adf 100644 --- a/Aaru.Core/Logging/ErrorLog.cs +++ b/Aaru.Core/Logging/ErrorLog.cs @@ -26,6 +26,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Logging; + using System; using System.Collections.Generic; using System.IO; @@ -33,8 +35,6 @@ using System.Linq; using Aaru.Decoders.ATA; using Aaru.Decoders.SCSI; -namespace Aaru.Core.Logging; - /// Logs errors public sealed class ErrorLog { @@ -76,8 +76,8 @@ public sealed class ErrorLog } else { - List error = new List(); - List status = new List(); + var error = new List(); + var status = new List(); if((registers.Status & 0x01) == 0x01) status.Add("ERR"); @@ -153,8 +153,8 @@ public sealed class ErrorLog } else { - List error = new List(); - List status = new List(); + var error = new List(); + var status = new List(); if((registers.Status & 0x01) == 0x01) status.Add("ERR"); @@ -204,8 +204,8 @@ public sealed class ErrorLog if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine("ATA reading C/H/S {0}/{1}/{2} error: status = {3}, error = {4}.", cylinder, head, - sector, string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine("ATA reading C/H/S {0}/{1}/{2} error: status = {3}, error = {4}.", cylinder, head, sector, + string.Join(' ', status), string.Join(' ', error)); _logSw.Flush(); } @@ -225,8 +225,8 @@ public sealed class ErrorLog } else { - List error = new List(); - List status = new List(); + var error = new List(); + var status = new List(); if((registers.Status & 0x01) == 0x01) status.Add("ERR"); @@ -276,8 +276,8 @@ public sealed class ErrorLog if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, - string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -297,8 +297,8 @@ public sealed class ErrorLog } else { - List error = new List(); - List status = new List(); + var error = new List(); + var status = new List(); if((registers.Status & 0x01) == 0x01) status.Add("ERR"); @@ -348,8 +348,8 @@ public sealed class ErrorLog if((registers.Error & 0x80) == 0x80) error.Add("BBK"); - _logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, - string.Join(' ', status), string.Join(' ', error)); + _logSw.WriteLine("ATA reading LBA {0} error: status = {1}, error = {2}.", block, string.Join(' ', status), + string.Join(' ', error)); _logSw.Flush(); } @@ -372,7 +372,7 @@ public sealed class ErrorLog DecodedSense? decodedSense = Sense.Decode(senseBuffer); string prettySense = Sense.PrettifySense(senseBuffer); - string hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}")); + var hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}")); if(decodedSense.HasValue) { @@ -387,15 +387,13 @@ public sealed class ErrorLog prettySense = prettySense.Replace("\n", " - "); _logSw.WriteLine("SCSI command {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}, {5}.", command, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, - hexSense, prettySense); + decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense, + prettySense); } else - { _logSw.WriteLine("SCSI command {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}.", command, decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense); - } } else { @@ -412,9 +410,7 @@ public sealed class ErrorLog _logSw.WriteLine("SCSI command {0} error: {1}, {2}.", command, hexSense, prettySense); } else - { _logSw.WriteLine("SCSI command {0} error: {1}", command, hexSense); - } } _logSw.Flush(); @@ -440,7 +436,7 @@ public sealed class ErrorLog DecodedSense? decodedSense = Sense.Decode(senseBuffer); string prettySense = Sense.PrettifySense(senseBuffer); - string hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}")); + var hexSense = string.Join(' ', senseBuffer.Select(b => $"{b:X2}")); if(decodedSense.HasValue) { @@ -455,15 +451,13 @@ public sealed class ErrorLog prettySense = prettySense.Replace("\n", " - "); _logSw.WriteLine("SCSI reading LBA {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}, {5}.", block, - decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, - hexSense, prettySense); + decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense, + prettySense); } else - { _logSw.WriteLine("SCSI reading LBA {0} error: SENSE {1} ASC {2:X2}h ASCQ {3:X2}h, {4}.", block, decodedSense.Value.SenseKey, decodedSense.Value.ASC, decodedSense.Value.ASCQ, hexSense); - } } else { @@ -480,9 +474,7 @@ public sealed class ErrorLog _logSw.WriteLine("SCSI reading LBA {0} error: {1}, {2}.", block, hexSense, prettySense); } else - { _logSw.WriteLine("SCSI reading LBA {0} error: {1}", block, hexSense); - } } _logSw.Flush(); @@ -529,8 +521,8 @@ public sealed class ErrorLog return; } - _logSw.WriteLine("SD/MMC reading LBA {0} ({1}-addressed) error: {2}", block, - byteAddressed ? "byte" : "block", string.Join(" - ", response.Select(r => $"0x{r:X8}"))); + _logSw.WriteLine("SD/MMC reading LBA {0} ({1}-addressed) error: {2}", block, byteAddressed ? "byte" : "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 d79012306..43ccc4abc 100644 --- a/Aaru.Core/Logging/IBGLog.cs +++ b/Aaru.Core/Logging/IBGLog.cs @@ -30,16 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Logging; + using System; using System.Globalization; using System.IO; using System.Text; using Aaru.Devices; -namespace Aaru.Core.Logging; - /// Implements a log in the format used by IMGBurn -internal sealed class IbgLog +sealed class IbgLog { readonly CultureInfo _ibgCulture; readonly double _ibgDivider; @@ -328,8 +328,7 @@ internal sealed class IbgLog ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_START={0:0.00}", _ibgStartSpeed).AppendLine(); ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / _ibgDivider).AppendLine(); - ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / _ibgDivider). - AppendLine(); + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / _ibgDivider).AppendLine(); ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", _ibgMaxSpeed).AppendLine(); ibgHeader.AppendFormat(_ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine(); diff --git a/Aaru.Core/Logging/MHDDLog.cs b/Aaru.Core/Logging/MHDDLog.cs index f7075d32d..5b796d8dd 100644 --- a/Aaru.Core/Logging/MHDDLog.cs +++ b/Aaru.Core/Logging/MHDDLog.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Logging; + using System; using System.Globalization; using System.IO; @@ -37,10 +39,8 @@ using System.Text; using Aaru.CommonTypes.Enums; using Aaru.Devices; -namespace Aaru.Core.Logging; - /// Implements a log in the format used by MHDD -internal sealed class MhddLog +sealed class MhddLog { const string MHDD_VER = "VER:2 "; readonly string _logFile; @@ -53,8 +53,7 @@ internal sealed class MhddLog /// Bytes per block /// How many blocks read at once /// Disable saving paths or serial numbers in log - internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead, - bool @private) + internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead, bool @private) { if(dev == null || string.IsNullOrEmpty(outputFile)) @@ -94,14 +93,13 @@ internal sealed class MhddLog break; } - string device = $"DEVICE: {dev.Manufacturer} {dev.Model}"; - string fw = $"F/W: {dev.FirmwareRevision}"; - string sn = $"S/N: {(@private ? "" : dev.Serial)}"; - string sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks); - string sectorSize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", blockSize); + var device = $"DEVICE: {dev.Manufacturer} {dev.Model}"; + var fw = $"F/W: {dev.FirmwareRevision}"; + var sn = $"S/N: {(@private ? "" : dev.Serial)}"; + var sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks); + var sectorSize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", blockSize); - string scanBlockSize = - string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead); + var scanBlockSize = string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead); byte[] deviceBytes = Encoding.ASCII.GetBytes(device); byte[] modeBytes = Encoding.ASCII.GetBytes(mode); @@ -112,12 +110,12 @@ internal sealed class MhddLog byte[] scanBlockSizeBytes = Encoding.ASCII.GetBytes(scanBlockSize); byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER); - uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length + - sectorsBytes.Length + sectorSizeBytes.Length + scanBlockSizeBytes.Length + - verBytes.Length + (2 * 9) + // New lines - 4); // Pointer + var pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length + + sectorsBytes.Length + sectorSizeBytes.Length + scanBlockSizeBytes.Length + + verBytes.Length + 2 * 9 + // New lines + 4); // Pointer - byte[] newLine = new byte[2]; + var newLine = new byte[2]; newLine[0] = 0x0D; newLine[1] = 0x0A; diff --git a/Aaru.Core/Logging/SubchannelLog.cs b/Aaru.Core/Logging/SubchannelLog.cs index 1ddb5fcda..d72c86dc4 100644 --- a/Aaru.Core/Logging/SubchannelLog.cs +++ b/Aaru.Core/Logging/SubchannelLog.cs @@ -26,12 +26,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Logging; + using System; using System.IO; using Aaru.Decoders.CD; -namespace Aaru.Core.Logging; - /// Logs subchannel data public class SubchannelLog { @@ -81,16 +81,16 @@ public class SubchannelLog return; } - int[] p = new int[subchannel.Length / 8]; - int[] q = new int[subchannel.Length / 8]; - int[] r = new int[subchannel.Length / 8]; - int[] s = new int[subchannel.Length / 8]; - int[] t = new int[subchannel.Length / 8]; - int[] u = new int[subchannel.Length / 8]; - int[] v = new int[subchannel.Length / 8]; - int[] w = new int[subchannel.Length / 8]; + var p = new int[subchannel.Length / 8]; + var q = new int[subchannel.Length / 8]; + var r = new int[subchannel.Length / 8]; + var s = new int[subchannel.Length / 8]; + var t = new int[subchannel.Length / 8]; + var u = new int[subchannel.Length / 8]; + var v = new int[subchannel.Length / 8]; + var w = new int[subchannel.Length / 8]; - for(int i = 0; i < subchannel.Length; i += 8) + for(var i = 0; i < subchannel.Length; i += 8) { p[i / 8] = subchannel[i] & 0x80; p[i / 8] += (subchannel[i + 1] & 0x80) >> 1; @@ -167,14 +167,13 @@ public class SubchannelLog for(uint block = 0; block < blocks; block++) { - bool rwEmpty = true; + var rwEmpty = true; if(raw) - for(uint i = 12 * block; i < (12 * block) + 12; i++) + for(uint i = 12 * block; i < 12 * block + 12; i++) { - if((r[i] == 0 && s[i] == 0 && t[i] == 0 && u[i] == 0 && v[i] == 0 && w[i] == 0) || - (r[i] == 0xFF && s[i] == 0xFF && t[i] == 0xFF && u[i] == 0xFF && v[i] == 0xFF && - w[i] == 0xFF)) + if(r[i] == 0 && s[i] == 0 && t[i] == 0 && u[i] == 0 && v[i] == 0 && w[i] == 0 || + r[i] == 0xFF && s[i] == 0xFF && t[i] == 0xFF && u[i] == 0xFF && v[i] == 0xFF && w[i] == 0xFF) continue; rwEmpty = false; @@ -182,10 +181,10 @@ public class SubchannelLog break; } - bool corruptedPause = false; - bool pause = false; + var corruptedPause = false; + var pause = false; - for(int i = 0; i < 12; i++) + for(var i = 0; i < 12; i++) { if(p[i] == 0 || p[i] == 0xFF) @@ -199,22 +198,22 @@ public class SubchannelLog if(!corruptedPause) pause = p[0] == 1; - byte[] subBuf = new byte[12]; - subBuf[0] = (byte)q[0 + (block * 12)]; - subBuf[1] = (byte)q[1 + (block * 12)]; - subBuf[2] = (byte)q[2 + (block * 12)]; - subBuf[3] = (byte)q[3 + (block * 12)]; - subBuf[4] = (byte)q[4 + (block * 12)]; - subBuf[5] = (byte)q[5 + (block * 12)]; - subBuf[6] = (byte)q[6 + (block * 12)]; - subBuf[7] = (byte)q[7 + (block * 12)]; - subBuf[8] = (byte)q[8 + (block * 12)]; - subBuf[9] = (byte)q[9 + (block * 12)]; - subBuf[10] = (byte)q[10 + (block * 12)]; - subBuf[11] = (byte)q[11 + (block * 12)]; + var subBuf = new byte[12]; + subBuf[0] = (byte)q[0 + block * 12]; + subBuf[1] = (byte)q[1 + block * 12]; + subBuf[2] = (byte)q[2 + block * 12]; + subBuf[3] = (byte)q[3 + block * 12]; + subBuf[4] = (byte)q[4 + block * 12]; + subBuf[5] = (byte)q[5 + block * 12]; + subBuf[6] = (byte)q[6 + block * 12]; + subBuf[7] = (byte)q[7 + block * 12]; + subBuf[8] = (byte)q[8 + block * 12]; + subBuf[9] = (byte)q[9 + block * 12]; + 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, rwEmpty); + string prettyQ = Subchannel.PrettifyQ(subBuf, generated || _bcd, startingLba + block, corruptedPause, pause, + rwEmpty); if(generated) prettyQ += " (GENERATED)"; @@ -241,8 +240,7 @@ public class SubchannelLog /// Logs message indicating the CONTROL field of the Q subchannel has been fixed /// LBA fix belongs to - public void WriteQCtrlFix(long lba) => - WriteMessageWithPosition(lba, "fixed Q subchannel with correct CONTROL."); + public void WriteQCtrlFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct CONTROL."); /// Logs message indicating the ZERO field of the Q subchannel has been fixed /// LBA fix belongs to @@ -276,8 +274,7 @@ public class SubchannelLog /// Logs message indicating the the Q subchannel has been fixed with a known good ISRC /// LBA fix belongs to - public void WriteQIsrcFix(long lba) => - WriteMessageWithPosition(lba, "fixed Q subchannel with known good ISRC."); + public void WriteQIsrcFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with known good ISRC."); /// Logs a message with a specified position /// LBA position diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index cb43a055d..a94d9d2a2 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -26,6 +26,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Media; + using System; using System.Collections.Generic; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.Decoders.CD; using Aaru.Devices; using Aaru.Helpers; -namespace Aaru.Core.Media; - /// Operations over CD based media public static class CompactDisc { @@ -83,8 +83,7 @@ public static class CompactDisc desiredSubchannel != MmcSubchannel.None) outputPlugin.WriteSectorsTag(sub, sectorAddress, length, SectorTagType.CdSectorSubchannel); - subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false, - false); + subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false, false); byte[] deSub = Subchannel.Deinterleave(sub); @@ -98,15 +97,15 @@ public static class CompactDisc int prePos = int.MinValue; // Check subchannel - for(int subPos = 0; subPos < deSub.Length; subPos += 96) + for(var subPos = 0; subPos < deSub.Length; subPos += 96) { // Expected LBA - long lba = (long)sectorAddress + (subPos / 96); + long lba = (long)sectorAddress + subPos / 96; // We fixed the subchannel - bool @fixed = false; + var @fixed = false; - byte[] q = new byte[12]; + var q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); // Check Q CRC @@ -114,8 +113,8 @@ public static class CompactDisc bool crcOk = crc[0] == q[10] && crc[1] == q[11]; // Start considering P to be OK - bool pOk = true; - int pWeight = 0; + var pOk = true; + var pWeight = 0; // Check P and weight for(int p = subPos; p < subPos + 12; p++) @@ -124,7 +123,7 @@ public static class CompactDisc deSub[p] != 255) pOk = false; - for(int w = 0; w < 8; w++) + for(var w = 0; w < 8; w++) if(((deSub[p] >> w) & 1) > 0) pWeight++; } @@ -149,13 +148,13 @@ public static class CompactDisc deSub.Skip(subPos + 84).Take(12).All(w => w == 0xFF); bool rwOk = rOk && sOk && tOk && uOk && vOk && wOk; - bool rwPacket = false; - bool cdtextPacket = false; + var rwPacket = false; + var cdtextPacket = false; // Check RW contents if(!rwOk) { - byte[] sectorSub = new byte[96]; + var sectorSub = new byte[96]; Array.Copy(sub, subPos, sectorSub, 0, 96); DetectRwPackets(sectorSub, out _, out rwPacket, out cdtextPacket); @@ -211,9 +210,9 @@ 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, out bool fixedIsrc); + 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) { @@ -257,13 +256,13 @@ public static class CompactDisc !rwOk) continue; - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if((q[0] & 0x3) == 1) { - amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F)); - asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F)); - aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150; + amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + aPos = amin * 60 * 75 + asec * 75 + aframe - 150; } else { @@ -272,7 +271,7 @@ public static class CompactDisc expectedSectorAddress -= (ulong)(smin * 60 * 75); ssec = (byte)(expectedSectorAddress / 75); - aPos = (smin * 60 * 75) + (ssec * 75) + aframe - 150; + aPos = smin * 60 * 75 + ssec * 75 + aframe - 150; // Next second if(aPos < prePos) @@ -285,7 +284,7 @@ public static class CompactDisc prePos = aPos; - byte[] posSub = new byte[96]; + var posSub = new byte[96]; Array.Copy(deSub, subPos, posSub, 0, 96); posSub = Subchannel.Interleave(posSub); outputPlugin.WriteSectorTag(posSub, (ulong)aPos, SectorTagType.CdSectorSubchannel); @@ -315,12 +314,12 @@ public static class CompactDisc UpdateStatusHandler updateStatus, Dictionary smallestPregapLbaPerTrack, bool dumping) { - bool status = false; + var status = false; // Check subchannel - for(int subPos = 0; subPos < deSub.Length; subPos += 96) + for(var subPos = 0; subPos < deSub.Length; subPos += 96) { - byte[] q = new byte[12]; + var q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); CRC16CCITTContext.Data(q, 10, out byte[] crc); @@ -391,9 +390,9 @@ public static class CompactDisc case 1 when !crcOk: continue; case 1: { - byte trackNo = (byte)((q[1] / 16 * 10) + (q[1] & 0x0F)); + var trackNo = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F)); - for(int i = 0; i < tracks.Length; i++) + for(var i = 0; i < tracks.Length; i++) { if(tracks[i].Sequence != trackNo) continue; @@ -402,10 +401,10 @@ public static class CompactDisc if(q[2] == 0 && trackNo > 1) { - byte pmin = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F)); - byte psec = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F)); - byte pframe = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F)); - int qPos = (pmin * 60 * 75) + (psec * 75) + pframe; + var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + int qPos = pmin * 60 * 75 + psec * 75 + pframe; // When we are dumping we calculate the pregap in reverse from index 1 back. // When we are not, we go from index 0. @@ -413,8 +412,7 @@ public static class CompactDisc smallestPregapLbaPerTrack[trackNo] = dumping ? 1 : 0; uint firstTrackNumberInSameSession = tracks. - Where(t => t.Session == - tracks[i].Session). + Where(t => t.Session == tracks[i].Session). Min(t => t.Sequence); if(tracks[i].Sequence == firstTrackNumberInSameSession) @@ -431,11 +429,9 @@ public static class CompactDisc tracks[i - 1].EndSector >= tracks[i].StartSector) tracks[i - 1].EndSector = tracks[i].StartSector - 1; - dumpLog?. - WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); + dumpLog?.WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); - updateStatus?. - Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); + updateStatus?.Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); status = true; } @@ -452,11 +448,9 @@ public static class CompactDisc tracks[i - 1].EndSector >= tracks[i].StartSector) tracks[i - 1].EndSector = tracks[i].StartSector - 1; - dumpLog?. - WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); + dumpLog?.WriteLine($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); - updateStatus?. - Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); + updateStatus?.Invoke($"Pregap for track {trackNo} set to {tracks[i].Pregap} sectors."); status = true; @@ -466,10 +460,10 @@ public static class CompactDisc if(q[2] == 0) continue; - byte amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F)); - byte asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F)); - byte aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); - int aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150; + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + int aPos = amin * 60 * 75 + asec * 75 + aframe - 150; if(tracks[i].Indexes.ContainsKey(q[2]) && aPos >= tracks[i].Indexes[q[2]]) @@ -502,18 +496,18 @@ public static class CompactDisc rwPacket = false; cdtextPacket = false; - byte[] cdTextPack1 = new byte[18]; - byte[] cdTextPack2 = new byte[18]; - byte[] cdTextPack3 = new byte[18]; - byte[] cdTextPack4 = new byte[18]; - byte[] cdSubRwPack1 = new byte[24]; - byte[] cdSubRwPack2 = new byte[24]; - byte[] cdSubRwPack3 = new byte[24]; - byte[] cdSubRwPack4 = new byte[24]; + var cdTextPack1 = new byte[18]; + var cdTextPack2 = new byte[18]; + var cdTextPack3 = new byte[18]; + var cdTextPack4 = new byte[18]; + var cdSubRwPack1 = new byte[24]; + var cdSubRwPack2 = new byte[24]; + var cdSubRwPack3 = new byte[24]; + var cdSubRwPack4 = new byte[24]; - int i = 0; + var i = 0; - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -532,7 +526,7 @@ public static class CompactDisc cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -551,7 +545,7 @@ public static class CompactDisc cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -570,7 +564,7 @@ public static class CompactDisc cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -591,16 +585,16 @@ public static class CompactDisc i = 0; - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) @@ -701,14 +695,14 @@ public static class CompactDisc /// true if subchannel contains a TEXT packet, false otherwise static bool CheckCdTextPackets(byte[] subchannel) { - byte[] cdTextPack1 = new byte[18]; - byte[] cdTextPack2 = new byte[18]; - byte[] cdTextPack3 = new byte[18]; - byte[] cdTextPack4 = new byte[18]; + var cdTextPack1 = new byte[18]; + var cdTextPack2 = new byte[18]; + var cdTextPack3 = new byte[18]; + var cdTextPack4 = new byte[18]; - int i = 0; + var i = 0; - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack1[j] = (byte)(cdTextPack1[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -727,7 +721,7 @@ public static class CompactDisc cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack2[j] = (byte)(cdTextPack2[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -746,7 +740,7 @@ public static class CompactDisc cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack3[j] = (byte)(cdTextPack3[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -765,7 +759,7 @@ public static class CompactDisc cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F)); } - for(int j = 0; j < 18; j++) + for(var j = 0; j < 18; j++) { cdTextPack4[j] = (byte)(cdTextPack4[j] | ((subchannel[i++] & 0x3F) << 2)); @@ -784,12 +778,12 @@ public static class CompactDisc cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F)); } - bool status = true; + var status = true; if((cdTextPack1[0] & 0x80) == 0x80) { - ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); - byte[] cdTextPack1ForCrc = new byte[16]; + var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); + var cdTextPack1ForCrc = new byte[16]; Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16); ushort calculatedCdtp1Crc = CRC16CCITTContext.Calculate(cdTextPack1ForCrc); @@ -800,8 +794,8 @@ public static class CompactDisc if((cdTextPack2[0] & 0x80) == 0x80) { - ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); - byte[] cdTextPack2ForCrc = new byte[16]; + var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); + var cdTextPack2ForCrc = new byte[16]; Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); ushort calculatedCdtp2Crc = CRC16CCITTContext.Calculate(cdTextPack2ForCrc); @@ -812,8 +806,8 @@ public static class CompactDisc if((cdTextPack3[0] & 0x80) == 0x80) { - ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); - byte[] cdTextPack3ForCrc = new byte[16]; + var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); + var cdTextPack3ForCrc = new byte[16]; Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); ushort calculatedCdtp3Crc = CRC16CCITTContext.Calculate(cdTextPack3ForCrc); @@ -825,8 +819,8 @@ public static class CompactDisc if((cdTextPack4[0] & 0x80) != 0x80) return status; - ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); - byte[] cdTextPack4ForCrc = new byte[16]; + var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); + var cdTextPack4ForCrc = new byte[16]; Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); ushort calculatedCdtp4Crc = CRC16CCITTContext.Calculate(cdTextPack4ForCrc); @@ -873,8 +867,8 @@ public static class CompactDisc fixedMcn = false; fixedIsrc = false; - byte[] preQ = new byte[12]; - byte[] nextQ = new byte[12]; + var preQ = new byte[12]; + var nextQ = new byte[12]; Array.Copy(deSub, subPos + 12 - 96, preQ, 0, 12); Array.Copy(deSub, subPos + 12 + 96, nextQ, 0, 12); bool status; @@ -1007,7 +1001,6 @@ public static class CompactDisc } if(preCrcOk && nextCrcOk) - { if(preQ[1] == nextQ[1] && preQ[1] != q[1]) { @@ -1020,10 +1013,8 @@ public static class CompactDisc if(status) return true; } - } if(preCrcOk && nextCrcOk) - { if(preQ[2] == nextQ[2] && preQ[2] != q[2]) { @@ -1036,17 +1027,16 @@ public static class CompactDisc if(status) return true; } - } - amin = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F)); - asec = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F)); - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); - aPos = (amin * 60 * 75) + (asec * 75) + aframe - 150; + amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + aPos = amin * 60 * 75 + asec * 75 + aframe - 150; - pmin = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F)); - psec = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F)); - pframe = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F)); - pPos = (pmin * 60 * 75) + (psec * 75) + pframe; + pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + pPos = pmin * 60 * 75 + psec * 75 + pframe; // TODO: pregap // Not pregap @@ -1055,10 +1045,10 @@ public static class CompactDisc // Previous was not pregap either if(preQ[2] > 0 && preCrcOk) { - rmin = (byte)((preQ[3] / 16 * 10) + (preQ[3] & 0x0F)); - rsec = (byte)((preQ[4] / 16 * 10) + (preQ[4] & 0x0F)); - rframe = (byte)((preQ[5] / 16 * 10) + (preQ[5] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe; + rmin = (byte)(preQ[3] / 16 * 10 + (preQ[3] & 0x0F)); + rsec = (byte)(preQ[4] / 16 * 10 + (preQ[4] & 0x0F)); + rframe = (byte)(preQ[5] / 16 * 10 + (preQ[5] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe; dPos = pPos - rPos; @@ -1112,10 +1102,10 @@ public static class CompactDisc nextCrcOk && !fixedRelPos) { - rmin = (byte)((nextQ[3] / 16 * 10) + (nextQ[3] & 0x0F)); - rsec = (byte)((nextQ[4] / 16 * 10) + (nextQ[4] & 0x0F)); - rframe = (byte)((nextQ[5] / 16 * 10) + (nextQ[5] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe; + rmin = (byte)(nextQ[3] / 16 * 10 + (nextQ[3] & 0x0F)); + rsec = (byte)(nextQ[4] / 16 * 10 + (nextQ[4] & 0x0F)); + rframe = (byte)(nextQ[5] / 16 * 10 + (nextQ[5] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe; dPos = rPos - pPos; @@ -1172,10 +1162,10 @@ public static class CompactDisc // Previous Q's CRC is correct if(preCrcOk) { - rmin = (byte)((preQ[7] / 16 * 10) + (preQ[7] & 0x0F)); - rsec = (byte)((preQ[8] / 16 * 10) + (preQ[8] & 0x0F)); - rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150; + rmin = (byte)(preQ[7] / 16 * 10 + (preQ[7] & 0x0F)); + rsec = (byte)(preQ[8] / 16 * 10 + (preQ[8] & 0x0F)); + rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150; dPos = aPos - rPos; @@ -1229,10 +1219,10 @@ public static class CompactDisc nextCrcOk && !fixedAbsPos) { - rmin = (byte)((nextQ[7] / 16 * 10) + (nextQ[7] & 0x0F)); - rsec = (byte)((nextQ[8] / 16 * 10) + (nextQ[8] & 0x0F)); - rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150; + rmin = (byte)(nextQ[7] / 16 * 10 + (nextQ[7] & 0x0F)); + rsec = (byte)(nextQ[8] / 16 * 10 + (nextQ[8] & 0x0F)); + rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150; dPos = rPos - pPos; @@ -1295,19 +1285,19 @@ public static class CompactDisc // Previous Q's CRC is correct if(preCrcOk) { - rmin = (byte)((preQ[7] / 16 * 10) + (preQ[7] & 0x0F)); - rsec = (byte)((preQ[8] / 16 * 10) + (preQ[8] & 0x0F)); - rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150; + rmin = (byte)(preQ[7] / 16 * 10 + (preQ[7] & 0x0F)); + rsec = (byte)(preQ[8] / 16 * 10 + (preQ[8] & 0x0F)); + rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150; dPos = aPos - rPos; bool absOk = dPos == 1; - rmin = (byte)((preQ[3] / 16 * 10) + (preQ[3] & 0x0F)); - rsec = (byte)((preQ[4] / 16 * 10) + (preQ[4] & 0x0F)); - rframe = (byte)((preQ[5] / 16 * 10) + (preQ[5] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe; + rmin = (byte)(preQ[3] / 16 * 10 + (preQ[3] & 0x0F)); + rsec = (byte)(preQ[4] / 16 * 10 + (preQ[4] & 0x0F)); + rframe = (byte)(preQ[5] / 16 * 10 + (preQ[5] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe; dPos = pPos - rPos; @@ -1333,19 +1323,19 @@ public static class CompactDisc // Next Q's CRC is correct if(nextCrcOk) { - rmin = (byte)((nextQ[7] / 16 * 10) + (nextQ[7] & 0x0F)); - rsec = (byte)((nextQ[8] / 16 * 10) + (nextQ[8] & 0x0F)); - rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe - 150; + rmin = (byte)(nextQ[7] / 16 * 10 + (nextQ[7] & 0x0F)); + rsec = (byte)(nextQ[8] / 16 * 10 + (nextQ[8] & 0x0F)); + rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe - 150; dPos = rPos - aPos; bool absOk = dPos == 1; - rmin = (byte)((nextQ[3] / 16 * 10) + (nextQ[3] & 0x0F)); - rsec = (byte)((nextQ[4] / 16 * 10) + (nextQ[4] & 0x0F)); - rframe = (byte)((nextQ[5] / 16 * 10) + (nextQ[5] & 0x0F)); - rPos = (rmin * 60 * 75) + (rsec * 75) + rframe; + rmin = (byte)(nextQ[3] / 16 * 10 + (nextQ[3] & 0x0F)); + rsec = (byte)(nextQ[4] / 16 * 10 + (nextQ[4] & 0x0F)); + rframe = (byte)(nextQ[5] / 16 * 10 + (nextQ[5] & 0x0F)); + rPos = rmin * 60 * 75 + rsec * 75 + rframe; dPos = rPos - pPos; @@ -1378,8 +1368,8 @@ public static class CompactDisc // Previous Q's CRC is correct if(preCrcOk) { - rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F)); - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if(aframe - rframe != 1) { @@ -1406,8 +1396,8 @@ public static class CompactDisc // Next Q's CRC is correct else if(nextCrcOk) { - rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F)); - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if(aframe - rframe != 1) { @@ -1433,13 +1423,13 @@ public static class CompactDisc // We know the MCN if(mcn != null) { - q[1] = (byte)((((mcn[0] - 0x30) & 0x0F) * 16) + ((mcn[1] - 0x30) & 0x0F)); - q[2] = (byte)((((mcn[2] - 0x30) & 0x0F) * 16) + ((mcn[3] - 0x30) & 0x0F)); - q[3] = (byte)((((mcn[4] - 0x30) & 0x0F) * 16) + ((mcn[5] - 0x30) & 0x0F)); - q[4] = (byte)((((mcn[6] - 0x30) & 0x0F) * 16) + ((mcn[7] - 0x30) & 0x0F)); - q[5] = (byte)((((mcn[8] - 0x30) & 0x0F) * 16) + ((mcn[9] - 0x30) & 0x0F)); - q[6] = (byte)((((mcn[10] - 0x30) & 0x0F) * 16) + ((mcn[11] - 0x30) & 0x0F)); - q[7] = (byte)(((mcn[12] - 0x30) & 0x0F) * 8); + q[1] = (byte)(((mcn[0] - 0x30) & 0x0F) * 16 + ((mcn[1] - 0x30) & 0x0F)); + q[2] = (byte)(((mcn[2] - 0x30) & 0x0F) * 16 + ((mcn[3] - 0x30) & 0x0F)); + q[3] = (byte)(((mcn[4] - 0x30) & 0x0F) * 16 + ((mcn[5] - 0x30) & 0x0F)); + q[4] = (byte)(((mcn[6] - 0x30) & 0x0F) * 16 + ((mcn[7] - 0x30) & 0x0F)); + q[5] = (byte)(((mcn[8] - 0x30) & 0x0F) * 16 + ((mcn[9] - 0x30) & 0x0F)); + q[6] = (byte)(((mcn[10] - 0x30) & 0x0F) * 16 + ((mcn[11] - 0x30) & 0x0F)); + q[7] = (byte)(((mcn[12] - 0x30) & 0x0F) * 8); q[8] = 0; fixedMcn = true; @@ -1471,8 +1461,8 @@ public static class CompactDisc // Previous Q's CRC is correct if(preCrcOk) { - rframe = (byte)((preQ[9] / 16 * 10) + (preQ[9] & 0x0F)); - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + rframe = (byte)(preQ[9] / 16 * 10 + (preQ[9] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if(aframe - rframe != 1) { @@ -1499,8 +1489,8 @@ public static class CompactDisc // Next Q's CRC is correct else if(nextCrcOk) { - rframe = (byte)((nextQ[9] / 16 * 10) + (nextQ[9] & 0x0F)); - aframe = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + rframe = (byte)(nextQ[9] / 16 * 10 + (nextQ[9] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if(aframe - rframe != 1) { @@ -1536,10 +1526,10 @@ public static class CompactDisc q[2] = (byte)(((i2 & 0xF) << 4) + (i3 >> 2)); q[3] = (byte)(((i3 & 0x3) << 6) + i4); q[4] = (byte)(i5 << 2); - q[5] = (byte)((((isrc[5] - 0x30) & 0x0F) * 16) + ((isrc[6] - 0x30) & 0x0F)); - q[6] = (byte)((((isrc[7] - 0x30) & 0x0F) * 16) + ((isrc[8] - 0x30) & 0x0F)); - q[7] = (byte)((((isrc[9] - 0x30) & 0x0F) * 16) + ((isrc[10] - 0x30) & 0x0F)); - q[8] = (byte)(((isrc[11] - 0x30) & 0x0F) * 16); + q[5] = (byte)(((isrc[5] - 0x30) & 0x0F) * 16 + ((isrc[6] - 0x30) & 0x0F)); + q[6] = (byte)(((isrc[7] - 0x30) & 0x0F) * 16 + ((isrc[8] - 0x30) & 0x0F)); + q[7] = (byte)(((isrc[9] - 0x30) & 0x0F) * 16 + ((isrc[10] - 0x30) & 0x0F)); + q[8] = (byte)(((isrc[11] - 0x30) & 0x0F) * 16); fixedIsrc = true; @@ -1627,8 +1617,7 @@ public static class CompactDisc updateProgress?.Invoke($"Generating subchannel for sector {sector}...", sector, (long)blocks); dumpLog?.WriteLine($"Generating subchannel for sector {sector}."); - byte[] sub = Subchannel.Generate(sector, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags, - index); + byte[] sub = Subchannel.Generate(sector, track?.Sequence ?? 0, (int)pregap, (int)trackStart, flags, index); outputPlugin.WriteSectorsTag(sub, (ulong)sector, 1, SectorTagType.CdSectorSubchannel); diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index 4d0b0ada6..f66b42395 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable JoinDeclarationAndInitializer + +namespace Aaru.Core.Media.Detection; + using System; using System.Collections.Generic; using System.IO; @@ -47,10 +53,6 @@ using Aaru.Devices; using Aaru.Helpers; using DMI = Aaru.Decoders.Xbox.DMI; -// ReSharper disable JoinDeclarationAndInitializer - -namespace Aaru.Core.Media.Detection; - /// Detects media type for MMC class devices public static class MMC { @@ -154,7 +156,7 @@ public static class MMC 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 }; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; Array.Copy(sector, 0, testMark, 0, 12); return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2); @@ -172,14 +174,14 @@ public static class MMC 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 }; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; - for(int i = 0; i <= 2336; i++) + for(var i = 0; i <= 2336; i++) { Array.Copy(sector, i, testMark, 0, 12); if(!syncMark.SequenceEqual(testMark) || - (sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)) + sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62) continue; // De-scramble M and S @@ -188,17 +190,17 @@ public static class MMC int frame = sector[i + 14]; // Convert to binary - minute = (minute / 16 * 10) + (minute & 0x0F); - second = (second / 16 * 10) + (second & 0x0F); - frame = (frame / 16 * 10) + (frame & 0x0F); + minute = minute / 16 * 10 + (minute & 0x0F); + second = second / 16 * 10 + (second & 0x0F); + frame = frame / 16 * 10 + (frame & 0x0F); // Calculate the first found LBA - int lba = (minute * 60 * 75) + (second * 75) + frame - 150; + int lba = minute * 60 * 75 + second * 75 + frame - 150; // Calculate the difference between the found LBA and the requested one int diff = wantedLba - lba; - offset = i + (2352 * diff); + offset = i + 2352 * diff; return true; } @@ -208,9 +210,9 @@ public static class MMC static byte[] DescrambleAndFixOffset(byte[] sector, int offsetBytes, int sectorsForOffset) { - byte[] descrambled = new byte[2352]; + var descrambled = new byte[2352]; - int offsetFix = offsetBytes < 0 ? (2352 * sectorsForOffset) + offsetBytes : offsetBytes; + int offsetFix = offsetBytes < 0 ? 2352 * sectorsForOffset + offsetBytes : offsetBytes; Array.Copy(sector, offsetFix, descrambled, 0, 2352); @@ -234,10 +236,10 @@ public static class MMC bool isData = IsData(sector0); if(!isData || - (sector0[0xF] != 2 && sector0[0xF] != 1)) + sector0[0xF] != 2 && sector0[0xF] != 1) return false; - byte[] testMark = new byte[4]; + var testMark = new byte[4]; Array.Copy(sector16, 24, testMark, 0, 4); return cdiMark.SequenceEqual(testMark); @@ -249,13 +251,13 @@ public static class MMC videoFrame.Length < _videoNowColorFrameMarker.Length) return false; - byte[] buffer = new byte[_videoNowColorFrameMarker.Length]; + var buffer = new byte[_videoNowColorFrameMarker.Length]; - for(int framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++) + for(var framePosition = 0; framePosition + buffer.Length < videoFrame.Length; framePosition++) { Array.Copy(videoFrame, framePosition, buffer, 0, buffer.Length); - for(int ab = 9; ab < buffer.Length; ab += 10) + for(var ab = 9; ab < buffer.Length; ab += 10) buffer[ab] = 0; if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) @@ -269,13 +271,13 @@ public static class MMC internal static int GetVideoNowColorOffset(byte[] data) { - byte[] buffer = new byte[_videoNowColorFrameMarker.Length]; + var buffer = new byte[_videoNowColorFrameMarker.Length]; - for(int framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++) + for(var framePosition = 0; framePosition + buffer.Length < data.Length; framePosition++) { Array.Copy(data, framePosition, buffer, 0, buffer.Length); - for(int ab = 9; ab < buffer.Length; ab += 10) + for(var ab = 9; ab < buffer.Length; ab += 10) buffer[ab] = 0; if(!_videoNowColorFrameMarker.SequenceEqual(buffer)) @@ -462,10 +464,10 @@ public static class MMC if(mediaType == MediaType.CD || mediaType == MediaType.CDROMXA) { - bool hasDataTrack = false; - bool hasAudioTrack = false; - bool allFirstSessionTracksAreAudio = true; - bool hasVideoTrack = false; + var hasDataTrack = false; + var hasAudioTrack = false; + var allFirstSessionTracksAreAudio = true; + var hasVideoTrack = false; if(decodedToc.HasValue) { @@ -498,8 +500,8 @@ public static class MMC if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental) { - uint startAddress = (uint)((track.PHOUR * 3600 * 75) + (track.PMIN * 60 * 75) + - (track.PSEC * 75) + track.PFRAME - 150); + var startAddress = (uint)(track.PHOUR * 3600 * 75 + track.PMIN * 60 * 75 + track.PSEC * 75 + + track.PFRAME - 150); if(startAddress < startOfFirstDataTrack) startOfFirstDataTrack = startAddress; @@ -508,9 +510,7 @@ public static class MMC allFirstSessionTracksAreAudio &= track.POINT >= firstTrackLastSession; } else - { hasAudioTrack = true; - } hasVideoTrack |= track.ADR == 4; } @@ -561,20 +561,18 @@ public static class MMC } if((mediaType == MediaType.CD || mediaType == MediaType.CDROM) && hasDataTrack) - { foreach(uint startAddress in decodedToc.Value.TrackDescriptors. Where(t => t.POINT > 0 && t.POINT <= 0x99 && ((TocControl)(t.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(t.CONTROL & 0x0D) == TocControl.DataTrackIncremental)). - Select(track => (uint)((track.PHOUR * 3600 * 75) + - (track.PMIN * 60 * 75) + - (track.PSEC * 75) + + 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, + 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) @@ -602,7 +600,6 @@ public static class MMC break; } - } } if(secondSessionFirstTrack != 0 && @@ -611,25 +608,23 @@ public static class MMC FullTOC.TrackDataDescriptor secondSessionFirstTrackTrack = decodedToc.Value.TrackDescriptors.First(t => t.POINT == secondSessionFirstTrack); - uint firstSectorSecondSessionFirstTrack = - (uint)((secondSessionFirstTrackTrack.PHOUR * 3600 * 75) + - (secondSessionFirstTrackTrack.PMIN * 60 * 75) + (secondSessionFirstTrackTrack.PSEC * 75) + - secondSessionFirstTrackTrack.PFRAME - 150); + var firstSectorSecondSessionFirstTrack = (uint)(secondSessionFirstTrackTrack.PHOUR * 3600 * 75 + + secondSessionFirstTrackTrack.PMIN * 60 * 75 + + secondSessionFirstTrackTrack.PSEC * 75 + + 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) @@ -642,9 +637,7 @@ public static class MMC if(!sense && !dev.Error) - { firstTrackSecondSessionAudio = cmdBuf; - } else { sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3, @@ -659,7 +652,7 @@ public static class MMC videoNowColorFrame = new byte[9 * 2352]; - for(int i = 0; i < 9; i++) + 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, @@ -686,9 +679,8 @@ public static class MMC if(firstTrack?.POINT == 1) { - uint firstTrackSector = (uint)((firstTrack.Value.PHOUR * 3600 * 75) + - (firstTrack.Value.PMIN * 60 * 75) + (firstTrack.Value.PSEC * 75) + - firstTrack.Value.PFRAME - 150); + var firstTrackSector = (uint)(firstTrack.Value.PHOUR * 3600 * 75 + firstTrack.Value.PMIN * 60 * 75 + + firstTrack.Value.PSEC * 75 + firstTrack.Value.PFRAME - 150); // Check for hidden data before start of track 1 if(firstTrackSector > 0) @@ -735,8 +727,8 @@ public static class MMC if(combinedOffset % 2352 != 0) sectorsForOffset++; - int lba0 = 0; - int lba16 = 16; + var lba0 = 0; + var lba16 = 16; if(combinedOffset < 0) { @@ -745,15 +737,14 @@ public static class MMC } 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 _); + 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, + 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); @@ -803,8 +794,8 @@ public static class MMC 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 _); + MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, + dev.Timeout, out _); if(!sense && !dev.Error) @@ -813,9 +804,9 @@ 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) @@ -824,9 +815,9 @@ 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) @@ -837,9 +828,9 @@ 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) @@ -849,8 +840,8 @@ public static class MMC } 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 _); + MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if(!sense && !dev.Error) @@ -864,8 +855,8 @@ 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, + 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) @@ -900,9 +891,9 @@ 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) @@ -911,9 +902,9 @@ 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) @@ -924,9 +915,9 @@ 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) @@ -951,9 +942,9 @@ 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; @@ -975,9 +966,9 @@ public static class MMC { 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) @@ -994,18 +985,16 @@ public static class MMC 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 _); + MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true, + false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); 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 _); + MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true, + false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if(!sense && !dev.Error) @@ -1013,9 +1002,7 @@ public static class MMC } } else - { goto case MediaType.DVDROM; - } } } @@ -1039,8 +1026,7 @@ public static class MMC blurayDi = DI.Decode(cmdBuf); } - sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout, - out _); + sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout, out _); if(!sense && !dev.Error) @@ -1054,8 +1040,8 @@ public static class MMC !dev.Error) sector1 = cmdBuf; - sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false, - dev.Timeout, out _); + sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false, dev.Timeout, + out _); if(!sense && !dev.Error && @@ -1089,8 +1075,8 @@ public static class MMC } else { - sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, - dev.Timeout, out _); + sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, dev.Timeout, + out _); if(!sense && !dev.Error) @@ -1141,15 +1127,13 @@ public static class MMC if(mediaType == MediaType.DVDROM) { sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); if(!sense) { PFI.PhysicalFormatInformation? pfi = PFI.Decode(cmdBuf, mediaType); if(pfi != null) - { switch(pfi.Value.DiskCategory) { case DiskCategory.DVDPR: @@ -1197,8 +1181,7 @@ public static class MMC break; case DiskCategory.Nintendo: - mediaType = pfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD - : MediaType.WOD; + mediaType = pfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; break; case DiskCategory.UMD: @@ -1206,12 +1189,11 @@ public static class MMC break; } - } } sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DiscManufacturingInformation, 0, - dev.Timeout, out _); + MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, + out _); if(!sense) { @@ -1255,8 +1237,8 @@ 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 || @@ -1272,8 +1254,8 @@ 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) @@ -1304,8 +1286,8 @@ public static class MMC isoSector[5] != 0x31) return; - uint rootStart = BitConverter.ToUInt32(isoSector, 158); - uint rootLength = BitConverter.ToUInt32(isoSector, 166); + var rootStart = BitConverter.ToUInt32(isoSector, 158); + var rootLength = BitConverter.ToUInt32(isoSector, 166); if(rootStart == 0 || rootLength == 0) @@ -1319,8 +1301,8 @@ 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; @@ -1338,7 +1320,7 @@ public static class MMC if(isoSector.Length < 2048) return; - int rootPos = 0; + var rootPos = 0; uint pcdStart = 0; uint pcdLength = 0; @@ -1346,8 +1328,8 @@ public static class MMC rootPos < isoSector.Length && rootPos + isoSector[rootPos] <= isoSector.Length) { - int nameLen = isoSector[rootPos + 32]; - byte[] tmpName = new byte[nameLen]; + int nameLen = isoSector[rootPos + 32]; + var tmpName = new byte[nameLen]; Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); @@ -1372,8 +1354,8 @@ 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; @@ -1391,7 +1373,7 @@ public static class MMC if(isoSector.Length < 2048) return; - for(int pi = 0; pi < pcdLength; pi++) + for(var pi = 0; pi < pcdLength; pi++) { int pcdPos = pi * 2048; uint infoPos = 0; @@ -1400,8 +1382,8 @@ public static class MMC pcdPos < isoSector.Length && pcdPos + isoSector[pcdPos] <= isoSector.Length) { - int nameLen = isoSector[pcdPos + 32]; - byte[] tmpName = new byte[nameLen]; + int nameLen = isoSector[pcdPos + 32]; + var tmpName = new byte[nameLen]; Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); @@ -1420,13 +1402,13 @@ 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; - byte[] systemId = new byte[8]; + var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); string id = StringHandlers.CToString(systemId).TrimEnd(); @@ -1521,7 +1503,7 @@ 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(int i = 0; i < 0x6000; i++) + for(var i = 0; i < 0x6000; i++) ps2BootSectors[i] ^= decryptByte; string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); @@ -1544,7 +1526,7 @@ public static class MMC if(sector0 != null) { - byte[] syncBytes = new byte[7]; + var syncBytes = new byte[7]; Array.Copy(sector0, 0, syncBytes, 0, 7); if(_operaId.SequenceEqual(syncBytes)) @@ -1571,8 +1553,8 @@ public static class MMC if(playdia1 != null && playdia2 != null) { - byte[] pd1 = new byte[_playdiaCopyright.Length]; - byte[] pd2 = new byte[_playdiaCopyright.Length]; + var pd1 = new byte[_playdiaCopyright.Length]; + var pd2 = new byte[_playdiaCopyright.Length]; Array.Copy(playdia1, 38, pd1, 0, pd1.Length); Array.Copy(playdia2, 0, pd2, 0, pd1.Length); @@ -1591,7 +1573,7 @@ public static class MMC if(secondDataSectorNotZero != null) { - byte[] pce = new byte[_pcEngineSignature.Length]; + var pce = new byte[_pcEngineSignature.Length]; Array.Copy(secondDataSectorNotZero, 32, pce, 0, pce.Length); if(_pcEngineSignature.SequenceEqual(pce)) @@ -1607,7 +1589,7 @@ public static class MMC if(firstDataSectorNotZero != null) { - byte[] pcfx = new byte[_pcFxSignature.Length]; + var pcfx = new byte[_pcFxSignature.Length]; Array.Copy(firstDataSectorNotZero, 0, pcfx, 0, pcfx.Length); if(_pcFxSignature.SequenceEqual(pcfx)) @@ -1623,9 +1605,9 @@ public static class MMC if(firstTrackSecondSessionAudio != null) { - byte[] jaguar = new byte[_atariSignature.Length]; + var jaguar = new byte[_atariSignature.Length]; - for(int i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2) + for(var i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2) { Array.Copy(firstTrackSecondSessionAudio, i, jaguar, 0, jaguar.Length); @@ -1643,7 +1625,7 @@ public static class MMC if(firstTrackSecondSession?.Length >= 2336) { - byte[] milcd = new byte[2048]; + var milcd = new byte[2048]; Array.Copy(firstTrackSecondSession, 24, milcd, 0, 2048); if(Dreamcast.DecodeIPBin(milcd).HasValue) @@ -1672,19 +1654,19 @@ 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) { - bool cdg = false; - bool cdeg = false; - bool cdmidi = false; + var cdg = false; + var cdeg = false; + var cdmidi = false; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { - byte[] tmpSub = new byte[96]; + var tmpSub = new byte[96]; Array.Copy(subBuf, i * 96, tmpSub, 0, 96); DetectRwPackets(tmpSub, out bool cdgPacket, out bool cdegPacket, out bool cdmidiPacket); @@ -1731,11 +1713,11 @@ public static class MMC } // If it has a PS2 boot area it can still be PS1, so check for SYSTEM.CNF below - hasPs2CdBoot: + 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 || @@ -1751,8 +1733,8 @@ 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) @@ -1783,8 +1765,8 @@ public static class MMC isoSector[5] != 0x31) return; - uint rootStart = BitConverter.ToUInt32(isoSector, 158); - uint rootLength = BitConverter.ToUInt32(isoSector, 166); + var rootStart = BitConverter.ToUInt32(isoSector, 158); + var rootLength = BitConverter.ToUInt32(isoSector, 166); if(rootStart == 0 || rootLength == 0) @@ -1798,8 +1780,8 @@ 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; @@ -1817,17 +1799,17 @@ public static class MMC if(isoSector.Length < 2048) return; - List rootEntries = new List(); - uint ngcdIplStart = 0; - uint ngcdIplLength = 0; - uint vcdStart = 0; - uint vcdLength = 0; - uint pcdStart = 0; - uint pcdLength = 0; - uint ps1Start = 0; - uint ps1Length = 0; + var rootEntries = new List(); + uint ngcdIplStart = 0; + uint ngcdIplLength = 0; + uint vcdStart = 0; + uint vcdLength = 0; + uint pcdStart = 0; + uint pcdLength = 0; + uint ps1Start = 0; + uint ps1Length = 0; - for(int ri = 0; ri < rootLength; ri++) + for(var ri = 0; ri < rootLength; ri++) { int rootPos = ri * 2048; @@ -1835,8 +1817,8 @@ public static class MMC isoSector[rootPos] > 0 && rootPos + isoSector[rootPos] <= isoSector.Length) { - int nameLen = isoSector[rootPos + 32]; - byte[] tmpName = new byte[nameLen]; + int nameLen = isoSector[rootPos + 32]; + var tmpName = new byte[nameLen]; Array.Copy(isoSector, rootPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); @@ -1916,8 +1898,8 @@ 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; @@ -1938,8 +1920,8 @@ public static class MMC { using var sr = new StringReader(iplTxt); - bool correctNeoGeoCd = true; - int lineNumber = 0; + var correctNeoGeoCd = true; + var lineNumber = 0; while(sr.Peek() > 0) { @@ -2052,8 +2034,8 @@ 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; @@ -2073,7 +2055,7 @@ public static class MMC uint infoPos = 0; - for(int vi = 0; vi < vcdLength; vi++) + for(var vi = 0; vi < vcdLength; vi++) { int vcdPos = vi * 2048; @@ -2081,8 +2063,8 @@ public static class MMC isoSector[vcdPos] > 0 && vcdPos + isoSector[vcdPos] <= isoSector.Length) { - int nameLen = isoSector[vcdPos + 32]; - byte[] tmpName = new byte[nameLen]; + int nameLen = isoSector[vcdPos + 32]; + var tmpName = new byte[nameLen]; Array.Copy(isoSector, vcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); @@ -2109,7 +2091,7 @@ public static class MMC if(sense) break; - byte[] systemId = new byte[8]; + var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); string id = StringHandlers.CToString(systemId).TrimEnd(); @@ -2149,8 +2131,8 @@ 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; @@ -2170,7 +2152,7 @@ public static class MMC uint infoPos = 0; - for(int pi = 0; pi < pcdLength; pi++) + for(var pi = 0; pi < pcdLength; pi++) { int pcdPos = pi * 2048; @@ -2178,8 +2160,8 @@ public static class MMC isoSector[pcdPos] > 0 && pcdPos + isoSector[pcdPos] <= isoSector.Length) { - int nameLen = isoSector[pcdPos + 32]; - byte[] tmpName = new byte[nameLen]; + int nameLen = isoSector[pcdPos + 32]; + var tmpName = new byte[nameLen]; Array.Copy(isoSector, pcdPos + 33, tmpName, 0, nameLen); string name = StringHandlers.CToString(tmpName).ToUpperInvariant(); @@ -2205,7 +2187,7 @@ public static class MMC if(sense) break; - byte[] systemId = new byte[8]; + var systemId = new byte[8]; Array.Copy(isoSector, 0, systemId, 0, 8); string id = StringHandlers.CToString(systemId).TrimEnd(); @@ -2240,8 +2222,8 @@ 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; @@ -2339,7 +2321,7 @@ 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(int i = 0; i < 0x6000; i++) + for(var i = 0; i < 0x6000; i++) ps2BootSectors[i] ^= decryptByte; string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); @@ -2360,7 +2342,7 @@ public static class MMC if(sector1 != null) { - byte[] tmp = new byte[_ps3Id.Length]; + var tmp = new byte[_ps3Id.Length]; Array.Copy(sector1, 0, tmp, 0, tmp.Length); if(tmp.SequenceEqual(_ps3Id)) @@ -2415,7 +2397,7 @@ public static class MMC case "BDU": if(sector1 != null) { - byte[] tmp = new byte[_ps5Id.Length]; + var tmp = new byte[_ps5Id.Length]; Array.Copy(sector1, 1024, tmp, 0, tmp.Length); if(tmp.SequenceEqual(_ps5Id)) @@ -2448,23 +2430,23 @@ public static class MMC cdegPacket = false; cdmidiPacket = false; - byte[] cdSubRwPack1 = new byte[24]; - byte[] cdSubRwPack2 = new byte[24]; - byte[] cdSubRwPack3 = new byte[24]; - byte[] cdSubRwPack4 = new byte[24]; + var cdSubRwPack1 = new byte[24]; + var cdSubRwPack2 = new byte[24]; + var cdSubRwPack3 = new byte[24]; + var cdSubRwPack4 = new byte[24]; - int i = 0; + var i = 0; - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); - for(int j = 0; j < 24; j++) + 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 2ab6fafe9..ff8064619 100644 --- a/Aaru.Core/Media/Info/CompactDisc.cs +++ b/Aaru.Core/Media/Info/CompactDisc.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core.Media.Info; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -43,8 +45,6 @@ using Aaru.Decoders.CD; using Aaru.Devices; using Device = Aaru.Database.Models.Device; -namespace Aaru.Core.Media.Info; - /// Core operations for retrieving information about CD based media public static class CompactDisc { @@ -63,9 +63,8 @@ public static class CompactDisc /// true if offset could be found, false otherwise [SuppressMessage("ReSharper", "TooWideLocalVariableScope")] public static void GetOffset(CdOffset cdOffset, Device dbDev, bool debug, Aaru.Devices.Device dev, - MediaType dskType, DumpLog dumpLog, Track[] tracks, - UpdateStatusHandler updateStatus, out int? driveOffset, out int? combinedOffset, - out bool supportsPlextorReadCdDa) + MediaType dskType, DumpLog dumpLog, Track[] tracks, UpdateStatusHandler updateStatus, + out int? driveOffset, out int? combinedOffset, out bool supportsPlextorReadCdDa) { byte[] cmdBuf; bool sense; @@ -78,7 +77,7 @@ public static class CompactDisc int diff; Track dataTrack = default; Track audioTrack = default; - bool offsetFound = false; + var offsetFound = false; const uint sectorSize = 2352; driveOffset = cdOffset?.Offset * 4; combinedOffset = null; @@ -101,22 +100,22 @@ public static class CompactDisc tmpBuf = new byte[sectorSync.Length]; // Ensure to be out of the pregap, or multi-session discs give funny values - uint wantedLba = (uint)(dataTrack.StartSector + 151); + var wantedLba = (uint)(dataTrack.StartSector + 151); // Plextor READ CDDA if(dbDev?.ATAPI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true || dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true || dev.Manufacturer.ToLowerInvariant() == "plextor") { - 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) { supportsPlextorReadCdDa = true; - for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++) + for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++) { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); @@ -129,17 +128,17 @@ public static class CompactDisc frame = cmdBuf[i + 14]; // Convert to binary - minute = (minute / 16 * 10) + (minute & 0x0F); - second = (second / 16 * 10) + (second & 0x0F); - frame = (frame / 16 * 10) + (frame & 0x0F); + minute = minute / 16 * 10 + (minute & 0x0F); + second = second / 16 * 10 + (second & 0x0F); + frame = frame / 16 * 10 + (frame & 0x0F); // Calculate the first found LBA - lba = (minute * 60 * 75) + (second * 75) + frame - 150; + lba = minute * 60 * 75 + second * 75 + frame - 150; // Calculate the difference between the found LBA and the requested one diff = (int)wantedLba - lba; - combinedOffset = i + (2352 * diff); + combinedOffset = i + 2352 * diff; offsetFound = true; break; @@ -148,10 +147,10 @@ public static class CompactDisc } if(!offsetFound && - (debug || dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true || - dbDev?.SCSI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true || - dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) == - true || dev.Manufacturer.ToLowerInvariant() == "hl-dt-st")) + (debug || dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true || + dbDev?.SCSI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true || + dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) == true || + dev.Manufacturer.ToLowerInvariant() == "hl-dt-st")) { sense = dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, @@ -161,22 +160,22 @@ public static class CompactDisc !dev.Error) { // Clear cache - for(int i = 0; i < 63; i++) + 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, out _); + 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; } - 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(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++) + for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++) { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); @@ -189,17 +188,17 @@ public static class CompactDisc frame = cmdBuf[i + 14]; // Convert to binary - minute = (minute / 16 * 10) + (minute & 0x0F); - second = (second / 16 * 10) + (second & 0x0F); - frame = (frame / 16 * 10) + (frame & 0x0F); + minute = minute / 16 * 10 + (minute & 0x0F); + second = second / 16 * 10 + (second & 0x0F); + frame = frame / 16 * 10 + (frame & 0x0F); // Calculate the first found LBA - lba = (minute * 60 * 75) + (second * 75) + frame - 150; + lba = minute * 60 * 75 + second * 75 + frame - 150; // Calculate the difference between the found LBA and the requested one diff = (int)wantedLba - lba; - combinedOffset = i + (2352 * diff); + combinedOffset = i + 2352 * diff; offsetFound = true; break; @@ -214,7 +213,7 @@ public static class CompactDisc // Try to get another the offset some other way, we need an audio track just after a data track, same session - for(int i = 1; i < tracks.Length; i++) + for(var i = 1; i < tracks.Length; i++) { if(tracks[i - 1].Type == TrackType.Audio || tracks[i].Type != TrackType.Audio) @@ -231,9 +230,9 @@ public static class CompactDisc 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; @@ -241,16 +240,16 @@ public static class CompactDisc dataTrack.EndSector += 150; // Calculate MSF - minute = (int)dataTrack.EndSector / 4500; - second = ((int)dataTrack.EndSector - (minute * 4500)) / 75; - frame = (int)dataTrack.EndSector - (minute * 4500) - (second * 75); + minute = (int)dataTrack.EndSector / 4500; + second = ((int)dataTrack.EndSector - minute * 4500) / 75; + frame = (int)dataTrack.EndSector - minute * 4500 - second * 75; dataTrack.EndSector -= 150; // Convert to BCD - minute = ((minute / 10) << 4) + (minute % 10); - second = ((second / 10) << 4) + (second % 10); - frame = ((frame / 10) << 4) + (frame % 10); + minute = ((minute / 10) << 4) + minute % 10; + second = ((second / 10) << 4) + second % 10; + frame = ((frame / 10) << 4) + frame % 10; // Scramble M and S minute ^= 0x01; @@ -265,7 +264,7 @@ public static class CompactDisc tmpBuf = new byte[sectorSync.Length]; - for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++) + for(var i = 0; i < cmdBuf.Length - sectorSync.Length; i++) { Array.Copy(cmdBuf, i, tmpBuf, 0, sectorSync.Length); @@ -288,13 +287,13 @@ public static class CompactDisc if(sense || dev.Error) return; - for(int i = 0; i < dataBuf.Length; i++) + for(var i = 0; i < dataBuf.Length; i++) dataBuf[i] ^= Sector.ScrambleTable[i]; - for(int i = 0; i < 2352; i++) + for(var i = 0; i < 2352; i++) { - byte[] dataSide = new byte[2352 - i]; - byte[] audioSide = new byte[2352 - i]; + var dataSide = new byte[2352 - i]; + var audioSide = new byte[2352 - i]; Array.Copy(dataBuf, i, dataSide, 0, dataSide.Length); Array.Copy(cmdBuf, 0, audioSide, 0, audioSide.Length); @@ -309,7 +308,7 @@ public static class CompactDisc } else { - byte[] videoNowColorFrame = new byte[9 * sectorSize]; + 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, @@ -318,13 +317,11 @@ public static class CompactDisc 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, out _); + MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, + out _); 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 49e8ac642..88b2f1943 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -30,6 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +using DVDDecryption = Aaru.Decryption.DVD.Dump; + +namespace Aaru.Core.Media.Info; + using System; using System.Collections.Generic; using System.Linq; @@ -48,11 +52,8 @@ using Aaru.Decoders.Xbox; using Aaru.Devices; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; using DMI = Aaru.Decoders.Xbox.DMI; -using DVDDecryption = Aaru.Decryption.DVD.Dump; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; -namespace Aaru.Core.Media.Info; - /// Retrieves information from a SCSI device public sealed class ScsiInfo { @@ -66,17 +67,17 @@ public sealed class ScsiInfo MediaType = MediaType.Unknown; MediaInserted = false; - int resets = 0; + var resets = 0; bool sense; byte[] cmdBuf; byte[] senseBuf; - bool containsFloppyPage = false; - int sessions = 1; - int firstTrackLastSession = 1; + var containsFloppyPage = false; + var sessions = 1; + var firstTrackLastSession = 1; if(dev.IsRemovable) { - deviceGotReset: + deviceGotReset: sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _); if(sense) @@ -96,7 +97,7 @@ public sealed class ScsiInfo if(decSense?.ASC == 0x3A) { - int leftRetries = 5; + var leftRetries = 5; while(leftRetries > 0) { @@ -120,7 +121,7 @@ public sealed class ScsiInfo else if(decSense?.ASC == 0x04 && decSense?.ASCQ == 0x01) { - int leftRetries = 10; + var leftRetries = 10; while(leftRetries > 0) { @@ -144,8 +145,7 @@ public sealed class ScsiInfo } else { - AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}", - Sense.PrettifySense(senseBuf)); + AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}", Sense.PrettifySense(senseBuf)); return; } @@ -194,8 +194,7 @@ public sealed class ScsiInfo { ReadCapacity = cmdBuf; - Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & - 0xFFFFFFFF; + Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF; BlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } @@ -219,7 +218,7 @@ public sealed class ScsiInfo if(ReadCapacity16 != null) { - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); @@ -275,17 +274,15 @@ public sealed class ScsiInfo } */ break; - case PeripheralDeviceTypes.BridgingExpander - when dev.Model.StartsWith("MDM", StringComparison.Ordinal) || - dev.Model.StartsWith("MDH", StringComparison.Ordinal): + case PeripheralDeviceTypes.BridgingExpander when dev.Model.StartsWith("MDM", StringComparison.Ordinal) || + dev.Model.StartsWith("MDH", StringComparison.Ordinal): sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out _); if(!sense) { ReadCapacity = cmdBuf; - Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & - 0xFFFFFFFF; + Blocks = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & 0xFFFFFFFF; BlockSize = (uint)((cmdBuf[5] << 24) + (cmdBuf[5] << 16) + (cmdBuf[6] << 8) + cmdBuf[7]); } @@ -475,8 +472,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Recognized Format Layers\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Recognized Format Layers\n{0}", Sense.PrettifySense(senseBuf)); else RecognizedFormatLayers = cmdBuf; @@ -485,8 +481,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Write Protection Status\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Write Protection Status\n{0}", Sense.PrettifySense(senseBuf)); else WriteProtectionStatus = cmdBuf; @@ -523,10 +518,8 @@ public sealed class ScsiInfo MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Sense.PrettifySense(senseBuf)); - } else { DvdPfi = cmdBuf; @@ -553,8 +546,7 @@ public sealed class ScsiInfo break; case DiskCategory.DVDR: - MediaType = DecodedPfi.Value.PartVersion >= 6 ? MediaType.DVDRDL - : MediaType.DVDR; + MediaType = DecodedPfi.Value.PartVersion >= 6 ? MediaType.DVDRDL : MediaType.DVDR; break; case DiskCategory.DVDRAM: @@ -603,18 +595,14 @@ public sealed class ScsiInfo out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}", Sense.PrettifySense(senseBuf)); - } else { DvdDmi = cmdBuf; if(DMI.IsXbox(cmdBuf)) - { MediaType = MediaType.XGD; - } else if(DMI.IsXbox360(cmdBuf)) { MediaType = MediaType.XGD2; @@ -827,8 +815,7 @@ public sealed class ScsiInfo case MediaType.DVDRWDL: case MediaType.HDDVDR: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, out _); if(sense) AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R Media ID\n{0}", @@ -902,8 +889,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}", Sense.PrettifySense(senseBuf)); else HddvdrMediumStatus = cmdBuf; @@ -944,8 +930,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.MiddleZoneStart, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Middle Zone Start\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Middle Zone Start\n{0}", Sense.PrettifySense(senseBuf)); else DvdrDlMiddleZoneStart = cmdBuf; @@ -954,8 +939,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Jump Interval Size\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Jump Interval Size\n{0}", Sense.PrettifySense(senseBuf)); else DvdrDlJumpIntervalSize = cmdBuf; @@ -975,8 +959,7 @@ public sealed class ScsiInfo MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Remap Anchor Point\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Remap Anchor Point\n{0}", Sense.PrettifySense(senseBuf)); else DvdrDlRemapAnchorPoint = cmdBuf; @@ -1048,15 +1031,13 @@ public sealed class ScsiInfo MmcDiscStructureFormat.CartridgeStatus, 0, dev.Timeout, out _); if(sense) - AaruConsole.DebugWriteLine("Media-Info command", - "READ DISC STRUCTURE: Cartridge Status\n{0}", + AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Cartridge Status\n{0}", Sense.PrettifySense(senseBuf)); else BlurayCartridgeStatus = cmdBuf; sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, out _); if(sense) AaruConsole.DebugWriteLine("Media-Info command", @@ -1083,8 +1064,8 @@ public sealed class ScsiInfo 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("Media-Info command", "READ DISC INFORMATION 010b\n{0}", @@ -1106,10 +1087,8 @@ public sealed class ScsiInfo bool tocSense = dev.ReadTocPmaAtip(out cmdBuf, out senseBuf, false, 0, 0, dev.Timeout, out _); if(tocSense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: TOC\n{0}", Sense.PrettifySense(senseBuf)); - } else { Toc = cmdBuf; @@ -1124,10 +1103,8 @@ public sealed class ScsiInfo sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: ATIP\n{0}", Sense.PrettifySense(senseBuf)); - } else { Atip = cmdBuf; @@ -1147,10 +1124,8 @@ public sealed class ScsiInfo sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Session info\n{0}", Sense.PrettifySense(senseBuf)); - } else if(cmdBuf.Length > 4) { Session = cmdBuf; @@ -1166,10 +1141,8 @@ public sealed class ScsiInfo sense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Raw TOC\n{0}", Sense.PrettifySense(senseBuf)); - } else if(cmdBuf.Length > 4) { RawToc = cmdBuf; @@ -1188,10 +1161,8 @@ public sealed class ScsiInfo sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: CD-TEXT\n{0}", Sense.PrettifySense(senseBuf)); - } else if(cmdBuf.Length > 4) { CdTextLeadIn = cmdBuf; @@ -1233,10 +1204,8 @@ public sealed class ScsiInfo MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Sense.PrettifySense(senseBuf)); - } else { DvdPfi = cmdBuf; @@ -1278,10 +1247,8 @@ public sealed class ScsiInfo sense = dev.ReadMediaSerialNumber(out cmdBuf, out senseBuf, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ MEDIA SERIAL NUMBER\n{0}", Sense.PrettifySense(senseBuf)); - } else { if(cmdBuf.Length >= 4) @@ -1334,8 +1301,7 @@ public sealed class ScsiInfo } ulong totalSize = - (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) & - 0xFFFFFFFF; + (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 _); @@ -1415,15 +1381,14 @@ public sealed class ScsiInfo break; } - AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", - totalSize); + AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize); ulong middleZone = totalSize - (PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN - PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1) - gameSize + 1; - totalSize = l0Video + l1Video + (middleZone * 2) + gameSize; - ulong layerBreak = l0Video + middleZone + (gameSize / 2); + totalSize = l0Video + l1Video + middleZone * 2 + gameSize; + ulong layerBreak = l0Video + middleZone + gameSize / 2; XgdInfo = new XgdInfo { @@ -1458,17 +1423,15 @@ public sealed class ScsiInfo MediaType = MediaType.GENERIC_HDD; if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice || - (dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42))) + dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42)) return; sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.DiscInformation, dev.Timeout, out _); if(sense) - { AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 000b\n{0}", Sense.PrettifySense(senseBuf)); - } else { DiscInformation = cmdBuf; diff --git a/Aaru.Core/Options.cs b/Aaru.Core/Options.cs index 6ea7bbf33..424773bee 100644 --- a/Aaru.Core/Options.cs +++ b/Aaru.Core/Options.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System.Collections.Generic; using System.Globalization; using System.Text; -namespace Aaru.Core; - /// Option parsing public static class Options { @@ -44,18 +44,18 @@ public static class Options /// Options name-value dictionary public static Dictionary Parse(string options) { - Dictionary parsed = new Dictionary(); - bool escaped = false; - bool quoted = false; - bool inValue = false; - string name = null; - string value; - var sb = new StringBuilder(); + var parsed = new Dictionary(); + var escaped = false; + var quoted = false; + var inValue = false; + string name = null; + string value; + var sb = new StringBuilder(); if(options == null) return parsed; - for(int index = 0; index < options.Length; index++) + for(var index = 0; index < options.Length; index++) { char c = options[index]; diff --git a/Aaru.Core/Partitions.cs b/Aaru.Core/Partitions.cs index 64c47174f..ead7a32b0 100644 --- a/Aaru.Core/Partitions.cs +++ b/Aaru.Core/Partitions.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; -namespace Aaru.Core; - /// Implements methods for handling partitions public static class Partitions { @@ -47,10 +47,10 @@ public static class Partitions /// List of found partitions public static List GetAll(IMediaImage image) { - PluginBase plugins = GetPluginBase.Instance; - List foundPartitions = new List(); - List childPartitions = new List(); - List checkedLocations = new List(); + PluginBase plugins = GetPluginBase.Instance; + var foundPartitions = new List(); + var childPartitions = new List(); + var checkedLocations = new List(); var tapeImage = image as ITapeImage; var partitionableImage = image as IPartitionableMediaImage; @@ -110,7 +110,7 @@ public static class Partitions continue; } - List children = new List(); + var children = new List(); foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values) { @@ -153,8 +153,7 @@ public static class Partitions // Be sure that device partitions are not excluded if not mapped by any scheme... if(!(tapeImage is null)) { - List startLocations = - childPartitions.Select(detectedPartition => detectedPartition.Start).ToList(); + var startLocations = childPartitions.Select(detectedPartition => detectedPartition.Start).ToList(); if(tapeImage.Files != null) childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock)). @@ -168,12 +167,12 @@ public static class Partitions if(!(partitionableImage is null)) { - List startLocations = - childPartitions.Select(detectedPartition => detectedPartition.Start).ToList(); + var startLocations = childPartitions.Select(detectedPartition => detectedPartition.Start).ToList(); 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). @@ -193,7 +192,7 @@ public static class Partitions partitions.Count == 0) return; - List schemes = new List(); + var schemes = new List(); foreach(Partition part in partitions.Where(part => !schemes.Contains(part.Scheme))) schemes.Add(part.Scheme); diff --git a/Aaru.Core/PrintScsiModePages.cs b/Aaru.Core/PrintScsiModePages.cs index 06df018f7..77178a666 100644 --- a/Aaru.Core/PrintScsiModePages.cs +++ b/Aaru.Core/PrintScsiModePages.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Console; using Aaru.Decoders.SCSI; using Aaru.Helpers; -namespace Aaru.Core; - /// Prints all SCSI MODE pages public static class PrintScsiModePages { @@ -64,8 +64,8 @@ public static class PrintScsiModePages else { if(page.Subpage != 0) - AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h", - page.Page, page.Subpage); + AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h", page.Page, + page.Subpage); else AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h", page.Page); } diff --git a/Aaru.Core/Remote.cs b/Aaru.Core/Remote.cs index 8b8bd2a37..24ec1ee97 100644 --- a/Aaru.Core/Remote.cs +++ b/Aaru.Core/Remote.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -43,14 +45,13 @@ using Aaru.Console; using Aaru.Database; using Aaru.Database.Models; using Aaru.Dto; +using Aaru.Settings; +using global::Spectre.Console; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; -using Spectre.Console; using CdOffset = Aaru.Database.Models.CdOffset; using Version = Aaru.CommonTypes.Metadata.Version; -namespace Aaru.Core; - /// Handles connections to Aaru.Server public static class Remote { @@ -66,11 +67,10 @@ public static class Remote try { - string json = JsonConvert.SerializeObject(report, Formatting.Indented, - new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - }); + string json = JsonConvert.SerializeObject(report, Formatting.Indented, new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }); byte[] jsonBytes = Encoding.UTF8.GetBytes(json); var request = WebRequest.Create("https://www.aaru.app/api/uploadreportv2"); @@ -116,7 +116,7 @@ public static class Remote /// If true creates the database from scratch, otherwise updates an existing database public static void UpdateMainDatabase(bool create) { - var mctx = AaruContext.Create(Settings.Settings.MainDbPath); + var mctx = AaruContext.Create(Settings.MainDbPath); if(create) { @@ -126,10 +126,8 @@ public static class Remote 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')"); - } } else mctx.Database.Migrate(); @@ -330,8 +328,7 @@ public static class Remote { task.Increment(1); - UsbVendor existing = - mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId); + UsbVendor existing = mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId); if(existing != null) { diff --git a/Aaru.Core/Sidecar/AudioMedia.cs b/Aaru.Core/Sidecar/AudioMedia.cs index e80e15acf..5f9902e83 100644 --- a/Aaru.Core/Sidecar/AudioMedia.cs +++ b/Aaru.Core/Sidecar/AudioMedia.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.IO; @@ -38,8 +40,6 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Core; - public sealed partial class Sidecar { // TODO: Complete it diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index 4ae9e443b..bfd9f9215 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.IO; @@ -49,8 +51,6 @@ using Schemas; using MediaType = Aaru.CommonTypes.Metadata.MediaType; using Tuple = Aaru.Decoders.PCMCIA.Tuple; -namespace Aaru.Core; - public sealed partial class Sidecar { /// Creates a metadata sidecar for a block media (e.g. floppy, hard disk, flash card, usb stick) @@ -189,8 +189,7 @@ public sealed partial class Sidecar sidecar.BlockMedia[0].PCMCIA.Compliance = $"{vers.MajorVersion}.{vers.MinorVersion}"; - sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = - vers.AdditionalInformation; + sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation; } break; @@ -615,8 +614,7 @@ public sealed partial class Sidecar if(sectors - doneSectors >= sectorsToRead) { - errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, sectorsToRead, - out sector); + errno = image.ReadSectors(tapeFile.FirstBlock + doneSectors, sectorsToRead, out sector); if(errno != ErrorNumber.NoError) { @@ -692,7 +690,7 @@ public sealed partial class Sidecar { sidecar.BlockMedia[0].FileSystemInformation = new PartitionType[partitions.Count]; - for(int i = 0; i < partitions.Count; i++) + for(var i = 0; i < partitions.Count; i++) { if(_aborted) return; @@ -1001,8 +999,8 @@ public sealed partial class Sidecar } catch(NotImplementedException) {} - if((image.Info.Heads == 2 && scpImage.Header.heads == 0) || - (image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2))) + if(image.Info.Heads == 2 && scpImage.Header.heads == 0 || + image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2)) if(scpImage.Header.end + 1 >= image.Info.Cylinders) { List scpBlockTrackTypes = new(); @@ -1038,9 +1036,9 @@ public sealed partial class Sidecar if(scpImage.ScpTracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack)) { - byte[] trackContents = - new byte[scpTrack.Entries.Last().dataOffset + - scpTrack.Entries.Last().trackLength - scpImage.Header.offsets[t] + 1]; + var trackContents = + new byte[scpTrack.Entries.Last().dataOffset + scpTrack.Entries.Last().trackLength - + scpImage.Header.offsets[t] + 1]; scpStream.Position = scpImage.Header.offsets[t]; scpStream.Read(trackContents, 0, trackContents.Length); @@ -1069,10 +1067,9 @@ public sealed partial class Sidecar #region KryoFlux string kfFile = null; - string basename = Path.Combine(Path.GetDirectoryName(imagePath), - Path.GetFileNameWithoutExtension(imagePath)); + string basename = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath)); - bool kfDir = false; + var kfDir = false; if(_aborted) return; @@ -1147,7 +1144,7 @@ public sealed partial class Sidecar } Stream kfStream = kvp.Value.GetDataForkStream(); - byte[] trackContents = new byte[kfStream.Length]; + var trackContents = new byte[kfStream.Length]; kfStream.Position = 0; kfStream.Read(trackContents, 0, trackContents.Length); kfBlockTrackType.Size = (ulong)trackContents.Length; @@ -1233,7 +1230,7 @@ public sealed partial class Sidecar dfiImage.TrackLengths.TryGetValue(t, out long length)) { dfiBlockTrackType.Image.offset = (ulong)offset; - byte[] trackContents = new byte[length]; + var trackContents = new byte[length]; dfiStream.Position = offset; dfiStream.Read(trackContents, 0, trackContents.Length); dfiBlockTrackType.Size = (ulong)trackContents.Length; @@ -1243,8 +1240,7 @@ public sealed partial class Sidecar dfiBlockTrackTypes.Add(dfiBlockTrackType); } - sidecar.BlockMedia[0].Track = - dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); + sidecar.BlockMedia[0].Track = dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); } else AaruConsole. diff --git a/Aaru.Core/Sidecar/BlockTape.cs b/Aaru.Core/Sidecar/BlockTape.cs index d6872f463..6f32860a7 100644 --- a/Aaru.Core/Sidecar/BlockTape.cs +++ b/Aaru.Core/Sidecar/BlockTape.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System.Collections.Generic; using System.IO; using Schemas; -namespace Aaru.Core; - /// Sidecar operations public sealed partial class Sidecar { @@ -84,14 +84,14 @@ public sealed partial class Sidecar if(_aborted) return _sidecar; - ulong currentBlock = 0; - ulong totalSize = 0; - var tapeWorker = new Checksum(); - List tapeFiles = new List(); + ulong currentBlock = 0; + ulong totalSize = 0; + var tapeWorker = new Checksum(); + var tapeFiles = new List(); UpdateStatus("Hashing files..."); - for(int i = 0; i < files.Count; i++) + for(var i = 0; i < files.Count; i++) { if(_aborted) return _sidecar; diff --git a/Aaru.Core/Sidecar/Events.cs b/Aaru.Core/Sidecar/Events.cs index f5d8868ca..4b46ecc88 100644 --- a/Aaru.Core/Sidecar/Events.cs +++ b/Aaru.Core/Sidecar/Events.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; - namespace Aaru.Core; +using Aaru.CommonTypes; + public sealed partial class Sidecar { /// Initializes a progress indicator (e.g. makes a progress bar visible) @@ -72,6 +72,5 @@ public sealed partial class Sidecar public void EndProgress2() => EndProgressEvent2?.Invoke(); /// Updates a status indicator - public void UpdateStatus(string text, params object[] args) => - UpdateStatusEvent?.Invoke(string.Format(text, args)); + public void UpdateStatus(string text, params object[] args) => UpdateStatusEvent?.Invoke(string.Format(text, args)); } \ No newline at end of file diff --git a/Aaru.Core/Sidecar/Files.cs b/Aaru.Core/Sidecar/Files.cs index fa91675e1..68ab3fdb2 100644 --- a/Aaru.Core/Sidecar/Files.cs +++ b/Aaru.Core/Sidecar/Files.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Linq; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Console; using Schemas; -namespace Aaru.Core; - public sealed partial class Sidecar { FilesystemContentsType Files(IReadOnlyFilesystem filesystem) diff --git a/Aaru.Core/Sidecar/Helpers.cs b/Aaru.Core/Sidecar/Helpers.cs index 8060390e8..a2e97f410 100644 --- a/Aaru.Core/Sidecar/Helpers.cs +++ b/Aaru.Core/Sidecar/Helpers.cs @@ -80,13 +80,13 @@ public sealed partial class Sidecar } else { - h = (lba + (450150 * 2)) / (75 * 60 * 60); - lba -= h * (75 * 60 * 60); - m = (lba + (450150 * 2)) / (75 * 60); - lba -= m * (75 * 60); - s = (lba + (450150 * 2)) / 75; - lba -= s * 75; - f = lba + (450150 * 2); + h = (lba + 450150 * 2) / (75 * 60 * 60); + lba -= h * (75 * 60 * 60); + m = (lba + 450150 * 2) / (75 * 60); + lba -= m * (75 * 60); + s = (lba + 450150 * 2) / 75; + lba -= s * 75; + f = lba + 450150 * 2; } return string.Format("{3}:{0:D2}:{1:D2}:{2:D2}", m, s, f, h); diff --git a/Aaru.Core/Sidecar/LinearMedia.cs b/Aaru.Core/Sidecar/LinearMedia.cs index 1b6c57d2c..e23bff4a0 100644 --- a/Aaru.Core/Sidecar/LinearMedia.cs +++ b/Aaru.Core/Sidecar/LinearMedia.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.IO; @@ -38,8 +40,6 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Core; - public sealed partial class Sidecar { // TODO: Complete it diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 67658d13d..2545b189f 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.IO; @@ -49,8 +51,6 @@ using MediaType = Aaru.CommonTypes.MediaType; using Session = Aaru.CommonTypes.Structs.Session; using TrackType = Schemas.TrackType; -namespace Aaru.Core; - public sealed partial class Sidecar { /// Creates a metadata sidecar for an optical disc (e.g. CD, DVD, GD, BD, XGD, GOD) @@ -600,9 +600,7 @@ public sealed partial class Sidecar // For fast debugging, skip checksum //skipChecksum: - List trkPartitions = partitions. - Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector). - ToList(); + var trkPartitions = partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList(); xmlTrk.FileSystemInformation = new PartitionType[1]; @@ -610,7 +608,7 @@ public sealed partial class Sidecar { xmlTrk.FileSystemInformation = new PartitionType[trkPartitions.Count]; - for(int i = 0; i < trkPartitions.Count; i++) + for(var i = 0; i < trkPartitions.Count; i++) { xmlTrk.FileSystemInformation[i] = new PartitionType { @@ -760,13 +758,11 @@ public sealed partial class Sidecar } if(trk.Indexes?.Count > 0) - { xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).Select(i => new TrackIndexType { index = i.Key, Value = i.Value }).ToArray(); - } trksLst.Add(xmlTrk); } @@ -780,8 +776,7 @@ public sealed partial class Sidecar if(dskType == MediaType.XGD2 && sidecar.OpticalDisc[0].Track.Length == 1) { - ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector + - 1; + ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector + 1; if(blocks == 25063 || // Locked (or non compatible drive) blocks == 4229664 || // Xtreme unlock diff --git a/Aaru.Core/Sidecar/Sidecar.cs b/Aaru.Core/Sidecar/Sidecar.cs index 2e3402a3e..75f2fecca 100644 --- a/Aaru.Core/Sidecar/Sidecar.cs +++ b/Aaru.Core/Sidecar/Sidecar.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Schemas; -namespace Aaru.Core; - public sealed partial class Sidecar { readonly ChecksumType[] _emptyChecksums; diff --git a/Aaru.Core/Spectre.cs b/Aaru.Core/Spectre.cs index 1f1232376..1fa242585 100644 --- a/Aaru.Core/Spectre.cs +++ b/Aaru.Core/Spectre.cs @@ -1,10 +1,10 @@ -using System; -using Spectre.Console; - namespace Aaru.Core; +using System; +using global::Spectre.Console; + public static class Spectre { - 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 589ff51a5..12ccdfe5c 100644 --- a/Aaru.Core/Statistics.cs +++ b/Aaru.Core/Statistics.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Core; + using System; using System.Collections.Generic; using System.Diagnostics; @@ -44,6 +46,7 @@ using Aaru.CommonTypes.Metadata; using Aaru.Console; using Aaru.Database; using Aaru.Database.Models; +using Aaru.Settings; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; @@ -52,8 +55,6 @@ using MediaType = Aaru.CommonTypes.MediaType; using OperatingSystem = Aaru.Database.Models.OperatingSystem; using Version = Aaru.Database.Models.Version; -namespace Aaru.Core; - /// Handles anonymous usage statistics public static class Statistics { @@ -65,15 +66,15 @@ public static class Statistics { try { - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); - if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"))) + if(File.Exists(Path.Combine(Settings.StatsPath, "Statistics.xml"))) try { var allStats = new Stats(); var xs = new XmlSerializer(allStats.GetType()); - var sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")); + var sr = new StreamReader(Path.Combine(Settings.StatsPath, "Statistics.xml")); allStats = (Stats)xs.Deserialize(sr); sr.Close(); @@ -93,12 +94,12 @@ public static class Statistics if(allStats.Commands?.Checksum > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "checksum" && c.Synchronized) ?? new Command - { - Name = "checksum", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "checksum" && c.Synchronized) ?? + new Command + { + Name = "checksum", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.Checksum; ctx.Commands.Update(command); @@ -120,8 +121,7 @@ public static class Statistics if(allStats.Commands?.ConvertImage > 0) { Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "convert-image" && c.Synchronized) ?? - new Command + ctx.Commands.FirstOrDefault(c => c.Name == "convert-image" && c.Synchronized) ?? new Command { Name = "convert-image", Synchronized = true @@ -160,13 +160,12 @@ public static class Statistics if(allStats.Commands?.DeviceInfo > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "device-info" && c.Synchronized) ?? - new Command - { - Name = "device-info", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "device-info" && c.Synchronized) ?? + new Command + { + Name = "device-info", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.DeviceInfo; ctx.Commands.Update(command); @@ -175,8 +174,7 @@ public static class Statistics if(allStats.Commands?.DeviceReport > 0) { Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "device-report" && c.Synchronized) ?? - new Command + ctx.Commands.FirstOrDefault(c => c.Name == "device-report" && c.Synchronized) ?? new Command { Name = "device-report", Synchronized = true @@ -188,13 +186,12 @@ public static class Statistics if(allStats.Commands?.DumpMedia > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "dump-media" && c.Synchronized) ?? - new Command - { - Name = "dump-media", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media" && c.Synchronized) ?? + new Command + { + Name = "dump-media", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.DumpMedia; ctx.Commands.Update(command); @@ -216,8 +213,7 @@ public static class Statistics if(allStats.Commands?.ExtractFiles > 0) { Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "extract-files" && c.Synchronized) ?? - new Command + ctx.Commands.FirstOrDefault(c => c.Name == "extract-files" && c.Synchronized) ?? new Command { Name = "extract-files", Synchronized = true @@ -242,13 +238,12 @@ public static class Statistics if(allStats.Commands?.ImageInfo > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "image-info" && c.Synchronized) ?? - new Command - { - Name = "image-info", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "image-info" && c.Synchronized) ?? + new Command + { + Name = "image-info", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.ImageInfo; ctx.Commands.Update(command); @@ -257,8 +252,7 @@ public static class Statistics if(allStats.Commands?.ListDevices > 0) { Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "list-devices" && c.Synchronized) ?? - new Command + ctx.Commands.FirstOrDefault(c => c.Name == "list-devices" && c.Synchronized) ?? new Command { Name = "list-devices", Synchronized = true @@ -297,13 +291,12 @@ public static class Statistics if(allStats.Commands?.MediaInfo > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "media-info" && c.Synchronized) ?? - new Command - { - Name = "media-info", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "media-info" && c.Synchronized) ?? + new Command + { + Name = "media-info", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.MediaInfo; ctx.Commands.Update(command); @@ -311,13 +304,12 @@ public static class Statistics if(allStats.Commands?.MediaScan > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "media-scan" && c.Synchronized) ?? - new Command - { - Name = "media-scan", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan" && c.Synchronized) ?? + new Command + { + Name = "media-scan", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.MediaScan; ctx.Commands.Update(command); @@ -325,12 +317,12 @@ public static class Statistics if(allStats.Commands?.PrintHex > 0) { - Command command = - ctx.Commands.FirstOrDefault(c => c.Name == "printhex" && c.Synchronized) ?? new Command - { - Name = "printhex", - Synchronized = true - }; + Command command = ctx.Commands.FirstOrDefault(c => c.Name == "printhex" && c.Synchronized) ?? + new Command + { + Name = "printhex", + Synchronized = true + }; command.Count += (ulong)allStats.Commands.PrintHex; ctx.Commands.Update(command); @@ -376,13 +368,12 @@ public static class Statistics if(string.IsNullOrWhiteSpace(nvs.name)) continue; - Version existing = - ctx.Versions.FirstOrDefault(c => c.Name == nvs.name && c.Synchronized) ?? - new Version - { - Name = nvs.name, - Synchronized = true - }; + Version existing = ctx.Versions.FirstOrDefault(c => c.Name == nvs.name && c.Synchronized) ?? + new Version + { + Name = nvs.name, + Synchronized = true + }; existing.Count += (ulong)nvs.Value; ctx.Versions.Update(existing); @@ -466,12 +457,12 @@ public static class Statistics if(string.IsNullOrWhiteSpace(nvs.name)) continue; - Filter existing = - ctx.Filters.FirstOrDefault(c => c.Name == nvs.name && c.Synchronized) ?? new Filter - { - Name = nvs.name, - Synchronized = true - }; + Filter existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name && c.Synchronized) ?? + new Filter + { + Name = nvs.name, + Synchronized = true + }; existing.Count += (ulong)nvs.Value; ctx.Filters.Update(existing); @@ -515,14 +506,14 @@ public static class Statistics } ctx.SaveChanges(); - File.Delete(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")); + File.Delete(Path.Combine(Settings.StatsPath, "Statistics.xml")); } catch { // Do not care about it } - if(Settings.Settings.Current.Stats == null) + if(Settings.Current.Stats == null) return; ctx.OperatingSystems.Add(new OperatingSystem @@ -554,7 +545,7 @@ public static class Statistics { try { - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.SaveChanges(); } @@ -564,7 +555,7 @@ public static class Statistics AaruConsole.DebugWriteLine("Stats", "{0}", ex); } - if(Settings.Settings.Current.Stats is { ShareStats: true }) + if(Settings.Current.Stats is { ShareStats: true }) SubmitStats(); } @@ -573,7 +564,7 @@ public static class Statistics { var submitThread = new Thread(() => { - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); try { @@ -601,8 +592,7 @@ public static class Statistics { dto.Commands = new List(); - foreach(string nvs in ctx.Commands.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Commands.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) dto.Commands.Add(new NameValueStats { name = nvs, @@ -627,8 +617,7 @@ public static class Statistics { dto.Filters = new List(); - foreach(string nvs in ctx.Filters.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Filters.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) dto.Filters.Add(new NameValueStats { name = nvs, @@ -653,8 +642,7 @@ public static class Statistics { dto.Partitions = new List(); - foreach(string nvs in ctx.Partitions.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Partitions.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) dto.Partitions.Add(new NameValueStats { name = nvs, @@ -666,8 +654,7 @@ public static class Statistics { dto.Versions = new List(); - foreach(string nvs in ctx.Versions.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Versions.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) dto.Versions.Add(new NameValueStats { name = nvs, @@ -679,8 +666,7 @@ public static class Statistics { dto.Medias = new List(); - foreach(string media in ctx.Medias.Where(c => !c.Synchronized).Select(c => c.Type). - Distinct()) + foreach(string media in ctx.Medias.Where(c => !c.Synchronized).Select(c => c.Type).Distinct()) { if(ctx.Medias.Any(c => !c.Synchronized && c.Type == media && c.Real)) dto.Medias.Add(new MediaStats @@ -719,8 +705,8 @@ 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). @@ -729,9 +715,8 @@ public static class Statistics { name = osName, version = osVersion, - Value = ctx.OperatingSystems.LongCount(c => !c.Synchronized && - c.Name == osName && - c.Version == osVersion) + Value = ctx.OperatingSystems.LongCount(c => !c.Synchronized && c.Name == osName && + c.Version == osVersion) }); } } @@ -749,10 +734,11 @@ public static class Statistics Select(c => c.Version).Distinct()) dto.RemoteApplications.Add(new OsStats { - name = remoteAppName, + name = remoteAppName, version = remoteAppVersion, - Value = ctx.RemoteApplications.LongCount(c => !c.Synchronized && - c.Name == remoteAppName && c.Version == remoteAppVersion) + Value = ctx.RemoteApplications.LongCount(c => !c.Synchronized && + c.Name == remoteAppName && + c.Version == remoteAppVersion) }); } } @@ -761,8 +747,8 @@ 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 { name = nvs, @@ -778,8 +764,7 @@ public static class Statistics Select(c => c.Name).Distinct()) { foreach(string remoteOsVersion in ctx.RemoteOperatingSystems. - Where(c => !c.Synchronized && - c.Name == remoteOsName). + Where(c => !c.Synchronized && c.Name == remoteOsName). Select(c => c.Version).Distinct()) dto.RemoteOperatingSystems.Add(new OsStats { @@ -792,7 +777,7 @@ public static class Statistics } #if DEBUG - System.Console.WriteLine("Uploading statistics"); + Console.WriteLine("Uploading statistics"); #else Aaru.Console.AaruConsole.DebugWriteLine("Submit stats", "Uploading statistics"); #endif @@ -831,8 +816,7 @@ public static class Statistics return; if(ctx.Commands.Any(c => !c.Synchronized)) - foreach(string nvs in ctx.Commands.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Commands.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) { Command existing = ctx.Commands.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Command @@ -851,25 +835,21 @@ public static class Statistics Distinct()) { Filesystem existing = - ctx.Filesystems.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? - new Filesystem + ctx.Filesystems.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Filesystem { Name = nvs, Synchronized = true }; - existing.Count += - (ulong)ctx.Filesystems.LongCount(c => !c.Synchronized && c.Name == nvs); + existing.Count += (ulong)ctx.Filesystems.LongCount(c => !c.Synchronized && c.Name == nvs); ctx.Filesystems.Update(existing); - ctx.Filesystems.RemoveRange(ctx.Filesystems.Where(c => !c.Synchronized && - c.Name == nvs)); + ctx.Filesystems.RemoveRange(ctx.Filesystems.Where(c => !c.Synchronized && c.Name == nvs)); } if(ctx.Filters.Any(c => !c.Synchronized)) - foreach(string nvs in ctx.Filters.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Filters.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) { Filter existing = ctx.Filters.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Filter @@ -888,25 +868,21 @@ public static class Statistics Distinct()) { MediaFormat existing = - ctx.MediaFormats.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? - new MediaFormat + ctx.MediaFormats.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new MediaFormat { Name = nvs, Synchronized = true }; - existing.Count += - (ulong)ctx.MediaFormats.LongCount(c => !c.Synchronized && c.Name == nvs); + existing.Count += (ulong)ctx.MediaFormats.LongCount(c => !c.Synchronized && c.Name == nvs); ctx.MediaFormats.Update(existing); - ctx.MediaFormats.RemoveRange(ctx.MediaFormats.Where(c => !c.Synchronized && - c.Name == nvs)); + ctx.MediaFormats.RemoveRange(ctx.MediaFormats.Where(c => !c.Synchronized && c.Name == nvs)); } if(ctx.Partitions.Any(c => !c.Synchronized)) - foreach(string nvs in ctx.Partitions.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Partitions.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) { Partition existing = ctx.Partitions.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Partition @@ -915,16 +891,14 @@ public static class Statistics Synchronized = true }; - existing.Count += - (ulong)ctx.Partitions.LongCount(c => !c.Synchronized && c.Name == nvs); + existing.Count += (ulong)ctx.Partitions.LongCount(c => !c.Synchronized && c.Name == nvs); ctx.Partitions.Update(existing); ctx.Partitions.RemoveRange(ctx.Partitions.Where(c => !c.Synchronized && c.Name == nvs)); } if(ctx.Versions.Any(c => !c.Synchronized)) - foreach(string nvs in ctx.Versions.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string nvs in ctx.Versions.Where(c => !c.Synchronized).Select(c => c.Name).Distinct()) { Version existing = ctx.Versions.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Version @@ -939,8 +913,7 @@ public static class Statistics } if(ctx.Medias.Any(c => !c.Synchronized)) - foreach(string media in ctx.Medias.Where(c => !c.Synchronized).Select(c => c.Type). - Distinct()) + foreach(string media in ctx.Medias.Where(c => !c.Synchronized).Select(c => c.Type).Distinct()) { if(ctx.Medias.Any(c => !c.Synchronized && c.Type == media && c.Real)) { @@ -993,8 +966,8 @@ 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). @@ -1011,9 +984,8 @@ public static class Statistics }; existing.Count += - (ulong)ctx.OperatingSystems.LongCount(c => !c.Synchronized && - c.Name == osName && - c.Version == osVersion); + (ulong)ctx.OperatingSystems.LongCount(c => !c.Synchronized && c.Name == osName && + c.Version == osVersion); ctx.OperatingSystems.Update(existing); @@ -1050,16 +1022,15 @@ public static class Statistics ctx.RemoteApplications.Update(existing); - ctx.RemoteApplications.RemoveRange(ctx.RemoteApplications.Where(c => - !c.Synchronized && - c.Name == remoteAppName && + ctx.RemoteApplications.RemoveRange(ctx.RemoteApplications.Where(c => !c.Synchronized && + c.Name == remoteAppName && c.Version == remoteAppVersion)); } } 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) ?? @@ -1074,8 +1045,8 @@ public static class Statistics ctx.RemoteArchitectures.Update(existing); - ctx.RemoteArchitectures.RemoveRange(ctx.RemoteArchitectures. - Where(c => !c.Synchronized && c.Name == nvs)); + ctx.RemoteArchitectures.RemoveRange(ctx.RemoteArchitectures.Where(c => !c.Synchronized && + c.Name == nvs)); } foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized). @@ -1134,8 +1105,7 @@ public static class Statistics } IEnumerable statsFiles = - Directory.EnumerateFiles(Settings.Settings.StatsPath, "PartialStats_*.xml", - SearchOption.TopDirectoryOnly); + Directory.EnumerateFiles(Settings.StatsPath, "PartialStats_*.xml", SearchOption.TopDirectoryOnly); foreach(string statsFile in statsFiles) try @@ -1147,7 +1117,7 @@ public static class Statistics // This can execute before debug console has been inited #if DEBUG - System.Console.WriteLine("Uploading partial statistics file {0}", statsFile); + Console.WriteLine("Uploading partial statistics file {0}", statsFile); #else Aaru.Console.AaruConsole.DebugWriteLine("Submit stats", "Uploading partial statistics file {0}", statsFile); #endif @@ -1214,11 +1184,11 @@ public static class Statistics if(string.IsNullOrWhiteSpace(command)) return; - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.DeviceStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.DeviceStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Commands.Add(new Command { @@ -1245,11 +1215,11 @@ public static class Statistics if(string.IsNullOrWhiteSpace(filesystem)) return; - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.FilesystemStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.FilesystemStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Filesystems.Add(new Filesystem { @@ -1276,11 +1246,11 @@ public static class Statistics if(string.IsNullOrWhiteSpace(partition)) return; - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.PartitionStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.PartitionStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Partitions.Add(new Partition { @@ -1307,11 +1277,11 @@ public static class Statistics if(string.IsNullOrWhiteSpace(filter)) return; - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.FilterStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.FilterStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Filters.Add(new Filter { @@ -1338,11 +1308,11 @@ public static class Statistics if(string.IsNullOrWhiteSpace(format)) return; - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.MediaImageStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.MediaImageStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.MediaFormats.Add(new MediaFormat { @@ -1366,8 +1336,8 @@ public static class Statistics /// Device public static void AddDevice(Device dev) { - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.DeviceStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.DeviceStats) return; string deviceBus; @@ -1379,7 +1349,7 @@ public static class Statistics else deviceBus = dev.Type.ToString(); - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); if(ctx.SeenDevices.Any(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model && d.Revision == dev.FirmwareRevision && d.Bus == deviceBus)) @@ -1410,11 +1380,11 @@ 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 == null || - !Settings.Settings.Current.Stats.MediaStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.MediaStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Medias.Add(new Database.Models.Media { @@ -1439,11 +1409,11 @@ public static class Statistics public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem, string serverOperatingSystemVersion, string serverArchitecture) { - if(Settings.Settings.Current.Stats == null || - !Settings.Settings.Current.Stats.MediaStats) + if(Settings.Current.Stats == null || + !Settings.Current.Stats.MediaStats) return; - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); ctx.RemoteApplications.Add(new RemoteApplication { diff --git a/Aaru.Database/Aaru.Database.csproj b/Aaru.Database/Aaru.Database.csproj index 9990199c4..51caf5a92 100644 --- a/Aaru.Database/Aaru.Database.csproj +++ b/Aaru.Database/Aaru.Database.csproj @@ -1,198 +1,198 @@  - - Debug - AnyCPU - 2.0 - Library - Aaru.Database - Aaru.Database - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Database - $(Version) - net6 - 10 - Database models used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - full - true - bin\Release\net6 - prompt - 4 - false - - - - LICENSE.LGPL - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + Library + Aaru.Database + Aaru.Database + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Database + $(Version) + net6 + 10 + Database models used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + full + true + bin\Release\net6 + prompt + 4 + false + + + + LICENSE.LGPL + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Database/Context.cs b/Aaru.Database/Context.cs index 0a7221e94..22549abb4 100644 --- a/Aaru.Database/Context.cs +++ b/Aaru.Database/Context.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Database; + using Aaru.Database.Models; using Microsoft.EntityFrameworkCore; -namespace Aaru.Database; - /// /// Database context public sealed class AaruContext : DbContext diff --git a/Aaru.Database/ContextFactory.cs b/Aaru.Database/ContextFactory.cs index ec39e035e..67e3049cc 100644 --- a/Aaru.Database/ContextFactory.cs +++ b/Aaru.Database/ContextFactory.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Microsoft.EntityFrameworkCore.Design; - namespace Aaru.Database; +using Microsoft.EntityFrameworkCore.Design; + /// /// Database context factory, for design time public class AaruContextFactory : IDesignTimeDbContextFactory diff --git a/Aaru.Database/Models/BaseModel.cs b/Aaru.Database/Models/BaseModel.cs index 4aaf1388b..423b93fff 100644 --- a/Aaru.Database/Models/BaseModel.cs +++ b/Aaru.Database/Models/BaseModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.ComponentModel.DataAnnotations; - namespace Aaru.Database.Models; +using System.ComponentModel.DataAnnotations; + /// Base database model public abstract class BaseModel { diff --git a/Aaru.Database/Models/CdOffset.cs b/Aaru.Database/Models/CdOffset.cs index 266f1b99c..cc131a18f 100644 --- a/Aaru.Database/Models/CdOffset.cs +++ b/Aaru.Database/Models/CdOffset.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.Database.Models; +using System; + /// /// CD read offset public class CdOffset : CommonTypes.Metadata.CdOffset diff --git a/Aaru.Database/Models/Device.cs b/Aaru.Database/Models/Device.cs index 605b1fa05..8f07e0004 100644 --- a/Aaru.Database/Models/Device.cs +++ b/Aaru.Database/Models/Device.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Database.Models; + using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Metadata; -namespace Aaru.Database.Models; - /// Known device public class Device : DeviceReportV2 { diff --git a/Aaru.Database/Models/NesHeaderInfo.cs b/Aaru.Database/Models/NesHeaderInfo.cs index 27b3d594a..f26aae772 100644 --- a/Aaru.Database/Models/NesHeaderInfo.cs +++ b/Aaru.Database/Models/NesHeaderInfo.cs @@ -1,9 +1,9 @@ +namespace Aaru.Database.Models; + using System; using System.ComponentModel.DataAnnotations; using Aaru.CommonTypes.Enums; -namespace Aaru.Database.Models; - /// Information needed to rebuild an iNES/NES 2.0 header from a ROM hash public class NesHeaderInfo : BaseModel { diff --git a/Aaru.Database/Models/Report.cs b/Aaru.Database/Models/Report.cs index 6c4fb5486..9335facaa 100644 --- a/Aaru.Database/Models/Report.cs +++ b/Aaru.Database/Models/Report.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Database.Models; + using System; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Metadata; -namespace Aaru.Database.Models; - /// Device report public class Report : DeviceReportV2 { diff --git a/Aaru.Database/Models/UsbProduct.cs b/Aaru.Database/Models/UsbProduct.cs index 9b05b8fa1..c13fb745a 100644 --- a/Aaru.Database/Models/UsbProduct.cs +++ b/Aaru.Database/Models/UsbProduct.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Database.Models; + using System; using System.ComponentModel.DataAnnotations; -namespace Aaru.Database.Models; - /// USB product public class UsbProduct { diff --git a/Aaru.Database/Models/UsbVendor.cs b/Aaru.Database/Models/UsbVendor.cs index 253826ee1..00f27f043 100644 --- a/Aaru.Database/Models/UsbVendor.cs +++ b/Aaru.Database/Models/UsbVendor.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Database.Models; + using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Aaru.Database.Models; - /// USB vendor public class UsbVendor { diff --git a/Aaru.Decoders b/Aaru.Decoders index 0deebadaa..bd76adc35 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit 0deebadaa0de188c07f137441f3d8082cd7052b3 +Subproject commit bd76adc35e1536654fead662288b0fd82b0d061f diff --git a/Aaru.Decryption b/Aaru.Decryption index 2b6d8ae47..7d64becec 160000 --- a/Aaru.Decryption +++ b/Aaru.Decryption @@ -1 +1 @@ -Subproject commit 2b6d8ae4738151d0042cec5f2137fbb93c065ce3 +Subproject commit 7d64becec8791e6f95cd3e62dd496f4406857795 diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj index 19c534f2b..b22627029 100644 --- a/Aaru.Devices/Aaru.Devices.csproj +++ b/Aaru.Devices/Aaru.Devices.csproj @@ -1,164 +1,161 @@  - - Debug - AnyCPU - 2.0 - {57BB2341-AB62-48FD-91B8-46F5A2F9ED51} - Library - Aaru.Devices - Aaru.Devices - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Devices - $(Version) - net6 - 10 - Media device hardware interface implementation used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - AnyCPU - - - full - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {57BB2341-AB62-48FD-91B8-46F5A2F9ED51} + Library + Aaru.Devices + Aaru.Devices + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Devices + $(Version) + net6 + 10 + Media device hardware interface implementation used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + AnyCPU + + + full + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Devices/Command.cs b/Aaru.Devices/Command.cs index b3e349e7e..d54d03af4 100644 --- a/Aaru.Devices/Command.cs +++ b/Aaru.Devices/Command.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedMember.Global + +namespace Aaru.Devices; + using System; using Aaru.CommonTypes.Interop; using Aaru.Decoders.ATA; @@ -37,11 +43,7 @@ using Aaru.Devices.Windows; using Microsoft.Win32.SafeHandles; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; -// ReSharper disable UnusedMember.Global - -namespace Aaru.Devices; - -internal static class Command +static class Command { /// Sends a SCSI command /// 0 if no error occurred, otherwise, errno @@ -57,13 +59,12 @@ internal static class Command /// sense /// /// If the specified platform is not supported - internal static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, - uint timeout, ScsiDirection direction, out double duration, out bool sense) + internal static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout, + ScsiDirection direction, out double duration, out bool sense) { PlatformID ptId = DetectOS.GetRealPlatformID(); - return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration, - out sense); + return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration, out sense); } /// Sends a SCSI command @@ -107,8 +108,8 @@ internal static class Command break; } - return Windows.Command.SendScsiCommand((SafeFileHandle)fd, cdb, ref buffer, out senseBuffer, - timeout, dir, out duration, out sense); + return Windows.Command.SendScsiCommand((SafeFileHandle)fd, cdb, ref buffer, out senseBuffer, timeout, + dir, out duration, out sense); } case PlatformID.Linux: { @@ -158,15 +159,14 @@ internal static class Command /// What register contains the transfer length /// Set to true if the transfer length is in block, otherwise it is in bytes /// If the specified platform is not supported - internal static int SendAtaCommand(object fd, AtaRegistersChs registers, - out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol, - AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, - bool transferBlocks, out double duration, out bool sense) + internal static int SendAtaCommand(object fd, AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, + AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, + uint timeout, bool transferBlocks, out double duration, out bool sense) { PlatformID ptId = DetectOS.GetRealPlatformID(); - return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, - timeout, transferBlocks, out duration, out sense); + return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, + transferBlocks, out duration, out sense); } /// Sends an ATA command in CHS format @@ -192,10 +192,9 @@ internal static class Command { case PlatformID.Win32NT: { - if((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && - (Environment.OSVersion.ServicePack == "Service Pack 1" || - Environment.OSVersion.ServicePack == "")) || - (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0)) + if(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && + (Environment.OSVersion.ServicePack == "Service Pack 1" || Environment.OSVersion.ServicePack == "") || + Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0) throw new InvalidOperationException("Windows XP or earlier is not supported."); // Windows NT 4 or earlier, requires special ATA pass thru SCSI. But Aaru cannot run there (or can it?) @@ -207,9 +206,8 @@ internal static class Command } case PlatformID.Linux: { - return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, - out duration, out sense); + return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); } default: throw new InvalidOperationException($"Platform {ptId} not yet supported."); } @@ -235,8 +233,8 @@ internal static class Command { PlatformID ptId = DetectOS.GetRealPlatformID(); - return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, - timeout, transferBlocks, out duration, out sense); + return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, + transferBlocks, out duration, out sense); } /// Sends an ATA command in 28-bit LBA format @@ -262,10 +260,9 @@ internal static class Command { case PlatformID.Win32NT: { - if((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && - (Environment.OSVersion.ServicePack == "Service Pack 1" || - Environment.OSVersion.ServicePack == "")) || - (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0)) + if(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 && + (Environment.OSVersion.ServicePack == "Service Pack 1" || Environment.OSVersion.ServicePack == "") || + Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0) throw new InvalidOperationException("Windows XP or earlier is not supported."); // Windows NT 4 or earlier, requires special ATA pass thru SCSI. But Aaru cannot run there (or can it?) @@ -277,9 +274,8 @@ internal static class Command } case PlatformID.Linux: { - return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, - out duration, out sense); + return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); } default: throw new InvalidOperationException($"Platform {ptId} not yet supported."); } @@ -305,8 +301,8 @@ internal static class Command { PlatformID ptId = DetectOS.GetRealPlatformID(); - return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, - timeout, transferBlocks, out duration, out sense); + return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, + transferBlocks, out duration, out sense); } /// Sends an ATA command in 48-bit format @@ -335,9 +331,8 @@ internal static class Command return Windows.Command.SendAtaCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol, ref buffer, timeout, out duration, out sense); case PlatformID.Linux: - return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, - out duration, out sense); + return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); default: throw new InvalidOperationException($"Platform {ptId} not yet supported."); } } @@ -358,10 +353,9 @@ internal static class Command /// Response registers /// Size of block in bytes /// If the specified platform is not supported - internal static int SendMmcCommand(object fd, MmcCommands command, bool write, bool isApplication, - MmcFlags flags, uint argument, uint blockSize, uint blocks, - ref byte[] buffer, out uint[] response, out double duration, out bool sense, - uint timeout = 0) + internal static int SendMmcCommand(object fd, MmcCommands command, bool write, bool isApplication, MmcFlags flags, + uint argument, uint blockSize, uint blocks, ref byte[] buffer, + out uint[] response, out double duration, out bool sense, uint timeout = 0) { PlatformID ptId = DetectOS.GetRealPlatformID(); @@ -386,10 +380,9 @@ internal static class Command /// Response registers /// Size of block in bytes /// If the specified platform is not supported - internal static int SendMmcCommand(PlatformID ptId, object fd, MmcCommands command, bool write, - bool isApplication, MmcFlags flags, uint argument, uint blockSize, - uint blocks, ref byte[] buffer, out uint[] response, out double duration, - out bool sense, uint timeout = 0) + internal static int SendMmcCommand(PlatformID ptId, object fd, MmcCommands command, bool write, bool isApplication, + MmcFlags flags, uint argument, uint blockSize, uint blocks, ref byte[] buffer, + out uint[] response, out double duration, out bool sense, uint timeout = 0) { switch(ptId) { @@ -398,9 +391,8 @@ internal static class Command argument, blockSize, blocks, ref buffer, out response, out duration, out sense, timeout); case PlatformID.Linux: - return Linux.Command.SendMmcCommand((int)fd, command, write, isApplication, flags, argument, - blockSize, blocks, ref buffer, out response, out duration, - out sense, timeout); + return Linux.Command.SendMmcCommand((int)fd, command, write, isApplication, flags, argument, blockSize, + blocks, ref buffer, out response, out duration, out sense, timeout); default: throw new InvalidOperationException($"Platform {ptId} not yet supported."); } } @@ -411,8 +403,8 @@ internal static class Command switch(ptId) { case PlatformID.Win32NT: - return Windows.Command.SendMultipleMmcCommands((SafeFileHandle)fd, commands, out duration, - out sense, timeout); + return Windows.Command.SendMultipleMmcCommands((SafeFileHandle)fd, commands, out duration, out sense, + timeout); case PlatformID.Linux: return Linux.Command.SendMultipleMmcCommands((int)fd, commands, out duration, out sense, timeout); default: throw new InvalidOperationException($"Platform {ptId} not yet supported."); diff --git a/Aaru.Devices/Device/AtaCommands/Ata28.cs b/Aaru.Devices/Device/AtaCommands/Ata28.cs index 4f1ac5261..af89f4914 100644 --- a/Aaru.Devices/Device/AtaCommands/Ata28.cs +++ b/Aaru.Devices/Device/AtaCommands/Ata28.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Reads the drive buffer using PIO transfer @@ -54,9 +54,8 @@ public sealed 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; @@ -112,8 +111,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba, - byte count, uint timeout, out double duration) + public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba, byte count, + uint timeout, out double duration) { buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count]; @@ -167,9 +166,8 @@ public sealed 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,9 +195,8 @@ public sealed 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; @@ -225,8 +222,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count, - uint timeout, out double duration) => + public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count, uint timeout, + out double duration) => Read(out buffer, out statusRegisters, true, lba, count, timeout, out duration); /// Reads sectors using 28-bit addressing and PIO transfer, retrying on error @@ -238,8 +235,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba, - byte count, uint timeout, out double duration) + public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba, byte count, + uint timeout, out double duration) { buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count]; @@ -255,9 +252,8 @@ public sealed 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; @@ -304,9 +300,8 @@ public sealed 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; @@ -336,9 +331,8 @@ public sealed 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 8c6fdc2d1..633840aad 100644 --- a/Aaru.Devices/Device/AtaCommands/Ata48.cs +++ b/Aaru.Devices/Device/AtaCommands/Ata48.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Gets native max address using 48-bit addressing @@ -56,9 +56,8 @@ public sealed 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; @@ -139,9 +138,8 @@ public sealed partial class Device registers.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; @@ -214,9 +212,8 @@ public sealed 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; @@ -244,9 +241,8 @@ public sealed 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; @@ -293,9 +289,8 @@ public sealed 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 7dc66d2b9..e821da648 100644 --- a/Aaru.Devices/Device/AtaCommands/AtaCHS.cs +++ b/Aaru.Devices/Device/AtaCommands/AtaCHS.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout @@ -77,9 +77,8 @@ public sealed partial class Device Command = (byte)AtaCommands.IdentifyDevice }; - 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; @@ -151,8 +150,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, - byte head, byte sector, byte count, uint timeout, out double duration) + public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, + byte sector, byte count, uint timeout, out double duration) { buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count]; @@ -166,9 +165,8 @@ public sealed 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; @@ -217,9 +215,8 @@ public sealed 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; @@ -268,9 +265,8 @@ public sealed 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; @@ -287,8 +283,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector, - uint timeout, out double duration) + public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector, uint timeout, + out double duration) { byte[] buffer = Array.Empty(); @@ -301,9 +297,8 @@ public sealed 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; @@ -332,8 +327,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, ushort cylinder, - byte head, byte sector, byte sectorCount, uint timeout, out double duration) + public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, ushort cylinder, byte head, + byte sector, byte sectorCount, uint timeout, out double duration) { byte[] buffer = Array.Empty(); @@ -348,9 +343,8 @@ public sealed 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,9 +367,8 @@ public sealed 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; @@ -398,9 +391,8 @@ public sealed 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; @@ -423,9 +415,8 @@ public sealed 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 352e9c653..322ce7456 100644 --- a/Aaru.Devices/Device/AtaCommands/Atapi.cs +++ b/Aaru.Devices/Device/AtaCommands/Atapi.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout @@ -76,9 +76,8 @@ public sealed partial class Device Command = (byte)AtaCommands.IdentifyPacketDevice }; - 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/Cfa.cs b/Aaru.Devices/Device/AtaCommands/Cfa.cs index 20a168187..233a41ea9 100644 --- a/Aaru.Devices/Device/AtaCommands/Cfa.cs +++ b/Aaru.Devices/Device/AtaCommands/Cfa.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Requests to translate an LBA to a card physical address @@ -45,8 +45,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, - uint timeout, out double duration) + public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, + out double duration) { buffer = new byte[512]; @@ -61,9 +61,8 @@ public sealed 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; @@ -81,8 +80,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, - byte head, byte sector, uint timeout, out double duration) + public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, + byte sector, uint timeout, out double duration) { buffer = new byte[512]; @@ -95,9 +94,8 @@ public sealed 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; @@ -112,8 +110,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLba28 statusRegisters, - uint timeout, out double duration) + public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLba28 statusRegisters, uint timeout, + out double duration) { byte[] buffer = Array.Empty(); @@ -122,9 +120,8 @@ public sealed 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 65a357398..5ebe080d1 100644 --- a/Aaru.Devices/Device/AtaCommands/MCPT.cs +++ b/Aaru.Devices/Device/AtaCommands/MCPT.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Enables media card pass through @@ -73,9 +73,8 @@ public sealed 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 f24686614..1438f4655 100644 --- a/Aaru.Devices/Device/AtaCommands/Smart.cs +++ b/Aaru.Devices/Device/AtaCommands/Smart.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - public sealed partial class Device { /// Disables S.M.A.R.T. @@ -55,9 +55,8 @@ public sealed 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; @@ -85,9 +84,8 @@ public sealed 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; @@ -114,9 +112,8 @@ public sealed 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; @@ -142,9 +139,8 @@ public sealed 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; @@ -159,8 +155,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand, - uint timeout, out double duration) + public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand, uint timeout, + out double duration) { byte[] buffer = Array.Empty(); @@ -173,9 +169,8 @@ public sealed 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; @@ -203,9 +198,8 @@ public sealed 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; @@ -235,9 +229,8 @@ public sealed 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; @@ -263,9 +256,8 @@ public sealed 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/Commands.cs b/Aaru.Devices/Device/Commands.cs index e40791a8f..33f64d3fb 100644 --- a/Aaru.Devices/Device/Commands.cs +++ b/Aaru.Devices/Device/Commands.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Diagnostics.CodeAnalysis; using Aaru.Decoders.ATA; -namespace Aaru.Devices; - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public sealed partial class Device { @@ -80,9 +80,9 @@ public sealed partial class Device /// /// Time it took to execute the command in milliseconds /// True if ATA/ATAPI command returned non-OK status - public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, - AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, - uint timeout, bool transferBlocks, out double duration, out bool sense) + public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol, + AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, + bool transferBlocks, out double duration, out bool sense) { // We need a timeout if(timeout == 0) @@ -92,9 +92,8 @@ public sealed partial class Device return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); - return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, out duration, - out sense); + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); } /// Sends an ATA/ATAPI command to this device using 28-bit LBA addressing @@ -123,9 +122,8 @@ public sealed partial class Device return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); - return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, out duration, - out sense); + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); } /// Sends an ATA/ATAPI command to this device using 48-bit LBA addressing @@ -154,9 +152,8 @@ public sealed partial class Device return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); - return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, - transferRegister, ref buffer, timeout, transferBlocks, out duration, - out sense); + return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol, transferRegister, + ref buffer, timeout, transferBlocks, out duration, out sense); } /// Sends a MMC/SD command to this device @@ -174,8 +171,8 @@ public sealed partial class Device /// Response registers /// Size of block in bytes public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags, uint argument, - uint blockSize, uint blocks, ref byte[] buffer, out uint[] response, - out double duration, out bool sense, uint timeout = 15) + uint blockSize, uint blocks, ref byte[] buffer, out uint[] response, out double duration, + out bool sense, uint timeout = 15) { // We need a timeout if(timeout == 0) @@ -238,7 +235,8 @@ public sealed partial class Device ? Command.SendMmcCommand(PlatformId, FileHandle, command, write, isApplication, flags, argument, blockSize, blocks, ref buffer, out response, out duration, out sense, timeout) : _remote.SendMmcCommand(command, write, isApplication, flags, - argument, blockSize, blocks, ref buffer, out response, out duration, out sense, + argument, blockSize, blocks, ref buffer, + out response, out duration, out sense, timeout); } @@ -283,22 +281,21 @@ public sealed partial class Device timeout = Timeout > 0 ? Timeout : 15; if(_remote is null) - return Command.SendMultipleMmcCommands(PlatformId, FileHandle, commands, out duration, out sense, - timeout); + return Command.SendMultipleMmcCommands(PlatformId, FileHandle, commands, out duration, out sense, timeout); if(_remote.ServerProtocolVersion >= 2) return _remote.SendMultipleMmcCommands(commands, out duration, out sense, timeout); - int error = 0; + var error = 0; duration = 0; sense = false; 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); + 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) diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index c812d2dbc..3abea867b 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -56,8 +58,6 @@ using Marshal = System.Runtime.InteropServices.Marshal; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using VendorString = Aaru.Decoders.SecureDigital.VendorString; -namespace Aaru.Devices; - /// Implements a device or media containing drive [SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnusedMember.Global"), SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")] @@ -102,14 +102,13 @@ public sealed partial class Device LastError = errno; } else - { switch(PlatformId) { case PlatformID.Win32NT: { FileHandle = Extern.CreateFile(devicePath, FileAccess.GenericRead | FileAccess.GenericWrite, - FileShare.Read | FileShare.Write, IntPtr.Zero, - FileMode.OpenExisting, FileAttributes.Normal, IntPtr.Zero); + FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.OpenExisting, + FileAttributes.Normal, IntPtr.Zero); if(((SafeFileHandle)FileHandle).IsInvalid) { @@ -141,9 +140,7 @@ public sealed partial class Device } } else - { Error = true; - } LastError = Marshal.GetLastWin32Error(); } @@ -152,7 +149,6 @@ public sealed partial class Device } default: throw new DeviceException($"Platform {PlatformId} not supported."); } - } if(Error) throw new DeviceException(LastError); @@ -175,10 +171,10 @@ public sealed partial class Device if(Error) throw new DeviceException(LastError); - bool scsiSense = true; + var scsiSense = true; if(_remote is null) - { + // Windows is answering SCSI INQUIRY for all device types so it needs to be detected first switch(PlatformId) { @@ -189,16 +185,15 @@ public sealed partial class Device query.AdditionalParameters = new byte[1]; IntPtr descriptorPtr = Marshal.AllocHGlobal(1000); - byte[] descriptorB = new byte[1000]; + var descriptorB = new byte[1000]; uint returned = 0; - int error = 0; + var error = 0; bool hasError = !Extern.DeviceIoControlStorageQuery((SafeFileHandle)FileHandle, WindowsIoctl.IoctlStorageQueryProperty, ref query, (uint)Marshal.SizeOf(query), - descriptorPtr, 1000, ref returned, - IntPtr.Zero); + descriptorPtr, 1000, ref returned, IntPtr.Zero); if(hasError) error = Marshal.GetLastWin32Error(); @@ -226,8 +221,7 @@ public sealed partial class Device descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength]; - Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, - descriptor.RawPropertiesLength); + Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength); switch(descriptor.BusType) { @@ -291,9 +285,7 @@ public sealed partial class Device scsiSense = ScsiInquiry(out inqBuf, out _); } else - { Manufacturer = "ATA"; - } break; } @@ -303,13 +295,13 @@ public sealed partial class Device if(Windows.Command.IsSdhci((SafeFileHandle)FileHandle)) { - byte[] sdBuffer = new byte[16]; + var sdBuffer = new byte[16]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCsd, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | - MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, - out _, out _, out bool sense); + MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _, + out _, out bool sense); if(!sense) { @@ -322,8 +314,8 @@ public sealed partial class Device LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, MmcCommands.SendCid, false, false, MmcFlags.ResponseSpiR2 | MmcFlags.ResponseR2 | - MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, - out _, out _, out sense); + MmcFlags.CommandAc, 0, 16, 1, ref sdBuffer, out _, + out _, out sense); if(!sense) { @@ -334,11 +326,11 @@ public sealed partial class Device sdBuffer = new byte[8]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, - (MmcCommands)SecureDigitalCommands.SendScr, - false, true, + (MmcCommands)SecureDigitalCommands.SendScr, false, + true, MmcFlags.ResponseSpiR1 | MmcFlags.ResponseR1 | - MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, - out _, out _, out sense); + MmcFlags.CommandAdtc, 0, 8, 1, ref sdBuffer, out _, + out _, out sense); if(!sense) { @@ -354,8 +346,8 @@ public sealed partial class Device SendOperatingCondition : MmcCommands.SendOpCond, false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | - MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer, - out _, out _, out sense); + MmcFlags.CommandBcr, 0, 4, 1, ref sdBuffer, out _, + out _, out sense); if(!sense) { @@ -370,9 +362,7 @@ public sealed partial class Device devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sg", StringComparison.Ordinal)) - { scsiSense = ScsiInquiry(out inqBuf, out _); - } // MultiMediaCard and SecureDigital go here else if(devicePath.StartsWith("/dev/mmcblk", StringComparison.Ordinal)) @@ -381,8 +371,7 @@ public sealed partial class Device if(File.Exists("/sys/block/" + devPath + "/device/csd")) { - int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/csd", - out _cachedCsd); + int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/csd", out _cachedCsd); if(len == 0) _cachedCsd = null; @@ -390,8 +379,7 @@ public sealed partial class Device if(File.Exists("/sys/block/" + devPath + "/device/cid")) { - int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/cid", - out _cachedCid); + int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/cid", out _cachedCid); if(len == 0) _cachedCid = null; @@ -399,8 +387,7 @@ public sealed partial class Device if(File.Exists("/sys/block/" + devPath + "/device/scr")) { - int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/scr", - out _cachedScr); + int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/scr", out _cachedScr); if(len == 0) _cachedScr = null; @@ -408,8 +395,7 @@ public sealed partial class Device if(File.Exists("/sys/block/" + devPath + "/device/ocr")) { - int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/ocr", - out _cachedOcr); + int len = ConvertFromFileHexAscii("/sys/block/" + devPath + "/device/ocr", out _cachedOcr); if(len == 0) _cachedOcr = null; @@ -422,7 +408,6 @@ public sealed partial class Device break; } - } else { Type = _remote.GetDeviceType(); @@ -455,24 +440,22 @@ public sealed partial class Device if(_cachedScr != null) { Type = DeviceType.SecureDigital; - CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(_cachedCid); + CID decoded = Decoders.DecodeCID(_cachedCid); Manufacturer = VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; - FirmwareRevision = - $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; + FirmwareRevision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; Serial = $"{decoded.ProductSerialNumber}"; } else { Type = DeviceType.MMC; - Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(_cachedCid); - Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); + Aaru.Decoders.MMC.CID decoded = Aaru.Decoders.MMC.Decoders.DecodeCID(_cachedCid); + Manufacturer = Aaru.Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; - FirmwareRevision = - $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; + FirmwareRevision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; Serial = $"{decoded.ProductSerialNumber}"; } @@ -483,7 +466,6 @@ public sealed partial class Device #region USB if(_remote is null) - { switch(PlatformId) { case PlatformID.Linux: @@ -510,11 +492,11 @@ public sealed partial class Device !File.Exists(resolvedLink + "/idVendor")) continue; - var usbFs = new FileStream(resolvedLink + "/descriptors", - System.IO.FileMode.Open, System.IO.FileAccess.Read); + var usbFs = new FileStream(resolvedLink + "/descriptors", System.IO.FileMode.Open, + System.IO.FileAccess.Read); - byte[] usbBuf = new byte[65536]; - int usbCount = usbFs.Read(usbBuf, 0, 65536); + var usbBuf = new byte[65536]; + int usbCount = usbFs.Read(usbBuf, 0, 65536); UsbDescriptors = new byte[usbCount]; Array.Copy(usbBuf, 0, UsbDescriptors, 0, usbCount); usbFs.Close(); @@ -590,8 +572,7 @@ public sealed partial class Device UsbProductString = usbDevice.Product; UsbSerialString = - usbDevice. - SerialNumber; // This is incorrect filled by Windows with SCSI/ATA serial number + usbDevice.SerialNumber; // This is incorrect filled by Windows with SCSI/ATA serial number } break; @@ -600,7 +581,6 @@ public sealed partial class Device break; } - } else { if(_remote.GetUsbData(out byte[] remoteUsbDescriptors, out ushort remoteUsbVendor, @@ -702,9 +682,7 @@ public sealed partial class Device // TODO: Implement for other operating systems else - { IsFireWire = false; - } } #endregion FireWire @@ -748,8 +726,8 @@ public sealed partial class Device var cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open, System.IO.FileAccess.Read); - byte[] cisBuf = new byte[65536]; - int cisCount = cisFs.Read(cisBuf, 0, 65536); + var cisBuf = new byte[65536]; + int cisCount = cisFs.Read(cisBuf, 0, 65536); Cis = new byte[cisCount]; Array.Copy(cisBuf, 0, Cis, 0, cisCount); cisFs.Close(); @@ -764,9 +742,7 @@ public sealed partial class Device // TODO: Implement for other operating systems else - { IsPcmcia = false; - } } else { @@ -825,7 +801,7 @@ public sealed partial class Device Error = false; } - if((scsiSense && !(IsUsb || IsFireWire)) || + if(scsiSense && !(IsUsb || IsFireWire) || Manufacturer == "ATA") { bool ataSense = AtaIdentify(out ataBuf, out _); @@ -840,9 +816,7 @@ public sealed partial class Device string[] separated = ataid.Value.Model.Split(' '); if(separated.Length == 1) - { Model = separated[0]; - } else { Manufacturer = separated[0]; @@ -884,7 +858,7 @@ public sealed partial class Device Serial = UsbSerialString; else foreach(char c in Serial.Where(c => !char.IsControl(c))) - Serial = $"{Serial}{(uint)c:X2}"; + Serial = $"{Serial}{c:X2}"; } if(IsFireWire) @@ -899,7 +873,7 @@ public sealed partial class Device Serial = $"{_firewireGuid:X16}"; else foreach(char c in Serial.Where(c => !char.IsControl(c))) - Serial = $"{Serial}{(uint)c:X2}"; + Serial = $"{Serial}{c:X2}"; } // Some optical drives are not getting the correct serial, and IDENTIFY PACKET DEVICE is blocked without diff --git a/Aaru.Devices/Device/Destructor.cs b/Aaru.Devices/Device/Destructor.cs index aa53c500f..1b8ffa1dc 100644 --- a/Aaru.Devices/Device/Destructor.cs +++ b/Aaru.Devices/Device/Destructor.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using Aaru.CommonTypes.Interop; using Aaru.Devices.Linux; using Microsoft.Win32.SafeHandles; -namespace Aaru.Devices; - public sealed partial class Device { /// diff --git a/Aaru.Devices/Device/DeviceException.cs b/Aaru.Devices/Device/DeviceException.cs index 5f496763c..cfecf17e0 100644 --- a/Aaru.Devices/Device/DeviceException.cs +++ b/Aaru.Devices/Device/DeviceException.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.Devices; +using System; + /// /// Exception to be returned by the device constructor public sealed class DeviceException : Exception diff --git a/Aaru.Devices/Device/List.cs b/Aaru.Devices/Device/List.cs index 1c988601a..5cb1dc851 100644 --- a/Aaru.Devices/Device/List.cs +++ b/Aaru.Devices/Device/List.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Runtime.InteropServices; using Aaru.CommonTypes.Interop; using Aaru.Console; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; -namespace Aaru.Devices; - /// Contains device information [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct DeviceInfo @@ -90,10 +90,9 @@ public sealed partial class Device /// Remote URI /// List of devices /// - public static DeviceInfo[] ListDevices(out bool isRemote, out string serverApplication, - out string serverVersion, out string serverOperatingSystem, - out string serverOperatingSystemVersion, out string serverArchitecture, - string aaruRemote = null) + public static DeviceInfo[] ListDevices(out bool isRemote, out string serverApplication, out string serverVersion, + out string serverOperatingSystem, out string serverOperatingSystemVersion, + out string serverArchitecture, string aaruRemote = null) { isRemote = false; serverApplication = null; @@ -108,8 +107,7 @@ public sealed partial class Device case PlatformID.Win32NT: return Windows.ListDevices.GetList(); case PlatformID.Linux: return Linux.ListDevices.GetList(); default: - throw new - InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported."); + throw new InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported."); } try diff --git a/Aaru.Devices/Device/MmcCommands/MMC.cs b/Aaru.Devices/Device/MmcCommands/MMC.cs index 7046dd014..77ac7c05b 100644 --- a/Aaru.Devices/Device/MmcCommands/MMC.cs +++ b/Aaru.Devices/Device/MmcCommands/MMC.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Reads the CSD register from a SecureDigital or MultiMediaCard device @@ -155,7 +155,7 @@ public sealed partial class Device public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength, bool byteAddressed, uint timeout, out double duration) { - bool sense = true; + var sense = true; buffer = null; response = null; duration = -1; @@ -164,8 +164,8 @@ public sealed partial class Device return ReadSingleBlock(out buffer, out response, lba, blockSize, byteAddressed, timeout, out duration); if(!_readMultipleBlockCannotSetBlockCount) - sense = ReadMultipleBlock(out buffer, out response, lba, blockSize, transferLength, byteAddressed, - timeout, out duration); + 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, @@ -183,8 +183,8 @@ public sealed partial class Device /// Timeout to wait for command execution /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise - public bool ReadSingleBlock(out byte[] buffer, out uint[] response, uint lba, uint blockSize, - bool byteAddressed, uint timeout, out double duration) + public bool ReadSingleBlock(out byte[] buffer, out uint[] response, uint lba, uint blockSize, bool byteAddressed, + uint timeout, out double duration) { uint address; buffer = new byte[blockSize]; @@ -233,8 +233,8 @@ public sealed partial class Device 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); + blockSize, transferLength, ref buffer, out response, out duration, out bool sense, + timeout); Error = LastError != 0; @@ -260,13 +260,12 @@ public sealed partial class Device /// Time the device took to execute the command in milliseconds /// true if the device set an error condition, false otherwise public bool ReadMultipleUsingSingle(out byte[] buffer, out uint[] response, uint lba, uint blockSize, - ushort transferLength, bool byteAddressed, uint timeout, - out double duration) + ushort transferLength, bool byteAddressed, uint timeout, out double duration) { buffer = new byte[transferLength * blockSize]; - byte[] blockBuffer = new byte[blockSize]; + var blockBuffer = new byte[blockSize]; duration = 0; - bool sense = true; + var sense = true; response = null; for(uint i = 0; i < transferLength; i++) @@ -280,8 +279,8 @@ public sealed partial class Device 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); + blockSize, 1, ref blockBuffer, out response, out double blockDuration, out sense, + timeout); Error = LastError != 0; @@ -332,8 +331,8 @@ public sealed partial class Device public bool ReadWithBlockCount(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength, bool byteAddressed, uint timeout, out double duration) { - uint address = byteAddressed ? lba * blockSize : lba; - MmcSingleCommand[] commands = new MmcSingleCommand[3]; + uint address = byteAddressed ? lba * blockSize : lba; + var commands = new MmcSingleCommand[3]; // SET_BLOCK_COUNT commands[0] = new MmcSingleCommand diff --git a/Aaru.Devices/Device/MmcCommands/SecureDigital.cs b/Aaru.Devices/Device/MmcCommands/SecureDigital.cs index ca0f50a44..2be782035 100644 --- a/Aaru.Devices/Device/MmcCommands/SecureDigital.cs +++ b/Aaru.Devices/Device/MmcCommands/SecureDigital.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Reads the status register from a SecureDigital device diff --git a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs index c8ed7221b..7e3335dd2 100644 --- a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs +++ b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs @@ -31,11 +31,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Gets the underlying drive cylinder, head and index bytes for the specified SCSI LBA. @@ -59,7 +59,7 @@ public sealed partial class Device out double duration) { buffer = new byte[8]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.AdaptecTranslate; @@ -86,8 +86,7 @@ public sealed partial class Device /// Sense buffer. /// Timeout. /// Duration. - public bool - AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, uint timeout, out double duration) => + public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, uint timeout, out double duration) => AdaptecSetErrorThreshold(threshold, out senseBuffer, false, timeout, out duration); /// Sets the error threshold @@ -100,9 +99,9 @@ public sealed partial class Device public bool AdaptecSetErrorThreshold(byte threshold, out byte[] senseBuffer, bool drive1, uint timeout, out double duration) { - byte[] buffer = new byte[1]; + var buffer = new byte[1]; buffer[0] = threshold; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.AdaptecSetErrorThreshold; @@ -127,8 +126,7 @@ public sealed partial class Device /// Sense buffer. /// Timeout. /// Duration. - public bool AdaptecReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, - out double duration) => + public bool AdaptecReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => AdaptecReadUsageCounter(out buffer, out senseBuffer, false, timeout, out duration); /// Requests the usage, seek and error counters, and resets them @@ -141,7 +139,7 @@ public sealed partial class Device out double duration) { buffer = new byte[9]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.AdaptecTranslate; @@ -168,10 +166,10 @@ public sealed partial class Device /// Duration. public bool AdaptecWriteBuffer(byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { - byte[] oneKBuffer = new byte[1024]; + var oneKBuffer = new byte[1024]; Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length < 1024 ? buffer.Length : 1024); - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.AdaptecWriteBuffer; @@ -194,7 +192,7 @@ public sealed partial class Device public bool AdaptecReadBuffer(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { buffer = new byte[1024]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.AdaptecReadBuffer; diff --git a/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs b/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs index 5071ccd05..6da1cfe0f 100644 --- a/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs +++ b/Aaru.Devices/Device/ScsiCommands/ArchiveCorp.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Gets the underlying drive cylinder, head and index bytes for the specified SCSI LBA. @@ -47,7 +47,7 @@ public sealed partial class Device out double duration) { buffer = new byte[3]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ArchiveRequestBlockAddress; @@ -84,7 +84,7 @@ public sealed partial class Device out double duration) { byte[] buffer = Array.Empty(); - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ArchiveSeekBlock; diff --git a/Aaru.Devices/Device/ScsiCommands/Certance.cs b/Aaru.Devices/Device/ScsiCommands/Certance.cs index 1a6953d44..2aba2048f 100644 --- a/Aaru.Devices/Device/ScsiCommands/Certance.cs +++ b/Aaru.Devices/Device/ScsiCommands/Certance.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Diagnostics.CodeAnalysis; using Aaru.Console; -namespace Aaru.Devices; - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public sealed partial class Device { @@ -61,7 +61,7 @@ public sealed partial class Device public bool CertanceParkUnpark(out byte[] senseBuffer, bool park, uint timeout, out double duration) { byte[] buffer = Array.Empty(); - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.CertanceParkUnpark; diff --git a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs index 1d748cd23..c78ef013f 100644 --- a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs +++ b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Devices; - public sealed partial class Device { /// Sets the data for the integrated display @@ -52,12 +52,12 @@ public sealed partial class Device string secondHalf, uint timeout, out double duration) { byte[] tmp; - byte[] firstHalfBytes = new byte[8]; - byte[] secondHalfBytes = new byte[8]; - byte[] buffer = new byte[17]; - bool displayLen = false; - bool halfMsg = false; - byte[] cdb = new byte[10]; + var firstHalfBytes = new byte[8]; + var secondHalfBytes = new byte[8]; + var buffer = new byte[17]; + var displayLen = false; + var halfMsg = false; + var cdb = new byte[10]; if(!string.IsNullOrWhiteSpace(firstHalf)) { diff --git a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs index e7f67c7dd..4344bf8cc 100644 --- a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs +++ b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Reads a "raw" sector from DVD on HL-DT-ST drives. @@ -44,11 +44,11 @@ public sealed partial class Device /// Duration in milliseconds it took for the device to execute the command. /// Start block address. /// How many blocks to read. - public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength, - uint timeout, out double duration) + public bool HlDtStReadRawDvd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint transferLength, uint timeout, + out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; buffer = new byte[2064 * transferLength]; cdb[0] = (byte)ScsiCommands.HlDtStVendor; diff --git a/Aaru.Devices/Device/ScsiCommands/HP.cs b/Aaru.Devices/Device/ScsiCommands/HP.cs index e32e09f73..3226d465a 100644 --- a/Aaru.Devices/Device/ScsiCommands/HP.cs +++ b/Aaru.Devices/Device/ScsiCommands/HP.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Sends the HP READ LONG vendor command @@ -65,12 +65,11 @@ public sealed partial class Device /// /// Timeout in seconds. /// Duration in milliseconds it took for the device to execute the command. - public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, - ushort transferLen, ushort blockBytes, bool pba, bool sectorCount, uint timeout, - out double duration) + public bool HpReadLong(out byte[] buffer, out byte[] senseBuffer, bool relAddr, uint address, ushort transferLen, + ushort blockBytes, bool pba, bool sectorCount, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.ReadLong; diff --git a/Aaru.Devices/Device/ScsiCommands/Kreon.cs b/Aaru.Devices/Device/ScsiCommands/Kreon.cs index 43c4d7d4a..ad94c2eb6 100644 --- a/Aaru.Devices/Device/ScsiCommands/Kreon.cs +++ b/Aaru.Devices/Device/ScsiCommands/Kreon.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Sets the drive to the xtreme unlocked state @@ -45,7 +45,7 @@ public sealed partial class Device public bool KreonDeprecatedUnlock(out byte[] senseBuffer, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.KreonCommand; @@ -96,7 +96,7 @@ public sealed partial class Device public bool KreonSetLockState(out byte[] senseBuffer, KreonLockStates state, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.KreonCommand; @@ -125,8 +125,8 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; - byte[] buffer = new byte[26]; + var cdb = new byte[6]; + var buffer = new byte[26]; features = 0; cdb[0] = (byte)ScsiCommands.KreonCommand; @@ -150,9 +150,9 @@ public sealed partial class Device buffer[3] != 0xA5) return true; - for(int i = 4; i < 26; i += 2) + for(var i = 4; i < 26; i += 2) { - ushort feature = BitConverter.ToUInt16(buffer, i); + var feature = BitConverter.ToUInt16(buffer, i); if(feature == 0x0000) break; @@ -216,7 +216,7 @@ public sealed partial class Device byte requestNumber = 0x00) { buffer = new byte[2048]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.KreonSsCommand; diff --git a/Aaru.Devices/Device/ScsiCommands/MMC.cs b/Aaru.Devices/Device/ScsiCommands/MMC.cs index 96bf0972c..21c1c8e9c 100644 --- a/Aaru.Devices/Device/ScsiCommands/MMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/MMC.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the MMC GET CONFIGURATION command for all Features @@ -55,8 +55,8 @@ public sealed partial class Device /// Feature number where the feature list should start from /// Timeout in seconds. /// 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) => + 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, out duration); @@ -72,7 +72,7 @@ public sealed partial class Device MmcGetConfigurationRt rt, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[8]; cdb[0] = (byte)ScsiCommands.GetConfiguration; @@ -91,7 +91,7 @@ public sealed partial class Device if(sense) return true; - ushort confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4); + var confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4); buffer = new byte[confLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -125,7 +125,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; buffer = new byte[8]; cdb[0] = (byte)ScsiCommands.ReadDiscStructure; @@ -148,7 +148,7 @@ public sealed partial class Device if(sense) return true; - ushort strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); // WORKAROUND: Some drives return incorrect length information. As these structures are fixed length just apply known length. if(mediaType == MmcDiscStructureMediaType.Bd) @@ -291,7 +291,7 @@ public sealed partial class Device byte trackSessionNumber, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1536]; @@ -310,7 +310,7 @@ public sealed partial class Device Error = LastError != 0; - uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); + var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); buffer = new byte[strctLength]; if(buffer.Length <= tmpBuffer.Length) @@ -361,8 +361,8 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; - byte[] tmpBuffer = new byte[804]; + var cdb = new byte[10]; + var tmpBuffer = new byte[804]; cdb[0] = (byte)ScsiCommands.ReadDiscInformation; cdb[1] = (byte)dataType; @@ -374,7 +374,7 @@ public sealed partial class Device Error = LastError != 0; - uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); + var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); if(strctLength > tmpBuffer.Length) strctLength = (uint)tmpBuffer.Length; @@ -408,12 +408,12 @@ public sealed partial class Device /// C2 error options. /// Subchannel selection. public bool ReadCd(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, uint transferLength, - MmcSectorTypes expectedSectorType, bool dap, bool relAddr, bool sync, - MmcHeaderCodes headerCodes, bool userData, bool edcEcc, MmcErrorField c2Error, - MmcSubchannel subchannel, uint timeout, out double duration) + MmcSectorTypes expectedSectorType, bool dap, bool relAddr, bool sync, MmcHeaderCodes headerCodes, + bool userData, bool edcEcc, MmcErrorField c2Error, MmcSubchannel subchannel, uint timeout, + out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCd; cdb[1] = (byte)((byte)expectedSectorType << 2); @@ -483,7 +483,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCdMsf; cdb[1] = (byte)((byte)expectedSectorType << 2); @@ -511,7 +511,7 @@ public sealed partial class Device cdb[10] = (byte)subchannel; - uint transferLength = (uint)(((cdb[6] - cdb[3]) * 60 * 75) + ((cdb[7] - cdb[4]) * 75) + (cdb[8] - cdb[5])); + var transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5])); buffer = new byte[blockSize * transferLength]; @@ -522,8 +522,8 @@ public sealed partial class Device AaruConsole.DebugWriteLine("SCSI Device", "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); + duration, startMsf, endMsf, blockSize, expectedSectorType, dap, sync, headerCodes, + userData, edcEcc, c2Error, subchannel, sense, LastError); return sense; } @@ -555,7 +555,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval; @@ -625,7 +625,7 @@ public sealed partial class Device bool changeFormatLayer, bool loadEject, bool start, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.StartStopUnit; @@ -670,11 +670,10 @@ public sealed partial class Device /// Duration in milliseconds it took for the device to execute the command. /// true if the command failed and contains the sense buffer. [SuppressMessage("ReSharper", "ShiftExpressionZeroLeftOperand")] - public bool ReadMcn(out string mcn, out byte[] buffer, out byte[] senseBuffer, uint timeout, - out double duration) + public bool ReadMcn(out string mcn, out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; mcn = null; cdb[0] = (byte)ScsiCommands.ReadSubChannel; @@ -691,9 +690,8 @@ public sealed partial class Device Error = LastError != 0; - AaruConsole.DebugWriteLine("SCSI Device", - "READ READ SUB-CHANNEL (MCN, Sense {1}, Last Error {2}) took {0} ms.", duration, - sense, LastError); + AaruConsole.DebugWriteLine("SCSI Device", "READ READ SUB-CHANNEL (MCN, Sense {1}, Last Error {2}) took {0} ms.", + duration, sense, LastError); if(!sense && (buffer[8] & 0x80) == 0x80) @@ -715,7 +713,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; isrc = null; cdb[0] = (byte)ScsiCommands.ReadSubChannel; @@ -756,7 +754,7 @@ public sealed partial class Device ushort writeSpeed, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.SetCdRomSpeed; @@ -787,11 +785,11 @@ public sealed partial class Device /// Duration in milliseconds it took for the device to execute the command. /// Report information of non-closed tracks /// Type of information to retrieve - public bool ReadTrackInformation(out byte[] buffer, out byte[] senseBuffer, bool open, - TrackInformationType type, uint address, uint timeout, out double duration) + public bool ReadTrackInformation(out byte[] buffer, out byte[] senseBuffer, bool open, TrackInformationType type, + uint address, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[48]; cdb[0] = (byte)ScsiCommands.ReadTrackInformation; diff --git a/Aaru.Devices/Device/ScsiCommands/MediaTek.cs b/Aaru.Devices/Device/ScsiCommands/MediaTek.cs index 7aeaf58ab..f4fb58923 100644 --- a/Aaru.Devices/Device/ScsiCommands/MediaTek.cs +++ b/Aaru.Devices/Device/ScsiCommands/MediaTek.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Reads from the drive's DRAM. @@ -48,7 +48,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[length]; cdb[0] = (byte)ScsiCommands.MediaTekVendorCommand; diff --git a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs index d513fc5c1..b433c66f3 100644 --- a/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs +++ b/Aaru.Devices/Device/ScsiCommands/MiniDisc.cs @@ -30,13 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using Aaru.Console; + // ReSharper disable InconsistentNaming namespace Aaru.Devices; +using System; +using Aaru.Console; + public sealed partial class Device { /// Reads the data TOC from an MD-DATA @@ -49,7 +51,7 @@ public sealed partial class Device { ushort transferLength = 2336; senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscReadDTOC; @@ -80,7 +82,7 @@ public sealed partial class Device { ushort transferLength = 2336; senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscReadUTOC; @@ -113,7 +115,7 @@ public sealed partial class Device { ushort transferLength = 4; senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscD5; @@ -141,7 +143,7 @@ public sealed partial class Device public bool MiniDiscStopPlaying(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscStopPlay; @@ -167,7 +169,7 @@ public sealed partial class Device { ushort transferLength = 4; senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscReadPosition; @@ -196,7 +198,7 @@ public sealed partial class Device { ushort transferLength = 8; senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.MiniDiscGetType; diff --git a/Aaru.Devices/Device/ScsiCommands/NEC.cs b/Aaru.Devices/Device/ScsiCommands/NEC.cs index 6e6f02559..7a69d704c 100644 --- a/Aaru.Devices/Device/ScsiCommands/NEC.cs +++ b/Aaru.Devices/Device/ScsiCommands/NEC.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Sends the NEC READ CD-DA command @@ -48,7 +48,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.NecReadCdDa; cdb[2] = (byte)((lba & 0xFF000000) >> 24); diff --git a/Aaru.Devices/Device/ScsiCommands/Optical.cs b/Aaru.Devices/Device/ScsiCommands/Optical.cs index 7a737b0e4..13817d0d8 100644 --- a/Aaru.Devices/Device/ScsiCommands/Optical.cs +++ b/Aaru.Devices/Device/ScsiCommands/Optical.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; using Aaru.Decoders.SCSI; -namespace Aaru.Devices; - public sealed partial class Device { /// Scan the medium for a contiguous set of written or blank logical blocks @@ -63,7 +63,7 @@ public sealed partial class Device out uint foundBlocks, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; byte[] buffer = Array.Empty(); foundLba = 0; foundBlocks = 0; diff --git a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs index 880f9d9e3..e8608cefb 100644 --- a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs +++ b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Sends the Pioneer READ CD-DA command @@ -47,11 +47,10 @@ public sealed partial class Device /// Block size. /// Subchannel selection. public bool PioneerReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, - uint transferLength, PioneerSubchannel subchannel, uint timeout, - out double duration) + uint transferLength, PioneerSubchannel subchannel, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCdDa; cdb[2] = (byte)((lba & 0xFF000000) >> 24); @@ -89,7 +88,7 @@ public sealed partial class Device uint blockSize, PioneerSubchannel subchannel, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCdDaMsf; cdb[3] = (byte)((startMsf & 0xFF0000) >> 16); @@ -100,7 +99,7 @@ public sealed partial class Device cdb[9] = (byte)(endMsf & 0xFF); cdb[10] = (byte)subchannel; - uint transferLength = (uint)(((cdb[7] - cdb[3]) * 60 * 75) + ((cdb[8] - cdb[4]) * 75) + (cdb[9] - cdb[5])); + 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, @@ -130,7 +129,7 @@ public sealed partial class Device bool errorFlags, bool wholeSector, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCdXa; cdb[2] = (byte)((lba & 0xFF000000) >> 24); diff --git a/Aaru.Devices/Device/ScsiCommands/Plasmon.cs b/Aaru.Devices/Device/ScsiCommands/Plasmon.cs index 9eda6bad5..c6ff39d7a 100644 --- a/Aaru.Devices/Device/ScsiCommands/Plasmon.cs +++ b/Aaru.Devices/Device/ScsiCommands/Plasmon.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Sends the Plasmon READ LONG vendor command @@ -67,9 +67,9 @@ public sealed partial class Device /// 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, out duration); + 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 /// true if the command failed and contains the sense buffer. @@ -83,7 +83,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.PlasmonReadSectorLocation; cdb[2] = (byte)((address & 0xFF000000) >> 24); diff --git a/Aaru.Devices/Device/ScsiCommands/Plextor.cs b/Aaru.Devices/Device/ScsiCommands/Plextor.cs index c805146e2..4f35c2c26 100644 --- a/Aaru.Devices/Device/ScsiCommands/Plextor.cs +++ b/Aaru.Devices/Device/ScsiCommands/Plextor.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the Plextor READ CD-DA command @@ -48,11 +48,10 @@ public sealed partial class Device /// Block size. /// Subchannel selection. public bool PlextorReadCdDa(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, - uint transferLength, PlextorSubchannel subchannel, uint timeout, - out double duration) + uint transferLength, PlextorSubchannel subchannel, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.ReadCdDa; cdb[2] = (byte)((lba & 0xFF000000) >> 24); @@ -91,7 +90,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[2064 * transferLength]; cdb[0] = (byte)ScsiCommands.ReadBuffer; @@ -123,7 +122,7 @@ public sealed partial class Device { buffer = new byte[256]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 1; @@ -148,7 +147,7 @@ public sealed partial class Device { buffer = new byte[512]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[8] = 2; @@ -176,7 +175,7 @@ public sealed partial class Device { buffer = new byte[blockSize]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorReadEeprom; cdb[1] = 1; @@ -205,9 +204,9 @@ public sealed partial class Device public bool PlextorGetSpeeds(out byte[] senseBuffer, out ushort selected, out ushort max, out ushort last, uint timeout, out double duration) { - byte[] buf = new byte[10]; + var buf = new byte[10]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; selected = 0; max = 0; @@ -243,9 +242,9 @@ public sealed partial class Device public bool PlextorGetPoweRec(out byte[] senseBuffer, out bool enabled, out ushort speed, uint timeout, out double duration) { - byte[] buf = new byte[8]; + var buf = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; enabled = false; speed = 0; @@ -280,7 +279,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -308,7 +307,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -337,7 +336,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -369,7 +368,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[2] = (byte)PlextorSubCommands.SecuRec; @@ -395,7 +394,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -422,7 +421,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -451,7 +450,7 @@ public sealed partial class Device { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; @@ -479,12 +478,11 @@ public sealed partial class Device /// Sense buffer. /// Timeout. /// Duration. - public bool PlextorGetTestWriteDvdPlus(out byte[] buffer, out byte[] senseBuffer, uint timeout, - out double duration) + public bool PlextorGetTestWriteDvdPlus(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { buffer = new byte[8]; senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.PlextorExtend; cdb[1] = (byte)PlextorSubCommands.GetMode; diff --git a/Aaru.Devices/Device/ScsiCommands/SBC.cs b/Aaru.Devices/Device/ScsiCommands/SBC.cs index 840e8a671..2ee5d6fa4 100644 --- a/Aaru.Devices/Device/ScsiCommands/SBC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SBC.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the SBC READ (6) command @@ -62,7 +62,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; cdb[0] = (byte)ScsiCommands.Read6; cdb[1] = (byte)((lba & 0x1F0000) >> 16); @@ -107,11 +107,11 @@ public sealed partial class Device /// How many blocks to read. /// If set to true address is relative to current position. public bool Read10(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv, - bool relAddr, uint lba, uint blockSize, byte groupNumber, ushort transferLength, - uint timeout, out double duration) + bool relAddr, uint lba, uint blockSize, byte groupNumber, ushort transferLength, uint timeout, + out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.Read10; cdb[1] = (byte)((rdprotect & 0x07) << 5); @@ -171,11 +171,11 @@ public sealed partial class Device /// If set to true the stream playback operation should be used (MMC only). /// If set to true address is relative to current position. public bool Read12(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv, - bool relAddr, uint lba, uint blockSize, byte groupNumber, uint transferLength, - bool streaming, uint timeout, out double duration) + bool relAddr, uint lba, uint blockSize, byte groupNumber, uint transferLength, bool streaming, + uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; cdb[0] = (byte)ScsiCommands.Read12; cdb[1] = (byte)((rdprotect & 0x07) << 5); @@ -239,11 +239,11 @@ public sealed partial class Device /// How many blocks to read. /// If set to true the stream playback operation should be used (MMC only). public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte rdprotect, bool dpo, bool fua, bool fuaNv, - ulong lba, uint blockSize, byte groupNumber, uint transferLength, bool streaming, - uint timeout, out double duration) + ulong lba, uint blockSize, byte groupNumber, uint transferLength, bool streaming, uint timeout, + out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; byte[] lbaBytes = BitConverter.GetBytes(lba); cdb[0] = (byte)ScsiCommands.Read16; @@ -304,7 +304,7 @@ public sealed partial class Device ushort transferBytes, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.ReadLong; @@ -349,7 +349,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; byte[] lbaBytes = BitConverter.GetBytes(lba); cdb[0] = (byte)ScsiCommands.ServiceActionIn; @@ -388,7 +388,7 @@ public sealed partial class Device public bool Seek6(out byte[] senseBuffer, uint lba, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.Seek6; @@ -414,7 +414,7 @@ public sealed partial class Device public bool Seek10(out byte[] senseBuffer, uint lba, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.Seek10; diff --git a/Aaru.Devices/Device/ScsiCommands/SMC.cs b/Aaru.Devices/Device/ScsiCommands/SMC.cs index ba5e7b9f7..423aab663 100644 --- a/Aaru.Devices/Device/ScsiCommands/SMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SMC.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Console; - namespace Aaru.Devices; +using Aaru.Console; + public sealed partial class Device { /// Reads an attribute from the medium auxiliary memory, or reports which elements in the changer contain one @@ -53,7 +53,7 @@ public sealed partial class Device uint timeout, out double duration) { buffer = new byte[256]; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ReadAttribute; @@ -81,7 +81,7 @@ public sealed partial class Device if(sense) return true; - uint attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); + var attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[attrLen]; cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16); diff --git a/Aaru.Devices/Device/ScsiCommands/SPC.cs b/Aaru.Devices/Device/ScsiCommands/SPC.cs index ecbbd1f91..d9bc7ccd9 100644 --- a/Aaru.Devices/Device/ScsiCommands/SPC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SPC.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using System.Diagnostics.CodeAnalysis; using Aaru.Console; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; -namespace Aaru.Devices; - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public sealed partial class Device { @@ -87,7 +87,7 @@ public sealed partial class Device if(sense) return true; - byte pagesLength = (byte)(buffer[4] + 5); + var pagesLength = (byte)(buffer[4] + 5); cdb = new byte[] { @@ -168,7 +168,7 @@ public sealed partial class Device if(buffer[1] != page) return true; - byte pagesLength = (byte)(buffer[3] + 4); + var pagesLength = (byte)(buffer[3] + 4); cdb = new byte[] { @@ -221,8 +221,7 @@ public sealed partial class Device /// Timeout in seconds. /// Duration in milliseconds it took for the device to execute the command. public bool ModeSense(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => - ModeSense6(out buffer, out senseBuffer, false, ScsiModeSensePageControl.Current, 0, 0, timeout, - out duration); + ModeSense6(out buffer, out senseBuffer, false, ScsiModeSensePageControl.Current, 0, 0, timeout, out duration); /// Sends the SPC MODE SENSE(6) command to the device as introduced in SCSI-2 /// true if the command failed and contains the sense buffer. @@ -233,10 +232,9 @@ public sealed partial class Device /// If set to true device MUST not return any block descriptor. /// Page control. /// Page code. - public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd, - ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, - out double duration) => ModeSense6(out buffer, out senseBuffer, dbd, pageControl, - pageCode, 0, timeout, out duration); + public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd, ScsiModeSensePageControl pageControl, + byte pageCode, uint timeout, out double duration) => + ModeSense6(out buffer, out senseBuffer, dbd, pageControl, pageCode, 0, timeout, out duration); /// Sends the SPC MODE SENSE(6) command to the device as introduced in SCSI-3 SPC-3 /// true if the command failed and contains the sense buffer. @@ -248,12 +246,11 @@ public sealed partial class Device /// Page control. /// Page code. /// Sub-page code. - public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd, - ScsiModeSensePageControl pageControl, byte pageCode, byte subPageCode, uint timeout, - out double duration) + public bool ModeSense6(out byte[] buffer, out byte[] senseBuffer, bool dbd, ScsiModeSensePageControl pageControl, + byte pageCode, byte subPageCode, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; buffer = new byte[255]; cdb[0] = (byte)ScsiCommands.ModeSense; @@ -275,7 +272,7 @@ public sealed partial class Device if(sense) return true; - byte modeLength = (byte)(buffer[0] + 1); + var modeLength = (byte)(buffer[0] + 1); buffer = new byte[modeLength]; cdb[4] = (byte)buffer.Length; senseBuffer = new byte[64]; @@ -299,10 +296,9 @@ public sealed partial class Device /// If set to true device MUST not return any block descriptor. /// Page control. /// Page code. - public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd, - ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, - out double duration) => ModeSense10(out buffer, out senseBuffer, false, dbd, - pageControl, pageCode, 0, timeout, out duration); + public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool dbd, ScsiModeSensePageControl pageControl, + byte pageCode, uint timeout, out double duration) => + ModeSense10(out buffer, out senseBuffer, false, dbd, pageControl, pageCode, 0, timeout, out duration); /// Sends the SPC MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-2 /// true if the command failed and contains the sense buffer. @@ -315,9 +311,8 @@ public sealed partial class Device /// Page code. /// If set means 64-bit LBAs are accepted by the caller. public bool ModeSense10(out byte[] buffer, out byte[] senseBuffer, bool llbaa, bool dbd, - ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, - out double duration) => ModeSense10(out buffer, out senseBuffer, llbaa, dbd, - pageControl, pageCode, 0, timeout, out duration); + ScsiModeSensePageControl pageControl, byte pageCode, uint timeout, out double duration) => + ModeSense10(out buffer, out senseBuffer, llbaa, dbd, pageControl, pageCode, 0, timeout, out duration); /// Sends the SPC MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-3 /// true if the command failed and contains the sense buffer. @@ -335,7 +330,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[4096]; cdb[0] = (byte)ScsiCommands.ModeSense10; @@ -361,7 +356,7 @@ public sealed partial class Device if(sense) return true; - ushort modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); buffer = new byte[modeLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -399,12 +394,10 @@ public sealed partial class Device /// Timeout in seconds. /// Duration in milliseconds it took for the device to execute the command. /// true to prevent medium removal, false to allow it. - public bool SpcPreventAllowMediumRemoval(out byte[] senseBuffer, bool prevent, uint timeout, - out double duration) + public bool SpcPreventAllowMediumRemoval(out byte[] senseBuffer, bool prevent, uint timeout, out double duration) { if(prevent) - return SpcPreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Prevent, timeout, - out duration); + return SpcPreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Prevent, timeout, out duration); return SpcPreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Allow, timeout, out duration); } @@ -419,7 +412,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval; @@ -457,7 +450,7 @@ public sealed partial class Device uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; buffer = new byte[8]; cdb[0] = (byte)ScsiCommands.ReadCapacity; @@ -506,7 +499,7 @@ public sealed partial class Device out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; buffer = new byte[32]; cdb[0] = (byte)ScsiCommands.ServiceActionIn; @@ -550,7 +543,7 @@ public sealed partial class Device public bool ReadMediaSerialNumber(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[12]; + var cdb = new byte[12]; buffer = new byte[4]; cdb[0] = (byte)ScsiCommands.ReadSerialNumber; @@ -568,7 +561,7 @@ public sealed partial class Device if(sense) return true; - uint strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); + var strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[strctLength]; cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16); @@ -610,8 +603,7 @@ public sealed partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, ushort firstAttribute, bool cache, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, cache, timeout, - out duration); + ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, cache, timeout, out duration); /// Reads an attribute from the medium auxiliary memory /// Buffer. @@ -635,8 +627,7 @@ public sealed partial class Device /// Duration. public bool ReadAttribute(out byte[] buffer, out byte[] senseBuffer, ScsiAttributeAction action, ushort firstAttribute, uint timeout, out double duration) => - ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, false, timeout, - out duration); + ReadAttribute(out buffer, out senseBuffer, action, 0, 0, 0, 0, firstAttribute, false, timeout, out duration); /// Reads an attribute from the medium auxiliary memory /// Buffer. @@ -663,8 +654,7 @@ public sealed partial class Device /// Timeout. /// 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) => + byte partition, ushort firstAttribute, bool cache, uint timeout, out double duration) => ReadAttribute(out buffer, out senseBuffer, action, 0, 0, volume, partition, firstAttribute, cache, timeout, out duration); @@ -700,7 +690,7 @@ public sealed partial class Device return true; } - byte[] cdb = new byte[6]; + var cdb = new byte[6]; cdb[0] = (byte)ScsiCommands.ModeSelect; @@ -754,7 +744,7 @@ public sealed partial class Device return true; } - byte[] cdb = new byte[10]; + var cdb = new byte[10]; cdb[0] = (byte)ScsiCommands.ModeSelect10; @@ -793,7 +783,7 @@ public sealed partial class Device /// true if the command failed. public bool RequestSense(bool descriptor, out byte[] buffer, uint timeout, out double duration) { - byte[] cdb = new byte[6]; + var cdb = new byte[6]; buffer = new byte[252]; cdb[0] = (byte)ScsiCommands.RequestSense; @@ -806,8 +796,7 @@ public sealed partial class Device cdb[4] = (byte)buffer.Length; cdb[5] = 0; - LastError = SendScsiCommand(cdb, ref buffer, out _, timeout, ScsiDirection.In, out duration, - out bool sense); + LastError = SendScsiCommand(cdb, ref buffer, out _, timeout, ScsiDirection.In, out duration, out bool sense); Error = LastError != 0; diff --git a/Aaru.Devices/Device/ScsiCommands/SSC.cs b/Aaru.Devices/Device/ScsiCommands/SSC.cs index 8ef85d29f..e28b2a244 100644 --- a/Aaru.Devices/Device/ScsiCommands/SSC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SSC.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Prepares the medium for reading @@ -66,11 +66,11 @@ public sealed partial class Device /// /// Timeout. /// Duration. - public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape, - bool hold, uint timeout, out double duration) + public bool LoadUnload(out byte[] senseBuffer, bool immediate, bool load, bool retense, bool endOfTape, bool hold, + uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.LoadUnload; @@ -134,8 +134,8 @@ public sealed 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 duration); + out double duration) => Locate(out senseBuffer, immediate, false, false, partition, lba, timeout, + out duration); /// Positions the medium to the specified object identifier /// Sense buffer. @@ -150,7 +150,7 @@ public sealed partial class Device uint objectId, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.Locate; @@ -205,8 +205,7 @@ public sealed partial class Device /// Timeout. /// Duration. public bool Locate16(out byte[] senseBuffer, bool immediate, ulong lba, uint timeout, out double duration) => - Locate16(out senseBuffer, immediate, false, SscLogicalIdTypes.ObjectId, false, 0, lba, timeout, - out duration); + Locate16(out senseBuffer, immediate, false, SscLogicalIdTypes.ObjectId, false, 0, lba, timeout, out duration); /// Positions the medium to the specified block in the specified partition /// Sense buffer. @@ -216,9 +215,8 @@ public sealed 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. @@ -234,7 +232,7 @@ public sealed partial class Device bool bam, byte partition, ulong identifier, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; byte[] buffer = Array.Empty(); byte[] idBytes = BitConverter.GetBytes(identifier); @@ -294,8 +292,8 @@ public sealed partial class Device /// 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); + 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. @@ -316,7 +314,7 @@ public sealed partial class Device uint blockSize, uint timeout, out double duration) { buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.Read6; @@ -366,8 +364,7 @@ public sealed partial class Device /// Duration. public bool Read16(out byte[] buffer, out byte[] senseBuffer, bool sili, byte partition, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - Read16(out buffer, out senseBuffer, sili, false, partition, objectId, blocks, blockSize, timeout, - out duration); + Read16(out buffer, out senseBuffer, sili, false, partition, objectId, blocks, blockSize, timeout, out duration); /// Reads a number of fixed-length blocks starting at specified object /// Buffer. @@ -378,8 +375,8 @@ public sealed 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, out duration); + 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 /// Buffer. @@ -392,8 +389,7 @@ public sealed partial class Device /// Duration. public bool Read16(out byte[] buffer, out byte[] senseBuffer, byte partition, ulong objectId, uint blocks, uint blockSize, uint timeout, out double duration) => - Read16(out buffer, out senseBuffer, false, true, partition, objectId, blocks, blockSize, timeout, - out duration); + Read16(out buffer, out senseBuffer, false, true, partition, objectId, blocks, blockSize, timeout, out duration); /// Reads a number of bytes or objects starting at specified object from the specified partition /// Buffer. @@ -416,7 +412,7 @@ public sealed partial class Device ulong objectId, uint transferLen, uint objectSize, uint timeout, out double duration) { buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; byte[] idBytes = BitConverter.GetBytes(objectId); @@ -459,7 +455,7 @@ public sealed partial class Device public bool ReadBlockLimits(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) { buffer = new byte[6]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ReadBlockLimits; @@ -547,7 +543,7 @@ public sealed partial class Device break; } - byte[] cdb = new byte[10]; + var cdb = new byte[10]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ReadPosition; @@ -577,8 +573,8 @@ public sealed 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. @@ -590,8 +586,7 @@ public sealed partial class Device /// Duration. public bool ReadReverse6(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize, uint timeout, out double duration) => - ReadReverse6(out buffer, out senseBuffer, false, sili, false, transferLen, blockSize, timeout, - out duration); + ReadReverse6(out buffer, out senseBuffer, false, sili, false, transferLen, blockSize, timeout, out duration); /// Reads the specified number of bytes or of blocks from the medium, backwards /// Buffer. @@ -613,7 +608,7 @@ public sealed partial class Device uint transferLen, uint blockSize, uint timeout, out double duration) { buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ReadReverse; @@ -667,8 +662,8 @@ public sealed 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, out duration); + 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 /// Buffer. @@ -678,8 +673,8 @@ public sealed partial class Device /// Object size in bytes. /// Timeout. /// Duration. - public bool ReadReverse16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, - uint blockSize, uint timeout, out double 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, out duration); @@ -692,10 +687,10 @@ public sealed partial class Device /// Object size in bytes. /// Timeout. /// 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, out 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, + out duration); /// Reads a number of bytes or objects starting at specified object from the specified partition, backwards /// Buffer. @@ -720,7 +715,7 @@ public sealed partial class Device out double duration) { buffer = fixedLen ? new byte[objectSize * transferLen] : new byte[transferLen]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; byte[] idBytes = BitConverter.GetBytes(objectId); @@ -779,8 +774,7 @@ public sealed partial class Device /// Duration. public bool RecoverBufferedData(out byte[] buffer, out byte[] senseBuffer, bool sili, uint transferLen, uint blockSize, uint timeout, out double duration) => - RecoverBufferedData(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout, - out duration); + RecoverBufferedData(out buffer, out senseBuffer, sili, false, transferLen, blockSize, timeout, out duration); /// Reads the specified number of bytes or of blocks from the device's buffer /// Buffer. @@ -801,7 +795,7 @@ public sealed partial class Device uint transferLen, uint blockSize, uint timeout, out double duration) { buffer = fixedLen ? new byte[blockSize * transferLen] : new byte[transferLen]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.RecoverBufferedData; @@ -831,8 +825,7 @@ public sealed partial class Device /// Sense buffer. /// Timeout. /// Duration. - public bool - ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => + public bool ReportDensitySupport(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => ReportDensitySupport(out buffer, out senseBuffer, false, false, timeout, out duration); /// Requests the device to return descriptors for supported densities or medium types @@ -856,7 +849,7 @@ public sealed partial class Device uint timeout, out double duration) { buffer = new byte[256]; - byte[] cdb = new byte[10]; + var cdb = new byte[10]; senseBuffer = new byte[64]; cdb[0] = (byte)ScsiCommands.ReportDensitySupport; @@ -878,7 +871,7 @@ public sealed partial class Device if(sense) return true; - ushort availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); buffer = new byte[availableLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -909,7 +902,7 @@ public sealed partial class Device public bool Rewind(out byte[] senseBuffer, bool immediate, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.Rewind; @@ -936,7 +929,7 @@ public sealed partial class Device public bool TrackSelect(out byte[] senseBuffer, byte track, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); cdb[0] = (byte)ScsiCommands.TrackSelect; @@ -962,7 +955,7 @@ public sealed partial class Device public bool Space(out byte[] senseBuffer, SscSpaceCodes code, int count, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; + var cdb = new byte[6]; byte[] buffer = Array.Empty(); byte[] countB = BitConverter.GetBytes(count); diff --git a/Aaru.Devices/Device/ScsiCommands/SyQuest.cs b/Aaru.Devices/Device/ScsiCommands/SyQuest.cs index dfb4763ca..a074b8e18 100644 --- a/Aaru.Devices/Device/ScsiCommands/SyQuest.cs +++ b/Aaru.Devices/Device/ScsiCommands/SyQuest.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using System; using Aaru.Console; -namespace Aaru.Devices; - public sealed partial class Device { /// Sends the SyQuest READ (6) command @@ -46,8 +46,8 @@ public sealed 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. @@ -72,12 +72,12 @@ public sealed partial class Device /// If set to true drive will return ECC bytes and disable error detection. /// Block size in bytes. /// How many blocks to read. - public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, - byte transferLength, bool inhibitDma, bool readLong, uint timeout, out double duration) + public bool SyQuestRead6(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, byte transferLength, + bool inhibitDma, bool readLong, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[6]; - bool sense; + var cdb = new byte[6]; + bool sense; cdb[0] = (byte)ScsiCommands.Read6; cdb[1] = (byte)((lba & 0x1F0000) >> 16); @@ -121,8 +121,7 @@ public sealed partial class Device /// Sense buffer. /// Timeout. /// Duration. - public bool SyQuestReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, - out double duration) => + public bool SyQuestReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) => AdaptecReadUsageCounter(out buffer, out senseBuffer, false, timeout, out duration); /// Sends the SyQuest READ LONG (10) command @@ -149,12 +148,11 @@ public sealed partial class Device /// Block size in bytes. /// How many blocks to read. public bool SyQuestRead10(out byte[] buffer, out byte[] senseBuffer, uint lba, uint blockSize, - ushort transferLength, bool inhibitDma, bool readLong, uint timeout, - out double duration) + ushort transferLength, bool inhibitDma, bool readLong, uint timeout, out double duration) { senseBuffer = new byte[64]; - byte[] cdb = new byte[10]; - bool sense; + var cdb = new byte[10]; + bool sense; cdb[0] = (byte)ScsiCommands.Read10; cdb[2] = (byte)((lba & 0xFF000000) >> 24); diff --git a/Aaru.Devices/Device/Variables.cs b/Aaru.Devices/Device/Variables.cs index ce6462955..46cfbe115 100644 --- a/Aaru.Devices/Device/Variables.cs +++ b/Aaru.Devices/Device/Variables.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices; + using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Devices; - public sealed partial class Device { readonly ushort _usbVendor; diff --git a/Aaru.Devices/Enums.cs b/Aaru.Devices/Enums.cs index 4f4e38163..e91960161 100644 --- a/Aaru.Devices/Enums.cs +++ b/Aaru.Devices/Enums.cs @@ -30,9 +30,6 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.Diagnostics.CodeAnalysis; - #pragma warning disable 1591 // ReSharper disable UnusedType.Global @@ -43,6 +40,9 @@ using System.Diagnostics.CodeAnalysis; namespace Aaru.Devices; +using System; +using System.Diagnostics.CodeAnalysis; + #region ATA Commands /// All known ATA commands public enum AtaCommands : byte @@ -515,7 +515,6 @@ public enum AtaCommands : byte #endregion Commands defined on ATA/ATAPI Command Set 3 (ACS-3) rev. 6 } #endregion ATA Commands - #region ATA SMART SubCommands /// All known ATA SMART sub-commands public enum AtaSmartSubCommands : byte @@ -560,7 +559,6 @@ public enum AtaSmartSubCommands : byte #endregion Commands defined on ATA/ATAPI-5 rev. 3 } #endregion ATA SMART SubCommands - #region ATA Device Configuration Overlay SubCommands /// All known ATA DEVICE CONFIGURATION sub-commands public enum AtaDeviceConfigurationSubCommands : byte @@ -580,7 +578,6 @@ public enum AtaDeviceConfigurationSubCommands : byte #endregion Commands defined on ATA/ATAPI-6 rev. 3b } #endregion ATA Device Configuration Overlay SubCommands - #region ATA SET MAX SubCommands /// All known ATA SET MAX sub-commands public enum AtaSetMaxSubCommands : byte @@ -606,7 +603,6 @@ public enum AtaSetMaxSubCommands : byte #endregion Commands defined on ATA/ATAPI-6 rev. 3b } #endregion ATA SET MAX SubCommands - #region ATA Non Volatile Cache SubCommands /// All known ATA NV CACHE sub-commands public enum AtaNonVolatileCacheSubCommands : byte @@ -638,7 +634,6 @@ public enum AtaNonVolatileCacheSubCommands : byte #endregion Commands defined on ATA/ATAPI-8 rev. 3f } #endregion ATA Non Volatile Cache SubCommands - #region ATA Sanitize SubCommands /// All known ATA SANITIZE sub-commands public enum AtaSanitizeSubCommands : ushort @@ -666,7 +661,6 @@ public enum AtaSanitizeSubCommands : ushort #endregion Commands defined on ATA/ATAPI Command Set 3 (ACS-3) rev. 5 } #endregion ATA Sanitize SubCommands - #region ATA NCQ Queue Management SubCommands /// All known ATA NCQ QUEUE MANAGEMENT sub-commands public enum AtaNcqQueueManagementSubcommands : byte @@ -973,7 +967,6 @@ public enum SasiCommands : byte #endregion SASI Class 7 commands } #endregion SASI Commands - #region SCSI Commands /// All known SCSI and ATAPI commands public enum ScsiCommands : byte @@ -1663,8 +1656,11 @@ public enum ScsiCommands : byte #endregion ATA Command Pass-Through #region 6-byte CDB aliases - ModeSelect6 = ModeSelect, ModeSense6 = ModeSense, Read6 = Read, - Seek6 = Seek, Write6 = Write, + ModeSelect6 = ModeSelect, + ModeSense6 = ModeSense, + Read6 = Read, + Seek6 = Seek, + Write6 = Write, #endregion 6-byte CDB aliases #region SCSI Zoned Block Commands @@ -1676,10 +1672,18 @@ public enum ScsiCommands : byte #endregion #region SCSI Commands with unknown meaning, mostly vendor specific - SetCdSpeedUnk = 0xB8, WriteCdMsf = 0xA2, WriteCd = 0xAA, - ReadDefectTag = 0xB7, PlayCd = 0xBC, SpareIn = 0xBC, - SpareOut = 0xBD, WriteStream16 = 0x9A, WriteAtomic = 0x9C, - ServiceActionBidirectional = 0x9D, WriteLong2 = 0xEA, UnknownCdCommand = 0xD4, + SetCdSpeedUnk = 0xB8, + WriteCdMsf = 0xA2, + WriteCd = 0xAA, + ReadDefectTag = 0xB7, + PlayCd = 0xBC, + SpareIn = 0xBC, + SpareOut = 0xBD, + WriteStream16 = 0x9A, + WriteAtomic = 0x9C, + ServiceActionBidirectional = 0x9D, + WriteLong2 = 0xEA, + UnknownCdCommand = 0xD4, UnknownCdCommand2 = 0xD5, #endregion SCSI Commands with unknown meaning, mostly vendor specific @@ -2429,7 +2433,8 @@ public enum SscSpaceCodes : byte SequentialFilemark = 2, /// End-of-data - EndOfData = 3, Obsolete1 = 4, Obsolete2 = 5 + EndOfData = 3, Obsolete1 = 4, + Obsolete2 = 5 } /// MMC / SecureDigital commands @@ -2498,7 +2503,8 @@ public enum MmcCommands : byte GoInactiveState = 15, /// The host sends the bus testing data pattern to a device (ADTC, R1) - BusTestWrite = 19, SpiReadOcr = 58, SpicrcOnOff = 59, + BusTestWrite = 19, SpiReadOcr = 58, + SpicrcOnOff = 59, #endregion Class 1 MMC Commands (Basic and read-stream) #region Class 2 MMC Commands (Block-oriented read) @@ -2677,20 +2683,36 @@ public enum SecureDigitalCommands : byte [Flags, SuppressMessage("ReSharper", "ShiftExpressionZeroLeftOperand")] public enum MmcFlags : uint { - ResponsePresent = 1 << 0, Response136 = 1 << 1, ResponseCrc = 1 << 2, - ResponseBusy = 1 << 3, ResponseOpcode = 1 << 4, CommandMask = 3 << 5, - CommandAc = 0 << 5, CommandAdtc = 1 << 5, CommandBc = 2 << 5, - CommandBcr = 3 << 5, ResponseSpiS1 = 1 << 7, ResponseSpiS2 = 1 << 8, - ResponseSpiB4 = 1 << 9, ResponseSpiBusy = 1 << 10, ResponseNone = 0, + ResponsePresent = 1 << 0, + Response136 = 1 << 1, + ResponseCrc = 1 << 2, + ResponseBusy = 1 << 3, + ResponseOpcode = 1 << 4, + CommandMask = 3 << 5, + CommandAc = 0 << 5, + CommandAdtc = 1 << 5, + CommandBc = 2 << 5, + CommandBcr = 3 << 5, + ResponseSpiS1 = 1 << 7, + ResponseSpiS2 = 1 << 8, + ResponseSpiB4 = 1 << 9, + ResponseSpiBusy = 1 << 10, + ResponseNone = 0, ResponseR1 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR1B = ResponsePresent | ResponseCrc | ResponseOpcode | ResponseBusy, - ResponseR2 = ResponsePresent | Response136 | ResponseCrc, ResponseR3 = ResponsePresent, - ResponseR4 = ResponsePresent, ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode, + ResponseR2 = ResponsePresent | Response136 | ResponseCrc, + ResponseR3 = ResponsePresent, + ResponseR4 = ResponsePresent, + ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR6 = ResponsePresent | ResponseCrc | ResponseOpcode, - ResponseR7 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseSpiR1 = ResponseSpiS1, - ResponseSpiR1B = ResponseSpiS1 | ResponseSpiBusy, ResponseSpiR2 = ResponseSpiS1 | ResponseSpiS2, - ResponseSpiR3 = ResponseSpiS1 | ResponseSpiB4, ResponseSpiR4 = ResponseSpiS1 | ResponseSpiB4, - ResponseSpiR5 = ResponseSpiS1 | ResponseSpiS2, ResponseSpiR7 = ResponseSpiS1 | ResponseSpiB4 + ResponseR7 = ResponsePresent | ResponseCrc | ResponseOpcode, + ResponseSpiR1 = ResponseSpiS1, + ResponseSpiR1B = ResponseSpiS1 | ResponseSpiBusy, + ResponseSpiR2 = ResponseSpiS1 | ResponseSpiS2, + ResponseSpiR3 = ResponseSpiS1 | ResponseSpiB4, + ResponseSpiR4 = ResponseSpiS1 | ResponseSpiB4, + ResponseSpiR5 = ResponseSpiS1 | ResponseSpiS2, + ResponseSpiR7 = ResponseSpiS1 | ResponseSpiB4 } [Flags] @@ -2876,28 +2898,40 @@ public enum AtaFeatures : byte public enum KreonLockStates : byte { - Locked = 0, Xtreme = 1, Wxripper = 2 + Locked = 0, + Xtreme = 1, + Wxripper = 2 } public enum RotationalControl : byte { - ClvAndImpureCav = 0, PureCav = 1 + ClvAndImpureCav = 0, + PureCav = 1 } public enum TrackInformationType : byte { - LogicalBlockAddress = 0, LogicalTrackNumber = 1, SessionNumber = 2 + LogicalBlockAddress = 0, + LogicalTrackNumber = 1, + SessionNumber = 2 } public enum CssReportKeyFormat : byte { - AgidForCssCppm = 0x00, ChallengeKey = 0x01, Key1 = 0x02, - TitleKey = 0x04, Asf = 0x05, RpcState = 0x08, - AgidForCprm = 0x11, InvalidateAgid = 0x3f + AgidForCssCppm = 0x00, + ChallengeKey = 0x01, + Key1 = 0x02, + TitleKey = 0x04, + Asf = 0x05, + RpcState = 0x08, + AgidForCprm = 0x11, + InvalidateAgid = 0x3f } public enum CssSendKeyFormat : byte { - ChallengeKey = 0x01, Key2 = 0x03, RpcStructure = 0x06, + ChallengeKey = 0x01, + Key2 = 0x03, + RpcStructure = 0x06, InvalidateAgid = 0x3f } \ No newline at end of file diff --git a/Aaru.Devices/Linux/Command.cs b/Aaru.Devices/Linux/Command.cs index 50fca0ceb..c7259440b 100644 --- a/Aaru.Devices/Linux/Command.cs +++ b/Aaru.Devices/Linux/Command.cs @@ -31,15 +31,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Linux; + using System; using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes.Interop; using Aaru.Decoders.ATA; -namespace Aaru.Devices.Linux; - -internal static class Command +static class Command { /// Sends a SCSI command /// 0 if no error occurred, otherwise, errno @@ -139,9 +139,8 @@ internal static class Command /// Which register contains the transfer count /// Set to true if the transfer count is in blocks, otherwise it is in bytes internal static int SendAtaCommand(int fd, AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, - AtaProtocol protocol, AtaTransferRegister transferRegister, - ref byte[] buffer, uint timeout, bool transferBlocks, out double duration, - out bool sense) + AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, + uint timeout, bool transferBlocks, out double duration, out bool sense) { duration = 0; sense = false; @@ -150,7 +149,7 @@ internal static class Command if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)(((byte)protocol << 1) & 0x1E); @@ -190,7 +189,7 @@ internal static class Command AtaProtocolToScsiDirection(protocol), out duration, out sense); if(senseBuffer.Length < 22 || - (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) + senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -219,10 +218,9 @@ internal static class Command /// ATA protocol to use /// Which register contains the transfer count /// Set to true if the transfer count is in blocks, otherwise it is in bytes - internal static int SendAtaCommand(int fd, AtaRegistersLba28 registers, - out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol, - AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, - bool transferBlocks, out double duration, out bool sense) + internal static int SendAtaCommand(int fd, AtaRegistersLba28 registers, out AtaErrorRegistersLba28 errorRegisters, + AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, + uint timeout, bool transferBlocks, out double duration, out bool sense) { duration = 0; sense = false; @@ -231,7 +229,7 @@ internal static class Command if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)(((byte)protocol << 1) & 0x1E); @@ -271,7 +269,7 @@ internal static class Command AtaProtocolToScsiDirection(protocol), out duration, out sense); if(senseBuffer.Length < 22 || - (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) + senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -300,10 +298,9 @@ internal static class Command /// ATA protocol to use /// Which register contains the transfer count /// Set to true if the transfer count is in blocks, otherwise it is in bytes - internal static int SendAtaCommand(int fd, AtaRegistersLba48 registers, - out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol, - AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, - bool transferBlocks, out double duration, out bool sense) + internal static int SendAtaCommand(int fd, AtaRegistersLba48 registers, out AtaErrorRegistersLba48 errorRegisters, + AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, + uint timeout, bool transferBlocks, out double duration, out bool sense) { duration = 0; sense = false; @@ -312,7 +309,7 @@ internal static class Command if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)(((byte)protocol << 1) & 0x1E); cdb[1] |= 0x01; @@ -358,7 +355,7 @@ internal static class Command AtaProtocolToScsiDirection(protocol), out duration, out sense); if(senseBuffer.Length < 22 || - (senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)) + senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C) return error; errorRegisters.Error = senseBuffer[11]; @@ -455,17 +452,17 @@ internal static class Command int off; // Create array for buffers - IntPtr[] bufferPointers = new IntPtr[commands.Length]; + var bufferPointers = new IntPtr[commands.Length]; // Allocate memory for the array for commands - byte[] ioMultiCmd = new byte[sizeof(ulong) + (Marshal.SizeOf() * commands.Length)]; + var ioMultiCmd = new byte[sizeof(ulong) + Marshal.SizeOf() * commands.Length]; // First value of array is uint64 with count of commands Array.Copy(BitConverter.GetBytes((ulong)commands.Length), 0, ioMultiCmd, 0, sizeof(ulong)); off = sizeof(ulong); - for(int i = 0; i < commands.Length; i++) + for(var i = 0; i < commands.Length; i++) { // Create command var ioCmd = new MmcIocCmd(); @@ -525,9 +522,9 @@ internal static class Command Marshal.Copy(ioMultiCmdPtr, ioMultiCmd, 0, ioMultiCmd.Length); // TODO: Use real pointers this is too slow - for(int i = 0; i < commands.Length; i++) + for(var i = 0; i < commands.Length; i++) { - byte[] tmp = new byte[Marshal.SizeOf()]; + var tmp = new byte[Marshal.SizeOf()]; // Copy command to managed space Array.Copy(ioMultiCmd, off, tmp, 0, tmp.Length); @@ -604,7 +601,7 @@ internal static class Command resultSize = result; } - byte[] resultString = new byte[resultSize]; + var resultString = new byte[resultSize]; Marshal.Copy(buf, resultString, 0, resultSize); Marshal.FreeHGlobal(buf); diff --git a/Aaru.Devices/Linux/Enums.cs b/Aaru.Devices/Linux/Enums.cs index 2d71df4f3..4d87c0156 100644 --- a/Aaru.Devices/Linux/Enums.cs +++ b/Aaru.Devices/Linux/Enums.cs @@ -31,12 +31,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.Devices.Linux; +using System; + [Flags] -internal enum FileFlags +enum FileFlags { /// O_RDONLY Readonly = 0x0, @@ -75,7 +75,7 @@ internal enum FileFlags } /// Direction of SCSI transfer -internal enum ScsiIoctlDirection +enum ScsiIoctlDirection { /// No data transfer happens SG_DXFER_NONE None = -1, @@ -89,17 +89,19 @@ internal enum ScsiIoctlDirection Unknown = -5 } -internal enum LinuxIoctl : uint +enum LinuxIoctl : uint { // SCSI IOCtls - SgGetVersionNum = 0x2282, SgIo = 0x2285, + SgGetVersionNum = 0x2282, + SgIo = 0x2285, // MMC IOCtl - MmcIocCmd = 0xC048B300, MmcIocMultiCmd = 0xC008B301 + MmcIocCmd = 0xC048B300, + MmcIocMultiCmd = 0xC008B301 } [Flags] -internal enum SgInfo : uint +enum SgInfo : uint { /// Mask to check OK OkMask = 0x01, @@ -119,14 +121,21 @@ internal enum SgInfo : uint } [Flags] -internal enum SgFlags : uint +enum SgFlags : uint { - DirectIo = 1, UnusedLunInhibit = 2, MmapIo = 4, - NoDxfer = 0x10000, QAtTail = 0x10, QAtHead = 0x20 + DirectIo = 1, + UnusedLunInhibit = 2, + MmapIo = 4, + NoDxfer = 0x10000, + QAtTail = 0x10, + QAtHead = 0x20 } -internal enum SeekWhence +enum SeekWhence { - Begin = 0, Current = 1, End = 2, - Data = 3, Hole = 4 + Begin = 0, + Current = 1, + End = 2, + Data = 3, + Hole = 4 } \ No newline at end of file diff --git a/Aaru.Devices/Linux/Extern.cs b/Aaru.Devices/Linux/Extern.cs index 6ab3994e4..ceb261b74 100644 --- a/Aaru.Devices/Linux/Extern.cs +++ b/Aaru.Devices/Linux/Extern.cs @@ -31,12 +31,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Linux; + using System; using System.Runtime.InteropServices; -namespace Aaru.Devices.Linux; - -internal static class Extern +static class Extern { [DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)] internal static extern int open(string pathname, [MarshalAs(UnmanagedType.U4)] FileFlags flags); @@ -63,8 +63,7 @@ internal static class Extern internal static extern IntPtr udev_new(); [DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)] - internal static extern IntPtr udev_device_new_from_subsystem_sysname( - IntPtr udev, string subsystem, string sysname); + internal static extern IntPtr udev_device_new_from_subsystem_sysname(IntPtr udev, string subsystem, string sysname); [DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)] internal static extern string udev_device_get_property_value(IntPtr udevDevice, string key); diff --git a/Aaru.Devices/Linux/ListDevices.cs b/Aaru.Devices/Linux/ListDevices.cs index 9dc914174..466ff6aa8 100644 --- a/Aaru.Devices/Linux/ListDevices.cs +++ b/Aaru.Devices/Linux/ListDevices.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Linux; + using System; using System.IO; using System.Text; -namespace Aaru.Devices.Linux; - -internal static class ListDevices +static class ListDevices { const string PATH_SYS_DEVBLOCK = "/sys/block/"; @@ -46,8 +46,8 @@ internal static class ListDevices { string[] sysdevs = Directory.GetFileSystemEntries(PATH_SYS_DEVBLOCK, "*", SearchOption.TopDirectoryOnly); - DeviceInfo[] devices = new DeviceInfo[sysdevs.Length]; - bool hasUdev; + var devices = new DeviceInfo[sysdevs.Length]; + bool hasUdev; IntPtr udev = IntPtr.Zero; @@ -61,7 +61,7 @@ internal static class ListDevices hasUdev = false; } - for(int i = 0; i < sysdevs.Length; i++) + for(var i = 0; i < sysdevs.Length; i++) { devices[i] = new DeviceInfo { diff --git a/Aaru.Devices/Linux/Structs.cs b/Aaru.Devices/Linux/Structs.cs index 8a533e088..63314f9ab 100644 --- a/Aaru.Devices/Linux/Structs.cs +++ b/Aaru.Devices/Linux/Structs.cs @@ -31,14 +31,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Linux; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Devices.Linux; - [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct SgIoHdrT +struct SgIoHdrT { /// Always 'S' for SG v3 public int interface_id; /* [i] 'S' (required) */ @@ -66,7 +66,7 @@ internal struct SgIoHdrT } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct MmcIocCmd +struct MmcIocCmd { /// Implies direction of data. true = write, false = read public bool write_flag; diff --git a/Aaru.Devices/Remote/Enums.cs b/Aaru.Devices/Remote/Enums.cs index 26442ce56..3640c9e96 100644 --- a/Aaru.Devices/Remote/Enums.cs +++ b/Aaru.Devices/Remote/Enums.cs @@ -36,17 +36,39 @@ namespace Aaru.Devices.Remote; public enum AaruPacketType : sbyte { #pragma warning disable 1591 - Nop = -1, Hello = 1, CommandListDevices = 2, - ResponseListDevices = 3, CommandOpen = 4, CommandScsi = 5, - ResponseScsi = 6, CommandAtaChs = 7, ResponseAtaChs = 8, - CommandAtaLba28 = 9, ResponseAtaLba28 = 10, CommandAtaLba48 = 11, - ResponseAtaLba48 = 12, CommandSdhci = 13, ResponseSdhci = 14, - CommandGetType = 15, ResponseGetType = 16, CommandGetSdhciRegisters = 17, - ResponseGetSdhciRegisters = 18, CommandGetUsbData = 19, ResponseGetUsbData = 20, - CommandGetFireWireData = 21, ResponseGetFireWireData = 22, CommandGetPcmciaData = 23, - ResponseGetPcmciaData = 24, CommandCloseDevice = 25, CommandAmIRoot = 26, - ResponseAmIRoot = 27, MultiCommandSdhci = 28, ResponseMultiSdhci = 29, - CommandReOpenDevice = 30, CommandOsRead = 31, ResponseOsRead = 32 + Nop = -1, + Hello = 1, + CommandListDevices = 2, + ResponseListDevices = 3, + CommandOpen = 4, + CommandScsi = 5, + ResponseScsi = 6, + CommandAtaChs = 7, + ResponseAtaChs = 8, + CommandAtaLba28 = 9, + ResponseAtaLba28 = 10, + CommandAtaLba48 = 11, + ResponseAtaLba48 = 12, + CommandSdhci = 13, + ResponseSdhci = 14, + CommandGetType = 15, + ResponseGetType = 16, + CommandGetSdhciRegisters = 17, + ResponseGetSdhciRegisters = 18, + CommandGetUsbData = 19, + ResponseGetUsbData = 20, + CommandGetFireWireData = 21, + ResponseGetFireWireData = 22, + CommandGetPcmciaData = 23, + ResponseGetPcmciaData = 24, + CommandCloseDevice = 25, + CommandAmIRoot = 26, + ResponseAmIRoot = 27, + MultiCommandSdhci = 28, + ResponseMultiSdhci = 29, + CommandReOpenDevice = 30, + CommandOsRead = 31, + ResponseOsRead = 32 #pragma warning restore 1591 } diff --git a/Aaru.Devices/Remote/Remote.cs b/Aaru.Devices/Remote/Remote.cs index 6a2ba86a3..2736e3c24 100644 --- a/Aaru.Devices/Remote/Remote.cs +++ b/Aaru.Devices/Remote/Remote.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable MemberCanBeInternal + +namespace Aaru.Devices.Remote; + using System; using System.Collections.Generic; using System.IO; @@ -44,10 +50,6 @@ using Aaru.Decoders.ATA; using Marshal = Aaru.Helpers.Marshal; using Version = Aaru.CommonTypes.Interop.Version; -// ReSharper disable MemberCanBeInternal - -namespace Aaru.Devices.Remote; - /// /// Handles communication with a remote device that's connected using the AaruRemote protocol public class Remote : IDisposable @@ -89,7 +91,7 @@ public class Remote : IDisposable AaruConsole.WriteLine("Connected to {0}", uri.Host); - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; int len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -235,7 +237,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -324,7 +326,7 @@ public class Remote : IDisposable return Array.Empty(); } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -392,9 +394,9 @@ public class Remote : IDisposable AaruPacketResponseListDevices response = Marshal.ByteArrayToStructureLittleEndian(buf); - List devices = new List(); - int offset = Marshal.SizeOf(); - int devInfoLen = Marshal.SizeOf(); + var devices = new List(); + int offset = Marshal.SizeOf(); + int devInfoLen = Marshal.SizeOf(); for(ushort i = 0; i < response.devices; i++) { @@ -444,7 +446,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -469,8 +471,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.Nop) { - AaruConsole.ErrorWriteLine("Expected List Devices Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected List Devices Response Packet, got packet type {0}...", hdr.packetType); lastError = -1; @@ -543,7 +544,7 @@ public class Remote : IDisposable cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.cdb_len + cmdPkt.buf_len); byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt); - byte[] buf = new byte[cmdPkt.hdr.len]; + var buf = new byte[cmdPkt.hdr.len]; Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); @@ -562,7 +563,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -626,9 +627,9 @@ public class Remote : IDisposable /// /// Time it took to execute the command in milliseconds /// True if ATA/ATAPI command returned non-OK status - public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, - AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer, - uint timeout, bool transferBlocks, out double duration, out bool sense) + public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol, + AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout, + bool transferBlocks, out double duration, out bool sense) { duration = 0; sense = true; @@ -656,7 +657,7 @@ public class Remote : IDisposable cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt); - byte[] buf = new byte[cmdPkt.hdr.len]; + var buf = new byte[cmdPkt.hdr.len]; Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); @@ -672,7 +673,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -765,7 +766,7 @@ public class Remote : IDisposable cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt); - byte[] buf = new byte[cmdPkt.hdr.len]; + var buf = new byte[cmdPkt.hdr.len]; Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); @@ -781,7 +782,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -804,8 +805,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAtaLba28) { - AaruConsole.ErrorWriteLine("Expected ATA LBA28 Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected ATA LBA28 Response Packet, got packet type {0}...", hdr.packetType); return -1; } @@ -875,7 +875,7 @@ public class Remote : IDisposable cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.buf_len); byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt); - byte[] buf = new byte[cmdPkt.hdr.len]; + var buf = new byte[cmdPkt.hdr.len]; Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); @@ -891,7 +891,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -914,8 +914,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseAtaLba48) { - AaruConsole.ErrorWriteLine("Expected ATA LBA48 Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected ATA LBA48 Response Packet, got packet type {0}...", hdr.packetType); return -1; } @@ -956,8 +955,8 @@ public class Remote : IDisposable /// Response registers /// Size of block in bytes public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags, uint argument, - uint blockSize, uint blocks, ref byte[] buffer, out uint[] response, - out double duration, out bool sense, uint timeout = 0) + uint blockSize, uint blocks, ref byte[] buffer, out uint[] response, out double duration, + out bool sense, uint timeout = 0) { duration = 0; sense = true; @@ -991,7 +990,7 @@ public class Remote : IDisposable cmdPkt.hdr.len = (uint)(Marshal.SizeOf() + cmdPkt.command.buf_len); byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt); - byte[] buf = new byte[cmdPkt.hdr.len]; + var buf = new byte[cmdPkt.hdr.len]; Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf()); @@ -1007,7 +1006,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1089,7 +1088,7 @@ public class Remote : IDisposable return DeviceType.Unknown; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1112,8 +1111,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetType) { - AaruConsole.ErrorWriteLine("Expected Device Type Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected Device Type Response Packet, got packet type {0}...", hdr.packetType); return DeviceType.Unknown; } @@ -1169,7 +1167,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1192,8 +1190,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetSdhciRegisters) { - AaruConsole.ErrorWriteLine("Expected Device Type Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected Device Type Response Packet, got packet type {0}...", hdr.packetType); return false; } @@ -1262,8 +1259,8 @@ public class Remote : IDisposable /// USB product string /// USB serial number string /// true if the device is attached via USB, false otherwise - public bool GetUsbData(out byte[] descriptors, out ushort idVendor, out ushort idProduct, - out string manufacturer, out string product, out string serial) + public bool GetUsbData(out byte[] descriptors, out ushort idVendor, out ushort idProduct, out string manufacturer, + out string product, out string serial) { descriptors = null; idVendor = 0; @@ -1295,7 +1292,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1388,7 +1385,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1427,8 +1424,7 @@ public class Remote : IDisposable return false; } - AaruPacketResGetFireWireData res = - Marshal.ByteArrayToStructureLittleEndian(buf); + AaruPacketResGetFireWireData res = Marshal.ByteArrayToStructureLittleEndian(buf); if(!res.isFireWire) return false; @@ -1472,7 +1468,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1495,8 +1491,7 @@ public class Remote : IDisposable if(hdr.packetType != AaruPacketType.ResponseGetPcmciaData) { - AaruConsole.ErrorWriteLine("Expected PCMCIA Data Response Packet, got packet type {0}...", - hdr.packetType); + AaruConsole.ErrorWriteLine("Expected PCMCIA Data Response Packet, got packet type {0}...", hdr.packetType); return false; } @@ -1529,7 +1524,7 @@ public class Remote : IDisposable /// Retrieved number of bytes static int Receive(Socket socket, byte[] buffer, int size, SocketFlags socketFlags) { - int offset = 0; + var offset = 0; while(size > 0) { @@ -1591,7 +1586,7 @@ public class Remote : IDisposable duration = 0; long packetSize = Marshal.SizeOf() + - (Marshal.SizeOf() * commands.LongLength); + Marshal.SizeOf() * commands.LongLength; foreach(Device.MmcSingleCommand command in commands) packetSize += command.buffer?.Length ?? 0; @@ -1609,7 +1604,7 @@ public class Remote : IDisposable } }; - byte[] buf = new byte[packetSize]; + var buf = new byte[packetSize]; byte[] tmp = Marshal.StructureToByteArrayLittleEndian(packet); Array.Copy(tmp, 0, buf, 0, tmp.Length); @@ -1651,7 +1646,7 @@ public class Remote : IDisposable return -1; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1702,7 +1697,7 @@ public class Remote : IDisposable off = Marshal.SizeOf(); - int error = 0; + var error = 0; foreach(Device.MmcSingleCommand command in commands) { @@ -1743,12 +1738,11 @@ public class Remote : IDisposable /// Set to true if any of the commands returned an error status, false otherwise /// Maximum allowed time to execute a single command /// 0 if no error occurred, otherwise, errno - int SendMultipleMmcCommandsV1(Device.MmcSingleCommand[] commands, out double duration, out bool sense, - uint timeout) + int SendMultipleMmcCommandsV1(Device.MmcSingleCommand[] commands, out double duration, out bool sense, uint timeout) { sense = false; duration = 0; - int error = 0; + var error = 0; foreach(Device.MmcSingleCommand command in commands) { @@ -1795,7 +1789,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); @@ -1898,7 +1892,7 @@ public class Remote : IDisposable return false; } - byte[] hdrBuf = new byte[Marshal.SizeOf()]; + var hdrBuf = new byte[Marshal.SizeOf()]; len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek); diff --git a/Aaru.Devices/Remote/Structs.cs b/Aaru.Devices/Remote/Structs.cs index 249d19a48..4a855c0fa 100644 --- a/Aaru.Devices/Remote/Structs.cs +++ b/Aaru.Devices/Remote/Structs.cs @@ -30,9 +30,7 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; -using Aaru.CommonTypes.Enums; -using Aaru.Decoders.ATA; + // ReSharper disable MemberCanBeInternal // ReSharper disable MemberCanBePrivate.Global @@ -41,6 +39,10 @@ using Aaru.Decoders.ATA; namespace Aaru.Devices.Remote; +using System.Runtime.InteropServices; +using Aaru.CommonTypes.Enums; +using Aaru.Decoders.ATA; + /// Header for any Aaru remote packet [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct AaruPacketHeader diff --git a/Aaru.Devices/Windows/Command.cs b/Aaru.Devices/Windows/Command.cs index 8ffe796b0..5a6711b3f 100644 --- a/Aaru.Devices/Windows/Command.cs +++ b/Aaru.Devices/Windows/Command.cs @@ -31,16 +31,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using Aaru.Decoders.ATA; using Microsoft.Win32.SafeHandles; -namespace Aaru.Devices.Windows; - [SuppressMessage("ReSharper", "UnusedParameter.Global")] -internal static class Command +static class Command { /// Sends a SCSI command /// 0 if no error occurred, otherwise, errno @@ -56,8 +56,7 @@ internal static class Command /// sense /// internal static int SendScsiCommand(SafeFileHandle fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, - uint timeout, ScsiIoctlDirection direction, out double duration, - out bool sense) + uint timeout, ScsiIoctlDirection direction, out double duration, out bool sense) { senseBuffer = null; duration = 0; @@ -86,7 +85,7 @@ internal static class Command Array.Copy(cdb, sptdSb.sptd.Cdb, cdb.Length); uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, sptdSb.sptd.DataBuffer, buffer.Length); @@ -126,8 +125,8 @@ internal static class Command /// Registers returned by drive /// ATA protocol to use internal static int SendAtaCommand(SafeFileHandle fd, AtaRegistersChs registers, - out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol, - ref byte[] buffer, uint timeout, out double duration, out bool sense) + out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol, ref byte[] buffer, + uint timeout, out double duration, out bool sense) { duration = 0; sense = false; @@ -186,7 +185,7 @@ internal static class Command aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -291,7 +290,7 @@ internal static class Command aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -405,7 +404,7 @@ internal static class Command aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -475,9 +474,8 @@ internal static class Command /// Response registers /// Size of block in bytes internal static int SendMmcCommand(SafeFileHandle fd, MmcCommands command, bool write, bool isApplication, - MmcFlags flags, uint argument, uint blockSize, uint blocks, - ref byte[] buffer, out uint[] response, out double duration, out bool sense, - uint timeout = 0) + MmcFlags flags, uint argument, uint blockSize, uint blocks, ref byte[] buffer, + out uint[] response, out double duration, out bool sense, uint timeout = 0) { var commandData = new SffdiskDeviceCommandData(); var commandDescriptor = new SdCmdDescriptor(); @@ -489,10 +487,10 @@ internal static class Command commandDescriptor.cmdClass = isApplication ? SdCommandClass.AppCmd : SdCommandClass.Standard; commandDescriptor.transferDirection = write ? SdTransferDirection.Write : SdTransferDirection.Read; - commandDescriptor.transferType = flags.HasFlag(MmcFlags.CommandAdtc) - ? command == MmcCommands.ReadMultipleBlock - ? SdTransferType.MultiBlock - : SdTransferType.SingleBlock : SdTransferType.CmdOnly; + commandDescriptor.transferType = flags.HasFlag(MmcFlags.CommandAdtc) ? command == MmcCommands.ReadMultipleBlock + ? SdTransferType.MultiBlock + : SdTransferType.SingleBlock + : SdTransferType.CmdOnly; commandDescriptor.responseType = 0; @@ -523,8 +521,7 @@ internal static class Command if(flags.HasFlag(MmcFlags.ResponseR6)) commandDescriptor.responseType = SdResponseType.R6; - byte[] commandB = new byte[commandData.size + commandData.protocolArgumentSize + - commandData.deviceDataBufferSize]; + var commandB = new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize]; Array.Copy(buffer, 0, commandB, commandData.size + commandData.protocolArgumentSize, buffer.Length); IntPtr hBuf = Marshal.AllocHGlobal(commandB.Length); @@ -534,7 +531,7 @@ internal static class Command Marshal.Copy(hBuf, commandB, 0, commandB.Length); Marshal.FreeHGlobal(hBuf); - int error = 0; + var error = 0; DateTime start = DateTime.Now; sense = !Extern.DeviceIoControl(fd, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB, (uint)commandB.Length, @@ -557,7 +554,7 @@ internal static class Command internal static int SendMultipleMmcCommands(SafeFileHandle fd, Device.MmcSingleCommand[] commands, out double duration, out bool sense, uint timeout = 0) { - int error = 0; + var error = 0; duration = 0; sense = false; @@ -566,16 +563,14 @@ internal static class Command commands[1].command == MmcCommands.ReadMultipleBlock && commands[2].command == MmcCommands.StopTransmission) return SendMmcCommand(fd, 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); + 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(Device.MmcSingleCommand command in commands) { - int singleError = SendMmcCommand(fd, 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(fd, 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) diff --git a/Aaru.Devices/Windows/Enums.cs b/Aaru.Devices/Windows/Enums.cs index e57f59d77..afe1e79a6 100644 --- a/Aaru.Devices/Windows/Enums.cs +++ b/Aaru.Devices/Windows/Enums.cs @@ -31,15 +31,17 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.Diagnostics.CodeAnalysis; + // ReSharper disable UnusedMember.Global namespace Aaru.Devices.Windows; +using System; +using System.Diagnostics.CodeAnalysis; + [Flags] -internal enum FileAttributes : uint +enum FileAttributes : uint { /// FILE_ATTRIBUTE_ARCHIVE Archive = 0x20, @@ -127,7 +129,7 @@ internal enum FileAttributes : uint } [Flags] -internal enum FileAccess : uint +enum FileAccess : uint { /// FILE_READ_DATA ReadData = 0x0001, @@ -185,7 +187,7 @@ internal enum FileAccess : uint } [Flags] -internal enum FileShare : uint +enum FileShare : uint { /// FILE_SHARE_NONE None = 0x00, @@ -201,7 +203,7 @@ internal enum FileShare : uint } [Flags] -internal enum FileMode : uint +enum FileMode : uint { /// NEW New = 0x01, @@ -220,7 +222,7 @@ internal enum FileMode : uint } /// Direction of SCSI transfer -internal enum ScsiIoctlDirection : byte +enum ScsiIoctlDirection : byte { /// From host to device SCSI_IOCTL_DATA_OUT Out = 0, @@ -232,9 +234,10 @@ internal enum ScsiIoctlDirection : byte Unspecified = 2 } -internal enum WindowsIoctl : uint +enum WindowsIoctl : uint { - IoctlAtaPassThrough = 0x4D02C, IoctlAtaPassThroughDirect = 0x4D030, + IoctlAtaPassThrough = 0x4D02C, + IoctlAtaPassThroughDirect = 0x4D030, /// ScsiPassThrough IoctlScsiPassThrough = 0x4D004, @@ -243,13 +246,15 @@ internal enum WindowsIoctl : uint IoctlScsiPassThroughDirect = 0x4D014, /// ScsiGetAddress - IoctlScsiGetAddress = 0x41018, IoctlStorageQueryProperty = 0x2D1400, IoctlIdePassThrough = 0x4D028, - IoctlStorageGetDeviceNumber = 0x2D1080, IoctlSffdiskQueryDeviceProtocol = 0x71E80, + IoctlScsiGetAddress = 0x41018, IoctlStorageQueryProperty = 0x2D1400, + IoctlIdePassThrough = 0x4D028, + IoctlStorageGetDeviceNumber = 0x2D1080, + IoctlSffdiskQueryDeviceProtocol = 0x71E80, IoctlSffdiskDeviceCommand = 0x79E84 } [Flags] -internal enum AtaFlags : ushort +enum AtaFlags : ushort { /// ATA_FLAGS_DRDY_REQUIRED DrdyRequired = 0x01, @@ -270,36 +275,62 @@ internal enum AtaFlags : ushort NoMultiple = 0x20 } -internal enum StoragePropertyId +enum StoragePropertyId { - Device = 0, Adapter = 1, Id = 2, - UniqueId = 3, WriteCache = 4, Miniport = 5, - AccessAlignment = 6, SeekPenalty = 7, Trim = 8, - WriteAggregation = 9, Telemetry = 10, LbProvisioning = 11, - Power = 12, Copyoffload = 13, Resiliency = 14 + Device = 0, + Adapter = 1, + Id = 2, + UniqueId = 3, + WriteCache = 4, + Miniport = 5, + AccessAlignment = 6, + SeekPenalty = 7, + Trim = 8, + WriteAggregation = 9, + Telemetry = 10, + LbProvisioning = 11, + Power = 12, + Copyoffload = 13, + Resiliency = 14 } -internal enum StorageQueryType +enum StorageQueryType { - Standard = 0, Exists = 1, Mask = 2, + Standard = 0, + Exists = 1, + Mask = 2, Max = 3 } [SuppressMessage("ReSharper", "InconsistentNaming")] -internal enum StorageBusType +enum StorageBusType { - Unknown = 0, SCSI = 1, ATAPI = 2, - ATA = 3, FireWire = 4, SSA = 5, - Fibre = 6, USB = 7, RAID = 8, - iSCSI = 9, SAS = 0xA, SATA = 0xB, - SecureDigital = 0xC, MultiMediaCard = 0xD, Virtual = 0xE, - FileBackedVirtual = 0xF, Spaces = 16, SCM = 18, - UFS = 19, Max = 20, MaxReserved = 127, + Unknown = 0, + SCSI = 1, + ATAPI = 2, + ATA = 3, + FireWire = 4, + SSA = 5, + Fibre = 6, + USB = 7, + RAID = 8, + iSCSI = 9, + SAS = 0xA, + SATA = 0xB, + SecureDigital = 0xC, + MultiMediaCard = 0xD, + Virtual = 0xE, + FileBackedVirtual = 0xF, + Spaces = 16, + SCM = 18, + UFS = 19, + Max = 20, + MaxReserved = 127, NVMe = 0x11 } [Flags] -internal enum DeviceGetClassFlags : uint +enum DeviceGetClassFlags : uint { /// DIGCF_DEFAULT Default = 0x01, @@ -317,47 +348,63 @@ internal enum DeviceGetClassFlags : uint DeviceInterface = 0x10 } -internal enum SdCommandClass : uint +enum SdCommandClass : uint { - Standard, AppCmd + Standard, + AppCmd } -internal enum SdTransferDirection : uint +enum SdTransferDirection : uint { - Unspecified, Read, Write + Unspecified, + Read, + Write } -internal enum SdTransferType : uint +enum SdTransferType : uint { - Unspecified, CmdOnly, SingleBlock, - MultiBlock, MultiBlockNoCmd12 + Unspecified, + CmdOnly, + SingleBlock, + MultiBlock, + MultiBlockNoCmd12 } [SuppressMessage("ReSharper", "InconsistentNaming")] -internal enum SdResponseType : uint +enum SdResponseType : uint { - Unspecified, None, R1, - R1b, R2, R3, - R4, R5, R5b, + Unspecified, + None, + R1, + R1b, + R2, + R3, + R4, + R5, + R5b, R6 } -internal enum SffdiskDcmd : uint +enum SffdiskDcmd : uint { - GetVersion, LockChannel, UnlockChannel, + GetVersion, + LockChannel, + UnlockChannel, DeviceCommand } -internal static class Consts +static class Consts { - public static Guid GuidSffProtocolSd = new Guid("AD7536A8-D055-4C40-AA4D-96312DDB6B38"); - public static Guid GuidSffProtocolMmc = new Guid("77274D3F-2365-4491-A030-8BB44AE60097"); + public static Guid GuidSffProtocolSd = new("AD7536A8-D055-4C40-AA4D-96312DDB6B38"); + public static Guid GuidSffProtocolMmc = new("77274D3F-2365-4491-A030-8BB44AE60097"); public static Guid GuidDevinterfaceDisk = - new Guid(0x53F56307, 0xB6BF, 0x11D0, 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B); + new(0x53F56307, 0xB6BF, 0x11D0, 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B); } -internal enum MoveMethod : uint +enum MoveMethod : uint { - Begin = 0, Current = 1, End = 2 + Begin = 0, + Current = 1, + End = 2 } \ No newline at end of file diff --git a/Aaru.Devices/Windows/Extern.cs b/Aaru.Devices/Windows/Extern.cs index 4bdcb5975..b42de11b6 100644 --- a/Aaru.Devices/Windows/Extern.cs +++ b/Aaru.Devices/Windows/Extern.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; -namespace Aaru.Devices.Windows; - -internal static class Extern +static class Extern { [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern SafeFileHandle CreateFile([MarshalAs(UnmanagedType.LPTStr)] string filename, @@ -45,16 +45,15 @@ internal static class Extern [MarshalAs(UnmanagedType.U4)] FileShare share, IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero [MarshalAs(UnmanagedType.U4)] FileMode creationDisposition, - [MarshalAs(UnmanagedType.U4)] - FileAttributes flagsAndAttributes, IntPtr templateFile); + [MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes, + IntPtr templateFile); [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)] internal static extern bool DeviceIoControlScsi(SafeFileHandle hDevice, WindowsIoctl ioControlCode, ref ScsiPassThroughDirectAndSenseBuffer inBuffer, uint nInBufferSize, ref ScsiPassThroughDirectAndSenseBuffer outBuffer, - uint nOutBufferSize, ref uint pBytesReturned, - IntPtr overlapped); + uint nOutBufferSize, ref uint pBytesReturned, IntPtr overlapped); [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)] internal static extern bool DeviceIoControlAta(SafeFileHandle hDevice, WindowsIoctl ioControlCode, @@ -77,9 +76,8 @@ internal static class Extern [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)] internal static extern bool DeviceIoControlGetDeviceNumber(SafeFileHandle hDevice, WindowsIoctl ioControlCode, IntPtr inBuffer, uint nInBufferSize, - ref StorageDeviceNumber outBuffer, - uint nOutBufferSize, ref uint pBytesReturned, - IntPtr overlapped); + ref StorageDeviceNumber outBuffer, uint nOutBufferSize, + ref uint pBytesReturned, IntPtr overlapped); [DllImport("Kernel32.dll", SetLastError = true, EntryPoint = "DeviceIoControl", CharSet = CharSet.Auto)] internal static extern bool DeviceIoControl(SafeFileHandle hDevice, WindowsIoctl ioControlCode, IntPtr inBuffer, @@ -92,8 +90,8 @@ internal static class Extern out uint pBytesReturned, IntPtr overlapped); [DllImport("setupapi.dll", CharSet = CharSet.Auto)] - internal static extern SafeFileHandle SetupDiGetClassDevs(ref Guid classGuid, IntPtr enumerator, - IntPtr hwndParent, DeviceGetClassFlags flags); + internal static extern SafeFileHandle SetupDiGetClassDevs(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, + DeviceGetClassFlags flags); [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool SetupDiEnumDeviceInterfaces(SafeFileHandle hDevInfo, IntPtr devInfo, @@ -104,8 +102,8 @@ internal static class Extern public static extern bool SetupDiGetDeviceInterfaceDetail(SafeFileHandle hDevInfo, ref DeviceInterfaceData deviceInterfaceData, IntPtr deviceInterfaceDetailData, - uint deviceInterfaceDetailDataSize, - ref uint requiredSize, IntPtr deviceInfoData); + uint deviceInterfaceDetailDataSize, ref uint requiredSize, + IntPtr deviceInfoData); [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool SetupDiDestroyDeviceInfoList(SafeFileHandle hDevInfo); @@ -114,8 +112,8 @@ internal static class Extern internal static extern bool CloseHandle(SafeFileHandle hDevice); [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, - out long lpNewFilePointer, MoveMethod dwMoveMethod); + public static extern bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, out long lpNewFilePointer, + MoveMethod dwMoveMethod); [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern bool ReadFile(SafeFileHandle hFile, byte[] lpBuffer, uint nNumberOfBytesToRead, diff --git a/Aaru.Devices/Windows/ListDevices.cs b/Aaru.Devices/Windows/ListDevices.cs index f854fcbca..08f6ac0c7 100644 --- a/Aaru.Devices/Windows/ListDevices.cs +++ b/Aaru.Devices/Windows/ListDevices.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -40,9 +42,7 @@ using Aaru.Helpers; using Microsoft.Win32.SafeHandles; using Marshal = System.Runtime.InteropServices.Marshal; -namespace Aaru.Devices.Windows; - -internal static class ListDevices +static class ListDevices { /// Converts a hex dump string to the ASCII string it represents /// Hex dump @@ -52,8 +52,8 @@ internal static class ListDevices var result = new StringBuilder(); const string HEXTABLE = "0123456789abcdef"; - for(int i = 0; i < hex.Length / 2; i++) - result.Append((char)((16 * HEXTABLE.IndexOf(hex[2 * i])) + HEXTABLE.IndexOf(hex[(2 * i) + 1]))); + for(var i = 0; i < hex.Length / 2; i++) + result.Append((char)(16 * HEXTABLE.IndexOf(hex[2 * i]) + HEXTABLE.IndexOf(hex[2 * i + 1]))); return result.ToString(); } @@ -63,7 +63,7 @@ internal static class ListDevices [SuppressMessage("ReSharper", "RedundantCatchClause")] internal static DeviceInfo[] GetList() { - List deviceIDs = new List(); + var deviceIDs = new List(); try { @@ -92,7 +92,7 @@ internal static class ListDevices #endif } - List devList = new List(); + var devList = new List(); foreach(string devId in deviceIDs) { @@ -123,14 +123,14 @@ internal static class ListDevices //descriptor.RawDeviceProperties = new byte[16384]; IntPtr descriptorPtr = Marshal.AllocHGlobal(1000); - byte[] descriptorB = new byte[1000]; + var descriptorB = new byte[1000]; uint returned = 0; - int error = 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(); @@ -163,12 +163,10 @@ internal static class ListDevices }; if(descriptor.VendorIdOffset > 0) - info.Vendor = - StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.VendorIdOffset); + info.Vendor = StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.VendorIdOffset); if(descriptor.ProductIdOffset > 0) - info.Model = - StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.ProductIdOffset); + info.Model = StringHandlers.CToString(descriptorB, Encoding.ASCII, start: descriptor.ProductIdOffset); // TODO: Get serial number of SCSI and USB devices, probably also FireWire (untested) if(descriptor.SerialNumberOffset > 0) diff --git a/Aaru.Devices/Windows/Structs.cs b/Aaru.Devices/Windows/Structs.cs index b80671940..bd32a8b7e 100644 --- a/Aaru.Devices/Windows/Structs.cs +++ b/Aaru.Devices/Windows/Structs.cs @@ -31,14 +31,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Devices.Windows; - [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct ScsiPassThroughDirect +struct ScsiPassThroughDirect { public ushort Length; public byte ScsiStatus; @@ -59,7 +59,7 @@ internal struct ScsiPassThroughDirect } [StructLayout(LayoutKind.Sequential)] -internal struct ScsiPassThroughDirectAndSenseBuffer +struct ScsiPassThroughDirectAndSenseBuffer { public ScsiPassThroughDirect sptd; @@ -68,7 +68,7 @@ internal struct ScsiPassThroughDirectAndSenseBuffer } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct AtaPassThroughDirect +struct AtaPassThroughDirect { /// Length in bytes of this structure public ushort Length; @@ -109,7 +109,7 @@ internal struct AtaPassThroughDirect } [StructLayout(LayoutKind.Explicit), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct AtaTaskFile +struct AtaTaskFile { // Fields for commands sent [FieldOffset(0)] @@ -139,7 +139,7 @@ internal struct AtaTaskFile } [StructLayout(LayoutKind.Sequential)] -internal struct StoragePropertyQuery +struct StoragePropertyQuery { [MarshalAs(UnmanagedType.U4)] public StoragePropertyId PropertyId; @@ -151,14 +151,14 @@ internal struct StoragePropertyQuery } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct StorageDescriptorHeader +struct StorageDescriptorHeader { public uint Version; public uint Size; } [StructLayout(LayoutKind.Sequential)] -internal struct StorageDeviceDescriptor +struct StorageDeviceDescriptor { public uint Version; public uint Size; @@ -178,7 +178,7 @@ internal struct StorageDeviceDescriptor } [StructLayout(LayoutKind.Sequential)] -internal struct IdePassThroughDirect +struct IdePassThroughDirect { /// ATA registers public AtaTaskFile CurrentTaskFile; @@ -192,7 +192,7 @@ internal struct IdePassThroughDirect } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct StorageDeviceNumber +struct StorageDeviceNumber { public int deviceType; public int deviceNumber; @@ -200,7 +200,7 @@ internal struct StorageDeviceNumber } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct DeviceInfoData +struct DeviceInfoData { public int cbSize; public Guid classGuid; @@ -209,7 +209,7 @@ internal struct DeviceInfoData } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct DeviceInterfaceData +struct DeviceInterfaceData { public int cbSize; public Guid interfaceClassGuid; @@ -218,7 +218,7 @@ internal struct DeviceInterfaceData } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct UsbSetupPacket +struct UsbSetupPacket { public byte bmRequest; public byte bRequest; @@ -228,7 +228,7 @@ internal struct UsbSetupPacket } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct UsbDescriptorRequest +struct UsbDescriptorRequest { public int ConnectionIndex; @@ -238,7 +238,7 @@ internal struct UsbDescriptorRequest } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct SffdiskQueryDeviceProtocolData +struct SffdiskQueryDeviceProtocolData { public ushort size; public ushort reserved; @@ -246,7 +246,7 @@ internal struct SffdiskQueryDeviceProtocolData } [StructLayout(LayoutKind.Sequential), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] -internal struct SffdiskDeviceCommandData +struct SffdiskDeviceCommandData { public ushort size; public ushort reserved; @@ -257,7 +257,7 @@ internal struct SffdiskDeviceCommandData } [StructLayout(LayoutKind.Sequential)] -internal struct SdCmdDescriptor +struct SdCmdDescriptor { public byte commandCode; public SdCommandClass cmdClass; diff --git a/Aaru.Devices/Windows/Usb.cs b/Aaru.Devices/Windows/Usb.cs index a7f437c8a..9ff5973c4 100644 --- a/Aaru.Devices/Windows/Usb.cs +++ b/Aaru.Devices/Windows/Usb.cs @@ -31,6 +31,8 @@ // Copyright © 2007 Fort Hood TX, herethen, Public Domain // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -38,19 +40,17 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Text; -namespace Aaru.Devices.Windows; - // TODO: Even after cleaning, refactoring and xml-documenting, this code needs some love /// Implements functions for getting and accessing information from the USB bus [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] -internal static partial class Usb +static partial class Usb { /// Return a list of USB Host Controllers /// List of USB Host Controllers static IEnumerable GetHostControllers() { - List hostList = new List(); - var hostGuid = new Guid(GUID_DEVINTERFACE_HUBCONTROLLER); + var hostList = new List(); + var hostGuid = new Guid(GUID_DEVINTERFACE_HUBCONTROLLER); // We start at the "root" of the device tree and look for all // devices that match the interface GUID of a Hub Controller @@ -61,7 +61,7 @@ internal static partial class Usb IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); bool success; - int i = 0; + var i = 0; do { @@ -92,7 +92,7 @@ internal static partial class Usb // trust me :) // now we can get some more detailed information - int nRequiredSize = 0; + var nRequiredSize = 0; const int N_BYTES = BUFFER_SIZE; if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, N_BYTES, ref nRequiredSize, ref da)) @@ -100,11 +100,11 @@ internal static partial class Usb host.ControllerDevicePath = didd.DevicePath; // get the Device Description and DriverKeyName - int requiredSize = 0; + var requiredSize = 0; int regType = REG_SZ; - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, - BUFFER_SIZE, ref requiredSize)) + 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, @@ -130,7 +130,7 @@ internal static partial class Usb /// USB device description static string GetDescriptionByKeyName(string driverKeyName) { - string ans = ""; + var ans = ""; const string DEV_ENUM = REGSTR_KEY_USB; // Use the "enumerator form" of the SetupDiGetClassDevs API @@ -143,7 +143,7 @@ internal static partial class Usb IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); bool success; - int i = 0; + var i = 0; do { @@ -156,9 +156,9 @@ internal static partial class Usb if(success) { - int requiredSize = 0; - int regType = REG_SZ; - string keyName = ""; + var requiredSize = 0; + int regType = REG_SZ; + var keyName = ""; if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, ref requiredSize)) @@ -167,8 +167,8 @@ internal static partial class Usb // is it a match? if(keyName == driverKeyName) { - if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, - BUFFER_SIZE, ref requiredSize)) + if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, BUFFER_SIZE, + ref requiredSize)) ans = Marshal.PtrToStringAuto(ptrBuf); break; @@ -189,7 +189,7 @@ internal static partial class Usb /// Device instance ID static string GetInstanceIdByKeyName(string driverKeyName) { - string ans = ""; + var ans = ""; const string DEV_ENUM = REGSTR_KEY_USB; // Use the "enumerator form" of the SetupDiGetClassDevs API @@ -202,7 +202,7 @@ internal static partial class Usb IntPtr ptrBuf = Marshal.AllocHGlobal(BUFFER_SIZE); bool success; - int i = 0; + var i = 0; do { @@ -215,10 +215,10 @@ internal static partial class Usb if(success) { - int requiredSize = 0; + var requiredSize = 0; int regType = REG_SZ; - string keyName = ""; + var keyName = ""; if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, ref requiredSize)) @@ -323,8 +323,8 @@ internal 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 _, IntPtr.Zero)) + if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out _, + IntPtr.Zero)) { nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo, typeof(UsbNodeInformation)); @@ -400,7 +400,7 @@ internal static partial class Usb /// List of downstream ports internal IEnumerable GetPorts() { - List portList = new List(); + 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, @@ -414,7 +414,7 @@ internal static partial class Usb // loop thru all of the ports on the hub // BTW: Ports are numbered starting at 1 - for(int i = 1; i <= HubPortCount; i++) + for(var i = 1; i <= HubPortCount; i++) { var nodeConnection = new UsbNodeConnectionInformationEx { @@ -434,14 +434,13 @@ internal static partial class Usb // load up the USBPort class var port = new UsbPort { - PortPortNumber = i, - PortHubDevicePath = HubDevicePath, - PortStatus = ((UsbConnectionStatus)nodeConnection.ConnectionStatus).ToString(), - PortSpeed = ((UsbDeviceSpeed)nodeConnection.Speed).ToString(), - PortIsDeviceConnected = - nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected, - PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub), - PortDeviceDescriptor = nodeConnection.DeviceDescriptor + PortPortNumber = i, + PortHubDevicePath = HubDevicePath, + PortStatus = ((UsbConnectionStatus)nodeConnection.ConnectionStatus).ToString(), + PortSpeed = ((UsbDeviceSpeed)nodeConnection.Speed).ToString(), + PortIsDeviceConnected = nodeConnection.ConnectionStatus == (int)UsbConnectionStatus.DeviceConnected, + PortIsHub = Convert.ToBoolean(nodeConnection.DeviceIsHub), + PortDeviceDescriptor = nodeConnection.DeviceDescriptor }; // add it to the list @@ -520,7 +519,7 @@ internal static partial class Usb int nBytes = BUFFER_SIZE; // We use this to zero fill a buffer - string nullString = new string((char)0, BUFFER_SIZE / Marshal.SystemDefaultCharSize); + var nullString = new string((char)0, BUFFER_SIZE / Marshal.SystemDefaultCharSize); // The iManufacturer, iProduct and iSerialNumber entries in the // Device Descriptor are really just indexes. So, we have to @@ -655,8 +654,8 @@ internal 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]; @@ -725,11 +724,10 @@ internal 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 _, IntPtr.Zero)) + if(DeviceIoControl(h, IOCTL_USB_GET_NODE_CONNECTION_NAME, ptrNodeName, nBytes, ptrNodeName, nBytes, out _, + IntPtr.Zero)) { - nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName, - typeof(UsbNodeConnectionName)); + nodeName = (UsbNodeConnectionName)Marshal.PtrToStructure(ptrNodeName, typeof(UsbNodeConnectionName)); hub.HubDevicePath = @"\\.\" + nodeName.NodeName; } @@ -750,8 +748,8 @@ internal 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 _, IntPtr.Zero)) + if(DeviceIoControl(h2, IOCTL_USB_GET_NODE_INFORMATION, ptrNodeInfo, nBytes, ptrNodeInfo, nBytes, out _, + IntPtr.Zero)) { nodeInfo = (UsbNodeInformation)Marshal.PtrToStructure(ptrNodeInfo, typeof(UsbNodeInformation)); @@ -833,7 +831,7 @@ internal static partial class Usb const int FILE_SHARE_READ = 0x1; const int FILE_SHARE_WRITE = 0x2; const int OPEN_EXISTING = 0x3; - static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); + static readonly IntPtr INVALID_HANDLE_VALUE = new(-1); const int IOCTL_GET_HCD_DRIVERKEY_NAME = 0x220424; const int IOCTL_USB_GET_ROOT_HUB_NAME = 0x220408; @@ -863,19 +861,28 @@ internal static partial class Usb enum UsbHubNode { - UsbHub, UsbMiParent + UsbHub, + UsbMiParent } enum UsbConnectionStatus { - NoDeviceConnected, DeviceConnected, DeviceFailedEnumeration, - DeviceGeneralFailure, DeviceCausedOvercurrent, DeviceNotEnoughPower, - DeviceNotEnoughBandwidth, DeviceHubNestedTooDeeply, DeviceInLegacyHub + NoDeviceConnected, + DeviceConnected, + DeviceFailedEnumeration, + DeviceGeneralFailure, + DeviceCausedOvercurrent, + DeviceNotEnoughPower, + DeviceNotEnoughBandwidth, + DeviceHubNestedTooDeeply, + DeviceInLegacyHub } enum UsbDeviceSpeed : byte { - UsbLowSpeed, UsbFullSpeed, UsbHighSpeed + UsbLowSpeed, + UsbFullSpeed, + UsbHighSpeed } // ********************** Stuctures ************************ @@ -1059,8 +1066,7 @@ internal static partial class Usb ref int requiredSize); [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)] - static extern bool SetupDiEnumDeviceInfo(IntPtr deviceInfoSet, int memberIndex, - ref SpDevinfoData deviceInfoData); + static extern bool SetupDiEnumDeviceInfo(IntPtr deviceInfoSet, int memberIndex, ref SpDevinfoData deviceInfoData); [DllImport("setupapi.dll", SetLastError = true)] static extern bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet); @@ -1077,8 +1083,8 @@ internal static partial class Usb [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr CreateFile(string lpFileName, int dwDesiredAccess, int dwShareMode, - IntPtr lpSecurityAttributes, int dwCreationDisposition, - int dwFlagsAndAttributes, IntPtr hTemplateFile); + IntPtr lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, + IntPtr hTemplateFile); [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern bool CloseHandle(IntPtr hObject); diff --git a/Aaru.Devices/Windows/UsbFunctions.cs b/Aaru.Devices/Windows/UsbFunctions.cs index a62500e5b..5ab815512 100644 --- a/Aaru.Devices/Windows/UsbFunctions.cs +++ b/Aaru.Devices/Windows/UsbFunctions.cs @@ -31,19 +31,19 @@ // Copyright © 2007 Fort Hood TX, herethen, Public Domain // ****************************************************************************/ +namespace Aaru.Devices.Windows; + using System; using System.Collections.Generic; using System.Runtime.InteropServices; -namespace Aaru.Devices.Windows; - // // A place for "higher level" related functions // You might not want to keep these in the USB class... your choice // // TODO: Even after cleaning, refactoring and xml-documenting, this code needs some love /// Implements functions for getting and accessing information from the USB bus -internal static partial class Usb +static partial class Usb { const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080; internal const string GuidDevinterfaceDisk = "53f56307-b6bf-11d0-94f2-00a0c91efb8b"; @@ -55,7 +55,7 @@ internal static partial class Usb /// List of usb devices internal static List GetConnectedDevices() { - List devList = new List(); + var devList = new List(); foreach(UsbController controller in GetHostControllers()) ListHub(controller.GetRootHub(), devList); @@ -70,9 +70,7 @@ internal static partial class Usb { foreach(UsbPort port in hub.GetPorts()) if(port.IsHub) - { ListHub(port.GetHub(), devList); - } else { if(port.IsDeviceConnected) @@ -106,9 +104,7 @@ internal static partial class Usb { foreach(UsbPort port in hub.GetPorts()) if(port.IsHub) - { SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName); - } else { if(!port.IsDeviceConnected) @@ -151,9 +147,7 @@ internal static partial class Usb { foreach(UsbPort port in hub.GetPorts()) if(port.IsHub) - { SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId); - } else { if(!port.IsDeviceConnected) @@ -211,7 +205,7 @@ internal static partial class Usb static UsbDevice FindDeviceNumber(int devNum, string deviceGuid) { UsbDevice foundDevice = null; - string instanceId = ""; + var instanceId = ""; var diskGuid = new Guid(deviceGuid); @@ -222,7 +216,7 @@ internal static partial class Usb if(h != INVALID_HANDLE_VALUE) { bool success; - int i = 0; + var i = 0; do { @@ -246,7 +240,7 @@ internal static partial class Usb }; // trust me :) // now we can get some more detailed information - int nRequiredSize = 0; + var nRequiredSize = 0; const int N_BYTES = BUFFER_SIZE; if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, N_BYTES, ref nRequiredSize, ref da)) diff --git a/Aaru.Dto b/Aaru.Dto index a5132ac13..acf627140 160000 --- a/Aaru.Dto +++ b/Aaru.Dto @@ -1 +1 @@ -Subproject commit a5132ac1315d5afcccedc15c4833aea0aa74a70e +Subproject commit acf62714081fedd47795fac32121cadc5b8610ec diff --git a/Aaru.Filesystems/AODOS.cs b/Aaru.Filesystems/AODOS.cs index 1e41e5683..de8632361 100644 --- a/Aaru.Filesystems/AODOS.cs +++ b/Aaru.Filesystems/AODOS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information has been extracted looking at available disk images // This may be missing fields, or not, I don't know russian so any help is appreciated /// @@ -91,8 +91,7 @@ public sealed class AODOS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { information = ""; Encoding = Encoding.GetEncoding("koi8-r"); @@ -123,8 +122,7 @@ public sealed class AODOS : IFilesystem sbInformation.AppendFormat("{0} files on volume", bb.files).AppendLine(); sbInformation.AppendFormat("{0} used sectors on volume", bb.usedSectors).AppendLine(); - sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(bb.volumeLabel, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(bb.volumeLabel, Encoding)).AppendLine(); information = sbInformation.ToString(); } diff --git a/Aaru.Filesystems/APFS.cs b/Aaru.Filesystems/APFS.cs index 877371fee..9de47325e 100644 --- a/Aaru.Filesystems/APFS.cs +++ b/Aaru.Filesystems/APFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Apple File System (APFS) [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -87,8 +87,7 @@ public sealed class APFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.UTF8; var sbInformation = new StringBuilder(); diff --git a/Aaru.Filesystems/Aaru.Filesystems.csproj b/Aaru.Filesystems/Aaru.Filesystems.csproj index f7e9c6e42..690aa39a6 100644 --- a/Aaru.Filesystems/Aaru.Filesystems.csproj +++ b/Aaru.Filesystems/Aaru.Filesystems.csproj @@ -1,295 +1,288 @@  - - Debug - AnyCPU - 2.0 - {D7016DF2-5A5E-4524-B40D-BA2D59576688} - Library - Aaru.Filesystems - Aaru.Filesystems - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Filesystems - $(Version) - net6 - CS0649 - 10 - Filesystem implementations used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - full - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {D7016DF2-5A5E-4524-B40D-BA2D59576688} + Library + Aaru.Filesystems + Aaru.Filesystems + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Filesystems + $(Version) + net6 + CS0649 + 10 + Filesystem implementations used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + full + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn.cs b/Aaru.Filesystems/Acorn.cs index ef78fff63..b56305d42 100644 --- a/Aaru.Filesystems/Acorn.cs +++ b/Aaru.Filesystems/Acorn.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of Acorn's Advanced Data Filing System (ADFS) public sealed class AcornADFS : IFilesystem @@ -125,7 +125,7 @@ public sealed class AcornADFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - byte[] tmp = new byte[256]; + var tmp = new byte[256]; Array.Copy(sector, 256, tmp, 0, 256); oldChk1 = AcornMapChecksum(tmp, 255); oldMap1 = Marshal.ByteArrayToStructureLittleEndian(tmp); @@ -152,7 +152,7 @@ public sealed class AcornADFS : IFilesystem if(sector.Length > OLD_DIRECTORY_SIZE) { - byte[] tmp = new byte[OLD_DIRECTORY_SIZE]; + var tmp = new byte[OLD_DIRECTORY_SIZE]; Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53); Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53); sector = tmp; @@ -161,8 +161,7 @@ public sealed class AcornADFS : IFilesystem OldDirectory oldRoot = Marshal.ByteArrayToStructureLittleEndian(sector); byte dirChk = AcornDirectoryChecksum(sector, (int)OLD_DIRECTORY_SIZE - 1); - AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.header.magic at 0x200 = {0}", - oldRoot.header.magic); + AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.header.magic at 0x200 = {0}", oldRoot.header.magic); AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.tail.magic at 0x200 = {0}", oldRoot.tail.magic); @@ -171,8 +170,8 @@ public sealed class AcornADFS : IFilesystem AaruConsole.DebugWriteLine("ADFS Plugin", "dirChk at 0x200 = {0}", dirChk); - if((oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC) || - (oldRoot.header.magic == NEW_DIR_MAGIC && oldRoot.tail.magic == NEW_DIR_MAGIC)) + if(oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC || + oldRoot.header.magic == NEW_DIR_MAGIC && oldRoot.tail.magic == NEW_DIR_MAGIC) return true; // RISC OS says the old directory can't be in the new location, hard disks created by RISC OS 3.10 do that... @@ -189,7 +188,7 @@ public sealed class AcornADFS : IFilesystem if(sector.Length > OLD_DIRECTORY_SIZE) { - byte[] tmp = new byte[OLD_DIRECTORY_SIZE]; + var tmp = new byte[OLD_DIRECTORY_SIZE]; Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53); Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53); sector = tmp; @@ -198,8 +197,7 @@ public sealed class AcornADFS : IFilesystem oldRoot = Marshal.ByteArrayToStructureLittleEndian(sector); dirChk = AcornDirectoryChecksum(sector, (int)OLD_DIRECTORY_SIZE - 1); - AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.header.magic at 0x400 = {0}", - oldRoot.header.magic); + AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.header.magic at 0x400 = {0}", oldRoot.header.magic); AaruConsole.DebugWriteLine("ADFS Plugin", "oldRoot.tail.magic at 0x400 = {0}", oldRoot.tail.magic); @@ -208,8 +206,8 @@ public sealed class AcornADFS : IFilesystem AaruConsole.DebugWriteLine("ADFS Plugin", "dirChk at 0x400 = {0}", dirChk); - if((oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC) || - (oldRoot.header.magic == NEW_DIR_MAGIC && oldRoot.tail.magic == NEW_DIR_MAGIC)) + if(oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC || + oldRoot.header.magic == NEW_DIR_MAGIC && oldRoot.tail.magic == NEW_DIR_MAGIC) return true; } } @@ -240,12 +238,12 @@ public sealed class AcornADFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - int bootChk = 0; + var bootChk = 0; if(bootSector.Length < 512) return false; - for(int i = 0; i < 0x1FF; i++) + for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; AaruConsole.DebugWriteLine("ADFS Plugin", "bootChk = {0}", bootChk); @@ -298,8 +296,7 @@ public sealed class AcornADFS : IFilesystem // TODO: Support big directories (ADFS-G?) // TODO: Find the real freemap on volumes with DiscRecord, as DiscRecord's discid may be empty but this one isn't /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); var sbInformation = new StringBuilder(); @@ -341,7 +338,7 @@ public sealed class AcornADFS : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] tmp = new byte[256]; + var tmp = new byte[256]; Array.Copy(sector, 256, tmp, 0, 256); oldChk1 = AcornMapChecksum(tmp, 255); oldMap1 = Marshal.ByteArrayToStructureLittleEndian(tmp); @@ -353,12 +350,12 @@ public sealed class AcornADFS : IFilesystem oldMap1.checksum != 0) { bytes = (ulong)((oldMap0.size[2] << 16) + (oldMap0.size[1] << 8) + oldMap0.size[0]) * 256; - byte[] namebytes = new byte[10]; + var namebytes = new byte[10]; - for(int i = 0; i < 5; i++) + for(var i = 0; i < 5; i++) { - namebytes[i * 2] = oldMap0.name[i]; - namebytes[(i * 2) + 1] = oldMap1.name[i]; + namebytes[i * 2] = oldMap0.name[i]; + namebytes[i * 2 + 1] = oldMap1.name[i]; } XmlFsType = new FileSystemType @@ -384,7 +381,7 @@ public sealed class AcornADFS : IFilesystem if(sector.Length > OLD_DIRECTORY_SIZE) { - byte[] tmp = new byte[OLD_DIRECTORY_SIZE]; + var tmp = new byte[OLD_DIRECTORY_SIZE]; Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53); Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53); sector = tmp; @@ -411,7 +408,7 @@ public sealed class AcornADFS : IFilesystem if(sector.Length > OLD_DIRECTORY_SIZE) { - byte[] tmp = new byte[OLD_DIRECTORY_SIZE]; + var tmp = new byte[OLD_DIRECTORY_SIZE]; Array.Copy(sector, 0, tmp, 0, OLD_DIRECTORY_SIZE - 53); Array.Copy(sector, sector.Length - 54, tmp, OLD_DIRECTORY_SIZE - 54, 53); @@ -433,7 +430,7 @@ public sealed class AcornADFS : IFilesystem if(sector.Length > NEW_DIRECTORY_SIZE) { - byte[] tmp = new byte[NEW_DIRECTORY_SIZE]; + var tmp = new byte[NEW_DIRECTORY_SIZE]; Array.Copy(sector, 0, tmp, 0, NEW_DIRECTORY_SIZE - 41); Array.Copy(sector, sector.Length - 42, tmp, NEW_DIRECTORY_SIZE - 42, 41); @@ -496,9 +493,9 @@ public sealed class AcornADFS : IFilesystem if(errno != ErrorNumber.NoError) return; - int bootChk = 0; + var bootChk = 0; - for(int i = 0; i < 0x1FF; i++) + for(var i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i]; AaruConsole.DebugWriteLine("ADFS Plugin", "bootChk = {0}", bootChk); @@ -610,8 +607,8 @@ public sealed class AcornADFS : IFilesystem byte AcornMapChecksum(byte[] data, int length) { - int sum = 0; - int carry = 0; + var sum = 0; + var carry = 0; if(length > data.Length) length = data.Length; @@ -675,7 +672,7 @@ public sealed class AcornADFS : IFilesystem length = data.Count; // EOR r0, r1, r0, ROR #13 - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { uint carry = sum & 0x1FFF; sum >>= 13; diff --git a/Aaru.Filesystems/AmigaDOS.cs b/Aaru.Filesystems/AmigaDOS.cs index 087ed8cea..963243406 100644 --- a/Aaru.Filesystems/AmigaDOS.cs +++ b/Aaru.Filesystems/AmigaDOS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of Amiga Fast File System (AFFS) public sealed class AmigaDOSPlugin : IFilesystem @@ -123,10 +123,10 @@ public sealed class AmigaDOSPlugin : IFilesystem ulong[] rootPtrs = { - bRootPtr + partition.Start, ((partition.End - partition.Start + 1) / 2) + partition.Start - 2, - ((partition.End - partition.Start + 1) / 2) + partition.Start - 1, - ((partition.End - partition.Start + 1) / 2) + partition.Start, - ((partition.End - partition.Start + 1) / 2) + partition.Start + 4 + bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2, + (partition.End - partition.Start + 1) / 2 + partition.Start - 1, + (partition.End - partition.Start + 1) / 2 + partition.Start, + (partition.End - partition.Start + 1) / 2 + partition.Start + 4 }; var rblk = new RootBlock(); @@ -152,7 +152,7 @@ public sealed class AmigaDOSPlugin : IFilesystem AaruConsole.DebugWriteLine("AmigaDOS plugin", "rblk.hashTableSize = {0}", rblk.hashTableSize); uint blockSize = (rblk.hashTableSize + 56) * 4; - uint sectorsPerBlock = (uint)(blockSize / sector.Length); + var sectorsPerBlock = (uint)(blockSize / sector.Length); AaruConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize); AaruConsole.DebugWriteLine("AmigaDOS plugin", "sectorsPerBlock = {0}", sectorsPerBlock); @@ -188,8 +188,7 @@ public sealed class AmigaDOSPlugin : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); var sbInformation = new StringBuilder(); @@ -217,16 +216,16 @@ public sealed class AmigaDOSPlugin : IFilesystem ulong[] rootPtrs = { - bRootPtr + partition.Start, ((partition.End - partition.Start + 1) / 2) + partition.Start - 2, - ((partition.End - partition.Start + 1) / 2) + partition.Start - 1, - ((partition.End - partition.Start + 1) / 2) + partition.Start, - ((partition.End - partition.Start + 1) / 2) + partition.Start + 4 + bRootPtr + partition.Start, (partition.End - partition.Start + 1) / 2 + partition.Start - 2, + (partition.End - partition.Start + 1) / 2 + partition.Start - 1, + (partition.End - partition.Start + 1) / 2 + partition.Start, + (partition.End - partition.Start + 1) / 2 + partition.Start + 4 }; var rootBlk = new RootBlock(); byte[] rootBlockSector = null; - bool rootFound = false; + var rootFound = false; uint blockSize = 0; // So to handle even number of sectors @@ -250,7 +249,7 @@ public sealed class AmigaDOSPlugin : IFilesystem AaruConsole.DebugWriteLine("AmigaDOS plugin", "rootBlk.hashTableSize = {0}", rootBlk.hashTableSize); blockSize = (rootBlk.hashTableSize + 56) * 4; - uint sectorsPerBlock = (uint)(blockSize / rootBlockSector.Length); + var sectorsPerBlock = (uint)(blockSize / rootBlockSector.Length); AaruConsole.DebugWriteLine("AmigaDOS plugin", "blockSize = {0}", blockSize); AaruConsole.DebugWriteLine("AmigaDOS plugin", "sectorsPerBlock = {0}", sectorsPerBlock); @@ -407,14 +406,14 @@ public sealed class AmigaDOSPlugin : IFilesystem static RootBlock MarshalRootBlock(byte[] block) { - byte[] tmp = new byte[228]; + var tmp = new byte[228]; Array.Copy(block, 0, tmp, 0, 24); Array.Copy(block, block.Length - 200, tmp, 28, 200); RootBlock root = Marshal.ByteArrayToStructureBigEndian(tmp); root.hashTable = new uint[(block.Length - 224) / 4]; - for(int i = 0; i < root.hashTable.Length; i++) - root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + (i * 4)); + for(var i = 0; i < root.hashTable.Length; i++) + root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + i * 4); return root; } @@ -423,7 +422,7 @@ public sealed class AmigaDOSPlugin : IFilesystem { uint sum = 0; - for(int i = 0; i < data.Length; i += 4) + for(var i = 0; i < data.Length; i += 4) sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3]); return (uint)-sum; @@ -433,7 +432,7 @@ public sealed class AmigaDOSPlugin : IFilesystem { uint sum = 0; - for(int i = 0; i < data.Length; i += 4) + for(var i = 0; i < data.Length; i += 4) { uint psum = sum; diff --git a/Aaru.Filesystems/AppleCommon/Consts.cs b/Aaru.Filesystems/AppleCommon/Consts.cs index 9d766cc00..5a2c787f6 100644 --- a/Aaru.Filesystems/AppleCommon/Consts.cs +++ b/Aaru.Filesystems/AppleCommon/Consts.cs @@ -34,7 +34,7 @@ namespace Aaru.Filesystems; // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf -internal static partial class AppleCommon +static partial class AppleCommon { /// "LK", HFS bootblock magic internal const ushort BB_MAGIC = 0x4C4B; diff --git a/Aaru.Filesystems/AppleCommon/Enums.cs b/Aaru.Filesystems/AppleCommon/Enums.cs index 94f348159..ab1eecc55 100644 --- a/Aaru.Filesystems/AppleCommon/Enums.cs +++ b/Aaru.Filesystems/AppleCommon/Enums.cs @@ -30,22 +30,30 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; + // ReSharper disable InconsistentNaming namespace Aaru.Filesystems; +using System; + // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf -internal static partial class AppleCommon +static partial class AppleCommon { [Flags] internal enum VolumeAttributes : ushort { - HardwareLock = 0x80, Unmounted = 0x100, SparedBadBlocks = 0x200, - DoesNotNeedCache = 0x400, BootInconsistent = 0x800, ReusedIds = 0x1000, - Journaled = 0x2000, Inconsistent = 0x4000, SoftwareLock = 0x8000 + HardwareLock = 0x80, + Unmounted = 0x100, + SparedBadBlocks = 0x200, + DoesNotNeedCache = 0x400, + BootInconsistent = 0x800, + ReusedIds = 0x1000, + Journaled = 0x2000, + Inconsistent = 0x4000, + SoftwareLock = 0x8000 } [Flags] @@ -82,7 +90,9 @@ internal static partial class AppleCommon internal enum FinderFolder : short { - fTrash = -3, fDesktop = -2, fDisk = 0 + fTrash = -3, + fDesktop = -2, + fDisk = 0 } [Flags] diff --git a/Aaru.Filesystems/AppleCommon/Info.cs b/Aaru.Filesystems/AppleCommon/Info.cs index 1b42af281..7732bd09e 100644 --- a/Aaru.Filesystems/AppleCommon/Info.cs +++ b/Aaru.Filesystems/AppleCommon/Info.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Text; using Aaru.Helpers; -namespace Aaru.Filesystems; - // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf -internal static partial class AppleCommon +static partial class AppleCommon { internal static string GetBootBlockInformation(byte[] bbSector, Encoding encoding) { @@ -62,9 +62,8 @@ internal static partial class AppleCommon sb.AppendLine("Boot block should be executed."); if((bb.bbVersion & 0x2000) > 0) - sb. - AppendFormat("System heap will be extended by {0} bytes and a {1} fraction of the available RAM", - bb.bbSysHeapExtra, bb.bbSysHeapFract).AppendLine(); + sb.AppendFormat("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) @@ -77,11 +76,9 @@ internal static partial class AppleCommon sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.bbSysName, encoding)).AppendLine(); - sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.bbShellName, encoding)). - AppendLine(); + sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.bbShellName, encoding)).AppendLine(); - sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.bbDbg1Name, encoding)). - AppendLine(); + sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.bbDbg1Name, encoding)).AppendLine(); sb.AppendFormat("Disassembler filename: {0}", StringHandlers.PascalToString(bb.bbDbg2Name, encoding)). AppendLine(); diff --git a/Aaru.Filesystems/AppleCommon/Structs.cs b/Aaru.Filesystems/AppleCommon/Structs.cs index ba3fc09b1..e56e7238f 100644 --- a/Aaru.Filesystems/AppleCommon/Structs.cs +++ b/Aaru.Filesystems/AppleCommon/Structs.cs @@ -30,15 +30,17 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; + // ReSharper disable InconsistentNaming namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf -internal static partial class AppleCommon +static partial class AppleCommon { /// Should be sectors 0 and 1 in volume, followed by boot code [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/AppleDOS/AppleDOS.cs b/Aaru.Filesystems/AppleDOS/AppleDOS.cs index 19f7df9aa..be857cf9a 100644 --- a/Aaru.Filesystems/AppleDOS/AppleDOS.cs +++ b/Aaru.Filesystems/AppleDOS/AppleDOS.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements the Apple DOS 3 filesystem public sealed partial class AppleDOS : IReadOnlyFilesystem diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs index c68bc2b6e..e14dd6851 100644 --- a/Aaru.Filesystems/AppleDOS/Dir.cs +++ b/Aaru.Filesystems/AppleDOS/Dir.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -37,8 +39,6 @@ using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class AppleDOS { /// @@ -77,8 +77,8 @@ public sealed partial class AppleDOS ErrorNumber ReadCatalog() { - var catalogMs = new MemoryStream(); - ulong lba = (ulong)((_vtoc.catalogTrack * _sectorsPerTrack) + _vtoc.catalogSector); + var catalogMs = new MemoryStream(); + var lba = (ulong)(_vtoc.catalogTrack * _sectorsPerTrack + _vtoc.catalogSector); _totalFileEntries = 0; _catalogCache = new Dictionary(); _fileTypeCache = new Dictionary(); @@ -110,11 +110,11 @@ public sealed partial class AppleDOS _track1UsedByFiles |= entry.extentTrack == 1; _track2UsedByFiles |= entry.extentTrack == 2; - byte[] filenameB = new byte[30]; - ushort ts = (ushort)((entry.extentTrack << 8) | entry.extentSector); + var filenameB = new byte[30]; + var ts = (ushort)((entry.extentTrack << 8) | entry.extentSector); // Apple DOS has high byte set over ASCII. - for(int i = 0; i < 30; i++) + for(var i = 0; i < 30; i++) filenameB[i] = (byte)(entry.filename[i] & 0x7F); string filename = StringHandlers.SpacePaddedToString(filenameB, Encoding); @@ -133,7 +133,7 @@ public sealed partial class AppleDOS _lockedFiles.Add(filename); } - lba = (ulong)((catSector.trackOfNext * _sectorsPerTrack) + catSector.sectorOfNext); + lba = (ulong)(catSector.trackOfNext * _sectorsPerTrack + catSector.sectorOfNext); if(lba > _device.Info.Sectors) break; diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index 7faff10e0..167d6b2e6 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Filesystems; - public sealed partial class AppleDOS { /// @@ -216,7 +216,7 @@ public sealed partial class AppleDOS if(!_catalogCache.TryGetValue(filename, out ushort ts)) return ErrorNumber.NoSuchFile; - ulong lba = (ulong)((((ts & 0xFF00) >> 8) * _sectorsPerTrack) + (ts & 0xFF)); + var lba = (ulong)(((ts & 0xFF00) >> 8) * _sectorsPerTrack + (ts & 0xFF)); var fileMs = new MemoryStream(); var tsListMs = new MemoryStream(); ushort expectedBlock = 0; @@ -237,7 +237,7 @@ public sealed partial class AppleDOS if(tsSector.sectorOffset > expectedBlock) { - byte[] hole = new byte[(tsSector.sectorOffset - expectedBlock) * _vtoc.bytesPerSector]; + var hole = new byte[(tsSector.sectorOffset - expectedBlock) * _vtoc.bytesPerSector]; fileMs.Write(hole, 0, hole.Length); expectedBlock = tsSector.sectorOffset; } @@ -248,7 +248,7 @@ public sealed partial class AppleDOS _track2UsedByFiles |= entry.track == 2; _usedSectors++; - ulong blockLba = (ulong)((entry.track * _sectorsPerTrack) + entry.sector); + var blockLba = (ulong)(entry.track * _sectorsPerTrack + entry.sector); if(blockLba == 0) break; @@ -262,7 +262,7 @@ public sealed partial class AppleDOS expectedBlock++; } - lba = (ulong)((tsSector.nextListTrack * _sectorsPerTrack) + tsSector.nextListSector); + lba = (ulong)(tsSector.nextListTrack * _sectorsPerTrack + tsSector.nextListSector); } if(_fileCache.ContainsKey(filename)) @@ -282,8 +282,7 @@ public sealed partial class AppleDOS _fileCache = new Dictionary(); _extentCache = new Dictionary(); - foreach(ErrorNumber error in _catalogCache.Keys.Select(CacheFile). - Where(error => error != ErrorNumber.NoError)) + foreach(ErrorNumber error in _catalogCache.Keys.Select(CacheFile).Where(error => error != ErrorNumber.NoError)) return error; uint tracksOnBoot = 1; diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs index f638405ab..6958df452 100644 --- a/Aaru.Filesystems/AppleDOS/Info.cs +++ b/Aaru.Filesystems/AppleDOS/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,8 +41,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems; - public sealed partial class AppleDOS { /// @@ -56,20 +56,19 @@ public sealed partial class AppleDOS int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; - var errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); + ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); if(errno != ErrorNumber.NoError) return false; _vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); - return _vtoc.catalogSector < spt && _vtoc.maxTrackSectorPairsPerSector <= 122 && - _vtoc.sectorsPerTrack == spt && _vtoc.bytesPerSector == 256; + return _vtoc.catalogSector < spt && _vtoc.maxTrackSectorPairsPerSector <= 122 && _vtoc.sectorsPerTrack == spt && + _vtoc.bytesPerSector == 256; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? new Apple2(); information = ""; @@ -77,7 +76,7 @@ public sealed partial class AppleDOS int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; - var errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); + ErrorNumber errno = imagePlugin.ReadSector((ulong)(17 * spt), out byte[] vtocB); if(errno != ErrorNumber.NoError) return; @@ -97,8 +96,7 @@ public sealed partial class AppleDOS sb.AppendFormat("{0} sectors per track", _vtoc.sectorsPerTrack).AppendLine(); sb.AppendFormat("{0} bytes per sector", _vtoc.bytesPerSector).AppendLine(); - sb.AppendFormat("Track allocation is {0}", _vtoc.allocationDirection > 0 ? "forward" : "reverse"). - AppendLine(); + sb.AppendFormat("Track allocation is {0}", _vtoc.allocationDirection > 0 ? "forward" : "reverse").AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/AppleDOS/Structs.cs b/Aaru.Filesystems/AppleDOS/Structs.cs index 0b6863146..0ae3b4819 100644 --- a/Aaru.Filesystems/AppleDOS/Structs.cs +++ b/Aaru.Filesystems/AppleDOS/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class AppleDOS { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index ff0d91bab..6c726b47c 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -41,8 +43,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems; - public sealed partial class AppleDOS { /// diff --git a/Aaru.Filesystems/AppleDOS/Xattr.cs b/Aaru.Filesystems/AppleDOS/Xattr.cs index 6193b2241..37ca90085 100644 --- a/Aaru.Filesystems/AppleDOS/Xattr.cs +++ b/Aaru.Filesystems/AppleDOS/Xattr.cs @@ -30,12 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Structs; - -namespace Aaru.Filesystems; public sealed partial class AppleDOS { diff --git a/Aaru.Filesystems/AppleHFS/AppleHFS.cs b/Aaru.Filesystems/AppleHFS/AppleHFS.cs index 7861b2d33..b5a7250ec 100644 --- a/Aaru.Filesystems/AppleHFS/AppleHFS.cs +++ b/Aaru.Filesystems/AppleHFS/AppleHFS.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf /// @@ -51,7 +51,7 @@ public sealed partial class AppleHFS : IFilesystem /// public string Name => "Apple Hierarchical File System"; /// - public Guid Id => new Guid("36405F8D-0D26-6ECC-0BBB-1D5225FF404F"); + public Guid Id => new("36405F8D-0D26-6ECC-0BBB-1D5225FF404F"); /// public string Author => "Natalia Portillo"; } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleHFS/Consts.cs b/Aaru.Filesystems/AppleHFS/Consts.cs index e72676063..61f204a9c 100644 --- a/Aaru.Filesystems/AppleHFS/Consts.cs +++ b/Aaru.Filesystems/AppleHFS/Consts.cs @@ -30,12 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; + // ReSharper disable InconsistentNaming namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; + // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf [SuppressMessage("ReSharper", "UnusedMember.Local")] diff --git a/Aaru.Filesystems/AppleHFS/Enums.cs b/Aaru.Filesystems/AppleHFS/Enums.cs index fca41fc07..f6f1bb038 100644 --- a/Aaru.Filesystems/AppleHFS/Enums.cs +++ b/Aaru.Filesystems/AppleHFS/Enums.cs @@ -64,6 +64,7 @@ public sealed partial class AppleHFS enum ForkType : sbyte { - Data = 0, Resource = -1 + Data = 0, + Resource = -1 } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs index 626ed04e3..00a1b591d 100644 --- a/Aaru.Filesystems/AppleHFS/Info.cs +++ b/Aaru.Filesystems/AppleHFS/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Text; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf public sealed partial class AppleHFS @@ -74,8 +74,7 @@ public sealed partial class AppleHFS if(drSigWord != AppleCommon.HFS_MAGIC) continue; - drSigWord = - BigEndianBitConverter.ToUInt16(mdbSector, offset + 0x7C); // Seek to embedded HFS+ signature + drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, offset + 0x7C); // Seek to embedded HFS+ signature return drSigWord != AppleCommon.HFSP_MAGIC; } @@ -104,8 +103,7 @@ public sealed partial class AppleHFS } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("macintosh"); information = ""; @@ -117,7 +115,7 @@ public sealed partial class AppleHFS ushort drSigWord; ErrorNumber errno; - bool apmFromHddOnCd = false; + var apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || diff --git a/Aaru.Filesystems/AppleHFS/Structs.cs b/Aaru.Filesystems/AppleHFS/Structs.cs index bab26b050..e8e228f0e 100644 --- a/Aaru.Filesystems/AppleHFS/Structs.cs +++ b/Aaru.Filesystems/AppleHFS/Structs.cs @@ -30,7 +30,7 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; + // ReSharper disable UnusedType.Local @@ -39,6 +39,8 @@ using System.Runtime.InteropServices; namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + // Information from Inside Macintosh // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf public sealed partial class AppleHFS diff --git a/Aaru.Filesystems/AppleHFSPlus.cs b/Aaru.Filesystems/AppleHFSPlus.cs index 20e7cb64d..9af6ea1c2 100644 --- a/Aaru.Filesystems/AppleHFSPlus.cs +++ b/Aaru.Filesystems/AppleHFSPlus.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html /// /// Implements detection of Apple Hierarchical File System Plus (HFS+) @@ -79,7 +79,7 @@ public sealed class AppleHFSPlus : IFilesystem if(vhSector.Length < 0x800) return false; - ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + var drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" { @@ -88,13 +88,13 @@ public sealed class AppleHFSPlus : IFilesystem if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" { // ReSharper disable once InconsistentNaming - ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); + var xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); - uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); + var drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); - ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); + var drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); - hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); + hfspOffset = (ulong)((drAlBlSt * 512 + xdrStABNt * drAlBlkSiz) / imagePlugin.Info.SectorSize); } else hfspOffset = 0; @@ -114,8 +114,7 @@ public sealed class AppleHFSPlus : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.BigEndianUnicode; information = ""; @@ -135,7 +134,7 @@ public sealed class AppleHFSPlus : IFilesystem if(errno != ErrorNumber.NoError) return; - ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + var drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" { @@ -144,13 +143,13 @@ public sealed class AppleHFSPlus : IFilesystem if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" { // ReSharper disable once InconsistentNaming - ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); + var xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); - uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); + var drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); - ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); + var drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); - hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); + hfspOffset = (ulong)((drAlBlSt * 512 + xdrStABNt * drAlBlkSiz) / imagePlugin.Info.SectorSize); wrapped = true; } else @@ -188,7 +187,7 @@ public sealed class AppleHFSPlus : IFilesystem if(wrapped) sb.AppendLine("Volume is wrapped inside an HFS volume."); - byte[] tmp = new byte[0x400]; + var tmp = new byte[0x400]; Array.Copy(vhSector, 0x400, tmp, 0, 0x400); vhSector = tmp; diff --git a/Aaru.Filesystems/AppleMFS/AppleMFS.cs b/Aaru.Filesystems/AppleMFS/AppleMFS.cs index efe4eda47..0be8e8647 100644 --- a/Aaru.Filesystems/AppleMFS/AppleMFS.cs +++ b/Aaru.Filesystems/AppleMFS/AppleMFS.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II /// /// Implements the Apple Macintosh File System diff --git a/Aaru.Filesystems/AppleMFS/Consts.cs b/Aaru.Filesystems/AppleMFS/Consts.cs index c796b7431..cd9951cc9 100644 --- a/Aaru.Filesystems/AppleMFS/Consts.cs +++ b/Aaru.Filesystems/AppleMFS/Consts.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; + // Information from Inside Macintosh Volume II [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class AppleMFS diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index ef26add9f..4c529ea9f 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Linq; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II public sealed partial class AppleMFS { @@ -77,7 +77,7 @@ public sealed partial class AppleMFS _idToEntry = new Dictionary(); _filenameToId = new Dictionary(); - int offset = 0; + var offset = 0; while(offset + 51 < _directoryBlocks.Length) { @@ -91,8 +91,7 @@ public sealed partial class AppleMFS entry.flTyp = _directoryBlocks[offset + 1]; - entry.flUsrWds = - Marshal.ByteArrayToStructureBigEndian(_directoryBlocks, offset + 2, 16); + entry.flUsrWds = Marshal.ByteArrayToStructureBigEndian(_directoryBlocks, offset + 2, 16); entry.flFlNum = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 18); entry.flStBlk = BigEndianBitConverter.ToUInt16(_directoryBlocks, offset + 22); diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index f599449ed..14fd98332 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.IO; using Aaru.CommonTypes.Enums; @@ -38,8 +40,6 @@ using Aaru.Console; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II public sealed partial class AppleMFS { @@ -77,7 +77,7 @@ public sealed partial class AppleMFS { if(relBlock == fileBlock) { - deviceBlock = ((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + (long)_partitionStart; + deviceBlock = (nextBlock - 2) * _sectorsPerBlock + _volMdb.drAlBlSt + (long)_partitionStart; return ErrorNumber.NoError; } @@ -236,27 +236,25 @@ public sealed partial class AppleMFS if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (_directoryBlocks.Length / stat.BlockSize) + - (_directoryBlocks.Length % stat.BlockSize); + stat.Blocks = _directoryBlocks.Length / stat.BlockSize + _directoryBlocks.Length % stat.BlockSize; stat.Length = _directoryBlocks.Length; } else if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (_blockMapBytes.Length / stat.BlockSize) + - (_blockMapBytes.Length % stat.BlockSize); + stat.Blocks = _blockMapBytes.Length / stat.BlockSize + _blockMapBytes.Length % stat.BlockSize; stat.Length = _blockMapBytes.Length; } else if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 && _bootBlocks != null) { - stat.Blocks = (_bootBlocks.Length / stat.BlockSize) + (_bootBlocks.Length % stat.BlockSize); + stat.Blocks = _bootBlocks.Length / stat.BlockSize + _bootBlocks.Length % stat.BlockSize; stat.Length = _bootBlocks.Length; } else if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (_mdbBlocks.Length / stat.BlockSize) + (_mdbBlocks.Length % stat.BlockSize); + stat.Blocks = _mdbBlocks.Length / stat.BlockSize + _mdbBlocks.Length % stat.BlockSize; stat.Length = _mdbBlocks.Length; } else diff --git a/Aaru.Filesystems/AppleMFS/Info.cs b/Aaru.Filesystems/AppleMFS/Info.cs index 92e60ca44..c155a4c53 100644 --- a/Aaru.Filesystems/AppleMFS/Info.cs +++ b/Aaru.Filesystems/AppleMFS/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes; @@ -40,8 +42,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II public sealed partial class AppleMFS { @@ -56,14 +56,13 @@ public sealed partial class AppleMFS if(errno != ErrorNumber.NoError) return false; - ushort drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); + var drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, 0x000); return drSigWord == MFS_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? new MacRoman(); information = ""; @@ -100,7 +99,7 @@ public sealed partial class AppleMFS mdb.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbSector, 0x01E); mdb.drFreeBks = BigEndianBitConverter.ToUInt16(mdbSector, 0x022); mdb.drVNSiz = mdbSector[0x024]; - byte[] variableSize = new byte[mdb.drVNSiz + 1]; + var variableSize = new byte[mdb.drVNSiz + 1]; Array.Copy(mdbSector, 0x024, variableSize, 0, mdb.drVNSiz + 1); mdb.drVN = StringHandlers.PascalToString(variableSize, Encoding); diff --git a/Aaru.Filesystems/AppleMFS/Structs.cs b/Aaru.Filesystems/AppleMFS/Structs.cs index 45c142792..6f05b7efd 100644 --- a/Aaru.Filesystems/AppleMFS/Structs.cs +++ b/Aaru.Filesystems/AppleMFS/Structs.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.Diagnostics.CodeAnalysis; - #pragma warning disable 169 namespace Aaru.Filesystems; +using System; +using System.Diagnostics.CodeAnalysis; + // Information from Inside Macintosh Volume II [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "NotAccessedField.Local")] public sealed partial class AppleMFS @@ -79,7 +79,8 @@ public sealed partial class AppleMFS [Flags] enum FileFlags : byte { - Locked = 0x01, Used = 0x80 + Locked = 0x01, + Used = 0x80 } struct FileEntry diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index e49e121a6..22536da66 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II public sealed partial class AppleMFS { @@ -91,7 +91,7 @@ public sealed partial class AppleMFS _volMdb.drNxtFNum = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x01E); _volMdb.drFreeBks = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x022); _volMdb.drVNSiz = _mdbBlocks[0x024]; - byte[] variableSize = new byte[_volMdb.drVNSiz + 1]; + var variableSize = new byte[_volMdb.drVNSiz + 1]; Array.Copy(_mdbBlocks, 0x024, variableSize, 0, _volMdb.drVNSiz + 1); _volMdb.drVN = StringHandlers.PascalToString(variableSize, Encoding); @@ -100,11 +100,11 @@ public sealed partial class AppleMFS if(errno != ErrorNumber.NoError) return errno; - int bytesInBlockMap = (_volMdb.drNmAlBlks * 12 / 8) + (_volMdb.drNmAlBlks * 12 % 8); - int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; + int bytesInBlockMap = _volMdb.drNmAlBlks * 12 / 8 + _volMdb.drNmAlBlks * 12 % 8; + int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; - int sectorsInWholeMdb = (bytesInWholeMdb / (int)_device.Info.SectorSize) + - (bytesInWholeMdb % (int)_device.Info.SectorSize); + int sectorsInWholeMdb = bytesInWholeMdb / (int)_device.Info.SectorSize + + bytesInWholeMdb % (int)_device.Info.SectorSize; errno = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb, out byte[] wholeMdb); @@ -114,10 +114,10 @@ public sealed partial class AppleMFS _blockMapBytes = new byte[bytesInBlockMap]; Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, _blockMapBytes, 0, _blockMapBytes.Length); - int offset = 0; + var offset = 0; _blockMap = new uint[_volMdb.drNmAlBlks + 2 + 1]; - for(int i = 2; i < _volMdb.drNmAlBlks + 2; i += 8) + for(var i = 2; i < _volMdb.drNmAlBlks + 2; i += 8) { uint tmp1 = 0; uint tmp2 = 0; @@ -178,7 +178,7 @@ public sealed partial class AppleMFS _mounted = true; - ushort bbSig = BigEndianBitConverter.ToUInt16(_bootBlocks, 0x000); + var bbSig = BigEndianBitConverter.ToUInt16(_bootBlocks, 0x000); if(bbSig != AppleCommon.BB_MAGIC) _bootBlocks = null; diff --git a/Aaru.Filesystems/AppleMFS/Xattr.cs b/Aaru.Filesystems/AppleMFS/Xattr.cs index 0a278bc56..c87f5f986 100644 --- a/Aaru.Filesystems/AppleMFS/Xattr.cs +++ b/Aaru.Filesystems/AppleMFS/Xattr.cs @@ -31,14 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; -namespace Aaru.Filesystems; - // Information from Inside Macintosh Volume II public sealed partial class AppleMFS { diff --git a/Aaru.Filesystems/AtheOS.cs b/Aaru.Filesystems/AtheOS.cs index f806e6a0e..b6f84d586 100644 --- a/Aaru.Filesystems/AtheOS.cs +++ b/Aaru.Filesystems/AtheOS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection for the AtheOS filesystem [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -86,21 +86,20 @@ public sealed class AtheOS : IFilesystem if(errno != ErrorNumber.NoError) return false; - byte[] sbSector = new byte[AFS_SUPERBLOCK_SIZE]; + var sbSector = new byte[AFS_SUPERBLOCK_SIZE]; if(offset + AFS_SUPERBLOCK_SIZE > tmp.Length) return false; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); - uint magic = BitConverter.ToUInt32(sbSector, 0x20); + var magic = BitConverter.ToUInt32(sbSector, 0x20); return magic == AFS_MAGIC1; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -119,7 +118,7 @@ public sealed class AtheOS : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] sbSector = new byte[AFS_SUPERBLOCK_SIZE]; + var sbSector = new byte[AFS_SUPERBLOCK_SIZE]; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); SuperBlock afsSb = Marshal.ByteArrayToStructureLittleEndian(sbSector); @@ -149,8 +148,8 @@ public sealed class AtheOS : IFilesystem afsSb.log_blocks_start, afsSb.log_blocks_ag, afsSb.log_blocks_len, afsSb.log_blocks_len * afsSb.block_size).AppendLine(); - sb.AppendFormat("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("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("Root folder's i-node resides in block {0} of allocation group {1} and runs for {2} blocks ({3} bytes)", @@ -167,8 +166,8 @@ public sealed class AtheOS : IFilesystem afsSb.indices_start, afsSb.indices_ag, afsSb.indices_len, afsSb.indices_len * afsSb.block_size).AppendLine(); - sb.AppendFormat("{0} blocks for bootloader ({1} bytes)", afsSb.boot_size, - afsSb.boot_size * afsSb.block_size).AppendLine(); + sb.AppendFormat("{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.cs b/Aaru.Filesystems/BFS.cs index a94b10f34..c482901fd 100644 --- a/Aaru.Filesystems/BFS.cs +++ b/Aaru.Filesystems/BFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from Practical Filesystem Design, ISBN 1-55860-497-9 /// /// Implements detection of the Be (new) filesystem @@ -85,8 +85,8 @@ public sealed class BeFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(sbSector, 0x20); - uint magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); + var magic = BitConverter.ToUInt32(sbSector, 0x20); + var magicBe = BigEndianBitConverter.ToUInt32(sbSector, 0x20); if(magic == BEFS_MAGIC1 || magicBe == BEFS_MAGIC1) @@ -114,8 +114,7 @@ public sealed class BeFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -189,8 +188,7 @@ public sealed class BeFS : IFilesystem sb.AppendFormat("Magic 2: 0x{0:X8} (Should be 0xDD121031)", besb.magic2).AppendLine(); sb.AppendFormat("Magic 3: 0x{0:X8} (Should be 0x15B6830E)", besb.magic3).AppendLine(); - sb.AppendFormat("Filesystem endianness: 0x{0:X8} (Should be 0x42494745)", besb.fs_byte_order). - AppendLine(); + sb.AppendFormat("Filesystem endianness: 0x{0:X8} (Should be 0x42494745)", besb.fs_byte_order).AppendLine(); sb.AppendFormat("Root folder's i-node size: {0} blocks (Should be 1)", besb.root_dir_len).AppendLine(); sb.AppendFormat("Indices' i-node size: {0} blocks (Should be 1)", besb.indices_len).AppendLine(); @@ -235,13 +233,12 @@ public sealed class BeFS : IFilesystem besb.log_blocks_start, besb.log_blocks_ag, besb.log_blocks_len, besb.log_blocks_len * besb.block_size).AppendLine(); - sb.AppendFormat("Journal starts in byte {0} and ends in byte {1}", besb.log_start, besb.log_end). - AppendLine(); + sb.AppendFormat("Journal starts in byte {0} and ends in byte {1}", besb.log_start, besb.log_end).AppendLine(); sb. AppendFormat("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(); + besb.root_dir_start, besb.root_dir_ag, besb.root_dir_len, besb.root_dir_len * besb.block_size). + AppendLine(); sb. AppendFormat("Indices' i-node resides in block {0} of allocation group {1} and runs for {2} blocks ({3} bytes)", diff --git a/Aaru.Filesystems/BTRFS.cs b/Aaru.Filesystems/BTRFS.cs index 10a0172bc..b4180ea1a 100644 --- a/Aaru.Filesystems/BTRFS.cs +++ b/Aaru.Filesystems/BTRFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Console; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the b-tree filesystem (btrfs) public sealed class BTRFS : IFilesystem @@ -97,8 +97,7 @@ public sealed class BTRFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); var sbInformation = new StringBuilder(); @@ -160,21 +159,18 @@ public sealed class BTRFS : IFilesystem AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.type = {0}", btrfsSb.dev_item.type); - AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.generation = {0}", - btrfsSb.dev_item.generation); + AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.generation = {0}", btrfsSb.dev_item.generation); AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.start_offset = {0}", btrfsSb.dev_item.start_offset); AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.dev_group = {0}", btrfsSb.dev_item.dev_group); - AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.seek_speed = {0}", - btrfsSb.dev_item.seek_speed); + AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.seek_speed = {0}", btrfsSb.dev_item.seek_speed); AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.bandwitdh = {0}", btrfsSb.dev_item.bandwitdh); - AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.device_uuid = {0}", - btrfsSb.dev_item.device_uuid); + AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.device_uuid = {0}", btrfsSb.dev_item.device_uuid); AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.dev_item.uuid = {0}", btrfsSb.dev_item.uuid); AaruConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.label = {0}", btrfsSb.label); @@ -214,7 +210,7 @@ public sealed class BTRFS : IFilesystem Type = Name }; - XmlFsType.FreeClusters = XmlFsType.Clusters - (btrfsSb.bytes_used / btrfsSb.sectorsize); + XmlFsType.FreeClusters = XmlFsType.Clusters - btrfsSb.bytes_used / btrfsSb.sectorsize; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/CBM.cs b/Aaru.Filesystems/CBM.cs index 3b13672ce..dcfadc1f2 100644 --- a/Aaru.Filesystems/CBM.cs +++ b/Aaru.Filesystems/CBM.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -42,8 +44,6 @@ using Schemas; using Encoding = System.Text.Encoding; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the filesystem used in 8-bit Commodore microcomputers public sealed class CBM : IFilesystem @@ -110,8 +110,7 @@ public sealed class CBM : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = new PETSCII(); information = ""; @@ -157,8 +156,7 @@ public sealed class CBM : IFilesystem sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine(); - sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, Encoding)).AppendLine(); XmlFsType.VolumeName = StringHandlers.CToString(cbmHdr.name, Encoding); XmlFsType.VolumeSerial = $"{cbmHdr.diskId}"; @@ -176,8 +174,7 @@ public sealed class CBM : IFilesystem cbmBam.directorySector).AppendLine(); sbInformation.AppendFormat("Disk DOS type: {0}", - Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType))). - AppendLine(); + Encoding.ASCII.GetString(BitConverter.GetBytes(cbmBam.dosType))).AppendLine(); sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new[] { @@ -186,8 +183,7 @@ public sealed class CBM : IFilesystem sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine(); - sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, Encoding)).AppendLine(); XmlFsType.VolumeName = StringHandlers.CToString(cbmBam.name, Encoding); XmlFsType.VolumeSerial = $"{cbmBam.diskId}"; diff --git a/Aaru.Filesystems/CPM/CPM.cs b/Aaru.Filesystems/CPM/CPM.cs index e62982bd6..f9b8e3090 100644 --- a/Aaru.Filesystems/CPM/CPM.cs +++ b/Aaru.Filesystems/CPM/CPM.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements the CP/M filesystem public sealed partial class CPM : IReadOnlyFilesystem diff --git a/Aaru.Filesystems/CPM/Definitions.cs b/Aaru.Filesystems/CPM/Definitions.cs index 990de5281..6a05fe291 100644 --- a/Aaru.Filesystems/CPM/Definitions.cs +++ b/Aaru.Filesystems/CPM/Definitions.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -38,8 +40,6 @@ using System.Reflection; using System.Xml; using System.Xml.Serialization; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// Loads all the known CP/M disk definitions from an XML stored as an embedded resource. @@ -67,7 +67,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(int i = 0; i < def.sectorsPerTrack; i++) + for(var i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; } @@ -82,7 +82,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(int i = 0; i < def.sectorsPerTrack; i++) + for(var i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; } } diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index d5afbb0f8..ef072e81e 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -30,15 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// @@ -72,20 +71,20 @@ public sealed partial class CPM if(directory == null) return false; - int fileCount = 0; + var fileCount = 0; - for(int off = 0; off < directory.Length; off += 32) + for(var off = 0; off < directory.Length; off += 32) { DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(directory, off, 32); if((entry.statusUser & 0x7F) < 0x20) { - for(int f = 0; f < 8; f++) + for(var f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(int e = 0; e < 3; e++) + for(var e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; @@ -95,12 +94,12 @@ public sealed partial class CPM } else if(entry.statusUser == 0x20) { - for(int f = 0; f < 8; f++) + for(var f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(int e = 0; e < 3; e++) + for(var e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; diff --git a/Aaru.Filesystems/CPM/File.cs b/Aaru.Filesystems/CPM/File.cs index ebdfa3991..b858b4203 100644 --- a/Aaru.Filesystems/CPM/File.cs +++ b/Aaru.Filesystems/CPM/File.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index 0f5781c38..a09779f67 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.IO; using System.Linq; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// @@ -179,11 +179,11 @@ public sealed partial class CPM if(errno == ErrorNumber.NoError) { - int amsSbOffset = 0; + var amsSbOffset = 0; - uint sig1 = BitConverter.ToUInt32(sector, 0x2B); + var sig1 = BitConverter.ToUInt32(sector, 0x2B); uint sig2 = BitConverter.ToUInt32(sector, 0x33) & 0x00FFFFFF; - uint sig3 = BitConverter.ToUInt32(sector, 0x7C); + var sig3 = BitConverter.ToUInt32(sector, 0x7C); // PCW16 extended boot record if(sig1 == 0x4D2F5043 && @@ -196,13 +196,13 @@ public sealed partial class CPM Marshal.ByteArrayToStructureLittleEndian(sector, amsSbOffset, 16); // Check that format byte and sidedness indicate the same number of sizes - if((amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0) || - (amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1) || - (amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2)) + if(amsSb.format == 0 && (amsSb.sidedness & 0x02) == 0 || + amsSb.format == 2 && (amsSb.sidedness & 0x02) == 1 || + amsSb.format == 2 && (amsSb.sidedness & 0x02) == 2) { // Calculate device limits - ulong sides = (ulong)(amsSb.format == 0 ? 1 : 2); - ulong sectorCount = (ulong)(amsSb.tps * amsSb.spt * (byte)sides); + var sides = (ulong)(amsSb.format == 0 ? 1 : 2); + var sectorCount = (ulong)(amsSb.tps * amsSb.spt * (byte)sides); sectorSize = (ulong)(128 << amsSb.psh); // Compare device limits from superblock to real limits @@ -220,7 +220,7 @@ public sealed partial class CPM bsh = amsSb.bsh }; - for(int i = 0; i < _dpb.bsh; i++) + for(var i = 0; i < _dpb.bsh; i++) _dpb.blm += (byte)Math.Pow(2, i); if(sectorCount >= 1440) @@ -239,11 +239,11 @@ public sealed partial class CPM _dpb.off = amsSb.off; _dpb.psh = amsSb.psh; - for(int i = 0; i < _dpb.psh; i++) + for(var i = 0; i < _dpb.psh; i++) _dpb.phm += (byte)Math.Pow(2, i); - _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); - uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); + _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); + var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); errno = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength, out directory); @@ -274,7 +274,7 @@ public sealed partial class CPM } }; - for(int si = 0; si < amsSb.spt; si++) + for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side1.sectorIds[si] = si + 1; if(amsSb.format == 2) @@ -301,7 +301,7 @@ public sealed partial class CPM sectorIds = new int[amsSb.spt] }; - for(int si = 0; si < amsSb.spt; si++) + for(var si = 0; si < amsSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } else @@ -327,7 +327,7 @@ public sealed partial class CPM ushort sum = 0; // Sum of all 16-bit words that make this sector must be 0 - for(int i = 0; i < sector.Length; i += 2) + for(var i = 0; i < sector.Length; i += 2) sum += BitConverter.ToUInt16(sector, i); // It may happen that there is a corrupted superblock @@ -335,15 +335,14 @@ public sealed partial class CPM if(sum == 0) { // Read the superblock - HardDiskSuperBlock hddSb = - Marshal.ByteArrayToStructureLittleEndian(sector); + HardDiskSuperBlock hddSb = Marshal.ByteArrayToStructureLittleEndian(sector); // Calculate volume size sectorSize = (ulong)(hddSb.recordsPerSector * 128); - ulong sectorsInPartition = (ulong)(hddSb.cylinders * hddSb.heads * hddSb.sectorsPerTrack); + var sectorsInPartition = (ulong)(hddSb.cylinders * hddSb.heads * hddSb.sectorsPerTrack); - ulong startingSector = - (ulong)(((hddSb.firstCylinder * hddSb.heads) + hddSb.heads) * hddSb.sectorsPerTrack); + var startingSector = + (ulong)((hddSb.firstCylinder * hddSb.heads + hddSb.heads) * hddSb.sectorsPerTrack); // If volume size corresponds with working partition (this variant will be inside MBR partitioning) if(sectorSize == imagePlugin.Info.SectorSize && @@ -374,7 +373,7 @@ public sealed partial class CPM spt = hddSb.spt }; - uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); + var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / sectorSize); errno = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength, out directory); @@ -415,10 +414,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < hddSb.sectorsPerTrack; si++) + for(var si = 0; si < hddSb.sectorsPerTrack; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < hddSb.spt; si++) + for(var si = 0; si < hddSb.spt; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } } @@ -505,7 +504,7 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 8; si++) + for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1; } @@ -566,10 +565,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 8; si++) + for(var si = 0; si < 8; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 8; si++) + for(var si = 0; si < 8; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -632,10 +631,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -697,10 +696,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -761,10 +760,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 9; si++) + for(var si = 0; si < 9; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -825,10 +824,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 15; si++) + for(var si = 0; si < 15; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 15; si++) + for(var si = 0; si < 15; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -889,10 +888,10 @@ public sealed partial class CPM sofs = 0 }; - for(int si = 0; si < 18; si++) + for(var si = 0; si < 18; si++) _workingDefinition.side1.sectorIds[si] = si + 1; - for(int si = 0; si < 18; si++) + for(var si = 0; si < 18; si++) _workingDefinition.side2.sectorIds[si] = si + 1; } @@ -901,7 +900,7 @@ public sealed partial class CPM if(_cpmFound) { - uint directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize); + var directoryLength = (uint)(((ulong)_dpb.drm + 1) * 32 / imagePlugin.Info.SectorSize); errno = imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength, out directory); @@ -956,7 +955,7 @@ public sealed partial class CPM { _sectorMask = new int[def.side1.sectorIds.Length]; - for(int m = 0; m < _sectorMask.Length; m++) + for(var m = 0; m < _sectorMask.Length; m++) _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; } else @@ -966,28 +965,27 @@ public sealed partial class CPM { _sectorMask = new int[def.side1.sectorIds.Length + def.side2.sectorIds.Length]; - for(int m = 0; m < def.side1.sectorIds.Length; m++) + for(var m = 0; m < def.side1.sectorIds.Length; m++) _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; // Skip first track (first side) - for(int m = 0; m < def.side2.sectorIds.Length; m++) + for(var m = 0; m < def.side2.sectorIds.Length; m++) _sectorMask[m + def.side1.sectorIds.Length] = - def.side2.sectorIds[m] - def.side2.sectorIds[0] + - def.side1.sectorIds.Length; + def.side2.sectorIds[m] - def.side2.sectorIds[0] + def.side1.sectorIds.Length; } // Head changes after whole side else if(string.Compare(def.order, "CYLINDERS", StringComparison.InvariantCultureIgnoreCase) == 0) { - for(int m = 0; m < def.side1.sectorIds.Length; m++) + for(var m = 0; m < def.side1.sectorIds.Length; m++) _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; // Skip first track (first side) and first track (second side) - for(int m = 0; m < def.side1.sectorIds.Length; m++) + for(var m = 0; m < def.side1.sectorIds.Length; m++) _sectorMask[m + def.side1.sectorIds.Length] = - def.side1.sectorIds[m] - def.side1.sectorIds[0] + - def.side1.sectorIds.Length + def.side2.sectorIds.Length; + def.side1.sectorIds[m] - def.side1.sectorIds[0] + def.side1.sectorIds.Length + + def.side2.sectorIds.Length; } // TODO: Implement COLUMBIA ordering @@ -1001,8 +999,8 @@ public sealed partial class CPM } // TODO: Implement EAGLE ordering - else if(string.Compare(def.order, "EAGLE", - StringComparison.InvariantCultureIgnoreCase) == 0) + else if(string.Compare(def.order, "EAGLE", StringComparison.InvariantCultureIgnoreCase) == + 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle EAGLE ordering, not proceeding with this definition."); @@ -1022,11 +1020,11 @@ public sealed partial class CPM // Read the directory marked by this definition var ms = new MemoryStream(); - for(int p = 0; p < dirLen; p++) + 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]), + ReadSector((ulong)((int)offset + (int)partition.Start + p / _sectorMask.Length * _sectorMask.Length + _sectorMask[p % _sectorMask.Length]), out byte[] dirSector); if(errno != ErrorNumber.NoError) @@ -1043,7 +1041,7 @@ public sealed partial class CPM // Complement of the directory bytes if needed if(def.complement) - for(int b = 0; b < directory.Length; b++) + for(var b = 0; b < directory.Length; b++) directory[b] = (byte)(~directory[b] & 0xFF); // Check the directory @@ -1151,8 +1149,7 @@ public sealed partial class CPM } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("IBM437"); information = ""; diff --git a/Aaru.Filesystems/CPM/Structs.cs b/Aaru.Filesystems/CPM/Structs.cs index 80339a4c4..743ec2488 100644 --- a/Aaru.Filesystems/CPM/Structs.cs +++ b/Aaru.Filesystems/CPM/Structs.cs @@ -30,13 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + // ReSharper disable NotAccessedField.Local namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + public sealed partial class CPM { /// Most of the times this structure is hard wired or generated by CP/M, not stored on disk diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index 133d31ebb..a3a7bb780 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -32,6 +32,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -47,8 +49,6 @@ using Schemas; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; using FileSystemInfo = Aaru.CommonTypes.Structs.FileSystemInfo; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// @@ -70,7 +70,7 @@ public sealed partial class CPM { _sectorMask = new int[_workingDefinition.side1.sectorIds.Length]; - for(int m = 0; m < _sectorMask.Length; m++) + for(var m = 0; m < _sectorMask.Length; m++) _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; } else @@ -81,11 +81,11 @@ public sealed partial class CPM _sectorMask = new int[_workingDefinition.side1.sectorIds.Length + _workingDefinition.side2.sectorIds.Length]; - for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; // Skip first track (first side) - for(int m = 0; m < _workingDefinition.side2.sectorIds.Length; m++) + for(var m = 0; m < _workingDefinition.side2.sectorIds.Length; m++) _sectorMask[m + _workingDefinition.side1.sectorIds.Length] = _workingDefinition.side2.sectorIds[m] - _workingDefinition.side2.sectorIds[0] + _workingDefinition.side1.sectorIds.Length; @@ -95,11 +95,11 @@ public sealed partial class CPM else if(string.Compare(_workingDefinition.order, "CYLINDERS", StringComparison.InvariantCultureIgnoreCase) == 0) { - for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; // Skip first track (first side) and first track (second side) - for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + for(var m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) _sectorMask[m + _workingDefinition.side1.sectorIds.Length] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0] + _workingDefinition.side1.sectorIds.Length + _workingDefinition.side2.sectorIds.Length; @@ -111,8 +111,8 @@ public sealed partial class CPM } // TODO: Implement COLUMBIA ordering - else if(string.Compare(_workingDefinition.order, "COLUMBIA", - StringComparison.InvariantCultureIgnoreCase) == 0) + else if(string.Compare(_workingDefinition.order, "COLUMBIA", StringComparison.InvariantCultureIgnoreCase) == + 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle COLUMBIA ordering, not proceeding with this definition."); @@ -121,8 +121,7 @@ public sealed partial class CPM } // TODO: Implement EAGLE ordering - else if(string.Compare(_workingDefinition.order, "EAGLE", - StringComparison.InvariantCultureIgnoreCase) == 0) + else if(string.Compare(_workingDefinition.order, "EAGLE", StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle EAGLE ordering, not proceeding with this definition."); @@ -147,18 +146,17 @@ public sealed partial class CPM { AaruConsole.DebugWriteLine("CP/M Plugin", "Deinterleaving whole volume."); - for(int p = 0; p <= (int)(partition.End - partition.Start); p++) + 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]), - out byte[] readSector); + _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(_workingDefinition.complement) - for(int b = 0; b < readSector.Length; b++) + for(var b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); deinterleavedSectors.Add((ulong)p, readSector); @@ -168,7 +166,7 @@ public sealed partial class CPM int blockSize = 128 << _dpb.bsh; var blockMs = new MemoryStream(); ulong blockNo = 0; - int sectorsPerBlock = 0; + var sectorsPerBlock = 0; Dictionary allocationBlocks = new(); AaruConsole.DebugWriteLine("CP/M Plugin", "Creating allocation blocks."); @@ -180,9 +178,9 @@ public sealed partial class CPM // May it happen? Just in case, CP/M blocks are smaller than physical sectors if(sector.Length > blockSize) - for(int i = 0; i < sector.Length / blockSize; i++) + for(var i = 0; i < sector.Length / blockSize; i++) { - byte[] tmp = new byte[blockSize]; + var tmp = new byte[blockSize]; Array.Copy(sector, blockSize * i, tmp, 0, blockSize); allocationBlocks.Add(blockNo++, tmp); } @@ -219,7 +217,7 @@ public sealed partial class CPM // Read the whole directory blocks var dirMs = new MemoryStream(); - for(int d = 0; d < dirSectors; d++) + for(var d = 0; d < dirSectors; d++) { deinterleavedSectors.TryGetValue((ulong)(d + dirOff), out byte[] sector); dirMs.Write(sector, 0, sector.Length); @@ -230,7 +228,7 @@ public sealed partial class CPM if(directory == null) return ErrorNumber.InvalidArgument; - int dirCnt = 0; + var dirCnt = 0; string file1 = null; string file2 = null; string file3 = null; @@ -239,7 +237,7 @@ public sealed partial class CPM _statCache = new Dictionary(); _cpmStat = new FileSystemInfo(); - bool atime = false; + var atime = false; _dirList = new List(); _labelCreationDate = null; _labelUpdateDate = null; @@ -248,7 +246,7 @@ public sealed partial class CPM AaruConsole.DebugWriteLine("CP/M Plugin", "Traversing directory."); // For each directory entry - for(int dOff = 0; dOff < directory.Length; dOff += 32) + for(var dOff = 0; dOff < directory.Length; dOff += 32) // Describes a file (does not support PDOS entries with user >= 16, because they're identical to password entries if((directory[dOff] & 0x7F) < 0x10) @@ -264,15 +262,15 @@ public sealed partial class CPM //bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80; int user = entry.statusUser & 0x0F; - bool validEntry = true; + var validEntry = true; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { entry.filename[i] &= 0x7F; validEntry &= entry.filename[i] >= 0x20; } - for(int i = 0; i < 3; i++) + for(var i = 0; i < 3; i++) { entry.extension[i] &= 0x7F; validEntry &= entry.extension[i] >= 0x20; @@ -293,7 +291,7 @@ public sealed partial class CPM filename = filename.Replace('/', '\u2215'); - int entryNo = ((32 * entry.extentCounter) + entry.extentCounterHigh) / (_dpb.exm + 1); + int entryNo = (32 * entry.extentCounter + entry.extentCounterHigh) / (_dpb.exm + 1); // Do we have a stat for the file already? if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) @@ -375,15 +373,15 @@ public sealed partial class CPM //bool backed = (entry.filename[3] & 0x80) == 0x80 || (entry.extension[3] & 0x80) == 0x80; int user = entry.statusUser & 0x0F; - bool validEntry = true; + var validEntry = true; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { entry.filename[i] &= 0x7F; validEntry &= entry.filename[i] >= 0x20; } - for(int i = 0; i < 3; i++) + for(var i = 0; i < 3; i++) { entry.extension[i] &= 0x7F; validEntry &= entry.extension[i] >= 0x20; @@ -404,7 +402,7 @@ public sealed partial class CPM filename = filename.Replace('/', '\u2215'); - int entryNo = ((32 * entry.extentCounterHigh) + entry.extentCounter) / (_dpb.exm + 1); + int entryNo = (32 * entry.extentCounterHigh + entry.extentCounter) / (_dpb.exm + 1); // Do we have a stat for the file already? if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) @@ -483,10 +481,10 @@ public sealed partial class CPM int user = entry.userNumber & 0x0F; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) entry.filename[i] &= 0x7F; - for(int i = 0; i < 3; i++) + for(var i = 0; i < 3; i++) entry.extension[i] &= 0x7F; string filename = Encoding.ASCII.GetString(entry.filename).Trim(); @@ -506,7 +504,7 @@ public sealed partial class CPM _passwordCache.Remove(filename); // Copy whole password entry - byte[] tmp = new byte[32]; + var tmp = new byte[32]; Array.Copy(directory, dOff, tmp, 0, 32); _passwordCache.Add(filename, tmp); @@ -653,7 +651,7 @@ public sealed partial class CPM else fInfo = new FileEntryInfo(); - byte[] ctime = new byte[4]; + var ctime = new byte[4]; ctime[0] = trdPartyDateEntry.create1[0]; ctime[1] = trdPartyDateEntry.create1[1]; @@ -671,7 +669,7 @@ public sealed partial class CPM else fInfo = new FileEntryInfo(); - byte[] ctime = new byte[4]; + var ctime = new byte[4]; ctime[0] = trdPartyDateEntry.create2[0]; ctime[1] = trdPartyDateEntry.create2[1]; @@ -689,7 +687,7 @@ public sealed partial class CPM else fInfo = new FileEntryInfo(); - byte[] ctime = new byte[4]; + var ctime = new byte[4]; ctime[0] = trdPartyDateEntry.create3[0]; ctime[1] = trdPartyDateEntry.create3[1]; @@ -725,7 +723,7 @@ public sealed partial class CPM fInfo.Blocks = 0; if(fileExtents.TryGetValue(filename, out Dictionary> extents)) - for(int ex = 0; ex < extents.Count; ex++) + for(var ex = 0; ex < extents.Count; ex++) { if(!extents.TryGetValue(ex, out List alBlks)) continue; @@ -755,10 +753,10 @@ public sealed partial class CPM if(_passwordCache.Count > 0) foreach(KeyValuePair kvp in _passwordCache) { - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(kvp.Value, 16, tmp, 0, 8); - for(int t = 0; t < 8; t++) + for(var t = 0; t < 8; t++) tmp[t] ^= kvp.Value[13]; _decodedPasswordCache.Add(kvp.Key, tmp); diff --git a/Aaru.Filesystems/CPM/Xattr.cs b/Aaru.Filesystems/CPM/Xattr.cs index 2ee64a82f..fb8942689 100644 --- a/Aaru.Filesystems/CPM/Xattr.cs +++ b/Aaru.Filesystems/CPM/Xattr.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; -namespace Aaru.Filesystems; - public sealed partial class CPM { /// diff --git a/Aaru.Filesystems/CPM/cpmdefs.xml b/Aaru.Filesystems/CPM/cpmdefs.xml index faf52856a..8652cb0c7 100644 --- a/Aaru.Filesystems/CPM/cpmdefs.xml +++ b/Aaru.Filesystems/CPM/cpmdefs.xml @@ -1,21849 +1,21849 @@ - - - Generic CP/M - SSSD 8" - 128 x 26 - FM - HIGH - 77 - 1 - 26 - 128 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - 20 - 26 - 6 - 12 - 18 - 24 - 4 - 10 - 16 - 22 - - - - 3 - 7 - 0 - 242 - 63 - 192 - 0 - 2 - 0 - false - false - - - ABC-80 - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 8 - 15 - 6 - 13 - 4 - 11 - 2 - 9 - 16 - 7 - 14 - 5 - 12 - 3 - 10 - - - - 3 - 7 - 0 - 151 - 63 - 192 - 0 - 2 - 0 - false - false - - - A. B. Dick Magna III - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 0 - - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - - - SIDES - - 3 - 7 - 0 - 255 - 255 - 255 - 0 - 4 - 0 - false - false - - - Actrix (Access Matrix) - SSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Actrix (Access Matrix) - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 1 - 174 - 63 - 128 - 0 - 2 - 0 - false - false - - - Adler Textriter - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 3 - 7 - 0 - 159 - 31 - 128 - 0 - 0 - 0 - false - false - - - Advanced Digital Super 6 - SSDD 48 tpi 5.25" - 1024 x 4 - MFM - LOW - 40 - 1 - 4 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - - - - 4 - 15 - 0 - 77 - 63 - 128 - 0 - 1 - 0 - false - false - - - Advanced Digital Super 6 - DSDD 48 tpi 5.25" - 1024 x 4 - MFM - LOW - 40 - 2 - 4 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - - - - 0 - - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 0 - 155 - 127 - 192 - 0 - 2 - 0 - false - false - - - Advanced Digital Super 6 - DSDD 96 tpi 5.25" - 1024 x 4 - MFM - LOW - 80 - 2 - 4 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - - - - 1 - - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 0 - 300 - 127 - 192 - 0 - 2 - 0 - false - false - - - Advanced Digital Super 8 - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 608 - 255 - 240 - 0 - 2 - 0 - false - false - - - Advanced Digital TurboDOS 312K - DSDD 48 tpi 5.25" - 1024 x 4 - MFM - LOW - 40 - 2 - 4 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - - - - 0 - - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 1 - 155 - 127 - 192 - 0 - 2 - 0 - false - false - - - Advanced Digital TurboDOS 366K - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 182 - 127 - 192 - 0 - 6 - 0 - false - false - - - Advanced Controls - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 0 - 385 - 127 - 192 - 0 - 6 - 0 - false - false - - - Allen-Bradley Advisor+ - DSDD 3.5" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 318 - 127 - 192 - 0 - 0 - 1 - false - false - - - Alspa - SSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 1 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 4 - 15 - 0 - 300 - 127 - 192 - 0 - 2 - 0 - false - false - - - Altos - SSSD 8" - 128 x 26 - FM - HIGH - 77 - 1 - 26 - 128 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 3 - 7 - 0 - 242 - 63 - 192 - 0 - 2 - 0 - false - false - - - Altos - DSSD 8" - 128 x 26 - FM - HIGH - 77 - 2 - 26 - 128 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - 20 - 26 - 6 - 12 - 18 - 24 - 4 - 10 - 16 - 22 - - - - 1 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - 20 - 26 - 6 - 12 - 18 - 24 - 4 - 10 - 16 - 22 - - - SIDES - - 5 - 31 - 3 - 122 - 127 - 128 - 0 - 2 - 0 - false - false - - - Altos - SSDD 8" - 512 x 15 - MFM - HIGH - 77 - 1 - 15 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 5 - 31 - 3 - 139 - 127 - 128 - 0 - 2 - 0 - false - false - - - Altos - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - SIDES - - 5 - 31 - 1 - 284 - 255 - 192 - 0 - 2 - 0 - false - false - - - Altos Series 5 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 176 - 176 - 192 - 0 - 2 - 0 - false - false - - - Amigo - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 3 - 7 - 0 - 189 - 63 - 192 - 0 - 2 - 0 - false - false - - - Amigo - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 195 - 63 - 128 - 0 - 2 - 0 - false - false - - - Ampro - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 4 - 15 - 1 - 94 - 63 - 128 - 0 - 2 - 0 - false - false - - - Ampro - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - - 1 - - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Ampro - SSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 1 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Ampro - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 2 - - 0 - - 17 - 18 - 19 - 20 - 21 - - - - 1 - - 17 - 18 - 19 - 20 - 21 - - - SIDES - - 4 - 15 - 0 - 394 - 255 - 240 - 0 - 2 - 0 - false - false - - - Amstrad PCW 8256 - SSDD 48 tpi 3.00" - MFM - LOW - 40 - 1 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 175 - 63 - 192 - 0 - 1 - 0 - false - false - - - Amstrad PCW 8256 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 356 - 255 - 240 - 0 - 1 - 0 - false - false - - - Amstrad CPC464 - SSDD 48 tpi 5.25"/3" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 5 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 3 - 7 - 0 - 171 - 63 - 192 - 0 - 2 - 0 - false - false - - - Amstrad CPC464 - SSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 1 - 9 - 512 - 5 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 5 - 31 - 3 - 87 - 127 - 128 - 0 - 2 - 0 - false - false - - - Amstrad PCW 8512 - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 356 - 255 - 240 - 0 - 1 - 0 - false - false - - - Amstrad CPC 6128 - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 1 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - SIDES - - 4 - 15 - 1 - 175 - 127 - 192 - 0 - 2 - 0 - false - false - - - Amstrad CPC 6128 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 1 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - SIDES - - 5 - 31 - 3 - 175 - 127 - 128 - 0 - 2 - 0 - false - false - - - Amstrad CPC 6128 Side 1 - SSDD 3.5" / 3" - 512 x 9 - MFM - LOW - 80 - 1 - 9 - 512 - 0 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 180 - 63 - 192 - 0 - 0 - 0 - false - false - - - Amstrad CPC 6128 Side 2 - SSDD 3.5" / 3" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 180 - 63 - 192 - 0 - 80 - 0 - false - false - - - Amstrad PCW w/DU49, Moonstone XFORMAT - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 5 - 31 - 3 - 198 - 255 - 192 - 0 - 1 - 0 - false - false - - - Amstrad CPC 6128 Vortex - DSDD 3.5"/96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 178 - 127 - 128 - 0 - 2 - 0 - false - false - - - Archive I - SSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Archive II & III - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 1 - - 1 - 4 - 2 - 5 - 3 - - - SIDES - - 4 - 15 - 0 - 394 - 319 - 248 - 0 - 2 - 0 - false - true - - - Arisia - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 3 - 7 - 0 - 147 - 127 - 240 - 0 - 2 - 0 - false - false - - - Associate - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - SIDES - - 4 - 15 - 1 - 195 - 127 - 192 - 0 - 2 - 0 - false - false - - - Aster CT-80 - DSDD 96 tpi 5.25" - 1024 x 5, 3:1 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 0 - 394 - 127 - 192 - 0 - 4 - 0 - false - false - - - ATR-8000 - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 3 - 7 - 0 - 189 - 63 - 192 - 0 - 2 - 0 - false - false - - - ATR-8000 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - ATR-8000 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - EAGLE - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 2 - 0 - false - false - - - ATT-7700 - DSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 1 - - 17 - 19 - 21 - 23 - 25 - 27 - 29 - 31 - 18 - 20 - 22 - 24 - 26 - 28 - 30 - 32 - - - SIDES - - 4 - 15 - 0 - 316 - 127 - 192 - 0 - 2 - 0 - false - false - - - Avatar - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 1 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - CYLINDERS - - 4 - 15 - 1 - 191 - 127 - 192 - 0 - 3 - 0 - false - false - - - Barudan - DSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - SIDES - - 5 - 31 - 3 - 155 - 127 - 128 - 0 - 4 - 0 - false - false - - - Beehive - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Beehive Microbee - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - - 1 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Beehive Microbee - SSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 0 - - 0 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Microbee Systems - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 22 - 25 - 28 - 21 - 24 - 27 - 30 - 23 - 26 - 29 - - - - 0 - - 22 - 25 - 28 - 21 - 24 - 27 - 30 - 23 - 26 - 29 - - - SIDES - - 5 - 31 - 3 - 194 - 127 - 128 - 0 - 4 - 0 - false - false - - - Microbee Dreamdisk format - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - - 1 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 0 - 391 - 255 - 240 - 0 - 2 - 0 - false - false - - - Computer Bell - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 192 - 127 - 192 - 0 - 3 - 0 - false - false - - - Big Board (512 bytes/sector) - SSDD 8" - 512 x 15 - MFM - HIGH - 77 - 1 - 15 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 4 - 15 - 0 - 280 - 127 - 192 - 0 - 2 - 0 - false - false - - - Big Board (512 bytes/sector) - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - CYLINDERS - - 4 - 15 - 0 - 569 - 127 - 192 - 0 - 2 - 0 - false - false - - - Big Board SWP 1024 bytes/sector - SSDD 8" - 1024 x 9 - MFM - HIGH - 77 - 1 - 9 - 1024 - 0 - - 4 - 15 - 0 - 336 - 127 - 192 - 0 - 2 - 0 - false - false - - - Bitelex - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 3 - 7 - 0 - 131 - 95 - 224 - 0 - 2 - 0 - false - false - - - BMC IF800 Model 20 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 7 - 13 - 19 - 5 - 11 - 17 - 3 - 9 - 15 - - - - 1 - - 1 - 7 - 13 - 19 - 5 - 11 - 17 - 3 - 9 - 15 - - - SIDES - - 4 - 15 - 0 - 191 - 127 - 192 - 0 - 3 - 0 - false - false - - - Bondwell 12 - SSDD 48 tpi 5.25" - 256 x 10 - MFM - LOW - 40 - 1 - 18 - 256 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 4 - 15 - 1 - 84 - 127 - 192 - 0 - 2 - 0 - false - false - - - Bondwell 14 - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - EAGLE - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - Bondwell 2 - SSDD 3.5" - 256 x 18 - MFM - LOW - 80 - 1 - 18 - 256 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - BOSS TurboDOS - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 616 - 255 - 240 - 0 - 0 - 0 - false - false - - - BTI Systems - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - EAGLE - - 4 - 15 - 1 - 175 - 127 - 192 - 0 - 2 - 0 - false - false - - - Burr-Brown - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 10 - 2 - 11 - 3 - 12 - 4 - 13 - 5 - 14 - 6 - 15 - 7 - 16 - 8 - 17 - 9 - 18 - - - - 1 - - 1 - 10 - 2 - 11 - 3 - 12 - 4 - 13 - 5 - 14 - 6 - 15 - 7 - 16 - 8 - 17 - 9 - 18 - - - SIDES - - 4 - 15 - 1 - 170 - 63 - 128 - 0 - 4 - 0 - false - false - - - Cal-PC - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Cashcom 100 - DSDD 96 tpi 5.25" - 1024 x 4 - MFM - LOW - 80 - 2 - 4 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - - - - 1 - - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 0 - 303 - 127 - 192 - 0 - 2 - 0 - false - false - - - Commodore Business Machines 1581 drive - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 397 - 127 - 192 - 0 - 0 - 0 - false - false - - - CCS (256 bytes/sector) - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - - - - 0 - - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - - - SIDES - - 4 - 15 - 1 - 165 - 63 - 128 - 0 - 6 - 0 - false - false - - - CCS (512 bytes/sector) - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - - 0 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - SIDES - - 4 - 15 - 1 - 184 - 63 - 128 - 0 - 6 - 0 - false - false - - - CCS (1024 bytes/sector) - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 0 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 1 - 184 - 63 - 128 - 0 - 6 - 0 - false - false - - - CCS 8 - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - SIDES - - 6 - 63 - 7 - 149 - 127 - 128 - 0 - 4 - 0 - false - false - - - CCS 2442 - SSDD 8" - 512 x 15 - MFM - HIGH - 77 - 1 - 15 - 512 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - - - - 5 - 31 - 3 - 139 - 127 - 128 - 0 - 2 - 0 - false - false - - - CCS (1024 bytes alternate) - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 1 - 184 - 63 - 128 - 0 - 6 - 0 - false - false - - - CDC-110 Viking - DSDD 8" - 512 x 16 - MFM - HIGH - 77 - 2 - 16 - 512 - 0 - - 0 - - 0 - 4 - 8 - 12 - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - - - - 1 - - 0 - 4 - 8 - 12 - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - - - SIDES - - 4 - 15 - 0 - 608 - 255 - 240 - 0 - 2 - 0 - false - false - - - CDI-5000 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 1 - - 1 - 4 - 2 - 5 - 3 - - - SIDES - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - COLEX 850 - SSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - COLEX 850 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 1 - - 11 - 15 - 19 - 13 - 17 - 12 - 16 - 20 - 14 - 18 - - - SIDES - - 4 - 15 - 0 - 389 - 127 - 192 - 0 - 4 - 0 - false - false - - - CMC Supersystem 2 - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 391 - 127 - 192 - 0 - 3 - 0 - false - false - - - Coin - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - - - EAGLE - - 4 - 15 - 0 - 392 - 127 - 192 - 0 - 3 - 0 - false - false - - - Coleco ADAM, 40 track - SSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 1 - 8 - 512 - 0 - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - - 3 - 7 - 0 - 146 - 63 - 192 - 0 - 0 - 26 - false - false - - - Coleco ADAM, 254K - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - EAGLE - - 3 - 7 - 0 - 255 - 63 - 192 - 0 - 0 - 26 - false - false - - - Coleco ADAM, 320K - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - EAGLE - - 4 - 15 - 1 - 152 - 63 - 128 - 0 - 0 - 26 - false - false - - - Coleco ADAM, 720K - DSDD 3.5" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - - 0 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - SIDES - - 4 - 15 - 0 - 354 - 127 - 192 - 0 - 0 - 26 - false - false - - - Coleco ADAM, 360K - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 1 - 179 - 63 - 128 - 0 - 0 - 4 - false - false - - - Coleco ADAM, E&T PROM 720K - DSDD 3.5" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - - 1 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - SIDES - - 4 - 15 - 0 - 354 - 127 - 192 - 0 - 0 - 26 - false - false - - - Coleco ADAM, 720K - DSDD 3.5" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - - 0 - - 1 - 5 - 9 - 4 - 8 - 3 - 7 - 2 - 6 - - - SIDES - - 4 - 15 - 0 - 358 - 127 - 192 - 0 - 0 - 4 - false - false - - - Coleco ADAM, 1.44M - DSHD 3.5" - 512 x 18 - MFM - HIGH - 80 - 2 - 18 - 512 - 0 - - 0 - - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - - - - 1 - - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - - - SIDES - - 4 - 15 - 0 - 712 - 255 - 240 - 0 - 2 - 0 - false - false - - - Coleco Adam TDOS - DSDD 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - - 1 - - 1 - 6 - 3 - 8 - 5 - 2 - 7 - 4 - - - EAGLE - - 3 - 7 - 0 - 255 - 63 - 192 - 0 - 0 - 26 - false - false - - - Columbia Commander 964 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - COLUMBIA - - 4 - 15 - 1 - 190 - 63 - 128 - 0 - 2 - 0 - false - false - - - Columbia 1600 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - COLUMBIA - - 5 - 31 - 3 - 197 - 255 - 192 - 0 - 2 - 0 - false - false - - - Columbia M64 - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 3 - 7 - 0 - 190 - 127 - 240 - 0 - 2 - 0 - true - false - - - Compis - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 4 - 15 - 0 - 317 - 127 - 192 - 0 - 1 - 0 - false - false - - - Compugraphic MCS-5 - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 3 - 7 - 0 - 155 - 63 - 192 - 0 - 1 - 0 - false - false - - - Compustar Model 30 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 35 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - EAGLE - - 4 - 15 - 1 - 169 - 63 - 128 - 0 - 2 - 0 - true - false - - - Compupro (Viasyn) - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 0 - 389 - 255 - 240 - 0 - 4 - 0 - false - false - - - Compupro (Viasyn) 8/16 - SSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 1 - 8 - 1024 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - - 4 - 15 - 0 - 299 - 127 - 192 - 0 - 2 - 0 - false - false - - - Compupro (Viasyn) 8/16 - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - SIDES - - 4 - 15 - 0 - 599 - 255 - 240 - 0 - 4 - 0 - false - false - - - Compupro (Viasyn) - SSDD 8" - 512 x 15 - MFM - HIGH - 77 - 1 - 15 - 512 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - - - - 4 - 15 - 0 - 280 - 127 - 192 - 0 - 2 - 0 - false - false - - - Compupro (Viasyn) - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 0 - - 0 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - - 4 - 15 - 0 - 242 - 127 - 192 - 0 - 2 - 0 - false - false - - - Compupro (Viasyn) 256 bytes/sector - DSHD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - - 1 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - - 4 - 15 - 0 - 487 - 255 - 240 - 0 - 4 - 0 - false - false - - - CPT Phoenix CP/M - DSDD 3.5" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 0 - 355 - 255 - 240 - 0 - 2 - 0 - false - false - - - Cromemco CDOS - SSSD 48 tpi 5.25" - 128 x 18 - FM - LOW - 40 - 1 - 18 - 128 - 0 - - 0 - - 1 - 6 - 11 - 16 - 3 - 8 - 13 - 18 - 5 - 10 - 15 - 2 - 7 - 12 - 17 - 4 - 9 - 14 - - - - 3 - 7 - 0 - 82 - 63 - 192 - 0 - 3 - 0 - false - false - - - Cromemco CDOS - DSSD 48 tpi 5.25" - 128 x 18 - FM - LOW - 40 - 2 - 128 - 18 - 0 - - 0 - - 1 - 6 - 11 - 16 - 3 - 8 - 13 - 18 - 5 - 10 - 15 - 2 - 7 - 12 - 17 - 4 - 9 - 14 - - - - 1 - - 1 - 6 - 11 - 16 - 3 - 8 - 13 - 18 - 5 - 10 - 15 - 2 - 7 - 12 - 17 - 4 - 9 - 14 - - - SIDES - - 3 - 7 - 0 - 172 - 63 - 192 - 0 - 3 - 0 - false - false - - - Cromemco CDOS - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 3 - 7 - 0 - 189 - 63 - 192 - 0 - 2 - 0 - false - false - - - Cromemco CDOS - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 1 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - SIDES - - 4 - 15 - 0 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Cromemco CDOS - DSDD 8" - 512 x 16 - MFM - HIGH - 77 - 2 - 16 - 512 - 0 - - 0 - - 1 - 12 - 7 - 2 - 13 - 8 - 3 - 14 - 9 - 4 - 15 - 10 - 5 - 16 - 11 - 6 - - - - 1 - - 1 - 12 - 7 - 2 - 13 - 8 - 3 - 14 - 9 - 4 - 15 - 10 - 5 - 16 - 11 - 6 - - - SIDES - - 4 - 15 - 0 - 608 - 255 - 240 - 0 - 2 - 0 - false - false - - - Cromemco CP/M - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - - 4 - 15 - 1 - 94 - 127 - 192 - 0 - 2 - 0 - false - false - - - Cromemco CP/M - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - - 1 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Cykey - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - - 1 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - SIDES - - 4 - 15 - 1 - 153 - 63 - 192 - 0 - 3 - 0 - false - false - - - Datavue DV80 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 3 - - 0 - - 129 - 130 - 131 - 132 - 133 - 134 - 135 - 136 - 137 - 138 - - - - 1 - - 129 - 130 - 131 - 132 - 133 - 134 - 135 - 136 - 137 - 138 - - - SIDES - - 5 - 31 - 3 - 94 - 127 - 128 - 0 - 4 - 0 - false - false - - - Datavue DV80 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 3 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - 202 - - - - 1 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - 202 - - - SIDES - - 5 - 31 - 3 - 194 - 127 - 128 - 0 - 4 - 0 - false - false - - - Davidge - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 0 - 384 - 127 - 192 - 0 - 6 - 0 - false - false - - - DEC DECMate II - SSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 4 - 15 - 1 - 195 - 127 - 192 - 0 - 2 - 0 - false - false - - - DEC VT-180 - SSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Dictaphone 6000 CP/M - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - SIDES - - 4 - 15 - 0 - 352 - 127 - 192 - 0 - 3 - 0 - false - false - - - Dictaphone 6000 CP/M - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 0 - 345 - 319 - 248 - 0 - 6 - 0 - false - false - - - Digilog 2500 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 35 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - - - EAGLE - - 4 - 15 - 1 - 166 - 63 - 128 - 0 - 3 - 0 - false - false - - - Digilog 1500 - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - CYLINDERS - - 4 - 15 - 0 - 392 - 127 - 192 - 0 - 3 - 0 - false - false - - - Digitech 500 series - SSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 1 - 199 - 319 - 248 - 0 - 0 - 0 - false - false - - - Digitech 500 series - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 398 - 319 - 248 - 0 - 0 - 0 - false - false - - - Digital Group, TVC-80 FDC - SSDD 8" - 1024 x 9 - MFM - HIGH - 77 - 1 - 9 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 0 - 342 - 127 - 192 - 0 - 1 - 0 - false - false - - - Dimension 68000 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 195 - 63 - 128 - 0 - 2 - 0 - false - false - - - Direct 1025 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 152 - 127 - 192 - 0 - 3 - 0 - false - false - - - Discovery - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 313 - 127 - 192 - 0 - 3 - 0 - false - false - - - Duet CP/M - DSDD 96tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - SIDES - - 4 - 15 - 0 - 355 - 255 - 240 - 0 - 2 - 0 - false - false - - - Eagle I, II - SSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 4 - 15 - 1 - 194 - 191 - 224 - 0 - 2 - 0 - false - false - - - Eagle III, IV, V - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - EAGLE - - 4 - 15 - 0 - 394 - 191 - 224 - 0 - 2 - 0 - false - false - - - Electroglas/Xynetics - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 3 - EAGLE - - 4 - 15 - 1 - 158 - 63 - 128 - 0 - 1 - 0 - false - false - - - Electroglas/Xynetics - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 3 - SIDES - - 4 - 15 - 0 - 397 - 255 - 240 - 0 - 1 - 0 - false - false - - - Epson QX-10 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - Epson QX-10 (256 bytes/sector) - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 139 - 63 - 128 - 0 - 8 - 0 - false - false - - - Epson PX-10/8 - DSDD 3.5" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 1 - 139 - 63 - 128 - 0 - 8 - 0 - false - false - - - Epson QX-16 640K - DSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 304 - 127 - 192 - 0 - 8 - 0 - false - false - - - Epson QX-16 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 389 - 255 - 252 - 0 - 4 - 0 - false - false - - - Ericsson DTC - SSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 5 - 31 - 3 - 77 - 127 - 128 - 0 - 2 - 0 - false - false - - - Ericsson DTC - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 5 - 31 - 3 - 157 - 127 - 128 - 0 - 2 - 0 - false - false - - - Ericsson Step One - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 174 - 127 - 128 - 0 - 4 - 0 - false - false - - - Estimation Inc. EST101 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - EAGLE - - 4 - 15 - 0 - 394 - 255 - 240 - 0 - 2 - 0 - false - false - - - Everett/Charles Kryterion 165 - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 6 - 63 - 3 - 151 - 255 - 192 - 0 - 2 - 0 - false - false - - - Eureka A4 - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - - 1 - - 2 - 5 - 8 - 1 - 4 - 7 - 10 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 0 - 399 - 255 - 240 - 0 - 0 - 0 - false - false - - - Exidy Sorcerer - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 6 - 11 - 16 - 5 - 10 - 15 - 4 - 9 - 14 - 3 - 8 - 13 - 2 - 7 - 12 - - - - 4 - 15 - 0 - 76 - 63 - 192 - 0 - 0 - 33 - false - false - - - EXO - SSDD 8" - 512 x 16 - MFM - HIGH - 77 - 1 - 16 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 5 - 31 - 3 - 149 - 127 - 128 - 0 - 2 - 0 - false - false - - - EXO - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - SIDES - - 5 - 31 - 1 - 303 - 127 - 128 - 0 - 2 - 0 - false - false - - - Florida Graphics - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 2 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - SIDES - - 4 - 15 - 0 - 295 - 127 - 192 - 0 - 12 - 0 - false - false - - - Formula 1 - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 2 - 5 - 6 - 9 - 10 - 13 - 14 - 17 - 18 - 3 - 4 - 7 - 8 - 11 - 12 - 15 - 16 - - - - 1 - - 1 - 2 - 5 - 6 - 9 - 10 - 13 - 14 - 17 - 18 - 3 - 4 - 7 - 8 - 11 - 12 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 172 - 127 - 192 - 0 - 3 - 0 - false - false - - - Fujitsu Micro 8 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 151 - 127 - 192 - 0 - 4 - 0 - false - false - - - Future FX-20 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 4 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 5 - 31 - 3 - 196 - 95 - 128 - 0 - 2 - 0 - false - false - - - Gemini Galaxy - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - EAGLE - - 5 - 31 - 3 - 196 - 127 - 128 - 0 - 2 - 0 - false - false - - - Globe 101 - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 319 - 127 - 192 - 0 - 0 - 13 - false - false - - - Gnat System 10 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 35 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - SIDES - - 4 - 15 - 0 - 169 - 127 - 192 - 0 - 2 - 0 - false - false - - - Graco OM-5000 - DSHD 5.25" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 5 - 31 - 3 - 248 - 127 - 128 - 0 - 2 - 0 - false - false - - - Hagiwara HPU 801 CP/M 68K - DSDD 3.5" Special - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - SIDES - - 4 - 15 - 0 - 486 - 127 - 192 - 0 - 4 - 0 - false - false - - - Hazeltine - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 77 - 2 - 10 - 512 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 379 - 255 - 240 - 0 - 2 - 0 - false - false - - - HCL System 2 - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 388 - 255 - 240 - 0 - 4 - 0 - false - false - - - Heath H89, Magnolia CP/M - SSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 1 - 82 - 95 - 192 - 0 - 3 - 0 - false - false - - - Heath H89, Magnolia CP/M - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - CYLINDERS - - 4 - 15 - 1 - 172 - 95 - 192 - 0 - 3 - 0 - false - false - - - Heath H89, Magnolia CP/M - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - CYLINDERS - - 5 - 31 - 3 - 176 - 127 - 128 - 0 - 3 - 0 - false - false - - - Heurikon MLZ-91A - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 5 - 6 - 9 - 10 - 13 - 14 - 3 - 4 - 7 - 8 - 11 - 12 - 15 - 16 - - - - 1 - - 1 - 2 - 5 - 6 - 9 - 10 - 13 - 14 - 3 - 4 - 7 - 8 - 11 - 12 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 315 - 127 - 192 - 0 - 2 - 0 - false - false - - - Hewlett-Packard HP86/87/120/125 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - SIDES - - 3 - 7 - 0 - 251 - 127 - 240 - 0 - 3 - 0 - false - false - - - Hewlett Packard HP 125 - SSSD 8" - 256 x 16 - FM - HIGH - 66 - 1 - 16 - 256 - 6 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 3 - 7 - 0 - 251 - 127 - 240 - 0 - 3 - 0 - false - false - - - Hewlett Packard HP 125 - SSDD 3.5" - 256 x 16 - MFM - LOW - 66 - 1 - 16 - 256 - 6 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 3 - 7 - 0 - 251 - 127 - 240 - 0 - 3 - 0 - false - false - - - Hitachi HPC-6000 CP/M 68K - DSHD 1.2M 3.5" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - SIDES - - 5 - 31 - 3 - 242 - 127 - 128 - 0 - 4 - 0 - false - false - - - Hitachi R-1500 CP/M 68K - DSHD 1.2M 5.25" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - SIDES - - 4 - 15 - 0 - 494 - 127 - 192 - 0 - 2 - 0 - false - false - - - Strippit Houdaille Fab/V - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 4 - 15 - 0 - 174 - 63 - 128 - 0 - 1 - 0 - false - false - - - IBM PC, CP/M-86 - SSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 1 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 3 - 7 - 0 - 155 - 63 - 192 - 0 - 1 - 0 - false - false - - - IBM PC, CP/M-86 - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 4 - 15 - 1 - 157 - 63 - 128 - 0 - 1 - 0 - false - false - - - IBS Ultraframe Turbo DOS - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 397 - 255 - 240 - 0 - 0 - 0 - false - false - - - IBEX 7300 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 5 - 31 - 3 - 246 - 127 - 128 - 0 - 2 - 0 - false - false - - - IBEX 7301 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - 20 - 26 - 6 - 12 - 18 - 24 - 4 - 10 - 16 - 22 - - - - 1 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - 20 - 26 - 6 - 12 - 18 - 24 - 4 - 10 - 16 - 22 - - - SIDES - - 5 - 31 - 2 - 242 - 127 - 128 - 0 - 4 - 0 - false - false - - - ICL DRS 20 - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 6 - 11 - 16 - 5 - 10 - 15 - 4 - 9 - 14 - 3 - 8 - 13 - 2 - 7 - 12 - - - - 1 - - 1 - 6 - 11 - 16 - 5 - 10 - 15 - 4 - 9 - 14 - 3 - 8 - 13 - 2 - 7 - 12 - - - SIDES - - 5 - 31 - 3 - 158 - 255 - 192 - 0 - 2 - 0 - false - false - - - ICL DRS 300 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 350 - 127 - 192 - 0 - 4 - 0 - false - false - - - ICL Model 35/36 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 391 - 127 - 192 - 0 - 0 - 36 - false - false - - - IMS 5000 - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 9 - 2 - 10 - 3 - 11 - 4 - 12 - 5 - 13 - 6 - 14 - 7 - 15 - 8 - 16 - - - - 3 - 7 - 0 - 147 - 63 - 192 - 0 - 3 - 0 - false - false - - - IMS 5000 TurboDOS - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 390 - 127 - 192 - 0 - 4 - 0 - false - false - - - IMS 5000 TurboDOS - SSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 1 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 4 - 15 - 0 - 308 - 191 - 224 - 0 - 0 - 0 - false - false - - - IMS 5000 CP/M - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - - - CYLINDERS - - 4 - 15 - 0 - 395 - 255 - 240 - 0 - 2 - 0 - false - false - - - Intel iPDS 100 - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 307 - 255 - 240 - 0 - 6 - 0 - false - false - - - Intuit - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 3 - 7 - 0 - 190 - 127 - 240 - 0 - 2 - 0 - false - false - - - Insight Enterprises - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 155 - 63 - 128 - 0 - 2 - 0 - false - false - - - Ithaca Intersystems - SSDD 96 tpi 5.25" - 256 x 18 - MFM - LOW - 80 - 1 - 18 - 256 - 2 - - 0 - - 1 - 2 - 5 - 6 - 9 - 10 - 13 - 14 - 17 - 18 - 3 - 4 - 7 - 8 - 11 - 12 - 15 - 16 - - - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - Ithaca Intersystems - SSDD 8" - 512 x 15 - MFM - HIGH - 77 - 1 - 15 - 512 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - - - - 4 - 15 - 0 - 284 - 191 - 224 - 0 - 1 - 0 - false - false - - - Ithaca Intersystems - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - - - - 1 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - - - SIDES - - 5 - 31 - 1 - 284 - 255 - 192 - 0 - 1 - 0 - false - false - - - ITT 3030 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 35 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 3 - 7 - 0 - 247 - 63 - 192 - 0 - 4 - 0 - false - false - - - ITT 3030 - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 70 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 4 - 15 - 0 - 270 - 127 - 192 - 0 - 4 - 0 - false - false - - - Sel ITT 3030 - 70 Tracks 560 kB - 256 x 16 - MFM - LOW - 70 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - EAGLE - - 4 - 15 - 0 - 271 - 127 - 192 - 0 - 4 - 0 - false - false - - - Jonos - SSDD 3.5" - 512 x 9 - MFM - LOW - 70 - 1 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 1 - 152 - 63 - 128 - 0 - 2 - 0 - false - false - - - Kaypro II/2 - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 194 - 63 - 240 - 0 - 1 - 0 - false - false - - - Kaypro 2X/4/10 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 0 - - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - - - SIDES - - 4 - 15 - 1 - 196 - 63 - 192 - 0 - 1 - 0 - false - false - - - Kaypro 2X/4/10 (Alternate) - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - - - SIDES - - 4 - 15 - 1 - 196 - 63 - 192 - 0 - 1 - 0 - false - false - - - Kaypro, Pro-8 ROM - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 0 - - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - - - SIDES - - 5 - 31 - 3 - 196 - 95 - 128 - 0 - 2 - 0 - false - false - - - Kaypro Advent TurboROM - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 11 - 12 - 13 - 14 - 15 - - - SIDES - - 4 - 15 - 1 - 195 - 255 - 240 - 0 - 2 - 0 - false - false - - - Kaypro Advent TurboROM - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 3 - 7 - 0 - 185 - 31 - 192 - 0 - 3 - 0 - false - false - - - Kaypro Advent TurboROM - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 21 - 22 - 23 - 24 - 25 - - - SIDES - - 4 - 15 - 0 - 395 - 255 - 240 - 0 - 2 - 0 - false - false - - - Kontron - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - - - CYLINDERS - - 4 - 15 - 0 - 489 - 255 - 240 - 0 - 3 - 0 - false - false - - - Kontron/Zeiss - DSDD 96 tpi 5.25" - 128 x 16 - FM - LOW - 35 - 2 - 16 - 128 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - CYLINDERS - - 3 - 7 - 0 - 106 - 63 - 192 - 0 - 17 - 0 - false - false - - - Kontron Transient Recorder- DSDD 96 tpi 5.25"/3.5" - 256 x 16 - MFM - LOW - 77 - 2 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - EAGLE - - 4 - 15 - 0 - 299 - 255 - 240 - 0 - 4 - 0 - false - false - - - Lanier LTD READ-ONLY - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 4 - 15 - 0 - 318 - 127 - 192 - 0 - 1 - 0 - false - false - - - Lexoriter - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 4 - 15 - 1 - 159 - 127 - 192 - 0 - 0 - 0 - false - false - - - Lobo Max-80 - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 3 - 7 - 0 - 165 - 63 - 192 - 0 - 3 - 0 - false - false - - - Lobo Max-80 (256) - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - SIDES - - 4 - 15 - 0 - 172 - 127 - 192 - 0 - 3 - 0 - false - false - - - Lobo Max-80 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 191 - 127 - 192 - 0 - 3 - 0 - false - false - - - Lobo Max-80 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 391 - 255 - 240 - 0 - 3 - 0 - false - false - - - Lobo CP/M 2.2 - SSHD 8" - 256 x 30 - MFM - HIGH - 77 - 1 - 30 - 256 - 3 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - - - - 4 - 15 - 0 - 280 - 127 - 192 - 0 - 2 - 0 - false - false - - - LNW 2 - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 0 - - 0 - - 1 - 6 - 11 - 16 - 3 - 8 - 13 - 18 - 5 - 10 - 15 - 2 - 7 - 12 - 17 - 4 - 9 - 14 - - - - 4 - 15 - 1 - 82 - 63 - 128 - 0 - 3 - 0 - false - false - - - Lockheed-Martin Wire Harness Tester - DSDD 3.5" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 1 - - 1 - 4 - 2 - 5 - 3 - - - SIDES - - 4 - 15 - 0 - 394 - 127 - 192 - 0 - 2 - 0 - false - false - - - Macsym 150 - SSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 1 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 4 - 15 - 1 - 155 - 127 - 192 - 0 - 2 - 0 - false - false - - - MAI Basic Four - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 312 - 127 - 192 - 0 - 3 - 0 - false - false - - - Marconi Midata 510 - DSDD 3.5" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 3 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - EAGLE - - 5 - 31 - 3 - 197 - 127 - 128 - 0 - 2 - 0 - false - false - - - Memotech MaxBP - DSDD 3.5" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 394 - 191 - 224 - 0 - 2 - 0 - false - false - - - Memotech FDX - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 156 - 63 - 128 - 0 - 0 - 26 - false - false - - - Micro Source M6000 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 0 - - 11 - 15 - 19 - 13 - 17 - 12 - 16 - 20 - 14 - 18 - - - SIDES - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - Michels and Kleberhoff CP/M 3 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - EAGLE - - 4 - 15 - 0 - 394 - 127 - 192 - 0 - 2 - 0 - true - false - - - Michels and Kleberhoff CP/M 3 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 35 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - CYLINDERS - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - true - false - - - MicroMint SB180 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - - - - 1 - - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - - - SIDES - - 4 - 15 - 1 - 200 - 127 - 192 - 0 - 0 - 0 - false - false - - - Molecular Series 9 - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 2 - SIDES - - 4 - 15 - 1 - 179 - 127 - 192 - 0 - 4 - 0 - false - false - - - Molecular/Durango Poppy 54 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 3 - - 0 - - 128 - 129 - 130 - 131 - 132 - 133 - 134 - 135 - 136 - 137 - - - - 1 - - 138 - 139 - 140 - 141 - 142 - 143 - 144 - 145 - 146 - 147 - - - SIDES - - 4 - 15 - 0 - 389 - 127 - 192 - 0 - 4 - 0 - false - false - - - Molecular - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 4 - 15 - 1 - 249 - 127 - 192 - 0 - 0 - 0 - false - false - - - Monroe 8800 Series - SSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - - 4 - 15 - 1 - 153 - 63 - 128 - 0 - 3 - 0 - false - false - - - Monroe System 2000 - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 315 - 127 - 192 - 0 - 2 - 0 - false - false - - - Morrow MD2 - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 4 - 15 - 1 - 94 - 127 - 192 - 0 - 2 - 0 - false - false - - - Morrow MD3, 5, 11, 16, 34 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 1 - - 1 - 4 - 2 - 5 - 3 - - - SIDES - - 4 - 15 - 1 - 194 - 191 - 224 - 0 - 2 - 0 - false - false - - - Morrow TurboDOS - DSDD 48 tpi 5.25" - 1024 x 4 - MFM - LOW - 40 - 2 - 4 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - - - - 1 - - 1 - 2 - 3 - 4 - - - SIDES - - 4 - 15 - 0 - 155 - 127 - 192 - 0 - 2 - 0 - false - false - - - Morrow MD3...CP/M Plus - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 1 - - 1 - 4 - 2 - 5 - 3 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Morrow 5/11/34 - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 4 - 2 - 5 - 3 - - - - 4 - 15 - 1 - 92 - 127 - 192 - 0 - 3 - 0 - false - false - - - MOS 80 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - - 1 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - SIDES - - 5 - 31 - 0 - 244 - 251 - 192 - 0 - 3 - 0 - false - false - - - Multitech MIC-540 - DSDD 96 tpi 5.25" - 256 x 18 - MFM - LOW - 80 - 2 - 18 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - SIDES - - 4 - 15 - 0 - 356 - 127 - 192 - 0 - 4 - 0 - false - false - - - MUPD/MDISK, Side I - SSSD 96 tpi 5.25" - 256 x 10 - FM - LOW - 80 - 1 - 10 - 256 - 0 - - 0 - - 0 - 2 - 4 - 6 - 8 - 1 - 3 - 5 - 7 - 9 - - - - 4 - 15 - 1 - 96 - 127 - 192 - 0 - 3 - 0 - false - false - - - MUPD/MDISK, Side II - SSSD 96 tpi 5.25" - 256 x 10 - FM - LOW - 80 - 2 - 10 - 256 - 0 - - 0 - - 0 - 2 - 4 - 6 - 8 - 1 - 3 - 5 - 7 - 9 - - - - 0 - - 0 - 2 - 4 - 6 - 8 - 1 - 3 - 5 - 7 - 9 - - - EAGLE - - 4 - 15 - 1 - 96 - 127 - 192 - 0 - 83 - 0 - false - false - - - MSD Systems PSC-1 POS - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 5 - 31 - 3 - 158 - 127 - 128 - 0 - 1 - 0 - false - false - - - NCHQ System II - SSSD 48tpi 5.25" - 128 x 18 - FM - LOW - 40 - 1 - 18 - 128 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 3 - 7 - 0 - 84 - 63 - 192 - 0 - 3 - 0 - false - false - - - NCR Decision Mate V - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - EAGLE - - 4 - 15 - 1 - 153 - 127 - 192 - 0 - 3 - 0 - false - false - - - NCR FirstStep - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 16 - 4 - 8 - 12 - 15 - 3 - 7 - 11 - 14 - 2 - 6 - 10 - - - - 1 - - 1 - 5 - 9 - 13 - 16 - 4 - 8 - 12 - 15 - 3 - 7 - 11 - 14 - 2 - 6 - 10 - - - SIDES - - 4 - 15 - 0 - 275 - 255 - 240 - 0 - 6 - 0 - false - false - - - NEC PC-8801A - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 6 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - SIDES - - 5 - 31 - 3 - 242 - 127 - 128 - 0 - 4 - 0 - false - false - - - NEC PC-8801A - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 6 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - - - SIDES - - 5 - 31 - 1 - 280 - 127 - 128 - 0 - 4 - 0 - false - false - - - NEC PC-8801A - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 599 - 255 - 240 - 0 - 4 - 0 - false - false - - - NEC PC-8001A - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 3 - 7 - 0 - 151 - 63 - 192 - 0 - 2 - 0 - false - false - - - NEC PC-8001B - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 151 - 63 - 128 - 0 - 2 - 0 - false - false - - - NEC PC 8801A - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 1 - 151 - 127 - 192 - 0 - 4 - 0 - false - false - - - NEC PC 8801A - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - NEC PC 8500/8431A, Starlet - DSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 4 - 15 - 1 - 151 - 127 - 192 - 0 - 4 - 0 - false - false - - - NEC APC CP/M-86 - DSHD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - - - - 4 - 15 - 0 - 494 - 255 - 240 - 0 - 2 - 0 - false - false - - - NEC APC TurboDOS - SSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 1 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 4 - 15 - 0 - 308 - 224 - 224 - 0 - 0 - 0 - false - false - - - New Brain - SSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 5 - 31 - 3 - 97 - 127 - 128 - 0 - 2 - 0 - false - false - - - Niat - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - - 1 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - CYLINDERS - - 5 - 31 - 3 - 157 - 127 - 128 - 0 - 2 - 0 - false - false - - - Nixdorf 8810/30 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 384 - 127 - 192 - 0 - 6 - 0 - false - false - - - Norsonic 830/836 - DSDD 3.5" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 199 - 127 - 192 - 0 - 0 - 0 - false - false - - - Numeridex 7000 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 1 - - 28 - 34 - 40 - 46 - 52 - 32 - 38 - 44 - 50 - 30 - 36 - 42 - 48 - - - SIDES - - 5 - 31 - 3 - 248 - 127 - 128 - 0 - 2 - 0 - false - false - - - Octagon 8/16 - SSDD 8" - 1024 x 9 - MFM - HIGH - 77 - 1 - 9 - 1024 - 3 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 5 - 31 - 1 - 167 - 127 - 128 - 0 - 2 - 0 - false - false - - - OEM Screen Typist - SSDD 3.5" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 1 - 94 - 63 - 128 - 0 - 2 - 0 - false - false - - - Olivetti ETV300 - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Olivetti M20 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 3 - 7 - 0 - 255 - 63 - 192 - 0 - 3 - 0 - false - false - - - Olivetti 250, CWP1 - SSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - SIDES - - 4 - 15 - 1 - 157 - 63 - 128 - 0 - 1 - 0 - false - false - - - Olivetti ETV 1010, CP/M 86 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 198 - 127 - 192 - 0 - 1 - 0 - false - false - - - Olivetti ETV 112 - SSDD 3.5" - 256 x 18 - MFM - LOW - 80 - 1 - 18 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 4 - 15 - 0 - 174 - 191 - 224 - 0 - 2 - 0 - false - false - - - Olympia EX-100 - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - Olympia ETX II - SSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 170 - 127 - 240 - 0 - 2 - 0 - false - false - - - Olympia Olytext 20 - DSDD 3.5" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 312 - 127 - 192 - 0 - 4 - 0 - false - false - - - Osborne 1 - SSSD 48 tpi 5.25" - 256 x 10 - FM - LOW - 40 - 1 - 10 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 4 - 15 - 1 - 45 - 63 - 128 - 0 - 3 - 0 - false - false - - - Osborne 1 - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 3 - 7 - 0 - 184 - 63 - 192 - 0 - 3 - 0 - false - false - - - Osborne G2 System - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - Osborne G2 System - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 389 - 255 - 240 - 0 - 4 - 0 - false - false - - - Osborne 1 + Osmosis - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - SIDES - - 4 - 15 - 0 - 384 - 127 - 192 - 0 - 6 - 0 - false - false - - - Osborne Nuevo - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 6 - 8 - 10 - 7 - 9 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Osborne Vixen - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Osborne Executive w/Z3 - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 0 - 395 - 127 - 248 - 0 - 2 - 0 - false - false - - - Osborne Executive Dig. Arts - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 248 - 0 - 2 - 0 - false - false - - - Osborne Nuevo 2.1 - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 394 - 255 - 240 - 0 - 2 - 0 - false - false - - - OSM Zeus 4 - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 311 - 127 - 192 - 0 - 4 - 0 - false - false - - - Otrona Attache - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - EAGLE - - 4 - 15 - 1 - 181 - 127 - 192 - 0 - 3 - 0 - false - false - - - Otrona Attache - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - CYLINDERS - - 4 - 15 - 0 - 386 - 127 - 192 - 0 - 3 - 0 - false - false - - - Potter & Brumfield - SSSD 48 tpi 5.25" - 128 x 18 - FM - LOW - 40 - 1 - 18 - 128 - 0 - - 0 - - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - - - - 3 - 7 - 0 - 83 - 63 - 192 - 0 - 3 - 0 - false - false - - - Pegasus Data Logger - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - 9 - - - SIDES - - 4 - 15 - 0 - 170 - 63 - 128 - 0 - 6 - 0 - false - false - - - People's World Computer - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - CYLINDERS - - 4 - 15 - 0 - 398 - 127 - 120 - 0 - 0 - 0 - false - false - - - People's World Computer Boot - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - CYLINDERS - - 4 - 15 - 0 - 397 - 127 - 240 - 0 - 0 - 0 - false - false - - - Pericom - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 0 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 0 - 395 - 127 - 192 - 0 - 2 - 0 - false - false - - - Philips PC-2010 - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 3 - 7 - 0 - 151 - 63 - 192 - 0 - 2 - 0 - false - false - - - Philips PC-2012 - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - SIDES - - 5 - 31 - 3 - 157 - 127 - 128 - 0 - 2 - 0 - false - false - - - Philips PC-3000 - 3004 - SSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 4 - 15 - 1 - 147 - 63 - 192 - 0 - 3 - 0 - false - false - - - Physical Acoutstics - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 3 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - CYLINDERS - - 4 - 15 - 1 - 173 - 127 - 192 - 0 - 3 - 0 - false - false - - - Pied Piper - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - SIDES - - 4 - 15 - 0 - 391 - 255 - 240 - 0 - 3 - 0 - false - false - - - Proglas 770K - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 388 - 255 - 240 - 0 - 2 - 0 - false - false - - - Pulsar LBB - SSHD 8" - 512 x 17 - MFM - HIGH - 77 - 1 - 17 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 2 - 5 - 8 - 11 - 14 - 17 - 3 - 6 - 9 - 12 - 15 - - - - 4 - 15 - 0 - 317 - 127 - 192 - 0 - 2 - 0 - false - false - - - Research Machines Limited 380Z - 128 x 16 - FM - LOW - 40 - 1 - 16 - 128 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 3 - 7 - 0 - 74 - 63 - 192 - 0 - 3 - 0 - false - false - - - Royal Alphatronic - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 151 - 127 - 192 - 0 - 4 - 0 - false - false - - - Sage IV - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 4 - 15 - 1 - 155 - 63 - 128 - 0 - 2 - 0 - false - false - - - Sage IV - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 315 - 63 - 128 - 0 - 2 - 0 - false - false - - - Sanyo MBC-1000, MBC-1150 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - SIDES - - 4 - 15 - 1 - 155 - 63 - 128 - 0 - 2 - 0 - false - false - - - Sanyo MBC-2000 - SSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 1 - 16 - 256 - 0 - - 0 - - 1 - 6 - 11 - 16 - 5 - 10 - 15 - 4 - 9 - 14 - 3 - 8 - 13 - 2 - 7 - 12 - - - - 4 - 15 - 1 - 152 - 63 - 128 - 0 - 4 - 0 - false - false - - - Sanyo MBC-3000 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 1 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - SIDES - - 5 - 31 - 3 - 237 - 127 - 128 - 0 - 4 - 0 - false - false - - - Sanco 8001 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - - 4 - 15 - 0 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - Schneider CPC 6128 Side 1 - DSDD 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 2 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 180 - 63 - 192 - 0 - 0 - 0 - false - false - - - Schneider CPC 6128 Side 2 - DSDD 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 180 - 63 - 192 - 0 - 40 - 0 - false - false - - - S.D. Systems 40 track - SSDD 3.5" - 256 x 18 - MFM - LOW - 80 - 1 - 18 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 4 - 15 - 0 - 84 - 127 - 192 - 0 - 2 - 0 - false - false - - - S.D. Systems 80 track - DSDD 3.5" - 256 x 18 - MFM - LOW - 80 - 2 - 18 - 256 - 0 - SIDES - - 5 - 31 - 0 - 176 - 127 - 128 - 0 - 2 - 0 - false - false - - - S.D. Systems 80 track - SSDD 5.25" - 256 x 18 - MFM - LOW - 80 - 1 - 18 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 4 - 15 - 0 - 175 - 127 - 192 - 0 - 2 - 0 - false - false - - - S.D. Systems - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 1 - - 0 - - 1 - 5 - 9 - 13 - 17 - 21 - 25 - 3 - 7 - 11 - 15 - 19 - 23 - 2 - 6 - 10 - 14 - 18 - 22 - 26 - - - - 4 - 15 - 1 - 240 - 127 - 192 - 0 - 3 - 0 - false - false - - - Seiko - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 315 - 127 - 192 - 0 - 2 - 0 - false - false - - - SemiDisk DT42 - DSHD 96 tpi 5.25" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 2 - 5 - 8 - 11 - 14 - 3 - 6 - 9 - 12 - 15 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 2 - 5 - 8 - 11 - 14 - 3 - 6 - 9 - 12 - 15 - - - SIDES - - 4 - 15 - 0 - 562 - 255 - 240 - 0 - 4 - 0 - false - false - - - Sharp MZ-80 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 1 - 169 - 127 - 192 - 0 - 2 - 0 - true - false - - - Sharp MZ-80B - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 1 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 1 - 195 - 127 - 192 - 0 - 2 - 0 - true - false - - - Sharp 3500/5500 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - SIDES - - 4 - 15 - 1 - 151 - 127 - 192 - 0 - 4 - 0 - false - false - - - Sharp 5600 - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - - - SIDES - - 4 - 15 - 0 - 312 - 127 - 192 - 0 - 4 - 0 - false - false - - - Sharp MZ 3541 - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Shelton SIG/NET 2 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - SIDES - - 4 - 15 - 1 - 195 - 63 - 128 - 0 - 2 - 0 - true - false - - - Shelton SIG/NET 2 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - SIDES - - 4 - 15 - 0 - 395 - 255 - 240 - 0 - 2 - 0 - true - false - - - Siemens PG-685 DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 350 - 255 - 240 - 0 - 4 - 0 - false - false - - - Siemens PG-675 DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 170 - 63 - 128 - 0 - 4 - 0 - false - false - - - Silver-Reed WP System - DSDD 3.5" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 3 - 5 - 2 - 4 - - - - 1 - - 1 - 3 - 5 - 2 - 4 - - - SIDES - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - Smart Aleck - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Sorbus TurboDOS - 5.25" DSHD (or 8" DSDD) - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 5 - 31 - 1 - 308 - 255 - 192 - 0 - 0 - 0 - false - false - - - Sony SMC-70 - SSDD 3.5" - 256 x 16 - MFM - LOW - 70 - 1 - 16 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 3 - 6 - 9 - 12 - 15 - 2 - 5 - 8 - 11 - 14 - - - - 4 - 15 - 1 - 135 - 127 - 192 - 0 - 2 - 0 - false - false - - - Spectravideo 318/328 - SSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 1 - 17 - 256 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 3 - 7 - 0 - 156 - 63 - 192 - 0 - 3 - 0 - false - false - - - Spectravideo SV-328 - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 2 - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - CYLINDERS - - 4 - 15 - 1 - 162 - 63 - 128 - 0 - 3 - 0 - false - false - - - Sperry UTS 30, UTS 5000 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 354 - 383 - 252 - 0 - 2 - 0 - false - false - - - Spectravideo - SSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 1 - 17 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 3 - 7 - 0 - 157 - 63 - 192 - 0 - 3 - 0 - false - false - - - Spectravideo - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - CYLINDERS - - 4 - 15 - 1 - 163 - 63 - 128 - 0 - 3 - 0 - false - false - - - Spectravideo - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 1 - 197 - 63 - 128 - 0 - 1 - 0 - false - false - - - Spectravideo - SSDD 3.5" - 512 x 9 - MFM - LOW - 80 - 1 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 1 - 163 - 63 - 128 - 0 - 3 - 0 - false - false - - - Superbrain JR - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 35 - 1 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 4 - 15 - 1 - 81 - 63 - 128 - 0 - 2 - 0 - true - false - - - Superbrain 40 track - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 4 - 15 - 1 - 94 - 63 - 128 - 0 - 2 - 0 - true - false - - - Superbrain QD - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 35 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - CYLINDERS - - 4 - 15 - 1 - 169 - 63 - 128 - 0 - 2 - 0 - true - false - - - Superbrain II - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - CYLINDERS - - 5 - 31 - 3 - 196 - 127 - 192 - 0 - 3 - 0 - true - false - - - Superbrain - SSDD 48 tpi 5.25" - 128 x 30 - MFM - LOW - 40 - 1 - 30 - 128 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 28 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - 29 - - - - 3 - 7 - 0 - 142 - 63 - 192 - 0 - 2 - 0 - true - false - - - System Group 2800 - DSDD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 5 - 31 - 1 - 303 - 255 - 192 - 0 - 2 - 0 - false - false - - - Tarbell - DSDD 8" - 512 x 15 - MFM - HIGH - 77 - 2 - 15 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 12 - 13 - 14 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 12 - 13 - 14 - - - SIDES - - 5 - 31 - 0 - 303 - 169 - 192 - 0 - 2 - 0 - false - false - - - Tatung TPC2000 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 3 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - EAGLE - - 4 - 15 - 0 - 354 - 127 - 192 - 0 - 2 - 0 - false - false - - - Techron TEF 10 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - - 1 - - 1 - 4 - 7 - 10 - 3 - 6 - 9 - 2 - 5 - 8 - - - SIDES - - 4 - 15 - 0 - 394 - 319 - 248 - 0 - 2 - 0 - false - false - - - Techron TEF 12 - DSHD 96 tpi 5.25" - 512 x 17 - MFM - HIGH - 80 - 2 - 17 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - SIDES - - 4 - 15 - 0 - 670 - 767 - 255 - 240 - 4 - 0 - false - false - - - Tektronix 4170 - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - CYLINDERS - - 4 - 15 - 0 - 153 - 63 - 128 - 0 - 1 - 0 - false - false - - - Teletek - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 4 - 15 - 1 - 242 - 127 - 192 - 0 - 2 - 0 - false - false - - - Teletek Systemaster - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 7 - 13 - 2 - 8 - 14 - 3 - 9 - 15 - 4 - 10 - 16 - 5 - 11 - 17 - 6 - 12 - 18 - - - - 1 - - 1 - 7 - 13 - 2 - 8 - 14 - 3 - 9 - 15 - 4 - 10 - 16 - 5 - 11 - 17 - 6 - 12 - 18 - - - CYLINDERS - - 4 - 15 - 1 - 172 - 127 - 192 - 0 - 3 - 0 - false - false - - - Teletek Systemaster - DSDD 96 tpi 5.25" - 256 x 18 - MFM - LOW - 80 - 2 - 18 - 256 - 0 - - 0 - - 1 - 7 - 13 - 2 - 8 - 14 - 3 - 9 - 15 - 4 - 10 - 16 - 5 - 11 - 17 - 6 - 12 - 18 - - - - 1 - - 1 - 7 - 13 - 2 - 8 - 14 - 3 - 9 - 15 - 4 - 10 - 16 - 5 - 11 - 17 - 6 - 12 - 18 - - - EAGLE - - 4 - 15 - 0 - 353 - 127 - 192 - 0 - 3 - 0 - false - false - - - TeleVideo 8nn/TPC-1 CP/M - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 6 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - SIDES - - 4 - 15 - 0 - 170 - 63 - 128 - 0 - 4 - 0 - false - false - - - TeleVideo 1603 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 354 - 127 - 192 - 0 - 2 - 0 - false - false - - - TeleVideo 806 TurboDOS - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 200 - 127 - 192 - 0 - 0 - 0 - false - false - - - TeleVideo 8nn TurboDOS - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 6 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - SIDES - - 4 - 15 - 1 - 170 - 63 - 128 - 0 - 4 - 0 - false - false - - - Timex/Sinclair 2068+AERCO FD-68 RP/M - DSDD 48 tpi 5.25" -1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 189 - 127 - 192 - 0 - 4 - 0 - false - false - - - Tokyo Electron 80W - DSHD 3.5" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 6 - 63 - 3 - 160 - 255 - 128 - 0 - 0 - 0 - false - false - - - Toshiba T100, T200 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - - 1 - - 1 - 5 - 9 - 13 - 2 - 6 - 10 - 14 - 3 - 7 - 11 - 15 - 4 - 8 - 12 - 16 - - - SIDES - - 3 - 7 - 0 - 255 - 63 - 192 - 0 - 6 - 0 - false - false - - - Toshiba 300 - DSDD 96 tpi 5.25" - 512 x 8 - MFM - LOW - 80 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 0 - 318 - 127 - 192 - 0 - 1 - 0 - false - false - - - Toshiba T-250 - DSHD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - - - - 1 - - 1 - 4 - 7 - 10 - 13 - 16 - 19 - 22 - 25 - 2 - 5 - 8 - 11 - 14 - 17 - 20 - 23 - 26 - 3 - 6 - 9 - 12 - 15 - 18 - 21 - 24 - - - SIDES - - 4 - 15 - 0 - 487 - 63 - 128 - 0 - 4 - 0 - false - false - - - Transtec - SSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - TRS-80 Model 1, Omikron CP/M - SSSD 48 tpi 5.25" - 128 x 18 - FM - LOW - 35 - 1 - 18 - 128 - 0 - - 0 - - 1 - 5 - 9 - 13 - 17 - 3 - 7 - 11 - 15 - 2 - 6 - 10 - 14 - 18 - 4 - 8 - 12 - 16 - - - - 3 - 7 - 0 - 71 - 63 - 192 - 0 - 3 - 0 - false - false - - - TRS-80 Model 1, Bigmem CP/M - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 0 - - 0 - - 1 - 7 - 13 - 19 - 25 - 5 - 11 - 17 - 23 - 3 - 9 - 15 - 21 - 2 - 8 - 14 - - - - 4 - 15 - 1 - 243 - 63 - 128 - 0 - 2 - 0 - false - false - - - TRS-80 Model 1, ColorPower II - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - TRS-80, Pickles & Trout CP/M - SSDD 8" - 512 x 16 - MFM - HIGH - 77 - 1 - 16 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 4 - 15 - 0 - 299 - 127 - 192 - 0 - 2 - 0 - false - false - - - TRS-80, Holmes CP/M - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 4 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - - - SIDES - - 4 - 15 - 1 - 190 - 63 - 240 - 0 - 2 - 0 - false - false - - - TRS-80, MM CP/M - SSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 1 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 4 - 15 - 1 - 94 - 127 - 192 - 0 - 2 - 0 - false - false - - - TRS-80 Model 4, 4P; MT CP/M - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 4 - 15 - 1 - 84 - 127 - 192 - 0 - 2 - 0 - false - false - - - TRS-80 Model 4, 4P; MT CP/M - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - SIDES - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - TRS-80 Model 4, 4P - SSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 1 - 8 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 3 - 7 - 0 - 155 - 63 - 192 - 0 - 1 - 0 - false - false - - - TRS-80 Model 4P-Montezuma800K - DSDD 96tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - 10 - - - SIDES - - 4 - 15 - 0 - 399 - 127 - 192 - 0 - 0 - 0 - false - false - - - TRS-80 II/12/16 Aton CP/M - DSHD 8" - 1024 x 8 - MFM - HIGH - 77 - 2 - 8 - 1024 - 3 - - 0 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - - 1 - - 1 - 4 - 7 - 2 - 5 - 8 - 3 - 6 - - - SIDES - - 4 - 15 - 0 - 608 - 191 - 224 - 0 - 2 - 0 - false - false - - - TRS-80 II/12/16 Pickles & Trout - DSHD 8" - 512 x 16 - MFM - HIGH - 77 - 2 - 16 - 512 - 4 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 4 - 15 - 0 - 608 - 191 - 224 - 0 - 2 - 0 - false - false - - - TRS-80 Model 4, Montezuma - DSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 2 - 18 - 256 - 0 - - 0 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - - 1 - - 1 - 3 - 5 - 7 - 9 - 11 - 13 - 15 - 17 - 2 - 4 - 6 - 8 - 10 - 12 - 14 - 16 - 18 - - - EAGLE - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - U-Micro 1000 - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 4 - 15 - 0 - 395 - 127 - 192 - 0 - 2 - 0 - false - false - - - Varian Spectra AA/20, DS-15 - DSDD 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - EAGLE - - 3 - 7 - 0 - 317 - 63 - 96 - 0 - 0 - 2 - false - false - - - Vector 4 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - EAGLE - - 4 - 15 - 0 - 356 - 127 - 192 - 0 - 1 - 0 - false - false - - - Visual 1050 - SSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 1 - 10 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 2 - 0 - false - false - - - Wangwriter - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 1 - 155 - 127 - 192 - 0 - 2 - 0 - false - false - - - Wave Mate Bullet - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 3 - 7 - 0 - 189 - 63 - 192 - 0 - 2 - 0 - false - false - - - Wave Mate Bullet - DSDD 96 tpi 5.25" - 1024 x 5 - MFM - LOW - 80 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 394 - 127 - 192 - 0 - 2 - 0 - false - false - - - Wave Mate Bullet - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - Wave Mate Bullet - SSHD 8" - 1024 x 9 - MFM - HIGH - 77 - 1 - 9 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 0 - 336 - 127 - 192 - 0 - 2 - 0 - false - false - - - Xerox - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - CYLINDERS - - 4 - 15 - 1 - 170 - 127 - 192 - 0 - 2 - 0 - false - false - - - Xerox 820 - SSSD 48 tpi 5.25" - 128 x 18 - FM - LOW - 40 - 1 - 18 - 128 - 0 - - 0 - - 1 - 6 - 11 - 16 - 3 - 8 - 13 - 18 - 5 - 10 - 15 - 2 - 7 - 12 - 17 - 4 - 9 - 14 - - - - 3 - 7 - 0 - 83 - 31 - 128 - 0 - 3 - 0 - false - false - - - Xerox 820 II - SSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 1 - 17 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 3 - 7 - 0 - 156 - 63 - 192 - 0 - 3 - 0 - false - false - - - Xerox 820-II, 16/8 - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - EAGLE - - 4 - 15 - 1 - 162 - 63 - 128 - 0 - 3 - 0 - false - false - - - Xerox 16/8 - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 5 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 4 - 15 - 1 - 242 - 127 - 192 - 0 - 2 - 0 - false - false - - - XEROX 16/8 - DSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 2 - 9 - 512 - 2 - CYLINDERS - - 4 - 15 - 1 - 162 - 63 - 128 - 0 - 2 - 0 - false - false - - - Xerox 820, S/W Publishers DD - SSDD 48 tpi 5.25" - 256 x 18 - MFM - LOW - 40 - 1 - 18 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - - - - 3 - 7 - 0 - 166 - 63 - 192 - 0 - 3 - 0 - false - false - - - Xerox 3700 Laser Printer - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 3 - CYLINDERS - - 4 - 15 - 1 - 162 - 63 - 192 - 0 - 3 - 0 - false - false - - - Xerox 16/8, 820 II - SSDD 48 tpi 5.25" - MFM - LOW - 40 - 1 - 17 - 256 - 3 - - 3 - 7 - 0 - 156 - 63 - 192 - 0 - 3 - 0 - false - false - - - Xerox 16/8 - SSDD 48 tpi 5.25" - 512 x 9 - MFM - LOW - 40 - 1 - 9 - 512 - 3 - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Xerox 16/8 Special - SSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 1 - 8 - 512 - 3 - - 3 - 7 - 0 - 151 - 63 - 192 - 0 - 2 - 0 - false - false - - - Xerox 16/8, 820-II - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 3 - EAGLE - - 4 - 15 - 1 - 162 - 63 - 128 - 0 - 3 - 0 - false - false - - - Xerox 16/8 Special - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 3 - CYLINDERS - - 4 - 15 - 1 - 155 - 63 - 128 - 0 - 2 - 0 - false - false - - - Xerox 3700 Laser Printer - DSDD 48 tpi 5.25" - 256 x 17 - MFM - LOW - 40 - 2 - 17 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - - - CYLINDERS - - 4 - 15 - 1 - 162 - 63 - 192 - 0 - 3 - 0 - false - false - - - Xor 5 - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 6 - 2 - 7 - 3 - 8 - 4 - 9 - 5 - 10 - - - - 0 - - 1 - 6 - 2 - 7 - 3 - 8 - 4 - 9 - 5 - 10 - - - SIDES - - 4 - 15 - 1 - 191 - 127 - 192 - 0 - 3 - 0 - false - false - - - XYZ - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 0 - - 0 - - 1 - 5 - 9 - 3 - 7 - 2 - 6 - 10 - 4 - 8 - - - - 1 - - 11 - 15 - 19 - 13 - 17 - 12 - 16 - 20 - 14 - 18 - - - SIDES - - 4 - 15 - 1 - 194 - 127 - 192 - 0 - 4 - 0 - false - false - - - Zeiss Video Analysis System - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - CYLINDERS - - 4 - 15 - 0 - 299 - 255 - 240 - 0 - 4 - 0 - false - false - - - Zenith Z-37 Disk - SSSD 48 tpi 5.25" - 256 x 10 - FM - LOW - 40 - 1 - 10 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 3 - 7 - 0 - 91 - 63 - 192 - 0 - 3 - 0 - false - false - - - Zenith Z-37 Disk - DSDD 96 tpi 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 315 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z89, Heath H89 - DSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 155 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z90 - SSDD 48 tpi 5.25" - 256 x 16 - MFM - LOW - 40 - 1 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 3 - 7 - 0 - 151 - 127 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z-100 - SSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 1 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 3 - 7 - 0 - 151 - 127 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z-100 - DSDD 48 tpi 5.25" - 512 x 8 - MFM - LOW - 40 - 2 - 8 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - SIDES - - 4 - 15 - 1 - 155 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z-100 - SSDD 8" - 256 x 26 - MFM - HIGH - 77 - 1 - 26 - 256 - 0 - - 0 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - - - - 4 - 15 - 1 - 242 - 127 - 192 - 0 - 2 - 0 - false - false - - - Zenith Z-37 Disk - DSDD 96 (Half drive) 5.25" - 256 x 16 - MFM - LOW - 80 - 2 - 16 - 256 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - SIDES - - 4 - 15 - 0 - 155 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith/Heath H-89 Ext Density - DSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 2 - 5 - 1024 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 195 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z-100, Heath H-47 - DSDD 8" - 256 x 26 - MFM - HIGH - 77 - 2 - 26 - 256 - 0 - - 0 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - 15 - 24 - 7 - 16 - 25 - 8 - 17 - 26 - 9 - 18 - - - - 1 - - 1 - 10 - 19 - 2 - 11 - 20 - 3 - 12 - 21 - 4 - 13 - 22 - 5 - 14 - 23 - 6 - 15 - 24 - 7 - 16 - 25 - 8 - 17 - 26 - 9 - 18 - - - SIDES - - 4 - 15 - 0 - 497 - 255 - 240 - 0 - 2 - 0 - false - false - - - Zenith Z-37 - SSDD 48 tpi 5.25" - 1024 x 5 - MFM - LOW - 40 - 1 - 5 - 1024 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 3 - 7 - 0 - 190 - 127 - 240 - 0 - 2 - 0 - false - false - - - Zenith/Heath H89/H90 Magnolia 7736 - SSHD 8" - 512 x 16 - MFM - HIGH - 77 - 1 - 16 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 4 - 15 - 0 - 299 - 191 - 224 - 0 - 2 - 0 - false - false - - - Zorba - DSDD 48 tpi 5.25" - 512 x 10 - MFM - LOW - 40 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - SIDES - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - Zorba - DSDD 96 tpi 5.25" - 512 x 10 - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - SIDES - - 5 - 31 - 3 - 194 - 127 - 128 - 0 - 2 - 0 - false - false - - - PIC-DISK SSDD 96tpi 3.5" - MFM - LOW - 80 - 1 - 9 - 512 - 1 - - 0 - - 1 - 3 - 5 - 7 - 9 - 2 - 4 - 6 - 8 - - - - 4 - 15 - 1 - 194 - 63 - 128 - 0 - 2 - 0 - false - false - - - SAM COUPE Pro-DOS - DSDD 160 tpi 3.5" - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 356 - 255 - 240 - 0 - 1 - 0 - false - false - - - Acorn CPM - MFM - LOW - 80 - 2 - 10 - 256 - 5 - - 0 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - CYLINDERS - - 4 - 15 - 1 - 200 - 127 - 192 - 0 - 3 - 0 - false - false - - - CPC 178K Data 40trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 40 - 2 - 9 - 512 - 5 - - 0 - - 0 - - - - 0 - - 0 - - - EAGLE - - 3 - 7 - 0 - 179 - 63 - 192 - 0 - 40 - 0 - false - false - - - CPC 187K Data 42trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 42 - 2 - 9 - 512 - 5 - - 0 - - 0 - - - - 0 - - 0 - - - EAGLE - - 3 - 7 - 0 - 188 - 63 - 192 - 0 - 42 - 0 - false - false - - - CPC-B360 358K Data 80trk 9sct 64dir 2Kpb Side 1 - MFM - LOW - 80 - 1 - 9 - 512 - 2 - - 0 - - 0 - - - - 4 - 15 - 1 - 179 - 63 - 128 - 0 - 0 - 0 - false - false - - - CPC-B360 358K Data 80trk 9sct 64dir 2Kpb Side 2 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 0 - - - - 0 - - 0 - - - EAGLE - - 4 - 15 - 1 - 179 - 63 - 128 - 0 - 80 - 0 - false - false - - - CPC 356K Data 40trk 9sct 128dir 2Kpb Two Sides - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 0 - - - - 1 - - 0 - - - SIDES - - 4 - 15 - 1 - 179 - 127 - 192 - 0 - 0 - 0 - false - false - - - DOBBERTIN 716K Data 80trk 9sct 128dir 4Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 0 - - - - 1 - - 0 - - - SIDES - - 5 - 31 - 3 - 179 - 127 - 128 - 0 - 0 - 0 - false - false - - - CPC-STD 169K System 40trk 9sct 64dir 1Kpb Side 1 - MFM - LOW - 40 - 1 - 9 - 512 - 5 - - 0 - - 41 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - CPC 169K System 40trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 40 - 2 - 9 - 512 - 5 - - 0 - - 41 - - - - 0 - - 41 - - - EAGLE - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 42 - 0 - false - false - - - CPC 178K System 42trk 9sct 64dir 1Kpb Side 1 - MFM - LOW - 42 - 1 - 9 - 512 - 5 - - 0 - - 41 - - - - 3 - 7 - 0 - 179 - 63 - 192 - 0 - 2 - 0 - false - false - - - CPC 178K System 42trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 42 - 2 - 9 - 512 - 5 - - 0 - - 41 - - - - 0 - - 41 - - - EAGLE - - 3 - 7 - 0 - 179 - 63 - 192 - 0 - 44 - 0 - false - false - - - CPC 253K System 60trk 9sct 64dir 1Kpb Side 1 - MFM - LOW - 60 - 1 - 9 - 512 - 5 - - 0 - - 41 - - - - 3 - 7 - 0 - 254 - 63 - 192 - 0 - 2 - 0 - false - false - - - CPC 253K System 60trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 60 - 2 - 9 - 512 - 5 - - 0 - - 41 - - - - 0 - - 41 - - - EAGLE - - 3 - 7 - 0 - 254 - 63 - 192 - 0 - 62 - 0 - false - false - - - CPC-B360 348K System 80trk 9sct 64dir 2Kpb Side 1 - MFM - LOW - 80 - 1 - 9 - 512 - 2 - - 0 - - 41 - - - - 4 - 15 - 1 - 174 - 63 - 128 - 0 - 2 - 0 - false - false - - - CPC-B360 348K System 80trk 9sct 64dir 2Kpb Side 2 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 41 - - - - 0 - - 41 - - - EAGLE - - 4 - 15 - 1 - 174 - 63 - 128 - 0 - 82 - 0 - false - false - - - CPC 346K System 40trk 9sct 128dir 2Kpb Two Sides - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 41 - - - - 1 - - 41 - - - SIDES - - 4 - 15 - 1 - 174 - 127 - 192 - 0 - 2 - 0 - false - false - - - CPC 344K System 80trk 9sct 128dir 4Kpb Side 1 - MFM - LOW - 80 - 1 - 9 - 512 - 5 - - 0 - - 41 - - - - 5 - 31 - 3 - 86 - 127 - 128 - 0 - 2 - 0 - false - false - - - CPC 344K System 80trk 9sct 128dir 4Kpb Side 2 - MFM - LOW - 80 - 2 - 9 - 512 - 5 - - 0 - - 41 - - - - 0 - - 41 - - - EAGLE - - 5 - 31 - 3 - 86 - 127 - 128 - 0 - 82 - 0 - false - false - - - DOBBERTIN 704K System 80trk 9sct 128dir 4Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 41 - - - - 1 - - 41 - - - SIDES - - 5 - 31 - 3 - 176 - 127 - 128 - 0 - 2 - 0 - false - false - - - ReadBIG 706K System 80trk 9sct 128dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 41 - - - - 1 - - 41 - - - SIDES - - 4 - 15 - 0 - 354 - 127 - 192 - 0 - 2 - 0 - false - false - - - CPC-STD 154K Ibm-Cpm86 40trk 8sct 64dir 1Kpb Side 1 - MFM - LOW - 40 - 1 - 8 - 512 - 2 - - 0 - - 1 - - - - 3 - 7 - 0 - 155 - 63 - 192 - 0 - 1 - 0 - false - false - - - CPC 154K Ibm-Cpm86 40trk 8sct 64dir 1Kpb Side 2 - MFM - LOW - 40 - 2 - 8 - 512 - 2 - - 0 - - 1 - - - - 0 - - 1 - - - EAGLE - - 3 - 7 - 0 - 155 - 63 - 192 - 0 - 41 - 0 - false - false - - - PCW-STD 173K Format 40trk 9sct 64dir 1Kpb Side 1 - MFM - LOW - 40 - 1 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 174 - 63 - 192 - 0 - 1 - 0 - false - false - - - PCW 173K Format 40trk 9sct 64dir 1Kpb Side 2 - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - EAGLE - - 3 - 7 - 0 - 174 - 63 - 192 - 0 - 41 - 0 - false - false - - - PCW 346K Format 40trk 9sct 256dir 2Kpb Two Sides - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 176 - 255 - 240 - 0 - 1 - 0 - false - false - - - PCW 706K Format 80trk 9sct 256dir 2Kpb Two Sides - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 4 - 15 - 0 - 356 - 255 - 240 - 0 - 1 - 0 - false - false - - - PCW 784K Format 80trk 10sct 256dir 4Kpb Two Sides - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 5 - 31 - 3 - 197 - 255 - 192 - 0 - 1 - 0 - false - false - - - DiskPara3 796K Format 80trk 10sct 128dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - - - - 1 - - 1 - - - SIDES - - 4 - 15 - 0 - 399 - 127 - 192 - 0 - 0 - 0 - false - false - - - DiskPara 824K Format 83trk 10sct 192dir 2Kpb Two Sides - MFM - LOW - 83 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 0 - - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - - - SIDES - - 4 - 15 - 0 - 414 - 191 - 224 - 0 - 0 - 0 - false - false - - - VORTEX 704K Format 80trk 9sct 128dir 4Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - - - - 1 - - 1 - - - SIDES - - 5 - 31 - 3 - 176 - 127 - 128 - 0 - 2 - 0 - false - false - - - RAMDOS-D1 716K Format 80trk 9sct 128dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 1 - - - - 1 - - 1 - - - SIDES - - 4 - 15 - 0 - 359 - 127 - 192 - 0 - 0 - 0 - false - false - - - RAMDOS-D10 796K Format 80trk 10sct 128dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 11 - - - - 1 - - 11 - - - SIDES - - 4 - 15 - 0 - 399 - 127 - 192 - 0 - 0 - 0 - false - false - - - RAMDOS-D2 712K Format 80trk 9sct 256dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 9 - 512 - 0 - - 0 - - 21 - - - - 1 - - 21 - - - SIDES - - 4 - 15 - 0 - 359 - 255 - 240 - 0 - 0 - 0 - false - false - - - RAMDOS-D20 792K Format 80trk 10sct 256dir 2Kpb Two Sides - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 31 - - - - 1 - - 31 - - - SIDES - - 4 - 15 - 0 - 399 - 255 - 240 - 0 - 0 - 0 - false - false - - - Amstrad ZX Spectrum +3 - SSDD 64dir 1Kpb 180K - 173K user free - MFM - LOW - 40 - 1 - 9 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 174 - 63 - 192 - 0 - 1 - 0 - false - false - - - Amstrad ZX Spectrum +3 - DSDD 128dir 2Kpb 720K - 710K user free - MFM - LOW - 80 - 2 - 9 - 512 - 3 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 356 - 127 - 192 - 0 - 1 - 0 - false - false - - - Altos Series 5 - DSDD 96 tpi 5.25" - 512 x 9 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 176 - 255 - 192 - 0 - 64 - 0 - false - false - - - PC1715 SCP (80*2* 5,1024 4 OFS 4k DIR) 5.25" - MFM - LOW - 80 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 389 - 127 - 192 - 0 - 4 - 0 - false - false - - - PC1715 CPA (80*2* 5,1024 0 OFS 6k DIR) 5.25" - MFM - LOW - 80 - 2 - 5 - 1024 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - - - SIDES - - 4 - 15 - 0 - 399 - 191 - 224 - 0 - 0 - 0 - false - false - - - Amstrad PCW8256 - DSDD 48 tpi 5.25" - MFM - LOW - 40 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 4 - 15 - 0 - 356 - 255 - 240 - 0 - 1 - 0 - false - false - - - Amstrad PCW8256 - SSDD 48 tpi 3" (JOYCE-SYSTEM) - MFM - LOW - 40 - 1 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 3 - 7 - 0 - 174 - 63 - 192 - 0 - 1 - 0 - false - false - - - Amstrad CPC System - SSDD 48 tpi 3" or 5.25" - MFM - LOW - 40 - 1 - 9 - 512 - 5 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 3 - 7 - 0 - 170 - 63 - 192 - 0 - 2 - 0 - false - false - - - Amstrad CPC-Data - SSDD 48 tpi 3" or 5.25" - MFM - LOW - 40 - 1 - 9 - 512 - 5 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 179 - 63 - 192 - 0 - 0 - 0 - false - false - - - Amstrad B360K - SSDD 96 tpi 5.25" SKEW 2 - MFM - LOW - 80 - 1 - 9 - 512 - 2 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 4 - 15 - 1 - 174 - 63 - 128 - 0 - 2 - 0 - false - false - - - Amstrad VORTEX - DSDD 96 tpi 5.25" - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 176 - 127 - 128 - 0 - 2 - 0 - false - false - - - Amstrad CPC System DSDD 96tpi 5.25" - DOBBERTIN - - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - - 1 - - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - - - SIDES - - 5 - 31 - 3 - 176 - 127 - 128 - 0 - 2 - 0 - false - false - - - Amstrad DOBBERTIN DATA DSDD 96 tpi 5.25" Skew 5 - MFM - LOW - 80 - 2 - 9 - 512 - 2 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 1 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 5 - 31 - 3 - 179 - 127 - 128 - 0 - 0 - 0 - false - false - - - Amstrad PCW8256 - DSDD 96 tpi 5.25" 10 x 512 788K - MFM - LOW - 80 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 5 - 31 - 3 - 197 - 255 - 192 - 0 - 1 - 0 - false - false - - - Amstrad PCW Joyce - SF2DD (824 kb - 256 entries) - MFM - LOW - 84 - 2 - 10 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - SIDES - - 5 - 31 - 3 - 208 - 255 - 192 - 0 - 1 - 0 - false - false - - - Amstrad PCW Joyce - 168 Track DD (740 kb - 256 entries) - MFM - LOW - 84 - 2 - 9 - 512 - 2 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - - SIDES - - 5 - 31 - 3 - 187 - 255 - 192 - 0 - 1 - 0 - false - false - - - Extended CPC 3" 43-track - MFM - LOW - 43 - 1 - 9 - 512 - 2 - - 0 - - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - - - - 3 - 7 - 0 - 193 - 63 - 192 - 0 - 0 - 0 - false - false - - - Apple // CPM card 13-sector - GCR - LOW - 35 - 1 - 13 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - - - - 3 - 7 - 0 - 103 - 47 - 192 - 0 - 3 - 0 - false - false - - - Apple // CPM card 16-sector - GCR - LOW - 35 - 1 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 3 - 7 - 0 - 127 - 63 - 192 - 0 - 3 - 0 - false - false - - - Apple // CPM card special - GCR - LOW - 80 - 2 - 16 - 256 - 0 - - 0 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 1 - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - - - - 4 - 15 - 0 - 313 - 255 - 240 - 0 - 3 - 0 - false - false - - - 2016-08-24T02:44:59.045767Z + + + Generic CP/M - SSSD 8" - 128 x 26 + FM + HIGH + 77 + 1 + 26 + 128 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + 20 + 26 + 6 + 12 + 18 + 24 + 4 + 10 + 16 + 22 + + + + 3 + 7 + 0 + 242 + 63 + 192 + 0 + 2 + 0 + false + false + + + ABC-80 - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 8 + 15 + 6 + 13 + 4 + 11 + 2 + 9 + 16 + 7 + 14 + 5 + 12 + 3 + 10 + + + + 3 + 7 + 0 + 151 + 63 + 192 + 0 + 2 + 0 + false + false + + + A. B. Dick Magna III - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 0 + + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + + + SIDES + + 3 + 7 + 0 + 255 + 255 + 255 + 0 + 4 + 0 + false + false + + + Actrix (Access Matrix) - SSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Actrix (Access Matrix) - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 1 + 174 + 63 + 128 + 0 + 2 + 0 + false + false + + + Adler Textriter - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 3 + 7 + 0 + 159 + 31 + 128 + 0 + 0 + 0 + false + false + + + Advanced Digital Super 6 - SSDD 48 tpi 5.25" - 1024 x 4 + MFM + LOW + 40 + 1 + 4 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + + + + 4 + 15 + 0 + 77 + 63 + 128 + 0 + 1 + 0 + false + false + + + Advanced Digital Super 6 - DSDD 48 tpi 5.25" - 1024 x 4 + MFM + LOW + 40 + 2 + 4 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + + + + 0 + + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 0 + 155 + 127 + 192 + 0 + 2 + 0 + false + false + + + Advanced Digital Super 6 - DSDD 96 tpi 5.25" - 1024 x 4 + MFM + LOW + 80 + 2 + 4 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + + + + 1 + + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 0 + 300 + 127 + 192 + 0 + 2 + 0 + false + false + + + Advanced Digital Super 8 - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 608 + 255 + 240 + 0 + 2 + 0 + false + false + + + Advanced Digital TurboDOS 312K - DSDD 48 tpi 5.25" - 1024 x 4 + MFM + LOW + 40 + 2 + 4 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + + + + 0 + + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 1 + 155 + 127 + 192 + 0 + 2 + 0 + false + false + + + Advanced Digital TurboDOS 366K - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 182 + 127 + 192 + 0 + 6 + 0 + false + false + + + Advanced Controls - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 0 + 385 + 127 + 192 + 0 + 6 + 0 + false + false + + + Allen-Bradley Advisor+ - DSDD 3.5" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 318 + 127 + 192 + 0 + 0 + 1 + false + false + + + Alspa - SSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 1 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 4 + 15 + 0 + 300 + 127 + 192 + 0 + 2 + 0 + false + false + + + Altos - SSSD 8" - 128 x 26 + FM + HIGH + 77 + 1 + 26 + 128 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 3 + 7 + 0 + 242 + 63 + 192 + 0 + 2 + 0 + false + false + + + Altos - DSSD 8" - 128 x 26 + FM + HIGH + 77 + 2 + 26 + 128 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + 20 + 26 + 6 + 12 + 18 + 24 + 4 + 10 + 16 + 22 + + + + 1 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + 20 + 26 + 6 + 12 + 18 + 24 + 4 + 10 + 16 + 22 + + + SIDES + + 5 + 31 + 3 + 122 + 127 + 128 + 0 + 2 + 0 + false + false + + + Altos - SSDD 8" - 512 x 15 + MFM + HIGH + 77 + 1 + 15 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 5 + 31 + 3 + 139 + 127 + 128 + 0 + 2 + 0 + false + false + + + Altos - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + SIDES + + 5 + 31 + 1 + 284 + 255 + 192 + 0 + 2 + 0 + false + false + + + Altos Series 5 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 176 + 176 + 192 + 0 + 2 + 0 + false + false + + + Amigo - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 3 + 7 + 0 + 189 + 63 + 192 + 0 + 2 + 0 + false + false + + + Amigo - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 195 + 63 + 128 + 0 + 2 + 0 + false + false + + + Ampro - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 4 + 15 + 1 + 94 + 63 + 128 + 0 + 2 + 0 + false + false + + + Ampro - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + + 1 + + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Ampro - SSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 1 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Ampro - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 2 + + 0 + + 17 + 18 + 19 + 20 + 21 + + + + 1 + + 17 + 18 + 19 + 20 + 21 + + + SIDES + + 4 + 15 + 0 + 394 + 255 + 240 + 0 + 2 + 0 + false + false + + + Amstrad PCW 8256 - SSDD 48 tpi 3.00" + MFM + LOW + 40 + 1 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 175 + 63 + 192 + 0 + 1 + 0 + false + false + + + Amstrad PCW 8256 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 356 + 255 + 240 + 0 + 1 + 0 + false + false + + + Amstrad CPC464 - SSDD 48 tpi 5.25"/3" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 5 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 3 + 7 + 0 + 171 + 63 + 192 + 0 + 2 + 0 + false + false + + + Amstrad CPC464 - SSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 1 + 9 + 512 + 5 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 5 + 31 + 3 + 87 + 127 + 128 + 0 + 2 + 0 + false + false + + + Amstrad PCW 8512 - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 356 + 255 + 240 + 0 + 1 + 0 + false + false + + + Amstrad CPC 6128 - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 1 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + SIDES + + 4 + 15 + 1 + 175 + 127 + 192 + 0 + 2 + 0 + false + false + + + Amstrad CPC 6128 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 1 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + SIDES + + 5 + 31 + 3 + 175 + 127 + 128 + 0 + 2 + 0 + false + false + + + Amstrad CPC 6128 Side 1 - SSDD 3.5" / 3" - 512 x 9 + MFM + LOW + 80 + 1 + 9 + 512 + 0 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 180 + 63 + 192 + 0 + 0 + 0 + false + false + + + Amstrad CPC 6128 Side 2 - SSDD 3.5" / 3" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 180 + 63 + 192 + 0 + 80 + 0 + false + false + + + Amstrad PCW w/DU49, Moonstone XFORMAT - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 5 + 31 + 3 + 198 + 255 + 192 + 0 + 1 + 0 + false + false + + + Amstrad CPC 6128 Vortex - DSDD 3.5"/96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 178 + 127 + 128 + 0 + 2 + 0 + false + false + + + Archive I - SSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Archive II & III - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 1 + + 1 + 4 + 2 + 5 + 3 + + + SIDES + + 4 + 15 + 0 + 394 + 319 + 248 + 0 + 2 + 0 + false + true + + + Arisia - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 3 + 7 + 0 + 147 + 127 + 240 + 0 + 2 + 0 + false + false + + + Associate - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + SIDES + + 4 + 15 + 1 + 195 + 127 + 192 + 0 + 2 + 0 + false + false + + + Aster CT-80 - DSDD 96 tpi 5.25" - 1024 x 5, 3:1 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 0 + 394 + 127 + 192 + 0 + 4 + 0 + false + false + + + ATR-8000 - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 3 + 7 + 0 + 189 + 63 + 192 + 0 + 2 + 0 + false + false + + + ATR-8000 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + ATR-8000 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + EAGLE + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 2 + 0 + false + false + + + ATT-7700 - DSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 1 + + 17 + 19 + 21 + 23 + 25 + 27 + 29 + 31 + 18 + 20 + 22 + 24 + 26 + 28 + 30 + 32 + + + SIDES + + 4 + 15 + 0 + 316 + 127 + 192 + 0 + 2 + 0 + false + false + + + Avatar - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 1 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + CYLINDERS + + 4 + 15 + 1 + 191 + 127 + 192 + 0 + 3 + 0 + false + false + + + Barudan - DSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + SIDES + + 5 + 31 + 3 + 155 + 127 + 128 + 0 + 4 + 0 + false + false + + + Beehive - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Beehive Microbee - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + + 1 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Beehive Microbee - SSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 0 + + 0 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Microbee Systems - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 22 + 25 + 28 + 21 + 24 + 27 + 30 + 23 + 26 + 29 + + + + 0 + + 22 + 25 + 28 + 21 + 24 + 27 + 30 + 23 + 26 + 29 + + + SIDES + + 5 + 31 + 3 + 194 + 127 + 128 + 0 + 4 + 0 + false + false + + + Microbee Dreamdisk format - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + + 1 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 0 + 391 + 255 + 240 + 0 + 2 + 0 + false + false + + + Computer Bell - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 192 + 127 + 192 + 0 + 3 + 0 + false + false + + + Big Board (512 bytes/sector) - SSDD 8" - 512 x 15 + MFM + HIGH + 77 + 1 + 15 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 4 + 15 + 0 + 280 + 127 + 192 + 0 + 2 + 0 + false + false + + + Big Board (512 bytes/sector) - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + CYLINDERS + + 4 + 15 + 0 + 569 + 127 + 192 + 0 + 2 + 0 + false + false + + + Big Board SWP 1024 bytes/sector - SSDD 8" - 1024 x 9 + MFM + HIGH + 77 + 1 + 9 + 1024 + 0 + + 4 + 15 + 0 + 336 + 127 + 192 + 0 + 2 + 0 + false + false + + + Bitelex - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 3 + 7 + 0 + 131 + 95 + 224 + 0 + 2 + 0 + false + false + + + BMC IF800 Model 20 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 7 + 13 + 19 + 5 + 11 + 17 + 3 + 9 + 15 + + + + 1 + + 1 + 7 + 13 + 19 + 5 + 11 + 17 + 3 + 9 + 15 + + + SIDES + + 4 + 15 + 0 + 191 + 127 + 192 + 0 + 3 + 0 + false + false + + + Bondwell 12 - SSDD 48 tpi 5.25" - 256 x 10 + MFM + LOW + 40 + 1 + 18 + 256 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 4 + 15 + 1 + 84 + 127 + 192 + 0 + 2 + 0 + false + false + + + Bondwell 14 - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + EAGLE + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + Bondwell 2 - SSDD 3.5" - 256 x 18 + MFM + LOW + 80 + 1 + 18 + 256 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + BOSS TurboDOS - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 616 + 255 + 240 + 0 + 0 + 0 + false + false + + + BTI Systems - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + EAGLE + + 4 + 15 + 1 + 175 + 127 + 192 + 0 + 2 + 0 + false + false + + + Burr-Brown - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 10 + 2 + 11 + 3 + 12 + 4 + 13 + 5 + 14 + 6 + 15 + 7 + 16 + 8 + 17 + 9 + 18 + + + + 1 + + 1 + 10 + 2 + 11 + 3 + 12 + 4 + 13 + 5 + 14 + 6 + 15 + 7 + 16 + 8 + 17 + 9 + 18 + + + SIDES + + 4 + 15 + 1 + 170 + 63 + 128 + 0 + 4 + 0 + false + false + + + Cal-PC - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Cashcom 100 - DSDD 96 tpi 5.25" - 1024 x 4 + MFM + LOW + 80 + 2 + 4 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + + + + 1 + + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 0 + 303 + 127 + 192 + 0 + 2 + 0 + false + false + + + Commodore Business Machines 1581 drive - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 397 + 127 + 192 + 0 + 0 + 0 + false + false + + + CCS (256 bytes/sector) - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + + + + 0 + + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + + + SIDES + + 4 + 15 + 1 + 165 + 63 + 128 + 0 + 6 + 0 + false + false + + + CCS (512 bytes/sector) - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + + 0 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + SIDES + + 4 + 15 + 1 + 184 + 63 + 128 + 0 + 6 + 0 + false + false + + + CCS (1024 bytes/sector) - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 0 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 1 + 184 + 63 + 128 + 0 + 6 + 0 + false + false + + + CCS 8 - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + SIDES + + 6 + 63 + 7 + 149 + 127 + 128 + 0 + 4 + 0 + false + false + + + CCS 2442 - SSDD 8" - 512 x 15 + MFM + HIGH + 77 + 1 + 15 + 512 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + + + + 5 + 31 + 3 + 139 + 127 + 128 + 0 + 2 + 0 + false + false + + + CCS (1024 bytes alternate) - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 1 + 184 + 63 + 128 + 0 + 6 + 0 + false + false + + + CDC-110 Viking - DSDD 8" - 512 x 16 + MFM + HIGH + 77 + 2 + 16 + 512 + 0 + + 0 + + 0 + 4 + 8 + 12 + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + + + + 1 + + 0 + 4 + 8 + 12 + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + + + SIDES + + 4 + 15 + 0 + 608 + 255 + 240 + 0 + 2 + 0 + false + false + + + CDI-5000 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 1 + + 1 + 4 + 2 + 5 + 3 + + + SIDES + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + COLEX 850 - SSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + COLEX 850 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 1 + + 11 + 15 + 19 + 13 + 17 + 12 + 16 + 20 + 14 + 18 + + + SIDES + + 4 + 15 + 0 + 389 + 127 + 192 + 0 + 4 + 0 + false + false + + + CMC Supersystem 2 - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 391 + 127 + 192 + 0 + 3 + 0 + false + false + + + Coin - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + + + EAGLE + + 4 + 15 + 0 + 392 + 127 + 192 + 0 + 3 + 0 + false + false + + + Coleco ADAM, 40 track - SSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 1 + 8 + 512 + 0 + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + + 3 + 7 + 0 + 146 + 63 + 192 + 0 + 0 + 26 + false + false + + + Coleco ADAM, 254K - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + EAGLE + + 3 + 7 + 0 + 255 + 63 + 192 + 0 + 0 + 26 + false + false + + + Coleco ADAM, 320K - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + EAGLE + + 4 + 15 + 1 + 152 + 63 + 128 + 0 + 0 + 26 + false + false + + + Coleco ADAM, 720K - DSDD 3.5" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + + 0 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + SIDES + + 4 + 15 + 0 + 354 + 127 + 192 + 0 + 0 + 26 + false + false + + + Coleco ADAM, 360K - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 1 + 179 + 63 + 128 + 0 + 0 + 4 + false + false + + + Coleco ADAM, E&T PROM 720K - DSDD 3.5" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + + 1 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + SIDES + + 4 + 15 + 0 + 354 + 127 + 192 + 0 + 0 + 26 + false + false + + + Coleco ADAM, 720K - DSDD 3.5" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + + 0 + + 1 + 5 + 9 + 4 + 8 + 3 + 7 + 2 + 6 + + + SIDES + + 4 + 15 + 0 + 358 + 127 + 192 + 0 + 0 + 4 + false + false + + + Coleco ADAM, 1.44M - DSHD 3.5" - 512 x 18 + MFM + HIGH + 80 + 2 + 18 + 512 + 0 + + 0 + + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + + + + 1 + + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + + + SIDES + + 4 + 15 + 0 + 712 + 255 + 240 + 0 + 2 + 0 + false + false + + + Coleco Adam TDOS - DSDD 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + + 1 + + 1 + 6 + 3 + 8 + 5 + 2 + 7 + 4 + + + EAGLE + + 3 + 7 + 0 + 255 + 63 + 192 + 0 + 0 + 26 + false + false + + + Columbia Commander 964 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + COLUMBIA + + 4 + 15 + 1 + 190 + 63 + 128 + 0 + 2 + 0 + false + false + + + Columbia 1600 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + COLUMBIA + + 5 + 31 + 3 + 197 + 255 + 192 + 0 + 2 + 0 + false + false + + + Columbia M64 - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 3 + 7 + 0 + 190 + 127 + 240 + 0 + 2 + 0 + true + false + + + Compis - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 4 + 15 + 0 + 317 + 127 + 192 + 0 + 1 + 0 + false + false + + + Compugraphic MCS-5 - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 3 + 7 + 0 + 155 + 63 + 192 + 0 + 1 + 0 + false + false + + + Compustar Model 30 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 35 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + EAGLE + + 4 + 15 + 1 + 169 + 63 + 128 + 0 + 2 + 0 + true + false + + + Compupro (Viasyn) - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 0 + 389 + 255 + 240 + 0 + 4 + 0 + false + false + + + Compupro (Viasyn) 8/16 - SSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 1 + 8 + 1024 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + + 4 + 15 + 0 + 299 + 127 + 192 + 0 + 2 + 0 + false + false + + + Compupro (Viasyn) 8/16 - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + SIDES + + 4 + 15 + 0 + 599 + 255 + 240 + 0 + 4 + 0 + false + false + + + Compupro (Viasyn) - SSDD 8" - 512 x 15 + MFM + HIGH + 77 + 1 + 15 + 512 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + + + + 4 + 15 + 0 + 280 + 127 + 192 + 0 + 2 + 0 + false + false + + + Compupro (Viasyn) - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 0 + + 0 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + + 4 + 15 + 0 + 242 + 127 + 192 + 0 + 2 + 0 + false + false + + + Compupro (Viasyn) 256 bytes/sector - DSHD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + + 1 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + + 4 + 15 + 0 + 487 + 255 + 240 + 0 + 4 + 0 + false + false + + + CPT Phoenix CP/M - DSDD 3.5" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 0 + 355 + 255 + 240 + 0 + 2 + 0 + false + false + + + Cromemco CDOS - SSSD 48 tpi 5.25" - 128 x 18 + FM + LOW + 40 + 1 + 18 + 128 + 0 + + 0 + + 1 + 6 + 11 + 16 + 3 + 8 + 13 + 18 + 5 + 10 + 15 + 2 + 7 + 12 + 17 + 4 + 9 + 14 + + + + 3 + 7 + 0 + 82 + 63 + 192 + 0 + 3 + 0 + false + false + + + Cromemco CDOS - DSSD 48 tpi 5.25" - 128 x 18 + FM + LOW + 40 + 2 + 128 + 18 + 0 + + 0 + + 1 + 6 + 11 + 16 + 3 + 8 + 13 + 18 + 5 + 10 + 15 + 2 + 7 + 12 + 17 + 4 + 9 + 14 + + + + 1 + + 1 + 6 + 11 + 16 + 3 + 8 + 13 + 18 + 5 + 10 + 15 + 2 + 7 + 12 + 17 + 4 + 9 + 14 + + + SIDES + + 3 + 7 + 0 + 172 + 63 + 192 + 0 + 3 + 0 + false + false + + + Cromemco CDOS - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 3 + 7 + 0 + 189 + 63 + 192 + 0 + 2 + 0 + false + false + + + Cromemco CDOS - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 1 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + SIDES + + 4 + 15 + 0 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Cromemco CDOS - DSDD 8" - 512 x 16 + MFM + HIGH + 77 + 2 + 16 + 512 + 0 + + 0 + + 1 + 12 + 7 + 2 + 13 + 8 + 3 + 14 + 9 + 4 + 15 + 10 + 5 + 16 + 11 + 6 + + + + 1 + + 1 + 12 + 7 + 2 + 13 + 8 + 3 + 14 + 9 + 4 + 15 + 10 + 5 + 16 + 11 + 6 + + + SIDES + + 4 + 15 + 0 + 608 + 255 + 240 + 0 + 2 + 0 + false + false + + + Cromemco CP/M - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + + 4 + 15 + 1 + 94 + 127 + 192 + 0 + 2 + 0 + false + false + + + Cromemco CP/M - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + + 1 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Cykey - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + + 1 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + SIDES + + 4 + 15 + 1 + 153 + 63 + 192 + 0 + 3 + 0 + false + false + + + Datavue DV80 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 3 + + 0 + + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + + + + 1 + + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + + + SIDES + + 5 + 31 + 3 + 94 + 127 + 128 + 0 + 4 + 0 + false + false + + + Datavue DV80 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 3 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + + + + 1 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + + + SIDES + + 5 + 31 + 3 + 194 + 127 + 128 + 0 + 4 + 0 + false + false + + + Davidge - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 0 + 384 + 127 + 192 + 0 + 6 + 0 + false + false + + + DEC DECMate II - SSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 4 + 15 + 1 + 195 + 127 + 192 + 0 + 2 + 0 + false + false + + + DEC VT-180 - SSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Dictaphone 6000 CP/M - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + SIDES + + 4 + 15 + 0 + 352 + 127 + 192 + 0 + 3 + 0 + false + false + + + Dictaphone 6000 CP/M - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 0 + 345 + 319 + 248 + 0 + 6 + 0 + false + false + + + Digilog 2500 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 35 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + + + EAGLE + + 4 + 15 + 1 + 166 + 63 + 128 + 0 + 3 + 0 + false + false + + + Digilog 1500 - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + CYLINDERS + + 4 + 15 + 0 + 392 + 127 + 192 + 0 + 3 + 0 + false + false + + + Digitech 500 series - SSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 1 + 199 + 319 + 248 + 0 + 0 + 0 + false + false + + + Digitech 500 series - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 398 + 319 + 248 + 0 + 0 + 0 + false + false + + + Digital Group, TVC-80 FDC - SSDD 8" - 1024 x 9 + MFM + HIGH + 77 + 1 + 9 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 0 + 342 + 127 + 192 + 0 + 1 + 0 + false + false + + + Dimension 68000 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 195 + 63 + 128 + 0 + 2 + 0 + false + false + + + Direct 1025 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 152 + 127 + 192 + 0 + 3 + 0 + false + false + + + Discovery - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 313 + 127 + 192 + 0 + 3 + 0 + false + false + + + Duet CP/M - DSDD 96tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + SIDES + + 4 + 15 + 0 + 355 + 255 + 240 + 0 + 2 + 0 + false + false + + + Eagle I, II - SSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 4 + 15 + 1 + 194 + 191 + 224 + 0 + 2 + 0 + false + false + + + Eagle III, IV, V - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + EAGLE + + 4 + 15 + 0 + 394 + 191 + 224 + 0 + 2 + 0 + false + false + + + Electroglas/Xynetics - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 3 + EAGLE + + 4 + 15 + 1 + 158 + 63 + 128 + 0 + 1 + 0 + false + false + + + Electroglas/Xynetics - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 3 + SIDES + + 4 + 15 + 0 + 397 + 255 + 240 + 0 + 1 + 0 + false + false + + + Epson QX-10 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + Epson QX-10 (256 bytes/sector) - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 139 + 63 + 128 + 0 + 8 + 0 + false + false + + + Epson PX-10/8 - DSDD 3.5" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 1 + 139 + 63 + 128 + 0 + 8 + 0 + false + false + + + Epson QX-16 640K - DSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 304 + 127 + 192 + 0 + 8 + 0 + false + false + + + Epson QX-16 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 389 + 255 + 252 + 0 + 4 + 0 + false + false + + + Ericsson DTC - SSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 5 + 31 + 3 + 77 + 127 + 128 + 0 + 2 + 0 + false + false + + + Ericsson DTC - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 5 + 31 + 3 + 157 + 127 + 128 + 0 + 2 + 0 + false + false + + + Ericsson Step One - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 174 + 127 + 128 + 0 + 4 + 0 + false + false + + + Estimation Inc. EST101 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + EAGLE + + 4 + 15 + 0 + 394 + 255 + 240 + 0 + 2 + 0 + false + false + + + Everett/Charles Kryterion 165 - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 6 + 63 + 3 + 151 + 255 + 192 + 0 + 2 + 0 + false + false + + + Eureka A4 - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + + 1 + + 2 + 5 + 8 + 1 + 4 + 7 + 10 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 0 + 399 + 255 + 240 + 0 + 0 + 0 + false + false + + + Exidy Sorcerer - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 6 + 11 + 16 + 5 + 10 + 15 + 4 + 9 + 14 + 3 + 8 + 13 + 2 + 7 + 12 + + + + 4 + 15 + 0 + 76 + 63 + 192 + 0 + 0 + 33 + false + false + + + EXO - SSDD 8" - 512 x 16 + MFM + HIGH + 77 + 1 + 16 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 5 + 31 + 3 + 149 + 127 + 128 + 0 + 2 + 0 + false + false + + + EXO - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + SIDES + + 5 + 31 + 1 + 303 + 127 + 128 + 0 + 2 + 0 + false + false + + + Florida Graphics - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 2 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + SIDES + + 4 + 15 + 0 + 295 + 127 + 192 + 0 + 12 + 0 + false + false + + + Formula 1 - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 2 + 5 + 6 + 9 + 10 + 13 + 14 + 17 + 18 + 3 + 4 + 7 + 8 + 11 + 12 + 15 + 16 + + + + 1 + + 1 + 2 + 5 + 6 + 9 + 10 + 13 + 14 + 17 + 18 + 3 + 4 + 7 + 8 + 11 + 12 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 172 + 127 + 192 + 0 + 3 + 0 + false + false + + + Fujitsu Micro 8 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 151 + 127 + 192 + 0 + 4 + 0 + false + false + + + Future FX-20 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 4 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 5 + 31 + 3 + 196 + 95 + 128 + 0 + 2 + 0 + false + false + + + Gemini Galaxy - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + EAGLE + + 5 + 31 + 3 + 196 + 127 + 128 + 0 + 2 + 0 + false + false + + + Globe 101 - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 319 + 127 + 192 + 0 + 0 + 13 + false + false + + + Gnat System 10 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 35 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + SIDES + + 4 + 15 + 0 + 169 + 127 + 192 + 0 + 2 + 0 + false + false + + + Graco OM-5000 - DSHD 5.25" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 5 + 31 + 3 + 248 + 127 + 128 + 0 + 2 + 0 + false + false + + + Hagiwara HPU 801 CP/M 68K - DSDD 3.5" Special - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + SIDES + + 4 + 15 + 0 + 486 + 127 + 192 + 0 + 4 + 0 + false + false + + + Hazeltine - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 77 + 2 + 10 + 512 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 379 + 255 + 240 + 0 + 2 + 0 + false + false + + + HCL System 2 - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 388 + 255 + 240 + 0 + 4 + 0 + false + false + + + Heath H89, Magnolia CP/M - SSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 1 + 82 + 95 + 192 + 0 + 3 + 0 + false + false + + + Heath H89, Magnolia CP/M - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + CYLINDERS + + 4 + 15 + 1 + 172 + 95 + 192 + 0 + 3 + 0 + false + false + + + Heath H89, Magnolia CP/M - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + CYLINDERS + + 5 + 31 + 3 + 176 + 127 + 128 + 0 + 3 + 0 + false + false + + + Heurikon MLZ-91A - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 5 + 6 + 9 + 10 + 13 + 14 + 3 + 4 + 7 + 8 + 11 + 12 + 15 + 16 + + + + 1 + + 1 + 2 + 5 + 6 + 9 + 10 + 13 + 14 + 3 + 4 + 7 + 8 + 11 + 12 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 315 + 127 + 192 + 0 + 2 + 0 + false + false + + + Hewlett-Packard HP86/87/120/125 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + SIDES + + 3 + 7 + 0 + 251 + 127 + 240 + 0 + 3 + 0 + false + false + + + Hewlett Packard HP 125 - SSSD 8" - 256 x 16 + FM + HIGH + 66 + 1 + 16 + 256 + 6 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 3 + 7 + 0 + 251 + 127 + 240 + 0 + 3 + 0 + false + false + + + Hewlett Packard HP 125 - SSDD 3.5" - 256 x 16 + MFM + LOW + 66 + 1 + 16 + 256 + 6 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 3 + 7 + 0 + 251 + 127 + 240 + 0 + 3 + 0 + false + false + + + Hitachi HPC-6000 CP/M 68K - DSHD 1.2M 3.5" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + SIDES + + 5 + 31 + 3 + 242 + 127 + 128 + 0 + 4 + 0 + false + false + + + Hitachi R-1500 CP/M 68K - DSHD 1.2M 5.25" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + SIDES + + 4 + 15 + 0 + 494 + 127 + 192 + 0 + 2 + 0 + false + false + + + Strippit Houdaille Fab/V - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 4 + 15 + 0 + 174 + 63 + 128 + 0 + 1 + 0 + false + false + + + IBM PC, CP/M-86 - SSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 1 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 3 + 7 + 0 + 155 + 63 + 192 + 0 + 1 + 0 + false + false + + + IBM PC, CP/M-86 - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 4 + 15 + 1 + 157 + 63 + 128 + 0 + 1 + 0 + false + false + + + IBS Ultraframe Turbo DOS - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 397 + 255 + 240 + 0 + 0 + 0 + false + false + + + IBEX 7300 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 5 + 31 + 3 + 246 + 127 + 128 + 0 + 2 + 0 + false + false + + + IBEX 7301 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + 20 + 26 + 6 + 12 + 18 + 24 + 4 + 10 + 16 + 22 + + + + 1 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + 20 + 26 + 6 + 12 + 18 + 24 + 4 + 10 + 16 + 22 + + + SIDES + + 5 + 31 + 2 + 242 + 127 + 128 + 0 + 4 + 0 + false + false + + + ICL DRS 20 - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 6 + 11 + 16 + 5 + 10 + 15 + 4 + 9 + 14 + 3 + 8 + 13 + 2 + 7 + 12 + + + + 1 + + 1 + 6 + 11 + 16 + 5 + 10 + 15 + 4 + 9 + 14 + 3 + 8 + 13 + 2 + 7 + 12 + + + SIDES + + 5 + 31 + 3 + 158 + 255 + 192 + 0 + 2 + 0 + false + false + + + ICL DRS 300 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 350 + 127 + 192 + 0 + 4 + 0 + false + false + + + ICL Model 35/36 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 391 + 127 + 192 + 0 + 0 + 36 + false + false + + + IMS 5000 - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 9 + 2 + 10 + 3 + 11 + 4 + 12 + 5 + 13 + 6 + 14 + 7 + 15 + 8 + 16 + + + + 3 + 7 + 0 + 147 + 63 + 192 + 0 + 3 + 0 + false + false + + + IMS 5000 TurboDOS - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 390 + 127 + 192 + 0 + 4 + 0 + false + false + + + IMS 5000 TurboDOS - SSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 1 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 4 + 15 + 0 + 308 + 191 + 224 + 0 + 0 + 0 + false + false + + + IMS 5000 CP/M - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + + + CYLINDERS + + 4 + 15 + 0 + 395 + 255 + 240 + 0 + 2 + 0 + false + false + + + Intel iPDS 100 - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 307 + 255 + 240 + 0 + 6 + 0 + false + false + + + Intuit - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 3 + 7 + 0 + 190 + 127 + 240 + 0 + 2 + 0 + false + false + + + Insight Enterprises - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 155 + 63 + 128 + 0 + 2 + 0 + false + false + + + Ithaca Intersystems - SSDD 96 tpi 5.25" - 256 x 18 + MFM + LOW + 80 + 1 + 18 + 256 + 2 + + 0 + + 1 + 2 + 5 + 6 + 9 + 10 + 13 + 14 + 17 + 18 + 3 + 4 + 7 + 8 + 11 + 12 + 15 + 16 + + + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + Ithaca Intersystems - SSDD 8" - 512 x 15 + MFM + HIGH + 77 + 1 + 15 + 512 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + + + + 4 + 15 + 0 + 284 + 191 + 224 + 0 + 1 + 0 + false + false + + + Ithaca Intersystems - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + + + + 1 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + + + SIDES + + 5 + 31 + 1 + 284 + 255 + 192 + 0 + 1 + 0 + false + false + + + ITT 3030 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 35 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 3 + 7 + 0 + 247 + 63 + 192 + 0 + 4 + 0 + false + false + + + ITT 3030 - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 70 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 4 + 15 + 0 + 270 + 127 + 192 + 0 + 4 + 0 + false + false + + + Sel ITT 3030 - 70 Tracks 560 kB - 256 x 16 + MFM + LOW + 70 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + EAGLE + + 4 + 15 + 0 + 271 + 127 + 192 + 0 + 4 + 0 + false + false + + + Jonos - SSDD 3.5" - 512 x 9 + MFM + LOW + 70 + 1 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 1 + 152 + 63 + 128 + 0 + 2 + 0 + false + false + + + Kaypro II/2 - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 194 + 63 + 240 + 0 + 1 + 0 + false + false + + + Kaypro 2X/4/10 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 0 + + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + SIDES + + 4 + 15 + 1 + 196 + 63 + 192 + 0 + 1 + 0 + false + false + + + Kaypro 2X/4/10 (Alternate) - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + SIDES + + 4 + 15 + 1 + 196 + 63 + 192 + 0 + 1 + 0 + false + false + + + Kaypro, Pro-8 ROM - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 0 + + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + + + SIDES + + 5 + 31 + 3 + 196 + 95 + 128 + 0 + 2 + 0 + false + false + + + Kaypro Advent TurboROM - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 11 + 12 + 13 + 14 + 15 + + + SIDES + + 4 + 15 + 1 + 195 + 255 + 240 + 0 + 2 + 0 + false + false + + + Kaypro Advent TurboROM - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 3 + 7 + 0 + 185 + 31 + 192 + 0 + 3 + 0 + false + false + + + Kaypro Advent TurboROM - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 21 + 22 + 23 + 24 + 25 + + + SIDES + + 4 + 15 + 0 + 395 + 255 + 240 + 0 + 2 + 0 + false + false + + + Kontron - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + + + CYLINDERS + + 4 + 15 + 0 + 489 + 255 + 240 + 0 + 3 + 0 + false + false + + + Kontron/Zeiss - DSDD 96 tpi 5.25" - 128 x 16 + FM + LOW + 35 + 2 + 16 + 128 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + CYLINDERS + + 3 + 7 + 0 + 106 + 63 + 192 + 0 + 17 + 0 + false + false + + + Kontron Transient Recorder- DSDD 96 tpi 5.25"/3.5" - 256 x 16 + MFM + LOW + 77 + 2 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + EAGLE + + 4 + 15 + 0 + 299 + 255 + 240 + 0 + 4 + 0 + false + false + + + Lanier LTD READ-ONLY - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 4 + 15 + 0 + 318 + 127 + 192 + 0 + 1 + 0 + false + false + + + Lexoriter - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 4 + 15 + 1 + 159 + 127 + 192 + 0 + 0 + 0 + false + false + + + Lobo Max-80 - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 3 + 7 + 0 + 165 + 63 + 192 + 0 + 3 + 0 + false + false + + + Lobo Max-80 (256) - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + SIDES + + 4 + 15 + 0 + 172 + 127 + 192 + 0 + 3 + 0 + false + false + + + Lobo Max-80 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 191 + 127 + 192 + 0 + 3 + 0 + false + false + + + Lobo Max-80 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 391 + 255 + 240 + 0 + 3 + 0 + false + false + + + Lobo CP/M 2.2 - SSHD 8" - 256 x 30 + MFM + HIGH + 77 + 1 + 30 + 256 + 3 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + + 4 + 15 + 0 + 280 + 127 + 192 + 0 + 2 + 0 + false + false + + + LNW 2 - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 0 + + 0 + + 1 + 6 + 11 + 16 + 3 + 8 + 13 + 18 + 5 + 10 + 15 + 2 + 7 + 12 + 17 + 4 + 9 + 14 + + + + 4 + 15 + 1 + 82 + 63 + 128 + 0 + 3 + 0 + false + false + + + Lockheed-Martin Wire Harness Tester - DSDD 3.5" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 1 + + 1 + 4 + 2 + 5 + 3 + + + SIDES + + 4 + 15 + 0 + 394 + 127 + 192 + 0 + 2 + 0 + false + false + + + Macsym 150 - SSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 1 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 4 + 15 + 1 + 155 + 127 + 192 + 0 + 2 + 0 + false + false + + + MAI Basic Four - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 312 + 127 + 192 + 0 + 3 + 0 + false + false + + + Marconi Midata 510 - DSDD 3.5" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 3 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + EAGLE + + 5 + 31 + 3 + 197 + 127 + 128 + 0 + 2 + 0 + false + false + + + Memotech MaxBP - DSDD 3.5" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 394 + 191 + 224 + 0 + 2 + 0 + false + false + + + Memotech FDX - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 156 + 63 + 128 + 0 + 0 + 26 + false + false + + + Micro Source M6000 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 0 + + 11 + 15 + 19 + 13 + 17 + 12 + 16 + 20 + 14 + 18 + + + SIDES + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + Michels and Kleberhoff CP/M 3 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + EAGLE + + 4 + 15 + 0 + 394 + 127 + 192 + 0 + 2 + 0 + true + false + + + Michels and Kleberhoff CP/M 3 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 35 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + CYLINDERS + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + true + false + + + MicroMint SB180 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + + + + 1 + + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + + + SIDES + + 4 + 15 + 1 + 200 + 127 + 192 + 0 + 0 + 0 + false + false + + + Molecular Series 9 - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 2 + SIDES + + 4 + 15 + 1 + 179 + 127 + 192 + 0 + 4 + 0 + false + false + + + Molecular/Durango Poppy 54 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 3 + + 0 + + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + + + + 1 + + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + + + SIDES + + 4 + 15 + 0 + 389 + 127 + 192 + 0 + 4 + 0 + false + false + + + Molecular - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 4 + 15 + 1 + 249 + 127 + 192 + 0 + 0 + 0 + false + false + + + Monroe 8800 Series - SSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + + 4 + 15 + 1 + 153 + 63 + 128 + 0 + 3 + 0 + false + false + + + Monroe System 2000 - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 315 + 127 + 192 + 0 + 2 + 0 + false + false + + + Morrow MD2 - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 4 + 15 + 1 + 94 + 127 + 192 + 0 + 2 + 0 + false + false + + + Morrow MD3, 5, 11, 16, 34 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 1 + + 1 + 4 + 2 + 5 + 3 + + + SIDES + + 4 + 15 + 1 + 194 + 191 + 224 + 0 + 2 + 0 + false + false + + + Morrow TurboDOS - DSDD 48 tpi 5.25" - 1024 x 4 + MFM + LOW + 40 + 2 + 4 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + + + + 1 + + 1 + 2 + 3 + 4 + + + SIDES + + 4 + 15 + 0 + 155 + 127 + 192 + 0 + 2 + 0 + false + false + + + Morrow MD3...CP/M Plus - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 1 + + 1 + 4 + 2 + 5 + 3 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Morrow 5/11/34 - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 4 + 2 + 5 + 3 + + + + 4 + 15 + 1 + 92 + 127 + 192 + 0 + 3 + 0 + false + false + + + MOS 80 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + + 1 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + SIDES + + 5 + 31 + 0 + 244 + 251 + 192 + 0 + 3 + 0 + false + false + + + Multitech MIC-540 - DSDD 96 tpi 5.25" - 256 x 18 + MFM + LOW + 80 + 2 + 18 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + SIDES + + 4 + 15 + 0 + 356 + 127 + 192 + 0 + 4 + 0 + false + false + + + MUPD/MDISK, Side I - SSSD 96 tpi 5.25" - 256 x 10 + FM + LOW + 80 + 1 + 10 + 256 + 0 + + 0 + + 0 + 2 + 4 + 6 + 8 + 1 + 3 + 5 + 7 + 9 + + + + 4 + 15 + 1 + 96 + 127 + 192 + 0 + 3 + 0 + false + false + + + MUPD/MDISK, Side II - SSSD 96 tpi 5.25" - 256 x 10 + FM + LOW + 80 + 2 + 10 + 256 + 0 + + 0 + + 0 + 2 + 4 + 6 + 8 + 1 + 3 + 5 + 7 + 9 + + + + 0 + + 0 + 2 + 4 + 6 + 8 + 1 + 3 + 5 + 7 + 9 + + + EAGLE + + 4 + 15 + 1 + 96 + 127 + 192 + 0 + 83 + 0 + false + false + + + MSD Systems PSC-1 POS - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 5 + 31 + 3 + 158 + 127 + 128 + 0 + 1 + 0 + false + false + + + NCHQ System II - SSSD 48tpi 5.25" - 128 x 18 + FM + LOW + 40 + 1 + 18 + 128 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 3 + 7 + 0 + 84 + 63 + 192 + 0 + 3 + 0 + false + false + + + NCR Decision Mate V - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + EAGLE + + 4 + 15 + 1 + 153 + 127 + 192 + 0 + 3 + 0 + false + false + + + NCR FirstStep - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 16 + 4 + 8 + 12 + 15 + 3 + 7 + 11 + 14 + 2 + 6 + 10 + + + + 1 + + 1 + 5 + 9 + 13 + 16 + 4 + 8 + 12 + 15 + 3 + 7 + 11 + 14 + 2 + 6 + 10 + + + SIDES + + 4 + 15 + 0 + 275 + 255 + 240 + 0 + 6 + 0 + false + false + + + NEC PC-8801A - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 6 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + SIDES + + 5 + 31 + 3 + 242 + 127 + 128 + 0 + 4 + 0 + false + false + + + NEC PC-8801A - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 6 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + + + SIDES + + 5 + 31 + 1 + 280 + 127 + 128 + 0 + 4 + 0 + false + false + + + NEC PC-8801A - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 599 + 255 + 240 + 0 + 4 + 0 + false + false + + + NEC PC-8001A - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 3 + 7 + 0 + 151 + 63 + 192 + 0 + 2 + 0 + false + false + + + NEC PC-8001B - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 151 + 63 + 128 + 0 + 2 + 0 + false + false + + + NEC PC 8801A - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 1 + 151 + 127 + 192 + 0 + 4 + 0 + false + false + + + NEC PC 8801A - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + NEC PC 8500/8431A, Starlet - DSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 4 + 15 + 1 + 151 + 127 + 192 + 0 + 4 + 0 + false + false + + + NEC APC CP/M-86 - DSHD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + + + + 4 + 15 + 0 + 494 + 255 + 240 + 0 + 2 + 0 + false + false + + + NEC APC TurboDOS - SSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 1 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 4 + 15 + 0 + 308 + 224 + 224 + 0 + 0 + 0 + false + false + + + New Brain - SSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 5 + 31 + 3 + 97 + 127 + 128 + 0 + 2 + 0 + false + false + + + Niat - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + + 1 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + CYLINDERS + + 5 + 31 + 3 + 157 + 127 + 128 + 0 + 2 + 0 + false + false + + + Nixdorf 8810/30 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 384 + 127 + 192 + 0 + 6 + 0 + false + false + + + Norsonic 830/836 - DSDD 3.5" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 199 + 127 + 192 + 0 + 0 + 0 + false + false + + + Numeridex 7000 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 1 + + 28 + 34 + 40 + 46 + 52 + 32 + 38 + 44 + 50 + 30 + 36 + 42 + 48 + + + SIDES + + 5 + 31 + 3 + 248 + 127 + 128 + 0 + 2 + 0 + false + false + + + Octagon 8/16 - SSDD 8" - 1024 x 9 + MFM + HIGH + 77 + 1 + 9 + 1024 + 3 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 5 + 31 + 1 + 167 + 127 + 128 + 0 + 2 + 0 + false + false + + + OEM Screen Typist - SSDD 3.5" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 1 + 94 + 63 + 128 + 0 + 2 + 0 + false + false + + + Olivetti ETV300 - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Olivetti M20 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 3 + 7 + 0 + 255 + 63 + 192 + 0 + 3 + 0 + false + false + + + Olivetti 250, CWP1 - SSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + SIDES + + 4 + 15 + 1 + 157 + 63 + 128 + 0 + 1 + 0 + false + false + + + Olivetti ETV 1010, CP/M 86 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 198 + 127 + 192 + 0 + 1 + 0 + false + false + + + Olivetti ETV 112 - SSDD 3.5" - 256 x 18 + MFM + LOW + 80 + 1 + 18 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 4 + 15 + 0 + 174 + 191 + 224 + 0 + 2 + 0 + false + false + + + Olympia EX-100 - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + Olympia ETX II - SSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 170 + 127 + 240 + 0 + 2 + 0 + false + false + + + Olympia Olytext 20 - DSDD 3.5" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 312 + 127 + 192 + 0 + 4 + 0 + false + false + + + Osborne 1 - SSSD 48 tpi 5.25" - 256 x 10 + FM + LOW + 40 + 1 + 10 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 4 + 15 + 1 + 45 + 63 + 128 + 0 + 3 + 0 + false + false + + + Osborne 1 - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 3 + 7 + 0 + 184 + 63 + 192 + 0 + 3 + 0 + false + false + + + Osborne G2 System - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + Osborne G2 System - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 389 + 255 + 240 + 0 + 4 + 0 + false + false + + + Osborne 1 + Osmosis - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + SIDES + + 4 + 15 + 0 + 384 + 127 + 192 + 0 + 6 + 0 + false + false + + + Osborne Nuevo - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 6 + 8 + 10 + 7 + 9 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Osborne Vixen - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Osborne Executive w/Z3 - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 0 + 395 + 127 + 248 + 0 + 2 + 0 + false + false + + + Osborne Executive Dig. Arts - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 248 + 0 + 2 + 0 + false + false + + + Osborne Nuevo 2.1 - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 394 + 255 + 240 + 0 + 2 + 0 + false + false + + + OSM Zeus 4 - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 311 + 127 + 192 + 0 + 4 + 0 + false + false + + + Otrona Attache - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + EAGLE + + 4 + 15 + 1 + 181 + 127 + 192 + 0 + 3 + 0 + false + false + + + Otrona Attache - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + CYLINDERS + + 4 + 15 + 0 + 386 + 127 + 192 + 0 + 3 + 0 + false + false + + + Potter & Brumfield - SSSD 48 tpi 5.25" - 128 x 18 + FM + LOW + 40 + 1 + 18 + 128 + 0 + + 0 + + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + + + + 3 + 7 + 0 + 83 + 63 + 192 + 0 + 3 + 0 + false + false + + + Pegasus Data Logger - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + 9 + + + SIDES + + 4 + 15 + 0 + 170 + 63 + 128 + 0 + 6 + 0 + false + false + + + People's World Computer - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + CYLINDERS + + 4 + 15 + 0 + 398 + 127 + 120 + 0 + 0 + 0 + false + false + + + People's World Computer Boot - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + CYLINDERS + + 4 + 15 + 0 + 397 + 127 + 240 + 0 + 0 + 0 + false + false + + + Pericom - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 0 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 0 + 395 + 127 + 192 + 0 + 2 + 0 + false + false + + + Philips PC-2010 - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 3 + 7 + 0 + 151 + 63 + 192 + 0 + 2 + 0 + false + false + + + Philips PC-2012 - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + SIDES + + 5 + 31 + 3 + 157 + 127 + 128 + 0 + 2 + 0 + false + false + + + Philips PC-3000 - 3004 - SSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 4 + 15 + 1 + 147 + 63 + 192 + 0 + 3 + 0 + false + false + + + Physical Acoutstics - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 3 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + CYLINDERS + + 4 + 15 + 1 + 173 + 127 + 192 + 0 + 3 + 0 + false + false + + + Pied Piper - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + SIDES + + 4 + 15 + 0 + 391 + 255 + 240 + 0 + 3 + 0 + false + false + + + Proglas 770K - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 388 + 255 + 240 + 0 + 2 + 0 + false + false + + + Pulsar LBB - SSHD 8" - 512 x 17 + MFM + HIGH + 77 + 1 + 17 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 2 + 5 + 8 + 11 + 14 + 17 + 3 + 6 + 9 + 12 + 15 + + + + 4 + 15 + 0 + 317 + 127 + 192 + 0 + 2 + 0 + false + false + + + Research Machines Limited 380Z - 128 x 16 + FM + LOW + 40 + 1 + 16 + 128 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 3 + 7 + 0 + 74 + 63 + 192 + 0 + 3 + 0 + false + false + + + Royal Alphatronic - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 151 + 127 + 192 + 0 + 4 + 0 + false + false + + + Sage IV - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 4 + 15 + 1 + 155 + 63 + 128 + 0 + 2 + 0 + false + false + + + Sage IV - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 315 + 63 + 128 + 0 + 2 + 0 + false + false + + + Sanyo MBC-1000, MBC-1150 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + SIDES + + 4 + 15 + 1 + 155 + 63 + 128 + 0 + 2 + 0 + false + false + + + Sanyo MBC-2000 - SSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 1 + 16 + 256 + 0 + + 0 + + 1 + 6 + 11 + 16 + 5 + 10 + 15 + 4 + 9 + 14 + 3 + 8 + 13 + 2 + 7 + 12 + + + + 4 + 15 + 1 + 152 + 63 + 128 + 0 + 4 + 0 + false + false + + + Sanyo MBC-3000 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 1 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + SIDES + + 5 + 31 + 3 + 237 + 127 + 128 + 0 + 4 + 0 + false + false + + + Sanco 8001 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + + 4 + 15 + 0 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + Schneider CPC 6128 Side 1 - DSDD 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 2 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 180 + 63 + 192 + 0 + 0 + 0 + false + false + + + Schneider CPC 6128 Side 2 - DSDD 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 180 + 63 + 192 + 0 + 40 + 0 + false + false + + + S.D. Systems 40 track - SSDD 3.5" - 256 x 18 + MFM + LOW + 80 + 1 + 18 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 4 + 15 + 0 + 84 + 127 + 192 + 0 + 2 + 0 + false + false + + + S.D. Systems 80 track - DSDD 3.5" - 256 x 18 + MFM + LOW + 80 + 2 + 18 + 256 + 0 + SIDES + + 5 + 31 + 0 + 176 + 127 + 128 + 0 + 2 + 0 + false + false + + + S.D. Systems 80 track - SSDD 5.25" - 256 x 18 + MFM + LOW + 80 + 1 + 18 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 4 + 15 + 0 + 175 + 127 + 192 + 0 + 2 + 0 + false + false + + + S.D. Systems - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 1 + + 0 + + 1 + 5 + 9 + 13 + 17 + 21 + 25 + 3 + 7 + 11 + 15 + 19 + 23 + 2 + 6 + 10 + 14 + 18 + 22 + 26 + + + + 4 + 15 + 1 + 240 + 127 + 192 + 0 + 3 + 0 + false + false + + + Seiko - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 315 + 127 + 192 + 0 + 2 + 0 + false + false + + + SemiDisk DT42 - DSHD 96 tpi 5.25" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 2 + 5 + 8 + 11 + 14 + 3 + 6 + 9 + 12 + 15 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 2 + 5 + 8 + 11 + 14 + 3 + 6 + 9 + 12 + 15 + + + SIDES + + 4 + 15 + 0 + 562 + 255 + 240 + 0 + 4 + 0 + false + false + + + Sharp MZ-80 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 1 + 169 + 127 + 192 + 0 + 2 + 0 + true + false + + + Sharp MZ-80B - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 1 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 1 + 195 + 127 + 192 + 0 + 2 + 0 + true + false + + + Sharp 3500/5500 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + SIDES + + 4 + 15 + 1 + 151 + 127 + 192 + 0 + 4 + 0 + false + false + + + Sharp 5600 - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + + + SIDES + + 4 + 15 + 0 + 312 + 127 + 192 + 0 + 4 + 0 + false + false + + + Sharp MZ 3541 - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Shelton SIG/NET 2 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + SIDES + + 4 + 15 + 1 + 195 + 63 + 128 + 0 + 2 + 0 + true + false + + + Shelton SIG/NET 2 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + SIDES + + 4 + 15 + 0 + 395 + 255 + 240 + 0 + 2 + 0 + true + false + + + Siemens PG-685 DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 350 + 255 + 240 + 0 + 4 + 0 + false + false + + + Siemens PG-675 DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 170 + 63 + 128 + 0 + 4 + 0 + false + false + + + Silver-Reed WP System - DSDD 3.5" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 3 + 5 + 2 + 4 + + + + 1 + + 1 + 3 + 5 + 2 + 4 + + + SIDES + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + Smart Aleck - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Sorbus TurboDOS - 5.25" DSHD (or 8" DSDD) - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 5 + 31 + 1 + 308 + 255 + 192 + 0 + 0 + 0 + false + false + + + Sony SMC-70 - SSDD 3.5" - 256 x 16 + MFM + LOW + 70 + 1 + 16 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 3 + 6 + 9 + 12 + 15 + 2 + 5 + 8 + 11 + 14 + + + + 4 + 15 + 1 + 135 + 127 + 192 + 0 + 2 + 0 + false + false + + + Spectravideo 318/328 - SSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 1 + 17 + 256 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 3 + 7 + 0 + 156 + 63 + 192 + 0 + 3 + 0 + false + false + + + Spectravideo SV-328 - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 2 + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + CYLINDERS + + 4 + 15 + 1 + 162 + 63 + 128 + 0 + 3 + 0 + false + false + + + Sperry UTS 30, UTS 5000 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 354 + 383 + 252 + 0 + 2 + 0 + false + false + + + Spectravideo - SSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 1 + 17 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 3 + 7 + 0 + 157 + 63 + 192 + 0 + 3 + 0 + false + false + + + Spectravideo - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + CYLINDERS + + 4 + 15 + 1 + 163 + 63 + 128 + 0 + 3 + 0 + false + false + + + Spectravideo - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 1 + 197 + 63 + 128 + 0 + 1 + 0 + false + false + + + Spectravideo - SSDD 3.5" - 512 x 9 + MFM + LOW + 80 + 1 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 1 + 163 + 63 + 128 + 0 + 3 + 0 + false + false + + + Superbrain JR - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 35 + 1 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 4 + 15 + 1 + 81 + 63 + 128 + 0 + 2 + 0 + true + false + + + Superbrain 40 track - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 4 + 15 + 1 + 94 + 63 + 128 + 0 + 2 + 0 + true + false + + + Superbrain QD - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 35 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + CYLINDERS + + 4 + 15 + 1 + 169 + 63 + 128 + 0 + 2 + 0 + true + false + + + Superbrain II - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + CYLINDERS + + 5 + 31 + 3 + 196 + 127 + 192 + 0 + 3 + 0 + true + false + + + Superbrain - SSDD 48 tpi 5.25" - 128 x 30 + MFM + LOW + 40 + 1 + 30 + 128 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 28 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + 29 + + + + 3 + 7 + 0 + 142 + 63 + 192 + 0 + 2 + 0 + true + false + + + System Group 2800 - DSDD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 5 + 31 + 1 + 303 + 255 + 192 + 0 + 2 + 0 + false + false + + + Tarbell - DSDD 8" - 512 x 15 + MFM + HIGH + 77 + 2 + 15 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 12 + 13 + 14 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 12 + 13 + 14 + + + SIDES + + 5 + 31 + 0 + 303 + 169 + 192 + 0 + 2 + 0 + false + false + + + Tatung TPC2000 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 3 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + EAGLE + + 4 + 15 + 0 + 354 + 127 + 192 + 0 + 2 + 0 + false + false + + + Techron TEF 10 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + + 1 + + 1 + 4 + 7 + 10 + 3 + 6 + 9 + 2 + 5 + 8 + + + SIDES + + 4 + 15 + 0 + 394 + 319 + 248 + 0 + 2 + 0 + false + false + + + Techron TEF 12 - DSHD 96 tpi 5.25" - 512 x 17 + MFM + HIGH + 80 + 2 + 17 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + SIDES + + 4 + 15 + 0 + 670 + 767 + 255 + 240 + 4 + 0 + false + false + + + Tektronix 4170 - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + CYLINDERS + + 4 + 15 + 0 + 153 + 63 + 128 + 0 + 1 + 0 + false + false + + + Teletek - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 4 + 15 + 1 + 242 + 127 + 192 + 0 + 2 + 0 + false + false + + + Teletek Systemaster - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 7 + 13 + 2 + 8 + 14 + 3 + 9 + 15 + 4 + 10 + 16 + 5 + 11 + 17 + 6 + 12 + 18 + + + + 1 + + 1 + 7 + 13 + 2 + 8 + 14 + 3 + 9 + 15 + 4 + 10 + 16 + 5 + 11 + 17 + 6 + 12 + 18 + + + CYLINDERS + + 4 + 15 + 1 + 172 + 127 + 192 + 0 + 3 + 0 + false + false + + + Teletek Systemaster - DSDD 96 tpi 5.25" - 256 x 18 + MFM + LOW + 80 + 2 + 18 + 256 + 0 + + 0 + + 1 + 7 + 13 + 2 + 8 + 14 + 3 + 9 + 15 + 4 + 10 + 16 + 5 + 11 + 17 + 6 + 12 + 18 + + + + 1 + + 1 + 7 + 13 + 2 + 8 + 14 + 3 + 9 + 15 + 4 + 10 + 16 + 5 + 11 + 17 + 6 + 12 + 18 + + + EAGLE + + 4 + 15 + 0 + 353 + 127 + 192 + 0 + 3 + 0 + false + false + + + TeleVideo 8nn/TPC-1 CP/M - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 6 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + SIDES + + 4 + 15 + 0 + 170 + 63 + 128 + 0 + 4 + 0 + false + false + + + TeleVideo 1603 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 354 + 127 + 192 + 0 + 2 + 0 + false + false + + + TeleVideo 806 TurboDOS - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 200 + 127 + 192 + 0 + 0 + 0 + false + false + + + TeleVideo 8nn TurboDOS - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 6 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + SIDES + + 4 + 15 + 1 + 170 + 63 + 128 + 0 + 4 + 0 + false + false + + + Timex/Sinclair 2068+AERCO FD-68 RP/M - DSDD 48 tpi 5.25" -1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 189 + 127 + 192 + 0 + 4 + 0 + false + false + + + Tokyo Electron 80W - DSHD 3.5" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 6 + 63 + 3 + 160 + 255 + 128 + 0 + 0 + 0 + false + false + + + Toshiba T100, T200 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + + 1 + + 1 + 5 + 9 + 13 + 2 + 6 + 10 + 14 + 3 + 7 + 11 + 15 + 4 + 8 + 12 + 16 + + + SIDES + + 3 + 7 + 0 + 255 + 63 + 192 + 0 + 6 + 0 + false + false + + + Toshiba 300 - DSDD 96 tpi 5.25" - 512 x 8 + MFM + LOW + 80 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 0 + 318 + 127 + 192 + 0 + 1 + 0 + false + false + + + Toshiba T-250 - DSHD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + + + + 1 + + 1 + 4 + 7 + 10 + 13 + 16 + 19 + 22 + 25 + 2 + 5 + 8 + 11 + 14 + 17 + 20 + 23 + 26 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + + + SIDES + + 4 + 15 + 0 + 487 + 63 + 128 + 0 + 4 + 0 + false + false + + + Transtec - SSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + TRS-80 Model 1, Omikron CP/M - SSSD 48 tpi 5.25" - 128 x 18 + FM + LOW + 35 + 1 + 18 + 128 + 0 + + 0 + + 1 + 5 + 9 + 13 + 17 + 3 + 7 + 11 + 15 + 2 + 6 + 10 + 14 + 18 + 4 + 8 + 12 + 16 + + + + 3 + 7 + 0 + 71 + 63 + 192 + 0 + 3 + 0 + false + false + + + TRS-80 Model 1, Bigmem CP/M - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 0 + + 0 + + 1 + 7 + 13 + 19 + 25 + 5 + 11 + 17 + 23 + 3 + 9 + 15 + 21 + 2 + 8 + 14 + + + + 4 + 15 + 1 + 243 + 63 + 128 + 0 + 2 + 0 + false + false + + + TRS-80 Model 1, ColorPower II - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + TRS-80, Pickles & Trout CP/M - SSDD 8" - 512 x 16 + MFM + HIGH + 77 + 1 + 16 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 4 + 15 + 0 + 299 + 127 + 192 + 0 + 2 + 0 + false + false + + + TRS-80, Holmes CP/M - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 4 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + + + SIDES + + 4 + 15 + 1 + 190 + 63 + 240 + 0 + 2 + 0 + false + false + + + TRS-80, MM CP/M - SSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 1 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 4 + 15 + 1 + 94 + 127 + 192 + 0 + 2 + 0 + false + false + + + TRS-80 Model 4, 4P; MT CP/M - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 4 + 15 + 1 + 84 + 127 + 192 + 0 + 2 + 0 + false + false + + + TRS-80 Model 4, 4P; MT CP/M - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + SIDES + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + TRS-80 Model 4, 4P - SSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 1 + 8 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 3 + 7 + 0 + 155 + 63 + 192 + 0 + 1 + 0 + false + false + + + TRS-80 Model 4P-Montezuma800K - DSDD 96tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + 10 + + + SIDES + + 4 + 15 + 0 + 399 + 127 + 192 + 0 + 0 + 0 + false + false + + + TRS-80 II/12/16 Aton CP/M - DSHD 8" - 1024 x 8 + MFM + HIGH + 77 + 2 + 8 + 1024 + 3 + + 0 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + + 1 + + 1 + 4 + 7 + 2 + 5 + 8 + 3 + 6 + + + SIDES + + 4 + 15 + 0 + 608 + 191 + 224 + 0 + 2 + 0 + false + false + + + TRS-80 II/12/16 Pickles & Trout - DSHD 8" - 512 x 16 + MFM + HIGH + 77 + 2 + 16 + 512 + 4 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 4 + 15 + 0 + 608 + 191 + 224 + 0 + 2 + 0 + false + false + + + TRS-80 Model 4, Montezuma - DSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 2 + 18 + 256 + 0 + + 0 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + + 1 + + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + + + EAGLE + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + U-Micro 1000 - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 4 + 15 + 0 + 395 + 127 + 192 + 0 + 2 + 0 + false + false + + + Varian Spectra AA/20, DS-15 - DSDD 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + EAGLE + + 3 + 7 + 0 + 317 + 63 + 96 + 0 + 0 + 2 + false + false + + + Vector 4 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + EAGLE + + 4 + 15 + 0 + 356 + 127 + 192 + 0 + 1 + 0 + false + false + + + Visual 1050 - SSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 1 + 10 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 2 + 0 + false + false + + + Wangwriter - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 1 + 155 + 127 + 192 + 0 + 2 + 0 + false + false + + + Wave Mate Bullet - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 3 + 7 + 0 + 189 + 63 + 192 + 0 + 2 + 0 + false + false + + + Wave Mate Bullet - DSDD 96 tpi 5.25" - 1024 x 5 + MFM + LOW + 80 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 394 + 127 + 192 + 0 + 2 + 0 + false + false + + + Wave Mate Bullet - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + Wave Mate Bullet - SSHD 8" - 1024 x 9 + MFM + HIGH + 77 + 1 + 9 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 0 + 336 + 127 + 192 + 0 + 2 + 0 + false + false + + + Xerox - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + CYLINDERS + + 4 + 15 + 1 + 170 + 127 + 192 + 0 + 2 + 0 + false + false + + + Xerox 820 - SSSD 48 tpi 5.25" - 128 x 18 + FM + LOW + 40 + 1 + 18 + 128 + 0 + + 0 + + 1 + 6 + 11 + 16 + 3 + 8 + 13 + 18 + 5 + 10 + 15 + 2 + 7 + 12 + 17 + 4 + 9 + 14 + + + + 3 + 7 + 0 + 83 + 31 + 128 + 0 + 3 + 0 + false + false + + + Xerox 820 II - SSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 1 + 17 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 3 + 7 + 0 + 156 + 63 + 192 + 0 + 3 + 0 + false + false + + + Xerox 820-II, 16/8 - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + EAGLE + + 4 + 15 + 1 + 162 + 63 + 128 + 0 + 3 + 0 + false + false + + + Xerox 16/8 - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 5 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 4 + 15 + 1 + 242 + 127 + 192 + 0 + 2 + 0 + false + false + + + XEROX 16/8 - DSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 2 + 9 + 512 + 2 + CYLINDERS + + 4 + 15 + 1 + 162 + 63 + 128 + 0 + 2 + 0 + false + false + + + Xerox 820, S/W Publishers DD - SSDD 48 tpi 5.25" - 256 x 18 + MFM + LOW + 40 + 1 + 18 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + + + + 3 + 7 + 0 + 166 + 63 + 192 + 0 + 3 + 0 + false + false + + + Xerox 3700 Laser Printer - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 3 + CYLINDERS + + 4 + 15 + 1 + 162 + 63 + 192 + 0 + 3 + 0 + false + false + + + Xerox 16/8, 820 II - SSDD 48 tpi 5.25" + MFM + LOW + 40 + 1 + 17 + 256 + 3 + + 3 + 7 + 0 + 156 + 63 + 192 + 0 + 3 + 0 + false + false + + + Xerox 16/8 - SSDD 48 tpi 5.25" - 512 x 9 + MFM + LOW + 40 + 1 + 9 + 512 + 3 + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Xerox 16/8 Special - SSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 1 + 8 + 512 + 3 + + 3 + 7 + 0 + 151 + 63 + 192 + 0 + 2 + 0 + false + false + + + Xerox 16/8, 820-II - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 3 + EAGLE + + 4 + 15 + 1 + 162 + 63 + 128 + 0 + 3 + 0 + false + false + + + Xerox 16/8 Special - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 3 + CYLINDERS + + 4 + 15 + 1 + 155 + 63 + 128 + 0 + 2 + 0 + false + false + + + Xerox 3700 Laser Printer - DSDD 48 tpi 5.25" - 256 x 17 + MFM + LOW + 40 + 2 + 17 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + + + CYLINDERS + + 4 + 15 + 1 + 162 + 63 + 192 + 0 + 3 + 0 + false + false + + + Xor 5 - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 6 + 2 + 7 + 3 + 8 + 4 + 9 + 5 + 10 + + + + 0 + + 1 + 6 + 2 + 7 + 3 + 8 + 4 + 9 + 5 + 10 + + + SIDES + + 4 + 15 + 1 + 191 + 127 + 192 + 0 + 3 + 0 + false + false + + + XYZ - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 0 + + 0 + + 1 + 5 + 9 + 3 + 7 + 2 + 6 + 10 + 4 + 8 + + + + 1 + + 11 + 15 + 19 + 13 + 17 + 12 + 16 + 20 + 14 + 18 + + + SIDES + + 4 + 15 + 1 + 194 + 127 + 192 + 0 + 4 + 0 + false + false + + + Zeiss Video Analysis System - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + CYLINDERS + + 4 + 15 + 0 + 299 + 255 + 240 + 0 + 4 + 0 + false + false + + + Zenith Z-37 Disk - SSSD 48 tpi 5.25" - 256 x 10 + FM + LOW + 40 + 1 + 10 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 3 + 7 + 0 + 91 + 63 + 192 + 0 + 3 + 0 + false + false + + + Zenith Z-37 Disk - DSDD 96 tpi 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 315 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z89, Heath H89 - DSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 155 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z90 - SSDD 48 tpi 5.25" - 256 x 16 + MFM + LOW + 40 + 1 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 3 + 7 + 0 + 151 + 127 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z-100 - SSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 1 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 3 + 7 + 0 + 151 + 127 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z-100 - DSDD 48 tpi 5.25" - 512 x 8 + MFM + LOW + 40 + 2 + 8 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + SIDES + + 4 + 15 + 1 + 155 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z-100 - SSDD 8" - 256 x 26 + MFM + HIGH + 77 + 1 + 26 + 256 + 0 + + 0 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + + + + 4 + 15 + 1 + 242 + 127 + 192 + 0 + 2 + 0 + false + false + + + Zenith Z-37 Disk - DSDD 96 (Half drive) 5.25" - 256 x 16 + MFM + LOW + 80 + 2 + 16 + 256 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + SIDES + + 4 + 15 + 0 + 155 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith/Heath H-89 Ext Density - DSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 2 + 5 + 1024 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 195 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z-100, Heath H-47 - DSDD 8" - 256 x 26 + MFM + HIGH + 77 + 2 + 26 + 256 + 0 + + 0 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + 15 + 24 + 7 + 16 + 25 + 8 + 17 + 26 + 9 + 18 + + + + 1 + + 1 + 10 + 19 + 2 + 11 + 20 + 3 + 12 + 21 + 4 + 13 + 22 + 5 + 14 + 23 + 6 + 15 + 24 + 7 + 16 + 25 + 8 + 17 + 26 + 9 + 18 + + + SIDES + + 4 + 15 + 0 + 497 + 255 + 240 + 0 + 2 + 0 + false + false + + + Zenith Z-37 - SSDD 48 tpi 5.25" - 1024 x 5 + MFM + LOW + 40 + 1 + 5 + 1024 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 3 + 7 + 0 + 190 + 127 + 240 + 0 + 2 + 0 + false + false + + + Zenith/Heath H89/H90 Magnolia 7736 - SSHD 8" - 512 x 16 + MFM + HIGH + 77 + 1 + 16 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 4 + 15 + 0 + 299 + 191 + 224 + 0 + 2 + 0 + false + false + + + Zorba - DSDD 48 tpi 5.25" - 512 x 10 + MFM + LOW + 40 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + SIDES + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + Zorba - DSDD 96 tpi 5.25" - 512 x 10 + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + SIDES + + 5 + 31 + 3 + 194 + 127 + 128 + 0 + 2 + 0 + false + false + + + PIC-DISK SSDD 96tpi 3.5" + MFM + LOW + 80 + 1 + 9 + 512 + 1 + + 0 + + 1 + 3 + 5 + 7 + 9 + 2 + 4 + 6 + 8 + + + + 4 + 15 + 1 + 194 + 63 + 128 + 0 + 2 + 0 + false + false + + + SAM COUPE Pro-DOS - DSDD 160 tpi 3.5" + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 356 + 255 + 240 + 0 + 1 + 0 + false + false + + + Acorn CPM + MFM + LOW + 80 + 2 + 10 + 256 + 5 + + 0 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + CYLINDERS + + 4 + 15 + 1 + 200 + 127 + 192 + 0 + 3 + 0 + false + false + + + CPC 178K Data 40trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 40 + 2 + 9 + 512 + 5 + + 0 + + 0 + + + + 0 + + 0 + + + EAGLE + + 3 + 7 + 0 + 179 + 63 + 192 + 0 + 40 + 0 + false + false + + + CPC 187K Data 42trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 42 + 2 + 9 + 512 + 5 + + 0 + + 0 + + + + 0 + + 0 + + + EAGLE + + 3 + 7 + 0 + 188 + 63 + 192 + 0 + 42 + 0 + false + false + + + CPC-B360 358K Data 80trk 9sct 64dir 2Kpb Side 1 + MFM + LOW + 80 + 1 + 9 + 512 + 2 + + 0 + + 0 + + + + 4 + 15 + 1 + 179 + 63 + 128 + 0 + 0 + 0 + false + false + + + CPC-B360 358K Data 80trk 9sct 64dir 2Kpb Side 2 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 0 + + + + 0 + + 0 + + + EAGLE + + 4 + 15 + 1 + 179 + 63 + 128 + 0 + 80 + 0 + false + false + + + CPC 356K Data 40trk 9sct 128dir 2Kpb Two Sides + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 0 + + + + 1 + + 0 + + + SIDES + + 4 + 15 + 1 + 179 + 127 + 192 + 0 + 0 + 0 + false + false + + + DOBBERTIN 716K Data 80trk 9sct 128dir 4Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 0 + + + + 1 + + 0 + + + SIDES + + 5 + 31 + 3 + 179 + 127 + 128 + 0 + 0 + 0 + false + false + + + CPC-STD 169K System 40trk 9sct 64dir 1Kpb Side 1 + MFM + LOW + 40 + 1 + 9 + 512 + 5 + + 0 + + 41 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + CPC 169K System 40trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 40 + 2 + 9 + 512 + 5 + + 0 + + 41 + + + + 0 + + 41 + + + EAGLE + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 42 + 0 + false + false + + + CPC 178K System 42trk 9sct 64dir 1Kpb Side 1 + MFM + LOW + 42 + 1 + 9 + 512 + 5 + + 0 + + 41 + + + + 3 + 7 + 0 + 179 + 63 + 192 + 0 + 2 + 0 + false + false + + + CPC 178K System 42trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 42 + 2 + 9 + 512 + 5 + + 0 + + 41 + + + + 0 + + 41 + + + EAGLE + + 3 + 7 + 0 + 179 + 63 + 192 + 0 + 44 + 0 + false + false + + + CPC 253K System 60trk 9sct 64dir 1Kpb Side 1 + MFM + LOW + 60 + 1 + 9 + 512 + 5 + + 0 + + 41 + + + + 3 + 7 + 0 + 254 + 63 + 192 + 0 + 2 + 0 + false + false + + + CPC 253K System 60trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 60 + 2 + 9 + 512 + 5 + + 0 + + 41 + + + + 0 + + 41 + + + EAGLE + + 3 + 7 + 0 + 254 + 63 + 192 + 0 + 62 + 0 + false + false + + + CPC-B360 348K System 80trk 9sct 64dir 2Kpb Side 1 + MFM + LOW + 80 + 1 + 9 + 512 + 2 + + 0 + + 41 + + + + 4 + 15 + 1 + 174 + 63 + 128 + 0 + 2 + 0 + false + false + + + CPC-B360 348K System 80trk 9sct 64dir 2Kpb Side 2 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 41 + + + + 0 + + 41 + + + EAGLE + + 4 + 15 + 1 + 174 + 63 + 128 + 0 + 82 + 0 + false + false + + + CPC 346K System 40trk 9sct 128dir 2Kpb Two Sides + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 41 + + + + 1 + + 41 + + + SIDES + + 4 + 15 + 1 + 174 + 127 + 192 + 0 + 2 + 0 + false + false + + + CPC 344K System 80trk 9sct 128dir 4Kpb Side 1 + MFM + LOW + 80 + 1 + 9 + 512 + 5 + + 0 + + 41 + + + + 5 + 31 + 3 + 86 + 127 + 128 + 0 + 2 + 0 + false + false + + + CPC 344K System 80trk 9sct 128dir 4Kpb Side 2 + MFM + LOW + 80 + 2 + 9 + 512 + 5 + + 0 + + 41 + + + + 0 + + 41 + + + EAGLE + + 5 + 31 + 3 + 86 + 127 + 128 + 0 + 82 + 0 + false + false + + + DOBBERTIN 704K System 80trk 9sct 128dir 4Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 41 + + + + 1 + + 41 + + + SIDES + + 5 + 31 + 3 + 176 + 127 + 128 + 0 + 2 + 0 + false + false + + + ReadBIG 706K System 80trk 9sct 128dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 41 + + + + 1 + + 41 + + + SIDES + + 4 + 15 + 0 + 354 + 127 + 192 + 0 + 2 + 0 + false + false + + + CPC-STD 154K Ibm-Cpm86 40trk 8sct 64dir 1Kpb Side 1 + MFM + LOW + 40 + 1 + 8 + 512 + 2 + + 0 + + 1 + + + + 3 + 7 + 0 + 155 + 63 + 192 + 0 + 1 + 0 + false + false + + + CPC 154K Ibm-Cpm86 40trk 8sct 64dir 1Kpb Side 2 + MFM + LOW + 40 + 2 + 8 + 512 + 2 + + 0 + + 1 + + + + 0 + + 1 + + + EAGLE + + 3 + 7 + 0 + 155 + 63 + 192 + 0 + 41 + 0 + false + false + + + PCW-STD 173K Format 40trk 9sct 64dir 1Kpb Side 1 + MFM + LOW + 40 + 1 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 174 + 63 + 192 + 0 + 1 + 0 + false + false + + + PCW 173K Format 40trk 9sct 64dir 1Kpb Side 2 + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + EAGLE + + 3 + 7 + 0 + 174 + 63 + 192 + 0 + 41 + 0 + false + false + + + PCW 346K Format 40trk 9sct 256dir 2Kpb Two Sides + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 176 + 255 + 240 + 0 + 1 + 0 + false + false + + + PCW 706K Format 80trk 9sct 256dir 2Kpb Two Sides + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 4 + 15 + 0 + 356 + 255 + 240 + 0 + 1 + 0 + false + false + + + PCW 784K Format 80trk 10sct 256dir 4Kpb Two Sides + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 5 + 31 + 3 + 197 + 255 + 192 + 0 + 1 + 0 + false + false + + + DiskPara3 796K Format 80trk 10sct 128dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + + + + 1 + + 1 + + + SIDES + + 4 + 15 + 0 + 399 + 127 + 192 + 0 + 0 + 0 + false + false + + + DiskPara 824K Format 83trk 10sct 192dir 2Kpb Two Sides + MFM + LOW + 83 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 0 + + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + SIDES + + 4 + 15 + 0 + 414 + 191 + 224 + 0 + 0 + 0 + false + false + + + VORTEX 704K Format 80trk 9sct 128dir 4Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + + + + 1 + + 1 + + + SIDES + + 5 + 31 + 3 + 176 + 127 + 128 + 0 + 2 + 0 + false + false + + + RAMDOS-D1 716K Format 80trk 9sct 128dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 1 + + + + 1 + + 1 + + + SIDES + + 4 + 15 + 0 + 359 + 127 + 192 + 0 + 0 + 0 + false + false + + + RAMDOS-D10 796K Format 80trk 10sct 128dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 11 + + + + 1 + + 11 + + + SIDES + + 4 + 15 + 0 + 399 + 127 + 192 + 0 + 0 + 0 + false + false + + + RAMDOS-D2 712K Format 80trk 9sct 256dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 9 + 512 + 0 + + 0 + + 21 + + + + 1 + + 21 + + + SIDES + + 4 + 15 + 0 + 359 + 255 + 240 + 0 + 0 + 0 + false + false + + + RAMDOS-D20 792K Format 80trk 10sct 256dir 2Kpb Two Sides + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 31 + + + + 1 + + 31 + + + SIDES + + 4 + 15 + 0 + 399 + 255 + 240 + 0 + 0 + 0 + false + false + + + Amstrad ZX Spectrum +3 - SSDD 64dir 1Kpb 180K - 173K user free + MFM + LOW + 40 + 1 + 9 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 174 + 63 + 192 + 0 + 1 + 0 + false + false + + + Amstrad ZX Spectrum +3 - DSDD 128dir 2Kpb 720K - 710K user free + MFM + LOW + 80 + 2 + 9 + 512 + 3 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 356 + 127 + 192 + 0 + 1 + 0 + false + false + + + Altos Series 5 - DSDD 96 tpi 5.25" - 512 x 9 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 176 + 255 + 192 + 0 + 64 + 0 + false + false + + + PC1715 SCP (80*2* 5,1024 4 OFS 4k DIR) 5.25" + MFM + LOW + 80 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 389 + 127 + 192 + 0 + 4 + 0 + false + false + + + PC1715 CPA (80*2* 5,1024 0 OFS 6k DIR) 5.25" + MFM + LOW + 80 + 2 + 5 + 1024 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + + + SIDES + + 4 + 15 + 0 + 399 + 191 + 224 + 0 + 0 + 0 + false + false + + + Amstrad PCW8256 - DSDD 48 tpi 5.25" + MFM + LOW + 40 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 4 + 15 + 0 + 356 + 255 + 240 + 0 + 1 + 0 + false + false + + + Amstrad PCW8256 - SSDD 48 tpi 3" (JOYCE-SYSTEM) + MFM + LOW + 40 + 1 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 3 + 7 + 0 + 174 + 63 + 192 + 0 + 1 + 0 + false + false + + + Amstrad CPC System - SSDD 48 tpi 3" or 5.25" + MFM + LOW + 40 + 1 + 9 + 512 + 5 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 3 + 7 + 0 + 170 + 63 + 192 + 0 + 2 + 0 + false + false + + + Amstrad CPC-Data - SSDD 48 tpi 3" or 5.25" + MFM + LOW + 40 + 1 + 9 + 512 + 5 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 179 + 63 + 192 + 0 + 0 + 0 + false + false + + + Amstrad B360K - SSDD 96 tpi 5.25" SKEW 2 + MFM + LOW + 80 + 1 + 9 + 512 + 2 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 4 + 15 + 1 + 174 + 63 + 128 + 0 + 2 + 0 + false + false + + + Amstrad VORTEX - DSDD 96 tpi 5.25" + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 176 + 127 + 128 + 0 + 2 + 0 + false + false + + + Amstrad CPC System DSDD 96tpi 5.25" - DOBBERTIN - + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + + 1 + + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + + + SIDES + + 5 + 31 + 3 + 176 + 127 + 128 + 0 + 2 + 0 + false + false + + + Amstrad DOBBERTIN DATA DSDD 96 tpi 5.25" Skew 5 + MFM + LOW + 80 + 2 + 9 + 512 + 2 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 1 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 5 + 31 + 3 + 179 + 127 + 128 + 0 + 0 + 0 + false + false + + + Amstrad PCW8256 - DSDD 96 tpi 5.25" 10 x 512 788K + MFM + LOW + 80 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 5 + 31 + 3 + 197 + 255 + 192 + 0 + 1 + 0 + false + false + + + Amstrad PCW Joyce - SF2DD (824 kb - 256 entries) + MFM + LOW + 84 + 2 + 10 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + SIDES + + 5 + 31 + 3 + 208 + 255 + 192 + 0 + 1 + 0 + false + false + + + Amstrad PCW Joyce - 168 Track DD (740 kb - 256 entries) + MFM + LOW + 84 + 2 + 9 + 512 + 2 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + SIDES + + 5 + 31 + 3 + 187 + 255 + 192 + 0 + 1 + 0 + false + false + + + Extended CPC 3" 43-track + MFM + LOW + 43 + 1 + 9 + 512 + 2 + + 0 + + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + + + + 3 + 7 + 0 + 193 + 63 + 192 + 0 + 0 + 0 + false + false + + + Apple // CPM card 13-sector + GCR + LOW + 35 + 1 + 13 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + + + + 3 + 7 + 0 + 103 + 47 + 192 + 0 + 3 + 0 + false + false + + + Apple // CPM card 16-sector + GCR + LOW + 35 + 1 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 3 + 7 + 0 + 127 + 63 + 192 + 0 + 3 + 0 + false + false + + + Apple // CPM card special + GCR + LOW + 80 + 2 + 16 + 256 + 0 + + 0 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 1 + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + + + + 4 + 15 + 0 + 313 + 255 + 240 + 0 + 3 + 0 + false + false + + + 2016-08-24T02:44:59.045767Z \ No newline at end of file diff --git a/Aaru.Filesystems/Cram.cs b/Aaru.Filesystems/Cram.cs index 14665e274..9b1731629 100644 --- a/Aaru.Filesystems/Cram.cs +++ b/Aaru.Filesystems/Cram.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,10 +47,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -// ReSharper disable UnusedMember.Local - -namespace Aaru.Filesystems; - /// /// Implements detection of the CRAM filesystem [SuppressMessage("ReSharper", "UnusedType.Local")] @@ -76,14 +78,13 @@ public sealed class Cram : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); return magic == CRAM_MAGIC || magic == CRAM_CIGAM; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -92,10 +93,10 @@ public sealed class Cram : IFilesystem if(errno != ErrorNumber.NoError) return; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); - var crSb = new SuperBlock(); - bool littleEndian = true; + var crSb = new SuperBlock(); + var littleEndian = true; switch(magic) { @@ -136,8 +137,11 @@ public sealed class Cram : IFilesystem enum CramCompression : ushort { - Zlib = 1, Lzma = 2, Lzo = 3, - Xz = 4, Lz4 = 5 + Zlib = 1, + Lzma = 2, + Lzo = 3, + Xz = 4, + Lz4 = 5 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ECMA67.cs b/Aaru.Filesystems/ECMA67.cs index ee1ce94b7..df954cdcc 100644 --- a/Aaru.Filesystems/ECMA67.cs +++ b/Aaru.Filesystems/ECMA67.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the filesystem described in ECMA-67 public sealed class ECMA67 : IFilesystem @@ -85,8 +85,7 @@ public sealed class ECMA67 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); information = ""; diff --git a/Aaru.Filesystems/EFS.cs b/Aaru.Filesystems/EFS.cs index 781ab8d38..9081d8412 100644 --- a/Aaru.Filesystems/EFS.cs +++ b/Aaru.Filesystems/EFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements identification for the SGI Extent FileSystem public sealed class EFS : IFilesystem @@ -58,7 +58,7 @@ public sealed class EFS : IFilesystem /// public string Name => "Extent File System Plugin"; /// - public Guid Id => new Guid("52A43F90-9AF3-4391-ADFE-65598DEEABAB"); + public Guid Id => new("52A43F90-9AF3-4391-ADFE-65598DEEABAB"); /// public string Author => "Natalia Portillo"; @@ -71,18 +71,20 @@ public sealed class EFS : IFilesystem // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize); + var sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize); if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) sbSize++; - var errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) return false; + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return false; if(sector.Length < Marshal.SizeOf()) return false; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + var sbpiece = new byte[Marshal.SizeOf()]; Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); @@ -97,13 +99,15 @@ public sealed class EFS : IFilesystem } else { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - var errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) return false; + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return false; if(sector.Length < Marshal.SizeOf()) return false; @@ -122,8 +126,7 @@ public sealed class EFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -136,18 +139,20 @@ public sealed class EFS : IFilesystem // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; - var errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) return; + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return; if(sector.Length < Marshal.SizeOf()) return; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + var sbpiece = new byte[Marshal.SizeOf()]; Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); @@ -158,13 +163,15 @@ public sealed class EFS : IFilesystem } else { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; - var errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); - if(errno != ErrorNumber.NoError) return; + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + 1, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return; if(sector.Length < Marshal.SizeOf()) return; diff --git a/Aaru.Filesystems/F2FS.cs b/Aaru.Filesystems/F2FS.cs index 037c00859..449142b67 100644 --- a/Aaru.Filesystems/F2FS.cs +++ b/Aaru.Filesystems/F2FS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Flash-Friendly File System (F2FS) [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -80,7 +80,7 @@ public sealed class F2FS : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -102,8 +102,7 @@ public sealed class F2FS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.Unicode; information = ""; @@ -117,7 +116,7 @@ public sealed class F2FS : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 607e573a0..dbbae2177 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.IO; using System.Text; @@ -39,14 +41,12 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class FAT { static BpbKind DetectBpbKind(byte[] bpbSector, IMediaImage imagePlugin, Partition partition, out BiosParameterBlockEbpb fakeBpb, out HumanParameterBlock humanBpb, - out AtariParameterBlock atariBpb, out byte minBootNearJump, - out bool andosOemCorrect, out bool bootable) + out AtariParameterBlock atariBpb, out byte minBootNearJump, out bool andosOemCorrect, + out bool bootable) { fakeBpb = new BiosParameterBlockEbpb(); minBootNearJump = 0; @@ -110,18 +110,18 @@ public sealed partial class FAT var ebpb = new BiosParameterBlockEbpb(); var apricotBpb = new ApricotLabel(); - bool useAtariBpb = false; - bool useMsxBpb = false; - bool useDos2Bpb = false; - bool useDos3Bpb = false; - bool useDos32Bpb = false; - bool useDos33Bpb = false; - bool userShortExtendedBpb = false; - bool useExtendedBpb = false; - bool useShortFat32 = false; - bool useLongFat32 = false; - bool useApricotBpb = false; - bool useDecRainbowBpb = false; + var useAtariBpb = false; + var useMsxBpb = false; + var useDos2Bpb = false; + var useDos3Bpb = false; + var useDos32Bpb = false; + var useDos33Bpb = false; + var userShortExtendedBpb = false; + var useExtendedBpb = false; + var useShortFat32 = false; + var useLongFat32 = false; + var useApricotBpb = false; + var useDecRainbowBpb = false; if(imagePlugin.Info.SectorSize >= 256) { @@ -149,21 +149,18 @@ public sealed partial class FAT bool correctSpcMsx = msxBpb.spc == 1 || msxBpb.spc == 2 || msxBpb.spc == 4 || msxBpb.spc == 8 || msxBpb.spc == 16 || msxBpb.spc == 32 || msxBpb.spc == 64; - bool correctSpcDos33 = dos33Bpb.spc == 1 || dos33Bpb.spc == 2 || dos33Bpb.spc == 4 || - dos33Bpb.spc == 8 || dos33Bpb.spc == 16 || dos33Bpb.spc == 32 || - dos33Bpb.spc == 64; + bool correctSpcDos33 = dos33Bpb.spc == 1 || dos33Bpb.spc == 2 || dos33Bpb.spc == 4 || dos33Bpb.spc == 8 || + dos33Bpb.spc == 16 || dos33Bpb.spc == 32 || dos33Bpb.spc == 64; - bool correctSpcDos40 = ebpb.spc == 1 || ebpb.spc == 2 || ebpb.spc == 4 || ebpb.spc == 8 || - ebpb.spc == 16 || ebpb.spc == 32 || ebpb.spc == 64; + bool correctSpcDos40 = ebpb.spc == 1 || ebpb.spc == 2 || ebpb.spc == 4 || ebpb.spc == 8 || ebpb.spc == 16 || + ebpb.spc == 32 || ebpb.spc == 64; - bool correctSpcFat32Short = shortFat32Bpb.spc == 1 || shortFat32Bpb.spc == 2 || - shortFat32Bpb.spc == 4 || shortFat32Bpb.spc == 8 || - shortFat32Bpb.spc == 16 || shortFat32Bpb.spc == 32 || + bool correctSpcFat32Short = shortFat32Bpb.spc == 1 || shortFat32Bpb.spc == 2 || shortFat32Bpb.spc == 4 || + shortFat32Bpb.spc == 8 || shortFat32Bpb.spc == 16 || shortFat32Bpb.spc == 32 || shortFat32Bpb.spc == 64; - bool correctSpcFat32 = fat32Bpb.spc == 1 || fat32Bpb.spc == 2 || fat32Bpb.spc == 4 || - fat32Bpb.spc == 8 || fat32Bpb.spc == 16 || fat32Bpb.spc == 32 || - fat32Bpb.spc == 64; + bool correctSpcFat32 = fat32Bpb.spc == 1 || fat32Bpb.spc == 2 || fat32Bpb.spc == 4 || fat32Bpb.spc == 8 || + fat32Bpb.spc == 16 || fat32Bpb.spc == 32 || fat32Bpb.spc == 64; bool correctSpcApricot = apricotBpb.mainBPB.spc == 1 || apricotBpb.mainBPB.spc == 2 || apricotBpb.mainBPB.spc == 4 || apricotBpb.mainBPB.spc == 8 || @@ -303,9 +300,9 @@ public sealed partial class FAT dos33Bpb.sectors > 0 && dos33Bpb.sectors <= partition.End - partition.Start + 1) if(atariBpb.jump[0] == 0x60 || - (atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && - Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ") || - partition.Type == "GEM" || + atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && + Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT " || + partition.Type == "GEM" || partition.Type == "BGM") { AaruConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); @@ -331,8 +328,8 @@ public sealed partial class FAT dos30Bpb.heads > 0 && dos30Bpb.heads < 256) if(atariBpb.jump[0] == 0x60 || - (atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && - Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ")) + atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && + Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ") { AaruConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); useAtariBpb = true; @@ -346,8 +343,8 @@ public sealed partial class FAT else { if(atariBpb.jump[0] == 0x60 || - (atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && - Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ")) + atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && + Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ") { AaruConsole.DebugWriteLine("FAT plugin", "Using Atari BPB"); useAtariBpb = true; @@ -400,14 +397,14 @@ public sealed partial class FAT } byte[] rootDir = rootMs.ToArray(); - bool validRootDir = true; + var validRootDir = true; // Iterate all root directory - for(int e = 0; e < 96 * 32; e += 32) + for(var e = 0; e < 96 * 32; e += 32) { - for(int c = 0; c < 11; c++) - if((rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05) || - rootDir[c + e] == 0xFF || + for(var c = 0; c < 11; c++) + if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 || + rootDir[c + e] == 0xFF || rootDir[c + e] == 0x2E) { validRootDir = false; @@ -633,8 +630,8 @@ public sealed partial class FAT } // This assumes a bootable sector will jump somewhere or disable interrupts in x86 code - bootable |= bpbSector[0] == 0xFA || (bpbSector[0] == 0xEB && bpbSector[1] <= 0x7F) || - (bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) <= 0x1FC); + bootable |= bpbSector[0] == 0xFA || bpbSector[0] == 0xEB && bpbSector[1] <= 0x7F || + bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) <= 0x1FC; fakeBpb.boot_code = bpbSector; diff --git a/Aaru.Filesystems/FAT/Consts.cs b/Aaru.Filesystems/FAT/Consts.cs index 30afff3fb..3e58c6d2b 100644 --- a/Aaru.Filesystems/FAT/Consts.cs +++ b/Aaru.Filesystems/FAT/Consts.cs @@ -30,12 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class FAT { const uint FSINFO_SIGNATURE1 = 0x41615252; @@ -86,8 +88,7 @@ public sealed partial class FAT ("b639b4d5b25f63560e3b34a3a0feb732aa65486f", "Amstrad MS-DOS 3.20 (8-sector floppy)"), ("9311151f13f7611b1431593da05ddd3153370574", "Amstrad MS-DOS 3.20 (Spanish)"), ("55eda6a9b955f5199020e6b56a6954fa6fcb7dc6", "AT&T MS-DOS 2.11"), - ("d5e10822977efa96e4fbaec2b268ca008d74fe6f", "Atari TOS"), - ("17f11a12b96899d2a4976d889cef160502167f2d", "BeOS"), + ("d5e10822977efa96e4fbaec2b268ca008d74fe6f", "Atari TOS"), ("17f11a12b96899d2a4976d889cef160502167f2d", "BeOS"), ("d0e31673028fcfcea38dff71a7be13669aa20b8d", "Compaq MS-DOS 3.30"), ("3aa4ce2fa6f9a297b5b15aaef930401af369fcbc", "Compaq MS-DOS 3.30 (8-sector floppy)"), ("8f1d33520343f35034aa3ce47e4180b10e960b43", "Compaq MS-DOS 3.30 (8-sector floppy)"), @@ -165,8 +166,7 @@ public sealed partial class FAT ("8f024b3d501c39ee6e3f8ca28173ad6a780d3eb0", "Windows Vista, 8, 10"), ("d3e93f8b82ef250db216037d827a4896dc97d2be", "TracerST"), // OEM ID: "TracerST" //("b741f85ef40288ccc8887de1f6e849009097e1c9", "Norton Utilities"), // OEM ID: "IBM PNCI", need to confirm - ("c49b275537ac7237cac64d83f34d2024ae0ca96a", - "Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish) + ("c49b275537ac7237cac64d83f34d2024ae0ca96a", "Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish) //("a48b0e4b696317eed829e960d1aa576562a4f185", "TracerST"), // Unknown OEM ID, apparently Tracer, unconfirmed ("fe477972602ba76658ff7143859045b3c4036ca5", "iomega"), // OEM ID: "SHIPDISK", contains timedate on boot code may not be unique @@ -179,31 +179,52 @@ public sealed partial class FAT [Flags] enum FatAttributes : byte { - ReadOnly = 0x01, Hidden = 0x02, System = 0x04, - VolumeLabel = 0x08, Subdirectory = 0x10, Archive = 0x20, - Device = 0x40, Reserved = 0x80, LFN = 0x0F + ReadOnly = 0x01, + Hidden = 0x02, + System = 0x04, + VolumeLabel = 0x08, + Subdirectory = 0x10, + Archive = 0x20, + Device = 0x40, + Reserved = 0x80, + LFN = 0x0F } enum BpbKind { - None, Hardcoded, Atari, - Msx, Dos2, Dos3, - Dos32, Dos33, ShortExtended, - Extended, ShortFat32, LongFat32, - Andos, Apricot, DecRainbow, + None, + Hardcoded, + Atari, + Msx, + Dos2, + Dos3, + Dos32, + Dos33, + ShortExtended, + Extended, + ShortFat32, + LongFat32, + Andos, + Apricot, + DecRainbow, Human } enum Namespace { - Dos, Nt, Lfn, - Os2, Ecs, Human + Dos, + Nt, + Lfn, + Os2, + Ecs, + Human } [Flags] enum EaFlags : uint { - Normal = 0, Critical = 1 + Normal = 0, + Critical = 1 } [Flags] diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index 7d6c2605f..6a83dd283 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class FAT { /// @@ -102,7 +102,7 @@ public sealed partial class FAT currentDirectory = _rootDirectoryCache; - for(int p = 0; p < pieces.Length; p++) + for(var p = 0; p < pieces.Length; p++) { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); @@ -135,12 +135,12 @@ public sealed partial class FAT if(clusters is null) return ErrorNumber.InvalidArgument; - byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; + var directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; - for(int i = 0; i < clusters.Length; i++) + for(var i = 0; i < clusters.Length; i++) { - errno = _image.ReadSectors(_firstClusterSector + (clusters[i] * _sectorsPerCluster), - _sectorsPerCluster, out byte[] buffer); + errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, _sectorsPerCluster, + out byte[] buffer); if(errno != ErrorNumber.NoError) return errno; @@ -152,7 +152,7 @@ public sealed partial class FAT byte[] lastLfnName = null; byte lastLfnChecksum = 0; - for(int pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf()) + for(var pos = 0; pos < directoryBuffer.Length; pos += Marshal.SizeOf()) { DirectoryEntry dirent = Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, @@ -191,8 +191,8 @@ public sealed partial class FAT lfnSequence--; Array.Copy(lfnEntry.name1, 0, lastLfnName, lfnSequence * 26, 10); - Array.Copy(lfnEntry.name2, 0, lastLfnName, (lfnSequence * 26) + 10, 12); - Array.Copy(lfnEntry.name3, 0, lastLfnName, (lfnSequence * 26) + 22, 4); + Array.Copy(lfnEntry.name2, 0, lastLfnName, lfnSequence * 26 + 10, 12); + Array.Copy(lfnEntry.name3, 0, lastLfnName, lfnSequence * 26 + 22, 4); continue; } @@ -251,14 +251,14 @@ public sealed partial class FAT AaruConsole.DebugWriteLine("FAT filesystem", "Found empty filename in {0}", path); if(!_debug || - (dirent.size > 0 && dirent.start_cluster == 0)) + dirent.size > 0 && dirent.start_cluster == 0) continue; // Skip invalid name // If debug, add it name = ":{EMPTYNAME}:"; // Try to create a unique filename with an extension from 000 to 999 - for(int uniq = 0; uniq < 1000; uniq++) + for(var uniq = 0; uniq < 1000; uniq++) { extension = $"{uniq:D03}"; @@ -320,8 +320,7 @@ public sealed partial class FAT (_namespace == Namespace.Os2 || _namespace == Namespace.Ecs) && !_fat32) { - List> filesWithEas = - currentDirectory.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); + var filesWithEas = currentDirectory.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); foreach(KeyValuePair fileWithEa in filesWithEas) { @@ -336,12 +335,12 @@ public sealed partial class FAT if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue; - ushort longnameSize = BitConverter.ToUInt16(longnameEa, 2); + var longnameSize = BitConverter.ToUInt16(longnameEa, 2); if(longnameSize + 4 > longnameEa.Length) continue; - byte[] longnameBytes = new byte[longnameSize]; + var longnameBytes = new byte[longnameSize]; Array.Copy(longnameEa, 4, longnameBytes, 0, longnameSize); @@ -362,8 +361,8 @@ public sealed partial class FAT // Check FAT32.IFS EAs if(_fat32 || _debug) { - List> 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) { diff --git a/Aaru.Filesystems/FAT/FAT.cs b/Aaru.Filesystems/FAT/FAT.cs index 935fe9bec..962d2efcd 100644 --- a/Aaru.Filesystems/FAT/FAT.cs +++ b/Aaru.Filesystems/FAT/FAT.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.Filesystems; - // TODO: Differentiate between Atari and X68k FAT, as this one uses a standard BPB. // X68K uses cdate/adate from direntry for extending filename /// diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 289e35b56..2ffa8acbf 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Filesystems; - public sealed partial class FAT { /// @@ -65,7 +65,7 @@ public sealed partial class FAT if(fileBlock >= clusters.Length) return ErrorNumber.InvalidArgument; - deviceBlock = (long)(_firstClusterSector + (clusters[fileBlock] * _sectorsPerCluster)); + deviceBlock = (long)(_firstClusterSector + clusters[fileBlock] * _sectorsPerCluster); return ErrorNumber.NoError; } @@ -132,12 +132,12 @@ public sealed partial class FAT var ms = new MemoryStream(); - for(int i = 0; i < sizeInClusters; i++) + for(var i = 0; i < sizeInClusters; i++) { if(i + firstCluster >= clusters.Length) return ErrorNumber.InvalidArgument; - errno = _image.ReadSectors(_firstClusterSector + (clusters[i + firstCluster] * _sectorsPerCluster), + errno = _image.ReadSectors(_firstClusterSector + clusters[i + firstCluster] * _sectorsPerCluster, _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) @@ -199,11 +199,10 @@ public sealed partial class FAT { stat.Attributes |= FileAttributes.Directory; - if((_fat32 && entry.ea_handle << 16 > 0) || + if(_fat32 && entry.ea_handle << 16 > 0 || entry.start_cluster > 0) - stat.Blocks = - _fat32 ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0 - : GetClusters(entry.start_cluster)?.Length ?? 0; + stat.Blocks = _fat32 ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0 + : GetClusters(entry.start_cluster)?.Length ?? 0; stat.Length = stat.Blocks * stat.BlockSize; } @@ -238,10 +237,9 @@ public sealed partial class FAT uint nextCluster = startCluster; - ulong nextSector = (nextCluster / _fatEntriesPerSector) + _fatFirstSector + - (_useFirstFat ? 0 : _sectorsPerFat); + ulong nextSector = nextCluster / _fatEntriesPerSector + _fatFirstSector + (_useFirstFat ? 0 : _sectorsPerFat); - int nextEntry = (int)(nextCluster % _fatEntriesPerSector); + var nextEntry = (int)(nextCluster % _fatEntriesPerSector); ulong currentSector = nextSector; ErrorNumber errno = _image.ReadSector(currentSector, out byte[] fatData); @@ -267,8 +265,7 @@ public sealed partial class FAT nextCluster = BitConverter.ToUInt32(fatData, nextEntry * 4); - nextSector = (nextCluster / _fatEntriesPerSector) + _fatFirstSector + - (_useFirstFat ? 0 : _sectorsPerFat); + nextSector = nextCluster / _fatEntriesPerSector + _fatFirstSector + (_useFirstFat ? 0 : _sectorsPerFat); nextEntry = (int)(nextCluster % _fatEntriesPerSector); } @@ -300,8 +297,7 @@ public sealed partial class FAT { entry = null; - string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) - : path.ToLower(_cultureInfo); + string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] { @@ -311,7 +307,7 @@ public sealed partial class FAT if(pieces.Length == 0) return ErrorNumber.InvalidArgument; - string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); + var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { @@ -343,10 +339,10 @@ public sealed partial class FAT { byte sum = 0; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) sum = (byte)(((sum & 1) << 7) + (sum >> 1) + name[i]); - for(int i = 0; i < 3; 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 62cadc19b..77200a565 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -45,8 +47,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - public sealed partial class FAT { /// @@ -68,11 +68,11 @@ public sealed partial class FAT byte bpbSignature; byte fat32Signature; ulong hugeSectors; - byte[] fat32Id = new byte[8]; - byte[] msxId = new byte[6]; + var fat32Id = new byte[8]; + var msxId = new byte[6]; byte fatId; - byte[] dosOem = new byte[8]; - byte[] atariOem = new byte[6]; + var dosOem = new byte[8]; + var atariOem = new byte[6]; ushort bootable = 0; uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1; @@ -176,14 +176,14 @@ public sealed partial class FAT AaruConsole.DebugWriteLine("FAT plugin", "huge_sectors = {0}", hugeSectors); AaruConsole.DebugWriteLine("FAT plugin", "fat_id = 0x{0:X2}", fatId); - ushort apricotBps = BitConverter.ToUInt16(bpbSector, 0x50); - byte apricotSpc = bpbSector[0x52]; - ushort apricotReservedSecs = BitConverter.ToUInt16(bpbSector, 0x53); - byte apricotFatsNo = bpbSector[0x55]; - ushort apricotRootEntries = BitConverter.ToUInt16(bpbSector, 0x56); - ushort apricotSectors = BitConverter.ToUInt16(bpbSector, 0x58); - byte apricotMediaDescriptor = bpbSector[0x5A]; - ushort apricotFatSectors = BitConverter.ToUInt16(bpbSector, 0x5B); + var apricotBps = BitConverter.ToUInt16(bpbSector, 0x50); + byte apricotSpc = bpbSector[0x52]; + var apricotReservedSecs = BitConverter.ToUInt16(bpbSector, 0x53); + byte apricotFatsNo = bpbSector[0x55]; + var apricotRootEntries = BitConverter.ToUInt16(bpbSector, 0x56); + var apricotSectors = BitConverter.ToUInt16(bpbSector, 0x58); + byte apricotMediaDescriptor = bpbSector[0x5A]; + var apricotFatSectors = BitConverter.ToUInt16(bpbSector, 0x5B); bool apricotCorrectSpc = apricotSpc == 1 || apricotSpc == 2 || apricotSpc == 4 || apricotSpc == 8 || apricotSpc == 16 || apricotSpc == 32 || apricotSpc == 64; @@ -230,8 +230,8 @@ public sealed partial class FAT if(errno != ErrorNumber.NoError) return false; - uint hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); - uint hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); + var hpfsMagic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); + var hpfsMagic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); if(hpfsMagic1 == 0xF995E849 && hpfsMagic2 == 0xFA53E9C5) @@ -322,14 +322,14 @@ public sealed partial class FAT } byte[] rootDir = rootMs.ToArray(); - bool validRootDir = true; + var validRootDir = true; // Iterate all root directory - for(int e = 0; e < 96 * 32; e += 32) + for(var e = 0; e < 96 * 32; e += 32) { - for(int c = 0; c < 11; c++) - if((rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05) || - rootDir[c + e] == 0xFF || + for(var c = 0; c < 11; c++) + if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 || + rootDir[c + e] == 0xFF || rootDir[c + e] == 0x2E) { validRootDir = false; @@ -349,9 +349,9 @@ public sealed partial class FAT return true; } - byte fat2 = fatSector[1]; - byte fat3 = fatSector[2]; - ushort fatCluster2 = (ushort)(((fat2 << 8) + fat3) & 0xFFF); + byte fat2 = fatSector[1]; + byte fat3 = fatSector[2]; + var fatCluster2 = (ushort)(((fat2 << 8) + fat3) & 0xFFF); AaruConsole.DebugWriteLine("FAT plugin", "1st fat cluster 1 = {0:X3}", fatCluster2); @@ -435,8 +435,7 @@ public sealed partial class FAT } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("IBM437"); information = ""; @@ -456,9 +455,9 @@ public sealed partial class FAT out HumanParameterBlock humanBpb, out AtariParameterBlock atariBpb, out byte minBootNearJump, out bool andosOemCorrect, out bool bootable); - bool isFat12 = false; - bool isFat16 = false; - bool isFat32 = false; + var isFat12 = false; + var isFat16 = false; + var isFat32 = false; ulong rootDirectorySector = 0; string extraInfo = null; string bootChk = null; @@ -484,8 +483,7 @@ public sealed partial class FAT { isFat32 = true; - Fat32ParameterBlock fat32Bpb = - Marshal.ByteArrayToStructureLittleEndian(bpbSector); + Fat32ParameterBlock fat32Bpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); Fat32ParameterBlockShort shortFat32Bpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); @@ -591,8 +589,7 @@ public sealed partial class FAT XmlFsType.VolumeName = StringHandlers.SpacePaddedToString(fat32Bpb.volume_label, Encoding); XmlFsType.VolumeName = XmlFsType.VolumeName?.Replace("\0", ""); - sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fat32Bpb.fs_type)). - AppendLine(); + sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fat32Bpb.fs_type)).AppendLine(); bootChk = Sha1Context.Data(fat32Bpb.boot_code, out _); } @@ -602,24 +599,23 @@ public sealed partial class FAT // 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"...... XmlFsType.Bootable = - (fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80) || - (fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 && - BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump && - BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC); + fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80 || + fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 && + BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump && + BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC; sectorsPerRealSector = fat32Bpb.bps / imagePlugin.Info.SectorSize; // First root directory sector rootDirectorySector = - (ulong)(((fat32Bpb.root_cluster - 2) * fat32Bpb.spc) + (fat32Bpb.big_spfat * fat32Bpb.fats_no) + + (ulong)((fat32Bpb.root_cluster - 2) * fat32Bpb.spc + fat32Bpb.big_spfat * fat32Bpb.fats_no + fat32Bpb.rsectors) * sectorsPerRealSector; sectorsForRootDirectory = 1; if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End) { - errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, - out byte[] fsinfoSector); + errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector); if(errno != ErrorNumber.NoError) return; @@ -651,7 +647,7 @@ public sealed partial class FAT { ushort sum = 0; - for(int i = 0; i < bpbSector.Length; i += 2) + for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i); // TODO: Check this @@ -671,7 +667,7 @@ public sealed partial class FAT if(atariBpb.ldmode == 0) { - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(atariBpb.fname, 0, tmp, 0, 8); string fname = Encoding.ASCII.GetString(tmp).Trim(); tmp = new byte[3]; @@ -687,10 +683,9 @@ public sealed partial class FAT atariSb.AppendFormat("Boot program resides in file \"{0}\"", filename).AppendLine(); } else - atariSb. - AppendFormat("Boot program starts in sector {0} and is {1} sectors long ({2} bytes)", - atariBpb.ssect, atariBpb.sectcnt, atariBpb.sectcnt * atariBpb.bps). - AppendLine(); + atariSb.AppendFormat("Boot program starts in sector {0} and is {1} sectors long ({2} bytes)", + atariBpb.ssect, atariBpb.sectcnt, atariBpb.sectcnt * atariBpb.bps). + AppendLine(); extraInfo = atariSb.ToString(); } @@ -724,8 +719,8 @@ public sealed partial class FAT if(bpbKind != BpbKind.Human) { - int reservedSectors = fakeBpb.rsectors + (fakeBpb.fats_no * fakeBpb.spfat) + - (fakeBpb.root_ent * 32 / fakeBpb.bps); + int reservedSectors = fakeBpb.rsectors + fakeBpb.fats_no * fakeBpb.spfat + + fakeBpb.root_ent * 32 / fakeBpb.bps; if(fakeBpb.sectors == 0) clusters = (ulong)(fakeBpb.spc == 0 ? fakeBpb.big_sectors - reservedSectors @@ -745,20 +740,20 @@ public sealed partial class FAT { if(clusters < 4089) { - ushort[] fat12 = new ushort[clusters]; + var fat12 = new ushort[clusters]; _reservedSectors = fakeBpb.rsectors; sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; - _fatFirstSector = partition.Start + (_reservedSectors * sectorsPerRealSector); + _fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector; errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes); if(errno != ErrorNumber.NoError) return; - int pos = 0; + var pos = 0; - for(int i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3) + for(var i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3) { fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); @@ -802,11 +797,9 @@ public sealed partial class FAT // Check BPB type if(isFat12 == isFat16) { - isFat12 = fakeBpb.fs_type != null && - Encoding.ASCII.GetString(fakeBpb.fs_type) == "FAT12 "; + isFat12 = fakeBpb.fs_type != null && Encoding.ASCII.GetString(fakeBpb.fs_type) == "FAT12 "; - isFat16 = fakeBpb.fs_type != null && - Encoding.ASCII.GetString(fakeBpb.fs_type) == "FAT16 "; + isFat16 = fakeBpb.fs_type != null && Encoding.ASCII.GetString(fakeBpb.fs_type) == "FAT16 "; } if(!isFat12 && @@ -1002,16 +995,15 @@ public sealed partial class FAT if(XmlFsType.Bootable == false && fakeBpb.jump != null) XmlFsType.Bootable |= - (fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80) || - (fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 && - BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump && - BitConverter.ToUInt16(fakeBpb.jump, 1) <= 0x1FC); + fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80 || + fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 && + BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump && + BitConverter.ToUInt16(fakeBpb.jump, 1) <= 0x1FC; sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; // First root directory sector - rootDirectorySector = - (ulong)((fakeBpb.spfat * fakeBpb.fats_no) + fakeBpb.rsectors) * sectorsPerRealSector; + rootDirectorySector = (ulong)(fakeBpb.spfat * fakeBpb.fats_no + fakeBpb.rsectors) * sectorsPerRealSector; sectorsForRootDirectory = (uint)(fakeBpb.root_ent * 32 / imagePlugin.Info.SectorSize); } @@ -1048,7 +1040,7 @@ public sealed partial class FAT rootDirectory = rootMs.ToArray(); } - for(int i = 0; i < rootDirectory.Length; i += 32) + for(var i = 0; i < rootDirectory.Length; i += 32) { // Not a correct entry if(rootDirectory[i] < DIRENT_MIN && @@ -1065,17 +1057,15 @@ public sealed partial class FAT rootDirectory[i + 0x0B] != 0x28) continue; - DirectoryEntry entry = - Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, 32); + DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, 32); - byte[] fullname = new byte[11]; + var fullname = new byte[11]; Array.Copy(entry.filename, 0, fullname, 0, 8); Array.Copy(entry.extension, 0, fullname, 8, 3); string volname = Encoding.GetString(fullname).Trim(); if(!string.IsNullOrEmpty(volname)) - XmlFsType.VolumeName = - entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) ? volname.ToLower() : volname; + XmlFsType.VolumeName = entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) ? volname.ToLower() : volname; if(entry.ctime > 0 && entry.cdate > 0) @@ -1114,8 +1104,8 @@ public sealed partial class FAT if(bpbSector[0] == 0xEB && bpbSector[1] < 0x80) { - int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0; - byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2]; + int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0; + var bootCode = new byte[512 - sigSize - bpbSector[1] - 2]; Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length); Sha1Context.Data(bootCode, out _); } @@ -1124,8 +1114,8 @@ public sealed partial class FAT else if(bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) < 0x1FC) { - int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0; - byte[] bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3]; + int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0; + var bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3]; Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0, bootCode.Length); Sha1Context.Data(bootCode, out _); } diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index 729abdfd6..4056b1f1f 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -30,13 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + // ReSharper disable NotAccessedField.Local namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class FAT { diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 61e7264d8..4d6cee924 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -47,8 +49,6 @@ using Schemas; using FileSystemInfo = Aaru.CommonTypes.Structs.FileSystemInfo; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - public sealed partial class FAT { uint _fatEntriesPerSector; @@ -150,8 +150,7 @@ public sealed partial class FAT { _fat32 = true; - Fat32ParameterBlock fat32Bpb = - Marshal.ByteArrayToStructureLittleEndian(bpbSector); + Fat32ParameterBlock fat32Bpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); Fat32ParameterBlockShort shortFat32Bpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); @@ -211,23 +210,22 @@ public sealed partial class FAT // 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"...... XmlFsType.Bootable = - (fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80) || - (fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 && - BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump && - BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC); + fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80 || + fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 && + BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump && + BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC; sectorsPerRealSector = fat32Bpb.bps / imagePlugin.Info.SectorSize; _sectorsPerCluster *= sectorsPerRealSector; // First root directory sector _firstClusterSector = - ((ulong)((fat32Bpb.big_spfat * fat32Bpb.fats_no) + fat32Bpb.rsectors) * sectorsPerRealSector) - - (2 * _sectorsPerCluster); + (ulong)(fat32Bpb.big_spfat * fat32Bpb.fats_no + fat32Bpb.rsectors) * sectorsPerRealSector - + 2 * _sectorsPerCluster; if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End) { - errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, - out byte[] fsinfoSector); + errno = imagePlugin.ReadSector(fat32Bpb.fsinfo_sector + partition.Start, out byte[] fsinfoSector); if(errno != ErrorNumber.NoError) return errno; @@ -252,7 +250,7 @@ public sealed partial class FAT { ushort sum = 0; - for(int i = 0; i < bpbSector.Length; i += 2) + for(var i = 0; i < bpbSector.Length; i += 2) sum += BigEndianBitConverter.ToUInt16(bpbSector, i); // TODO: Check this @@ -304,8 +302,8 @@ public sealed partial class FAT if(bpbKind != BpbKind.Human) { - int reservedSectors = fakeBpb.rsectors + (fakeBpb.fats_no * fakeBpb.spfat) + - (fakeBpb.root_ent * 32 / fakeBpb.bps); + int reservedSectors = fakeBpb.rsectors + fakeBpb.fats_no * fakeBpb.spfat + + fakeBpb.root_ent * 32 / fakeBpb.bps; if(fakeBpb.sectors == 0) clusters = (ulong)(fakeBpb.spc == 0 ? fakeBpb.big_sectors - reservedSectors @@ -325,20 +323,20 @@ public sealed partial class FAT { if(clusters < 4089) { - ushort[] fat12 = new ushort[clusters]; + var fat12 = new ushort[clusters]; _reservedSectors = fakeBpb.rsectors; sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; - _fatFirstSector = partition.Start + (_reservedSectors * sectorsPerRealSector); + _fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector; errno = imagePlugin.ReadSectors(_fatFirstSector, fakeBpb.spfat, out byte[] fatBytes); if(errno != ErrorNumber.NoError) return errno; - int pos = 0; + var pos = 0; - for(int i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3) + for(var i = 0; i + 3 < fatBytes.Length && pos < fat12.Length; i += 3) { fat12[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); @@ -511,15 +509,14 @@ public sealed partial class FAT if(XmlFsType.Bootable == false && fakeBpb.jump != null) XmlFsType.Bootable |= - (fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80) || - (fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 && - BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump && - BitConverter.ToUInt16(fakeBpb.jump, 1) <= 0x1FC); + fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80 || + fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 && + BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump && + BitConverter.ToUInt16(fakeBpb.jump, 1) <= 0x1FC; // First root directory sector - firstRootSector = - ((ulong)((fakeBpb.spfat * fakeBpb.fats_no) + fakeBpb.rsectors) * sectorsPerRealSector) + - partition.Start; + firstRootSector = (ulong)(fakeBpb.spfat * fakeBpb.fats_no + fakeBpb.rsectors) * sectorsPerRealSector + + partition.Start; sectorsForRootDirectory = (uint)(fakeBpb.root_ent * 32 / imagePlugin.Info.SectorSize); @@ -538,14 +535,14 @@ public sealed partial class FAT else _fatEntriesPerSector = imagePlugin.Info.SectorSize * 2 / 3; - _fatFirstSector = partition.Start + (_reservedSectors * sectorsPerRealSector); + _fatFirstSector = partition.Start + _reservedSectors * sectorsPerRealSector; _rootDirectoryCache = new Dictionary(); byte[] rootDirectory; if(!_fat32) { - _firstClusterSector = firstRootSector + sectorsForRootDirectory - (_sectorsPerCluster * 2); + _firstClusterSector = firstRootSector + sectorsForRootDirectory - _sectorsPerCluster * 2; errno = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory, out rootDirectory); if(errno != ErrorNumber.NoError) @@ -581,8 +578,8 @@ public sealed partial class FAT foreach(uint cluster in rootDirectoryClusters) { - errno = imagePlugin.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), - _sectorsPerCluster, out byte[] buffer); + errno = imagePlugin.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, _sectorsPerCluster, + out byte[] buffer); if(errno != ErrorNumber.NoError) return errno; @@ -603,7 +600,7 @@ public sealed partial class FAT byte[] lastLfnName = null; byte lastLfnChecksum = 0; - for(int i = 0; i < rootDirectory.Length; i += Marshal.SizeOf()) + for(var i = 0; i < rootDirectory.Length; i += Marshal.SizeOf()) { DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, @@ -619,8 +616,7 @@ public sealed partial class FAT continue; LfnEntry lfnEntry = - Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, - Marshal.SizeOf()); + Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, Marshal.SizeOf()); int lfnSequence = lfnEntry.sequence & LFN_MASK; @@ -642,8 +638,8 @@ public sealed partial class FAT lfnSequence--; Array.Copy(lfnEntry.name1, 0, lastLfnName, lfnSequence * 26, 10); - Array.Copy(lfnEntry.name2, 0, lastLfnName, (lfnSequence * 26) + 10, 12); - Array.Copy(lfnEntry.name3, 0, lastLfnName, (lfnSequence * 26) + 22, 4); + Array.Copy(lfnEntry.name2, 0, lastLfnName, lfnSequence * 26 + 10, 12); + Array.Copy(lfnEntry.name3, 0, lastLfnName, lfnSequence * 26 + 22, 4); continue; } @@ -669,15 +665,14 @@ public sealed partial class FAT if(entry.attributes.HasFlag(FatAttributes.VolumeLabel)) { - byte[] fullname = new byte[11]; + var fullname = new byte[11]; Array.Copy(entry.filename, 0, fullname, 0, 8); Array.Copy(entry.extension, 0, fullname, 8, 3); string volname = Encoding.GetString(fullname).Trim(); if(!string.IsNullOrEmpty(volname)) - XmlFsType.VolumeName = - entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) && _namespace == Namespace.Nt - ? volname.ToLower() : volname; + XmlFsType.VolumeName = entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) && _namespace == Namespace.Nt + ? volname.ToLower() : volname; XmlFsType.VolumeName = XmlFsType.VolumeName?.Replace("\0", ""); @@ -748,14 +743,14 @@ public sealed partial class FAT AaruConsole.DebugWriteLine("FAT filesystem", "Found empty filename in root directory"); if(!_debug || - (entry.size > 0 && entry.start_cluster == 0)) + entry.size > 0 && entry.start_cluster == 0) continue; // Skip invalid name // If debug, add it name = ":{EMPTYNAME}:"; // Try to create a unique filename with an extension from 000 to 999 - for(int uniq = 0; uniq < 1000; uniq++) + for(var uniq = 0; uniq < 1000; uniq++) { extension = $"{uniq:D03}"; @@ -863,10 +858,10 @@ public sealed partial class FAT _bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize; - ushort[] firstFatEntries = new ushort[_statfs.Blocks]; - ushort[] secondFatEntries = new ushort[_statfs.Blocks]; - bool firstFatValid = true; - bool secondFatValid = true; + var firstFatEntries = new ushort[_statfs.Blocks]; + var secondFatEntries = new ushort[_statfs.Blocks]; + var firstFatValid = true; + var secondFatValid = true; if(_fat12) { @@ -877,9 +872,9 @@ public sealed partial class FAT if(errno != ErrorNumber.NoError) return errno; - int pos = 0; + var pos = 0; - for(int i = 0; i + 3 < fatBytes.Length && pos < firstFatEntries.Length; i += 3) + for(var i = 0; i + 3 < fatBytes.Length && pos < firstFatEntries.Length; i += 3) { firstFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); @@ -898,7 +893,7 @@ public sealed partial class FAT pos = 0; - for(int i = 0; i + 3 < fatBytes.Length && pos < secondFatEntries.Length; i += 3) + for(var i = 0; i + 3 < fatBytes.Length && pos < secondFatEntries.Length; i += 3) { secondFatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); @@ -995,7 +990,7 @@ public sealed partial class FAT if(_eaDirEntry.start_cluster != 0) { CacheEaData(); - ushort eamagic = BitConverter.ToUInt16(_cachedEaData, 0); + var eamagic = BitConverter.ToUInt16(_cachedEaData, 0); if(eamagic != EADATA_MAGIC) { @@ -1013,8 +1008,7 @@ public sealed partial class FAT (_namespace == Namespace.Os2 || _namespace == Namespace.Ecs) && !_fat32) { - List> rootFilesWithEas = - _rootDirectoryCache.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); + var rootFilesWithEas = _rootDirectoryCache.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); foreach(KeyValuePair fileWithEa in rootFilesWithEas) { @@ -1029,12 +1023,12 @@ public sealed partial class FAT if(BitConverter.ToUInt16(longnameEa, 0) != EAT_ASCII) continue; - ushort longnameSize = BitConverter.ToUInt16(longnameEa, 2); + var longnameSize = BitConverter.ToUInt16(longnameEa, 2); if(longnameSize + 4 > longnameEa.Length) continue; - byte[] longnameBytes = new byte[longnameSize]; + var longnameBytes = new byte[longnameSize]; Array.Copy(longnameEa, 4, longnameBytes, 0, longnameSize); @@ -1055,15 +1049,14 @@ public sealed partial class FAT // Check FAT32.IFS EAs if(_fat32 || _debug) { - List> 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) { // No real file this sidecar accompanies - if(!_rootDirectoryCache. - TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length), - out CompleteDirectoryEntry fileWithEa)) + if(!_rootDirectoryCache.TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length), + out CompleteDirectoryEntry fileWithEa)) continue; // If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index 3f5ed385d..27b64825b 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -38,8 +40,6 @@ using System.Text; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class FAT { Dictionary> _eaCache; @@ -135,7 +135,7 @@ public sealed partial class FAT foreach(uint cluster in rootDirectoryClusters) { - ErrorNumber errno = _image.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), + ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) @@ -145,8 +145,8 @@ public sealed partial class FAT } byte[] full = eaMs.ToArray(); - ushort size = BitConverter.ToUInt16(full, 0); - byte[] eas = new byte[size]; + var size = BitConverter.ToUInt16(full, 0); + var eas = new byte[size]; Array.Copy(full, 0, eas, 0, size); eaMs.Close(); @@ -159,11 +159,11 @@ public sealed partial class FAT int aIndex = eaHandle >> 7; // First 0x20 bytes are the magic number and unused words - ushort a = BitConverter.ToUInt16(_cachedEaData, (aIndex * 2) + 0x20); + var a = BitConverter.ToUInt16(_cachedEaData, aIndex * 2 + 0x20); - ushort b = BitConverter.ToUInt16(_cachedEaData, (eaHandle * 2) + 0x200); + var b = BitConverter.ToUInt16(_cachedEaData, eaHandle * 2 + 0x200); - uint eaCluster = (uint)(a + b); + var eaCluster = (uint)(a + b); if(b == EA_UNUSED) return null; @@ -175,13 +175,12 @@ public sealed partial class FAT if(header.magic != 0x4145) return null; - uint eaLen = BitConverter.ToUInt32(_cachedEaData, - (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf()); + var eaLen = BitConverter.ToUInt32(_cachedEaData, + (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf()); - byte[] eaData = new byte[eaLen]; + var eaData = new byte[eaLen]; - Array.Copy(_cachedEaData, (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf(), eaData, 0, - eaLen); + Array.Copy(_cachedEaData, (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf(), eaData, 0, eaLen); return GetEas(eaData); } @@ -197,19 +196,19 @@ public sealed partial class FAT if(_debug) eas.Add("com.microsoft.os2.fea", eaData); - int pos = 4; + var pos = 4; while(pos < eaData.Length) { pos++; // Skip fEA - byte cbName = eaData[pos++]; - ushort cbValue = BitConverter.ToUInt16(eaData, pos); + byte cbName = eaData[pos++]; + var cbValue = BitConverter.ToUInt16(eaData, pos); pos += 2; string name = Encoding.ASCII.GetString(eaData, pos, cbName); pos += cbName; pos++; - byte[] data = new byte[cbValue]; + var data = new byte[cbValue]; Array.Copy(eaData, pos, data, 0, cbValue); pos += cbValue; @@ -239,7 +238,7 @@ public sealed partial class FAT foreach(uint cluster in GetClusters(_eaDirEntry.start_cluster)) { - ErrorNumber errno = _image.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), + ErrorNumber errno = _image.ReadSectors(_firstClusterSector + cluster * _sectorsPerCluster, _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) diff --git a/Aaru.Filesystems/FATX/Consts.cs b/Aaru.Filesystems/FATX/Consts.cs index b6cc8b27b..f06c01e0a 100644 --- a/Aaru.Filesystems/FATX/Consts.cs +++ b/Aaru.Filesystems/FATX/Consts.cs @@ -30,12 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class XboxFatPlugin { const uint FATX_MAGIC = 0x58544146; @@ -62,7 +64,10 @@ public sealed partial class XboxFatPlugin [Flags] enum Attributes : byte { - ReadOnly = 0x01, Hidden = 0x02, System = 0x04, - Directory = 0x10, Archive = 0x20 + ReadOnly = 0x01, + Hidden = 0x02, + System = 0x04, + Directory = 0x10, + Archive = 0x20 } } \ No newline at end of file diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index 9c31746c0..bf1f6bbe3 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class XboxFatPlugin { /// @@ -56,8 +56,7 @@ public sealed partial class XboxFatPlugin return ErrorNumber.NoError; } - string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) - : path.ToLower(_cultureInfo); + string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo); if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) { @@ -84,7 +83,7 @@ public sealed partial class XboxFatPlugin currentDirectory = _rootDirectory; - for(int p = 0; p < pieces.Length; p++) + for(var p = 0; p < pieces.Length; p++) { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); @@ -105,12 +104,12 @@ public sealed partial class XboxFatPlugin if(clusters is null) return ErrorNumber.InvalidArgument; - byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; + var directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; - for(int i = 0; i < clusters.Length; i++) + for(var i = 0; i < clusters.Length; i++) { ErrorNumber errno = - _imagePlugin.ReadSectors(_firstClusterSector + ((clusters[i] - 1) * _sectorsPerCluster), + _imagePlugin.ReadSectors(_firstClusterSector + (clusters[i] - 1) * _sectorsPerCluster, _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) @@ -121,15 +120,13 @@ public sealed partial class XboxFatPlugin currentDirectory = new Dictionary(); - int pos = 0; + var pos = 0; while(pos < directoryBuffer.Length) { DirectoryEntry dirent = _littleEndian - ? Marshal. - ByteArrayToStructureLittleEndian< - DirectoryEntry>(directoryBuffer, pos, - Marshal.SizeOf()) + ? Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, + pos, Marshal.SizeOf()) : Marshal.ByteArrayToStructureBigEndian(directoryBuffer, pos, Marshal.SizeOf()); diff --git a/Aaru.Filesystems/FATX/FATX.cs b/Aaru.Filesystems/FATX/FATX.cs index 2409f58c4..a2eff9548 100644 --- a/Aaru.Filesystems/FATX/FATX.cs +++ b/Aaru.Filesystems/FATX/FATX.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements the Xbox File Allocation Table (FATX or XTAF) filesystem. public sealed partial class XboxFatPlugin : IReadOnlyFilesystem diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 5ef30a65b..3edadd189 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Filesystems; - public sealed partial class XboxFatPlugin { /// @@ -65,7 +65,7 @@ public sealed partial class XboxFatPlugin if(fileBlock >= clusters.Length) return ErrorNumber.InvalidArgument; - deviceBlock = (long)(_firstClusterSector + ((clusters[fileBlock] - 1) * _sectorsPerCluster)); + deviceBlock = (long)(_firstClusterSector + (clusters[fileBlock] - 1) * _sectorsPerCluster); return ErrorNumber.NoError; } @@ -120,15 +120,14 @@ public sealed partial class XboxFatPlugin var ms = new MemoryStream(); - for(int i = 0; i < sizeInClusters; i++) + for(var i = 0; i < sizeInClusters; i++) { if(i + firstCluster >= clusters.Length) return ErrorNumber.InvalidArgument; ErrorNumber errno = - _imagePlugin. - ReadSectors(_firstClusterSector + ((clusters[i + firstCluster] - 1) * _sectorsPerCluster), - _sectorsPerCluster, out byte[] buffer); + _imagePlugin.ReadSectors(_firstClusterSector + (clusters[i + firstCluster] - 1) * _sectorsPerCluster, + _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) return errno; @@ -186,8 +185,7 @@ public sealed partial class XboxFatPlugin ? 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.lastWrittenDate, entry.lastWrittenTime).AddYears(20) : DateHandlers.DosToDateTime(entry.lastWrittenTime, entry.lastWrittenDate) }; @@ -255,8 +253,7 @@ public sealed partial class XboxFatPlugin { entry = new DirectoryEntry(); - string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) - : path.ToLower(_cultureInfo); + string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] { @@ -266,7 +263,7 @@ public sealed partial class XboxFatPlugin if(pieces.Length == 0) return ErrorNumber.InvalidArgument; - string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); + var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); ErrorNumber err = ReadDir(parentPath, out _); diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index fd7cbb99a..a02860551 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class XboxFatPlugin { /// @@ -58,8 +58,7 @@ public sealed partial class XboxFatPlugin } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.UTF8; information = ""; @@ -67,7 +66,7 @@ public sealed partial class XboxFatPlugin if(imagePlugin.Info.SectorSize < 512) return; - bool bigEndian = true; + var bigEndian = true; ErrorNumber errno = imagePlugin.ReadSector(partition.Start, out byte[] sector); @@ -101,8 +100,7 @@ public sealed partial class XboxFatPlugin sb.AppendFormat("Root directory starts on 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("Volume label: {0}", volumeLabel).AppendLine(); sb.AppendFormat("Volume serial: {0:X8}", fatxSb.id).AppendLine(); diff --git a/Aaru.Filesystems/FATX/Structs.cs b/Aaru.Filesystems/FATX/Structs.cs index 4a2c72ef6..6c6dea002 100644 --- a/Aaru.Filesystems/FATX/Structs.cs +++ b/Aaru.Filesystems/FATX/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class XboxFatPlugin { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index bd15579ad..0b5a59432 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -44,8 +46,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - public sealed partial class XboxFatPlugin { /// @@ -130,7 +130,7 @@ public sealed partial class XboxFatPlugin AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type: {0}", _statfs.Type); byte[] buffer; - _fatStartSector = (FAT_START / imagePlugin.Info.SectorSize) + partition.Start; + _fatStartSector = FAT_START / imagePlugin.Info.SectorSize + partition.Start; uint fatSize; AaruConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector: {0}", _fatStartSector); @@ -162,7 +162,7 @@ public sealed partial class XboxFatPlugin _fat32 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - for(int i = 0; i < _fat32.Length; i++) + for(var i = 0; i < _fat32.Length; i++) _fat32[i] = Swapping.Swap(_fat32[i]); AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); @@ -197,7 +197,7 @@ public sealed partial class XboxFatPlugin _fat16 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - for(int i = 0; i < _fat16.Length; i++) + for(var i = 0; i < _fat16.Length; i++) _fat16[i] = Swapping.Swap(_fat16[i]); AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); @@ -220,15 +220,14 @@ public sealed partial class XboxFatPlugin if(rootDirectoryClusters is null) return ErrorNumber.InvalidArgument; - byte[] rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length]; + var rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length]; AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading root directory"); - for(int i = 0; i < rootDirectoryClusters.Length; i++) + for(var i = 0; i < rootDirectoryClusters.Length; i++) { - errno = - imagePlugin.ReadSectors(_firstClusterSector + ((rootDirectoryClusters[i] - 1) * _sectorsPerCluster), - _sectorsPerCluster, out buffer); + errno = imagePlugin.ReadSectors(_firstClusterSector + (rootDirectoryClusters[i] - 1) * _sectorsPerCluster, + _sectorsPerCluster, out buffer); if(errno != ErrorNumber.NoError) return errno; @@ -238,17 +237,15 @@ public sealed partial class XboxFatPlugin _rootDirectory = new Dictionary(); - int pos = 0; + var pos = 0; while(pos < rootDirectoryBuffer.Length) { DirectoryEntry entry = _littleEndian - ? Marshal. - ByteArrayToStructureLittleEndian< - DirectoryEntry>(rootDirectoryBuffer, pos, - Marshal.SizeOf()) - : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, - pos, Marshal.SizeOf()); + ? Marshal.ByteArrayToStructureLittleEndian(rootDirectoryBuffer, + pos, Marshal.SizeOf()) + : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, pos, + Marshal.SizeOf()); pos += Marshal.SizeOf(); diff --git a/Aaru.Filesystems/FFS.cs b/Aaru.Filesystems/FFS.cs index f41f8584e..25424a4c2 100644 --- a/Aaru.Filesystems/FFS.cs +++ b/Aaru.Filesystems/FFS.cs @@ -30,6 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +using time_t = System.Int32; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -42,10 +47,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -using time_t = System.Int32; -using ufs_daddr_t = System.Int32; - -namespace Aaru.Filesystems; // Using information from Linux kernel headers /// @@ -132,7 +133,6 @@ public sealed class FFSPlugin : IFilesystem try { foreach(ulong loc in locations) - { if(partition.End > partition.Start + loc + sbSizeInSectors) { ErrorNumber errno = @@ -141,7 +141,7 @@ public sealed class FFSPlugin : IFilesystem if(errno != ErrorNumber.NoError) continue; - uint magic = BitConverter.ToUInt32(ufsSbSectors, 0x055C); + var magic = BitConverter.ToUInt32(ufsSbSectors, 0x055C); if(magic == UFS_MAGIC || magic == UFS_CIGAM || @@ -153,7 +153,6 @@ public sealed class FFSPlugin : IFilesystem magic == UFS_BAD_CIGAM) return true; } - } return false; } @@ -164,8 +163,7 @@ public sealed class FFSPlugin : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -175,13 +173,13 @@ public sealed class FFSPlugin : IFilesystem uint sb_size_in_sectors; byte[] ufs_sb_sectors; ulong sb_offset = partition.Start; - bool fs_type_42bsd = false; - bool fs_type_43bsd = false; - bool fs_type_44bsd = false; - bool fs_type_ufs = false; - bool fs_type_ufs2 = false; - bool fs_type_sun = false; - bool fs_type_sun86 = false; + var fs_type_42bsd = false; + var fs_type_43bsd = false; + var fs_type_44bsd = false; + var fs_type_ufs = false; + var fs_type_ufs2 = false; + var fs_type_sun = false; + var fs_type_sun86 = false; if(imagePlugin.Info.SectorSize == 2336 || imagePlugin.Info.SectorSize == 2352 || @@ -290,10 +288,10 @@ public sealed class FFSPlugin : IFilesystem SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); - if((bs_sfu.fs_magic == UFS_MAGIC && sb.fs_magic == UFS_CIGAM) || - (bs_sfu.fs_magic == UFS_MAGIC_BW && sb.fs_magic == UFS_CIGAM_BW) || - (bs_sfu.fs_magic == UFS2_MAGIC && sb.fs_magic == UFS2_CIGAM) || - (bs_sfu.fs_magic == UFS_BAD_MAGIC && sb.fs_magic == UFS_BAD_CIGAM)) + if(bs_sfu.fs_magic == UFS_MAGIC && sb.fs_magic == UFS_CIGAM || + bs_sfu.fs_magic == UFS_MAGIC_BW && sb.fs_magic == UFS_CIGAM_BW || + bs_sfu.fs_magic == UFS2_MAGIC && sb.fs_magic == UFS2_CIGAM || + bs_sfu.fs_magic == UFS_BAD_MAGIC && sb.fs_magic == UFS_BAD_CIGAM) { sb = bs_sfu; sb.fs_old_cstotal.cs_nbfree = Swapping.Swap(sb.fs_old_cstotal.cs_nbfree); @@ -355,11 +353,9 @@ public sealed class FFSPlugin : IFilesystem else { const uint - SunOSEpoch = - 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00 + SunOSEpoch = 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00 - fs_type_43bsd = - true; // There is no way of knowing this is the version, but there is of knowing it is not. + fs_type_43bsd = true; // There is no way of knowing this is the version, but there is of knowing it is not. if(sb.fs_link > 0) { @@ -552,8 +548,7 @@ public sealed class FFSPlugin : IFilesystem sbInformation.AppendFormat("Volume last mounted on \"{0}\"", StringHandlers.CToString(sb.fs_fsmnt)). AppendLine(); - sbInformation.AppendFormat("Volume name: \"{0}\"", StringHandlers.CToString(sb.fs_volname)). - AppendLine(); + sbInformation.AppendFormat("Volume name: \"{0}\"", StringHandlers.CToString(sb.fs_volname)).AppendLine(); XmlFsType.VolumeName = StringHandlers.CToString(sb.fs_volname); sbInformation.AppendFormat("Volume ID: 0x{0:X16}", sb.fs_swuid).AppendLine(); @@ -604,8 +599,7 @@ public sealed class FFSPlugin : IFilesystem sbInformation.AppendFormat("A file can be {0} bytes at max", sb.fs_maxfilesize).AppendLine(); - sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(sb.fs_state)). - AppendLine(); + sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(sb.fs_state)).AppendLine(); } if(sb.fs_old_nrpos > 0) diff --git a/Aaru.Filesystems/Fossil.cs b/Aaru.Filesystems/Fossil.cs index 92df09a32..cd1076976 100644 --- a/Aaru.Filesystems/Fossil.cs +++ b/Aaru.Filesystems/Fossil.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection for the Plan-9 Fossil on-disk filesystem public sealed class Fossil : IFilesystem @@ -86,8 +86,7 @@ public sealed class Fossil : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { // Technically everything on Plan 9 from Bell Labs is in UTF-8 Encoding = Encoding.UTF8; @@ -118,7 +117,7 @@ public sealed class Fossil : IFilesystem sb.AppendFormat("Data starts at block {0}", hdr.data).AppendLine(); sb.AppendFormat("Volume has {0} blocks", hdr.end).AppendLine(); - ulong sbLocation = (hdr.super * (hdr.blockSize / imagePlugin.Info.SectorSize)) + partition.Start; + ulong sbLocation = hdr.super * (hdr.blockSize / imagePlugin.Info.SectorSize) + partition.Start; XmlFsType = new FileSystemType { diff --git a/Aaru.Filesystems/HAMMER.cs b/Aaru.Filesystems/HAMMER.cs index 9e36ec145..9e929f3a4 100644 --- a/Aaru.Filesystems/HAMMER.cs +++ b/Aaru.Filesystems/HAMMER.cs @@ -30,6 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +using hammer_crc_t = System.UInt32; +using hammer_off_t = System.UInt64; +using hammer_tid_t = System.UInt64; + +#pragma warning disable 169 + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -39,15 +47,8 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using hammer_crc_t = System.UInt32; -using hammer_off_t = System.UInt64; -using hammer_tid_t = System.UInt64; using Marshal = Aaru.Helpers.Marshal; -#pragma warning disable 169 - -namespace Aaru.Filesystems; - /// /// Implements detection for the HAMMER filesystem public sealed class HAMMER : IFilesystem @@ -84,14 +85,13 @@ public sealed class HAMMER : IFilesystem if(errno != ErrorNumber.NoError) return false; - ulong magic = BitConverter.ToUInt64(sbSector, 0); + var magic = BitConverter.ToUInt64(sbSector, 0); return magic == HAMMER_FSBUF_VOLUME || magic == HAMMER_FSBUF_VOLUME_REV; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -110,7 +110,7 @@ public sealed class HAMMER : IFilesystem if(errno != ErrorNumber.NoError) return; - ulong magic = BitConverter.ToUInt64(sbSector, 0); + var magic = BitConverter.ToUInt64(sbSector, 0); superBlock = magic == HAMMER_FSBUF_VOLUME ? Marshal.ByteArrayToStructureLittleEndian(sbSector) : Marshal.ByteArrayToStructureBigEndian(sbSector); @@ -145,8 +145,7 @@ public sealed class HAMMER : IFilesystem sb.AppendFormat("Filesystem contains {0} \"big-blocks\" ({1} bytes)", superBlock.vol0_stat_bigblocks, superBlock.vol0_stat_bigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); - sb.AppendFormat("Filesystem has {0} \"big-blocks\" free ({1} bytes)", - superBlock.vol0_stat_freebigblocks, + sb.AppendFormat("Filesystem has {0} \"big-blocks\" free ({1} bytes)", superBlock.vol0_stat_freebigblocks, superBlock.vol0_stat_freebigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); sb.AppendFormat("Filesystem has {0} inode used", superBlock.vol0_stat_inodes).AppendLine(); diff --git a/Aaru.Filesystems/HPFS.cs b/Aaru.Filesystems/HPFS.cs index 483b5ae3f..08d076a3b 100644 --- a/Aaru.Filesystems/HPFS.cs +++ b/Aaru.Filesystems/HPFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from an old unnamed document /// /// Implements detection of IBM's High Performance File System (HPFS) @@ -72,15 +72,14 @@ public sealed class HPFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); - uint magic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); + var magic1 = BitConverter.ToUInt32(hpfsSbSector, 0x000); + var magic2 = BitConverter.ToUInt32(hpfsSbSector, 0x004); return magic1 == 0xF995E849 && magic2 == 0xFA53E9C5; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("ibm850"); information = ""; diff --git a/Aaru.Filesystems/HPOFS/HPOFS.cs b/Aaru.Filesystems/HPOFS/HPOFS.cs index cc91ada30..f8b4b93d4 100644 --- a/Aaru.Filesystems/HPOFS/HPOFS.cs +++ b/Aaru.Filesystems/HPOFS/HPOFS.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - // Information from test floppy images created with OS/2 HPOFS 2.0 // Need to get IBM document GA32-0224 -> IBM 3995 Optical Library Dataserver Products: Optical Disk Format /// @@ -50,7 +50,7 @@ public sealed partial class HPOFS : IFilesystem /// public string Name => "High Performance Optical File System"; /// - public Guid Id => new Guid("1b72dcd5-d031-4757-8a9f-8d2fb18c59e2"); + public Guid Id => new("1b72dcd5-d031-4757-8a9f-8d2fb18c59e2"); /// public string Author => "Natalia Portillo"; } \ No newline at end of file diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index b2739737b..7c795dd1d 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Linq; using System.Text; using Aaru.CommonTypes; @@ -40,8 +42,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class HPOFS { /// @@ -66,8 +66,7 @@ public sealed partial class HPOFS } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("ibm850"); information = ""; @@ -97,8 +96,7 @@ public sealed partial class HPOFS MediaInformationBlock mib = Marshal.ByteArrayToStructureBigEndian(medInfoSector); VolumeInformationBlock vib = Marshal.ByteArrayToStructureBigEndian(volInfoSector); - AaruConsole.DebugWriteLine("HPOFS Plugin", "bpb.oem_name = \"{0}\"", - StringHandlers.CToString(bpb.oem_name)); + AaruConsole.DebugWriteLine("HPOFS Plugin", "bpb.oem_name = \"{0}\"", StringHandlers.CToString(bpb.oem_name)); AaruConsole.DebugWriteLine("HPOFS Plugin", "bpb.bps = {0}", bpb.bps); AaruConsole.DebugWriteLine("HPOFS Plugin", "bpb.spc = {0}", bpb.spc); @@ -196,8 +194,7 @@ public sealed partial class HPOFS sb.AppendFormat("Volume label: {0}", StringHandlers.SpacePaddedToString(mib.volumeLabel, Encoding)). AppendLine(); - sb.AppendFormat("Volume comment: {0}", StringHandlers.SpacePaddedToString(mib.comment, Encoding)). - AppendLine(); + sb.AppendFormat("Volume comment: {0}", StringHandlers.SpacePaddedToString(mib.comment, Encoding)).AppendLine(); sb.AppendFormat("Volume owner: {0}", StringHandlers.SpacePaddedToString(vib.owner, Encoding)).AppendLine(); diff --git a/Aaru.Filesystems/HPOFS/Structs.cs b/Aaru.Filesystems/HPOFS/Structs.cs index 57219eb21..ba71bf9b2 100644 --- a/Aaru.Filesystems/HPOFS/Structs.cs +++ b/Aaru.Filesystems/HPOFS/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Filesystems; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class HPOFS { diff --git a/Aaru.Filesystems/ISO9660/Consts/AAIP.cs b/Aaru.Filesystems/ISO9660/Consts/AAIP.cs index 58b3fdb01..3585f3879 100644 --- a/Aaru.Filesystems/ISO9660/Consts/AAIP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/AAIP.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const ushort AAIP_MAGIC = 0x414C; // "AL" diff --git a/Aaru.Filesystems/ISO9660/Consts/Amiga.cs b/Aaru.Filesystems/ISO9660/Consts/Amiga.cs index e5ec72b03..b4fb0ad02 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Amiga.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Amiga.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const ushort AMIGA_MAGIC = 0x4153; // "AS" @@ -44,22 +46,34 @@ public sealed partial class ISO9660 [Flags] enum AmigaFlags : byte { - Protection = 1 << 0, Comment = 1 << 1, CommentContinues = 1 << 2 + Protection = 1 << 0, + Comment = 1 << 1, + CommentContinues = 1 << 2 } [Flags] enum AmigaMultiuser : byte { - GroupDelete = 1 << 0, GroupExec = 1 << 1, GroupWrite = 1 << 2, - GroupRead = 1 << 3, OtherDelete = 1 << 4, OtherExec = 1 << 5, - OtherWrite = 1 << 6, OtherRead = 1 << 7 + GroupDelete = 1 << 0, + GroupExec = 1 << 1, + GroupWrite = 1 << 2, + GroupRead = 1 << 3, + OtherDelete = 1 << 4, + OtherExec = 1 << 5, + OtherWrite = 1 << 6, + OtherRead = 1 << 7 } [Flags] enum AmigaAttributes : byte { - OwnerDelete = 1 << 0, OwnerExec = 1 << 1, OwnerWrite = 1 << 2, - OwnerRead = 1 << 3, Archive = 1 << 4, Reentrant = 1 << 5, - Script = 1 << 6, Reserved = 1 << 7 + OwnerDelete = 1 << 0, + OwnerExec = 1 << 1, + OwnerWrite = 1 << 2, + OwnerRead = 1 << 3, + Archive = 1 << 4, + Reentrant = 1 << 5, + Script = 1 << 6, + Reserved = 1 << 7 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/Apple.cs b/Aaru.Filesystems/ISO9660/Consts/Apple.cs index 58f299bc2..cd2c009b6 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Apple.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Apple.cs @@ -40,12 +40,17 @@ public sealed partial class ISO9660 enum AppleId : byte { - ProDOS = 1, HFS = 2 + ProDOS = 1, + HFS = 2 } enum AppleOldId : byte { - ProDOS = 1, TypeCreator = 2, TypeCreatorBundle = 3, - TypeCreatorIcon = 4, TypeCreatorIconBundle = 5, HFS = 6 + ProDOS = 1, + TypeCreator = 2, + TypeCreatorBundle = 3, + TypeCreatorIcon = 4, + TypeCreatorIconBundle = 5, + HFS = 6 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/CDi.cs b/Aaru.Filesystems/ISO9660/Consts/CDi.cs index 3240d91c4..99198562b 100644 --- a/Aaru.Filesystems/ISO9660/Consts/CDi.cs +++ b/Aaru.Filesystems/ISO9660/Consts/CDi.cs @@ -31,13 +31,15 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; -using Aaru.Helpers; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; +using Aaru.Helpers; + public sealed partial class ISO9660 { const string CDI_MAGIC = "CD-I "; @@ -60,8 +62,13 @@ public sealed partial class ISO9660 [Flags] enum CdiAttributes : ushort { - OwnerRead = 1 << 0, OwnerExecute = 1 << 2, GroupRead = 1 << 4, - GroupExecute = 1 << 6, OtherRead = 1 << 8, OtherExecute = 1 << 10, - DigitalAudio = 1 << 14, Directory = 1 << 15 + OwnerRead = 1 << 0, + OwnerExecute = 1 << 2, + GroupRead = 1 << 4, + GroupExecute = 1 << 6, + OtherRead = 1 << 8, + OtherExecute = 1 << 10, + DigitalAudio = 1 << 14, + Directory = 1 << 15 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs index a799e7b76..1c78e4a74 100644 --- a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const ushort EL_TORITO_MAGIC = 0xAA55; @@ -44,26 +46,36 @@ public sealed partial class ISO9660 enum ElToritoIndicator : byte { - Header = 1, Extension = 0x44, Bootable = 0x88, - MoreHeaders = 0x90, LastHeader = 0x91 + Header = 1, + Extension = 0x44, + Bootable = 0x88, + MoreHeaders = 0x90, + LastHeader = 0x91 } enum ElToritoPlatform : byte { - x86 = 0, PowerPC = 1, Macintosh = 2, - EFI = 0xef + x86 = 0, + PowerPC = 1, + Macintosh = 2, + EFI = 0xef } enum ElToritoEmulation : byte { - None = 0, Md2Hd = 1, Mf2Hd = 2, - Mf2Ed = 3, Hdd = 4 + None = 0, + Md2Hd = 1, + Mf2Hd = 2, + Mf2Ed = 3, + Hdd = 4 } [Flags] enum ElToritoFlags : byte { - Reserved = 0x10, Continued = 0x20, ATAPI = 0x40, - SCSI = 0x08 + Reserved = 0x10, + Continued = 0x20, + ATAPI = 0x40, + SCSI = 0x08 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs index 22e52b2df..5bd42017a 100644 --- a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using Aaru.Helpers; - namespace Aaru.Filesystems; +using Aaru.Helpers; + public sealed partial class ISO9660 { const string HIGH_SIERRA_MAGIC = "CDROM"; diff --git a/Aaru.Filesystems/ISO9660/Consts/ISO.cs b/Aaru.Filesystems/ISO9660/Consts/ISO.cs index 6c28e055f..bbe62a958 100644 --- a/Aaru.Filesystems/ISO9660/Consts/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Consts/ISO.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const string ISO_MAGIC = "CD001"; @@ -44,26 +46,39 @@ public sealed partial class ISO9660 [Flags] enum FileFlags : byte { - Hidden = 0x01, Directory = 0x02, Associated = 0x04, - Record = 0x08, Protected = 0x10, MultiExtent = 0x80 + Hidden = 0x01, + Directory = 0x02, + Associated = 0x04, + Record = 0x08, + Protected = 0x10, + MultiExtent = 0x80 } [Flags] enum Permissions : ushort { - SystemRead = 0x01, SystemExecute = 0x04, OwnerRead = 0x10, - OwnerExecute = 0x40, GroupRead = 0x100, GroupExecute = 0x400, - OtherRead = 0x1000, OtherExecute = 0x4000 + SystemRead = 0x01, + SystemExecute = 0x04, + OwnerRead = 0x10, + OwnerExecute = 0x40, + GroupRead = 0x100, + GroupExecute = 0x400, + OtherRead = 0x1000, + OtherExecute = 0x4000 } enum RecordFormat : byte { - Unspecified = 0, FixedLength = 1, VariableLength = 2, + Unspecified = 0, + FixedLength = 1, + VariableLength = 2, VariableLengthAlternate = 3 } enum RecordAttribute : byte { - LFCR = 0, ISO1539 = 1, ControlContained = 2 + LFCR = 0, + ISO1539 = 1, + ControlContained = 2 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/Internal.cs b/Aaru.Filesystems/ISO9660/Consts/Internal.cs index 1d5ba627b..45cf6eff0 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Internal.cs @@ -31,11 +31,11 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Diagnostics.CodeAnalysis; using Aaru.Helpers; -namespace Aaru.Filesystems; - [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class ISO9660 { @@ -44,7 +44,10 @@ public sealed partial class ISO9660 enum Namespace { - Normal, Vms, Joliet, - Rrip, Romeo + Normal, + Vms, + Joliet, + Rrip, + Romeo } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/RRIP.cs b/Aaru.Filesystems/ISO9660/Consts/RRIP.cs index 39dd98d40..b0f4ac491 100644 --- a/Aaru.Filesystems/ISO9660/Consts/RRIP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/RRIP.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const ushort RRIP_MAGIC = 0x5252; // "RR" @@ -53,13 +55,25 @@ public sealed partial class ISO9660 [Flags] enum PosixMode : uint { - OwnerRead = 0x0100, OwnerWrite = 0x0080, OwnerExecute = 0x0040, - GroupRead = 0x0020, GroupWrite = 0x0010, GroupExecute = 0x0008, - OtherRead = 0x0004, OtherWrite = 0x0002, OtherExecute = 0x0001, - SetUID = 0x0800, SetGid = 0x0400, IsVTX = 0x0200, - Socket = 0xC000, Symlink = 0xA000, Regular = 0x8000, - Block = 0x6000, Character = 0x2000, Directory = 0x4000, - Pipe = 0x1000 + OwnerRead = 0x0100, + OwnerWrite = 0x0080, + OwnerExecute = 0x0040, + GroupRead = 0x0020, + GroupWrite = 0x0010, + GroupExecute = 0x0008, + OtherRead = 0x0004, + OtherWrite = 0x0002, + OtherExecute = 0x0001, + SetUID = 0x0800, + SetGid = 0x0400, + IsVTX = 0x0200, + Socket = 0xC000, + Symlink = 0xA000, + Regular = 0x8000, + Block = 0x6000, + Character = 0x2000, + Directory = 0x4000, + Pipe = 0x1000 } [Flags] @@ -71,22 +85,33 @@ public sealed partial class ISO9660 [Flags] enum SymlinkComponentFlags : byte { - Continue = 1, Current = 2, Parent = 4, - Root = 8, Mountpoint = 16, Networkname = 32 + Continue = 1, + Current = 2, + Parent = 4, + Root = 8, + Mountpoint = 16, + Networkname = 32 } [Flags] enum AlternateNameFlags : byte { - Continue = 1, Current = 2, Parent = 4, + Continue = 1, + Current = 2, + Parent = 4, Networkname = 32 } [Flags] enum TimestampFlags : byte { - Creation = 1 << 0, Modification = 1 << 1, Access = 1 << 2, - AttributeChange = 1 << 3, Backup = 1 << 4, Expiration = 1 << 5, - Effective = 1 << 6, LongFormat = 1 << 7 + Creation = 1 << 0, + Modification = 1 << 1, + Access = 1 << 2, + AttributeChange = 1 << 3, + Backup = 1 << 4, + Expiration = 1 << 5, + Effective = 1 << 6, + LongFormat = 1 << 7 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/SUSP.cs b/Aaru.Filesystems/ISO9660/Consts/SUSP.cs index 8ae5aa866..943c4b3d6 100644 --- a/Aaru.Filesystems/ISO9660/Consts/SUSP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/SUSP.cs @@ -33,10 +33,10 @@ // ReSharper disable IdentifierTypo -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class ISO9660 { diff --git a/Aaru.Filesystems/ISO9660/Consts/XA.cs b/Aaru.Filesystems/ISO9660/Consts/XA.cs index a289b3f37..6ee9cb4fd 100644 --- a/Aaru.Filesystems/ISO9660/Consts/XA.cs +++ b/Aaru.Filesystems/ISO9660/Consts/XA.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; + // ReSharper disable UnusedMember.Local namespace Aaru.Filesystems; +using System; + public sealed partial class ISO9660 { const ushort XA_MAGIC = 0x5841; // "XA" @@ -44,17 +46,29 @@ public sealed partial class ISO9660 [Flags] enum XaAttributes : ushort { - SystemRead = 0x01, SystemExecute = 0x04, OwnerRead = 0x10, - OwnerExecute = 0x40, GroupRead = 0x100, GroupExecute = 0x400, - Mode2Form1 = 0x800, Mode2Form2 = 0x1000, Interleaved = 0x2000, - Cdda = 0x4000, Directory = 0x8000 + SystemRead = 0x01, + SystemExecute = 0x04, + OwnerRead = 0x10, + OwnerExecute = 0x40, + GroupRead = 0x100, + GroupExecute = 0x400, + Mode2Form1 = 0x800, + Mode2Form2 = 0x1000, + Interleaved = 0x2000, + Cdda = 0x4000, + Directory = 0x8000 } [Flags] enum Mode2Submode : byte { - EndOfFile = 0x80, RealTime = 0x40, Form2 = 0x20, - Trigger = 0x10, Data = 0x08, Audio = 0x04, - Video = 0x02, EndOfRecord = 0x01 + EndOfFile = 0x80, + RealTime = 0x40, + Form2 = 0x20, + Trigger = 0x10, + Data = 0x08, + Audio = 0x04, + Video = 0x02, + EndOfRecord = 0x01 } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/Ziso.cs b/Aaru.Filesystems/ISO9660/Consts/Ziso.cs index 02699857a..4af1fe4f5 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Ziso.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Ziso.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class ISO9660 { diff --git a/Aaru.Filesystems/ISO9660/Date.cs b/Aaru.Filesystems/ISO9660/Date.cs index 8ec326ca0..a5abe1d64 100644 --- a/Aaru.Filesystems/ISO9660/Date.cs +++ b/Aaru.Filesystems/ISO9660/Date.cs @@ -31,11 +31,11 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { static DateTime? DecodeIsoDateTime(byte[] timestamp) diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index 75c588dd4..02165dd1b 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -31,6 +31,8 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -40,8 +42,6 @@ using System.Text; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { Dictionary> _directoryCache; @@ -91,7 +91,7 @@ public sealed partial class ISO9660 currentDirectory = _rootDirectoryCache; - for(int p = 0; p < pieces.Length; p++) + for(var p = 0; p < pieces.Length; p++) { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[p]); @@ -162,7 +162,7 @@ public sealed partial class ISO9660 Dictionary DecodeCdiDirectory(ulong start, uint size) { Dictionary entries = new(); - int entryOff = 0; + var entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -174,9 +174,9 @@ public sealed partial class ISO9660 if(record.length == 0) { // Skip to next sector - if(data.Length - (((entryOff / 2048) + 1) * 2048) > 0) + if(data.Length - (entryOff / 2048 + 1) * 2048 > 0) { - entryOff = ((entryOff / 2048) + 1) * 2048; + entryOff = (entryOff / 2048 + 1) * 2048; continue; } @@ -239,7 +239,7 @@ public sealed partial class ISO9660 Dictionary DecodeHighSierraDirectory(ulong start, uint size) { Dictionary entries = new(); - int entryOff = 0; + var entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -252,9 +252,9 @@ public sealed partial class ISO9660 if(record.length == 0) { // Skip to next sector - if(data.Length - (((entryOff / 2048) + 1) * 2048) > 0) + if(data.Length - (entryOff / 2048 + 1) * 2048 > 0) { - entryOff = ((entryOff / 2048) + 1) * 2048; + entryOff = (entryOff / 2048 + 1) * 2048; continue; } @@ -310,7 +310,7 @@ public sealed partial class ISO9660 Dictionary DecodeIsoDirectory(ulong start, uint size) { Dictionary entries = new(); - int entryOff = 0; + var entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -322,9 +322,9 @@ public sealed partial class ISO9660 if(record.length == 0) { // Skip to next sector - if(data.Length - (((entryOff / 2048) + 1) * 2048) > 0) + if(data.Length - (entryOff / 2048 + 1) * 2048 > 0) { - entryOff = ((entryOff / 2048) + 1) * 2048; + entryOff = (entryOff / 2048 + 1) * 2048; continue; } @@ -464,8 +464,7 @@ public sealed partial class ISO9660 // Relocated directories should be shown in correct place when using Rock Ridge namespace return _namespace == Namespace.Rrip - ? entries.Where(e => !e.Value.RockRidgeRelocated).ToDictionary(x => x.Key, x => x.Value) - : entries; + ? entries.Where(e => !e.Value.RockRidgeRelocated).ToDictionary(x => x.Key, x => x.Value) : entries; } void DecodeTransTable(Dictionary entries) @@ -480,8 +479,8 @@ public sealed partial class ISO9660 byte[] transTbl = 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); + transTblEntry.Value.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, + transTblEntry.Value.XA?.filenumber ?? 0); var mr = new MemoryStream(transTbl, 0, (int)transTblEntry.Value.Size, false); var sr = new StreamReader(mr, Encoding); @@ -513,8 +512,7 @@ public sealed partial class ISO9660 KeyValuePair originalEntry = entries.FirstOrDefault(e => !e.Value.Flags.HasFlag(FileFlags.Directory) && - (e.Value.Filename.ToLower(CultureInfo.CurrentUICulture) == - originalName || + (e.Value.Filename.ToLower(CultureInfo.CurrentUICulture) == originalName || e.Value.Filename.ToLower(CultureInfo.CurrentUICulture) == originalNameWithVersion)); @@ -526,18 +524,17 @@ public sealed partial class ISO9660 entries.Remove(transTblEntry.Key); } - void DecodeSystemArea(byte[] data, int start, int end, ref DecodedDirectoryEntry entry, - out bool hasResourceFork) + void DecodeSystemArea(byte[] data, int start, int end, ref DecodedDirectoryEntry entry, out bool hasResourceFork) { int systemAreaOff = start; hasResourceFork = false; - bool continueSymlink = false; - bool continueSymlinkComponent = false; + var continueSymlink = false; + var continueSymlinkComponent = false; AppleCommon.FInfo fInfo; while(systemAreaOff + 2 <= end) { - ushort systemAreaSignature = BigEndianBitConverter.ToUInt16(data, systemAreaOff); + var systemAreaSignature = BigEndianBitConverter.ToUInt16(data, systemAreaOff); if(BigEndianBitConverter.ToUInt16(data, systemAreaOff + 6) == XA_MAGIC) systemAreaSignature = XA_MAGIC; @@ -590,8 +587,8 @@ public sealed partial class ISO9660 { case AppleOldId.ProDOS: AppleProDOSOldSystemUse appleProDosOldSystemUse = - Marshal.ByteArrayToStructureLittleEndian(data, - systemAreaOff, Marshal.SizeOf()); + Marshal.ByteArrayToStructureLittleEndian(data, systemAreaOff, + Marshal.SizeOf()); entry.AppleProDosType = appleProDosOldSystemUse.aux_type; entry.AppleDosType = appleProDosOldSystemUse.type; @@ -602,8 +599,8 @@ public sealed partial class ISO9660 case AppleOldId.TypeCreator: case AppleOldId.TypeCreatorBundle: AppleHFSTypeCreatorSystemUse appleHfsTypeCreatorSystemUse = - Marshal.ByteArrayToStructureBigEndian(data, - systemAreaOff, Marshal.SizeOf()); + Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, + Marshal.SizeOf()); hasResourceFork = true; @@ -671,14 +668,13 @@ public sealed partial class ISO9660 Marshal.ByteArrayToStructureBigEndian(data, systemAreaOff, Marshal.SizeOf()); - int protectionLength = 0; + var protectionLength = 0; if(amiga.flags.HasFlag(AmigaFlags.Protection)) { entry.AmigaProtection = Marshal.ByteArrayToStructureBigEndian(data, - systemAreaOff + Marshal.SizeOf(), - Marshal.SizeOf()); + systemAreaOff + Marshal.SizeOf(), Marshal.SizeOf()); protectionLength = Marshal.SizeOf(); } @@ -688,15 +684,15 @@ public sealed partial class ISO9660 if(entry.AmigaComment is null) entry.AmigaComment = Array.Empty(); - byte[] newComment = new byte[entry.AmigaComment.Length + - data - [systemAreaOff + Marshal.SizeOf() + protectionLength] - - 1]; + var newComment = new byte[entry.AmigaComment.Length + + data + [systemAreaOff + Marshal.SizeOf() + protectionLength] - + 1]; Array.Copy(entry.AmigaComment, 0, newComment, 0, entry.AmigaComment.Length); - Array.Copy(data, systemAreaOff + Marshal.SizeOf() + protectionLength, - newComment, entry.AmigaComment.Length, + Array.Copy(data, systemAreaOff + Marshal.SizeOf() + protectionLength, newComment, + entry.AmigaComment.Length, data[systemAreaOff + Marshal.SizeOf() + protectionLength] - 1); entry.AmigaComment = newComment; @@ -773,8 +769,7 @@ public sealed partial class ISO9660 systemAreaOff + Marshal.SizeOf() + Marshal.SizeOf(), slc.length) : Encoding.GetString(data, - systemAreaOff + - Marshal.SizeOf() + + systemAreaOff + Marshal.SizeOf() + Marshal.SizeOf(), slc.length); @@ -813,7 +808,7 @@ public sealed partial class ISO9660 if(entry.RockRidgeAlternateName is null) entry.RockRidgeAlternateName = Array.Empty(); - byte[] newNm = new byte[entry.RockRidgeAlternateName.Length + nm.Length]; + var newNm = new byte[entry.RockRidgeAlternateName.Length + nm.Length]; Array.Copy(entry.RockRidgeAlternateName, 0, newNm, 0, entry.RockRidgeAlternateName.Length); Array.Copy(nm, 0, newNm, entry.RockRidgeAlternateName.Length, nm.Length); @@ -1026,13 +1021,15 @@ public sealed partial class ISO9660 '/' }, StringSplitOptions.RemoveEmptyEntries); - int currentParent = 1; - int currentPiece = 0; + var currentParent = 1; + var currentPiece = 0; while(currentPiece < pieces.Length) { PathTableEntryInternal currentEntry = _pathTable.FirstOrDefault(p => p.Parent == currentParent && - p.Name.ToLower(CultureInfo.CurrentUICulture) == pieces[currentPiece]); + p.Name.ToLower(CultureInfo. + CurrentUICulture) == + pieces[currentPiece]); if(currentEntry is null) break; diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index d10caf081..0408261c5 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -31,6 +31,8 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { /// @@ -129,7 +129,6 @@ public sealed partial class ISO9660 if(entry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) == true && entry.Extents.Count == 1) - { try { long firstSector = offset / 2352; @@ -157,7 +156,6 @@ public sealed partial class ISO9660 return ErrorNumber.UnexpectedException; } - } buf = ReadWithExtents(offset, size, entry.Extents, entry.XA?.signature == XA_MAGIC && @@ -453,7 +451,7 @@ public sealed partial class ISO9660 if(pieces.Length == 0) return ErrorNumber.InvalidArgument; - string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); + var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { @@ -478,8 +476,7 @@ public sealed partial class ISO9660 if(!_joliet && !pieces[^1].EndsWith(";1", StringComparison.Ordinal)) { - dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == - pieces[^1] + ";1"); + dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[^1] + ";1"); if(string.IsNullOrEmpty(dirent.Key)) return ErrorNumber.NoSuchFile; @@ -514,7 +511,7 @@ public sealed partial class ISO9660 var ms = new MemoryStream(); long currentFilePos = 0; - for(int i = 0; i < extents.Count; i++) + for(var i = 0; i < extents.Count; i++) { if(offset - currentFilePos >= extents[i].size) { @@ -528,8 +525,8 @@ public sealed partial class ISO9660 while(leftExtentSize > 0) { - ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector, out byte[] sector, - interleaved, fileNumber); + ErrorNumber errno = ReadSector(extents[i].extent + currentExtentSector, out byte[] sector, interleaved, + fileNumber); if(errno != ErrorNumber.NoError || sector is null) @@ -549,8 +546,7 @@ public sealed partial class ISO9660 } if(offset - currentFilePos > 0) - ms.Write(sector, (int)(offset - currentFilePos), - (int)(sector.Length - (offset - currentFilePos))); + ms.Write(sector, (int)(offset - currentFilePos), (int)(sector.Length - (offset - currentFilePos))); else ms.Write(sector, 0, sector.Length); @@ -576,16 +572,15 @@ public sealed partial class ISO9660 { var ms = new MemoryStream(); - for(int i = 0; i < extents.Count; i++) + for(var i = 0; i < extents.Count; i++) { long leftExtentSize = extents[i].size; uint currentExtentSector = 0; while(leftExtentSize > 0) { - ErrorNumber errno = - _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048, - SectorTagType.CdSectorSubHeader, out byte[] fullSector); + ErrorNumber errno = _image.ReadSectorTag((extents[i].extent + currentExtentSector) * _blockSize / 2048, + SectorTagType.CdSectorSubHeader, out byte[] fullSector); if(errno != ErrorNumber.NoError) return null; diff --git a/Aaru.Filesystems/ISO9660/ISO9660.cs b/Aaru.Filesystems/ISO9660/ISO9660.cs index c53680b94..f3a4a0fe4 100644 --- a/Aaru.Filesystems/ISO9660/ISO9660.cs +++ b/Aaru.Filesystems/ISO9660/ISO9660.cs @@ -31,6 +31,8 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.Filesystems; - // This is coded following ECMA-119. /// /// Implements the High Sierra, ISO9660 and CD-i filesystems diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index 8001d4837..56742e911 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -31,6 +31,8 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; @@ -43,8 +45,6 @@ using Aaru.Decoders.Sega; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { /// @@ -64,14 +64,14 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return false; - int xaOff = 0; + var xaOff = 0; if(vdSector.Length == 2336) xaOff = 8; - byte vdType = vdSector[0 + xaOff]; - byte[] vdMagic = new byte[5]; - byte[] hsMagic = new byte[5]; + 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) @@ -84,21 +84,19 @@ public sealed partial class ISO9660 AaruConsole.DebugWriteLine("ISO9660 plugin", "HSMagic = {0}", Encoding.ASCII.GetString(hsMagic)); return Encoding.ASCII.GetString(vdMagic) == ISO_MAGIC || - Encoding.ASCII.GetString(hsMagic) == HIGH_SIERRA_MAGIC || - Encoding.ASCII.GetString(vdMagic) == CDI_MAGIC; + Encoding.ASCII.GetString(hsMagic) == HIGH_SIERRA_MAGIC || Encoding.ASCII.GetString(vdMagic) == CDI_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.ASCII; information = ""; - var isoMetadata = new StringBuilder(); - byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" - byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" + var isoMetadata = new StringBuilder(); + var vdMagic = new byte[5]; // Volume Descriptor magic "CD001" + var hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" - string bootSpec = ""; + var bootSpec = ""; PrimaryVolumeDescriptor? pvd = null; PrimaryVolumeDescriptor? jolietvd = null; @@ -125,14 +123,14 @@ public sealed partial class ISO9660 int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); bool highSierraInfo = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; - int hsOff = 0; + var hsOff = 0; if(highSierraInfo) hsOff = 8; - bool cdiInfo = false; - bool evd = false; - bool vpd = false; + var cdiInfo = false; + var evd = false; + var vpd = false; while(true) { @@ -164,8 +162,7 @@ public sealed partial class ISO9660 if(Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && - Encoding.GetString(vdMagic) != - CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. + Encoding.GetString(vdMagic) != CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { if(counter == 0) return; @@ -188,8 +185,7 @@ public sealed partial class ISO9660 bootSpec = "El Torito"; torito = - Marshal.ByteArrayToStructureLittleEndian(vdSector, hsOff, - 2048 - hsOff); + Marshal.ByteArrayToStructureLittleEndian(vdSector, hsOff, 2048 - hsOff); } break; @@ -198,8 +194,7 @@ public sealed partial class ISO9660 case 1: { if(highSierraInfo) - hsvd = Marshal. - ByteArrayToStructureLittleEndian(vdSector); + hsvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); else if(cdiInfo) fsvd = Marshal.ByteArrayToStructureBigEndian(vdSector); else @@ -293,14 +288,14 @@ public sealed partial class ISO9660 } byte[] rootDir = Array.Empty(); - int rootOff = 0; - bool xaExtensions = false; - bool apple = false; - bool susp = false; - bool rrip = false; - bool ziso = false; - bool amiga = false; - bool aaip = false; + var rootOff = 0; + var xaExtensions = false; + var apple = false; + var susp = false; + var rrip = false; + var ziso = false; + var amiga = false; + var aaip = false; List contareas = new(); List refareas = new(); var suspInformation = new StringBuilder(); @@ -328,13 +323,13 @@ public sealed partial class ISO9660 if(saLen > 0 && rootOff + saOff + saLen <= rootDir.Length) { - byte[] sa = new byte[saLen]; + var sa = new byte[saLen]; Array.Copy(rootDir, rootOff + saOff, sa, 0, saLen); saOff = 0; while(saOff < saLen) { - bool noneFound = true; + var noneFound = true; if(Marshal.SizeOf() + saOff <= saLen) { @@ -351,7 +346,7 @@ public sealed partial class ISO9660 if(saOff + 2 >= saLen) break; - ushort nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); + var nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); switch(nextSignature) { @@ -414,7 +409,7 @@ public sealed partial class ISO9660 break; case SUSP_CONTINUATION when saOff + sa[saOff + 2] <= saLen: - byte[] ce = new byte[sa[saOff + 2]]; + var ce = new byte[sa[saOff + 2]]; Array.Copy(sa, saOff, ce, 0, ce.Length); ContinuationArea ca = @@ -424,7 +419,7 @@ public sealed partial class ISO9660 break; case SUSP_REFERENCE when saOff + sa[saOff + 2] <= saLen: - byte[] er = new byte[sa[saOff + 2]]; + var er = new byte[sa[saOff + 2]]; Array.Copy(sa, saOff, er, 0, er.Length); refareas.Add(er); @@ -440,8 +435,8 @@ public sealed partial class ISO9660 ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; - aaip |= nextSignature == AAIP_MAGIC || (nextSignature == AAIP_MAGIC_OLD && - sa[saOff + 3] == 1 && sa[saOff + 2] >= 9); + aaip |= nextSignature == AAIP_MAGIC || nextSignature == AAIP_MAGIC_OLD && + sa[saOff + 3] == 1 && sa[saOff + 2] >= 9; saOff += sa[saOff + 2]; @@ -477,13 +472,13 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return; - byte[] caData = new byte[ca.ca_length_be]; + var caData = new byte[ca.ca_length_be]; Array.Copy(caSectors, ca.offset_be, caData, 0, ca.ca_length_be); - int caOff = 0; + var caOff = 0; while(caOff < ca.ca_length_be) { - ushort nextSignature = BigEndianBitConverter.ToUInt16(caData, caOff); + var nextSignature = BigEndianBitConverter.ToUInt16(caData, caOff); switch(nextSignature) { @@ -497,7 +492,7 @@ public sealed partial class ISO9660 break; case SUSP_REFERENCE when caOff + caData[caOff + 2] <= ca.ca_length_be: - byte[] er = new byte[caData[caOff + 2]]; + var er = new byte[caData[caOff + 2]]; Array.Copy(caData, caOff, er, 0, er.Length); refareas.Add(er); @@ -513,8 +508,8 @@ public sealed partial class ISO9660 ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; - aaip |= nextSignature == AAIP_MAGIC || (nextSignature == AAIP_MAGIC_OLD && caData[caOff + 3] == 1 && - caData[caOff + 2] >= 9); + aaip |= nextSignature == AAIP_MAGIC || nextSignature == AAIP_MAGIC_OLD && caData[caOff + 3] == 1 && + caData[caOff + 2] >= 9; caOff += caData[caOff + 2]; } @@ -617,14 +612,11 @@ public sealed partial class ISO9660 isoMetadata.AppendLine(Dreamcast.Prettify(dreamcast)); } - isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : ""). - AppendLine(); + isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : "").AppendLine(); - isoMetadata.AppendFormat("{0}VOLUME DESCRIPTOR INFORMATION:", cdiInfo ? "FILE STRUCTURE " : ""). - AppendLine(); + isoMetadata.AppendFormat("{0}VOLUME DESCRIPTOR INFORMATION:", cdiInfo ? "FILE STRUCTURE " : "").AppendLine(); - isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : ""). - AppendLine(); + isoMetadata.AppendFormat("{0}------------------------------", cdiInfo ? "---------------" : "").AppendLine(); isoMetadata.AppendFormat("System identifier: {0}", decodedVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume identifier: {0}", decodedVd.VolumeIdentifier).AppendLine(); @@ -660,16 +652,14 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat("System identifier: {0}", decodedJolietVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume identifier: {0}", decodedJolietVd.VolumeIdentifier).AppendLine(); - isoMetadata.AppendFormat("Volume set identifier: {0}", decodedJolietVd.VolumeSetIdentifier). - AppendLine(); + isoMetadata.AppendFormat("Volume set identifier: {0}", decodedJolietVd.VolumeSetIdentifier).AppendLine(); isoMetadata.AppendFormat("Publisher identifier: {0}", decodedJolietVd.PublisherIdentifier).AppendLine(); isoMetadata.AppendFormat("Data preparer identifier: {0}", decodedJolietVd.DataPreparerIdentifier). AppendLine(); - isoMetadata.AppendFormat("Application identifier: {0}", decodedJolietVd.ApplicationIdentifier). - AppendLine(); + isoMetadata.AppendFormat("Application identifier: {0}", decodedJolietVd.ApplicationIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume creation date: {0}", decodedJolietVd.CreationTime).AppendLine(); @@ -680,8 +670,7 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat("Volume has not been modified.").AppendLine(); if(decodedJolietVd.HasExpirationTime) - isoMetadata.AppendFormat("Volume expiration date: {0}", decodedJolietVd.ExpirationTime). - AppendLine(); + isoMetadata.AppendFormat("Volume expiration date: {0}", decodedJolietVd.ExpirationTime).AppendLine(); else isoMetadata.AppendFormat("Volume does not expire.").AppendLine(); @@ -698,7 +687,7 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return; - int toritoOff = 0; + var toritoOff = 0; if(vdSector[toritoOff] != 1) goto exit_torito; @@ -718,8 +707,7 @@ public sealed partial class ISO9660 initialEntry.boot_type = (ElToritoEmulation)((byte)initialEntry.boot_type & 0xF); - AaruConsole.DebugWriteLine("DEBUG (ISO9660 plugin)", "initialEntry.load_rba = {0}", - initialEntry.load_rba); + AaruConsole.DebugWriteLine("DEBUG (ISO9660 plugin)", "initialEntry.load_rba = {0}", initialEntry.load_rba); AaruConsole.DebugWriteLine("DEBUG (ISO9660 plugin)", "initialEntry.sector_count = {0}", initialEntry.sector_count); @@ -746,8 +734,7 @@ public sealed partial class ISO9660 if(valentry.platform_id == ElToritoPlatform.x86) isoMetadata.AppendFormat("\tBootable image will be loaded at segment {0:X4}h", - initialEntry.load_seg == 0 ? 0x7C0 : initialEntry.load_seg). - AppendLine(); + initialEntry.load_seg == 0 ? 0x7C0 : initialEntry.load_seg).AppendLine(); else isoMetadata.AppendFormat("\tBootable image will be loaded at 0x{0:X8}", (uint)initialEntry.load_seg * 10).AppendLine(); @@ -805,7 +792,7 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat("\tSection ID: {0}", Encoding.GetString(sectionHeader.identifier)). AppendLine(); - for(int entryCounter = 1; entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length; + for(var entryCounter = 1; entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length; entryCounter++) { ElToritoSectionEntry sectionEntry = @@ -821,8 +808,8 @@ public sealed partial class ISO9660 bootImage = null; if(sectionEntry.load_rba + partition.Start + sectionEntry.sector_count - 1 <= partition.End) - imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, - sectionEntry.sector_count, out bootImage); + imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, sectionEntry.sector_count, + out bootImage); isoMetadata.AppendFormat("\t\tBootable on {0}", sectionHeader.platform_id).AppendLine(); @@ -868,8 +855,7 @@ public sealed partial class ISO9660 isoMetadata.AppendFormat("\t\tSelection criteria type: {0}", sectionEntry.selection_criteria_type).AppendLine(); - isoMetadata.AppendFormat("\t\tSystem type: 0x{0:X2}", sectionEntry.system_type). - AppendLine(); + isoMetadata.AppendFormat("\t\tSystem type: 0x{0:X2}", sectionEntry.system_type).AppendLine(); if(bootImage != null) isoMetadata.AppendFormat("\t\tBootable image's SHA1: {0}", @@ -892,8 +878,8 @@ public sealed partial class ISO9660 while(toritoOff < vdSector.Length) { ElToritoSectionEntryExtension sectionExtension = - Marshal.ByteArrayToStructureLittleEndian(vdSector, - toritoOff, EL_TORITO_ENTRY_SIZE); + Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, + EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; @@ -907,7 +893,7 @@ public sealed partial class ISO9660 } } - exit_torito: + exit_torito: if(refareas.Count > 0) isoMetadata.Append(suspInformation); @@ -943,8 +929,8 @@ public sealed partial class ISO9660 decodedVd.DataPreparerIdentifier.Length > decodedJolietVd.DataPreparerIdentifier.Length) XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; else - XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) - ? null : decodedJolietVd.DataPreparerIdentifier; + XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) ? null + : decodedJolietVd.DataPreparerIdentifier; if(string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) || decodedVd.ApplicationIdentifier.Length > decodedJolietVd.ApplicationIdentifier.Length) diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs index cae145911..aa82f2811 100644 --- a/Aaru.Filesystems/ISO9660/Mode2.cs +++ b/Aaru.Filesystems/ISO9660/Mode2.cs @@ -31,14 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Decoders.CD; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { ErrorNumber ReadSector(ulong sector, out byte[] buffer, bool interleaved = false, byte fileNumber = 0) @@ -70,7 +70,6 @@ public sealed partial class ISO9660 return errno; if(_debug) - { switch(data.Length) { case 2048: @@ -79,16 +78,15 @@ public sealed partial class ISO9660 break; case 2324: - AaruConsole.DebugWriteLine("ISO9660 Plugin", "Sector {0}, Cooked, Mode 2 Form 2", - realSector); + AaruConsole.DebugWriteLine("ISO9660 Plugin", "Sector {0}, Cooked, Mode 2 Form 2", realSector); break; case 2336: AaruConsole.DebugWriteLine("ISO9660 Plugin", "Sector {0}, Cooked, Mode 2 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 || data[1] != 0xFF || data[2] != 0xFF || data[3] != 0xFF || @@ -98,9 +96,8 @@ public sealed partial class ISO9660 break; case 2352 when data[15] != 2: - AaruConsole.DebugWriteLine("ISO9660 Plugin", - "Sector {0} ({1:X2}:{2:X2}:{3:X2}), Raw, Mode {4}", realSector, - data[12], data[13], data[14], data[15]); + AaruConsole.DebugWriteLine("ISO9660 Plugin", "Sector {0} ({1:X2}:{2:X2}:{3:X2}), Raw, Mode {4}", + realSector, data[12], data[13], data[14], data[15]); break; case 2352: @@ -112,7 +109,6 @@ public sealed partial class ISO9660 break; } - } if(_blockSize == 2048) { @@ -121,7 +117,7 @@ public sealed partial class ISO9660 return ErrorNumber.NoError; } - byte[] tmp = new byte[_blockSize]; + var tmp = new byte[_blockSize]; Array.Copy(Sector.GetUserData(data, interleaved, fileNumber), (int)offset, tmp, 0, _blockSize); buffer = tmp; @@ -145,12 +141,11 @@ public sealed partial class ISO9660 return errno; if(_debug) - { switch(data.Length) { case 2048: - AaruConsole.DebugWriteLine("ISO9660 Plugin", - "Sector {0}, Cooked, Mode 0/1 / Mode 2 Form 1", dstSector); + AaruConsole.DebugWriteLine("ISO9660 Plugin", "Sector {0}, Cooked, Mode 0/1 / Mode 2 Form 1", + dstSector); break; case 2324: @@ -174,8 +169,8 @@ public sealed partial class ISO9660 break; case 2352 when data[15] != 2: AaruConsole.DebugWriteLine("ISO9660 Plugin", - "Sector {0} ({1:X2}:{2:X2}:{3:X2}), Raw, Mode {4}", - dstSector, data[12], data[13], data[14], data[15]); + "Sector {0} ({1:X2}:{2:X2}:{3:X2}), Raw, Mode {4}", dstSector, + data[12], data[13], data[14], data[15]); break; case 2352: @@ -187,14 +182,13 @@ public sealed partial class ISO9660 break; } - } byte[] sectorData = Sector.GetUserData(data, interleaved, fileNumber); ms.Write(sectorData, 0, sectorData.Length); } - byte[] tmp = new byte[_blockSize]; + var tmp = new byte[_blockSize]; Array.Copy(Sector.GetUserData(ms.ToArray(), interleaved, fileNumber), 0, tmp, 0, _blockSize); buffer = tmp; diff --git a/Aaru.Filesystems/ISO9660/PathTable.cs b/Aaru.Filesystems/ISO9660/PathTable.cs index 1f864506d..3875dabec 100644 --- a/Aaru.Filesystems/ISO9660/PathTable.cs +++ b/Aaru.Filesystems/ISO9660/PathTable.cs @@ -31,21 +31,22 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Collections.Generic; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { PathTableEntryInternal[] DecodePathTable(byte[] data) { - if(data is null || data.Length == 0) + if(data is null || + data.Length == 0) return null; - List table = new List(); + var table = new List(); - int off = 0; + var off = 0; PathTableEntry entry = Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); @@ -58,8 +59,7 @@ public sealed partial class ISO9660 while(off < data.Length) { - entry = - Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); + entry = Marshal.ByteArrayToStructureBigEndian(data, off, Marshal.SizeOf()); if(entry.name_len == 0) break; @@ -90,15 +90,17 @@ public sealed partial class ISO9660 if(data is null) return null; - List table = new List(); + var table = new List(); - int off = 0; + var off = 0; while(off < data.Length) { HighSierraPathTableEntry entry = Marshal.ByteArrayToStructureBigEndian(data, off, - Marshal.SizeOf()); + Marshal. + SizeOf< + HighSierraPathTableEntry>()); if(entry.name_len == 0) break; diff --git a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs index dd79add7c..df9a91834 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/Apple.cs b/Aaru.Filesystems/ISO9660/Structs/Apple.cs index b41b345e0..ae478d938 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Apple.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Apple.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class ISO9660 { // Little-endian diff --git a/Aaru.Filesystems/ISO9660/Structs/CDi.cs b/Aaru.Filesystems/ISO9660/Structs/CDi.cs index 041286f1f..66f7251a8 100644 --- a/Aaru.Filesystems/ISO9660/Structs/CDi.cs +++ b/Aaru.Filesystems/ISO9660/Structs/CDi.cs @@ -31,12 +31,12 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { static DecodedVolumeDescriptor DecodeVolumeDescriptor(FileStructureVolumeDescriptor pvd) diff --git a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs index dcff144aa..92b947b9b 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs index 453d89d8d..4adb44aa7 100644 --- a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs @@ -31,13 +31,13 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { static DecodedVolumeDescriptor DecodeVolumeDescriptor(HighSierraPrimaryVolumeDescriptor pvd) diff --git a/Aaru.Filesystems/ISO9660/Structs/ISO.cs b/Aaru.Filesystems/ISO9660/Structs/ISO.cs index 391747672..f4f99cf0d 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ISO.cs @@ -31,15 +31,17 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; -using System.Text; -using Aaru.Helpers; + // ReSharper disable UnusedType.Local namespace Aaru.Filesystems; +using System; +using System.Runtime.InteropServices; +using System.Text; +using Aaru.Helpers; + public sealed partial class ISO9660 { static DecodedVolumeDescriptor DecodeVolumeDescriptor(PrimaryVolumeDescriptor pvd, Encoding encoding = null) diff --git a/Aaru.Filesystems/ISO9660/Structs/Internal.cs b/Aaru.Filesystems/ISO9660/Structs/Internal.cs index 2406f087a..0a1b910bb 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Internal.cs @@ -31,11 +31,11 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { struct DecodedVolumeDescriptor diff --git a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs index d86186bb6..7f74b1c92 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs @@ -31,30 +31,28 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { static DecodedVolumeDescriptor DecodeJolietDescriptor(PrimaryVolumeDescriptor jolietvd) { var decodedVd = new DecodedVolumeDescriptor { - 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(), + 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() + 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 || diff --git a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs index 3f8d82fa0..f3d7c033c 100644 --- a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs @@ -31,11 +31,11 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Filesystems; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class ISO9660 { diff --git a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs index 2474b810a..f661845fd 100644 --- a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs @@ -31,12 +31,14 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Runtime.InteropServices; + // ReSharper disable UnusedType.Local namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/XA.cs b/Aaru.Filesystems/ISO9660/Structs/XA.cs index 836484708..cac275d70 100644 --- a/Aaru.Filesystems/ISO9660/Structs/XA.cs +++ b/Aaru.Filesystems/ISO9660/Structs/XA.cs @@ -31,10 +31,10 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class ISO9660 { // Big-endian diff --git a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs index 116f38394..bfa8a0c75 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs @@ -31,11 +31,11 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Filesystems; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class ISO9660 { diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 0f5474efd..c92d9d3ed 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -31,6 +31,8 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; @@ -43,8 +45,6 @@ using Aaru.Decoders.Sega; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { /// @@ -52,8 +52,8 @@ public sealed partial class ISO9660 Dictionary options, string @namespace) { Encoding = encoding ?? Encoding.GetEncoding(1252); - byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" - byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" + var vdMagic = new byte[5]; // Volume Descriptor magic "CD001" + var hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" options ??= GetDefaultOptions(); @@ -121,7 +121,7 @@ public sealed partial class ISO9660 int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); _highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; - int hsOff = 0; + var hsOff = 0; if(_highSierra) hsOff = 8; @@ -163,8 +163,7 @@ public sealed partial class ISO9660 if(Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && - Encoding.GetString(vdMagic) != - CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. + Encoding.GetString(vdMagic) != CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { if(counter == 0) return ErrorNumber.InvalidArgument; @@ -187,8 +186,7 @@ public sealed partial class ISO9660 case 1: { if(_highSierra) - hsvd = Marshal. - ByteArrayToStructureLittleEndian(vdSector); + hsvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); else if(_cdi) fsvd = Marshal.ByteArrayToStructureBigEndian(vdSector); else @@ -367,7 +365,7 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return errno; - bool pvdWrongRoot = false; + var pvdWrongRoot = false; if(_highSierra) { @@ -391,7 +389,7 @@ public sealed partial class ISO9660 AaruConsole.DebugWriteLine("ISO9660 plugin", "PVD does not point to correct root directory, checking path table..."); - bool pathTableWrongRoot = false; + var pathTableWrongRoot = false; rootLocation = _pathTable[0].Extent; @@ -434,8 +432,7 @@ public sealed partial class ISO9660 if(errno != ErrorNumber.NoError) return errno; - CdiDirectoryRecord rootEntry = - Marshal.ByteArrayToStructureBigEndian(firstRootSector); + CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian(firstRootSector); rootSize = rootEntry.size; @@ -465,8 +462,7 @@ public sealed partial class ISO9660 } else { - DirectoryRecord rootEntry = - Marshal.ByteArrayToStructureLittleEndian(firstRootSector); + DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); rootSize = rootEntry.size; } @@ -551,8 +547,8 @@ public sealed partial class ISO9660 decodedVd.DataPreparerIdentifier.Length > decodedJolietVd.DataPreparerIdentifier.Length) XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; else - XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) - ? null : decodedJolietVd.DataPreparerIdentifier; + XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) ? null + : decodedJolietVd.DataPreparerIdentifier; if(string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) || decodedVd.ApplicationIdentifier.Length > decodedJolietVd.ApplicationIdentifier.Length) @@ -650,7 +646,7 @@ public sealed partial class ISO9660 Timestamp = decodedVd.CreationTime }); - for(int i = 0; i < bvdSectors.Count; i++) + for(var i = 0; i < bvdSectors.Count; i++) _rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> @@ -662,7 +658,7 @@ public sealed partial class ISO9660 Timestamp = decodedVd.CreationTime }); - for(int i = 0; i < pvdSectors.Count; i++) + for(var i = 0; i < pvdSectors.Count; i++) _rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> @@ -674,7 +670,7 @@ public sealed partial class ISO9660 Timestamp = decodedVd.CreationTime }); - for(int i = 0; i < svdSectors.Count; i++) + for(var i = 0; i < svdSectors.Count; i++) _rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> @@ -686,7 +682,7 @@ public sealed partial class ISO9660 Timestamp = decodedVd.CreationTime }); - for(int i = 0; i < evdSectors.Count; i++) + for(var i = 0; i < evdSectors.Count; i++) _rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> @@ -698,7 +694,7 @@ public sealed partial class ISO9660 Timestamp = decodedVd.CreationTime }); - for(int i = 0; i < vpdSectors.Count; i++) + for(var i = 0; i < vpdSectors.Count; i++) _rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index 046e4a96b..4647e8e3c 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -31,13 +31,13 @@ // In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24 // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class ISO9660 { /// diff --git a/Aaru.Filesystems/JFS.cs b/Aaru.Filesystems/JFS.cs index bb5162000..5a2af388d 100644 --- a/Aaru.Filesystems/JFS.cs +++ b/Aaru.Filesystems/JFS.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,10 +47,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -// ReSharper disable UnusedMember.Local - -namespace Aaru.Filesystems; - /// /// Implements detection of IBM's Journaled File System public sealed class JFS : IFilesystem @@ -85,8 +87,7 @@ public sealed class JFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -180,8 +181,7 @@ public sealed class JFS : IFilesystem sb.AppendLine("Volume is dirty"); sb.AppendFormat("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("Volume name: {0}", StringHandlers.CToString(jfsSb.s_fpack, Encoding)).AppendLine(); @@ -211,21 +211,39 @@ public sealed class JFS : IFilesystem [Flags, SuppressMessage("ReSharper", "InconsistentNaming")] enum Flags : uint { - Unicode = 0x00000001, RemountRO = 0x00000002, Continue = 0x00000004, - Panic = 0x00000008, UserQuota = 0x00000010, GroupQuota = 0x00000020, - NoJournal = 0x00000040, Discard = 0x00000080, GroupCommit = 0x00000100, - LazyCommit = 0x00000200, Temporary = 0x00000400, InlineLog = 0x00000800, - InlineMoving = 0x00001000, BadSAIT = 0x00010000, Sparse = 0x00020000, - DASDEnabled = 0x00040000, DASDPrime = 0x00080000, SwapBytes = 0x00100000, - DirIndex = 0x00200000, Linux = 0x10000000, DFS = 0x20000000, - OS2 = 0x40000000, AIX = 0x80000000 + Unicode = 0x00000001, + RemountRO = 0x00000002, + Continue = 0x00000004, + Panic = 0x00000008, + UserQuota = 0x00000010, + GroupQuota = 0x00000020, + NoJournal = 0x00000040, + Discard = 0x00000080, + GroupCommit = 0x00000100, + LazyCommit = 0x00000200, + Temporary = 0x00000400, + InlineLog = 0x00000800, + InlineMoving = 0x00001000, + BadSAIT = 0x00010000, + Sparse = 0x00020000, + DASDEnabled = 0x00040000, + DASDPrime = 0x00080000, + SwapBytes = 0x00100000, + DirIndex = 0x00200000, + Linux = 0x10000000, + DFS = 0x20000000, + OS2 = 0x40000000, + AIX = 0x80000000 } [Flags] enum State : uint { - Clean = 0, Mounted = 1, Dirty = 2, - Logredo = 4, Extendfs = 8 + Clean = 0, + Mounted = 1, + Dirty = 2, + Logredo = 4, + Extendfs = 8 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/LIF.cs b/Aaru.Filesystems/LIF.cs index 721cb4861..30c83f745 100644 --- a/Aaru.Filesystems/LIF.cs +++ b/Aaru.Filesystems/LIF.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem /// /// Implements detection of the LIF filesystem @@ -79,8 +79,7 @@ public sealed class LIF : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; diff --git a/Aaru.Filesystems/LisaFS/Consts.cs b/Aaru.Filesystems/LisaFS/Consts.cs index 2406994f5..4b95af50f 100644 --- a/Aaru.Filesystems/LisaFS/Consts.cs +++ b/Aaru.Filesystems/LisaFS/Consts.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems.LisaFS; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class LisaFS { diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs index ce01e9f80..653d65849 100644 --- a/Aaru.Filesystems/LisaFS/Dir.cs +++ b/Aaru.Filesystems/LisaFS/Dir.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Decoders; using Aaru.Helpers; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// @@ -113,7 +113,7 @@ public sealed partial class LisaFS if(error != ErrorNumber.NoError) return error; - int offset = 0; + var offset = 0; List catalogV2 = new(); // For each entry on the catalog @@ -258,7 +258,7 @@ public sealed partial class LisaFS // Foreach catalog block foreach(byte[] buf in catalogBlocks) { - int offset = 0; + var offset = 0; // Traverse all entries while(offset + 64 <= buf.Length) diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index 11f7a81e3..eaeb190ef 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Decoders; using Aaru.Helpers; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// @@ -62,7 +62,7 @@ public sealed partial class LisaFS return ErrorNumber.AccessDenied; if(fileId < 4 || - (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) + fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1) return ErrorNumber.InvalidArgument; if(_extentCache.TryGetValue(fileId, out file)) @@ -90,7 +90,7 @@ public sealed partial class LisaFS // This code just allow to ignore that corruption by searching the Extents File using sector tags if(ptr >= _device.Info.Sectors) { - bool found = false; + var found = false; for(ulong i = 0; i < _device.Info.Sectors; i++) { @@ -178,7 +178,7 @@ public sealed partial class LisaFS file.LisaInfo = new byte[128]; Array.Copy(sector, 0x180, file.LisaInfo, 0, 128); - int extentsCount = 0; + var extentsCount = 0; int extentsOffset; if(_mddf.fsversion == LISA_V1) @@ -194,9 +194,9 @@ public sealed partial class LisaFS extentsOffset = 0x88; } - for(int j = 0; j < 41; j++) + for(var j = 0; j < 41; j++) { - if(BigEndianBitConverter.ToInt16(sector, extentsOffset + (j * 6) + 4) == 0) + if(BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) == 0) break; extentsCount++; @@ -204,11 +204,11 @@ public sealed partial class LisaFS file.extents = new Extent[extentsCount]; - for(int j = 0; j < extentsCount; j++) + for(var j = 0; j < extentsCount; j++) file.extents[j] = new Extent { - start = BigEndianBitConverter.ToInt32(sector, extentsOffset + (j * 6)), - length = BigEndianBitConverter.ToInt16(sector, extentsOffset + (j * 6) + 4) + start = BigEndianBitConverter.ToInt32(sector, extentsOffset + j * 6), + length = BigEndianBitConverter.ToInt16(sector, extentsOffset + j * 6 + 4) }; _extentCache.Add(fileId, file); @@ -253,8 +253,7 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].release = {1}", fileId, file.release); AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].build = {1}", fileId, file.build); - AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].compatibility = {1}", fileId, - file.compatibility); + AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].compatibility = {1}", fileId, file.compatibility); AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].revision = {1}", fileId, file.revision); AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown6 = 0x{1:X4}", fileId, file.unknown6); @@ -281,7 +280,7 @@ public sealed partial class LisaFS AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].length = {1}", fileId, file.length); AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown9 = 0x{1:X8}", fileId, file.unknown9); - for(int ext = 0; ext < file.extents.Length; ext++) + for(var ext = 0; ext < file.extents.Length; ext++) { AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].extents[{1}].start = {2}", fileId, ext, file.extents[ext].start); @@ -313,13 +312,13 @@ public sealed partial class LisaFS // Each entry takes 14 bytes _srecords = new SRecord[sectors.Length / 14]; - for(int s = 0; s < _srecords.Length; s++) + for(var s = 0; s < _srecords.Length; s++) _srecords[s] = new SRecord { - extent_ptr = BigEndianBitConverter.ToUInt32(sectors, 0x00 + (14 * s)), - unknown = BigEndianBitConverter.ToUInt32(sectors, 0x04 + (14 * s)), - filesize = BigEndianBitConverter.ToUInt32(sectors, 0x08 + (14 * s)), - flags = BigEndianBitConverter.ToUInt16(sectors, 0x0C + (14 * s)) + extent_ptr = BigEndianBitConverter.ToUInt32(sectors, 0x00 + 14 * s), + unknown = BigEndianBitConverter.ToUInt32(sectors, 0x04 + 14 * s), + filesize = BigEndianBitConverter.ToUInt32(sectors, 0x08 + 14 * s), + flags = BigEndianBitConverter.ToUInt16(sectors, 0x0C + 14 * s) }; return ErrorNumber.NoError; diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index 9657e1403..12296019e 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; @@ -37,8 +39,6 @@ using Aaru.Console; using Aaru.Decoders; using Aaru.Helpers; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// @@ -208,13 +208,12 @@ public sealed partial class LisaFS !tags) return ErrorNumber.NoError; - int count = 0; + var count = 0; if(fileId == FILEID_SRECORD) if(!tags) { - errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, - out buf); + errno = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, out buf); if(errno != ErrorNumber.NoError) return errno; @@ -397,7 +396,7 @@ public sealed partial class LisaFS tags &= _debug; if(fileId < 4 || - (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) + fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1) return ErrorNumber.InvalidArgument; if(!tags && @@ -416,11 +415,11 @@ public sealed partial class LisaFS else sectorSize = (int)_device.Info.SectorSize; - byte[] temp = new byte[file.length * sectorSize]; + var temp = new byte[file.length * sectorSize]; - int offset = 0; + var offset = 0; - for(int i = 0; i < file.extents.Length; i++) + for(var i = 0; i < file.extents.Length; i++) { byte[] sector; @@ -525,7 +524,7 @@ public sealed partial class LisaFS } } - for(int lvl = 0; lvl < pathElements.Length; lvl++) + for(var lvl = 0; lvl < pathElements.Length; lvl++) { string wantedFilename = pathElements[0].Replace('-', '/'); diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs index b91def688..50955a8eb 100644 --- a/Aaru.Filesystems/LisaFS/Info.cs +++ b/Aaru.Filesystems/LisaFS/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using System.Text; using Aaru.CommonTypes; @@ -42,8 +44,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// @@ -61,7 +61,7 @@ public sealed partial class LisaFS int beforeMddf = -1; // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors - for(int i = 0; i < 100; i++) + for(var i = 0; i < 100; i++) { errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); @@ -132,8 +132,7 @@ public sealed partial class LisaFS } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = new LisaRoman(); information = ""; @@ -150,7 +149,7 @@ public sealed partial class LisaFS int beforeMddf = -1; // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors - for(int i = 0; i < 100; i++) + for(var i = 0; i < 100; i++) { errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); @@ -173,8 +172,8 @@ public sealed partial class LisaFS if(errno != ErrorNumber.NoError) continue; - var infoMddf = new MDDF(); - byte[] pString = new byte[33]; + var infoMddf = new MDDF(); + var pString = new byte[33]; infoMddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); infoMddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); @@ -189,7 +188,7 @@ public sealed partial class LisaFS infoMddf.unknown2 = sector[0x4F]; infoMddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); infoMddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); - uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); + var lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); infoMddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); infoMddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); diff --git a/Aaru.Filesystems/LisaFS/LisaFS.cs b/Aaru.Filesystems/LisaFS/LisaFS.cs index b72d22b83..5e3995382 100644 --- a/Aaru.Filesystems/LisaFS/LisaFS.cs +++ b/Aaru.Filesystems/LisaFS/LisaFS.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems.LisaFS; - // All information by Natalia Portillo // Variable names from Lisa API /// diff --git a/Aaru.Filesystems/LisaFS/Structs.cs b/Aaru.Filesystems/LisaFS/Structs.cs index a167d4ddc..e883f3079 100644 --- a/Aaru.Filesystems/LisaFS/Structs.cs +++ b/Aaru.Filesystems/LisaFS/Structs.cs @@ -30,13 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.Diagnostics.CodeAnalysis; + // ReSharper disable NotAccessedField.Local namespace Aaru.Filesystems.LisaFS; +using System; +using System.Diagnostics.CodeAnalysis; + public sealed partial class LisaFS { /// diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index 6c36f2a6c..6cb13263b 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -43,8 +45,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// @@ -103,7 +103,7 @@ public sealed partial class LisaFS return errno; _mddf = new MDDF(); - byte[] pString = new byte[33]; + var pString = new byte[33]; _mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); _mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); @@ -118,7 +118,7 @@ public sealed partial class LisaFS _mddf.unknown2 = sector[0x4F]; _mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); _mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); - uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); + var lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); _mddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); _mddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); diff --git a/Aaru.Filesystems/LisaFS/Xattr.cs b/Aaru.Filesystems/LisaFS/Xattr.cs index fd46350e6..7cd729e43 100644 --- a/Aaru.Filesystems/LisaFS/Xattr.cs +++ b/Aaru.Filesystems/LisaFS/Xattr.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.LisaFS; + using System; using System.Collections.Generic; using System.Text; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.Decoders; using Aaru.Helpers; -namespace Aaru.Filesystems.LisaFS; - public sealed partial class LisaFS { /// diff --git a/Aaru.Filesystems/Locus.cs b/Aaru.Filesystems/Locus.cs index 4dacdef44..7aad335b9 100644 --- a/Aaru.Filesystems/Locus.cs +++ b/Aaru.Filesystems/Locus.cs @@ -30,17 +30,6 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.Console; -using Aaru.Helpers; -using Schemas; - // Commit count using commitcnt_t = System.Int32; @@ -55,7 +44,6 @@ using gfs_t = System.Int32; // Inode number using ino_t = System.Int32; -using Marshal = Aaru.Helpers.Marshal; // Filesystem pack number using pckno_t = System.Int16; @@ -68,6 +56,18 @@ using time_t = System.Int32; namespace Aaru.Filesystems; +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.Console; +using Aaru.Helpers; +using Schemas; +using Marshal = Aaru.Helpers.Marshal; + /// /// Implements detection of the Locus filesystem public sealed class Locus : IFilesystem @@ -101,7 +101,7 @@ public sealed class Locus : IFilesystem for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -132,8 +132,7 @@ public sealed class Locus : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -146,7 +145,7 @@ public sealed class Locus : IFilesystem for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -217,8 +216,7 @@ public sealed class Locus : IFilesystem AaruConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fmod = {0}", locusSb.s_fmod); AaruConsole.DebugWriteLine("Locus plugin", "LocusSb.s_version = {0}", locusSb.s_version); - sb.AppendFormat("Superblock last modified on {0}", DateHandlers.UnixToDateTime(locusSb.s_time)). - AppendLine(); + sb.AppendFormat("Superblock last modified on {0}", DateHandlers.UnixToDateTime(locusSb.s_time)).AppendLine(); sb.AppendFormat("Volume has {0} blocks of {1} bytes each (total {2} bytes)", locusSb.s_fsize, blockSize, locusSb.s_fsize * blockSize).AppendLine(); @@ -404,22 +402,26 @@ public sealed class Locus : IFilesystem Flags] enum Flags : ushort { - SB_RDONLY = 0x1, /* no writes on filesystem */ SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */ - SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ SB_RMV = 0x8, /* fs is a removable file system */ - SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */ - SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */ - SB_USER = 0x40, /* This is a "user" replicated filesystem. */ - SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */ + SB_RDONLY = 0x1, /* no writes on filesystem */ + SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */ + SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ + SB_RMV = 0x8, /* fs is a removable file system */ + SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */ + SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */ + SB_USER = 0x40, /* This is a "user" replicated filesystem. */ + SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */ SB_NFS = 0x100, /* This is a NFS type filesystem */ SB_BYHAND = 0x200, /* Inhibits automatic fscks on a mangled file system */ - SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */ SB_SYNCW = 0x800 /* Synchronous Write */ + SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */ + SB_SYNCW = 0x800 /* Synchronous Write */ } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), Flags] enum Version : byte { - SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ SB_B1024 = 2, /* 1024 byte block filesystem */ - NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */ + SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ + SB_B1024 = 2, /* 1024 byte block filesystem */ + NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */ } } \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS.cs b/Aaru.Filesystems/MicroDOS.cs index 5f8788c7f..c078d3bcb 100644 --- a/Aaru.Filesystems/MicroDOS.cs +++ b/Aaru.Filesystems/MicroDOS.cs @@ -30,6 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedType.Local +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -39,11 +46,6 @@ using Aaru.CommonTypes.Interfaces; using Schemas; using Marshal = Aaru.Helpers.Marshal; -// ReSharper disable UnusedType.Local -// ReSharper disable UnusedMember.Local - -namespace Aaru.Filesystems; - /// /// /// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks @@ -85,8 +87,7 @@ public sealed class MicroDOS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("koi8-r"); information = ""; @@ -178,7 +179,10 @@ public sealed class MicroDOS : IFilesystem enum FileStatus : byte { - CommonFile = 0, Protected = 1, LogicalDisk = 2, - BadFile = 0x80, Deleted = 0xFF + CommonFile = 0, + Protected = 1, + LogicalDisk = 2, + BadFile = 0x80, + Deleted = 0xFF } } \ No newline at end of file diff --git a/Aaru.Filesystems/MinixFS.cs b/Aaru.Filesystems/MinixFS.cs index e2aed578f..1adb4ea19 100644 --- a/Aaru.Filesystems/MinixFS.cs +++ b/Aaru.Filesystems/MinixFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection of the MINIX filesystem @@ -103,12 +103,12 @@ public sealed class MinixFS : IFilesystem // Optical media if(offset > 0) { - byte[] tmp = new byte[0x200]; + var tmp = new byte[0x200]; Array.Copy(minixSbSector, offset, tmp, 0, 0x200); minixSbSector = tmp; } - ushort magic = BitConverter.ToUInt16(minixSbSector, 0x010); + var magic = BitConverter.ToUInt16(minixSbSector, 0x010); if(magic == MINIX_MAGIC || magic == MINIX_MAGIC2 || @@ -127,8 +127,7 @@ public sealed class MinixFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -144,7 +143,7 @@ public sealed class MinixFS : IFilesystem offset = 0x400; } - bool minix3 = false; + var minix3 = false; int filenamesize; string minixVersion; ErrorNumber errno = imagePlugin.ReadSector(sector + partition.Start, out byte[] minixSbSector); @@ -155,12 +154,12 @@ public sealed class MinixFS : IFilesystem // Optical media if(offset > 0) { - byte[] tmp = new byte[0x200]; + var tmp = new byte[0x200]; Array.Copy(minixSbSector, offset, tmp, 0, 0x200); minixSbSector = tmp; } - ushort magic = BitConverter.ToUInt16(minixSbSector, 0x018); + var magic = BitConverter.ToUInt16(minixSbSector, 0x018); XmlFsType = new FileSystemType(); @@ -278,11 +277,9 @@ public sealed class MinixFS : IFilesystem sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine(); if(mnxSb.s_zones > 0) // On V2 - sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024). - AppendLine(); + sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024).AppendLine(); else - sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024). - AppendLine(); + sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024).AppendLine(); sb.AppendFormat("{0} bytes/block", mnxSb.s_blocksize).AppendLine(); sb.AppendFormat("{0} inodes on volume", mnxSb.s_ninodes).AppendLine(); @@ -311,11 +308,9 @@ public sealed class MinixFS : IFilesystem sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine(); if(mnxSb.s_zones > 0) // On V2 - sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024). - AppendLine(); + sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024).AppendLine(); else - sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024). - AppendLine(); + sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024).AppendLine(); sb.AppendFormat("{0} inodes on volume", mnxSb.s_ninodes).AppendLine(); diff --git a/Aaru.Filesystems/NILFS2.cs b/Aaru.Filesystems/NILFS2.cs index 7bfeeacce..87d90b6e5 100644 --- a/Aaru.Filesystems/NILFS2.cs +++ b/Aaru.Filesystems/NILFS2.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,10 +46,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -// ReSharper disable UnusedMember.Local - -namespace Aaru.Filesystems; - /// /// Implements detection of the New Implementation of a Log-structured File System v2 public sealed class NILFS2 : IFilesystem @@ -73,7 +75,7 @@ public sealed class NILFS2 : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -95,8 +97,7 @@ public sealed class NILFS2 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.UTF8; information = ""; @@ -109,7 +110,7 @@ public sealed class NILFS2 : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -146,11 +147,9 @@ public sealed class NILFS2 : IFilesystem sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(nilfsSb.volume_name, Encoding)).AppendLine(); sb.AppendFormat("Volume created on {0}", DateHandlers.UnixUnsignedToDateTime(nilfsSb.ctime)).AppendLine(); - sb.AppendFormat("Volume last mounted on {0}", DateHandlers.UnixUnsignedToDateTime(nilfsSb.mtime)). - AppendLine(); + sb.AppendFormat("Volume last mounted on {0}", DateHandlers.UnixUnsignedToDateTime(nilfsSb.mtime)).AppendLine(); - sb.AppendFormat("Volume last written on {0}", DateHandlers.UnixUnsignedToDateTime(nilfsSb.wtime)). - AppendLine(); + sb.AppendFormat("Volume last written on {0}", DateHandlers.UnixUnsignedToDateTime(nilfsSb.wtime)).AppendLine(); information = sb.ToString(); @@ -174,7 +173,9 @@ public sealed class NILFS2 : IFilesystem enum State : ushort { - Valid = 0x0001, Error = 0x0002, Resize = 0x0004 + Valid = 0x0001, + Error = 0x0002, + Resize = 0x0004 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/NTFS.cs b/Aaru.Filesystems/NTFS.cs index 06e5947c6..15657d71e 100644 --- a/Aaru.Filesystems/NTFS.cs +++ b/Aaru.Filesystems/NTFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from Inside Windows NT /// /// Implements detection of the New Technology File System (NTFS) @@ -65,7 +65,7 @@ public sealed class NTFS : IFilesystem if(2 + partition.Start >= partition.End) return false; - byte[] eigthBytes = new byte[8]; + var eigthBytes = new byte[8]; ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] ntfsBpb); @@ -78,9 +78,9 @@ public sealed class NTFS : IFilesystem if(oemName != "NTFS ") return false; - byte fatsNo = ntfsBpb[0x010]; - ushort spFat = BitConverter.ToUInt16(ntfsBpb, 0x016); - ushort signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE); + byte fatsNo = ntfsBpb[0x010]; + var spFat = BitConverter.ToUInt16(ntfsBpb, 0x016); + var signature = BitConverter.ToUInt16(ntfsBpb, 0x1FE); if(fatsNo != 0) return false; @@ -92,8 +92,7 @@ public sealed class NTFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.Unicode; information = ""; @@ -126,8 +125,7 @@ public sealed class NTFS : IFilesystem // 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("{0} sectors on volume ({1} bytes)", ntfsBb.sectors, ntfsBb.sectors * ntfsBb.bps). - AppendLine(); + sb.AppendFormat("{0} sectors on volume ({1} bytes)", ntfsBb.sectors, ntfsBb.sectors * ntfsBb.bps).AppendLine(); sb.AppendFormat("Cluster where $MFT starts: {0}", ntfsBb.mft_lsn).AppendLine(); sb.AppendFormat("Cluster where $MFTMirr starts: {0}", ntfsBb.mftmirror_lsn).AppendLine(); diff --git a/Aaru.Filesystems/Nintendo.cs b/Aaru.Filesystems/Nintendo.cs index a4bce5f0f..3101f3134 100644 --- a/Aaru.Filesystems/Nintendo.cs +++ b/Aaru.Filesystems/Nintendo.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes; @@ -39,8 +41,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs public sealed class NintendoPlugin : IFilesystem @@ -70,15 +70,14 @@ public sealed class NintendoPlugin : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C); - uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); + var magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C); + var magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); return magicGc == 0xC2339F3D || magicWii == 0x5D1C9EA3; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("shift_jis"); var sbInformation = new StringBuilder(); @@ -92,10 +91,10 @@ public sealed class NintendoPlugin : IFilesystem if(errno != ErrorNumber.NoError) return; - bool wii = false; + var wii = false; - uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C); - uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); + var magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C); + var magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); if(magicWii == 0x5D1C9EA3) wii = true; @@ -111,7 +110,7 @@ public sealed class NintendoPlugin : IFilesystem fields.DiscVersion = header[7]; fields.Streaming |= header[8] > 0; fields.StreamBufferSize = header[9]; - byte[] temp = new byte[64]; + var temp = new byte[64]; Array.Copy(header, 0x20, temp, 0, 64); fields.Title = StringHandlers.CToString(temp, Encoding); @@ -137,44 +136,40 @@ public sealed class NintendoPlugin : IFilesystem fields.ThirdPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40010)]; fields.FourthPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40018)]; - for(int i = 0; i < fields.FirstPartitions.Length; i++) - if(offset1 + (i * 8) + 8 < 0x50000) + for(var i = 0; i < fields.FirstPartitions.Length; i++) + if(offset1 + i * 8 + 8 < 0x50000) { fields.FirstPartitions[i].Offset = - BigEndianBitConverter.ToUInt32(header, (int)(offset1 + (i * 8) + 0)) << 2; + BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 0)) << 2; - fields.FirstPartitions[i].Type = - BigEndianBitConverter.ToUInt32(header, (int)(offset1 + (i * 8) + 4)); + fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 4)); } - for(int i = 0; i < fields.SecondPartitions.Length; i++) - if(offset1 + (i * 8) + 8 < 0x50000) + for(var i = 0; i < fields.SecondPartitions.Length; i++) + if(offset1 + i * 8 + 8 < 0x50000) { fields.FirstPartitions[i].Offset = - BigEndianBitConverter.ToUInt32(header, (int)(offset2 + (i * 8) + 0)) << 2; + BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 0)) << 2; - fields.FirstPartitions[i].Type = - BigEndianBitConverter.ToUInt32(header, (int)(offset2 + (i * 8) + 4)); + fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 4)); } - for(int i = 0; i < fields.ThirdPartitions.Length; i++) - if(offset1 + (i * 8) + 8 < 0x50000) + for(var i = 0; i < fields.ThirdPartitions.Length; i++) + if(offset1 + i * 8 + 8 < 0x50000) { fields.FirstPartitions[i].Offset = - BigEndianBitConverter.ToUInt32(header, (int)(offset3 + (i * 8) + 0)) << 2; + BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 0)) << 2; - fields.FirstPartitions[i].Type = - BigEndianBitConverter.ToUInt32(header, (int)(offset3 + (i * 8) + 4)); + fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 4)); } - for(int i = 0; i < fields.FourthPartitions.Length; i++) - if(offset1 + (i * 8) + 8 < 0x50000) + for(var i = 0; i < fields.FourthPartitions.Length; i++) + if(offset1 + i * 8 + 8 < 0x50000) { fields.FirstPartitions[i].Offset = - BigEndianBitConverter.ToUInt32(header, (int)(offset4 + (i * 8) + 0)) << 2; + BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 0)) << 2; - fields.FirstPartitions[i].Type = - BigEndianBitConverter.ToUInt32(header, (int)(offset4 + (i * 8) + 4)); + fields.FirstPartitions[i].Type = BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 4)); } fields.Region = header[0x4E000]; @@ -213,7 +208,7 @@ public sealed class NintendoPlugin : IFilesystem AaruConsole.DebugWriteLine("Nintendo plugin", "fstSize = {0}", fields.FstSize); AaruConsole.DebugWriteLine("Nintendo plugin", "fstMax = {0}", fields.FstMax); - for(int i = 0; i < fields.FirstPartitions.Length; i++) + for(var i = 0; i < fields.FirstPartitions.Length; i++) { AaruConsole.DebugWriteLine("Nintendo plugin", "firstPartitions[{1}].offset = {0}", fields.FirstPartitions[i].Offset, i); @@ -222,7 +217,7 @@ public sealed class NintendoPlugin : IFilesystem fields.FirstPartitions[i].Type, i); } - for(int i = 0; i < fields.SecondPartitions.Length; i++) + for(var i = 0; i < fields.SecondPartitions.Length; i++) { AaruConsole.DebugWriteLine("Nintendo plugin", "secondPartitions[{1}].offset = {0}", fields.SecondPartitions[i].Offset, i); @@ -231,7 +226,7 @@ public sealed class NintendoPlugin : IFilesystem fields.SecondPartitions[i].Type, i); } - for(int i = 0; i < fields.ThirdPartitions.Length; i++) + for(var i = 0; i < fields.ThirdPartitions.Length; i++) { AaruConsole.DebugWriteLine("Nintendo plugin", "thirdPartitions[{1}].offset = {0}", fields.ThirdPartitions[i].Offset, i); @@ -240,7 +235,7 @@ public sealed class NintendoPlugin : IFilesystem fields.ThirdPartitions[i].Type, i); } - for(int i = 0; i < fields.FourthPartitions.Length; i++) + for(var i = 0; i < fields.FourthPartitions.Length; i++) { AaruConsole.DebugWriteLine("Nintendo plugin", "fourthPartitions[{1}].offset = {0}", fields.FourthPartitions[i].Offset, i); @@ -281,22 +276,22 @@ public sealed class NintendoPlugin : IFilesystem if(wii) { - for(int i = 0; i < fields.FirstPartitions.Length; i++) + for(var i = 0; i < fields.FirstPartitions.Length; i++) sbInformation.AppendFormat("First {0} partition starts at sector {1}", PartitionTypeToString(fields.FirstPartitions[i].Type), fields.FirstPartitions[i].Offset / 2048).AppendLine(); - for(int i = 0; i < fields.SecondPartitions.Length; i++) + for(var i = 0; i < fields.SecondPartitions.Length; i++) sbInformation.AppendFormat("Second {0} partition starts at sector {1}", PartitionTypeToString(fields.SecondPartitions[i].Type), fields.SecondPartitions[i].Offset / 2048).AppendLine(); - for(int i = 0; i < fields.ThirdPartitions.Length; i++) + for(var i = 0; i < fields.ThirdPartitions.Length; i++) sbInformation.AppendFormat("Third {0} partition starts at sector {1}", PartitionTypeToString(fields.ThirdPartitions[i].Type), fields.ThirdPartitions[i].Offset / 2048).AppendLine(); - for(int i = 0; i < fields.FourthPartitions.Length; i++) + for(var i = 0; i < fields.FourthPartitions.Length; i++) sbInformation.AppendFormat("Fourth {0} partition starts at sector {1}", PartitionTypeToString(fields.FourthPartitions[i].Type), fields.FourthPartitions[i].Offset / 2048).AppendLine(); diff --git a/Aaru.Filesystems/ODS.cs b/Aaru.Filesystems/ODS.cs index b6fa58310..d0fc13d2e 100644 --- a/Aaru.Filesystems/ODS.cs +++ b/Aaru.Filesystems/ODS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from VMS File System Internals by Kirby McCoy // ISBN: 1-55558-056-4 // With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h @@ -76,7 +76,7 @@ public sealed class ODS : IFilesystem if(imagePlugin.Info.SectorSize < 512) return false; - byte[] magicB = new byte[12]; + var magicB = new byte[12]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); if(errno != ErrorNumber.NoError) @@ -112,8 +112,7 @@ public sealed class ODS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); information = ""; @@ -171,14 +170,13 @@ public sealed class ODS : IFilesystem sb.AppendFormat("Highest structure in the volume is Level {0}, revision {1}", (homeblock.highstruclev & 0xFF00) >> 8, homeblock.highstruclev & 0xFF).AppendLine(); - sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512). - AppendLine(); + sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512).AppendLine(); sb.AppendFormat("This home block is on sector {0} (VBN {1})", homeblock.homelbn, homeblock.homevbn). AppendLine(); - sb.AppendFormat("Secondary home block is on sector {0} (VBN {1})", homeblock.alhomelbn, - homeblock.alhomevbn).AppendLine(); + sb.AppendFormat("Secondary home block is on sector {0} (VBN {1})", homeblock.alhomelbn, homeblock.alhomevbn). + AppendLine(); sb.AppendFormat("Volume bitmap starts in sector {0} (VBN {1})", homeblock.ibmaplbn, homeblock.ibmapvbn). AppendLine(); diff --git a/Aaru.Filesystems/Opera/Consts.cs b/Aaru.Filesystems/Opera/Consts.cs index 5f56476cb..4a849598b 100644 --- a/Aaru.Filesystems/Opera/Consts.cs +++ b/Aaru.Filesystems/Opera/Consts.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Diagnostics.CodeAnalysis; using Aaru.Helpers; -namespace Aaru.Filesystems; - [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class OperaFS { @@ -52,7 +52,10 @@ public sealed partial class OperaFS enum FileFlags : uint { - File = 2, Special = 6, Directory = 7, - LastEntryInBlock = 0x40000000, LastEntry = 0x80000000 + File = 2, + Special = 6, + Directory = 7, + LastEntryInBlock = 0x40000000, + LastEntry = 0x80000000 } } \ No newline at end of file diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index 779effb9a..4582f8860 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -37,8 +39,6 @@ using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems; - public sealed partial class OperaFS { /// @@ -61,8 +61,7 @@ public sealed partial class OperaFS ? path.Substring(1).ToLower(CultureInfo.CurrentUICulture) : path.ToLower(CultureInfo.CurrentUICulture); - if(_directoryCache.TryGetValue(cutPath, - out Dictionary currentDirectory)) + if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) { contents = currentDirectory.Keys.ToList(); @@ -87,7 +86,7 @@ public sealed partial class OperaFS currentDirectory = _rootDirectoryCache; - for(int p = 0; p < pieces.Length; p++) + for(var p = 0; p < pieces.Length; p++) { entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[p]); @@ -125,8 +124,8 @@ public sealed partial class OperaFS do { - ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), - _volumeBlockSizeRatio, out byte[] data); + ErrorNumber errno = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), _volumeBlockSizeRatio, + out byte[] data); if(errno != ErrorNumber.NoError) break; @@ -134,7 +133,7 @@ public sealed partial class OperaFS header = Marshal.ByteArrayToStructureBigEndian(data); nextBlock = header.next_block + firstBlock; - int off = (int)header.first_used; + var off = (int)header.first_used; var entry = new DirectoryEntry(); @@ -149,9 +148,9 @@ public sealed partial class OperaFS Pointers = new uint[entry.last_copy + 1] }; - for(int i = 0; i <= entry.last_copy; i++) + for(var i = 0; i <= entry.last_copy; i++) entryWithPointers.Pointers[i] = - BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + (i * 4)); + BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + i * 4); entries.Add(name, entryWithPointers); @@ -159,7 +158,7 @@ public sealed partial class OperaFS (entry.flags & (uint)FileFlags.LastEntryInBlock) != 0) break; - off += (int)(_directoryEntrySize + ((entry.last_copy + 1) * 4)); + off += (int)(_directoryEntrySize + (entry.last_copy + 1) * 4); } if((entry.flags & (uint)FileFlags.LastEntry) != 0) diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index 2a5d25561..607ce5299 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Globalization; @@ -37,8 +39,6 @@ using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; -namespace Aaru.Filesystems; - public sealed partial class OperaFS { /// @@ -130,7 +130,7 @@ public sealed partial class OperaFS else fileBlockSizeRatio = entry.Entry.block_size / _image.Info.SectorSize; - ErrorNumber errno = _image.ReadSectors((ulong)(entry.Pointers[0] + (firstBlock * fileBlockSizeRatio)), + ErrorNumber errno = _image.ReadSectors((ulong)(entry.Pointers[0] + firstBlock * fileBlockSizeRatio), (uint)(sizeInBlocks * fileBlockSizeRatio), out byte[] buffer); if(errno != ErrorNumber.NoError) @@ -194,7 +194,7 @@ public sealed partial class OperaFS if(pieces.Length == 0) return ErrorNumber.InvalidArgument; - string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); + var parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index ac62715a0..7c5345fcc 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class OperaFS { /// @@ -53,7 +53,7 @@ public sealed partial class OperaFS if(errno != ErrorNumber.NoError) return false; - byte[] syncBytes = new byte[5]; + var syncBytes = new byte[5]; byte recordType = sbSector[0x000]; Array.Copy(sbSector, 0x001, syncBytes, 0, 5); @@ -67,8 +67,7 @@ public sealed partial class OperaFS } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { // TODO: Find correct default encoding Encoding = Encoding.ASCII; @@ -92,13 +91,12 @@ public sealed partial class OperaFS superBlockMetadata.AppendFormat("Opera filesystem disc.").AppendLine(); if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_label, Encoding))) - superBlockMetadata. - AppendFormat("Volume label: {0}", StringHandlers.CToString(sb.volume_label, Encoding)).AppendLine(); + superBlockMetadata.AppendFormat("Volume label: {0}", StringHandlers.CToString(sb.volume_label, Encoding)). + AppendLine(); if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_comment, Encoding))) superBlockMetadata. - AppendFormat("Volume comment: {0}", StringHandlers.CToString(sb.volume_comment, Encoding)). - AppendLine(); + AppendFormat("Volume comment: {0}", StringHandlers.CToString(sb.volume_comment, Encoding)).AppendLine(); superBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine(); superBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine(); diff --git a/Aaru.Filesystems/Opera/Opera.cs b/Aaru.Filesystems/Opera/Opera.cs index ae5b4b8af..be0d23582 100644 --- a/Aaru.Filesystems/Opera/Opera.cs +++ b/Aaru.Filesystems/Opera/Opera.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Text; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements the 3DO Opera filesystem public sealed partial class OperaFS : IReadOnlyFilesystem diff --git a/Aaru.Filesystems/Opera/Structs.cs b/Aaru.Filesystems/Opera/Structs.cs index 122277aed..a77fa6f2a 100644 --- a/Aaru.Filesystems/Opera/Structs.cs +++ b/Aaru.Filesystems/Opera/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Filesystems; +using System.Runtime.InteropServices; + public sealed partial class OperaFS { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 76e60b125..8ab91380d 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System.Collections.Generic; using System.Text; using Aaru.CommonTypes; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - public sealed partial class OperaFS { /// @@ -101,7 +101,7 @@ public sealed partial class OperaFS }; _image = imagePlugin; - int firstRootBlock = BigEndianBitConverter.ToInt32(sbSector, Marshal.SizeOf()); + var firstRootBlock = BigEndianBitConverter.ToInt32(sbSector, Marshal.SizeOf()); _rootDirectoryCache = DecodeDirectory(firstRootBlock); _directoryCache = new Dictionary>(); _mounted = true; diff --git a/Aaru.Filesystems/PCEngine.cs b/Aaru.Filesystems/PCEngine.cs index 3c83f7c30..5be8de704 100644 --- a/Aaru.Filesystems/PCEngine.cs +++ b/Aaru.Filesystems/PCEngine.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Text; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - /// /// Implements detection of the PC-Engine CD file headers public sealed class PCEnginePlugin : IFilesystem @@ -60,7 +60,7 @@ public sealed class PCEnginePlugin : IFilesystem if(2 + partition.Start >= partition.End) return false; - byte[] systemDescriptor = new byte[23]; + var systemDescriptor = new byte[23]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] sector); if(errno != ErrorNumber.NoError) @@ -72,8 +72,7 @@ public sealed class PCEnginePlugin : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("shift_jis"); information = ""; diff --git a/Aaru.Filesystems/PCFX.cs b/Aaru.Filesystems/PCFX.cs index 963cf8f38..0e3873d70 100644 --- a/Aaru.Filesystems/PCFX.cs +++ b/Aaru.Filesystems/PCFX.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Not a filesystem, more like an executable header /// /// Implements detection of NEC PC-FX headers @@ -77,8 +77,7 @@ public sealed class PCFX : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { // Always Shift-JIS Encoding = Encoding.GetEncoding("shift_jis"); @@ -97,9 +96,9 @@ public sealed class PCFX : IFilesystem try { date = Encoding.GetString(header.date); - int year = int.Parse(date.Substring(0, 4)); - int month = int.Parse(date.Substring(4, 2)); - int day = int.Parse(date.Substring(6, 2)); + var year = int.Parse(date.Substring(0, 4)); + var month = int.Parse(date.Substring(4, 2)); + var day = int.Parse(date.Substring(6, 2)); dateTime = new DateTime(year, month, day); } catch @@ -123,8 +122,7 @@ public sealed class PCFX : IFilesystem sb.AppendFormat("Load {0} sectors from sector {1}", header.loadCount, header.loadOffset).AppendLine(); - sb.AppendFormat("Load at 0x{0:X8} and jump to 0x{1:X8}", header.loadAddress, header.entryPoint). - AppendLine(); + sb.AppendFormat("Load at 0x{0:X8} and jump to 0x{1:X8}", header.loadAddress, header.entryPoint).AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/PFS.cs b/Aaru.Filesystems/PFS.cs index b47b2ae43..a5ad49001 100644 --- a/Aaru.Filesystems/PFS.cs +++ b/Aaru.Filesystems/PFS.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,10 +46,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -// ReSharper disable UnusedType.Local - -namespace Aaru.Filesystems; - /// /// Implements detection of the Professional File System public sealed class PFS : IFilesystem @@ -81,15 +83,14 @@ public sealed class PFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BigEndianBitConverter.ToUInt32(sector, 0x00); + var magic = BigEndianBitConverter.ToUInt32(sector, 0x00); return magic == AFS_DISK || magic == PFS2_DISK || magic == PFS_DISK || magic == MUAF_DISK || magic == MUPFS_DISK; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { information = ""; Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); @@ -141,8 +142,7 @@ public sealed class PFS : IFilesystem rootBlock.creationtick)).AppendLine(); if(rootBlock.extension > 0) - sbInformation.AppendFormat("Root block extension resides at block {0}", rootBlock.extension). - AppendLine(); + sbInformation.AppendFormat("Root block extension resides at block {0}", rootBlock.extension).AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/ProDOS.cs b/Aaru.Filesystems/ProDOS.cs index 3ab9d4e49..542ee4f53 100644 --- a/Aaru.Filesystems/ProDOS.cs +++ b/Aaru.Filesystems/ProDOS.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable NotAccessedField.Local + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -42,10 +48,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -// ReSharper disable NotAccessedField.Local - -namespace Aaru.Filesystems; - // Information from Apple ProDOS 8 Technical Reference /// /// Implements detection of Apple ProDOS filesystem @@ -101,13 +103,13 @@ public sealed class ProDOSPlugin : IFilesystem if(partition.Length < 3) return false; - uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); + 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[] rootDirectoryKeyBlock); - bool apmFromHddOnCd = false; + var apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || @@ -132,13 +134,13 @@ public sealed class ProDOSPlugin : IFilesystem } } - ushort prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0); + var prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0); AaruConsole.DebugWriteLine("ProDOS plugin", "prePointer = {0}", prePointer); if(prePointer != 0) return false; - byte storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4); + var storageType = (byte)((rootDirectoryKeyBlock[0x04] & STORAGE_TYPE_MASK) >> 4); AaruConsole.DebugWriteLine("ProDOS plugin", "storage_type = {0}", storageType); if(storageType != ROOT_DIRECTORY_TYPE) @@ -156,13 +158,13 @@ public sealed class ProDOSPlugin : IFilesystem if(entriesPerBlock != ENTRIES_PER_BLOCK) return false; - ushort bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27); + var bitMapPointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27); AaruConsole.DebugWriteLine("ProDOS plugin", "bit_map_pointer = {0}", bitMapPointer); if(bitMapPointer > partition.End) return false; - ushort totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); + var totalBlocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); if(apmFromHddOnCd) totalBlocks /= 4; @@ -174,22 +176,21 @@ public sealed class ProDOSPlugin : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? new Apple2c(); information = ""; - var sbInformation = new StringBuilder(); - uint multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); + var sbInformation = new StringBuilder(); + 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; - bool apmFromHddOnCd = false; + var apmFromHddOnCd = false; if(imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448 || @@ -221,28 +222,27 @@ public sealed class ProDOSPlugin : IFilesystem next_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x02) }; - rootDirectoryKeyBlock.header.storage_type = - (byte)((rootDirectoryKeyBlockBytes[0x04] & STORAGE_TYPE_MASK) >> 4); + rootDirectoryKeyBlock.header.storage_type = (byte)((rootDirectoryKeyBlockBytes[0x04] & STORAGE_TYPE_MASK) >> 4); rootDirectoryKeyBlock.header.name_length = (byte)(rootDirectoryKeyBlockBytes[0x04] & NAME_LENGTH_MASK); - byte[] temporal = new byte[rootDirectoryKeyBlock.header.name_length]; + var temporal = new byte[rootDirectoryKeyBlock.header.name_length]; Array.Copy(rootDirectoryKeyBlockBytes, 0x05, temporal, 0, rootDirectoryKeyBlock.header.name_length); rootDirectoryKeyBlock.header.volume_name = Encoding.GetString(temporal); rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14); - ushort tempTimestampLeft = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C); - ushort tempTimestampRight = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E); + var tempTimestampLeft = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C); + var tempTimestampRight = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E); bool dateCorrect; try { - uint tempTimestamp = (uint)((tempTimestampLeft << 16) + tempTimestampRight); - int year = (int)((tempTimestamp & YEAR_MASK) >> 25); - int month = (int)((tempTimestamp & MONTH_MASK) >> 21); - int day = (int)((tempTimestamp & DAY_MASK) >> 16); - int hour = (int)((tempTimestamp & HOUR_MASK) >> 8); - int minute = (int)(tempTimestamp & MINUTE_MASK); + var tempTimestamp = (uint)((tempTimestampLeft << 16) + tempTimestampRight); + var year = (int)((tempTimestamp & YEAR_MASK) >> 25); + var month = (int)((tempTimestamp & MONTH_MASK) >> 21); + var day = (int)((tempTimestamp & DAY_MASK) >> 16); + var hour = (int)((tempTimestamp & HOUR_MASK) >> 8); + var minute = (int)(tempTimestamp & MINUTE_MASK); year += 1900; if(year < 1940) @@ -275,8 +275,7 @@ public sealed class ProDOSPlugin : IFilesystem rootDirectoryKeyBlock.header.total_blocks = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x29); if(apmFromHddOnCd) - sbInformation.AppendLine("ProDOS uses 512 bytes/sector while devices uses 2048 bytes/sector."). - AppendLine(); + sbInformation.AppendLine("ProDOS uses 512 bytes/sector while devices uses 2048 bytes/sector.").AppendLine(); if(rootDirectoryKeyBlock.header.version != VERSION1 || rootDirectoryKeyBlock.header.min_version != VERSION1) @@ -307,13 +306,11 @@ public sealed class ProDOSPlugin : IFilesystem sbInformation.AppendFormat("{0} bytes per directory entry", rootDirectoryKeyBlock.header.entry_length). AppendLine(); - sbInformation. - AppendFormat("{0} entries per directory block", rootDirectoryKeyBlock.header.entries_per_block). - AppendLine(); - - sbInformation.AppendFormat("{0} files in root directory", rootDirectoryKeyBlock.header.file_count). + sbInformation.AppendFormat("{0} entries per directory block", rootDirectoryKeyBlock.header.entries_per_block). AppendLine(); + sbInformation.AppendFormat("{0} files in root directory", rootDirectoryKeyBlock.header.file_count).AppendLine(); + sbInformation.AppendFormat("{0} blocks in volume", rootDirectoryKeyBlock.header.total_blocks).AppendLine(); sbInformation.AppendFormat("Bitmap starts at block {0}", rootDirectoryKeyBlock.header.bit_map_pointer). diff --git a/Aaru.Filesystems/QNX4.cs b/Aaru.Filesystems/QNX4.cs index 1d66dbfcc..66e6d47ff 100644 --- a/Aaru.Filesystems/QNX4.cs +++ b/Aaru.Filesystems/QNX4.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of QNX 4 filesystem [SuppressMessage("ReSharper", "UnusedType.Local")] @@ -110,8 +110,7 @@ public sealed class QNX4 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -200,8 +199,7 @@ public sealed class QNX4 : IFilesystem AaruConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_status = {0}", qnxSb.altBoot.di_status); */ - information = - $"QNX4 filesystem\nCreated on {DateHandlers.UnixUnsignedToDateTime(qnxSb.rootDir.di_ftime)}\n"; + information = $"QNX4 filesystem\nCreated on {DateHandlers.UnixUnsignedToDateTime(qnxSb.rootDir.di_ftime)}\n"; XmlFsType = new FileSystemType { diff --git a/Aaru.Filesystems/QNX6.cs b/Aaru.Filesystems/QNX6.cs index f3bd6ea6b..b544dec77 100644 --- a/Aaru.Filesystems/QNX6.cs +++ b/Aaru.Filesystems/QNX6.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of QNX 6 filesystem public sealed class QNX6 : IFilesystem @@ -91,8 +91,7 @@ public sealed class QNX6 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; diff --git a/Aaru.Filesystems/RBF.cs b/Aaru.Filesystems/RBF.cs index 3c5415bde..36f605055 100644 --- a/Aaru.Filesystems/RBF.cs +++ b/Aaru.Filesystems/RBF.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Locus filesystem public sealed class RBF : IFilesystem @@ -76,9 +76,9 @@ public sealed class RBF : IFilesystem 0, 4, 15 }) { - ulong location = (ulong)i; + var location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -98,8 +98,8 @@ public sealed class RBF : IFilesystem NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("RBF plugin", - "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", - location, rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); + "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", location, + rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync == RBF_SYNC || @@ -111,8 +111,7 @@ public sealed class RBF : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -128,8 +127,8 @@ public sealed class RBF : IFilesystem 0, 4, 15 }) { - ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var location = (ulong)i; + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -146,8 +145,8 @@ public sealed class RBF : IFilesystem rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("RBF plugin", - "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", - location, rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); + "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", location, + rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS); if(rbfSb.dd_sync == RBF_SYNC || rbf9000Sb.rid_sync == RBF_SYNC || @@ -180,8 +179,7 @@ public sealed class RBF : IFilesystem // TODO: Convert to flags? sb.AppendLine((rbf9000Sb.rid_format & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided"); - sb.AppendLine((rbf9000Sb.rid_format & 0x02) == 0x02 ? "Disk is double density" - : "Disk is single density"); + sb.AppendLine((rbf9000Sb.rid_format & 0x02) == 0x02 ? "Disk is double density" : "Disk is single density"); if((rbf9000Sb.rid_format & 0x10) == 0x10) sb.AppendLine("Disk is 384 TPI"); @@ -206,14 +204,12 @@ public sealed class RBF : IFilesystem sb.AppendFormat("Disk is owned by group {0} user {1}", rbf9000Sb.rid_group, rbf9000Sb.rid_owner). AppendLine(); - sb.AppendFormat("Volume was created on {0}", DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime)). - AppendLine(); + sb.AppendFormat("Volume was created on {0}", DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime)).AppendLine(); sb.AppendFormat("Volume's identification block was last written on {0}", DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime)).AppendLine(); - sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbf9000Sb.rid_name, Encoding)). - AppendLine(); + sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbf9000Sb.rid_name, Encoding)).AppendLine(); XmlFsType = new FileSystemType { @@ -263,8 +259,7 @@ public sealed class RBF : IFilesystem sb.AppendFormat("Boot file starts at block {0} and has {1} bytes", LSNToUInt32(rbfSb.dd_bt), rbfSb.dd_bsz).AppendLine(); - sb.AppendFormat("Root directory descriptor starts at block {0}", LSNToUInt32(rbfSb.dd_dir)). - AppendLine(); + sb.AppendFormat("Root directory descriptor starts at block {0}", LSNToUInt32(rbfSb.dd_dir)).AppendLine(); sb.AppendFormat("Disk is owned by user {0}", rbfSb.dd_own).AppendLine(); sb.AppendFormat("Volume was created on {0}", DateHandlers.Os9ToDateTime(rbfSb.dd_dat)).AppendLine(); diff --git a/Aaru.Filesystems/RT11.cs b/Aaru.Filesystems/RT11.cs index f559c0811..2a8409e5c 100644 --- a/Aaru.Filesystems/RT11.cs +++ b/Aaru.Filesystems/RT11.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -42,8 +44,6 @@ using Schemas; using Encoding = System.Text.Encoding; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from http://www.trailing-edge.com/~shoppa/rt11fs/ /// /// Implements detection of the DEC RT-11 filesystem @@ -66,7 +66,7 @@ public sealed class RT11 : IFilesystem if(1 + partition.Start >= partition.End) return false; - byte[] magicB = new byte[12]; + var magicB = new byte[12]; ErrorNumber errno = imagePlugin.ReadSector(1 + partition.Start, out byte[] hbSector); if(errno != ErrorNumber.NoError) @@ -82,8 +82,7 @@ public sealed class RT11 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = new Radix50(); information = ""; @@ -108,15 +107,14 @@ public sealed class RT11 : IFilesystem */ ushort check = 0; - for(int i = 0; i < 512; i += 2) + for(var i = 0; i < 512; i += 2) check += BitConverter.ToUInt16(hbSector, i); - sb.AppendFormat("Volume format is {0}", - StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)).AppendLine(); - - sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512). + sb.AppendFormat("Volume format is {0}", StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)). AppendLine(); + sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512).AppendLine(); + sb.AppendFormat("First directory segment starts at block {0}", homeblock.rootBlock).AppendLine(); sb.AppendFormat("Volume owner is \"{0}\"", Encoding.GetString(homeblock.ownername).TrimEnd()).AppendLine(); sb.AppendFormat("Volume label: \"{0}\"", Encoding.GetString(homeblock.volname).TrimEnd()).AppendLine(); diff --git a/Aaru.Filesystems/ReFS.cs b/Aaru.Filesystems/ReFS.cs index db86be220..b0c61764f 100644 --- a/Aaru.Filesystems/ReFS.cs +++ b/Aaru.Filesystems/ReFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of Microsoft's Resilient filesystem (ReFS) public sealed class ReFS : IFilesystem @@ -67,7 +67,7 @@ public sealed class ReFS : IFilesystem /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -90,13 +90,12 @@ public sealed class ReFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.UTF8; information = ""; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/Register.cs b/Aaru.Filesystems/Register.cs index 84392b872..00982b5f1 100644 --- a/Aaru.Filesystems/Register.cs +++ b/Aaru.Filesystems/Register.cs @@ -36,14 +36,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Filesystems; - /// public sealed class Register : IPluginRegister { diff --git a/Aaru.Filesystems/Reiser.cs b/Aaru.Filesystems/Reiser.cs index 18919fcc2..c54c9d0ec 100644 --- a/Aaru.Filesystems/Reiser.cs +++ b/Aaru.Filesystems/Reiser.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Reiser v3 filesystem public sealed class Reiser : IFilesystem @@ -84,7 +84,7 @@ public sealed class Reiser : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -107,8 +107,7 @@ public sealed class Reiser : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -121,7 +120,7 @@ public sealed class Reiser : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/Reiser4.cs b/Aaru.Filesystems/Reiser4.cs index 66d3e50de..0ea950eb0 100644 --- a/Aaru.Filesystems/Reiser4.cs +++ b/Aaru.Filesystems/Reiser4.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Linq; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Reiser v4 filesystem public sealed class Reiser4 : IFilesystem @@ -76,7 +76,7 @@ public sealed class Reiser4 : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -98,8 +98,7 @@ public sealed class Reiser4 : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -112,7 +111,7 @@ public sealed class Reiser4 : IFilesystem if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/SFS.cs b/Aaru.Filesystems/SFS.cs index f7fc19923..f20c3eb1a 100644 --- a/Aaru.Filesystems/SFS.cs +++ b/Aaru.Filesystems/SFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Smart File System public sealed class SFS : IFilesystem @@ -73,14 +73,13 @@ public sealed class SFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BigEndianBitConverter.ToUInt32(sector, 0x00); + var magic = BigEndianBitConverter.ToUInt32(sector, 0x00); return magic == SFS_MAGIC || magic == SFS2_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { information = ""; Encoding = encoding ?? Encoding.GetEncoding("iso-8859-1"); @@ -105,8 +104,7 @@ public sealed class SFS : IFilesystem AppendLine(); sbInformation.AppendFormat("Volume created on {0}", - DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8)). - AppendLine(); + DateHandlers.UnixUnsignedToDateTime(rootBlock.datecreated).AddYears(8)).AppendLine(); sbInformation.AppendFormat("Bitmap starts in block {0}", rootBlock.bitmapbase).AppendLine(); @@ -116,9 +114,8 @@ public sealed class SFS : IFilesystem sbInformation.AppendFormat("Root object container starts in block {0}", rootBlock.rootobjectcontainer). AppendLine(); - sbInformation. - AppendFormat("Root node of the extent B-tree resides in block {0}", rootBlock.extentbnoderoot). - AppendLine(); + sbInformation.AppendFormat("Root node of the extent B-tree resides in block {0}", rootBlock.extentbnoderoot). + AppendLine(); sbInformation.AppendFormat("Root node of the object B-tree resides in block {0}", rootBlock.objectnoderoot). AppendLine(); @@ -144,7 +141,8 @@ public sealed class SFS : IFilesystem [Flags] enum Flags : byte { - RecycledFolder = 64, CaseSensitive = 128 + RecycledFolder = 64, + CaseSensitive = 128 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/SolarFS.cs b/Aaru.Filesystems/SolarFS.cs index 3f218f4ee..8bc09c1b0 100644 --- a/Aaru.Filesystems/SolarFS.cs +++ b/Aaru.Filesystems/SolarFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - // Based on FAT's BPB, cannot find a FAT or directory /// /// Implements detection of the Solar OS filesystem @@ -69,7 +69,7 @@ public sealed class SolarFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - byte[] fsTypeB = new byte[8]; + var fsTypeB = new byte[8]; byte signature = bpb[0x25]; Array.Copy(bpb, 0x35, fsTypeB, 0, 8); @@ -79,8 +79,7 @@ public sealed class SolarFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -103,7 +102,7 @@ public sealed class SolarFS : IFilesystem signature = bpbSector[0x25] }; - byte[] bpbStrings = new byte[8]; + var bpbStrings = new byte[8]; Array.Copy(bpbSector, 0x03, bpbStrings, 0, 8); bpb.OEMName = StringHandlers.CToString(bpbStrings); bpbStrings = new byte[8]; diff --git a/Aaru.Filesystems/Squash.cs b/Aaru.Filesystems/Squash.cs index 500819a10..ade29ef9f 100644 --- a/Aaru.Filesystems/Squash.cs +++ b/Aaru.Filesystems/Squash.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the squash filesystem public sealed class Squash : IFilesystem @@ -72,14 +72,13 @@ public sealed class Squash : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); return magic == SQUASH_MAGIC || magic == SQUASH_CIGAM; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.UTF8; information = ""; @@ -88,10 +87,10 @@ public sealed class Squash : IFilesystem if(errno != ErrorNumber.NoError) return; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); - var sqSb = new SuperBlock(); - bool littleEndian = true; + var sqSb = new SuperBlock(); + var littleEndian = true; switch(magic) { @@ -170,8 +169,12 @@ public sealed class Squash : IFilesystem enum SquashCompression : ushort { - Zlib = 1, Lzma = 2, Lzo = 3, - Xz = 4, Lz4 = 5, Zstd = 6 + Zlib = 1, + Lzma = 2, + Lzo = 3, + Xz = 4, + Lz4 = 5, + Zstd = 6 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/SysV.cs b/Aaru.Filesystems/SysV.cs index 47ee58965..c634497f9 100644 --- a/Aaru.Filesystems/SysV.cs +++ b/Aaru.Filesystems/SysV.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable NotAccessedField.Local + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -40,10 +46,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -// ReSharper disable NotAccessedField.Local - -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection of the UNIX System V filesystem @@ -98,12 +100,12 @@ public sealed class SysVfs : IFilesystem sb_size_in_sectors = 1; // If not a single sector can store it if(partition.End <= - partition.Start + (4 * (ulong)sb_size_in_sectors) + + partition.Start + 4 * (ulong)sb_size_in_sectors + sb_size_in_sectors) // Device must be bigger than SB location + SB size + offset return false; // Sectors in a cylinder - int spc = (int)(imagePlugin.Info.Heads * imagePlugin.Info.SectorsPerTrack); + var spc = (int)(imagePlugin.Info.Heads * imagePlugin.Info.SectorsPerTrack); // Superblock can start on 0x000, 0x200, 0x600 and 0x800, not aligned, so we assume 16 (128 bytes/sector) sectors as a safe value int[] locations = @@ -124,7 +126,7 @@ public sealed class SysVfs : IFilesystem sb_sector.Length < 0x400) continue; - uint magic = BitConverter.ToUInt32(sb_sector, 0x3F8); + var magic = BitConverter.ToUInt32(sb_sector, 0x3F8); if(magic == XENIX_MAGIC || magic == XENIX_CIGAM || @@ -144,21 +146,21 @@ public sealed class SysVfs : IFilesystem magic == XENIX_CIGAM) return true; - byte[] coherent_string = new byte[6]; + var coherent_string = new byte[6]; Array.Copy(sb_sector, 0x1E4, coherent_string, 0, 6); // Coherent UNIX s_fname location string s_fname = StringHandlers.CToString(coherent_string); Array.Copy(sb_sector, 0x1EA, coherent_string, 0, 6); // Coherent UNIX s_fpack location string s_fpack = StringHandlers.CToString(coherent_string); - if((s_fname == COH_FNAME && s_fpack == COH_FPACK) || - (s_fname == COH_XXXXX && s_fpack == COH_XXXXX) || - (s_fname == COH_XXXXS && s_fpack == COH_XXXXN)) + if(s_fname == COH_FNAME && s_fpack == COH_FPACK || + s_fname == COH_XXXXX && s_fpack == COH_XXXXX || + s_fname == COH_XXXXS && s_fpack == COH_XXXXN) return true; // Now try to identify 7th edition - uint s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); - ushort s_nfree = BitConverter.ToUInt16(sb_sector, 0x006); - ushort s_ninode = BitConverter.ToUInt16(sb_sector, 0x0D0); + var s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); + var s_nfree = BitConverter.ToUInt16(sb_sector, 0x006); + var s_ninode = BitConverter.ToUInt16(sb_sector, 0x0D0); if(s_fsize <= 0 || s_fsize >= 0xFFFFFFFF || @@ -199,23 +201,22 @@ public sealed class SysVfs : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; var sb = new StringBuilder(); - bool bigEndian = false; // Start in little endian until we know what are we handling here - int start = 0; - bool xenix = false; - bool sysv = false; - bool sys7th = false; - bool coherent = false; - bool xenix3 = false; + var bigEndian = false; // Start in little endian until we know what are we handling here + var start = 0; + var xenix = false; + var sysv = false; + var sys7th = false; + var coherent = false; + var xenix3 = false; byte[] sb_sector; byte sb_size_in_sectors; - int offset = 0; + var offset = 0; if(imagePlugin.Info.SectorSize <= 0x400) // Check if underlying device sector size is smaller than SuperBlock size @@ -224,7 +225,7 @@ public sealed class SysVfs : IFilesystem sb_size_in_sectors = 1; // If not a single sector can store it // Sectors in a cylinder - int spc = (int)(imagePlugin.Info.Heads * imagePlugin.Info.SectorsPerTrack); + var spc = (int)(imagePlugin.Info.Heads * imagePlugin.Info.SectorsPerTrack); // Superblock can start on 0x000, 0x200, 0x600 and 0x800, not aligned, so we assume 16 (128 bytes/sector) sectors as a safe value int[] locations = @@ -244,7 +245,7 @@ public sealed class SysVfs : IFilesystem if(errno != ErrorNumber.NoError) continue; - uint magic = BitConverter.ToUInt32(sb_sector, 0x3F8); + var magic = BitConverter.ToUInt32(sb_sector, 0x3F8); if(magic == XENIX_MAGIC || magic == SYSV_MAGIC) @@ -318,15 +319,15 @@ public sealed class SysVfs : IFilesystem break; } - byte[] coherent_string = new byte[6]; + var coherent_string = new byte[6]; Array.Copy(sb_sector, 0x1E4, coherent_string, 0, 6); // Coherent UNIX s_fname location string s_fname = StringHandlers.CToString(coherent_string, Encoding); Array.Copy(sb_sector, 0x1EA, coherent_string, 0, 6); // Coherent UNIX s_fpack location string s_fpack = StringHandlers.CToString(coherent_string, Encoding); - if((s_fname == COH_FNAME && s_fpack == COH_FPACK) || - (s_fname == COH_XXXXX && s_fpack == COH_XXXXX) || - (s_fname == COH_XXXXS && s_fpack == COH_XXXXN)) + if(s_fname == COH_FNAME && s_fpack == COH_FPACK || + s_fname == COH_XXXXX && s_fpack == COH_XXXXX || + s_fname == COH_XXXXS && s_fpack == COH_XXXXN) { coherent = true; start = i; @@ -335,9 +336,9 @@ public sealed class SysVfs : IFilesystem } // Now try to identify 7th edition - uint s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); - ushort s_nfree = BitConverter.ToUInt16(sb_sector, 0x006); - ushort s_ninode = BitConverter.ToUInt16(sb_sector, 0x0D0); + var s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); + var s_nfree = BitConverter.ToUInt16(sb_sector, 0x006); + var s_ninode = BitConverter.ToUInt16(sb_sector, 0x0D0); if(s_fsize <= 0 || s_fsize >= 0xFFFFFFFF || @@ -390,8 +391,8 @@ public sealed class SysVfs : IFilesystem if(xenix || xenix3) { - byte[] xenix_strings = new byte[6]; - var xnx_sb = new XenixSuperBlock(); + var xenix_strings = new byte[6]; + var xnx_sb = new XenixSuperBlock(); errno = imagePlugin.ReadSectors((ulong)start + partition.Start, sb_size_in_sectors, out sb_sector); if(errno != ErrorNumber.NoError) @@ -513,11 +514,9 @@ public sealed class SysVfs : IFilesystem sb.AppendFormat("{0} zones on volume ({1} bytes)", xnx_sb.s_fsize, xnx_sb.s_fsize * bs).AppendLine(); - sb.AppendFormat("{0} free zones on volume ({1} bytes)", xnx_sb.s_tfree, xnx_sb.s_tfree * bs). - AppendLine(); + sb.AppendFormat("{0} free zones on volume ({1} bytes)", xnx_sb.s_tfree, xnx_sb.s_tfree * bs).AppendLine(); - sb.AppendFormat("{0} free blocks on list ({1} bytes)", xnx_sb.s_nfree, xnx_sb.s_nfree * bs). - AppendLine(); + sb.AppendFormat("{0} free blocks on list ({1} bytes)", xnx_sb.s_nfree, xnx_sb.s_nfree * bs).AppendLine(); sb.AppendFormat("{0} blocks per cylinder ({1} bytes)", xnx_sb.s_cylblks, xnx_sb.s_cylblks * bs). AppendLine(); @@ -539,8 +538,7 @@ public sealed class SysVfs : IFilesystem if(xnx_sb.s_ronly > 0) sb.AppendLine("Volume is mounted read-only"); - sb.AppendFormat("Superblock last updated on {0}", DateHandlers.UnixToDateTime(xnx_sb.s_time)). - AppendLine(); + sb.AppendFormat("Superblock last updated on {0}", DateHandlers.UnixToDateTime(xnx_sb.s_time)).AppendLine(); if(xnx_sb.s_time != 0) { @@ -568,7 +566,7 @@ public sealed class SysVfs : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] sysv_strings = new byte[6]; + var sysv_strings = new byte[6]; var sysv_sb = new SystemVRelease4SuperBlock { @@ -684,17 +682,14 @@ public sealed class SysVfs : IFilesystem XmlFsType.Clusters = sysv_sb.s_fsize; sb.AppendFormat("{0} zones on volume ({1} bytes)", sysv_sb.s_fsize, sysv_sb.s_fsize * bs).AppendLine(); - sb.AppendFormat("{0} free zones on volume ({1} bytes)", sysv_sb.s_tfree, sysv_sb.s_tfree * bs). - AppendLine(); + sb.AppendFormat("{0} free zones on volume ({1} bytes)", sysv_sb.s_tfree, sysv_sb.s_tfree * bs).AppendLine(); - sb.AppendFormat("{0} free blocks on list ({1} bytes)", sysv_sb.s_nfree, sysv_sb.s_nfree * bs). - AppendLine(); + sb.AppendFormat("{0} free blocks on list ({1} bytes)", sysv_sb.s_nfree, sysv_sb.s_nfree * bs).AppendLine(); sb.AppendFormat("{0} blocks per cylinder ({1} bytes)", sysv_sb.s_cylblks, sysv_sb.s_cylblks * bs). AppendLine(); - sb.AppendFormat("{0} blocks per gap ({1} bytes)", sysv_sb.s_gapblks, sysv_sb.s_gapblks * bs). - AppendLine(); + sb.AppendFormat("{0} blocks per gap ({1} bytes)", sysv_sb.s_gapblks, sysv_sb.s_gapblks * bs).AppendLine(); sb.AppendFormat("First data zone: {0}", sysv_sb.s_isize).AppendLine(); sb.AppendFormat("{0} free inodes on volume", sysv_sb.s_tinode).AppendLine(); @@ -741,8 +736,8 @@ public sealed class SysVfs : IFilesystem if(errno != ErrorNumber.NoError) return; - var coh_sb = new CoherentSuperBlock(); - byte[] coh_strings = new byte[6]; + var coh_sb = new CoherentSuperBlock(); + var coh_strings = new byte[6]; coh_sb.s_isize = BitConverter.ToUInt16(sb_sector, 0x000); coh_sb.s_fsize = Swapping.PDPFromLittleEndian(BitConverter.ToUInt32(sb_sector, 0x002)); @@ -769,17 +764,14 @@ public sealed class SysVfs : IFilesystem sb.AppendLine("Coherent UNIX filesystem"); if(imagePlugin.Info.SectorSize != 512) - sb. - AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/sector", - 512, 2048).AppendLine(); + sb.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/sector", + 512, 2048).AppendLine(); sb.AppendFormat("{0} zones on volume ({1} bytes)", coh_sb.s_fsize, coh_sb.s_fsize * 512).AppendLine(); - sb.AppendFormat("{0} free zones on volume ({1} bytes)", coh_sb.s_tfree, coh_sb.s_tfree * 512). - AppendLine(); + sb.AppendFormat("{0} free zones on volume ({1} bytes)", coh_sb.s_tfree, coh_sb.s_tfree * 512).AppendLine(); - sb.AppendFormat("{0} free blocks on list ({1} bytes)", coh_sb.s_nfree, coh_sb.s_nfree * 512). - AppendLine(); + sb.AppendFormat("{0} free blocks on list ({1} bytes)", coh_sb.s_nfree, coh_sb.s_nfree * 512).AppendLine(); sb.AppendFormat("First data zone: {0}", coh_sb.s_isize).AppendLine(); sb.AppendFormat("{0} free inodes on volume", coh_sb.s_tinode).AppendLine(); @@ -818,8 +810,8 @@ public sealed class SysVfs : IFilesystem if(errno != ErrorNumber.NoError) return; - var v7_sb = new UNIX7thEditionSuperBlock(); - byte[] sys7_strings = new byte[6]; + var v7_sb = new UNIX7thEditionSuperBlock(); + var sys7_strings = new byte[6]; v7_sb.s_isize = BitConverter.ToUInt16(sb_sector, 0x000); v7_sb.s_fsize = BitConverter.ToUInt32(sb_sector, 0x002); @@ -845,14 +837,12 @@ public sealed class SysVfs : IFilesystem sb.AppendLine("UNIX 7th Edition filesystem"); if(imagePlugin.Info.SectorSize != 512) - sb. - AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/sector", - 512, 2048).AppendLine(); + sb.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/sector", + 512, 2048).AppendLine(); sb.AppendFormat("{0} zones on volume ({1} bytes)", v7_sb.s_fsize, v7_sb.s_fsize * 512).AppendLine(); - sb.AppendFormat("{0} free zones on volume ({1} bytes)", v7_sb.s_tfree, v7_sb.s_tfree * 512). - AppendLine(); + sb.AppendFormat("{0} free zones on volume ({1} bytes)", v7_sb.s_tfree, v7_sb.s_tfree * 512).AppendLine(); sb.AppendFormat("{0} free blocks on list ({1} bytes)", v7_sb.s_nfree, v7_sb.s_nfree * 512).AppendLine(); sb.AppendFormat("First data zone: {0}", v7_sb.s_isize).AppendLine(); diff --git a/Aaru.Filesystems/UCSDPascal/Consts.cs b/Aaru.Filesystems/UCSDPascal/Consts.cs index c497573e2..a0e5aaac1 100644 --- a/Aaru.Filesystems/UCSDPascal/Consts.cs +++ b/Aaru.Filesystems/UCSDPascal/Consts.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems.UCSDPascal; +using System.Diagnostics.CodeAnalysis; + // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class PascalPlugin diff --git a/Aaru.Filesystems/UCSDPascal/Dir.cs b/Aaru.Filesystems/UCSDPascal/Dir.cs index 7ab468411..7db730362 100644 --- a/Aaru.Filesystems/UCSDPascal/Dir.cs +++ b/Aaru.Filesystems/UCSDPascal/Dir.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.UCSDPascal; + using System; using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.Helpers; -namespace Aaru.Filesystems.UCSDPascal; - // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure public sealed partial class PascalPlugin { diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index fc85ea599..c16d93d53 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.UCSDPascal; + using System; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; -namespace Aaru.Filesystems.UCSDPascal; - // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure public sealed partial class PascalPlugin { @@ -107,7 +107,7 @@ public sealed partial class PascalPlugin if(error != ErrorNumber.NoError) return error; - file = new byte[((entry.LastBlock - entry.FirstBlock - 1) * _device.Info.SectorSize * _multiplier) + + file = new byte[(entry.LastBlock - entry.FirstBlock - 1) * _device.Info.SectorSize * _multiplier + entry.LastBytes]; Array.Copy(tmp, 0, file, 0, file.Length); @@ -152,14 +152,13 @@ public sealed partial class PascalPlugin if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (_catalogBlocks.Length / stat.BlockSize) + - (_catalogBlocks.Length % stat.BlockSize); + stat.Blocks = _catalogBlocks.Length / stat.BlockSize + _catalogBlocks.Length % stat.BlockSize; stat.Length = _catalogBlocks.Length; } else { - stat.Blocks = (_bootBlocks.Length / stat.BlockSize) + (_catalogBlocks.Length % stat.BlockSize); + stat.Blocks = _bootBlocks.Length / stat.BlockSize + _catalogBlocks.Length % stat.BlockSize; stat.Length = _bootBlocks.Length; } @@ -173,12 +172,11 @@ public sealed partial class PascalPlugin stat = new FileEntryInfo { - Attributes = FileAttributes.File, - Blocks = entry.LastBlock - entry.FirstBlock, - BlockSize = _device.Info.SectorSize * _multiplier, + Attributes = FileAttributes.File, + Blocks = entry.LastBlock - entry.FirstBlock, + BlockSize = _device.Info.SectorSize * _multiplier, LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.ModificationTime), - Length = ((entry.LastBlock - entry.FirstBlock) * _device.Info.SectorSize * _multiplier) + - entry.LastBytes, + Length = (entry.LastBlock - entry.FirstBlock) * _device.Info.SectorSize * _multiplier + entry.LastBytes, Links = 1 }; diff --git a/Aaru.Filesystems/UCSDPascal/Info.cs b/Aaru.Filesystems/UCSDPascal/Info.cs index 6a871acd6..1a005aff0 100644 --- a/Aaru.Filesystems/UCSDPascal/Info.cs +++ b/Aaru.Filesystems/UCSDPascal/Info.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.UCSDPascal; + using System; using System.Text; using Aaru.CommonTypes; @@ -41,8 +43,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems.UCSDPascal; - // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure public sealed partial class PascalPlugin { @@ -56,7 +56,7 @@ public sealed partial class PascalPlugin // Blocks 0 and 1 are boot code ErrorNumber errno = - imagePlugin.ReadSectors((_multiplier * 2) + partition.Start, _multiplier, out byte[] volBlock); + imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock); if(errno != ErrorNumber.NoError) return false; @@ -84,6 +84,7 @@ public sealed partial class PascalPlugin AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.firstBlock = {0}", volEntry.FirstBlock); AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.lastBlock = {0}", volEntry.LastBlock); AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.entryType = {0}", volEntry.EntryType); + // AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.volumeName = {0}", volEntry.VolumeName); AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.blocks = {0}", volEntry.Blocks); AaruConsole.DebugWriteLine("UCSD Pascal Plugin", "volEntry.files = {0}", volEntry.Files); @@ -97,7 +98,7 @@ public sealed partial class PascalPlugin // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || - (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / _multiplier) - 2) + (ulong)volEntry.LastBlock > imagePlugin.Info.Sectors / _multiplier - 2) return false; // Volume record entry type must be volume or secure @@ -119,8 +120,7 @@ public sealed partial class PascalPlugin } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? new Apple2(); var sbInformation = new StringBuilder(); @@ -132,7 +132,7 @@ public sealed partial class PascalPlugin // Blocks 0 and 1 are boot code ErrorNumber errno = - imagePlugin.ReadSectors((_multiplier * 2) + partition.Start, _multiplier, out byte[] volBlock); + imagePlugin.ReadSectors(_multiplier * 2 + partition.Start, _multiplier, out byte[] volBlock); if(errno != ErrorNumber.NoError) return; @@ -163,7 +163,7 @@ public sealed partial class PascalPlugin // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || - (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / _multiplier) - 2) + (ulong)volEntry.LastBlock > imagePlugin.Info.Sectors / _multiplier - 2) return; // Volume record entry type must be volume or secure @@ -187,16 +187,14 @@ public sealed partial class PascalPlugin sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.FirstBlock, volEntry.LastBlock).AppendLine(); - sbInformation. - AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.VolumeName, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.VolumeName, Encoding)). + AppendLine(); sbInformation.AppendFormat("Volume has {0} blocks", volEntry.Blocks).AppendLine(); sbInformation.AppendFormat("Volume has {0} files", volEntry.Files).AppendLine(); - sbInformation. - AppendFormat("Volume last booted at {0}", DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot)). - AppendLine(); + sbInformation.AppendFormat("Volume last booted at {0}", DateHandlers.UcsdPascalToDateTime(volEntry.LastBoot)). + AppendLine(); information = sbInformation.ToString(); diff --git a/Aaru.Filesystems/UCSDPascal/Structs.cs b/Aaru.Filesystems/UCSDPascal/Structs.cs index 2aec998ee..c3cfb2b40 100644 --- a/Aaru.Filesystems/UCSDPascal/Structs.cs +++ b/Aaru.Filesystems/UCSDPascal/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Filesystems.UCSDPascal; +using System.Diagnostics.CodeAnalysis; + // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure [SuppressMessage("ReSharper", "NotAccessedField.Local")] public sealed partial class PascalPlugin diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs index ea23397d4..b2de9036c 100644 --- a/Aaru.Filesystems/UCSDPascal/Super.cs +++ b/Aaru.Filesystems/UCSDPascal/Super.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.UCSDPascal; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -41,8 +43,6 @@ using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -namespace Aaru.Filesystems.UCSDPascal; - // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure public sealed partial class PascalPlugin { @@ -85,25 +85,24 @@ public sealed partial class PascalPlugin _mountedVolEntry.LastBoot = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x14); _mountedVolEntry.Tail = BigEndianBitConverter.ToInt32(_catalogBlocks, 0x16); - if(_mountedVolEntry.FirstBlock != 0 || - _mountedVolEntry.LastBlock <= _mountedVolEntry.FirstBlock || - (ulong)_mountedVolEntry.LastBlock > (_device.Info.Sectors / _multiplier) - 2 || - (_mountedVolEntry.EntryType != PascalFileKind.Volume && - _mountedVolEntry.EntryType != PascalFileKind.Secure) || - _mountedVolEntry.VolumeName[0] > 7 || - _mountedVolEntry.Blocks < 0 || - (ulong)_mountedVolEntry.Blocks != _device.Info.Sectors / _multiplier || + if(_mountedVolEntry.FirstBlock != 0 || + _mountedVolEntry.LastBlock <= _mountedVolEntry.FirstBlock || + (ulong)_mountedVolEntry.LastBlock > _device.Info.Sectors / _multiplier - 2 || + _mountedVolEntry.EntryType != PascalFileKind.Volume && _mountedVolEntry.EntryType != PascalFileKind.Secure || + _mountedVolEntry.VolumeName[0] > 7 || + _mountedVolEntry.Blocks < 0 || + (ulong)_mountedVolEntry.Blocks != _device.Info.Sectors / _multiplier || _mountedVolEntry.Files < 0) return ErrorNumber.InvalidArgument; - errno = _device.ReadSectors(_multiplier * 2, - (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * - _multiplier, out _catalogBlocks); + errno = _device.ReadSectors(_multiplier * 2, + (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * _multiplier, + out _catalogBlocks); if(errno != ErrorNumber.NoError) return errno; - int offset = 26; + var offset = 26; _fileEntries = new List(); @@ -171,8 +170,7 @@ public sealed partial class PascalPlugin Type = "UCSD Pascal" }; - stat.FreeBlocks = - (ulong)(_mountedVolEntry.Blocks - (_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock)); + stat.FreeBlocks = (ulong)(_mountedVolEntry.Blocks - (_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock)); foreach(PascalFileEntry entry in _fileEntries) stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock); diff --git a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs index 2527e2b35..bf02263b1 100644 --- a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs +++ b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems.UCSDPascal; + using System; using System.Collections.Generic; using System.Text; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems.UCSDPascal; - // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure /// /// Implements the U.C.S.D. Pascal filesystem diff --git a/Aaru.Filesystems/UDF.cs b/Aaru.Filesystems/UDF.cs index 39f8e47bc..2ba4d1e0d 100644 --- a/Aaru.Filesystems/UDF.cs +++ b/Aaru.Filesystems/UDF.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // TODO: Detect bootable /// /// Implements detection of the Universal Disk Format filesystem @@ -119,7 +119,7 @@ public sealed class UDF : IFilesystem } }; - bool anchorFound = false; + var anchorFound = false; uint ratio = 1; foreach(ulong[] position in positions.Where(position => position[0] + partition.Start + position[1] <= @@ -140,11 +140,9 @@ public sealed class UDF : IFilesystem AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.tagChecksum = 0x{0:X2}", anchor.tag.tagChecksum); AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.reserved = {0}", anchor.tag.reserved); - AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.tagSerialNumber = {0}", - anchor.tag.tagSerialNumber); + AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.tagSerialNumber = {0}", anchor.tag.tagSerialNumber); - AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.descriptorCrc = 0x{0:X4}", - anchor.tag.descriptorCrc); + AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.descriptorCrc = 0x{0:X4}", anchor.tag.descriptorCrc); AaruConsole.DebugWriteLine("UDF Plugin", "anchor.tag.descriptorCrcLength = {0}", anchor.tag.descriptorCrcLength); @@ -164,9 +162,8 @@ public sealed class UDF : IFilesystem anchor.reserveVolumeDescriptorSequenceExtent.location); if(anchor.tag.tagIdentifier != TagIdentifier.AnchorVolumeDescriptorPointer || - anchor.tag.tagLocation != position[0] / position[1] || - (anchor.mainVolumeDescriptorSequenceExtent.location * position[1]) + partition.Start >= - partition.End) + anchor.tag.tagLocation != position[0] / position[1] || + anchor.mainVolumeDescriptorSequenceExtent.location * position[1] + partition.Start >= partition.End) continue; anchorFound = true; @@ -184,7 +181,7 @@ public sealed class UDF : IFilesystem { ErrorNumber errno = imagePlugin. - ReadSectors(partition.Start + (anchor.mainVolumeDescriptorSequenceExtent.location * ratio) + (count * ratio), + ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, ratio, out sector); if(errno != ErrorNumber.NoError) @@ -194,10 +191,10 @@ public sealed class UDF : IFilesystem continue; } - var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0); - uint location = BitConverter.ToUInt32(sector, 0x0C); + var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0); + var location = BitConverter.ToUInt32(sector, 0x0C); - if(location == (partition.Start / ratio) + anchor.mainVolumeDescriptorSequenceExtent.location + count) + if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count) { if(tagId == TagIdentifier.TerminatingDescriptor) break; @@ -220,8 +217,7 @@ public sealed class UDF : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { information = ""; ErrorNumber errno; @@ -305,16 +301,16 @@ public sealed class UDF : IFilesystem { errno = imagePlugin. - ReadSectors(partition.Start + (anchor.mainVolumeDescriptorSequenceExtent.location * ratio) + (count * ratio), + ReadSectors(partition.Start + anchor.mainVolumeDescriptorSequenceExtent.location * ratio + count * ratio, ratio, out sector); if(errno != ErrorNumber.NoError) continue; - var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0); - uint location = BitConverter.ToUInt32(sector, 0x0C); + var tagId = (TagIdentifier)BitConverter.ToUInt16(sector, 0); + var location = BitConverter.ToUInt32(sector, 0x0C); - if(location == (partition.Start / ratio) + anchor.mainVolumeDescriptorSequenceExtent.location + count) + if(location == partition.Start / ratio + anchor.mainVolumeDescriptorSequenceExtent.location + count) { if(tagId == TagIdentifier.TerminatingDescriptor) break; @@ -348,7 +344,7 @@ public sealed class UDF : IFilesystem lvid.tag.tagLocation == lvd.integritySequenceExtent.location) lvidiu = Marshal.ByteArrayToStructureLittleEndian(sector, - (int)((lvid.numberOfPartitions * 8) + 80), + (int)(lvid.numberOfPartitions * 8 + 80), System.Runtime.InteropServices.Marshal.SizeOf(lvidiu)); else lvid = new LogicalVolumeIntegrityDescriptor(); @@ -359,9 +355,8 @@ public sealed class UDF : IFilesystem sbInformation.AppendFormat("Volume set identifier: {0}", StringHandlers.DecompressUnicode(pvd.volumeSetIdentifier)).AppendLine(); - sbInformation. - AppendFormat("Volume name: {0}", StringHandlers.DecompressUnicode(lvd.logicalVolumeIdentifier)). - AppendLine(); + sbInformation.AppendFormat("Volume name: {0}", StringHandlers.DecompressUnicode(lvd.logicalVolumeIdentifier)). + AppendLine(); sbInformation.AppendFormat("Volume uses {0} bytes per block", lvd.logicalBlockSize).AppendLine(); @@ -370,13 +365,11 @@ public sealed class UDF : IFilesystem sbInformation.AppendFormat("Volume contains {0} partitions", lvid.numberOfPartitions).AppendLine(); - sbInformation. - AppendFormat("Volume contains {0} files and {1} directories", lvidiu.files, lvidiu.directories). - AppendLine(); + sbInformation.AppendFormat("Volume contains {0} files and {1} directories", lvidiu.files, lvidiu.directories). + AppendLine(); sbInformation.AppendFormat("Volume conforms to {0}", - Encoding.GetString(lvd.domainIdentifier.identifier).TrimEnd('\u0000')). - AppendLine(); + Encoding.GetString(lvd.domainIdentifier.identifier).TrimEnd('\u0000')).AppendLine(); sbInformation.AppendFormat("Volume was last written by: {0}", Encoding.GetString(pvd.implementationIdentifier.identifier).TrimEnd('\u0000')). @@ -423,7 +416,8 @@ public sealed class UDF : IFilesystem [Flags] enum EntityFlags : byte { - Dirty = 0x01, Protected = 0x02 + Dirty = 0x01, + Protected = 0x02 } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -456,9 +450,15 @@ public sealed class UDF : IFilesystem enum TagIdentifier : ushort { - PrimaryVolumeDescriptor = 1, AnchorVolumeDescriptorPointer = 2, VolumeDescriptorPointer = 3, - ImplementationUseVolumeDescriptor = 4, PartitionDescriptor = 5, LogicalVolumeDescriptor = 6, - UnallocatedSpaceDescriptor = 7, TerminatingDescriptor = 8, LogicalVolumeIntegrityDescriptor = 9 + PrimaryVolumeDescriptor = 1, + AnchorVolumeDescriptorPointer = 2, + VolumeDescriptorPointer = 3, + ImplementationUseVolumeDescriptor = 4, + PartitionDescriptor = 5, + LogicalVolumeDescriptor = 6, + UnallocatedSpaceDescriptor = 7, + TerminatingDescriptor = 8, + LogicalVolumeIntegrityDescriptor = 9 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/UNICOS.cs b/Aaru.Filesystems/UNICOS.cs index f47053b48..877bcf7e7 100644 --- a/Aaru.Filesystems/UNICOS.cs +++ b/Aaru.Filesystems/UNICOS.cs @@ -30,6 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +// UNICOS is ILP64 so let's think everything is 64-bit +using blkno_t = System.Int64; +using daddr_t = System.Int64; +using dev_t = System.Int64; +using extent_t = System.Int64; +using ino_t = System.Int64; +using time_t = System.Int64; + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -40,17 +50,7 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; - -// UNICOS is ILP64 so let's think everything is 64-bit -using blkno_t = System.Int64; -using daddr_t = System.Int64; -using dev_t = System.Int64; -using extent_t = System.Int64; -using ino_t = System.Int64; using Marshal = Aaru.Helpers.Marshal; -using time_t = System.Int64; - -namespace Aaru.Filesystems; /// /// Implements detection for the Cray UNICOS filesystem @@ -79,7 +79,7 @@ public sealed class UNICOS : IFilesystem if(imagePlugin.Info.SectorSize < 512) return false; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -104,8 +104,7 @@ public sealed class UNICOS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -113,7 +112,7 @@ public sealed class UNICOS : IFilesystem if(imagePlugin.Info.SectorSize < 512) return; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/UNIXBFS.cs b/Aaru.Filesystems/UNIXBFS.cs index fe00d33f8..815a52e57 100644 --- a/Aaru.Filesystems/UNIXBFS.cs +++ b/Aaru.Filesystems/UNIXBFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection of the UNIX boot filesystem @@ -71,14 +71,13 @@ public sealed class BFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(tmp, 0); + var magic = BitConverter.ToUInt32(tmp, 0); return magic == BFS_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -89,7 +88,7 @@ public sealed class BFS : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] sbStrings = new byte[6]; + var sbStrings = new byte[6]; var bfsSb = new SuperBlock { diff --git a/Aaru.Filesystems/VMfs.cs b/Aaru.Filesystems/VMfs.cs index e2425f1c3..8943a0d49 100644 --- a/Aaru.Filesystems/VMfs.cs +++ b/Aaru.Filesystems/VMfs.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the VMware filesystem [SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "IdentifierTypo"), @@ -80,14 +80,13 @@ public sealed class VMfs : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); return magic == VMFS_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.UTF8; information = ""; @@ -103,15 +102,14 @@ public sealed class VMfs : IFilesystem sbInformation.AppendLine("VMware file system"); - uint ctimeSecs = (uint)(volInfo.ctime / 1000000); - uint ctimeNanoSecs = (uint)(volInfo.ctime % 1000000); - uint mtimeSecs = (uint)(volInfo.mtime / 1000000); - uint mtimeNanoSecs = (uint)(volInfo.mtime % 1000000); + var ctimeSecs = (uint)(volInfo.ctime / 1000000); + var ctimeNanoSecs = (uint)(volInfo.ctime % 1000000); + var mtimeSecs = (uint)(volInfo.mtime / 1000000); + var mtimeNanoSecs = (uint)(volInfo.mtime % 1000000); sbInformation.AppendFormat("Volume version {0}", volInfo.version).AppendLine(); - sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name, Encoding)).AppendLine(); sbInformation.AppendFormat("Volume size {0} bytes", volInfo.size * 256).AppendLine(); sbInformation.AppendFormat("Volume UUID {0}", volInfo.uuid).AppendLine(); @@ -141,7 +139,8 @@ public sealed class VMfs : IFilesystem [Flags] enum Flags : byte { - RecyledFolder = 64, CaseSensitive = 128 + RecyledFolder = 64, + CaseSensitive = 128 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/VxFS.cs b/Aaru.Filesystems/VxFS.cs index dd2c88a78..0fc6c7e26 100644 --- a/Aaru.Filesystems/VxFS.cs +++ b/Aaru.Filesystems/VxFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of the Veritas filesystem public sealed class VxFS : IFilesystem @@ -74,14 +74,13 @@ public sealed class VxFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - uint magic = BitConverter.ToUInt32(sector, 0x00); + var magic = BitConverter.ToUInt32(sector, 0x00); return magic == VXFS_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.UTF8; information = ""; @@ -99,11 +98,9 @@ public sealed class VxFS : IFilesystem sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine(); - sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, Encoding)). - AppendLine(); + sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, Encoding)).AppendLine(); - sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size). - AppendLine(); + sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).AppendLine(); sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine(); sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine(); diff --git a/Aaru.Filesystems/XFS.cs b/Aaru.Filesystems/XFS.cs index d49ed8f84..06499f26a 100644 --- a/Aaru.Filesystems/XFS.cs +++ b/Aaru.Filesystems/XFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Runtime.InteropServices; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - /// /// Implements detection of SGI's XFS public sealed class XFS : IFilesystem @@ -69,7 +69,7 @@ public sealed class XFS : IFilesystem // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -82,7 +82,7 @@ public sealed class XFS : IFilesystem if(sector.Length < Marshal.SizeOf()) return false; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + var sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] { @@ -93,8 +93,8 @@ public sealed class XFS : IFilesystem Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", - location, xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location, + xfsSb.magicnum, XFS_MAGIC); if(xfsSb.magicnum == XFS_MAGIC) return true; @@ -106,9 +106,9 @@ public sealed class XFS : IFilesystem 0, 1, 2 }) { - ulong location = (ulong)i; + var location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -134,8 +134,7 @@ public sealed class XFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -148,7 +147,7 @@ public sealed class XFS : IFilesystem // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + var sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -159,7 +158,7 @@ public sealed class XFS : IFilesystem sector.Length < Marshal.SizeOf()) return; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + var sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] { @@ -170,8 +169,8 @@ public sealed class XFS : IFilesystem xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); - AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", - location, xfsSb.magicnum, XFS_MAGIC); + AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location, + xfsSb.magicnum, XFS_MAGIC); if(xfsSb.magicnum == XFS_MAGIC) break; @@ -183,8 +182,8 @@ public sealed class XFS : IFilesystem 0, 1, 2 }) { - ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var location = (ulong)i; + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; diff --git a/Aaru.Filesystems/Xia.cs b/Aaru.Filesystems/Xia.cs index 0ce95dfd4..e927e4181 100644 --- a/Aaru.Filesystems/Xia.cs +++ b/Aaru.Filesystems/Xia.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection for the Xia filesystem @@ -71,8 +71,8 @@ public sealed class Xia : IFilesystem /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - int sbSizeInBytes = Marshal.SizeOf(); - uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); + int sbSizeInBytes = Marshal.SizeOf(); + var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; @@ -91,16 +91,15 @@ public sealed class Xia : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; var sb = new StringBuilder(); - int sbSizeInBytes = Marshal.SizeOf(); - uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); + int sbSizeInBytes = Marshal.SizeOf(); + var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; @@ -119,14 +118,14 @@ public sealed class Xia : IFilesystem sb.AppendFormat("{0} inodes", supblk.s_ninodes).AppendLine(); - sb.AppendFormat("{0} data zones ({1} bytes)", supblk.s_ndatazones, - supblk.s_ndatazones * supblk.s_zone_size).AppendLine(); + sb.AppendFormat("{0} data zones ({1} bytes)", supblk.s_ndatazones, supblk.s_ndatazones * supblk.s_zone_size). + AppendLine(); - sb.AppendFormat("{0} imap zones ({1} bytes)", supblk.s_imap_zones, - supblk.s_imap_zones * supblk.s_zone_size).AppendLine(); + sb.AppendFormat("{0} imap zones ({1} bytes)", supblk.s_imap_zones, supblk.s_imap_zones * supblk.s_zone_size). + AppendLine(); - sb.AppendFormat("{0} zmap zones ({1} bytes)", supblk.s_zmap_zones, - supblk.s_zmap_zones * supblk.s_zone_size).AppendLine(); + sb.AppendFormat("{0} zmap zones ({1} bytes)", supblk.s_zmap_zones, supblk.s_zmap_zones * supblk.s_zone_size). + AppendLine(); sb.AppendFormat("First data zone: {0}", supblk.s_firstdatazone).AppendLine(); diff --git a/Aaru.Filesystems/ZFS.cs b/Aaru.Filesystems/ZFS.cs index adb76db0e..913ff4e1a 100644 --- a/Aaru.Filesystems/ZFS.cs +++ b/Aaru.Filesystems/ZFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -namespace Aaru.Filesystems; - /* * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) * of ZFS-On-Linux. @@ -130,8 +130,7 @@ public sealed class ZFS : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { // ZFS is always UTF-8 Encoding = Encoding.UTF8; @@ -183,8 +182,8 @@ public sealed class ZFS : IFilesystem if(errno != ErrorNumber.NoError) return; - sb.AppendLine(!DecodeNvList(nvlist, out Dictionary decodedNvList) - ? "Could not decode nvlist" : PrintNvList(decodedNvList)); + sb.AppendLine(!DecodeNvList(nvlist, out Dictionary decodedNvList) ? "Could not decode nvlist" + : PrintNvList(decodedNvList)); information = sb.ToString(); @@ -205,7 +204,7 @@ public sealed class ZFS : IFilesystem static bool DecodeNvList(byte[] nvlist, out Dictionary decodedNvList) { - byte[] tmp = new byte[nvlist.Length - 4]; + var tmp = new byte[nvlist.Length - 4]; Array.Copy(nvlist, 4, tmp, 0, nvlist.Length - 4); bool xdr = nvlist[0] == 1; bool littleEndian = nvlist[1] == 1; @@ -214,8 +213,7 @@ public sealed class ZFS : IFilesystem } // TODO: Decode native nvlist - static bool DecodeNvList(byte[] nvlist, out Dictionary decodedNvList, bool xdr, - bool littleEndian) + static bool DecodeNvList(byte[] nvlist, out Dictionary decodedNvList, bool xdr, bool littleEndian) { decodedNvList = new Dictionary(); @@ -226,7 +224,7 @@ public sealed class ZFS : IFilesystem if(!xdr) return false; - int offset = 8; + var offset = 8; while(offset < nvlist.Length) { @@ -242,13 +240,13 @@ public sealed class ZFS : IFilesystem offset += 4; item.decodedSize = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - uint nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); + var nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; if(nameLength % 4 > 0) - nameLength += 4 - (nameLength % 4); + nameLength += 4 - nameLength % 4; - byte[] nameBytes = new byte[nameLength]; + var nameBytes = new byte[nameLength]; Array.Copy(nvlist, offset, nameBytes, 0, nameLength); item.name = StringHandlers.CToString(nameBytes); offset += (int)nameLength; @@ -271,11 +269,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_BOOLEAN_VALUE: if(item.elements > 1) { - bool[] boolArray = new bool[item.elements]; + var boolArray = new bool[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset); + var temp = BigEndianBitConverter.ToUInt32(nvlist, offset); boolArray[i] = temp > 0; offset += 4; } @@ -284,7 +282,7 @@ public sealed class ZFS : IFilesystem } else { - uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset); + var temp = BigEndianBitConverter.ToUInt32(nvlist, offset); item.value = temp > 0; offset += 4; } @@ -296,7 +294,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT8_ARRAY: if(item.elements > 1) { - byte[] byteArray = new byte[item.elements]; + var byteArray = new byte[item.elements]; Array.Copy(nvlist, offset, byteArray, 0, item.elements); offset += (int)item.elements; @@ -315,11 +313,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_DOUBLE: if(item.elements > 1) { - double[] doubleArray = new double[item.elements]; + var doubleArray = new double[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - double temp = BigEndianBitConverter.ToDouble(nvlist, offset); + var temp = BigEndianBitConverter.ToDouble(nvlist, offset); doubleArray[i] = temp; offset += 8; } @@ -336,9 +334,9 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_HRTIME: if(item.elements > 1) { - DateTime[] hrtimeArray = new DateTime[item.elements]; + var hrtimeArray = new DateTime[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { DateTime temp = DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset)); @@ -351,8 +349,7 @@ public sealed class ZFS : IFilesystem } else { - item.value = - DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset)); + item.value = DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset)); offset += 8; } @@ -362,11 +359,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT16_ARRAY: if(item.elements > 1) { - short[] shortArray = new short[item.elements]; + var shortArray = new short[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - short temp = BigEndianBitConverter.ToInt16(nvlist, offset); + var temp = BigEndianBitConverter.ToInt16(nvlist, offset); shortArray[i] = temp; offset += 4; } @@ -384,11 +381,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT32_ARRAY: if(item.elements > 1) { - int[] intArray = new int[item.elements]; + var intArray = new int[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - int temp = BigEndianBitConverter.ToInt32(nvlist, offset); + var temp = BigEndianBitConverter.ToInt32(nvlist, offset); intArray[i] = temp; offset += 4; } @@ -406,11 +403,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT64_ARRAY: if(item.elements > 1) { - long[] longArray = new long[item.elements]; + var longArray = new long[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - long temp = BigEndianBitConverter.ToInt64(nvlist, offset); + var temp = BigEndianBitConverter.ToInt64(nvlist, offset); longArray[i] = temp; offset += 8; } @@ -428,11 +425,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT8_ARRAY: if(item.elements > 1) { - sbyte[] sbyteArray = new sbyte[item.elements]; + var sbyteArray = new sbyte[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - sbyte temp = (sbyte)nvlist[offset]; + var temp = (sbyte)nvlist[offset]; sbyteArray[i] = temp; offset++; } @@ -440,7 +437,7 @@ public sealed class ZFS : IFilesystem item.value = sbyteArray; if(sbyteArray.Length % 4 > 0) - offset += 4 - (sbyteArray.Length % 4); + offset += 4 - sbyteArray.Length % 4; } else { @@ -453,13 +450,13 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_STRING_ARRAY: if(item.elements > 1) { - string[] stringArray = new string[item.elements]; + var stringArray = new string[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - uint strLength = BigEndianBitConverter.ToUInt32(nvlist, offset); + var strLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - byte[] strBytes = new byte[strLength]; + var strBytes = new byte[strLength]; Array.Copy(nvlist, offset, strBytes, 0, strLength); stringArray[i] = StringHandlers.CToString(strBytes); offset += (int)strLength; @@ -472,9 +469,9 @@ public sealed class ZFS : IFilesystem } else { - uint strLength = BigEndianBitConverter.ToUInt32(nvlist, offset); + var strLength = BigEndianBitConverter.ToUInt32(nvlist, offset); offset += 4; - byte[] strBytes = new byte[strLength]; + var strBytes = new byte[strLength]; Array.Copy(nvlist, offset, strBytes, 0, strLength); item.value = StringHandlers.CToString(strBytes); offset += (int)strLength; @@ -488,11 +485,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT16_ARRAY: if(item.elements > 1) { - ushort[] ushortArray = new ushort[item.elements]; + var ushortArray = new ushort[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - ushort temp = BigEndianBitConverter.ToUInt16(nvlist, offset); + var temp = BigEndianBitConverter.ToUInt16(nvlist, offset); ushortArray[i] = temp; offset += 4; } @@ -510,11 +507,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT32_ARRAY: if(item.elements > 1) { - uint[] uintArray = new uint[item.elements]; + var uintArray = new uint[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset); + var temp = BigEndianBitConverter.ToUInt32(nvlist, offset); uintArray[i] = temp; offset += 4; } @@ -532,11 +529,11 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT64_ARRAY: if(item.elements > 1) { - ulong[] ulongArray = new ulong[item.elements]; + var ulongArray = new ulong[item.elements]; - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) { - ulong temp = BigEndianBitConverter.ToUInt64(nvlist, offset); + var temp = BigEndianBitConverter.ToUInt64(nvlist, offset); ulongArray[i] = temp; offset += 8; } @@ -554,7 +551,7 @@ public sealed class ZFS : IFilesystem if(item.elements > 1) goto default; - byte[] subListBytes = new byte[item.encodedSize - (offset - currOff)]; + var subListBytes = new byte[item.encodedSize - (offset - currOff)]; Array.Copy(nvlist, offset, subListBytes, 0, subListBytes.Length); if(DecodeNvList(subListBytes, out Dictionary subList, true, littleEndian)) @@ -566,7 +563,7 @@ public sealed class ZFS : IFilesystem break; default: - byte[] unknown = new byte[item.encodedSize - (offset - currOff)]; + var unknown = new byte[item.encodedSize - (offset - currOff)]; Array.Copy(nvlist, offset, unknown, 0, unknown.Length); item.value = unknown; offset = (int)(currOff + item.encodedSize); @@ -599,7 +596,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_BOOLEAN_ARRAY: case NVS_DataTypes.DATA_TYPE_BOOLEAN_VALUE: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((bool[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (bool)item.value).AppendLine(); @@ -610,7 +607,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT8: case NVS_DataTypes.DATA_TYPE_UINT8_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((byte[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (byte)item.value).AppendLine(); @@ -618,7 +615,7 @@ public sealed class ZFS : IFilesystem break; case NVS_DataTypes.DATA_TYPE_DOUBLE: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((double[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (double)item.value).AppendLine(); @@ -626,9 +623,8 @@ public sealed class ZFS : IFilesystem break; case NVS_DataTypes.DATA_TYPE_HRTIME: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) - sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((DateTime[])item.value)[i]). - AppendLine(); + for(var i = 0; i < item.elements; i++) + sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((DateTime[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (DateTime)item.value).AppendLine(); @@ -636,7 +632,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT16: case NVS_DataTypes.DATA_TYPE_INT16_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((short[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (short)item.value).AppendLine(); @@ -645,7 +641,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT32: case NVS_DataTypes.DATA_TYPE_INT32_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((int[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (int)item.value).AppendLine(); @@ -654,7 +650,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT64: case NVS_DataTypes.DATA_TYPE_INT64_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((long[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (long)item.value).AppendLine(); @@ -663,7 +659,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_INT8: case NVS_DataTypes.DATA_TYPE_INT8_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((sbyte[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (sbyte)item.value).AppendLine(); @@ -672,7 +668,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_STRING: case NVS_DataTypes.DATA_TYPE_STRING_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((string[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (string)item.value).AppendLine(); @@ -681,7 +677,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT16: case NVS_DataTypes.DATA_TYPE_UINT16_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((ushort[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (ushort)item.value).AppendLine(); @@ -690,7 +686,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT32: case NVS_DataTypes.DATA_TYPE_UINT32_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((uint[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (uint)item.value).AppendLine(); @@ -699,7 +695,7 @@ public sealed class ZFS : IFilesystem case NVS_DataTypes.DATA_TYPE_UINT64: case NVS_DataTypes.DATA_TYPE_UINT64_ARRAY: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((ulong[])item.value)[i]).AppendLine(); else sb.AppendFormat("{0} = {1}", item.name, (ulong)item.value).AppendLine(); @@ -707,8 +703,8 @@ public sealed class ZFS : IFilesystem break; case NVS_DataTypes.DATA_TYPE_NVLIST: if(item.elements == 1) - sb.AppendFormat("{0} =\n{1}", item.name, - PrintNvList((Dictionary)item.value)).AppendLine(); + sb.AppendFormat("{0} =\n{1}", item.name, PrintNvList((Dictionary)item.value)). + AppendLine(); else sb.AppendFormat("{0} = {1} elements nvlist[], unable to print", item.name, item.elements). AppendLine(); @@ -716,7 +712,7 @@ public sealed class ZFS : IFilesystem break; default: if(item.elements > 1) - for(int i = 0; i < item.elements; i++) + for(var i = 0; i < item.elements; i++) sb.AppendFormat("{0}[{1}] = Unknown data type {2}", item.name, i, item.dataType). AppendLine(); else @@ -769,15 +765,33 @@ public sealed class ZFS : IFilesystem enum NVS_DataTypes : uint { - DATA_TYPE_UNKNOWN = 0, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTE, - DATA_TYPE_INT16, DATA_TYPE_UINT16, DATA_TYPE_INT32, - DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64, - DATA_TYPE_STRING, DATA_TYPE_BYTE_ARRAY, DATA_TYPE_INT16_ARRAY, - DATA_TYPE_UINT16_ARRAY, DATA_TYPE_INT32_ARRAY, DATA_TYPE_UINT32_ARRAY, - DATA_TYPE_INT64_ARRAY, DATA_TYPE_UINT64_ARRAY, DATA_TYPE_STRING_ARRAY, - DATA_TYPE_HRTIME, DATA_TYPE_NVLIST, DATA_TYPE_NVLIST_ARRAY, - DATA_TYPE_BOOLEAN_VALUE, DATA_TYPE_INT8, DATA_TYPE_UINT8, - DATA_TYPE_BOOLEAN_ARRAY, DATA_TYPE_INT8_ARRAY, DATA_TYPE_UINT8_ARRAY, + DATA_TYPE_UNKNOWN = 0, + DATA_TYPE_BOOLEAN, + DATA_TYPE_BYTE, + DATA_TYPE_INT16, + DATA_TYPE_UINT16, + DATA_TYPE_INT32, + DATA_TYPE_UINT32, + DATA_TYPE_INT64, + DATA_TYPE_UINT64, + DATA_TYPE_STRING, + DATA_TYPE_BYTE_ARRAY, + DATA_TYPE_INT16_ARRAY, + DATA_TYPE_UINT16_ARRAY, + DATA_TYPE_INT32_ARRAY, + DATA_TYPE_UINT32_ARRAY, + DATA_TYPE_INT64_ARRAY, + DATA_TYPE_UINT64_ARRAY, + DATA_TYPE_STRING_ARRAY, + DATA_TYPE_HRTIME, + DATA_TYPE_NVLIST, + DATA_TYPE_NVLIST_ARRAY, + DATA_TYPE_BOOLEAN_VALUE, + DATA_TYPE_INT8, + DATA_TYPE_UINT8, + DATA_TYPE_BOOLEAN_ARRAY, + DATA_TYPE_INT8_ARRAY, + DATA_TYPE_UINT8_ARRAY, DATA_TYPE_DOUBLE } diff --git a/Aaru.Filesystems/dump.cs b/Aaru.Filesystems/dump.cs index cfd4543de..86f555b54 100644 --- a/Aaru.Filesystems/dump.cs +++ b/Aaru.Filesystems/dump.cs @@ -30,6 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,9 +45,6 @@ using Aaru.Console; using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -using ufs_daddr_t = System.Int32; - -namespace Aaru.Filesystems; /// /// Implements identification of a dump(8) image (virtual filesystem on a file) @@ -112,7 +113,7 @@ public sealed class dump : IFilesystem if(partition.Start != 0) return false; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -139,8 +140,7 @@ public sealed class dump : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -151,7 +151,7 @@ public sealed class dump : IFilesystem if(partition.Start != 0) return; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + var sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; @@ -168,8 +168,8 @@ public sealed class dump : IFilesystem spcl_aix aixHdr = Marshal.ByteArrayToStructureLittleEndian(sector); s_spcl newHdr = Marshal.ByteArrayToStructureLittleEndian(sector); - bool useOld = false; - bool useAix = false; + var useOld = false; + var useAix = false; if(newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || diff --git a/Aaru.Filesystems/exFAT.cs b/Aaru.Filesystems/exFAT.cs index b45347b7e..46fe3dc61 100644 --- a/Aaru.Filesystems/exFAT.cs +++ b/Aaru.Filesystems/exFAT.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from https://www.sans.org/reading-room/whitepapers/forensics/reverse-engineering-microsoft-exfat-file-system-33274 /// /// Implements detection of the exFAT filesystem @@ -87,8 +87,7 @@ public sealed class exFAT : IFilesystem } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -152,7 +151,7 @@ public sealed class exFAT : IFilesystem if(vbr.flags.HasFlag(VolumeFlags.MediaFailure)) sb.AppendLine("Underlying media presented errors"); - int count = 1; + var count = 1; foreach(OemParameter parameter in parametersTable.parameters) { @@ -187,7 +186,9 @@ public sealed class exFAT : IFilesystem [Flags] enum VolumeFlags : ushort { - SecondFatActive = 1, VolumeDirty = 2, MediaFailure = 4, + SecondFatActive = 1, + VolumeDirty = 2, + MediaFailure = 4, ClearToZero = 8 } diff --git a/Aaru.Filesystems/ext2FS.cs b/Aaru.Filesystems/ext2FS.cs index 56f9a093e..6601a7586 100644 --- a/Aaru.Filesystems/ext2FS.cs +++ b/Aaru.Filesystems/ext2FS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection of the Linux extended filesystem v2, v3 and v4 @@ -185,8 +185,8 @@ public sealed class ext2FS : IFilesystem if(sbSectorOff + partition.Start >= partition.End) return false; - int sbSizeInBytes = Marshal.SizeOf(); - uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); + int sbSizeInBytes = Marshal.SizeOf(); + var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; @@ -197,33 +197,32 @@ public sealed class ext2FS : IFilesystem if(errno != ErrorNumber.NoError) return false; - byte[] sb = new byte[sbSizeInBytes]; + var sb = new byte[sbSizeInBytes]; if(sbOff + sbSizeInBytes > sbSector.Length) return false; Array.Copy(sbSector, sbOff, sb, 0, sbSizeInBytes); - ushort magic = BitConverter.ToUInt16(sb, 0x038); + var magic = BitConverter.ToUInt16(sb, 0x038); return magic == EXT2_MAGIC || magic == EXT2_MAGIC_OLD; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; var sb = new StringBuilder(); - bool newExt2 = false; - bool ext3 = false; - bool ext4 = false; + var newExt2 = false; + var ext3 = false; + var ext4 = false; - int sbSizeInBytes = Marshal.SizeOf(); - uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); + int sbSizeInBytes = Marshal.SizeOf(); + var sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; @@ -237,7 +236,7 @@ public sealed class ext2FS : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] sblock = new byte[sbSizeInBytes]; + var sblock = new byte[sbSizeInBytes]; Array.Copy(sbSector, sbOff, sblock, 0, sbSizeInBytes); SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sblock); @@ -251,21 +250,19 @@ public sealed class ext2FS : IFilesystem break; case EXT2_MAGIC: - ext3 |= (supblk.ftr_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) == EXT3_FEATURE_COMPAT_HAS_JOURNAL || - (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) == EXT3_FEATURE_INCOMPAT_RECOVER || - (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) == - EXT3_FEATURE_INCOMPAT_JOURNAL_DEV; + ext3 |= (supblk.ftr_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) == EXT3_FEATURE_COMPAT_HAS_JOURNAL || + (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) == EXT3_FEATURE_INCOMPAT_RECOVER || + (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) == EXT3_FEATURE_INCOMPAT_JOURNAL_DEV; - if((supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) == EXT4_FEATURE_RO_COMPAT_HUGE_FILE || - (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) == EXT4_FEATURE_RO_COMPAT_GDT_CSUM || - (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_DIR_NLINK) == EXT4_FEATURE_RO_COMPAT_DIR_NLINK || - (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) == - EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE || - (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_64BIT) == EXT4_FEATURE_INCOMPAT_64BIT || - (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_MMP) == EXT4_FEATURE_INCOMPAT_MMP || - (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) == EXT4_FEATURE_INCOMPAT_FLEX_BG || - (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_EA_INODE) == EXT4_FEATURE_INCOMPAT_EA_INODE || - (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_DIRDATA) == EXT4_FEATURE_INCOMPAT_DIRDATA) + if((supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) == EXT4_FEATURE_RO_COMPAT_HUGE_FILE || + (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) == EXT4_FEATURE_RO_COMPAT_GDT_CSUM || + (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_DIR_NLINK) == EXT4_FEATURE_RO_COMPAT_DIR_NLINK || + (supblk.ftr_ro_compat & EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) == EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE || + (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_64BIT) == EXT4_FEATURE_INCOMPAT_64BIT || + (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_MMP) == EXT4_FEATURE_INCOMPAT_MMP || + (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) == EXT4_FEATURE_INCOMPAT_FLEX_BG || + (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_EA_INODE) == EXT4_FEATURE_INCOMPAT_EA_INODE || + (supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_DIRDATA) == EXT4_FEATURE_INCOMPAT_DIRDATA) { ext3 = false; ext4 = true; @@ -341,8 +338,8 @@ public sealed class ext2FS : IFilesystem else sb.AppendFormat("Volume was created for {0}", extOs).AppendLine(); - byte[] tempBytes = new byte[8]; - ulong blocks, reserved, free; + var tempBytes = new byte[8]; + ulong blocks, reserved, free; if((supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_64BIT) == EXT4_FEATURE_INCOMPAT_64BIT) { @@ -393,8 +390,7 @@ public sealed class ext2FS : IFilesystem supblk.block_size = 1024; sb.AppendFormat("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(); + 1024 << (int)supblk.block_size, blocks * (ulong)(1024 << (int)supblk.block_size)).AppendLine(); XmlFsType.Clusters = blocks; XmlFsType.ClusterSize = (uint)(1024 << (int)supblk.block_size); @@ -414,8 +410,8 @@ public sealed class ext2FS : IFilesystem supblk.mount_c).AppendLine(); if(!string.IsNullOrEmpty(StringHandlers.CToString(supblk.last_mount_dir, Encoding))) - sb.AppendFormat("Last mounted on: \"{0}\"", - StringHandlers.CToString(supblk.last_mount_dir, Encoding)).AppendLine(); + sb.AppendFormat("Last mounted on: \"{0}\"", StringHandlers.CToString(supblk.last_mount_dir, Encoding)). + AppendLine(); if(!string.IsNullOrEmpty(StringHandlers.CToString(supblk.mount_options, Encoding))) sb.AppendFormat("Last used mount options were: {0}", @@ -449,8 +445,7 @@ public sealed class ext2FS : IFilesystem if(supblk.write_t > 0) { - sb.AppendFormat("Last written on {0}", DateHandlers.UnixUnsignedToDateTime(supblk.write_t)). - AppendLine(); + sb.AppendFormat("Last written on {0}", DateHandlers.UnixUnsignedToDateTime(supblk.write_t)).AppendLine(); XmlFsType.ModificationDate = DateHandlers.UnixUnsignedToDateTime(supblk.write_t); XmlFsType.ModificationDateSpecified = true; @@ -573,9 +568,8 @@ public sealed class ext2FS : IFilesystem supblk.hash_seed_2 > 0 && supblk.hash_seed_3 > 0 && supblk.hash_seed_4 > 0) - sb.AppendFormat("Hash seed: {0:X8}{1:X8}{2:X8}{3:X8}, version {4}", supblk.hash_seed_1, - supblk.hash_seed_2, supblk.hash_seed_3, supblk.hash_seed_4, supblk.hash_version). - AppendLine(); + sb.AppendFormat("Hash seed: {0:X8}{1:X8}{2:X8}{3:X8}, 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 || (supblk.ftr_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) == EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) diff --git a/Aaru.Filesystems/extFS.cs b/Aaru.Filesystems/extFS.cs index dbc202a35..93e921e62 100644 --- a/Aaru.Filesystems/extFS.cs +++ b/Aaru.Filesystems/extFS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filesystems; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Schemas; -namespace Aaru.Filesystems; - // Information from the Linux kernel /// /// Implements detection of the Linux extended filesystem @@ -78,21 +78,20 @@ public sealed class extFS : IFilesystem if(errno != ErrorNumber.NoError) return false; - byte[] sb = new byte[512]; + var sb = new byte[512]; if(sbOff + 512 > sbSector.Length) return false; Array.Copy(sbSector, sbOff, sb, 0, 512); - ushort magic = BitConverter.ToUInt16(sb, 0x038); + var magic = BitConverter.ToUInt16(sb, 0x038); return magic == EXT_MAGIC; } /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, - Encoding encoding) + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; @@ -113,7 +112,7 @@ public sealed class extFS : IFilesystem if(errno != ErrorNumber.NoError) return; - byte[] sbSector = new byte[512]; + var sbSector = new byte[512]; Array.Copy(sblock, sbOff, sbSector, 0, 512); var extSb = new SuperBlock diff --git a/Aaru.Filters/Aaru.Filters.csproj b/Aaru.Filters/Aaru.Filters.csproj index 3ad655c92..fa4a263de 100644 --- a/Aaru.Filters/Aaru.Filters.csproj +++ b/Aaru.Filters/Aaru.Filters.csproj @@ -1,120 +1,118 @@  - - Debug - AnyCPU - 2.0 - {D571B8EF-903D-4353-BDD5-B834F9F029EF} - Library - Aaru.Filters - Aaru.Filters - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Filters - $(Version) - net6 - 10 - File filters used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {D571B8EF-903D-4353-BDD5-B834F9F029EF} + Library + Aaru.Filters + Aaru.Filters + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Filters + $(Version) + net6 + 10 + File filters used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index def6a1cf3..2659c4052 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filters; - /// /// Decodes AppleDouble files [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -183,7 +183,7 @@ public sealed class AppleDouble : IFilter if(prodosStream.Length > 26) { - byte[] prodosB = new byte[26]; + var prodosB = new byte[26]; prodosStream.Read(prodosB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); @@ -201,7 +201,7 @@ public sealed class AppleDouble : IFilter if(unixStream.Length > 26) { - byte[] unixB = new byte[26]; + var unixB = new byte[26]; unixStream.Read(unixB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); @@ -219,7 +219,7 @@ public sealed class AppleDouble : IFilter if(dosStream.Length > 26) { - byte[] dosB = new byte[26]; + var dosB = new byte[26]; dosStream.Read(dosB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); @@ -237,7 +237,7 @@ public sealed class AppleDouble : IFilter if(doslStream.Length > 26) { - byte[] doslB = new byte[26]; + var doslB = new byte[26]; doslStream.Read(doslB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); @@ -255,7 +255,7 @@ public sealed class AppleDouble : IFilter if(netatalkStream.Length > 26) { - byte[] netatalkB = new byte[26]; + var netatalkB = new byte[26]; netatalkStream.Read(netatalkB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); @@ -273,7 +273,7 @@ public sealed class AppleDouble : IFilter if(daveStream.Length > 26) { - byte[] daveB = new byte[26]; + var daveB = new byte[26]; daveStream.Read(daveB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); @@ -291,7 +291,7 @@ public sealed class AppleDouble : IFilter if(osxStream.Length > 26) { - byte[] osxB = new byte[26]; + var osxB = new byte[26]; osxStream.Read(osxB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); @@ -311,7 +311,7 @@ public sealed class AppleDouble : IFilter if(unarStream.Length <= 26) return false; - byte[] unarB = new byte[26]; + var unarB = new byte[26]; unarStream.Read(unarB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); @@ -371,7 +371,7 @@ public sealed class AppleDouble : IFilter if(prodosStream.Length > 26) { - byte[] prodosB = new byte[26]; + var prodosB = new byte[26]; prodosStream.Read(prodosB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); @@ -389,7 +389,7 @@ public sealed class AppleDouble : IFilter if(unixStream.Length > 26) { - byte[] unixB = new byte[26]; + var unixB = new byte[26]; unixStream.Read(unixB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); @@ -407,7 +407,7 @@ public sealed class AppleDouble : IFilter if(dosStream.Length > 26) { - byte[] dosB = new byte[26]; + var dosB = new byte[26]; dosStream.Read(dosB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); @@ -425,7 +425,7 @@ public sealed class AppleDouble : IFilter if(doslStream.Length > 26) { - byte[] doslB = new byte[26]; + var doslB = new byte[26]; doslStream.Read(doslB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); @@ -443,7 +443,7 @@ public sealed class AppleDouble : IFilter if(netatalkStream.Length > 26) { - byte[] netatalkB = new byte[26]; + var netatalkB = new byte[26]; netatalkStream.Read(netatalkB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); @@ -461,7 +461,7 @@ public sealed class AppleDouble : IFilter if(daveStream.Length > 26) { - byte[] daveB = new byte[26]; + var daveB = new byte[26]; daveStream.Read(daveB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); @@ -479,7 +479,7 @@ public sealed class AppleDouble : IFilter if(osxStream.Length > 26) { - byte[] osxB = new byte[26]; + var osxB = new byte[26]; osxStream.Read(osxB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); @@ -497,7 +497,7 @@ public sealed class AppleDouble : IFilter if(unarStream.Length > 26) { - byte[] unarB = new byte[26]; + var unarB = new byte[26]; unarStream.Read(unarB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); @@ -515,15 +515,15 @@ public sealed class AppleDouble : IFilter var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; fs.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - Entry[] entries = new Entry[_header.entries]; + var entries = new Entry[_header.entries]; - for(int i = 0; i < _header.entries; i++) + for(var i = 0; i < _header.entries; i++) { - byte[] entry = new byte[12]; + var entry = new byte[12]; fs.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } @@ -539,7 +539,7 @@ public sealed class AppleDouble : IFilter break; case EntryId.FileDates: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] datesB = new byte[16]; + var datesB = new byte[16]; fs.Read(datesB, 0, 16); FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); @@ -550,7 +550,7 @@ public sealed class AppleDouble : IFilter break; case EntryId.FileInfo: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] finfo = new byte[entry.length]; + var finfo = new byte[entry.length]; fs.Read(finfo, 0, finfo.Length); if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) @@ -578,8 +578,7 @@ public sealed class AppleDouble : IFilter { DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - LastWriteTime = - DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); + LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; @@ -609,12 +608,22 @@ public sealed class AppleDouble : IFilter enum EntryId : uint { - Invalid = 0, DataFork = 1, ResourceFork = 2, - RealName = 3, Comment = 4, Icon = 5, - ColorIcon = 6, FileInfo = 7, FileDates = 8, - FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11, - DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14, - DirectoryID = 15 + Invalid = 0, + DataFork = 1, + ResourceFork = 2, + RealName = 3, + Comment = 4, + Icon = 5, + ColorIcon = 6, + FileInfo = 7, + FileDates = 8, + FinderInfo = 9, + MacFileInfo = 10, + ProDOSFileInfo = 11, + DOSFileInfo = 12, + ShortName = 13, + AfpFileInfo = 14, + DirectoryID = 15 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index b9e8a1a57..bc1842c32 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filters; - /// /// Decodes AppleSingle files [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -174,7 +174,7 @@ public sealed class AppleSingle : IFilter buffer.Length < 26) return false; - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; Array.Copy(buffer, 0, hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); @@ -188,7 +188,7 @@ public sealed class AppleSingle : IFilter stream.Length < 26) return false; - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; stream.Seek(0, SeekOrigin.Begin); stream.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); @@ -207,7 +207,7 @@ public sealed class AppleSingle : IFilter if(fstream.Length < 26) return false; - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; fstream.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); @@ -222,15 +222,15 @@ public sealed class AppleSingle : IFilter var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; ms.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - Entry[] entries = new Entry[_header.entries]; + var entries = new Entry[_header.entries]; - for(int i = 0; i < _header.entries; i++) + for(var i = 0; i < _header.entries; i++) { - byte[] entry = new byte[12]; + var entry = new byte[12]; ms.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } @@ -247,7 +247,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileDates: ms.Seek(entry.offset, SeekOrigin.Begin); - byte[] datesB = new byte[16]; + var datesB = new byte[16]; ms.Read(datesB, 0, 16); FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); @@ -258,7 +258,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileInfo: ms.Seek(entry.offset, SeekOrigin.Begin); - byte[] finfo = new byte[entry.length]; + var finfo = new byte[entry.length]; ms.Read(finfo, 0, finfo.Length); if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) @@ -286,8 +286,7 @@ public sealed class AppleSingle : IFilter { DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - LastWriteTime = - DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); + LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; @@ -309,15 +308,15 @@ public sealed class AppleSingle : IFilter { stream.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; stream.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - Entry[] entries = new Entry[_header.entries]; + var entries = new Entry[_header.entries]; - for(int i = 0; i < _header.entries; i++) + for(var i = 0; i < _header.entries; i++) { - byte[] entry = new byte[12]; + var entry = new byte[12]; stream.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } @@ -334,7 +333,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileDates: stream.Seek(entry.offset, SeekOrigin.Begin); - byte[] datesB = new byte[16]; + var datesB = new byte[16]; stream.Read(datesB, 0, 16); FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); @@ -345,7 +344,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileInfo: stream.Seek(entry.offset, SeekOrigin.Begin); - byte[] finfo = new byte[entry.length]; + var finfo = new byte[entry.length]; stream.Read(finfo, 0, finfo.Length); if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) @@ -373,8 +372,7 @@ public sealed class AppleSingle : IFilter { DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - LastWriteTime = - DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); + LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; @@ -397,15 +395,15 @@ public sealed class AppleSingle : IFilter var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[26]; + var hdrB = new byte[26]; fs.Read(hdrB, 0, 26); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - Entry[] entries = new Entry[_header.entries]; + var entries = new Entry[_header.entries]; - for(int i = 0; i < _header.entries; i++) + for(var i = 0; i < _header.entries; i++) { - byte[] entry = new byte[12]; + var entry = new byte[12]; fs.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } @@ -422,7 +420,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileDates: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] datesB = new byte[16]; + var datesB = new byte[16]; fs.Read(datesB, 0, 16); FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); @@ -433,7 +431,7 @@ public sealed class AppleSingle : IFilter break; case AppleSingleEntryID.FileInfo: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] finfo = new byte[entry.length]; + var finfo = new byte[entry.length]; fs.Read(finfo, 0, finfo.Length); if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) @@ -461,8 +459,7 @@ public sealed class AppleSingle : IFilter { DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - LastWriteTime = - DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); + LastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; @@ -481,12 +478,22 @@ public sealed class AppleSingle : IFilter enum AppleSingleEntryID : uint { - Invalid = 0, DataFork = 1, ResourceFork = 2, - RealName = 3, Comment = 4, Icon = 5, - ColorIcon = 6, FileInfo = 7, FileDates = 8, - FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11, - DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14, - DirectoryID = 15 + Invalid = 0, + DataFork = 1, + ResourceFork = 2, + RealName = 3, + Comment = 4, + Icon = 5, + ColorIcon = 6, + FileInfo = 7, + FileDates = 8, + FinderInfo = 9, + MacFileInfo = 10, + ProDOSFileInfo = 11, + DOSFileInfo = 12, + ShortName = 13, + AfpFileInfo = 14, + DirectoryID = 15 } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filters/BZip2.cs b/Aaru.Filters/BZip2.cs index abc9b2511..c29195c63 100644 --- a/Aaru.Filters/BZip2.cs +++ b/Aaru.Filters/BZip2.cs @@ -30,15 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Ionic.BZip2; -namespace Aaru.Filters; - /// /// Decompress bz2 files while reading public class BZip2 : IFilter @@ -95,7 +94,7 @@ public class BZip2 : IFilter /// public bool Identify(Stream stream) { - byte[] buffer = new byte[4]; + var buffer = new byte[4]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 4); @@ -125,8 +124,8 @@ public class BZip2 : IFilter if(!File.Exists(path)) return false; - var stream = new FileStream(path, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[4]; + var stream = new FileStream(path, FileMode.Open, FileAccess.Read); + var buffer = new byte[4]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 4); diff --git a/Aaru.Filters/ForcedSeekStream.cs b/Aaru.Filters/ForcedSeekStream.cs index d1483e097..5b2a0cb55 100644 --- a/Aaru.Filters/ForcedSeekStream.cs +++ b/Aaru.Filters/ForcedSeekStream.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; -namespace Aaru.Filters; - /// /// ForcedSeekStream allows to seek a forward-readable stream (like System.IO.Compression streams) by doing the /// slow and known trick of rewinding and forward reading until arriving the desired position. @@ -105,7 +105,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream do { - byte[] buffer = new byte[BUFFER_LEN]; + var buffer = new byte[BUFFER_LEN]; read = _baseStream.Read(buffer, 0, BUFFER_LEN); _backStream.Write(buffer, 0, read); } while(read == BUFFER_LEN); @@ -131,13 +131,13 @@ public sealed class ForcedSeekStream : Stream where T : Stream _backStream.Position = _backStream.Length; long toPosition = position - _backStream.Position; - int fullBufferReads = (int)(toPosition / BUFFER_LEN); - int restToRead = (int)(toPosition % BUFFER_LEN); + var fullBufferReads = (int)(toPosition / BUFFER_LEN); + var restToRead = (int)(toPosition % BUFFER_LEN); byte[] buffer; var bufPos = 0; - var left = BUFFER_LEN; + int left = BUFFER_LEN; - for(int i = 0; i < fullBufferReads; i++) + for(var i = 0; i < fullBufferReads; i++) { buffer = new byte[BUFFER_LEN]; bufPos = 0; @@ -145,7 +145,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream while(left > 0) { - var done = _baseStream.Read(buffer, bufPos, left); + int done = _baseStream.Read(buffer, bufPos, left); left -= done; bufPos += done; } @@ -159,7 +159,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream while(left > 0) { - var done = _baseStream.Read(buffer, bufPos, left); + int done = _baseStream.Read(buffer, bufPos, left); left -= done; bufPos += done; } @@ -183,7 +183,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream if(_backStream.Position + count <= _backStream.Length) return _backStream.Read(buffer, offset, count); - var oldPosition = _backStream.Position; + long oldPosition = _backStream.Position; SetPosition(_backStream.Position + count); SetPosition(oldPosition); diff --git a/Aaru.Filters/GZip.cs b/Aaru.Filters/GZip.cs index 4aae13e57..09cffcf4c 100644 --- a/Aaru.Filters/GZip.cs +++ b/Aaru.Filters/GZip.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using System.IO.Compression; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.Filters; - /// /// Decompress gzip files while reading public sealed class GZip : IFilter @@ -83,7 +83,7 @@ public sealed class GZip : IFilter /// public bool Identify(Stream stream) { - byte[] buffer = new byte[3]; + var buffer = new byte[3]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 3); @@ -98,8 +98,8 @@ public sealed class GZip : IFilter if(!File.Exists(path)) return false; - var stream = new FileStream(path, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[3]; + var stream = new FileStream(path, FileMode.Open, FileAccess.Read); + var buffer = new byte[3]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 3); @@ -111,8 +111,8 @@ public sealed class GZip : IFilter /// public ErrorNumber Open(byte[] buffer) { - byte[] mtimeB = new byte[4]; - byte[] isizeB = new byte[4]; + var mtimeB = new byte[4]; + var isizeB = new byte[4]; _dataStream = new MemoryStream(buffer); BasePath = null; @@ -123,8 +123,8 @@ public sealed class GZip : IFilter _dataStream.Read(isizeB, 0, 4); _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtimeB, 0); - uint isize = BitConverter.ToUInt32(isizeB, 0); + var mtime = BitConverter.ToUInt32(mtimeB, 0); + var isize = BitConverter.ToUInt32(isizeB, 0); _decompressedSize = isize; CreationTime = DateHandlers.UnixUnsignedToDateTime(mtime); @@ -138,8 +138,8 @@ public sealed class GZip : IFilter /// public ErrorNumber Open(Stream stream) { - byte[] mtimeB = new byte[4]; - byte[] isizeB = new byte[4]; + var mtimeB = new byte[4]; + var isizeB = new byte[4]; _dataStream = stream; BasePath = null; @@ -150,8 +150,8 @@ public sealed class GZip : IFilter _dataStream.Read(isizeB, 0, 4); _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtimeB, 0); - uint isize = BitConverter.ToUInt32(isizeB, 0); + var mtime = BitConverter.ToUInt32(mtimeB, 0); + var isize = BitConverter.ToUInt32(isizeB, 0); _decompressedSize = isize; CreationTime = DateHandlers.UnixUnsignedToDateTime(mtime); @@ -165,8 +165,8 @@ public sealed class GZip : IFilter /// public ErrorNumber Open(string path) { - byte[] mtimeB = new byte[4]; - byte[] isizeB = new byte[4]; + var mtimeB = new byte[4]; + var isizeB = new byte[4]; _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); BasePath = System.IO.Path.GetFullPath(path); @@ -177,8 +177,8 @@ public sealed class GZip : IFilter _dataStream.Read(isizeB, 0, 4); _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtimeB, 0); - uint isize = BitConverter.ToUInt32(isizeB, 0); + var mtime = BitConverter.ToUInt32(mtimeB, 0); + var isize = BitConverter.ToUInt32(isizeB, 0); _decompressedSize = isize; var fi = new FileInfo(path); diff --git a/Aaru.Filters/LZip.cs b/Aaru.Filters/LZip.cs index 1cb47db0a..b7f2ab207 100644 --- a/Aaru.Filters/LZip.cs +++ b/Aaru.Filters/LZip.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using SharpCompress.Compressors; using SharpCompress.Compressors.LZMA; -namespace Aaru.Filters; - /// /// Decompress lzip files while reading public sealed class LZip : IFilter @@ -83,14 +83,13 @@ public sealed class LZip : IFilter /// public bool Identify(Stream stream) { - byte[] buffer = new byte[5]; + var buffer = new byte[5]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 5); stream.Seek(0, SeekOrigin.Begin); - return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && - buffer[4] == 0x01; + return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && buffer[4] == 0x01; } /// @@ -99,15 +98,14 @@ public sealed class LZip : IFilter if(!File.Exists(path)) return false; - var stream = new FileStream(path, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[5]; + var stream = new FileStream(path, FileMode.Open, FileAccess.Read); + var buffer = new byte[5]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, 5); stream.Seek(0, SeekOrigin.Begin); - return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && - buffer[4] == 0x01; + return buffer[0] == 0x4C && buffer[1] == 0x5A && buffer[2] == 0x49 && buffer[3] == 0x50 && buffer[4] == 0x01; } /// @@ -131,7 +129,7 @@ public sealed class LZip : IFilter BasePath = null; CreationTime = DateTime.UtcNow; LastWriteTime = CreationTime; - byte[] tmp = new byte[8]; + var tmp = new byte[8]; _dataStream.Seek(-16, SeekOrigin.End); _dataStream.Read(tmp, 0, 8); DataForkLength = BitConverter.ToInt64(tmp, 0); @@ -150,7 +148,7 @@ public sealed class LZip : IFilter var fi = new FileInfo(path); CreationTime = fi.CreationTimeUtc; LastWriteTime = fi.LastWriteTimeUtc; - byte[] tmp = new byte[8]; + var tmp = new byte[8]; _dataStream.Seek(-16, SeekOrigin.End); _dataStream.Read(tmp, 0, 8); DataForkLength = BitConverter.ToInt64(tmp, 0); diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index b4ca54d3b..3d2c5d87a 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -30,18 +30,17 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Filters; - // TODO: Interpret fdScript /// /// Decodes MacBinary files @@ -147,14 +146,13 @@ public sealed class MacBinary : IFilter buffer.Length < 128) return false; - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; Array.Copy(buffer, 0, hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && - _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && - _header.reserved == 0 && - (_header.dataLength > 0 || _header.resourceLength > 0)); + return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 && + _header.zero1 == 0 && _header.zero2 == 0 && _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0); } /// @@ -164,15 +162,14 @@ public sealed class MacBinary : IFilter stream.Length < 128) return false; - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; stream.Seek(0, SeekOrigin.Begin); stream.Read(hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && - _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && - _header.reserved == 0 && - (_header.dataLength > 0 || _header.resourceLength > 0)); + return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 && + _header.zero1 == 0 && _header.zero2 == 0 && _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0); } /// @@ -186,16 +183,15 @@ public sealed class MacBinary : IFilter if(fstream.Length < 128) return false; - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; fstream.Read(hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); fstream.Close(); - return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && - _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && - _header.reserved == 0 && - (_header.dataLength > 0 || _header.resourceLength > 0)); + return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 && + _header.zero1 == 0 && _header.zero2 == 0 && _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0); } /// @@ -204,7 +200,7 @@ public sealed class MacBinary : IFilter var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; ms.Read(hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); @@ -238,7 +234,7 @@ public sealed class MacBinary : IFilter { stream.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; stream.Read(hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); @@ -273,7 +269,7 @@ public sealed class MacBinary : IFilter var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[128]; + var hdrB = new byte[128]; fs.Read(hdrB, 0, 128); _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); diff --git a/Aaru.Filters/OffsetStream.cs b/Aaru.Filters/OffsetStream.cs index 3790149ee..6fe5dad43 100644 --- a/Aaru.Filters/OffsetStream.cs +++ b/Aaru.Filters/OffsetStream.cs @@ -30,15 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; -using System.IO; -using Microsoft.Win32.SafeHandles; #if !NETSTANDARD2_0 #endif namespace Aaru.Filters { + using System; + using System.IO; + using Microsoft.Win32.SafeHandles; + /// Creates a stream that is a subset of another stream. /// public sealed class OffsetStream : Stream diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index e051cb428..fef643665 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -42,8 +44,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Marshal = System.Runtime.InteropServices.Marshal; -namespace Aaru.Filters; - /// /// Decodes PCExchange files [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -122,24 +122,24 @@ public sealed class PcExchange : IFilter string baseFilename = System.IO.Path.GetFileName(path); - bool dataFound = false; - bool rsrcFound = false; + var dataFound = false; + var rsrcFound = false; var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), FileMode.Open, FileAccess.Read); while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new Entry(); - byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; + var datEntry = new Entry(); + var datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); // TODO: Add support for encoding on filters string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); - byte[] tmpDosNameB = new byte[8]; - byte[] tmpDosExtB = new byte[3]; + var tmpDosNameB = new byte[8]; + var tmpDosExtB = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8); Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3); @@ -154,9 +154,8 @@ public sealed class PcExchange : IFilter continue; dataFound |= - File.Exists(System.IO.Path.Combine(parentFolder, - macName ?? throw new InvalidOperationException())) || - File.Exists(System.IO.Path.Combine(parentFolder, dosName)) || + File.Exists(System.IO.Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())) || + File.Exists(System.IO.Path.Combine(parentFolder, dosName)) || File.Exists(System.IO.Path.Combine(parentFolder, dosNameLow)); rsrcFound |= File.Exists(System.IO.Path.Combine(parentFolder, RESOURCES, dosName)) || @@ -189,15 +188,15 @@ public sealed class PcExchange : IFilter while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new Entry(); - byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; + var datEntry = new Entry(); + var datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); - byte[] tmpDosNameB = new byte[8]; - byte[] tmpDosExtB = new byte[3]; + var tmpDosNameB = new byte[8]; + var tmpDosExtB = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8); Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3); diff --git a/Aaru.Filters/Register.cs b/Aaru.Filters/Register.cs index a66a53981..36e85fd0c 100644 --- a/Aaru.Filters/Register.cs +++ b/Aaru.Filters/Register.cs @@ -36,14 +36,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Filters; - /// public class Register : IPluginRegister { diff --git a/Aaru.Filters/SplitJoinStream.cs b/Aaru.Filters/SplitJoinStream.cs index 89718e4d3..8ef1fdba4 100644 --- a/Aaru.Filters/SplitJoinStream.cs +++ b/Aaru.Filters/SplitJoinStream.cs @@ -1,3 +1,5 @@ +namespace Aaru.Filters; + using System; using System.Collections.Generic; using System.Data; @@ -6,8 +8,6 @@ using System.Linq; using Aaru.CommonTypes.Interfaces; using Microsoft.Win32.SafeHandles; -namespace Aaru.Filters; - /// /// Implements a stream that joins two or more files (sequentially) as a single stream public class SplitJoinStream : Stream @@ -140,8 +140,8 @@ public class SplitJoinStream : Stream /// 4096. /// /// Specifies whether to use asynchronous I/O or synchronous I/O. - public void Add(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, - bool useAsync) => Add(new FileStream(path, mode, access, share, bufferSize, useAsync)); + public void Add(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) => + Add(new FileStream(path, mode, access, share, bufferSize, useAsync)); /// Adds the specified file to the end of the current stream /// A relative or absolute path for the file that the stream will encapsulate. @@ -257,13 +257,13 @@ public class SplitJoinStream : Stream } /// - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, - object state) => + public override IAsyncResult + BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => throw new NotSupportedException("Asynchronous I/O is not supported."); /// - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, - object state) => + public override IAsyncResult + BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => throw new NotSupportedException("Asynchronous I/O is not supported."); /// @@ -310,7 +310,7 @@ public class SplitJoinStream : Stream /// public override int Read(byte[] buffer, int offset, int count) { - int read = 0; + var read = 0; while(count > 0) { diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs index 834a10cbb..6d2ff2970 100644 --- a/Aaru.Filters/XZ.cs +++ b/Aaru.Filters/XZ.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using SharpCompress.Compressors.Xz; -namespace Aaru.Filters; - /// /// Decompress xz files while reading public sealed class XZ : IFilter @@ -83,8 +83,8 @@ public sealed class XZ : IFilter /// public bool Identify(Stream stream) { - byte[] buffer = new byte[6]; - byte[] footer = new byte[2]; + var buffer = new byte[6]; + var footer = new byte[2]; if(stream.Length < 8) return false; @@ -95,8 +95,8 @@ public sealed class XZ : IFilter stream.Read(footer, 0, 2); stream.Seek(0, SeekOrigin.Begin); - return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && - buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A; + return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && buffer[4] == 0x5A && + buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A; } /// @@ -105,9 +105,9 @@ public sealed class XZ : IFilter if(!File.Exists(path)) return false; - var stream = new FileStream(path, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[6]; - byte[] footer = new byte[2]; + 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; @@ -118,8 +118,8 @@ public sealed class XZ : IFilter stream.Read(footer, 0, 2); stream.Seek(0, SeekOrigin.Begin); - return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && - buffer[4] == 0x5A && buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A; + return buffer[0] == 0xFD && buffer[1] == 0x37 && buffer[2] == 0x7A && buffer[3] == 0x58 && buffer[4] == 0x5A && + buffer[5] == 0x00 && footer[0] == 0x59 && footer[1] == 0x5A; } /// @@ -200,7 +200,7 @@ public sealed class XZ : IFilter // Seek to footer backwards size field _dataStream.Seek(-8, SeekOrigin.End); - byte[] tmp = new byte[4]; + var tmp = new byte[4]; _dataStream.Read(tmp, 0, 4); uint backwardSize = (BitConverter.ToUInt32(tmp, 0) + 1) * 4; @@ -232,7 +232,7 @@ public sealed class XZ : IFilter sizeMax = 9; num = (ulong)(buf[0] & 0x7F); - int i = 0; + var i = 0; while((buf[i++] & 0x80) == 0x80) { diff --git a/Aaru.Filters/ZZZNoFilter.cs b/Aaru.Filters/ZZZNoFilter.cs index 01a330af3..6b8cef7d9 100644 --- a/Aaru.Filters/ZZZNoFilter.cs +++ b/Aaru.Filters/ZZZNoFilter.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Filters; + using System; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Filters; - /// /// No filter for reading files not recognized by any filter public sealed class ZZZNoFilter : IFilter diff --git a/Aaru.Gui/Aaru.Gui.csproj b/Aaru.Gui/Aaru.Gui.csproj index 07543178f..574baf79b 100644 --- a/Aaru.Gui/Aaru.Gui.csproj +++ b/Aaru.Gui/Aaru.Gui.csproj @@ -1,452 +1,452 @@  - - Aaru.Gui - Aaru.Gui - $(Version) - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru Data Preservation Suite - $(Version) - net6 - CS0649,CS0169 - 10 - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} built by {mname} in $(Configuration){!:, modified} - true - true - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %(Filename) - - - Designer - - - - Designer - - - Designer - - - Designer - - - Designer - - - Designer - - - About.xaml - - - Console.xaml - - - Encodings.xaml - - - DeviceInfo.xaml - - - FileSystem.xaml - - - ImageInfo.xaml - - - MediaInfo.xaml - - - Partition.xaml - - - Subdirectory.xaml - - - AtaInfo.xaml - - - BlurayInfo.xaml - - - CompactDiscInfo.xaml - - - DvdInfo.xaml - - - DvdWritableInfo.xaml - - - PcmciaInfo.xaml - - - ScsiInfo.xaml - - - XboxInfo.xaml - - - DecodeMediaTags.xaml - - - ImageChecksum.xaml - - - ImageConvert.xaml - - - ImageEntropy.xaml - - - ImageSidecar.xaml - - - ImageVerify.xaml - - - MediaDump.xaml - - - MediaScan.xaml - - - ViewSector.xaml - - - - - - - - LICENSE - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Aaru.Gui + Aaru.Gui + $(Version) + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru Data Preservation Suite + $(Version) + net6 + CS0649,CS0169 + 10 + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} built by {mname} in $(Configuration){!:, modified} + true + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(Filename) + + + Designer + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + About.xaml + + + Console.xaml + + + Encodings.xaml + + + DeviceInfo.xaml + + + FileSystem.xaml + + + ImageInfo.xaml + + + MediaInfo.xaml + + + Partition.xaml + + + Subdirectory.xaml + + + AtaInfo.xaml + + + BlurayInfo.xaml + + + CompactDiscInfo.xaml + + + DvdInfo.xaml + + + DvdWritableInfo.xaml + + + PcmciaInfo.xaml + + + ScsiInfo.xaml + + + XboxInfo.xaml + + + DecodeMediaTags.xaml + + + ImageChecksum.xaml + + + ImageConvert.xaml + + + ImageEntropy.xaml + + + ImageSidecar.xaml + + + ImageVerify.xaml + + + MediaDump.xaml + + + MediaScan.xaml + + + ViewSector.xaml + + + + + + + + LICENSE + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index bc9a5799f..7634ba224 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -30,6 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedParameter.Local + +namespace Aaru.Gui; + using System; using Aaru.Gui.ViewModels.Windows; using Aaru.Gui.Views.Windows; @@ -38,11 +45,6 @@ using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; -// ReSharper disable UnusedMember.Local -// ReSharper disable UnusedParameter.Local - -namespace Aaru.Gui; - public sealed class App : Application { public override void Initialize() => AvaloniaXamlLoader.Load(this); @@ -84,9 +86,9 @@ public sealed class App : Application void OnAboutClicked(object sender, EventArgs args) { if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime - { - MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } - })) + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteAboutCommand(); @@ -95,9 +97,9 @@ public sealed class App : Application void OnQuitClicked(object sender, EventArgs args) { if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime - { - MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } - })) + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteExitCommand(); @@ -106,9 +108,9 @@ public sealed class App : Application void OnPreferencesClicked(object sender, EventArgs args) { if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime - { - MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } - })) + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteSettingsCommand(); diff --git a/Aaru.Gui/Assets/Logos/Media/XGD2.svg b/Aaru.Gui/Assets/Logos/Media/XGD2.svg index fe9c4d1ff..1b652fb69 100644 --- a/Aaru.Gui/Assets/Logos/Media/XGD2.svg +++ b/Aaru.Gui/Assets/Logos/Media/XGD2.svg @@ -1,8 +1,8 @@ image/svg+xml image/svg+xml image/svg+xml diff --git a/Aaru.Gui/ConsoleHandler.cs b/Aaru.Gui/ConsoleHandler.cs index b8dea796a..c7b87fc61 100644 --- a/Aaru.Gui/ConsoleHandler.cs +++ b/Aaru.Gui/ConsoleHandler.cs @@ -31,14 +31,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui; + using System; using System.Collections.ObjectModel; using Aaru.Console; using JetBrains.Annotations; -namespace Aaru.Gui; - -internal static class ConsoleHandler +static class ConsoleHandler { static bool _debug; static bool _verbose; @@ -77,7 +77,7 @@ internal static class ConsoleHandler } } - public static ObservableCollection Entries { get; } = new ObservableCollection(); + public static ObservableCollection Entries { get; } = new(); internal static void Init() { diff --git a/Aaru.Gui/Controls/BlockMap.cs b/Aaru.Gui/Controls/BlockMap.cs index ee454e7ab..964c59b0e 100644 --- a/Aaru.Gui/Controls/BlockMap.cs +++ b/Aaru.Gui/Controls/BlockMap.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Controls; + using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -43,8 +45,6 @@ using Avalonia.Threading; using Avalonia.Visuals.Media.Imaging; using JetBrains.Annotations; -namespace Aaru.Gui.Controls; - // TODO: Partially fill clusters // TODO: React to size changes // TODO: Optimize block size to viewport @@ -385,10 +385,8 @@ public sealed class BlockMap : ItemsControl { if(e.NewValue != null && !(e.NewValue is IList<(ulong, double)>)) - { throw new ArgumentException("Items must be a IList<(ulong, double)> with ulong being the block and double being the time spent reading it, or NaN for an error."); - } base.ItemsChanged(e); @@ -420,13 +418,13 @@ public sealed class BlockMap : ItemsControl ulong clustersPerRow = (ulong)Width / BLOCK_SIZE; - bool allBlocksDrawn = false; + var allBlocksDrawn = false; for(ulong y = 0; y < Height && !allBlocksDrawn; y += BLOCK_SIZE) { for(ulong x = 0; x < Width; x += BLOCK_SIZE) { - ulong currentBlockValue = (y * clustersPerRow / BLOCK_SIZE) + (x / BLOCK_SIZE); + ulong currentBlockValue = y * clustersPerRow / BLOCK_SIZE + x / BLOCK_SIZE; if(currentBlockValue >= _maxBlocks || currentBlockValue >= Blocks) @@ -446,20 +444,20 @@ public sealed class BlockMap : ItemsControl using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null); using var ctx = new DrawingContext(ctxi, false); - int squareWidth = (sideLength - (2 * borderWidth)) / colors.Length; + int squareWidth = (sideLength - 2 * borderWidth) / colors.Length; int squareHeight = squareWidth; - int x = 0; - int y = 0; + var x = 0; + var y = 0; foreach(Color color in colors) { ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareHeight)); - x += squareWidth + (2 * borderWidth); + x += squareWidth + 2 * borderWidth; if(x >= sideLength) { x = 0; - y += squareHeight + (2 * borderWidth); + y += squareHeight + 2 * borderWidth; } } } diff --git a/Aaru.Gui/Main.cs b/Aaru.Gui/Main.cs index f490441e1..6b3773044 100644 --- a/Aaru.Gui/Main.cs +++ b/Aaru.Gui/Main.cs @@ -26,13 +26,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui; + using System.Text; using Avalonia; using Avalonia.Dialogs; using Avalonia.ReactiveUI; -namespace Aaru.Gui; - public static class Main { public static int Start(string[] args) diff --git a/Aaru.Gui/Models/DeviceModel.cs b/Aaru.Gui/Models/DeviceModel.cs index 5fb59f811..63703dbb4 100644 --- a/Aaru.Gui/Models/DeviceModel.cs +++ b/Aaru.Gui/Models/DeviceModel.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Aaru.Gui.ViewModels.Panels; using Avalonia.Media.Imaging; -namespace Aaru.Gui.Models; - public sealed class DeviceModel { public DeviceModel() => Media = new ObservableCollection(); diff --git a/Aaru.Gui/Models/DevicesRootModel.cs b/Aaru.Gui/Models/DevicesRootModel.cs index 165faba61..2529ba9d3 100644 --- a/Aaru.Gui/Models/DevicesRootModel.cs +++ b/Aaru.Gui/Models/DevicesRootModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.ObjectModel; - namespace Aaru.Gui.Models; +using System.Collections.ObjectModel; + public sealed class DevicesRootModel : RootModel { public DevicesRootModel() => Devices = new ObservableCollection(); diff --git a/Aaru.Gui/Models/FileModel.cs b/Aaru.Gui/Models/FileModel.cs index a7ee20a07..7e0986a6e 100644 --- a/Aaru.Gui/Models/FileModel.cs +++ b/Aaru.Gui/Models/FileModel.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System; using Aaru.CommonTypes.Structs; using JetBrains.Annotations; -namespace Aaru.Gui.Models; - public sealed class FileModel { public string Name { get; set; } diff --git a/Aaru.Gui/Models/FileSystemModel.cs b/Aaru.Gui/Models/FileSystemModel.cs index f3e636ee7..94b85444c 100644 --- a/Aaru.Gui/Models/FileSystemModel.cs +++ b/Aaru.Gui/Models/FileSystemModel.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Aaru.CommonTypes.Interfaces; using Aaru.Gui.ViewModels.Panels; -namespace Aaru.Gui.Models; - public sealed class FileSystemModel : RootModel { public FileSystemModel() => Roots = new ObservableCollection(); diff --git a/Aaru.Gui/Models/ImageModel.cs b/Aaru.Gui/Models/ImageModel.cs index 86732d980..725f243cd 100644 --- a/Aaru.Gui/Models/ImageModel.cs +++ b/Aaru.Gui/Models/ImageModel.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Aaru.CommonTypes.Interfaces; using Aaru.Gui.ViewModels.Panels; using Avalonia.Media.Imaging; -namespace Aaru.Gui.Models; - public sealed class ImageModel { public ImageModel() => PartitionSchemesOrFileSystems = new ObservableCollection(); diff --git a/Aaru.Gui/Models/ImagePluginModel.cs b/Aaru.Gui/Models/ImagePluginModel.cs index 200528554..93dca650a 100644 --- a/Aaru.Gui/Models/ImagePluginModel.cs +++ b/Aaru.Gui/Models/ImagePluginModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Interfaces; - namespace Aaru.Gui.Models; +using Aaru.CommonTypes.Interfaces; + public sealed class ImagePluginModel { public string Name => Plugin.Name; diff --git a/Aaru.Gui/Models/ImagesRootModel.cs b/Aaru.Gui/Models/ImagesRootModel.cs index bcddbd33e..b375097db 100644 --- a/Aaru.Gui/Models/ImagesRootModel.cs +++ b/Aaru.Gui/Models/ImagesRootModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.ObjectModel; - namespace Aaru.Gui.Models; +using System.Collections.ObjectModel; + public sealed class ImagesRootModel : RootModel { public ImagesRootModel() => Images = new ObservableCollection(); diff --git a/Aaru.Gui/Models/MediaModel.cs b/Aaru.Gui/Models/MediaModel.cs index c2fea59f1..8f94d4230 100644 --- a/Aaru.Gui/Models/MediaModel.cs +++ b/Aaru.Gui/Models/MediaModel.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using Aaru.Gui.ViewModels.Panels; using Avalonia.Media.Imaging; -namespace Aaru.Gui.Models; - public sealed class MediaModel { public Bitmap Icon { get; set; } diff --git a/Aaru.Gui/Models/MediaTagModel.cs b/Aaru.Gui/Models/MediaTagModel.cs index 6edc6ca5a..b0abafa97 100644 --- a/Aaru.Gui/Models/MediaTagModel.cs +++ b/Aaru.Gui/Models/MediaTagModel.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using Aaru.CommonTypes.Enums; using JetBrains.Annotations; -namespace Aaru.Gui.Models; - public sealed class MediaTagModel { public MediaTagType Tag { get; set; } diff --git a/Aaru.Gui/Models/PartitionModel.cs b/Aaru.Gui/Models/PartitionModel.cs index 492809801..2f216f19b 100644 --- a/Aaru.Gui/Models/PartitionModel.cs +++ b/Aaru.Gui/Models/PartitionModel.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Aaru.CommonTypes; using Aaru.Gui.ViewModels.Panels; using Avalonia.Media.Imaging; -namespace Aaru.Gui.Models; - public sealed class PartitionModel { public PartitionModel() => FileSystems = new ObservableCollection(); diff --git a/Aaru.Gui/Models/PartitionSchemeModel.cs b/Aaru.Gui/Models/PartitionSchemeModel.cs index 67a395471..6c045cf3f 100644 --- a/Aaru.Gui/Models/PartitionSchemeModel.cs +++ b/Aaru.Gui/Models/PartitionSchemeModel.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Avalonia.Media.Imaging; -namespace Aaru.Gui.Models; - public sealed class PartitionSchemeModel : RootModel { public PartitionSchemeModel() => Partitions = new ObservableCollection(); diff --git a/Aaru.Gui/Models/PluginModel.cs b/Aaru.Gui/Models/PluginModel.cs index 8bcd2183e..4598089b9 100644 --- a/Aaru.Gui/Models/PluginModel.cs +++ b/Aaru.Gui/Models/PluginModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.Gui.Models; +using System; + public sealed class PluginModel { public string Name { get; set; } diff --git a/Aaru.Gui/Models/SubdirectoryModel.cs b/Aaru.Gui/Models/SubdirectoryModel.cs index 2a086c656..da2884446 100644 --- a/Aaru.Gui/Models/SubdirectoryModel.cs +++ b/Aaru.Gui/Models/SubdirectoryModel.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Models; + using System.Collections.ObjectModel; using Aaru.CommonTypes.Interfaces; -namespace Aaru.Gui.Models; - public sealed class SubdirectoryModel { public SubdirectoryModel() => Subdirectories = new ObservableCollection(); diff --git a/Aaru.Gui/ResourceHandler.cs b/Aaru.Gui/ResourceHandler.cs index f8d83c739..887a5c22c 100644 --- a/Aaru.Gui/ResourceHandler.cs +++ b/Aaru.Gui/ResourceHandler.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui; + using System.IO; using System.Reflection; using JetBrains.Annotations; -namespace Aaru.Gui; - -internal static class ResourceHandler +static class ResourceHandler { [CanBeNull] internal static Stream GetResourceStream([NotNull] string resourcePath) => diff --git a/Aaru.Gui/ViewLocator.cs b/Aaru.Gui/ViewLocator.cs index 31d1fe79a..ff3e1459a 100644 --- a/Aaru.Gui/ViewLocator.cs +++ b/Aaru.Gui/ViewLocator.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui; + using System; using Aaru.Gui.ViewModels; using Avalonia.Controls; using Avalonia.Controls.Templates; using JetBrains.Annotations; -namespace Aaru.Gui; - public sealed class ViewLocator : IDataTemplate { public bool SupportsRecycling => false; @@ -53,9 +53,7 @@ public sealed class ViewLocator : IDataTemplate var type = Type.GetType(name); 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 0b56adb0b..b7911b2c5 100644 --- a/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System; using System.Collections.ObjectModel; using System.Diagnostics; @@ -43,8 +45,6 @@ using Aaru.Gui.Views.Dialogs; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class AboutViewModel : ViewModelBase { readonly About _view; diff --git a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs index 598e3baad..5da29817f 100644 --- a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -43,17 +45,16 @@ using JetBrains.Annotations; using MessageBox.Avalonia; using MessageBox.Avalonia.Enums; using ReactiveUI; +using Console = Aaru.Gui.Views.Dialogs.Console; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class ConsoleViewModel : ViewModelBase { - readonly Views.Dialogs.Console _view; - bool _debugChecked; + readonly Console _view; + bool _debugChecked; - public ConsoleViewModel(Views.Dialogs.Console view) + public ConsoleViewModel(Console view) { _view = view; SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand); diff --git a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs index d736d1f99..7c6ecefbb 100644 --- a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs @@ -30,7 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; +namespace Aaru.Gui.ViewModels.Dialogs; + using System.Collections.ObjectModel; using System.Linq; using System.Reactive; @@ -41,8 +42,6 @@ using Aaru.Gui.Views.Dialogs; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class EncodingsViewModel : ViewModelBase { readonly Encodings _view; @@ -55,7 +54,7 @@ public sealed class EncodingsViewModel : ViewModelBase Task.Run(() => { - List encodings = Encoding.GetEncodings().Select(info => new EncodingModel + var encodings = Encoding.GetEncodings().Select(info => new EncodingModel { Name = info.Name, DisplayName = info.GetEncoding().EncodingName diff --git a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs index d299df772..e64946df3 100644 --- a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System.IO; using System.Reactive; using System.Reflection; @@ -37,8 +39,6 @@ using Aaru.Gui.Views.Dialogs; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class LicenseViewModel : ViewModelBase { readonly LicenseDialog _view; diff --git a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs index 46cfe13e8..bdcc005dc 100644 --- a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System.Collections.ObjectModel; using System.Reactive; using System.Reflection; @@ -40,8 +42,6 @@ using Aaru.Gui.Views.Dialogs; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class PluginsViewModel : ViewModelBase { readonly PluginsDialog _view; diff --git a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs index d5ee44a1c..7910ebc2b 100644 --- a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System.Reactive; using Aaru.Gui.Views.Dialogs; using Aaru.Settings; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class SettingsViewModel : ViewModelBase { readonly SettingsDialog _view; @@ -61,22 +61,22 @@ public sealed class SettingsViewModel : ViewModelBase { _view = view; GdprVisible = gdprChange; - SaveReportsGloballyChecked = Settings.Settings.Current.SaveReportsGlobally; - ShareReportsChecked = Settings.Settings.Current.ShareReports; + SaveReportsGloballyChecked = Settings.Current.SaveReportsGlobally; + ShareReportsChecked = Settings.Current.ShareReports; - if(Settings.Settings.Current.Stats != null) + if(Settings.Current.Stats != null) { SaveStatsChecked = true; - ShareStatsChecked = Settings.Settings.Current.Stats.ShareStats; - CommandStatsChecked = Settings.Settings.Current.Stats.CommandStats; - DeviceStatsChecked = Settings.Settings.Current.Stats.DeviceStats; - FilesystemStatsChecked = Settings.Settings.Current.Stats.FilesystemStats; - FilterStatsChecked = Settings.Settings.Current.Stats.FilterStats; - MediaImageStatsChecked = Settings.Settings.Current.Stats.MediaImageStats; - MediaScanStatsChecked = Settings.Settings.Current.Stats.MediaScanStats; - PartitionStatsChecked = Settings.Settings.Current.Stats.PartitionStats; - MediaStatsChecked = Settings.Settings.Current.Stats.MediaStats; - VerifyStatsChecked = Settings.Settings.Current.Stats.VerifyStats; + ShareStatsChecked = Settings.Current.Stats.ShareStats; + CommandStatsChecked = Settings.Current.Stats.CommandStats; + DeviceStatsChecked = Settings.Current.Stats.DeviceStats; + FilesystemStatsChecked = Settings.Current.Stats.FilesystemStats; + FilterStatsChecked = Settings.Current.Stats.FilterStats; + MediaImageStatsChecked = Settings.Current.Stats.MediaImageStats; + MediaScanStatsChecked = Settings.Current.Stats.MediaScanStats; + PartitionStatsChecked = Settings.Current.Stats.PartitionStats; + MediaStatsChecked = Settings.Current.Stats.MediaStats; + VerifyStatsChecked = Settings.Current.Stats.VerifyStats; } else SaveStatsChecked = false; @@ -108,8 +108,7 @@ we must give you the following information about Aaru and ask if you want to opt in some information sharing."; [NotNull] - public string GdprText2 => - @"Disclaimer: Because Aaru is an open source software this information, and therefore, + public string GdprText2 => @"Disclaimer: Because Aaru is an open source software this information, and therefore, compliance with GDPR only holds true if you obtained a certificated copy from its original authors. In case of doubt, close Aaru now and ask in our IRC support channel."; @@ -266,11 +265,11 @@ pool with no way of using them to identify you."; void ExecuteSaveCommand() { - Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked; - Settings.Settings.Current.ShareReports = ShareReportsChecked; + Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked; + Settings.Current.ShareReports = ShareReportsChecked; if(SaveStatsChecked) - Settings.Settings.Current.Stats = new StatsSettings + Settings.Current.Stats = new StatsSettings { ShareStats = ShareStatsChecked, CommandStats = CommandStatsChecked, @@ -284,10 +283,10 @@ pool with no way of using them to identify you."; VerifyStats = VerifyStatsChecked }; else - Settings.Settings.Current.Stats = null; + Settings.Current.Stats = null; - Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL; - Settings.Settings.SaveSettings(); + Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL; + Settings.SaveSettings(); _view.Close(); } diff --git a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs index 32707bf89..f1ca5c966 100644 --- a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Dialogs; + using System.Collections.ObjectModel; using System.Linq; using System.Reactive; @@ -37,12 +39,11 @@ using Aaru.Database; using Aaru.Database.Models; using Aaru.Gui.Models; using Aaru.Gui.Views.Dialogs; +using Aaru.Settings; using JetBrains.Annotations; using ReactiveUI; using NameCountModel = Aaru.Gui.Models.NameCountModel; -namespace Aaru.Gui.ViewModels.Dialogs; - public sealed class StatisticsViewModel : ViewModelBase { readonly StatisticsDialog _view; @@ -97,7 +98,7 @@ public sealed class StatisticsViewModel : ViewModelBase Devices = new ObservableCollection(); Medias = new ObservableCollection(); CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); if(ctx.Commands.Any()) { @@ -163,8 +164,8 @@ 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); @@ -196,8 +197,8 @@ 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); @@ -207,8 +208,8 @@ 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); @@ -218,8 +219,8 @@ 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); @@ -251,8 +252,8 @@ 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); @@ -262,8 +263,8 @@ 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); @@ -273,8 +274,8 @@ 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); diff --git a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs index 0fcf6712f..35cb69984 100644 --- a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Panels; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Avalonia.Controls; using ReactiveUI; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; -namespace Aaru.Gui.ViewModels.Panels; - public sealed class DeviceInfoViewModel : ViewModelBase { readonly DeviceInfo _devInfo; @@ -175,31 +175,26 @@ public sealed class DeviceInfoViewModel : ViewModelBase } if(devInfo.IsPcmcia) - { PcmciaInfo = new PcmciaInfo { DataContext = new PcmciaInfoViewModel(devInfo.Cis, _view) }; - } if(devInfo.AtaIdentify != null || devInfo.AtapiIdentify != null) - { AtaInfo = new AtaInfo { DataContext = new AtaInfoViewModel(devInfo.AtaIdentify, devInfo.AtapiIdentify, devInfo.AtaMcptError, _view) }; - } if(devInfo.ScsiInquiryData != null) { 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) @@ -238,8 +233,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase { PlextorPoweRecRecommendedVisible = true; - PlextorPoweRecRecommended = - $"{devInfo.PlextorFeatures.PoweRecRecommendedSpeed} Kb/sec."; + PlextorPoweRecRecommended = $"{devInfo.PlextorFeatures.PoweRecRecommendedSpeed} Kb/sec."; } if(devInfo.PlextorFeatures.PoweRecSelected > 0) @@ -298,9 +292,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase PlextorSpeedRead = devInfo.PlextorFeatures.SpeedRead; if(devInfo.PlextorFeatures.SpeedRead) - { PlextorSpeedEnabled = devInfo.PlextorFeatures.SpeedReadEnabled; - } PlextorHiding = devInfo.PlextorFeatures.Hiding; @@ -340,17 +332,14 @@ public sealed class DeviceInfoViewModel : ViewModelBase if(devInfo.BlockLimits != null) { - BlockLimits.BlockLimitsData? - blockLimits = Decoders.SCSI.SSC.BlockLimits.Decode(devInfo.BlockLimits); + BlockLimits.BlockLimitsData? blockLimits = Decoders.SCSI.SSC.BlockLimits.Decode(devInfo.BlockLimits); if(blockLimits.HasValue) { Ssc = true; if(blockLimits.Value.minBlockLen == blockLimits.Value.maxBlockLen) - { MinBlockSize = $"Device's block size is fixed at {blockLimits.Value.minBlockLen} bytes"; - } else { MaxBlockSize = blockLimits.Value.maxBlockLen > 0 @@ -360,26 +349,20 @@ public sealed class DeviceInfoViewModel : ViewModelBase MinBlockSize = $"Device's minimum block size is {blockLimits.Value.minBlockLen} bytes"; if(blockLimits.Value.granularity > 0) - { BlockSizeGranularity = $"Device's needs a block size granularity of 2^{blockLimits.Value.granularity} ({Math.Pow(2, blockLimits.Value.granularity)}) bytes"; - } } } } if(devInfo.DensitySupport != null) if(devInfo.DensitySupportHeader.HasValue) - { Densities = DensitySupport.PrettifyDensity(devInfo.DensitySupportHeader); - } if(devInfo.MediumDensitySupport != null) { if(devInfo.MediaTypeSupportHeader.HasValue) - { MediumTypes = DensitySupport.PrettifyMediumType(devInfo.MediaTypeSupportHeader); - } MediumDensity = DensitySupport.PrettifyMediumType(devInfo.MediumDensitySupport); } diff --git a/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs b/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs index 32e9c4112..8afab1640 100644 --- a/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/FileSystemViewModel.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Panels; + using JetBrains.Annotations; using Schemas; -namespace Aaru.Gui.ViewModels.Panels; - public sealed class FileSystemViewModel { public FileSystemViewModel([NotNull] FileSystemType xmlFsType, string information) diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 74e12497d..d8fd19b7e 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Panels; + using System; using System.Collections.ObjectModel; using System.Linq; @@ -58,8 +60,6 @@ using Schemas; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.Gui.ViewModels.Panels; - public sealed class ImageInfoViewModel : ViewModelBase { readonly IFilter _filter; @@ -278,7 +278,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != toc.Length) { - byte[] tmp = new byte[toc.Length + 2]; + var tmp = new byte[toc.Length + 2]; Array.Copy(toc, 0, tmp, 2, toc.Length); tmp[0] = (byte)((toc.Length & 0xFF00) >> 8); tmp[1] = (byte)(toc.Length & 0xFF); @@ -300,7 +300,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != fullToc.Length) { - byte[] tmp = new byte[fullToc.Length + 2]; + var tmp = new byte[fullToc.Length + 2]; Array.Copy(fullToc, 0, tmp, 2, fullToc.Length); tmp[0] = (byte)((fullToc.Length & 0xFF00) >> 8); tmp[1] = (byte)(fullToc.Length & 0xFF); @@ -322,7 +322,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 2 != pma.Length) { - byte[] tmp = new byte[pma.Length + 2]; + var tmp = new byte[pma.Length + 2]; Array.Copy(pma, 0, tmp, 2, pma.Length); tmp[0] = (byte)((pma.Length & 0xFF00) >> 8); tmp[1] = (byte)(pma.Length & 0xFF); @@ -341,7 +341,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 4 != atip.Length) { - byte[] tmp = new byte[atip.Length + 4]; + var tmp = new byte[atip.Length + 4]; Array.Copy(atip, 0, tmp, 4, atip.Length); tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24); tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16); @@ -364,7 +364,7 @@ public sealed class ImageInfoViewModel : ViewModelBase if(dataLen + 4 != cdtext.Length) { - byte[] tmp = new byte[cdtext.Length + 4]; + var tmp = new byte[cdtext.Length + 4]; Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); @@ -486,11 +486,10 @@ public sealed class ImageInfoViewModel : ViewModelBase { DataContext = new DvdWritableInfoViewModel(imageFormat.Info.MediaType, dvdRamDds, dvdRamCartridgeStatus, dvdRamSpareArea, lastBorderOutRmd, dvdPreRecordedInfo, - dvdrMediaIdentifier, dvdrPhysicalInformation, - hddvdrMediumStatus, null, dvdrLayerCapacity, - dvdrDlMiddleZoneStart, dvdrDlJumpIntervalSize, - dvdrDlManualLayerJumpStartLba, null, dvdPlusAdip, dvdPlusDcb, - view) + dvdrMediaIdentifier, dvdrPhysicalInformation, hddvdrMediumStatus, + null, dvdrLayerCapacity, dvdrDlMiddleZoneStart, + dvdrDlJumpIntervalSize, dvdrDlManualLayerJumpStartLba, null, + dvdPlusAdip, dvdPlusDcb, view) }; byte[] blurayBurstCuttingArea = null; @@ -525,8 +524,8 @@ public sealed class ImageInfoViewModel : ViewModelBase BlurayInfo = new BlurayInfo { DataContext = new BlurayInfoViewModel(blurayDiscInformation, blurayBurstCuttingArea, blurayDds, - blurayCartridgeStatus, bluraySpareAreaInformation, - blurayPowResources, blurayTrackResources, null, null, view) + blurayCartridgeStatus, bluraySpareAreaInformation, blurayPowResources, + blurayTrackResources, null, null, view) }; byte[] xboxDmi = null; diff --git a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs index f97b960ee..5e25ef0c8 100644 --- a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Panels; + using System; using System.Collections.Generic; using System.IO; @@ -48,8 +50,6 @@ using MessageBox.Avalonia.Enums; using ReactiveUI; using ScsiInfo = Aaru.Core.Media.Info.ScsiInfo; -namespace Aaru.Gui.ViewModels.Panels; - public sealed class MediaInfoViewModel : ViewModelBase { readonly string _devicePath; @@ -127,7 +127,7 @@ public sealed class MediaInfoViewModel : ViewModelBase { var sbSerial = new StringBuilder(); - for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++) + for(var i = 4; i < scsiInfo.MediaSerialNumber.Length; i++) sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]); MediaSerial = sbSerial.ToString(); @@ -159,18 +159,17 @@ public sealed class MediaInfoViewModel : ViewModelBase { 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) + 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.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi, - scsiInfo.DvdCmi, scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca, - scsiInfo.DvdAacs, scsiInfo.DecodedPfi, _view) + DataContext = new DvdInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi, scsiInfo.DvdCmi, + scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca, scsiInfo.DvdAacs, + scsiInfo.DecodedPfi, _view) }; XboxInfo = new XboxInfo @@ -184,8 +183,7 @@ public sealed class MediaInfoViewModel : ViewModelBase DataContext = new DvdWritableInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdRamDds, scsiInfo.DvdRamCartridgeStatus, scsiInfo.DvdRamSpareArea, scsiInfo.LastBorderOutRmd, scsiInfo.DvdPreRecordedInfo, - scsiInfo.DvdrMediaIdentifier, - scsiInfo.DvdrPhysicalInformation, + scsiInfo.DvdrMediaIdentifier, scsiInfo.DvdrPhysicalInformation, scsiInfo.HddvdrMediumStatus, scsiInfo.HddvdrLastRmd, scsiInfo.DvdrLayerCapacity, scsiInfo.DvdrDlMiddleZoneStart, scsiInfo.DvdrDlJumpIntervalSize, @@ -426,8 +424,8 @@ public sealed class MediaInfoViewModel : ViewModelBase case CommonTypes.MediaType.GDR: case CommonTypes.MediaType.GDROM: await MessageBoxManager. - GetMessageBoxStandardWindow("Error", "GD-ROM scan support is not yet implemented.", - ButtonEnum.Ok, Icon.Error).ShowDialog(_view); + GetMessageBoxStandardWindow("Error", "GD-ROM scan support is not yet implemented.", ButtonEnum.Ok, + Icon.Error).ShowDialog(_view); return; @@ -436,8 +434,8 @@ public sealed class MediaInfoViewModel : ViewModelBase case CommonTypes.MediaType.XGD2: case CommonTypes.MediaType.XGD3: await MessageBoxManager. - GetMessageBoxStandardWindow("Error", "Scanning Xbox discs is not yet supported.", - ButtonEnum.Ok, Icon.Error).ShowDialog(_view); + GetMessageBoxStandardWindow("Error", "Scanning Xbox discs is not yet supported.", ButtonEnum.Ok, + Icon.Error).ShowDialog(_view); return; } diff --git a/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs b/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs index 01d6cad2f..e3e861436 100644 --- a/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/PartitionViewModel.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; - namespace Aaru.Gui.ViewModels.Panels; +using Aaru.CommonTypes; + public sealed class PartitionViewModel { public PartitionViewModel(Partition partition) diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index e475870d3..45988b46b 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Panels; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -49,8 +51,6 @@ using MessageBox.Avalonia.Enums; using ReactiveUI; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; -namespace Aaru.Gui.ViewModels.Panels; - public sealed class SubdirectoryViewModel { readonly SubdirectoryModel _model; @@ -180,7 +180,7 @@ public sealed class SubdirectoryViewModel else chars = new char[filename.Length]; - for(int ci = 0; ci < chars.Length; ci++) + for(var ci = 0; ci < chars.Length; ci++) switch(filename[ci]) { case '<': @@ -279,8 +279,8 @@ public sealed class SubdirectoryViewModel catch(IOException) { mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot delete", - "Could not delete existing file.\nDo you want to continue?", - ButtonEnum.YesNo, Icon.Error).ShowDialog(_view); + "Could not delete existing file.\nDo you want to continue?", ButtonEnum.YesNo, + Icon.Error).ShowDialog(_view); if(mboxResult == ButtonResult.No) return; @@ -291,14 +291,13 @@ public sealed class SubdirectoryViewModel { byte[] outBuf = Array.Empty(); - ErrorNumber error = - _model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf); + ErrorNumber error = _model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf); if(error != ErrorNumber.NoError) { mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Error reading file", - $"Error {error} reading file.\nDo you want to continue?", - ButtonEnum.YesNo, Icon.Error).ShowDialog(_view); + $"Error {error} reading file.\nDo you want to continue?", ButtonEnum.YesNo, + Icon.Error).ShowDialog(_view); if(mboxResult == ButtonResult.No) return; @@ -346,8 +345,8 @@ public sealed class SubdirectoryViewModel catch(IOException) { mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot create file", - "Could not create destination file.\nDo you want to continue?", - ButtonEnum.YesNo, Icon.Error).ShowDialog(_view); + "Could not create destination file.\nDo you want to continue?", ButtonEnum.YesNo, + Icon.Error).ShowDialog(_view); if(mboxResult == ButtonResult.No) return; diff --git a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs index fe4a03ed3..bbe2c13bb 100644 --- a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.IO; using System.Reactive; @@ -38,16 +40,14 @@ using Avalonia.Controls; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class AtaInfoViewModel : ViewModelBase { readonly byte[] _ata; readonly byte[] _atapi; readonly Window _view; - public AtaInfoViewModel([CanBeNull] byte[] ataIdentify, byte[] atapiIdentify, - AtaErrorRegistersChs? ataMcptError, Window view) + public AtaInfoViewModel([CanBeNull] byte[] ataIdentify, byte[] atapiIdentify, AtaErrorRegistersChs? ataMcptError, + Window view) { SaveAtaBinaryCommand = ReactiveCommand.Create(ExecuteSaveAtaBinaryCommand); SaveAtaTextCommand = ReactiveCommand.Create(ExecuteSaveAtaTextCommand); @@ -91,16 +91,14 @@ public sealed class AtaInfoViewModel : ViewModelBase break; default: - AtaMcptText = - $"Device contains unknown media card type {ataMcptError.Value.DeviceHead & 0x07}"; + AtaMcptText = $"Device contains unknown media card type {ataMcptError.Value.DeviceHead & 0x07}"; break; } AtaMcptWriteProtectionChecked = (ataMcptError.Value.DeviceHead & 0x08) == 0x08; - ushort specificData = (ushort)((ataMcptError.Value.CylinderHigh * 0x100) + - ataMcptError.Value.CylinderLow); + var specificData = (ushort)(ataMcptError.Value.CylinderHigh * 0x100 + ataMcptError.Value.CylinderLow); AtaMcptSpecificDataText = $"Card specific data: 0x{specificData:X4}"; } diff --git a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs index 75a10ae81..512dee473 100644 --- a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.IO; using System.Reactive; @@ -39,8 +41,6 @@ using Avalonia.Controls; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class BlurayInfoViewModel { readonly byte[] _burstCuttingArea; @@ -75,8 +75,7 @@ public sealed class BlurayInfoViewModel SaveBlurayDdsCommand = ReactiveCommand.Create(ExecuteSaveBlurayDdsCommand); SaveBlurayCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveBlurayCartridgeStatusCommand); - SaveBluraySpareAreaInformationCommand = - ReactiveCommand.Create(ExecuteSaveBluraySpareAreaInformationCommand); + SaveBluraySpareAreaInformationCommand = ReactiveCommand.Create(ExecuteSaveBluraySpareAreaInformationCommand); SaveBlurayPowResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayPowResourcesCommand); SaveBlurayTrackResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayTrackResourcesCommand); diff --git a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs index af8ee046e..5aa4f9f7a 100644 --- a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -40,8 +42,6 @@ using Aaru.Gui.Models; using Avalonia.Controls; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class CompactDiscInfoViewModel : ViewModelBase { readonly byte[] _atipData; @@ -57,8 +57,8 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase byte[] rawToc, byte[] pma, byte[] cdTextLeadIn, TOC.CDTOC? decodedToc, ATIP.CDATIP decodedAtip, Session.CDSessionInfo? decodedSession, FullTOC.CDFullTOC? fullToc, CDTextOnLeadIn.CDText? decodedCdTextLeadIn, - DiscInformation.StandardDiscInformation? decodedCompactDiscInformation, - string mcn, Dictionary isrcs, Window view) + DiscInformation.StandardDiscInformation? decodedCompactDiscInformation, string mcn, + Dictionary isrcs, Window view) { _tocData = toc; _atipData = atip; @@ -100,14 +100,12 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase if(isrcs != null && isrcs.Count > 0) - { foreach(KeyValuePair isrc in isrcs) IsrcList.Add(new IsrcModel { Track = isrc.Key.ToString(), Isrc = isrc.Value }); - } MiscellaneousVisible = McnText != null || isrcs?.Count > 0 || pma != null; CdPmaVisible = pma != null; diff --git a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs index 9b0fc097d..adc9c3c3b 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.IO; using System.Reactive; @@ -39,8 +41,6 @@ using Avalonia.Controls; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class DvdInfoViewModel { readonly byte[] _dvdAacs; @@ -51,9 +51,8 @@ public sealed class DvdInfoViewModel readonly byte[] _hddvdCopyrightInformation; readonly Window _view; - public DvdInfoViewModel(MediaType mediaType, [CanBeNull] byte[] pfi, [CanBeNull] byte[] dmi, - [CanBeNull] byte[] cmi, [CanBeNull] byte[] hdCopyrightInformation, - [CanBeNull] byte[] bca, [CanBeNull] byte[] aacs, + public DvdInfoViewModel(MediaType mediaType, [CanBeNull] byte[] pfi, [CanBeNull] byte[] dmi, [CanBeNull] byte[] cmi, + [CanBeNull] byte[] hdCopyrightInformation, [CanBeNull] byte[] bca, [CanBeNull] byte[] aacs, PFI.PhysicalFormatInformation? decodedPfi, Window view) { _dvdPfi = pfi; diff --git a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs index ae63db73d..91906a732 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.IO; using System.Reactive; @@ -38,8 +40,6 @@ using Aaru.Decoders.DVD; using Avalonia.Controls; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class DvdWritableInfoViewModel { readonly byte[] _dvdLastBorderOutRmd; @@ -64,15 +64,14 @@ public sealed class DvdWritableInfoViewModel byte[] lastBorderOutRmd, byte[] preRecordedInfo, byte[] mediaIdentifier, byte[] physicalInformation, byte[] mediumStatus, byte[] hdLastRmd, byte[] layerCapacity, byte[] middleZoneStart, byte[] jumpIntervalSize, - byte[] manualLayerJumpStartLba, byte[] remapAnchorPoint, byte[] adip, - byte[] dcb, Window view) + byte[] manualLayerJumpStartLba, byte[] remapAnchorPoint, byte[] adip, byte[] dcb, + Window view) { _view = view; SaveDvdRamDdsCommand = ReactiveCommand.Create(ExecuteSaveDvdRamDdsCommand); SaveDvdRamCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveDvdRamCartridgeStatusCommand); - SaveDvdRamSpareAreaInformationCommand = - ReactiveCommand.Create(ExecuteSaveDvdRamSpareAreaInformationCommand); + SaveDvdRamSpareAreaInformationCommand = ReactiveCommand.Create(ExecuteSaveDvdRamSpareAreaInformationCommand); SaveLastBorderOutRmdCommand = ReactiveCommand.Create(ExecuteSaveLastBorderOutRmdCommand); SaveDvdPreRecordedInfoCommand = ReactiveCommand.Create(ExecuteSaveDvdPreRecordedInfoCommand); diff --git a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs index 618b98e9d..adf419b38 100644 --- a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -41,8 +43,6 @@ using Avalonia.Controls; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public class PcmciaInfoViewModel : ViewModelBase { readonly byte[] _cis; diff --git a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs index 7a7b006c3..f85f61bd3 100644 --- a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -45,8 +47,6 @@ using Avalonia.Controls; using ReactiveUI; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class ScsiInfoViewModel : ViewModelBase { readonly byte[] _configuration; @@ -311,8 +311,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase } case 0x21: { - if(StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).Trim() == - "CERTANCE") + if(StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).Trim() == "CERTANCE") decodedText = Modes.PrettifyCertanceModePage_21(page.PageResponse); else goto default; @@ -321,8 +320,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase } case 0x22: { - if(StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).Trim() == - "CERTANCE") + if(StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).Trim() == "CERTANCE") decodedText = Modes.PrettifyCertanceModePage_22(page.PageResponse); else goto default; @@ -426,10 +424,9 @@ public sealed class ScsiInfoViewModel : ViewModelBase } if(scsiEvpdPages != null) - { foreach(KeyValuePair page in scsiEvpdPages.OrderBy(t => t.Key)) { - string evpdPageTitle = ""; + var evpdPageTitle = ""; string evpdDecodedPage; if(page.Key >= 0x01 && @@ -504,44 +501,44 @@ public sealed class ScsiInfoViewModel : ViewModelBase evpdDecodedPage = EVPD.DecodePageB4(page.Value); } else if(page.Key == 0xC0 && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "quantum") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "quantum") { evpdPageTitle = "Quantum Firmware Build Information page"; evpdDecodedPage = EVPD.PrettifyPage_C0_Quantum(page.Value); } else if(page.Key == 0xC0 && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "seagate") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "seagate") { evpdPageTitle = "Seagate Firmware Numbers page"; evpdDecodedPage = EVPD.PrettifyPage_C0_Seagate(page.Value); } else if(page.Key == 0xC0 && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "ibm") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "ibm") { evpdPageTitle = "IBM Drive Component Revision Levels page"; evpdDecodedPage = EVPD.PrettifyPage_C0_IBM(page.Value); } else if(page.Key == 0xC1 && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "ibm") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "ibm") { evpdPageTitle = "IBM Drive Serial Numbers page"; evpdDecodedPage = EVPD.PrettifyPage_C1_IBM(page.Value); } else if((page.Key == 0xC0 || page.Key == 0xC1) && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "certance") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "certance") { evpdPageTitle = "Certance Drive Component Revision Levels page"; evpdDecodedPage = EVPD.PrettifyPage_C0_C1_Certance(page.Value); } else if((page.Key == 0xC2 || page.Key == 0xC3 || page.Key == 0xC4 || page.Key == 0xC5 || page.Key == 0xC6) && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "certance") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "certance") { switch(page.Key) { @@ -571,8 +568,8 @@ public sealed class ScsiInfoViewModel : ViewModelBase } else if((page.Key == 0xC0 || page.Key == 0xC1 || page.Key == 0xC2 || page.Key == 0xC3 || page.Key == 0xC4 || page.Key == 0xC5) && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "hp") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "hp") { switch(page.Key) { @@ -605,8 +602,8 @@ public sealed class ScsiInfoViewModel : ViewModelBase evpdDecodedPage = EVPD.PrettifyPage_C0_to_C5_HP(page.Value); } else if(page.Key == 0xDF && - StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant(). - Trim() == "certance") + StringHandlers.CToString(scsiInquiry.Value.VendorIdentification).ToLowerInvariant().Trim() == + "certance") { evpdPageTitle = "Certance drive status page"; evpdDecodedPage = EVPD.PrettifyPage_DF_Certance(page.Value); @@ -630,14 +627,12 @@ public sealed class ScsiInfoViewModel : ViewModelBase Description = evpdDecodedPage }); } - } if(_configuration != null) { Features.SeparatedFeatures ftr = Features.Separate(_configuration); - AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", - ftr.DataLength); + AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength); AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h", ftr.CurrentProfile); @@ -896,8 +891,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase }); } else - AaruConsole.DebugWriteLine("Device-Info command", - "GET CONFIGURATION returned no feature descriptors"); + AaruConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION returned no feature descriptors"); } } diff --git a/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs index cfc9a182c..17a486f9b 100644 --- a/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/SdMmcInfoViewModel.cs @@ -30,11 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; -using JetBrains.Annotations; - namespace Aaru.Gui.ViewModels.Tabs; +using Aaru.Decoders.MMC; +using JetBrains.Annotations; +using DeviceType = Aaru.CommonTypes.Enums.DeviceType; + public sealed class SdMmcInfoViewModel { public SdMmcInfoViewModel(DeviceType deviceType, [CanBeNull] byte[] cid, [CanBeNull] byte[] csd, @@ -47,16 +48,16 @@ public sealed class SdMmcInfoViewModel //Text = "MultiMediaCard"; if(cid != null) - CidText = Decoders.MMC.Decoders.PrettifyCID(cid); + CidText = Decoders.PrettifyCID(cid); if(csd != null) - CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd); + CsdText = Decoders.PrettifyCSD(csd); if(ocr != null) - OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr); + OcrText = Decoders.PrettifyOCR(ocr); if(extendedCsd != null) - ExtendedCsdText = Decoders.MMC.Decoders.PrettifyExtendedCSD(extendedCsd); + ExtendedCsdText = Decoders.PrettifyExtendedCSD(extendedCsd); } break; @@ -65,16 +66,16 @@ public sealed class SdMmcInfoViewModel //Text = "SecureDigital"; if(cid != null) - CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid); + CidText = Aaru.Decoders.SecureDigital.Decoders.PrettifyCID(cid); if(csd != null) - CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd); + CsdText = Aaru.Decoders.SecureDigital.Decoders.PrettifyCSD(csd); if(ocr != null) - OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr); + OcrText = Aaru.Decoders.SecureDigital.Decoders.PrettifyOCR(ocr); if(scr != null) - ScrText = Decoders.SecureDigital.Decoders.PrettifySCR(scr); + ScrText = Aaru.Decoders.SecureDigital.Decoders.PrettifySCR(scr); } break; diff --git a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs index 1888559c7..4f6e9dcd9 100644 --- a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Tabs; + using System.Collections.Generic; using System.IO; using System.Reactive; @@ -39,8 +41,6 @@ using Avalonia.Controls; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Tabs; - public sealed class XboxInfoViewModel { readonly Window _view; diff --git a/Aaru.Gui/ViewModels/ViewModelBase.cs b/Aaru.Gui/ViewModels/ViewModelBase.cs index e54d944f8..107e4ce02 100644 --- a/Aaru.Gui/ViewModels/ViewModelBase.cs +++ b/Aaru.Gui/ViewModels/ViewModelBase.cs @@ -30,8 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using ReactiveUI; - namespace Aaru.Gui.ViewModels; +using ReactiveUI; + public class ViewModelBase : ReactiveObject {} \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs index 7a344943a..dfe3bdada 100644 --- a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System.Collections.ObjectModel; using System.Text; using Aaru.CommonTypes; @@ -54,8 +56,6 @@ using DMI = Aaru.Decoders.Xbox.DMI; using Inquiry = Aaru.Decoders.SCSI.Inquiry; using Spare = Aaru.Decoders.DVD.Spare; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class DecodeMediaTagsViewModel : ViewModelBase { const int HEX_COLUMNS = 32; diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index 9c6008d03..5228de358 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.ObjectModel; using System.Reactive; @@ -45,8 +47,6 @@ using Avalonia.Threading; using ReactiveUI; using Schemas; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ImageChecksumViewModel : ViewModelBase { // How many sectors to read at once @@ -369,8 +369,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase async void DoWork() { - var opticalMediaImage = _inputFormat as IOpticalMediaImage; - bool formatHasTracks = false; + var opticalMediaImage = _inputFormat as IOpticalMediaImage; + var formatHasTracks = false; if(opticalMediaImage != null) try @@ -488,8 +488,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase AaruConsole.DebugWriteLine("Checksum command", "Track {0} starts at sector {1} and ends at sector {2}", - currentTrack.Sequence, currentTrack.StartSector, - currentTrack.EndSector); + currentTrack.Sequence, currentTrack.StartSector, currentTrack.EndSector); if(ChecksumTracksChecked) trackChecksum = new Checksum(enabledChecksums); @@ -515,8 +514,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase if(sectors - doneSectors >= SECTORS_TO_READ) { - errno = opticalMediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, - currentTrack.Sequence, out sector); + errno = opticalMediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, currentTrack.Sequence, + out sector); if(errno != ErrorNumber.NoError) { diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index 9917f92f8..6b04a6ecf 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -59,8 +61,6 @@ using Schemas; using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ImageConvertViewModel : ViewModelBase { readonly IMediaImage _inputFormat; @@ -570,7 +570,7 @@ public sealed class ImageConvertViewModel : ViewModelBase async void DoWork(object plugin) { - bool warning = false; + var warning = false; if(!(plugin is IWritableImage outputFormat)) { @@ -752,8 +752,8 @@ public sealed class ImageConvertViewModel : ViewModelBase Progress2Indeterminate = true; }); - if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, - _inputFormat.Info.Sectors, _inputFormat.Info.SectorSize)) + if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, _inputFormat.Info.Sectors, + _inputFormat.Info.SectorSize)) { await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", @@ -804,7 +804,8 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", $"Error {outputFormat.ErrorMessage} setting metadata, not continuing...", - icon: Icon.Error).ShowDialog(_view)); + icon: Icon.Error). + ShowDialog(_view)); AaruConsole.ErrorWriteLine("not continuing..."); @@ -835,8 +836,7 @@ public sealed class ImageConvertViewModel : ViewModelBase icon: Icon.Error). ShowDialog(_view)); - AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", - outputFormat.ErrorMessage); + AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", outputFormat.ErrorMessage); return; } @@ -868,8 +868,7 @@ public sealed class ImageConvertViewModel : ViewModelBase warning = true; if(errno == ErrorNumber.NoError) - AaruConsole.ErrorWriteLine("Error {0} writing media tag, continuing...", - outputFormat.ErrorMessage); + AaruConsole.ErrorWriteLine("Error {0} writing media tag, continuing...", outputFormat.ErrorMessage); else AaruConsole.ErrorWriteLine("Error {0} reading media tag, continuing...", errno); } @@ -984,8 +983,7 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", $"Error {errno} reading sector {doneSectors}, not continuing...", - icon: Icon.Error). - ShowDialog(_view)); + icon: Icon.Error).ShowDialog(_view)); AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno, doneSectors); @@ -1018,8 +1016,7 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", $"Error {errno} reading sector {doneSectors}, not continuing...", - icon: Icon.Error). - ShowDialog(_view)); + icon: Icon.Error).ShowDialog(_view)); AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno, doneSectors); @@ -1171,9 +1168,10 @@ public sealed class ImageConvertViewModel : ViewModelBase 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); + 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); if(indexesChanged) outputOptical.SetTracks(tracks.ToList()); @@ -1224,7 +1222,8 @@ 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); + outputFormat as IWritableOpticalImage, false, false, null, null, + smallestPregapLbaPerTrack, false); if(indexesChanged) outputOptical.SetTracks(tracks.ToList()); @@ -1274,8 +1273,7 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", $"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", - icon: Icon.Error). - ShowDialog(_view)); + icon: Icon.Error).ShowDialog(_view)); AaruConsole.ErrorWriteLine("Error {0} writing sector {1}, not continuing...", outputFormat.ErrorMessage, doneSectors); @@ -1389,8 +1387,7 @@ public sealed class ImageConvertViewModel : ViewModelBase } else { - errno = sectorsToDo == 1 - ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector) + errno = sectorsToDo == 1 ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector) : _inputFormat.ReadSectors(doneSectors + track.StartSector, sectorsToDo, out sector); @@ -1436,8 +1433,7 @@ public sealed class ImageConvertViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager. GetMessageBoxStandardWindow("Error", $"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", - icon: Icon.Error). - ShowDialog(_view)); + icon: Icon.Error).ShowDialog(_view)); return; } @@ -1573,12 +1569,10 @@ public sealed class ImageConvertViewModel : ViewModelBase out sector); if(errno == ErrorNumber.NoError) - { result = sectorsToDo == 1 ? outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag) : outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector, sectorsToDo, tag); - } else { result = true; @@ -1587,8 +1581,8 @@ public sealed class ImageConvertViewModel : ViewModelBase { warning = true; - AaruConsole.ErrorWriteLine("Error {0} reading tag for sector {1}, continuing...", - errno, doneSectors); + AaruConsole.ErrorWriteLine("Error {0} reading tag for sector {1}, continuing...", errno, + doneSectors); } else { @@ -1919,8 +1913,7 @@ public sealed class ImageConvertViewModel : ViewModelBase void ExecuteDriveSerialNumberCommand() => DriveSerialNumberText = _inputFormat.Info.DriveSerialNumber; - void ExecuteDriveFirmwareRevisionCommand() => - DriveFirmwareRevisionText = _inputFormat.Info.DriveFirmwareRevision; + void ExecuteDriveFirmwareRevisionCommand() => DriveFirmwareRevisionText = _inputFormat.Info.DriveFirmwareRevision; void ExecuteCicmXmlFromImageCommand() { @@ -2014,17 +2007,15 @@ public sealed class ImageConvertViewModel : ViewModelBase } else await MessageBoxManager. - GetMessageBoxStandardWindow("Error", - "Resume file does not contain dump hardware information...", + GetMessageBoxStandardWindow("Error", "Resume file does not contain dump hardware information...", icon: Icon.Error).ShowDialog(_view); sr.Close(); } catch { - await MessageBoxManager. - GetMessageBoxStandardWindow("Error", "Incorrect resume file...", icon: Icon.Error). - ShowDialog(_view); + await MessageBoxManager.GetMessageBoxStandardWindow("Error", "Incorrect resume file...", icon: Icon.Error). + ShowDialog(_view); } } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs index 2001f0e0a..1181d05dc 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.ObjectModel; using System.Globalization; @@ -44,8 +46,6 @@ using Avalonia.Threading; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ImageEntropyViewModel : ViewModelBase { readonly IMediaImage _inputFormat; @@ -317,8 +317,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase foreach(EntropyResults trackEntropy in _tracksEntropy) { - AaruConsole.WriteLine("Entropy for track {0} is {1:F4}.", trackEntropy.Track, - trackEntropy.Entropy); + AaruConsole.WriteLine("Entropy for track {0} is {1:F4}.", trackEntropy.Track, trackEntropy.Entropy); if(trackEntropy.UniqueSectors != null) AaruConsole.WriteLine("Track {0} has {1} unique sectors ({2:P3})", trackEntropy.Track, @@ -348,7 +347,6 @@ public sealed class ImageEntropyViewModel : ViewModelBase ResultsVisible = true; if(SeparatedTracksChecked) - { foreach(EntropyResults trackEntropy in _tracksEntropy) TrackEntropy.Add(new TrackEntropyModel { @@ -357,7 +355,6 @@ public sealed class ImageEntropyViewModel : ViewModelBase UniqueSectors = $"{trackEntropy.UniqueSectors} ({(trackEntropy.UniqueSectors ?? 0) / (double)trackEntropy.Sectors:P3})" }); - } if(WholeDiscChecked != true) return; @@ -386,41 +383,39 @@ public sealed class ImageEntropyViewModel : ViewModelBase void EndProgress2() => Progress2Visible = false; - async void UpdateProgress(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => + async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + ProgressText = text; + + if(maximum == 0) { - ProgressText = text; + ProgressIndeterminate = true; - if(maximum == 0) - { - ProgressIndeterminate = true; + return; + } - return; - } + if(ProgressIndeterminate) + ProgressIndeterminate = false; - if(ProgressIndeterminate) - ProgressIndeterminate = false; + ProgressMax = maximum; + ProgressValue = current; + }); - ProgressMax = maximum; - ProgressValue = current; - }); + async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + Progress2Text = text; - async void UpdateProgress2(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => + if(maximum == 0) { - Progress2Text = text; + Progress2Indeterminate = true; - if(maximum == 0) - { - Progress2Indeterminate = true; + return; + } - return; - } + if(Progress2Indeterminate) + Progress2Indeterminate = false; - if(Progress2Indeterminate) - Progress2Indeterminate = false; - - Progress2Max = maximum; - Progress2Value = current; - }); + Progress2Max = maximum; + Progress2Value = current; + }); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs index 4fc9aface..20c256ca3 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.Generic; using System.IO; @@ -45,8 +47,6 @@ using Avalonia.Threading; using ReactiveUI; using Schemas; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ImageSidecarViewModel : ViewModelBase { readonly Encoding _encoding; @@ -266,15 +266,14 @@ public sealed class ImageSidecarViewModel : ViewModelBase Progress2Visible = false; }); - async void UpdateProgress2(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => - { - Progress2Text = text; - Progress2Indeterminate = false; + async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + Progress2Text = text; + Progress2Indeterminate = false; - Progress2MaxValue = maximum; - Progress2Value = current; - }); + Progress2MaxValue = maximum; + Progress2Value = current; + }); async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { @@ -286,15 +285,14 @@ public sealed class ImageSidecarViewModel : ViewModelBase Progress1Visible = false; }); - async void UpdateProgress(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => - { - ProgressText = text; - ProgressIndeterminate = false; + async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + ProgressText = text; + ProgressIndeterminate = false; - ProgressMaxValue = maximum; - ProgressValue = current; - }); + ProgressMaxValue = maximum; + ProgressValue = current; + }); async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { diff --git a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs index 5197bd81a..369224db7 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -44,8 +46,6 @@ using Avalonia.Controls; using Avalonia.Threading; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ImageVerifyViewModel : ViewModelBase { readonly IMediaImage _inputFormat; @@ -436,8 +436,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase } }); - AaruConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds", - checkTime.TotalSeconds); + AaruConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds", checkTime.TotalSeconds); } } @@ -505,8 +504,8 @@ public sealed class ImageVerifyViewModel : ViewModelBase inputOptical.VerifySectors(currentSector, (uint)remainingSectors, currentTrack.Sequence, out tempFailingLbas, out tempUnknownLbas); else - inputOptical.VerifySectors(currentSector, 512, currentTrack.Sequence, - out tempFailingLbas, out tempUnknownLbas); + inputOptical.VerifySectors(currentSector, 512, currentTrack.Sequence, out tempFailingLbas, + out tempUnknownLbas); failingLbas.AddRange(tempFailingLbas); @@ -562,8 +561,8 @@ public sealed class ImageVerifyViewModel : ViewModelBase List tempUnknownLbas; if(remainingSectors < 512) - verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors, - out tempFailingLbas, out tempUnknownLbas); + verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors, out tempFailingLbas, + out tempUnknownLbas); else 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 5af157613..a911b2422 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -53,6 +55,7 @@ using Aaru.Gui.ViewModels.Panels; using Aaru.Gui.Views.Dialogs; using Aaru.Gui.Views.Panels; using Aaru.Gui.Views.Windows; +using Aaru.Settings; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; @@ -62,13 +65,12 @@ using JetBrains.Annotations; using MessageBox.Avalonia; using MessageBox.Avalonia.Enums; using ReactiveUI; +using Console = Aaru.Gui.Views.Dialogs.Console; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; using ImageInfo = Aaru.Gui.Views.Panels.ImageInfo; using Partition = Aaru.Gui.Views.Panels.Partition; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class MainWindowViewModel : ViewModelBase { readonly IAssetLoader _assets; @@ -83,7 +85,7 @@ public sealed class MainWindowViewModel : ViewModelBase readonly Bitmap _sdIcon; readonly Bitmap _usbIcon; readonly MainWindow _view; - Views.Dialogs.Console _console; + Console _console; object _contentPanel; bool _devicesSupported; object _treeViewSelectedItem; @@ -148,18 +150,15 @@ public sealed class MainWindowViewModel : ViewModelBase _usbIcon = new - Bitmap(_assets.Open(new - Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png"))); + Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png"))); _removableIcon = - new - Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png"))); + new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png"))); _sdIcon = new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-flash-sd-mmc.png"))); - _ejectIcon = - new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png"))); + _ejectIcon = new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png"))); } public bool DevicesSupported @@ -243,7 +242,6 @@ public sealed class MainWindowViewModel : ViewModelBase case DeviceModel deviceModel: { if(deviceModel.ViewModel is null) - { try { var dev = new Device(deviceModel.Path); @@ -290,8 +288,8 @@ public sealed class MainWindowViewModel : ViewModelBase deviceModel.Media.Add(new MediaModel { DevicePath = deviceModel.Path, - Icon = _assets.Exists(mediaResource) - ? new Bitmap(_assets.Open(mediaResource)) : null, + Icon = _assets.Exists(mediaResource) ? new Bitmap(_assets.Open(mediaResource)) + : null, Name = $"{scsiInfo.MediaType}", ViewModel = new MediaInfoViewModel(scsiInfo, deviceModel.Path, _view) }); @@ -310,7 +308,6 @@ public sealed class MainWindowViewModel : ViewModelBase return; } - } ContentPanel = new Views.Panels.DeviceInfo { @@ -455,7 +452,7 @@ public sealed class MainWindowViewModel : ViewModelBase void ExecuteStatisticsCommand() { - using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + using var ctx = AaruContext.Create(Settings.LocalDbPath); if(!ctx.Commands.Any() && !ctx.Filesystems.Any() && @@ -489,7 +486,7 @@ public sealed class MainWindowViewModel : ViewModelBase { if(_console is null) { - _console = new Views.Dialogs.Console(); + _console = new Console(); _console.DataContext = new ConsoleViewModel(_console); } @@ -523,12 +520,12 @@ public sealed class MainWindowViewModel : ViewModelBase try { - IMediaImage imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage; + var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage; if(imageFormat == null) { - MessageBoxManager.GetMessageBoxStandardWindow("Error", "Image format not identified.", - ButtonEnum.Ok, Icon.Error); + MessageBoxManager.GetMessageBoxStandardWindow("Error", "Image format not identified.", ButtonEnum.Ok, + Icon.Error); return; } @@ -550,8 +547,7 @@ public sealed class MainWindowViewModel : ViewModelBase return; } - var mediaResource = - new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.png"); + var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{imageFormat.Info.MediaType}.png"); var imageModel = new ImageModel { @@ -569,10 +565,10 @@ public sealed class MainWindowViewModel : ViewModelBase Filter = inputFilter }; - List partitions = Core.Partitions.GetAll(imageFormat); - Core.Partitions.AddSchemesToStats(partitions); + List partitions = Partitions.GetAll(imageFormat); + Partitions.AddSchemesToStats(partitions); - bool checkRaw = false; + var checkRaw = false; List idPlugins; IFilesystem plugin; PluginBase plugins = GetPluginBase.Instance; @@ -608,7 +604,7 @@ public sealed class MainWindowViewModel : ViewModelBase AaruConsole.WriteLine("Identifying filesystem on partition"); - Core.Filesystems.Identify(imageFormat, out idPlugins, partition); + Filesystems.Identify(imageFormat, out idPlugins, partition); if(idPlugins.Count == 0) AaruConsole.WriteLine("Filesystem not identified"); @@ -677,7 +673,7 @@ public sealed class MainWindowViewModel : ViewModelBase Size = imageFormat.Info.Sectors * imageFormat.Info.SectorSize }; - Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart); + Filesystems.Identify(imageFormat, out idPlugins, wholePart); if(idPlugins.Count == 0) AaruConsole.WriteLine("Filesystem not identified"); @@ -737,8 +733,8 @@ public sealed class MainWindowViewModel : ViewModelBase } catch(Exception ex) { - MessageBoxManager.GetMessageBoxStandardWindow("Error", "Unable to open image format.", - ButtonEnum.Ok, Icon.Error); + MessageBoxManager.GetMessageBoxStandardWindow("Error", "Unable to open image format.", ButtonEnum.Ok, + Icon.Error); AaruConsole.ErrorWriteLine("Unable to open image format"); AaruConsole.ErrorWriteLine("Error: {0}", ex.Message); @@ -771,8 +767,8 @@ public sealed class MainWindowViewModel : ViewModelBase AaruConsole.WriteLine("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("Main window", "Found supported device model {0} by manufacturer {1} on bus {2} and path {3}", diff --git a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs index f80a64309..90a859f3e 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -60,8 +62,6 @@ using Schemas; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; using MediaType = Aaru.CommonTypes.MediaType; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class MediaDumpViewModel : ViewModelBase { readonly string _devicePath; @@ -691,7 +691,7 @@ public sealed class MediaDumpViewModel : ViewModelBase if(_resume == null || _resume.NextBlock <= _resume.LastBlock || - (_resume.BadBlocks.Count != 0 && !_resume.Tape)) + _resume.BadBlocks.Count != 0 && !_resume.Tape) return; await MessageBoxManager. @@ -769,7 +769,7 @@ public sealed class MediaDumpViewModel : ViewModelBase return; } - Dictionary parsedOptions = new Dictionary(); + var parsedOptions = new Dictionary(); /* TODO: Options if(grpOptions.Content is StackLayout stkFormatOptions) @@ -806,11 +806,11 @@ 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); + _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); new Thread(DoWork).Start(); } @@ -848,15 +848,14 @@ public sealed class MediaDumpViewModel : ViewModelBase Progress2Visible = false; }); - async void UpdateProgress2(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => - { - Progress2Text = text; - Progress2Indeterminate = false; + async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + Progress2Text = text; + Progress2Indeterminate = false; - Progress2MaxValue = maximum; - Progress2Value = current; - }); + Progress2MaxValue = maximum; + Progress2Value = current; + }); async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { @@ -868,15 +867,14 @@ public sealed class MediaDumpViewModel : ViewModelBase Progress1Visible = false; }); - async void UpdateProgress(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => - { - ProgressText = text; - ProgressIndeterminate = false; + async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + ProgressText = text; + ProgressIndeterminate = false; - ProgressMaxValue = maximum; - ProgressValue = current; - }); + ProgressMaxValue = maximum; + ProgressValue = current; + }); async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { diff --git a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs index 82a3fbb2f..d35ff5ff2 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System.Collections.ObjectModel; using System.Reactive; using System.Threading; @@ -44,8 +46,6 @@ using MessageBox.Avalonia.Enums; using OxyPlot; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class MediaScanViewModel : ViewModelBase { readonly Window _view; @@ -366,8 +366,7 @@ public sealed class MediaScanViewModel : ViewModelBase await Dispatcher.UIThread.InvokeAsync(() => { - TotalTime = - $"Took a total of {results.TotalTime} seconds ({results.ProcessingTime} processing commands)."; + TotalTime = $"Took a total of {results.TotalTime} seconds ({results.ProcessingTime} processing commands)."; AvgSpeed = $"Average speed: {results.AvgSpeed:F3} MiB/sec."; MaxSpeed = $"Fastest speed burst: {results.MaxSpeed:F3} MiB/sec."; @@ -411,7 +410,7 @@ public sealed class MediaScanViewModel : ViewModelBase ChartPoints.Add(new DataPoint(sector, currentSpeed)); if(currentSpeed > MaxY) - MaxY = currentSpeed + (currentSpeed / 10d); + MaxY = currentSpeed + currentSpeed / 10d; }); async void InitBlockMap(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile) => @@ -532,15 +531,14 @@ public sealed class MediaScanViewModel : ViewModelBase Progress1Visible = false; }); - async void UpdateProgress(string text, long current, long maximum) => - await Dispatcher.UIThread.InvokeAsync(() => - { - ProgressText = text; - ProgressIndeterminate = false; + async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() => + { + ProgressText = text; + ProgressIndeterminate = false; - ProgressMaxValue = maximum; - ProgressValue = current; - }); + ProgressMaxValue = maximum; + ProgressValue = current; + }); async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { diff --git a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs index 486530694..9dbf4d41b 100644 --- a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using System; using System.IO; using System.Linq; @@ -46,8 +48,6 @@ using Avalonia.Threading; using Microsoft.EntityFrameworkCore; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class SplashWindowViewModel : ViewModelBase { readonly SplashWindow _view; @@ -107,7 +107,7 @@ public sealed class SplashWindowViewModel : ViewModelBase Task.Run(() => { // TODO: Detect there are no settings yet - Settings.Settings.LoadSettings(); + Settings.LoadSettings(); Dispatcher.UIThread.Post(MigrateLocalDatabase); }); @@ -125,7 +125,7 @@ public sealed class SplashWindowViewModel : ViewModelBase try { - ctx = AaruContext.Create(Settings.Settings.LocalDbPath, false); + ctx = AaruContext.Create(Settings.LocalDbPath, false); ctx.Database.Migrate(); } catch(NotSupportedException) @@ -140,18 +140,16 @@ public sealed class SplashWindowViewModel : ViewModelBase // Should not ever arrive here, but if it does, keep trying to replace it anyway } - File.Delete(Settings.Settings.LocalDbPath); - ctx = AaruContext.Create(Settings.Settings.LocalDbPath); + File.Delete(Settings.LocalDbPath); + ctx = AaruContext.Create(Settings.LocalDbPath); ctx.Database.EnsureCreated(); 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.SaveChanges(); } @@ -165,9 +163,8 @@ public sealed class SplashWindowViewModel : ViewModelBase a.Bus }).Where(a => a.Count() > 1).Distinct().Select(a => a.Key)) ctx.RemoveRange(ctx.SeenDevices!. - Where(d => d.Manufacturer == duplicate.Manufacturer && - d.Model == duplicate.Model && d.Revision == duplicate.Revision && - d.Bus == duplicate.Bus).Skip(1)); + Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model && + d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1)); // Remove nulls ctx.RemoveRange(ctx.SeenDevices!.Where(d => d.Manufacturer == null && d.Model == null && @@ -187,16 +184,14 @@ public sealed class SplashWindowViewModel : ViewModelBase Task.Run(() => { - bool mainDbUpdate = false; + var mainDbUpdate = false; - if(!File.Exists(Settings.Settings.MainDbPath)) - { + if(!File.Exists(Settings.MainDbPath)) mainDbUpdate = true; - // TODO: Update database - } + // TODO: Update database - var mainContext = AaruContext.Create(Settings.Settings.MainDbPath, false); + var mainContext = AaruContext.Create(Settings.MainDbPath, false); if(mainContext.Database.GetPendingMigrations().Any()) { @@ -204,14 +199,13 @@ public sealed class SplashWindowViewModel : ViewModelBase try { - File.Delete(Settings.Settings.MainDbPath); + File.Delete(Settings.MainDbPath); } catch(Exception) { - AaruConsole. - ErrorWriteLine("Exception trying to remove old database version, cannot continue..."); + AaruConsole.ErrorWriteLine("Exception trying to remove old database version, cannot continue..."); - AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MainDbPath); + AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.MainDbPath); return; } @@ -229,7 +223,7 @@ public sealed class SplashWindowViewModel : ViewModelBase Message = "Checking GDPR compliance..."; AaruConsole.WriteLine("Checking GDPR compliance..."); - if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL) + if(Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL) { var settingsDialog = new SettingsDialog(); var settingsDialogViewModel = new SettingsViewModel(settingsDialog, true); diff --git a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs index 0aa0170ea..8db2ac1d1 100644 --- a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.ViewModels.Windows; + using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using JetBrains.Annotations; using ReactiveUI; -namespace Aaru.Gui.ViewModels.Windows; - public sealed class ViewSectorViewModel : ViewModelBase { const int HEX_COLUMNS = 32; diff --git a/Aaru.Gui/Views/Dialogs/About.xaml.cs b/Aaru.Gui/Views/Dialogs/About.xaml.cs index 550698034..7c4b686ac 100644 --- a/Aaru.Gui/Views/Dialogs/About.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/About.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class About : Window { public About() diff --git a/Aaru.Gui/Views/Dialogs/Console.xaml.cs b/Aaru.Gui/Views/Dialogs/Console.xaml.cs index f4a9bc60d..8cd5829f1 100644 --- a/Aaru.Gui/Views/Dialogs/Console.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/Console.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using System.ComponentModel; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; using JetBrains.Annotations; -namespace Aaru.Gui.Views.Dialogs; - public sealed class Console : Window { public Console() diff --git a/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs b/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs index 64ec09a1d..6ef263298 100644 --- a/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/Encodings.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class Encodings : Window { public Encodings() diff --git a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs index f4d0f0412..88303f724 100644 --- a/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/LicenseDialog.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class LicenseDialog : Window { public LicenseDialog() diff --git a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs index 6d20dd0cb..a6df61361 100644 --- a/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/PluginsDialog.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class PluginsDialog : Window { public PluginsDialog() diff --git a/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs index f640a9a8c..cd879e99f 100644 --- a/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/SettingsDialog.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class SettingsDialog : Window { public SettingsDialog() diff --git a/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs b/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs index 5d615ceee..0bbc75f10 100644 --- a/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs +++ b/Aaru.Gui/Views/Dialogs/StatisticsDialog.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Dialogs; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Dialogs; - public sealed class StatisticsDialog : Window { public StatisticsDialog() diff --git a/Aaru.Gui/Views/Panels/DeviceInfo.xaml.cs b/Aaru.Gui/Views/Panels/DeviceInfo.xaml.cs index ae68e6823..edab8766d 100644 --- a/Aaru.Gui/Views/Panels/DeviceInfo.xaml.cs +++ b/Aaru.Gui/Views/Panels/DeviceInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class DeviceInfo : UserControl { public DeviceInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Panels/FileSystem.xaml.cs b/Aaru.Gui/Views/Panels/FileSystem.xaml.cs index e6afd84a1..34d1f738d 100644 --- a/Aaru.Gui/Views/Panels/FileSystem.xaml.cs +++ b/Aaru.Gui/Views/Panels/FileSystem.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class FileSystem : UserControl { public FileSystem() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Panels/ImageInfo.xaml.cs b/Aaru.Gui/Views/Panels/ImageInfo.xaml.cs index 45a9745a2..ca1e010b4 100644 --- a/Aaru.Gui/Views/Panels/ImageInfo.xaml.cs +++ b/Aaru.Gui/Views/Panels/ImageInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class ImageInfo : UserControl { public ImageInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Panels/MediaInfo.xaml.cs b/Aaru.Gui/Views/Panels/MediaInfo.xaml.cs index cea7e9527..f77f57434 100644 --- a/Aaru.Gui/Views/Panels/MediaInfo.xaml.cs +++ b/Aaru.Gui/Views/Panels/MediaInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class MediaInfo : UserControl { public MediaInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Panels/Partition.xaml.cs b/Aaru.Gui/Views/Panels/Partition.xaml.cs index 988d4f69d..9844f9377 100644 --- a/Aaru.Gui/Views/Panels/Partition.xaml.cs +++ b/Aaru.Gui/Views/Panels/Partition.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class Partition : UserControl { public Partition() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Panels/Subdirectory.xaml.cs b/Aaru.Gui/Views/Panels/Subdirectory.xaml.cs index d501ff033..fbbf4fd09 100644 --- a/Aaru.Gui/Views/Panels/Subdirectory.xaml.cs +++ b/Aaru.Gui/Views/Panels/Subdirectory.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Panels; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Panels; - public sealed class Subdirectory : UserControl { public Subdirectory() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/AtaInfo.xaml.cs b/Aaru.Gui/Views/Tabs/AtaInfo.xaml.cs index 88a86fd1e..21269955b 100644 --- a/Aaru.Gui/Views/Tabs/AtaInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/AtaInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class AtaInfo : UserControl { public AtaInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/BlurayInfo.xaml.cs b/Aaru.Gui/Views/Tabs/BlurayInfo.xaml.cs index 9e8fbc0ff..9d982b83f 100644 --- a/Aaru.Gui/Views/Tabs/BlurayInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/BlurayInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class BlurayInfo : UserControl { public BlurayInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml.cs b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml.cs index 67fe3ad42..057630178 100644 --- a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class CompactDiscInfo : UserControl { public CompactDiscInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/DvdInfo.xaml.cs b/Aaru.Gui/Views/Tabs/DvdInfo.xaml.cs index 02285efa8..3ed46183f 100644 --- a/Aaru.Gui/Views/Tabs/DvdInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/DvdInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class DvdInfo : UserControl { public DvdInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml.cs b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml.cs index 68e48f914..f2c379302 100644 --- a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class DvdWritableInfo : UserControl { public DvdWritableInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml.cs b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml.cs index 9b2f1e5a6..74c3c548e 100644 --- a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class PcmciaInfo : UserControl { public PcmciaInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/ScsiInfo.xaml.cs b/Aaru.Gui/Views/Tabs/ScsiInfo.xaml.cs index 0ef594201..12f9a7cfb 100644 --- a/Aaru.Gui/Views/Tabs/ScsiInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/ScsiInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class ScsiInfo : UserControl { public ScsiInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml.cs b/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml.cs index ed31e5982..5b376f1de 100644 --- a/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class SdMmcInfo : UserControl { public SdMmcInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Tabs/XboxInfo.xaml.cs b/Aaru.Gui/Views/Tabs/XboxInfo.xaml.cs index 4f028d965..9829bae03 100644 --- a/Aaru.Gui/Views/Tabs/XboxInfo.xaml.cs +++ b/Aaru.Gui/Views/Tabs/XboxInfo.xaml.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Tabs; + using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Tabs; - public sealed class XboxInfo : UserControl { public XboxInfo() => InitializeComponent(); diff --git a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs index 3c95ab733..cbec5201b 100644 --- a/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs +++ b/Aaru.Gui/Views/Windows/DecodeMediaTags.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class DecodeMediaTags : Window { public DecodeMediaTags() diff --git a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs index 0ce8f833f..72056aeca 100644 --- a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ImageChecksum : Window { public ImageChecksum() diff --git a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs index 4a2a32026..5aef2340b 100644 --- a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ImageConvert : Window { public ImageConvert() diff --git a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs index 0acfba0c5..30e3dec98 100644 --- a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ImageEntropy : Window { public ImageEntropy() diff --git a/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs b/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs index 7a239bf3e..f5d2f0cf8 100644 --- a/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageSidecar.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ImageSidecar : Window { public ImageSidecar() diff --git a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs index b08bb196b..778ca7163 100644 --- a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ImageVerify : Window { public ImageVerify() diff --git a/Aaru.Gui/Views/Windows/MainWindow.xaml.cs b/Aaru.Gui/Views/Windows/MainWindow.xaml.cs index 65318cbeb..2f7a89484 100644 --- a/Aaru.Gui/Views/Windows/MainWindow.xaml.cs +++ b/Aaru.Gui/Views/Windows/MainWindow.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class MainWindow : Window { public MainWindow() diff --git a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs index b8474315c..6bd914a84 100644 --- a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class MediaDump : Window { public MediaDump() diff --git a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs index 24bacdba9..72ccacd80 100644 --- a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System.ComponentModel; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class MediaScan : Window { public MediaScan() diff --git a/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs b/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs index fd8b0d968..2548949cc 100644 --- a/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs +++ b/Aaru.Gui/Views/Windows/SplashWindow.xaml.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using System; using Aaru.Gui.ViewModels.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class SplashWindow : Window { public SplashWindow() diff --git a/Aaru.Gui/Views/Windows/ViewSector.xaml.cs b/Aaru.Gui/Views/Windows/ViewSector.xaml.cs index 228275c14..34380e391 100644 --- a/Aaru.Gui/Views/Windows/ViewSector.xaml.cs +++ b/Aaru.Gui/Views/Windows/ViewSector.xaml.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Gui.Views.Windows; + using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; -namespace Aaru.Gui.Views.Windows; - public sealed class ViewSector : Window { public ViewSector() diff --git a/Aaru.Helpers b/Aaru.Helpers index bfca01481..1502ea91c 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit bfca01481a2448fd6f15b5bc8591710885e6a2ec +Subproject commit 1502ea91c1658b635f89789893ecd56eb0048a9e diff --git a/Aaru.Images/AaruFormat/AaruFormat.cs b/Aaru.Images/AaruFormat/AaruFormat.cs index 979a61e4d..852360fa2 100644 --- a/Aaru.Images/AaruFormat/AaruFormat.cs +++ b/Aaru.Images/AaruFormat/AaruFormat.cs @@ -69,6 +69,8 @@ P.S.2: Support for floppy image contaning bitslices and/or fluxes will be added soon. */ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -78,8 +80,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading and writing AaruFormat media images public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage { diff --git a/Aaru.Images/AaruFormat/CdEcc.cs b/Aaru.Images/AaruFormat/CdEcc.cs index a90810d66..ba42ac174 100644 --- a/Aaru.Images/AaruFormat/CdEcc.cs +++ b/Aaru.Images/AaruFormat/CdEcc.cs @@ -31,11 +31,11 @@ // ECC algorithm from ECM(c) 2002-2011 Neill Corlett // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { byte[] _eccBTable; @@ -55,7 +55,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < 256; i++) { uint edc = i; - uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); + var j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); _eccFTable[i] = (byte)j; _eccBTable[i ^ j] = (byte)i; @@ -93,10 +93,10 @@ public sealed partial class AaruFormat if(!correctEccQ) return false; - uint storedEdc = BitConverter.ToUInt32(sector, 0x810); + var storedEdc = BitConverter.ToUInt32(sector, 0x810); uint edc = 0; - int size = 0x810; - int pos = 0; + var size = 0x810; + var pos = 0; for(; size > 0; size--) edc = (edc >> 8) ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; @@ -111,7 +111,7 @@ public sealed partial class AaruFormat if(!_initedEdc) EccInit(); - byte[] zeroAddress = new byte[4]; + var zeroAddress = new byte[4]; bool correctEccP = CheckEcc(zeroAddress, sector, 86, 24, 2, 86, sector, 0, 0x10, 0x81C); @@ -123,10 +123,10 @@ public sealed partial class AaruFormat if(!correctEccQ) return false; - uint storedEdc = BitConverter.ToUInt32(sector, 0x818); + var storedEdc = BitConverter.ToUInt32(sector, 0x818); uint edc = 0; - int size = 0x808; - int pos = 0x10; + var size = 0x808; + var pos = 0x10; for(; size > 0; size--) edc = (edc >> 8) ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; @@ -144,7 +144,7 @@ public sealed partial class AaruFormat for(major = 0; major < majorCount; major++) { - uint idx = ((major >> 1) * majorMult) + (major & 1); + uint idx = (major >> 1) * majorMult + (major & 1); byte eccA = 0; byte eccB = 0; uint minor; @@ -180,7 +180,7 @@ public sealed partial class AaruFormat for(major = 0; major < majorCount; major++) { - uint idx = ((major >> 1) * majorMult) + (major & 1); + uint idx = (major >> 1) * majorMult + (major & 1); byte eccA = 0; byte eccB = 0; uint minor; @@ -204,8 +204,7 @@ public sealed partial class AaruFormat } } - void EccWriteSector(byte[] address, byte[] data, ref byte[] ecc, int addressOffset, int dataOffset, - int eccOffset) + void EccWriteSector(byte[] address, byte[] data, ref byte[] ecc, int addressOffset, int dataOffset, int eccOffset) { WriteEcc(address, data, 86, 24, 2, 86, ref ecc, addressOffset, dataOffset, eccOffset); // P WriteEcc(address, data, 52, 43, 86, 88, ref ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q @@ -235,9 +234,9 @@ public sealed partial class AaruFormat (byte minute, byte second, byte frame) msf = LbaToMsf(lba); - sector[0x00C] = (byte)(((msf.minute / 10) << 4) + (msf.minute % 10)); - sector[0x00D] = (byte)(((msf.second / 10) << 4) + (msf.second % 10)); - sector[0x00E] = (byte)(((msf.frame / 10) << 4) + (msf.frame % 10)); + sector[0x00C] = (byte)(((msf.minute / 10) << 4) + msf.minute % 10); + sector[0x00D] = (byte)(((msf.second / 10) << 4) + msf.second % 10); + sector[0x00E] = (byte)(((msf.frame / 10) << 4) + msf.frame % 10); switch(type) { @@ -309,7 +308,7 @@ public sealed partial class AaruFormat default: return; } - byte[] zeroAddress = new byte[4]; + var zeroAddress = new byte[4]; switch(type) { diff --git a/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs b/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs index 2904f36e5..686a18dad 100644 --- a/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs +++ b/Aaru.Images/AaruFormat/ClauniaSubchannelTransform.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { static byte[] ClauniaSubchannelTransform(byte[] interleaved) @@ -42,18 +42,18 @@ public sealed partial class AaruFormat if(interleaved == null) return null; - int[] p = new int[interleaved.Length / 8]; - int[] q = new int[interleaved.Length / 8]; - int[] r = new int[interleaved.Length / 8]; - int[] s = new int[interleaved.Length / 8]; - int[] t = new int[interleaved.Length / 8]; - int[] u = new int[interleaved.Length / 8]; - int[] v = new int[interleaved.Length / 8]; - int[] w = new int[interleaved.Length / 8]; + var p = new int[interleaved.Length / 8]; + var q = new int[interleaved.Length / 8]; + var r = new int[interleaved.Length / 8]; + var s = new int[interleaved.Length / 8]; + var t = new int[interleaved.Length / 8]; + var u = new int[interleaved.Length / 8]; + var v = new int[interleaved.Length / 8]; + var w = new int[interleaved.Length / 8]; DateTime start = DateTime.UtcNow; - for(int i = 0; i < interleaved.Length; i += 8) + for(var i = 0; i < interleaved.Length; i += 8) { p[i / 8] = interleaved[i] & 0x80; p[i / 8] += (interleaved[i + 1] & 0x80) >> 1; @@ -131,7 +131,7 @@ public sealed partial class AaruFormat DateTime end = DateTime.UtcNow; TimeSpan deinterleave = end - start; - byte[] sequential = new byte[interleaved.Length]; + var sequential = new byte[interleaved.Length]; start = DateTime.UtcNow; int qStart = p.Length * 1; @@ -142,7 +142,7 @@ public sealed partial class AaruFormat int vStart = p.Length * 6; int wStart = p.Length * 7; - for(int i = 0; i < p.Length; i++) + for(var i = 0; i < p.Length; i++) { sequential[i] = (byte)p[i]; sequential[qStart + i] = (byte)q[i]; @@ -174,14 +174,14 @@ public sealed partial class AaruFormat if(sequential == null) return null; - int[] p = new int[sequential.Length / 8]; - int[] q = new int[sequential.Length / 8]; - int[] r = new int[sequential.Length / 8]; - int[] s = new int[sequential.Length / 8]; - int[] t = new int[sequential.Length / 8]; - int[] u = new int[sequential.Length / 8]; - int[] v = new int[sequential.Length / 8]; - int[] w = new int[sequential.Length / 8]; + var p = new int[sequential.Length / 8]; + var q = new int[sequential.Length / 8]; + var r = new int[sequential.Length / 8]; + var s = new int[sequential.Length / 8]; + var t = new int[sequential.Length / 8]; + var u = new int[sequential.Length / 8]; + var v = new int[sequential.Length / 8]; + var w = new int[sequential.Length / 8]; int qStart = p.Length * 1; int rStart = p.Length * 2; @@ -193,7 +193,7 @@ public sealed partial class AaruFormat DateTime start = DateTime.UtcNow; - for(int i = 0; i < p.Length; i++) + for(var i = 0; i < p.Length; i++) { p[i] = sequential[i]; q[i] = sequential[qStart + i]; @@ -208,10 +208,10 @@ public sealed partial class AaruFormat DateTime end = DateTime.UtcNow; TimeSpan desequentialize = end - start; - byte[] interleaved = new byte[sequential.Length]; + var interleaved = new byte[sequential.Length]; start = DateTime.UtcNow; - for(int i = 0; i < interleaved.Length; i += 8) + for(var i = 0; i < interleaved.Length; i += 8) { interleaved[i] = (byte)((p[i / 8] & 0x80) == 0x80 ? 0x80 : 0); interleaved[i + 1] += (byte)((p[i / 8] & 0x40) == 0x40 ? 0x80 : 0); diff --git a/Aaru.Images/AaruFormat/Enums.cs b/Aaru.Images/AaruFormat/Enums.cs index 264c72868..3c0645296 100644 --- a/Aaru.Images/AaruFormat/Enums.cs +++ b/Aaru.Images/AaruFormat/Enums.cs @@ -259,13 +259,19 @@ public sealed partial class AaruFormat enum ChecksumAlgorithm : byte { - Invalid = 0, Md5 = 1, Sha1 = 2, - Sha256 = 3, SpamSum = 4 + Invalid = 0, + Md5 = 1, + Sha1 = 2, + Sha256 = 3, + SpamSum = 4 } enum CdFixFlags : uint { - NotDumped = 0x10000000, Correct = 0x20000000, Mode2Form1Ok = 0x30000000, - Mode2Form2Ok = 0x40000000, Mode2Form2NoCrc = 0x50000000 + NotDumped = 0x10000000, + Correct = 0x20000000, + Mode2Form1Ok = 0x30000000, + Mode2Form2Ok = 0x40000000, + Mode2Form2NoCrc = 0x50000000 } } \ No newline at end of file diff --git a/Aaru.Images/AaruFormat/Helpers.cs b/Aaru.Images/AaruFormat/Helpers.cs index 447829125..d8a0d1afd 100644 --- a/Aaru.Images/AaruFormat/Helpers.cs +++ b/Aaru.Images/AaruFormat/Helpers.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SecureDigital; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// Checks for media tags that may contain metadata and sets it up if not already set @@ -48,7 +48,7 @@ public sealed partial class AaruFormat // Search for SecureDigital CID if(_mediaTags.TryGetValue(MediaTagType.SD_CID, out byte[] sdCid)) { - CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(sdCid); + CID decoded = Decoders.DecodeCID(sdCid); if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) _imageInfo.DriveManufacturer = VendorString.Prettify(decoded.Manufacturer); @@ -67,10 +67,10 @@ public sealed partial class AaruFormat // Search for MultiMediaCard CID if(_mediaTags.TryGetValue(MediaTagType.MMC_CID, out byte[] mmcCid)) { - Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(mmcCid); + Aaru.Decoders.MMC.CID decoded = Aaru.Decoders.MMC.Decoders.DecodeCID(mmcCid); if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) - _imageInfo.DriveManufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); + _imageInfo.DriveManufacturer = Aaru.Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) _imageInfo.DriveModel = decoded.ProductName; @@ -99,8 +99,7 @@ public sealed partial class AaruFormat _imageInfo.DriveModel = StringHandlers.CToString(inquiry.ProductIdentification)?.Trim(); if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) - _imageInfo.DriveFirmwareRevision = - StringHandlers.CToString(inquiry.ProductRevisionLevel)?.Trim(); + _imageInfo.DriveFirmwareRevision = StringHandlers.CToString(inquiry.ProductRevisionLevel)?.Trim(); } } @@ -253,7 +252,7 @@ public sealed partial class AaruFormat long oldPosition = _imageStream.Position; _imageStream.Position = _outMemoryDdtPosition + Marshal.SizeOf(); _imageStream.Position += (long)(sectorAddress * sizeof(ulong)); - byte[] temp = new byte[sizeof(ulong)]; + var temp = new byte[sizeof(ulong)]; _imageStream.Read(temp, 0, sizeof(ulong)); _imageStream.Position = oldPosition; entry = BitConverter.ToUInt64(temp, 0); diff --git a/Aaru.Images/AaruFormat/Identify.cs b/Aaru.Images/AaruFormat/Identify.cs index de6ca9b8e..e62739a19 100644 --- a/Aaru.Images/AaruFormat/Identify.cs +++ b/Aaru.Images/AaruFormat/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// diff --git a/Aaru.Images/AaruFormat/Properties.cs b/Aaru.Images/AaruFormat/Properties.cs index bb664a519..4af64e2a6 100644 --- a/Aaru.Images/AaruFormat/Properties.cs +++ b/Aaru.Images/AaruFormat/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// @@ -62,7 +62,7 @@ public sealed partial class AaruFormat /// public string Name => "Aaru Format"; /// - public Guid Id => new Guid("49360069-1784-4A2F-B723-0C844D610B0A"); + public Guid Id => new("49360069-1784-4A2F-B723-0C844D610B0A"); /// public string Format => "Aaru"; /// @@ -78,8 +78,7 @@ public sealed partial class AaruFormat /// public CICMMetadataType CicmMetadata { get; private set; } /// - public IEnumerable SupportedMediaTags => - Enum.GetValues(typeof(MediaTagType)).Cast(); + public IEnumerable SupportedMediaTags => Enum.GetValues(typeof(MediaTagType)).Cast(); /// public IEnumerable SupportedSectorTags => Enum.GetValues(typeof(SectorTagType)).Cast(); @@ -99,8 +98,7 @@ public sealed partial class AaruFormat ("spamsum", typeof(bool), "Calculate and store SpamSum of image's user data", false), ("deduplicate", typeof(bool), "Store only unique sectors. This consumes more memory and is slower, but it's enabled by default", true), - ("compress", typeof(bool), "Compress user data blocks. Other blocks will always be compressed", - (object)true) + ("compress", typeof(bool), "Compress user data blocks. Other blocks will always be compressed", (object)true) }; /// public IEnumerable KnownExtensions => new[] diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs index 159eab985..fa0b07652 100644 --- a/Aaru.Images/AaruFormat/Read.cs +++ b/Aaru.Images/AaruFormat/Read.cs @@ -31,6 +31,8 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -52,8 +54,6 @@ using Marshal = Aaru.Helpers.Marshal; using Session = Aaru.CommonTypes.Structs.Session; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// @@ -106,11 +106,10 @@ public sealed partial class AaruFormat _imageStream.Read(_structureBytes, 0, _structureBytes.Length); IndexHeader2 idxHeader2 = Marshal.SpanToStructureLittleEndian(_structureBytes); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", - _header.indexOffset, idxHeader2.entries); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", _header.indexOffset, + idxHeader2.entries); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Fill in-memory index _index = new List(); @@ -122,19 +121,18 @@ public sealed partial class AaruFormat IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", - "Block type {0} with data type {1} is indexed to be at {2}", - entry.blockType, entry.dataType, entry.offset); + "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, + entry.dataType, entry.offset); _index.Add(entry); } } else { - AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", - _header.indexOffset, idxHeader.entries); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", _header.indexOffset, + idxHeader.entries); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Fill in-memory index _index = new List(); @@ -146,8 +144,8 @@ public sealed partial class AaruFormat IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", - "Block type {0} with data type {1} is indexed to be at {2}", - entry.blockType, entry.dataType, entry.offset); + "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, + entry.dataType, entry.offset); _index.Add(entry); } @@ -157,7 +155,7 @@ public sealed partial class AaruFormat _imageInfo.ImageSize = 0; - bool foundUserDataDdt = false; + var foundUserDataDdt = false; _mediaTags = new Dictionary(); List compactDiscIndexes = null; @@ -191,8 +189,7 @@ public sealed partial class AaruFormat if(blockHeader.identifier != entry.blockType) { AaruConsole.DebugWriteLine("Aaru Format plugin", - "Incorrect identifier for data block at position {0}", - entry.offset); + "Incorrect identifier for data block at position {0}", entry.offset); break; } @@ -229,8 +226,8 @@ public sealed partial class AaruFormat } DateTime startDecompress = DateTime.Now; - byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; - byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; + var compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; + var lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.Read(compressedTag, 0, compressedTag.Length); data = new byte[blockHeader.length]; @@ -435,13 +432,13 @@ public sealed partial class AaruFormat case CompressionType.Lzma: AaruConsole.DebugWriteLine("Aaru Format plugin", "Decompressing DDT..."); DateTime ddtStart = DateTime.UtcNow; - byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; - byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; + var compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; + var lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.Read(compressedDdt, 0, compressedDdt.Length); - byte[] decompressedDdt = new byte[ddtHeader.length]; + var decompressedDdt = new byte[ddtHeader.length]; - ulong decompressedLength = + var decompressedLength = (ulong)LZMA.DecodeBuffer(compressedDdt, decompressedDdt, lzmaProperties); if(decompressedLength != ddtHeader.length) @@ -486,7 +483,7 @@ public sealed partial class AaruFormat case DataType.CdSectorPrefixCorrected: case DataType.CdSectorSuffixCorrected: { - byte[] decompressedDdt = new byte[ddtHeader.length]; + var decompressedDdt = new byte[ddtHeader.length]; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -497,12 +494,12 @@ public sealed partial class AaruFormat case CompressionType.Lzma: AaruConsole.DebugWriteLine("Aaru Format plugin", "Decompressing DDT..."); DateTime ddtStart = DateTime.UtcNow; - byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; - byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; + var compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; + var lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.Read(compressedDdt, 0, compressedDdt.Length); - ulong decompressedLength = + var decompressedLength = (ulong)LZMA.DecodeBuffer(compressedDdt, decompressedDdt, lzmaProperties); DateTime ddtEnd = DateTime.UtcNow; @@ -591,14 +588,12 @@ public sealed partial class AaruFormat _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.Read(_structureBytes, 0, _structureBytes.Length); - MetadataBlock metadataBlock = - Marshal.SpanToStructureLittleEndian(_structureBytes); + MetadataBlock metadataBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); if(metadataBlock.identifier != entry.blockType) { AaruConsole.DebugWriteLine("Aaru Format plugin", - "Incorrect identifier for data block at position {0}", - entry.offset); + "Incorrect identifier for data block at position {0}", entry.offset); break; } @@ -606,7 +601,7 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine("Aaru Format plugin", "Found metadata block at position {0}", entry.offset); - byte[] metadata = new byte[metadataBlock.blockSize]; + var metadata = new byte[metadataBlock.blockSize]; _imageStream.Position = (long)entry.offset; _imageStream.Read(metadata, 0, metadata.Length); @@ -626,19 +621,16 @@ public sealed partial class AaruFormat _imageInfo.Creator = Encoding.Unicode.GetString(metadata, (int)metadataBlock.creatorOffset, (int)(metadataBlock.creatorLength - 2)); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting creator: {0}", - _imageInfo.Creator); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting creator: {0}", _imageInfo.Creator); } if(metadataBlock.commentsOffset > 0 && metadataBlock.commentsLength + metadataBlock.commentsOffset <= metadata.Length) { - _imageInfo.Comments = - Encoding.Unicode.GetString(metadata, (int)metadataBlock.commentsOffset, - (int)(metadataBlock.commentsLength - 2)); + _imageInfo.Comments = Encoding.Unicode.GetString(metadata, (int)metadataBlock.commentsOffset, + (int)(metadataBlock.commentsLength - 2)); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting comments: {0}", - _imageInfo.Comments); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting comments: {0}", _imageInfo.Comments); } if(metadataBlock.mediaTitleOffset > 0 && @@ -652,9 +644,8 @@ public sealed partial class AaruFormat _imageInfo.MediaTitle); } - if(metadataBlock.mediaManufacturerOffset > 0 && - metadataBlock.mediaManufacturerLength + metadataBlock.mediaManufacturerOffset <= - metadata.Length) + if(metadataBlock.mediaManufacturerOffset > 0 && + metadataBlock.mediaManufacturerLength + metadataBlock.mediaManufacturerOffset <= metadata.Length) { _imageInfo.MediaManufacturer = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaManufacturerOffset, @@ -675,9 +666,8 @@ public sealed partial class AaruFormat _imageInfo.MediaModel); } - if(metadataBlock.mediaSerialNumberOffset > 0 && - metadataBlock.mediaSerialNumberLength + metadataBlock.mediaSerialNumberOffset <= - metadata.Length) + if(metadataBlock.mediaSerialNumberOffset > 0 && + metadataBlock.mediaSerialNumberLength + metadataBlock.mediaSerialNumberOffset <= metadata.Length) { _imageInfo.MediaSerialNumber = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaSerialNumberOffset, @@ -709,9 +699,8 @@ public sealed partial class AaruFormat _imageInfo.MediaPartNumber); } - if(metadataBlock.driveManufacturerOffset > 0 && - metadataBlock.driveManufacturerLength + metadataBlock.driveManufacturerOffset <= - metadata.Length) + if(metadataBlock.driveManufacturerOffset > 0 && + metadataBlock.driveManufacturerLength + metadataBlock.driveManufacturerOffset <= metadata.Length) { _imageInfo.DriveManufacturer = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveManufacturerOffset, @@ -732,9 +721,8 @@ public sealed partial class AaruFormat _imageInfo.DriveModel); } - if(metadataBlock.driveSerialNumberOffset > 0 && - metadataBlock.driveSerialNumberLength + metadataBlock.driveSerialNumberOffset <= - metadata.Length) + if(metadataBlock.driveSerialNumberOffset > 0 && + metadataBlock.driveSerialNumberLength + metadataBlock.driveSerialNumberOffset <= metadata.Length) { _imageInfo.DriveSerialNumber = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveSerialNumberOffset, @@ -803,8 +791,7 @@ public sealed partial class AaruFormat _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.Read(_structureBytes, 0, _structureBytes.Length); - TrackEntry trackEntry = - Marshal.ByteArrayToStructureLittleEndian(_structureBytes); + TrackEntry trackEntry = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); Tracks.Add(new Track { @@ -855,13 +842,13 @@ public sealed partial class AaruFormat if(cicmBlock.identifier != BlockType.CicmBlock) break; - AaruConsole.DebugWriteLine("Aaru Format plugin", - "Found CICM XML metadata block at position {0}", entry.offset); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Found CICM XML metadata block at position {0}", + entry.offset); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); - byte[] cicmBytes = new byte[cicmBlock.length]; + var cicmBytes = new byte[cicmBlock.length]; _imageStream.Read(cicmBytes, 0, cicmBytes.Length); var cicmMs = new MemoryStream(cicmBytes); var cicmXs = new XmlSerializer(typeof(CICMMetadataType)); @@ -1040,7 +1027,7 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine("Aaru Format plugin", "Found tape partition block at position {0}", entry.offset); - byte[] tapePartitionBytes = new byte[partitionHeader.length]; + var tapePartitionBytes = new byte[partitionHeader.length]; _imageStream.Read(tapePartitionBytes, 0, tapePartitionBytes.Length); Span tapePartitions = @@ -1065,8 +1052,7 @@ public sealed partial class AaruFormat _structureBytes = new byte[Marshal.SizeOf()]; _imageStream.Read(_structureBytes, 0, _structureBytes.Length); - TapeFileHeader fileHeader = - Marshal.SpanToStructureLittleEndian(_structureBytes); + TapeFileHeader fileHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); if(fileHeader.identifier != BlockType.TapeFileBlock) break; @@ -1074,7 +1060,7 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine("Aaru Format plugin", "Found tape file block at position {0}", entry.offset); - byte[] tapeFileBytes = new byte[fileHeader.length]; + var tapeFileBytes = new byte[fileHeader.length]; _imageStream.Read(tapeFileBytes, 0, tapeFileBytes.Length); Span tapeFiles = MemoryMarshal.Cast(tapeFileBytes); Files = new List(); @@ -1126,8 +1112,7 @@ public sealed partial class AaruFormat compactDiscIndexes = new List(); - AaruConsole.DebugWriteLine("Aaru Format plugin", - "Found {0} compact disc indexes at position {0}", + AaruConsole.DebugWriteLine("Aaru Format plugin", "Found {0} compact disc indexes at position {0}", indexesHeader.entries, entry.offset); for(ushort i = 0; i < indexesHeader.entries; i++) @@ -1158,8 +1143,7 @@ public sealed partial class AaruFormat AaruConsole.DebugWriteLine("Aaru Format plugin", "Image created on {0}", _imageInfo.CreationTime); _imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(_header.lastWrittenTime); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Image last written on {0}", - _imageInfo.LastModificationTime); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Image last written on {0}", _imageInfo.LastModificationTime); _imageInfo.XmlMediaType = GetXmlMediaType(_header.mediaType); @@ -1190,12 +1174,12 @@ public sealed partial class AaruFormat { if(Tracks != null) { - bool leadOutFixed = false; - bool sessionPregapFixed = false; + var leadOutFixed = false; + var sessionPregapFixed = false; if(_mediaTags.TryGetValue(MediaTagType.CD_FullTOC, out byte[] fullToc)) { - byte[] tmp = new byte[fullToc.Length + 2]; + var tmp = new byte[fullToc.Length + 2]; Array.Copy(fullToc, 0, tmp, 2, fullToc.Length); tmp[0] = (byte)(fullToc.Length >> 8); tmp[1] = (byte)(fullToc.Length & 0xFF); @@ -1246,8 +1230,8 @@ public sealed partial class AaruFormat phour = trk.PHOUR; } - int lastSector = (phour * 3600 * 75) + (pmin * 60 * 75) + (psec * 75) + pframe - 150; - leadOutStarts?.Add(trk.SessionNumber, lastSector + 1); + int lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150; + leadOutStarts?.Add(trk.SessionNumber, lastSector + 1); } foreach(KeyValuePair leadOuts in leadOutStarts) @@ -1269,7 +1253,6 @@ public sealed partial class AaruFormat } if(_header.imageMajorVersion <= 1) - { foreach(Track track in Tracks) { if(track.Sequence <= 1) @@ -1291,7 +1274,6 @@ public sealed partial class AaruFormat sessionPregapFixed = true; } - } if(leadOutFixed) AaruConsole.ErrorWriteLine("This image has a corrupted track list, convert will fix it."); @@ -1301,8 +1283,7 @@ public sealed partial class AaruFormat ErrorWriteLine("This image has a corrupted track list, a best effort has been tried but may require manual editing or redump."); } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); if(Tracks == null || Tracks.Count == 0) @@ -1333,12 +1314,11 @@ public sealed partial class AaruFormat _trackIsrcs = new Dictionary(); } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); Sessions = new List(); - for(int i = 1; i <= Tracks.Max(t => t.Session); i++) + for(var i = 1; i <= Tracks.Max(t => t.Session); i++) Sessions.Add(new Session { Sequence = (ushort)i, @@ -1348,8 +1328,7 @@ public sealed partial class AaruFormat EndSector = Tracks.Where(t => t.Session == i).Max(t => t.EndSector) }); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); foreach(Track track in Tracks.OrderBy(t => t.StartSector)) { @@ -1391,8 +1370,7 @@ public sealed partial class AaruFormat currentTrackOffset += (track.EndSector - track.StartSector + 1) * (ulong)track.BytesPerSector; } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); Track[] tracks = Tracks.ToArray(); @@ -1406,8 +1384,8 @@ public sealed partial class AaruFormat trk.BytesPerSector = sector.Length; trk.RawBytesPerSector = - (_sectorPrefix != null && _sectorSuffix != null) || - (_sectorPrefixDdt != null && _sectorSuffixDdt != null) ? 2352 : sector.Length; + _sectorPrefix != null && _sectorSuffix != null || + _sectorPrefixDdt != null && _sectorSuffixDdt != null ? 2352 : sector.Length; if(_sectorSubchannel == null) continue; @@ -1417,16 +1395,13 @@ public sealed partial class AaruFormat trk.SubchannelType = TrackSubchannelType.Raw; } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); Tracks = tracks.ToList(); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", - GC.GetTotalMemory(false)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); if(compactDiscIndexes != null) - { foreach(CompactDiscIndexEntry compactDiscIndex in compactDiscIndexes.OrderBy(i => i.Track). ThenBy(i => i.Index)) { @@ -1437,7 +1412,6 @@ public sealed partial class AaruFormat track.Indexes[compactDiscIndex.Index] = compactDiscIndex.Lba; } - } } else { @@ -1526,7 +1500,7 @@ public sealed partial class AaruFormat return ErrorNumber.OutOfRange; ulong ddtEntry = GetDdtEntry(sectorAddress); - uint offsetMask = (uint)((1 << _shift) - 1); + var offsetMask = (uint)((1 << _shift) - 1); ulong offset = ddtEntry & offsetMask; ulong blockOffset = ddtEntry >> _shift; @@ -1570,8 +1544,8 @@ public sealed partial class AaruFormat break; case CompressionType.Lzma: - byte[] compressedBlock = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; - byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; + var compressedBlock = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; + var lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.Read(compressedBlock, 0, compressedBlock.Length); block = new byte[blockHeader.length]; @@ -1591,7 +1565,7 @@ public sealed partial class AaruFormat break; case CompressionType.Flac: - byte[] flacBlock = new byte[blockHeader.cmpLength]; + var flacBlock = new byte[blockHeader.cmpLength]; _imageStream.Read(flacBlock, 0, flacBlock.Length); block = new byte[blockHeader.length]; decompressedLength = (ulong)FLAC.DecodeBuffer(flacBlock, block); @@ -1910,7 +1884,6 @@ public sealed partial class AaruFormat case TrackType.Data: { if(_imageInfo.MediaType == MediaType.DVDROM) - { switch(tag) { case SectorTagType.DvdCmi: @@ -1942,7 +1915,6 @@ public sealed partial class AaruFormat } default: return ErrorNumber.NotSupported; } - } else return ErrorNumber.NotSupported; @@ -1968,7 +1940,7 @@ public sealed partial class AaruFormat return ErrorNumber.NoError; } - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) Array.Copy(dataSource, (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), buffer, i * sectorSize, sectorSize); @@ -2019,8 +1991,7 @@ public sealed partial class AaruFormat switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: - Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && - sectorAddress <= t.EndSector); + Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector); if(trk is null) return ErrorNumber.SectorNotFound; @@ -2056,9 +2027,8 @@ public sealed partial class AaruFormat { if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructPrefix(ref buffer, trk.Type, (long)sectorAddress); - else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == - (uint)CdFixFlags.NotDumped || - _sectorPrefixDdt[sectorAddress] == 0) + else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || + _sectorPrefixDdt[sectorAddress] == 0) { // Do nothing } @@ -2083,9 +2053,8 @@ public sealed partial class AaruFormat { if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructEcc(ref buffer, trk.Type); - else if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == - (uint)CdFixFlags.NotDumped || - _sectorSuffixDdt[sectorAddress] == 0) + else if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || + _sectorSuffixDdt[sectorAddress] == 0) { // Do nothing } @@ -2114,9 +2083,8 @@ public sealed partial class AaruFormat { if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructPrefix(ref buffer, trk.Type, (long)sectorAddress); - else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == - (uint)CdFixFlags.NotDumped || - _sectorPrefixDdt[sectorAddress] == 0) + else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || + _sectorPrefixDdt[sectorAddress] == 0) { // Do nothing } @@ -2160,9 +2128,8 @@ public sealed partial class AaruFormat } default: { - if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == - (uint)CdFixFlags.NotDumped || - _sectorSuffixDdt[sectorAddress] == 0) + if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || + _sectorSuffixDdt[sectorAddress] == 0) { // Do nothing } @@ -2170,9 +2137,7 @@ public sealed partial class AaruFormat { // Incorrectly written images if(data.Length == 2328) - { Array.Copy(data, 0, buffer, 24, 2328); - } else { bool form2 = (buffer[18] & 0x20) == 0x20 || (buffer[22] & 0x20) == 0x20; @@ -2247,8 +2212,7 @@ public sealed partial class AaruFormat switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: - Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && - sectorAddress <= t.EndSector); + Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.StartSector && sectorAddress <= t.EndSector); if(trk is null) return ErrorNumber.SectorNotFound; @@ -2280,8 +2244,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < length; i++) { - Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), buffer, (int)(i * 2352), - 16); + Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), buffer, (int)(i * 2352), 16); Array.Copy(data, (int)(i * 2048), buffer, (int)(i * 2352) + 16, 2048); @@ -2326,8 +2289,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < length; i++) { - Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), buffer, (int)(i * 2352), - 16); + Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), buffer, (int)(i * 2352), 16); Array.Copy(data, (int)(i * 2336), buffer, (int)(i * 2352) + 16, 2336); } @@ -2401,7 +2363,7 @@ public sealed partial class AaruFormat for(uint i = 0; i < length; i++) { Array.Copy(_sectorSubchannel, (int)((sectorAddress + i) * tagSize), buffer, - (int)((i * sectorSize) + 512), tagSize); + (int)(i * sectorSize + 512), tagSize); Array.Copy(data, (int)((sectorAddress + i) * 512), buffer, (int)(i * 512), 512); } @@ -2433,8 +2395,7 @@ public sealed partial class AaruFormat } /// - public List GetSessionTracks(Session session) => - Tracks.Where(t => t.Sequence == session.Sequence).ToList(); + public List GetSessionTracks(Session session) => Tracks.Where(t => t.Sequence == session.Sequence).ToList(); /// public List GetSessionTracks(ushort session) => Tracks.Where(t => t.Sequence == session).ToList(); diff --git a/Aaru.Images/AaruFormat/Structs.cs b/Aaru.Images/AaruFormat/Structs.cs index 5717acd46..6d876742a 100644 --- a/Aaru.Images/AaruFormat/Structs.cs +++ b/Aaru.Images/AaruFormat/Structs.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// Header, at start of file diff --git a/Aaru.Images/AaruFormat/Tape.cs b/Aaru.Images/AaruFormat/Tape.cs index 37bd618fc..083126b5b 100644 --- a/Aaru.Images/AaruFormat/Tape.cs +++ b/Aaru.Images/AaruFormat/Tape.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs index 2bb248835..1d53c2b5c 100644 --- a/Aaru.Images/AaruFormat/Verify.cs +++ b/Aaru.Images/AaruFormat/Verify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class AaruFormat { /// @@ -111,9 +111,8 @@ public sealed partial class AaruFormat crcVerify = new Crc64Context(); readBytes = 0; - AaruConsole.DebugWriteLine("Aaru Format plugin", - "Verifying data block type {0} at position {1}", entry.dataType, - entry.offset); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Verifying data block type {0} at position {1}", + entry.dataType, entry.offset); while(readBytes + verifySize < blockHeader.cmpLength) { @@ -131,8 +130,7 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != blockHeader.cmpCrc64) { - AaruConsole.DebugWriteLine("Aaru Format plugin", - "Expected block CRC {0:X16} but got {1:X16}", + AaruConsole.DebugWriteLine("Aaru Format plugin", "Expected block CRC {0:X16} but got {1:X16}", blockHeader.cmpCrc64, BitConverter.ToUInt64(verifyCrc, 0)); return false; @@ -148,8 +146,8 @@ public sealed partial class AaruFormat readBytes = 0; AaruConsole.DebugWriteLine("Aaru Format plugin", - "Verifying deduplication table type {0} at position {1}", - entry.dataType, entry.offset); + "Verifying deduplication table type {0} at position {1}", entry.dataType, + entry.offset); while(readBytes + verifySize < ddtHeader.cmpLength) { @@ -188,9 +186,8 @@ public sealed partial class AaruFormat if(BitConverter.ToUInt64(verifyCrc, 0) != trkHeader.crc64) { - AaruConsole.DebugWriteLine("Aaru Format plugin", - "Expected index CRC {0:X16} but got {1:X16}", trkHeader.crc64, - BitConverter.ToUInt64(verifyCrc, 0)); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Expected index CRC {0:X16} but got {1:X16}", + trkHeader.crc64, BitConverter.ToUInt64(verifyCrc, 0)); return false; } @@ -238,12 +235,12 @@ public sealed partial class AaruFormat if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; failingLbas = new List(); unknownLbas = new List(); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -291,10 +288,10 @@ public sealed partial class AaruFormat if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/Alcohol120/Alcohol120.cs b/Aaru.Images/Alcohol120/Alcohol120.cs index d495979de..ae1fb3d71 100644 --- a/Aaru.Images/Alcohol120/Alcohol120.cs +++ b/Aaru.Images/Alcohol120/Alcohol120.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing Alcohol 120% disk images public sealed partial class Alcohol120 : IWritableOpticalImage diff --git a/Aaru.Images/Alcohol120/Enums.cs b/Aaru.Images/Alcohol120/Enums.cs index aaf4cb8d0..bbc7339d4 100644 --- a/Aaru.Images/Alcohol120/Enums.cs +++ b/Aaru.Images/Alcohol120/Enums.cs @@ -30,30 +30,41 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + public sealed partial class Alcohol120 { [SuppressMessage("ReSharper", "InconsistentNaming")] enum MediumType : ushort { - CD = 0x00, CDR = 0x01, CDRW = 0x02, - DVD = 0x10, DVDR = 0x12 + CD = 0x00, + CDR = 0x01, + CDRW = 0x02, + DVD = 0x10, + DVDR = 0x12 } [SuppressMessage("ReSharper", "InconsistentNaming")] enum TrackMode : byte { - NoData = 0x00, DVD = 0x02, Audio = 0xA9, - AudioAlt = 0xE9, Mode1 = 0xAA, Mode1Alt = 0xEA, - Mode2 = 0xAB, Mode2F1 = 0xEC, Mode2F2 = 0xED, - Mode2F1Alt = 0xAC, Mode2F2Alt = 0xAD + NoData = 0x00, + DVD = 0x02, + Audio = 0xA9, + AudioAlt = 0xE9, + Mode1 = 0xAA, + Mode1Alt = 0xEA, + Mode2 = 0xAB, + Mode2F1 = 0xEC, + Mode2F2 = 0xED, + Mode2F1Alt = 0xAC, + Mode2F2Alt = 0xAD } enum SubchannelMode : byte { - None = 0x00, Interleaved = 0x08 + None = 0x00, + Interleaved = 0x08 } } \ No newline at end of file diff --git a/Aaru.Images/Alcohol120/Helpers.cs b/Aaru.Images/Alcohol120/Helpers.cs index b1906aa09..45bc56eef 100644 --- a/Aaru.Images/Alcohol120/Helpers.cs +++ b/Aaru.Images/Alcohol120/Helpers.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { static ushort TrackModeToCookedBytesPerSector(TrackMode trackMode) diff --git a/Aaru.Images/Alcohol120/Identify.cs b/Aaru.Images/Alcohol120/Identify.cs index ae1b3cbbd..46d6f1aaa 100644 --- a/Aaru.Images/Alcohol120/Identify.cs +++ b/Aaru.Images/Alcohol120/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { /// @@ -48,7 +48,7 @@ public sealed partial class Alcohol120 if(stream.Length < 88) return false; - byte[] hdr = new byte[88]; + var hdr = new byte[88]; stream.Read(hdr, 0, 88); Header header = Marshal.ByteArrayToStructureLittleEndian
(hdr); diff --git a/Aaru.Images/Alcohol120/Properties.cs b/Aaru.Images/Alcohol120/Properties.cs index c15f7ffe0..738121470 100644 --- a/Aaru.Images/Alcohol120/Properties.cs +++ b/Aaru.Images/Alcohol120/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { /// @@ -163,27 +163,26 @@ public sealed partial class Alcohol120 /// public IEnumerable SupportedSectorTags => new[] { - SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, - SectorTagType.CdSectorEdc, SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, - SectorTagType.CdSectorSync, SectorTagType.CdTrackFlags, SectorTagType.CdSectorSubchannel + SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, SectorTagType.CdSectorEdc, + SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, SectorTagType.CdSectorSync, + SectorTagType.CdTrackFlags, SectorTagType.CdSectorSubchannel }; /// public IEnumerable SupportedMediaTypes => new[] { MediaType.BDR, MediaType.BDRE, MediaType.BDREXL, MediaType.BDROM, MediaType.UHDBD, MediaType.BDRXL, - MediaType.CBHD, MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, - MediaType.CDMIDI, MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, - MediaType.CDRW, MediaType.CDV, MediaType.DVDDownload, MediaType.DVDPR, MediaType.DVDPRDL, MediaType.DVDPRW, - MediaType.DVDPRWDL, MediaType.DVDR, MediaType.DVDRAM, MediaType.DVDRDL, MediaType.DVDROM, MediaType.DVDRW, - MediaType.DVDRWDL, MediaType.EVD, MediaType.FDDVD, MediaType.DTSCD, MediaType.FVD, MediaType.HDDVDR, - MediaType.HDDVDRAM, MediaType.HDDVDRDL, MediaType.HDDVDROM, MediaType.HDDVDRW, MediaType.HDDVDRWDL, - MediaType.HDVMD, MediaType.HVD, MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, - MediaType.PS2DVD, MediaType.PS3BD, MediaType.PS3DVD, MediaType.PS4BD, MediaType.PS5BD, - MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SVOD, MediaType.SATURNCD, MediaType.ThreeDO, MediaType.UDO, - MediaType.UDO2, MediaType.UDO2_WORM, MediaType.UMD, MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, - MediaType.PCFX, MediaType.CDTV, MediaType.CD32, MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, - MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, MediaType.VideoNowColor, MediaType.VideoNowXp, - MediaType.CVD, MediaType.PCD + MediaType.CBHD, MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, + MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, + MediaType.CDV, MediaType.DVDDownload, MediaType.DVDPR, MediaType.DVDPRDL, MediaType.DVDPRW, MediaType.DVDPRWDL, + MediaType.DVDR, MediaType.DVDRAM, MediaType.DVDRDL, MediaType.DVDROM, MediaType.DVDRW, MediaType.DVDRWDL, + MediaType.EVD, MediaType.FDDVD, MediaType.DTSCD, MediaType.FVD, MediaType.HDDVDR, MediaType.HDDVDRAM, + MediaType.HDDVDRDL, MediaType.HDDVDROM, MediaType.HDDVDRW, MediaType.HDDVDRWDL, MediaType.HDVMD, MediaType.HVD, + MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, MediaType.PS2DVD, MediaType.PS3BD, + MediaType.PS3DVD, MediaType.PS4BD, MediaType.PS5BD, MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SVOD, + MediaType.SATURNCD, MediaType.ThreeDO, MediaType.UDO, MediaType.UDO2, MediaType.UDO2_WORM, MediaType.UMD, + MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, MediaType.PCFX, MediaType.CDTV, MediaType.CD32, + MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, + MediaType.VideoNowColor, MediaType.VideoNowXp, MediaType.CVD, MediaType.PCD }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index 514fc1526..0340c0c76 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -44,8 +46,6 @@ using Aaru.Decoders.DVD; using Aaru.Helpers; using DMI = Aaru.Decoders.Xbox.DMI; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { /// @@ -58,7 +58,7 @@ public sealed partial class Alcohol120 return ErrorNumber.InvalidArgument; _isDvd = false; - byte[] hdr = new byte[88]; + var hdr = new byte[88]; stream.Read(hdr, 0, 88); _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); @@ -71,28 +71,27 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.type = {0}", _header.type); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessions = {0}", _header.sessions); - for(int i = 0; i < _header.unknown1.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown1[{1}] = 0x{0:X4}", - _header.unknown1[i], i); + for(var i = 0; i < _header.unknown1.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown1[{1}] = 0x{0:X4}", _header.unknown1[i], + i); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaLength = {0}", _header.bcaLength); - for(int i = 0; i < _header.unknown2.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown2[{1}] = 0x{0:X8}", - _header.unknown2[i], i); + for(var i = 0; i < _header.unknown2.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown2[{1}] = 0x{0:X8}", _header.unknown2[i], + i); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaOffset = {0}", _header.bcaOffset); - for(int i = 0; i < _header.unknown3.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown3[{1}] = 0x{0:X8}", - _header.unknown3[i], i); + for(var i = 0; i < _header.unknown3.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown3[{1}] = 0x{0:X8}", _header.unknown3[i], + i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.structuresOffset = {0}", - _header.structuresOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.structuresOffset = {0}", _header.structuresOffset); - for(int i = 0; i < _header.unknown4.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown4[{1}] = 0x{0:X8}", - _header.unknown4[i], i); + for(var i = 0; i < _header.unknown4.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown4[{1}] = 0x{0:X8}", _header.unknown4[i], + i); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessionOffset = {0}", _header.sessionOffset); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.dpmOffset = {0}", _header.dpmOffset); @@ -103,18 +102,17 @@ public sealed partial class Alcohol120 stream.Seek(_header.sessionOffset, SeekOrigin.Begin); _alcSessions = new Dictionary(); - for(int i = 0; i < _header.sessions; i++) + for(var i = 0; i < _header.sessions; i++) { - byte[] sesHdr = new byte[24]; + var sesHdr = new byte[24]; stream.Read(sesHdr, 0, 24); Session session = Marshal.SpanToStructureLittleEndian(sesHdr); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionStart = {0}", - session.sessionStart, i); - - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionEnd = {0}", session.sessionEnd, + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionStart = {0}", session.sessionStart, i); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionEnd = {0}", session.sessionEnd, i); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionSequence = {0}", session.sessionSequence, i); @@ -123,22 +121,19 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].nonTrackBlocks = {0}", session.nonTrackBlocks, i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].firstTrack = {0}", session.firstTrack, - i); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].firstTrack = {0}", session.firstTrack, i); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].lastTrack = {0}", session.lastTrack, i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].unknown = 0x{0:X8}", session.unknown, - i); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].unknown = 0x{0:X8}", session.unknown, i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].trackOffset = {0}", session.trackOffset, - i); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].trackOffset = {0}", session.trackOffset, i); _alcSessions.Add(session.sessionSequence, session); } long footerOff = 0; - bool oldIncorrectImage = false; + var oldIncorrectImage = false; _alcTracks = new Dictionary(); _alcToc = new Dictionary>(); @@ -149,9 +144,9 @@ public sealed partial class Alcohol120 stream.Seek(session.trackOffset, SeekOrigin.Begin); Dictionary sesToc = new(); - for(int i = 0; i < session.allBlocks; i++) + for(var i = 0; i < session.allBlocks; i++) { - byte[] trkHdr = new byte[80]; + var trkHdr = new byte[80]; stream.Read(trkHdr, 0, 80); Track track = Marshal.ByteArrayToStructureLittleEndian(trkHdr); @@ -175,14 +170,14 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].subMode = {0}", track.subMode, track.point, session.sessionSequence); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].adrCtl = {0}", - track.adrCtl, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].adrCtl = {0}", track.adrCtl, + track.point, session.sessionSequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].tno = {0}", track.tno, track.point, session.sessionSequence); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].point = {0:X2}", - track.point, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].point = {0:X2}", track.point, + track.point, session.sessionSequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].min = {0}", track.min, track.point, session.sessionSequence); @@ -190,8 +185,8 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].sec = {0}", track.sec, track.point, session.sessionSequence); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].frame = {0}", - track.frame, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].frame = {0}", track.frame, + track.point, session.sessionSequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].zero = {0}", track.zero, track.point, session.sessionSequence); @@ -202,8 +197,8 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].psec = {0}", track.psec, track.point, session.sessionSequence); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].pframe = {0}", - track.pframe, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].pframe = {0}", track.pframe, + track.point, session.sessionSequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].extraOffset = {0}", track.extraOffset, track.point, session.sessionSequence); @@ -219,8 +214,8 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].startOffset = {0}", track.startOffset, track.point, session.sessionSequence); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].files = {0}", - track.files, track.point, session.sessionSequence); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].files = {0}", track.files, + track.point, session.sessionSequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].footerOffset = {0}", track.footerOffset, track.point, session.sessionSequence); @@ -262,7 +257,7 @@ public sealed partial class Alcohol120 if(track.extraOffset > 0 && !_isDvd) { - byte[] extHdr = new byte[8]; + var extHdr = new byte[8]; stream.Seek(track.extraOffset, SeekOrigin.Begin); stream.Read(extHdr, 0, 8); TrackExtra extra = Marshal.SpanToStructureLittleEndian(extHdr); @@ -293,20 +288,19 @@ public sealed partial class Alcohol120 if(footerOff > 0) { - byte[] footer = new byte[16]; + var footer = new byte[16]; stream.Seek(footerOff, SeekOrigin.Begin); stream.Read(footer, 0, 16); _alcFooter = Marshal.SpanToStructureLittleEndian
(footer); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filenameOffset = {0}", - _alcFooter.filenameOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filenameOffset = {0}", _alcFooter.filenameOffset); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.widechar = {0}", _alcFooter.widechar); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown1 = 0x{0:X8}", _alcFooter.unknown1); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown2 = 0x{0:X8}", _alcFooter.unknown2); } - string alcFile = "*.mdf"; + var alcFile = "*.mdf"; if(_alcFooter.filenameOffset > 0) { @@ -391,7 +385,7 @@ public sealed partial class Alcohol120 // TODO: Second layer if(_header.structuresOffset > 0) { - byte[] structures = new byte[4100]; + var structures = new byte[4100]; stream.Seek(_header.structuresOffset, SeekOrigin.Begin); stream.Read(structures, 0, 4100); _dmi = new byte[2052]; @@ -443,8 +437,7 @@ public sealed partial class Alcohol120 break; case DiskCategory.DVDRW: - _imageInfo.MediaType = - pfi0.Value.PartVersion >= 15 ? MediaType.DVDRWDL : MediaType.DVDRW; + _imageInfo.MediaType = pfi0.Value.PartVersion >= 15 ? MediaType.DVDRWDL : MediaType.DVDRW; break; case DiskCategory.HDDVDR: @@ -479,7 +472,7 @@ public sealed partial class Alcohol120 else if(DMI.IsXbox360(_dmi)) _imageInfo.MediaType = MediaType.XGD2; - byte[] tmp = new byte[2048]; + var tmp = new byte[2048]; Array.Copy(_dmi, 4, tmp, 0, 2048); _dmi = tmp; tmp = new byte[2048]; @@ -493,11 +486,11 @@ public sealed partial class Alcohol120 } else if(_header.type == MediumType.CD) { - bool data = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; foreach(Track alcoholTrack in _alcTracks.Values) { @@ -538,7 +531,7 @@ public sealed partial class Alcohol120 Sessions.Count > 1 && mode2) _imageInfo.MediaType = MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = MediaType.CDROM; @@ -659,8 +652,7 @@ public sealed partial class Alcohol120 AaruConsole.DebugWriteLine("Alcohol 120% plugin", "Partition sequence: {0}", partition.Sequence); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition name: {0}", partition.Name); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition description: {0}", - partition.Description); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition description: {0}", partition.Description); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition type: {0}", partition.Type); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition starting sector: {0}", partition.Start); @@ -780,8 +772,7 @@ public sealed partial class Alcohol120 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -854,7 +845,7 @@ public sealed partial class Alcohol120 uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(alcTrack.mode) { @@ -929,7 +920,7 @@ public sealed partial class Alcohol120 } uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip); - long fileOffset = (long)alcTrack.startOffset; + var fileOffset = (long)alcTrack.startOffset; if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); @@ -946,9 +937,9 @@ public sealed partial class Alcohol120 buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -960,7 +951,7 @@ public sealed partial class Alcohol120 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1352,7 +1343,7 @@ public sealed partial class Alcohol120 } uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip); - long fileOffset = (long)alcTrack.startOffset; + var fileOffset = (long)alcTrack.startOffset; if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); @@ -1367,7 +1358,7 @@ public sealed partial class Alcohol120 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1462,7 +1453,7 @@ public sealed partial class Alcohol120 } uint pregapBytes = alcExtra.pregap * (sectorOffset + sectorSize + sectorSkip); - long fileOffset = (long)alcTrack.startOffset; + var fileOffset = (long)alcTrack.startOffset; if(alcTrack.startOffset >= pregapBytes) fileOffset = (long)(alcTrack.startOffset - pregapBytes); @@ -1477,7 +1468,7 @@ public sealed partial class Alcohol120 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); diff --git a/Aaru.Images/Alcohol120/Structs.cs b/Aaru.Images/Alcohol120/Structs.cs index bf860e680..1a477de89 100644 --- a/Aaru.Images/Alcohol120/Structs.cs +++ b/Aaru.Images/Alcohol120/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Alcohol120 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/Alcohol120/Verify.cs b/Aaru.Images/Alcohol120/Verify.cs index 972941b6f..748e1286f 100644 --- a/Aaru.Images/Alcohol120/Verify.cs +++ b/Aaru.Images/Alcohol120/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { /// @@ -58,10 +58,10 @@ public sealed partial class Alcohol120 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class Alcohol120 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index bc1352655..5fc04d95e 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class Alcohol120 { /// @@ -213,8 +213,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(!_isDvd) { @@ -245,7 +244,7 @@ public sealed partial class Alcohol120 } _imageStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -271,8 +270,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -306,7 +304,7 @@ public sealed partial class Alcohol120 { case TrackSubchannelType.None: _imageStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -317,7 +315,7 @@ public sealed partial class Alcohol120 case TrackSubchannelType.Raw: case TrackSubchannelType.RawInterleaved: _imageStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96))), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), SeekOrigin.Begin); for(uint i = 0; i < length; i++) @@ -347,8 +345,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -364,10 +361,10 @@ public sealed partial class Alcohol120 return false; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); _imageStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize))), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -386,8 +383,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -410,12 +406,12 @@ public sealed partial class Alcohol120 return false; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); for(uint i = 0; i < length; i++) { _imageStream. - Seek((long)(track.FileOffset + ((i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize))), + Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), SeekOrigin.Begin); _imageStream.Write(data, (int)(i * track.RawBytesPerSector), track.RawBytesPerSector); @@ -435,7 +431,7 @@ public sealed partial class Alcohol120 { CommonTypes.Structs.Track[] tmpTracks = tracks.OrderBy(t => t.Sequence).ToArray(); - for(int i = 1; i < tmpTracks.Length; i++) + for(var i = 1; i < tmpTracks.Length; i++) { CommonTypes.Structs.Track firstTrackInSession = tracks.FirstOrDefault(t => t.Session == tmpTracks[i].Session); @@ -532,7 +528,7 @@ public sealed partial class Alcohol120 _alcToc = new Dictionary>(); _writingTracks = _writingTracks.OrderBy(t => t.Session).ThenBy(t => t.Sequence).ToList(); _alcTrackExtras = new Dictionary(); - long currentTrackOffset = header.sessionOffset + (Marshal.SizeOf() * sessions); + long currentTrackOffset = header.sessionOffset + Marshal.SizeOf() * sessions; byte[] tmpToc = null; @@ -548,9 +544,9 @@ public sealed partial class Alcohol120 FullTOC.CDFullTOC? decodedToc = FullTOC.Decode(tmpToc); long currentExtraOffset = currentTrackOffset; - int extraCount = 0; + var extraCount = 0; - for(int i = 1; i <= sessions; i++) + for(var i = 1; i <= sessions; i++) if(decodedToc.HasValue) { extraCount += decodedToc.Value.TrackDescriptors.Count(t => t.SessionNumber == i); @@ -574,7 +570,7 @@ public sealed partial class Alcohol120 } } - long footerOffset = currentExtraOffset + (Marshal.SizeOf() * extraCount); + long footerOffset = currentExtraOffset + Marshal.SizeOf() * extraCount; if(_bca != null) { @@ -616,7 +612,7 @@ public sealed partial class Alcohol120 _alcToc.Add(1, _alcTracks); } else - for(int i = 1; i <= sessions; i++) + for(var i = 1; i <= sessions; i++) { CommonTypes.Structs.Track firstTrack = _writingTracks.First(t => t.Session == i); CommonTypes.Structs.Track lastTrack = _writingTracks.Last(t => t.Session == i); @@ -650,8 +646,8 @@ public sealed partial class Alcohol120 (byte minute, byte second, byte frame) leadinPmsf = LbaToMsf(lastTrack.EndSector + 1); - if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT >= 0xA0 && - t.POINT <= 0xAF) == true) + if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT >= 0xA0 && t.POINT <= 0xAF) == + true) foreach(FullTOC.TrackDataDescriptor tocTrk in decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && t.POINT >= 0xA0 && t.POINT <= 0xAF)) @@ -731,8 +727,7 @@ public sealed partial class Alcohol120 { var alcTrk = new Track(); - if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT == track.Sequence) == - true) + if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT == track.Sequence) == true) { FullTOC.TrackDataDescriptor tocTrk = decodedToc.Value.TrackDescriptors.First(t => t.SessionNumber == i && @@ -775,7 +770,7 @@ public sealed partial class Alcohol120 (track.SubchannelType != TrackSubchannelType.None ? 96 : 0)); alcTrk.startLba = (uint)(track.StartSector + track.Pregap); - alcTrk.startOffset = track.FileOffset + (alcTrk.sectorSize * track.Pregap); + alcTrk.startOffset = track.FileOffset + alcTrk.sectorSize * track.Pregap; alcTrk.files = 1; alcTrk.extraOffset = (uint)currentExtraOffset; alcTrk.footerOffset = (uint)footerOffset; @@ -790,8 +785,8 @@ public sealed partial class Alcohol120 // Daemon Tools expect it to be like this alcTrk.unknown = new byte[] { - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 }; alcTrk.unknown2 = new byte[24]; @@ -900,7 +895,7 @@ public sealed partial class Alcohol120 // Write header _descriptorStream.Seek(0, SeekOrigin.Begin); - byte[] block = new byte[Marshal.SizeOf
()]; + var block = new byte[Marshal.SizeOf
()]; IntPtr blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); @@ -972,8 +967,7 @@ public sealed partial class Alcohol120 if(_alcTrackExtras.TryGetValue(alcoholTrack.point, out TrackExtra extra)) { - blockPtr = System.Runtime.InteropServices.Marshal. - AllocHGlobal(Marshal.SizeOf()); + blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); System.Runtime.InteropServices.Marshal.StructureToPtr(extra, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); @@ -1054,8 +1048,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -1097,7 +1090,7 @@ public sealed partial class Alcohol120 } _imageStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96))) + track.RawBytesPerSector, + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, SeekOrigin.Begin); _imageStream.Write(data, 0, data.Length); @@ -1122,8 +1115,7 @@ public sealed partial class Alcohol120 } CommonTypes.Structs.Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -1155,7 +1147,7 @@ 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, + 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/Anex86.cs b/Aaru.Images/Anex86/Anex86.cs index a8a3608a5..af3a702b4 100644 --- a/Aaru.Images/Anex86/Anex86.cs +++ b/Aaru.Images/Anex86/Anex86.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing Anex-86 disk images public sealed partial class Anex86 : IWritableImage diff --git a/Aaru.Images/Anex86/Identify.cs b/Aaru.Images/Anex86/Identify.cs index bd5bbbf9f..1a102affc 100644 --- a/Aaru.Images/Anex86/Identify.cs +++ b/Aaru.Images/Anex86/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Anex86 { /// @@ -48,7 +48,7 @@ public sealed partial class Anex86 if(stream.Length < Marshal.SizeOf
()) return false; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); _header = Marshal.SpanToStructureLittleEndian
(hdrB); diff --git a/Aaru.Images/Anex86/Properties.cs b/Aaru.Images/Anex86/Properties.cs index 2404092a3..a16a30efc 100644 --- a/Aaru.Images/Anex86/Properties.cs +++ b/Aaru.Images/Anex86/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Anex86 { /// @@ -47,7 +47,7 @@ public sealed partial class Anex86 /// public string Name => "Anex86 Disk Image"; /// - public Guid Id => new Guid("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); + public Guid Id => new("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); /// public string Author => "Natalia Portillo"; /// @@ -78,10 +78,9 @@ public sealed partial class Anex86 MediaType.ACORN_35_DS_DD, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.ACORN_35_DS_HD, MediaType.DOS_525_HD, MediaType.ACORN_525_DS_DD, MediaType.DOS_35_HD, MediaType.XDF_525, MediaType.DMF, MediaType.XDF_35, MediaType.DOS_35_ED, MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_525_HD, - MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD, MediaType.Unknown, MediaType.GENERIC_HDD, - MediaType.FlashDrive, MediaType.CompactFlash, MediaType.CompactFlashType2, MediaType.PCCardTypeI, - MediaType.PCCardTypeII, MediaType.PCCardTypeIII, MediaType.PCCardTypeIV, MediaType.MetaFloppy_Mod_I, - MediaType.MetaFloppy_Mod_II + MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD, MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, + MediaType.CompactFlash, MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, + MediaType.PCCardTypeIII, MediaType.PCCardTypeIV, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/Anex86/Read.cs b/Aaru.Images/Anex86/Read.cs index f22d15653..3d34427a0 100644 --- a/Aaru.Images/Anex86/Read.cs +++ b/Aaru.Images/Anex86/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Anex86 { /// @@ -50,7 +50,7 @@ public sealed partial class Anex86 if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); _header = Marshal.SpanToStructureLittleEndian
(hdrB); @@ -81,8 +81,7 @@ public sealed partial class Anex86 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -99,7 +98,7 @@ public sealed partial class Anex86 Stream stream = _anexImageFilter.GetDataForkStream(); - stream.Seek((long)((ulong)_header.hdrSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)((ulong)_header.hdrSize + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); diff --git a/Aaru.Images/Anex86/Structs.cs b/Aaru.Images/Anex86/Structs.cs index 3bc086a89..958834021 100644 --- a/Aaru.Images/Anex86/Structs.cs +++ b/Aaru.Images/Anex86/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Anex86 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/Anex86/Unsupported.cs b/Aaru.Images/Anex86/Unsupported.cs index f00d2cd9d..a77b21055 100644 --- a/Aaru.Images/Anex86/Unsupported.cs +++ b/Aaru.Images/Anex86/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Anex86 { /// diff --git a/Aaru.Images/Anex86/Write.cs b/Aaru.Images/Anex86/Write.cs index f2b5366ef..f14797bbf 100644 --- a/Aaru.Images/Anex86/Write.cs +++ b/Aaru.Images/Anex86/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Anex86 { /// @@ -133,7 +133,7 @@ public sealed partial class Anex86 return false; } - _writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(4096 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -165,7 +165,7 @@ public sealed partial class Anex86 return false; } - _writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(4096 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -229,7 +229,7 @@ public sealed partial class Anex86 } } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; MemoryMarshal.Write(hdr, ref _header); _writingStream.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Images/Apple2MG/Apple2MG.cs b/Aaru.Images/Apple2MG/Apple2MG.cs index c1f8052f4..3a23fe7de 100644 --- a/Aaru.Images/Apple2MG/Apple2MG.cs +++ b/Aaru.Images/Apple2MG/Apple2MG.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing XGD emulator disk images public sealed partial class Apple2Mg : IWritableImage diff --git a/Aaru.Images/Apple2MG/Constants.cs b/Aaru.Images/Apple2MG/Constants.cs index 7fc5ee17d..76a35f652 100644 --- a/Aaru.Images/Apple2MG/Constants.cs +++ b/Aaru.Images/Apple2MG/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Apple2Mg { diff --git a/Aaru.Images/Apple2MG/Enums.cs b/Aaru.Images/Apple2MG/Enums.cs index 205c49241..291bd751e 100644 --- a/Aaru.Images/Apple2MG/Enums.cs +++ b/Aaru.Images/Apple2MG/Enums.cs @@ -36,6 +36,8 @@ public sealed partial class Apple2Mg { enum SectorOrder : uint { - Dos = 0, ProDos = 1, Nibbles = 2 + Dos = 0, + ProDos = 1, + Nibbles = 2 } } \ No newline at end of file diff --git a/Aaru.Images/Apple2MG/Helpers.cs b/Aaru.Images/Apple2MG/Helpers.cs index 135918ea9..f598d37bc 100644 --- a/Aaru.Images/Apple2MG/Helpers.cs +++ b/Aaru.Images/Apple2MG/Helpers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; - namespace Aaru.DiscImages; +using Aaru.CommonTypes; + public sealed partial class Apple2Mg { MediaType GetMediaType() diff --git a/Aaru.Images/Apple2MG/Identify.cs b/Aaru.Images/Apple2MG/Identify.cs index 78f1dd0bc..e38efa228 100644 --- a/Aaru.Images/Apple2MG/Identify.cs +++ b/Aaru.Images/Apple2MG/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Apple2Mg { /// @@ -47,7 +47,7 @@ public sealed partial class Apple2Mg if(stream.Length < 65) return false; - byte[] header = new byte[64]; + var header = new byte[64]; stream.Read(header, 0, 64); Header hdr = Marshal.SpanToStructureLittleEndian
(header); diff --git a/Aaru.Images/Apple2MG/Properties.cs b/Aaru.Images/Apple2MG/Properties.cs index 52662ceae..4ae75a059 100644 --- a/Aaru.Images/Apple2MG/Properties.cs +++ b/Aaru.Images/Apple2MG/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Apple2Mg { /// @@ -47,7 +47,7 @@ public sealed partial class Apple2Mg /// public string Name => "Apple 2IMG"; /// - public Guid Id => new Guid("CBAF8824-BA5F-415F-953A-19A03519B2D1"); + public Guid Id => new("CBAF8824-BA5F-415F-953A-19A03519B2D1"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/Apple2MG/Read.cs b/Aaru.Images/Apple2MG/Read.cs index 64f62e74a..5a5f2f6aa 100644 --- a/Aaru.Images/Apple2MG/Read.cs +++ b/Aaru.Images/Apple2MG/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; @@ -40,8 +42,6 @@ using Aaru.Console; using Aaru.Filters; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Apple2Mg { /// @@ -52,10 +52,10 @@ public sealed partial class Apple2Mg _imageHeader = new Header(); - byte[] header = new byte[64]; + var header = new byte[64]; stream.Read(header, 0, 64); - byte[] magic = new byte[4]; - byte[] creator = new byte[4]; + var magic = new byte[4]; + var creator = new byte[4]; Array.Copy(header, 0, magic, 0, 4); Array.Copy(header, 4, creator, 0, 4); @@ -70,8 +70,7 @@ public sealed partial class Apple2Mg AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.magic = \"{0}\"", Encoding.ASCII.GetString(magic)); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.creator = \"{0}\"", - Encoding.ASCII.GetString(creator)); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.creator = \"{0}\"", Encoding.ASCII.GetString(creator)); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.headerSize = {0}", _imageHeader.HeaderSize); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.version = {0}", _imageHeader.Version); @@ -81,8 +80,7 @@ public sealed partial class Apple2Mg AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataOffset = 0x{0:X8}", _imageHeader.DataOffset); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataSize = {0}", _imageHeader.DataSize); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentOffset = 0x{0:X8}", - _imageHeader.CommentOffset); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentOffset = 0x{0:X8}", _imageHeader.CommentOffset); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentSize = {0}", _imageHeader.CommentSize); @@ -143,11 +141,10 @@ public sealed partial class Apple2Mg ? _interleave : _deinterleave; - for(int t = 0; t < 35; t++) + for(var t = 0; t < 35; t++) { - for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), _decodedImage, - (t * 16 * 256) + (offsets[s] * 256), 256); + for(var s = 0; s < 16; s++) + Array.Copy(tmp, t * 16 * 256 + s * 256, _decodedImage, t * 16 * 256 + offsets[s] * 256, 256); } _imageInfo.Sectors = 560; @@ -161,11 +158,10 @@ public sealed partial class Apple2Mg _decodedImage = new byte[_imageHeader.DataSize]; offsets = _interleave; - for(int t = 0; t < 200; t++) + for(var t = 0; t < 200; t++) { - for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), _decodedImage, - (t * 16 * 256) + (offsets[s] * 256), 256); + for(var s = 0; s < 16; s++) + Array.Copy(tmp, t * 16 * 256 + s * 256, _decodedImage, t * 16 * 256 + offsets[s] * 256, 256); } _imageInfo.Sectors = 1600; @@ -233,7 +229,7 @@ public sealed partial class Apple2Mg { stream.Seek(_imageHeader.CommentOffset, SeekOrigin.Begin); - byte[] comments = new byte[_imageHeader.CommentSize]; + var comments = new byte[_imageHeader.CommentSize]; stream.Read(comments, 0, (int)_imageHeader.CommentSize); _imageInfo.Comments = Encoding.ASCII.GetString(comments); } @@ -306,8 +302,7 @@ public sealed partial class Apple2Mg } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -329,8 +324,7 @@ public sealed partial class Apple2Mg { Stream stream = _a2MgImageFilter.GetDataForkStream(); - stream.Seek((long)(_imageHeader.DataOffset + (sectorAddress * _imageInfo.SectorSize)), - SeekOrigin.Begin); + stream.Seek((long)(_imageHeader.DataOffset + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); } diff --git a/Aaru.Images/Apple2MG/Structs.cs b/Aaru.Images/Apple2MG/Structs.cs index 94f0f9832..665207901 100644 --- a/Aaru.Images/Apple2MG/Structs.cs +++ b/Aaru.Images/Apple2MG/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - public sealed partial class Apple2Mg { [SuppressMessage("ReSharper", "NotAccessedField.Local"), StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/Apple2MG/Unsupported.cs b/Aaru.Images/Apple2MG/Unsupported.cs index 1d060a6e7..23ead8095 100644 --- a/Aaru.Images/Apple2MG/Unsupported.cs +++ b/Aaru.Images/Apple2MG/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Apple2Mg { /// diff --git a/Aaru.Images/Apple2MG/Write.cs b/Aaru.Images/Apple2MG/Write.cs index ab577b3c7..3b67582c9 100644 --- a/Aaru.Images/Apple2MG/Write.cs +++ b/Aaru.Images/Apple2MG/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Apple2Mg { /// @@ -51,7 +51,7 @@ public sealed partial class Apple2Mg { if(sectorSize != 512) if(sectorSize != 256 || - (mediaType != MediaType.Apple32SS && mediaType != MediaType.Apple33SS)) + mediaType != MediaType.Apple32SS && mediaType != MediaType.Apple33SS) { ErrorMessage = "Unsupported sector size"; @@ -128,7 +128,7 @@ public sealed partial class Apple2Mg return false; } - _writingStream.Seek((long)(0x40 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(0x40 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -160,7 +160,7 @@ public sealed partial class Apple2Mg return false; } - _writingStream.Seek((long)(0x40 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(0x40 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -194,8 +194,8 @@ public sealed partial class Apple2Mg return false; } - _writingStream.Seek(0x40 + (17 * 16 * 256), SeekOrigin.Begin); - byte[] tmp = new byte[256]; + _writingStream.Seek(0x40 + 17 * 16 * 256, SeekOrigin.Begin); + var tmp = new byte[256]; _writingStream.Read(tmp, 0, tmp.Length); bool isDos = tmp[0x01] == 17 && tmp[0x02] < 16 && tmp[0x27] <= 122 && tmp[0x34] == 35 && tmp[0x35] == 16 && @@ -207,8 +207,8 @@ public sealed partial class Apple2Mg Creator = CREATOR_AARU, DataOffset = 0x40, DataSize = (uint)(_imageInfo.Sectors * _imageInfo.SectorSize), - Flags = (uint)(_imageInfo.LastMediaSequence != 0 - ? VALID_VOLUME_NUMBER + (_imageInfo.MediaSequence & 0xFF) : 0), + Flags = (uint)(_imageInfo.LastMediaSequence != 0 ? VALID_VOLUME_NUMBER + (_imageInfo.MediaSequence & 0xFF) + : 0), HeaderSize = 0x40, ImageFormat = isDos ? SectorOrder.Dos : SectorOrder.ProDos, Magic = MAGIC, @@ -225,7 +225,7 @@ public sealed partial class Apple2Mg _writingStream.WriteByte(0); } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_imageHeader, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/AppleDOS/AppleDOS.cs b/Aaru.Images/AppleDOS/AppleDOS.cs index 876c69c92..3aae2869f 100644 --- a/Aaru.Images/AppleDOS/AppleDOS.cs +++ b/Aaru.Images/AppleDOS/AppleDOS.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing interleaved Apple DOS disk images public sealed partial class AppleDos : IWritableImage diff --git a/Aaru.Images/AppleDOS/Identify.cs b/Aaru.Images/AppleDOS/Identify.cs index 8dfdeb097..61d59fa43 100644 --- a/Aaru.Images/AppleDOS/Identify.cs +++ b/Aaru.Images/AppleDOS/Identify.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class AppleDos { /// diff --git a/Aaru.Images/AppleDOS/Properties.cs b/Aaru.Images/AppleDOS/Properties.cs index e2585ddb6..a1472f1b6 100644 --- a/Aaru.Images/AppleDOS/Properties.cs +++ b/Aaru.Images/AppleDOS/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class AppleDos { /// @@ -47,7 +47,7 @@ public sealed partial class AppleDos /// public string Name => "Apple ][ Interleaved Disk Image"; /// - public Guid Id => new Guid("A5828AC0-62C9-4304-81D4-EFD4AAE47360"); + public Guid Id => new("A5828AC0-62C9-4304-81D4-EFD4AAE47360"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/AppleDOS/Read.cs b/Aaru.Images/AppleDOS/Read.cs index 3721b7fc9..6282f83a9 100644 --- a/Aaru.Images/AppleDOS/Read.cs +++ b/Aaru.Images/AppleDOS/Read.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class AppleDos { /// @@ -46,7 +46,7 @@ public sealed partial class AppleDos Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] tmp = new byte[imageFilter.DataForkLength]; + var tmp = new byte[imageFilter.DataForkLength]; stream.Read(tmp, 0, tmp.Length); _extension = Path.GetExtension(imageFilter.Filename)?.ToLower(); @@ -72,11 +72,10 @@ public sealed partial class AppleDos ? _interleave : _deinterleave; - for(int t = 0; t < 35; t++) + for(var t = 0; t < 35; t++) { - for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), _deinterleaved, (t * 16 * 256) + (offsets[s] * 256), - 256); + for(var s = 0; s < 16; s++) + Array.Copy(tmp, t * 16 * 256 + s * 256, _deinterleaved, t * 16 * 256 + offsets[s] * 256, 256); } } @@ -96,8 +95,7 @@ public sealed partial class AppleDos } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) diff --git a/Aaru.Images/AppleDOS/Unsupported.cs b/Aaru.Images/AppleDOS/Unsupported.cs index 88a7550b0..9268b9e6b 100644 --- a/Aaru.Images/AppleDOS/Unsupported.cs +++ b/Aaru.Images/AppleDOS/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class AppleDos { /// diff --git a/Aaru.Images/AppleDOS/Write.cs b/Aaru.Images/AppleDOS/Write.cs index ce8b0f1ba..d9534b857 100644 --- a/Aaru.Images/AppleDOS/Write.cs +++ b/Aaru.Images/AppleDOS/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class AppleDos { /// @@ -61,8 +61,8 @@ public sealed partial class AppleDos return false; } - if((mediaType == MediaType.Apple32SS && sectors != 455) || - (mediaType == MediaType.Apple33SS && sectors != 560)) + if(mediaType == MediaType.Apple32SS && sectors != 455 || + mediaType == MediaType.Apple33SS && sectors != 560) { ErrorMessage = "Incorrect number of sectors for media"; @@ -177,10 +177,9 @@ public sealed partial class AppleDos tmp = _deinterleaved; else { - bool isDos = _deinterleaved[0x11001] == 17 && _deinterleaved[0x11002] < 16 && + bool isDos = _deinterleaved[0x11001] == 17 && _deinterleaved[0x11002] < 16 && _deinterleaved[0x11027] <= 122 && _deinterleaved[0x11034] == 35 && - _deinterleaved[0x11035] == 16 && _deinterleaved[0x11036] == 0 && - _deinterleaved[0x11037] == 1; + _deinterleaved[0x11035] == 16 && _deinterleaved[0x11036] == 0 && _deinterleaved[0x11037] == 1; tmp = new byte[_deinterleaved.Length]; @@ -192,10 +191,9 @@ public sealed partial class AppleDos ? _interleave : _deinterleave; - for(int t = 0; t < 35; t++) - for(int s = 0; s < 16; s++) - Array.Copy(_deinterleaved, (t * 16 * 256) + (offsets[s] * 256), tmp, (t * 16 * 256) + (s * 256), - 256); + 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); } _writingStream.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Images/AppleNIB/AppleNIB.cs b/Aaru.Images/AppleNIB/AppleNIB.cs index 17f2ed20e..df0cec117 100644 --- a/Aaru.Images/AppleNIB/AppleNIB.cs +++ b/Aaru.Images/AppleNIB/AppleNIB.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Checksum sectors /// /// Implements reading nibbelized Apple II disk images diff --git a/Aaru.Images/AppleNIB/Constants.cs b/Aaru.Images/AppleNIB/Constants.cs index 69b0a9c9b..ba3e74c0b 100644 --- a/Aaru.Images/AppleNIB/Constants.cs +++ b/Aaru.Images/AppleNIB/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class AppleNib { diff --git a/Aaru.Images/AppleNIB/Identify.cs b/Aaru.Images/AppleNIB/Identify.cs index cf7ee3ac7..aa2a7db19 100644 --- a/Aaru.Images/AppleNIB/Identify.cs +++ b/Aaru.Images/AppleNIB/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Decoders.Floppy; -namespace Aaru.DiscImages; - public sealed partial class AppleNib { /// @@ -47,7 +47,7 @@ public sealed partial class AppleNib if(stream.Length < 512) return false; - byte[] test = new byte[512]; + var test = new byte[512]; stream.Read(test, 0, 512); return Apple2.IsApple2GCR(test); diff --git a/Aaru.Images/AppleNIB/Properties.cs b/Aaru.Images/AppleNIB/Properties.cs index 9a3314ba0..04e08fbde 100644 --- a/Aaru.Images/AppleNIB/Properties.cs +++ b/Aaru.Images/AppleNIB/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class AppleNib { /// @@ -45,7 +45,7 @@ public sealed partial class AppleNib /// public string Name => "Apple NIB"; /// - public Guid Id => new Guid("AE171AE8-6747-49CC-B861-9D450B7CD42E"); + public Guid Id => new("AE171AE8-6747-49CC-B861-9D450B7CD42E"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/AppleNIB/Read.cs b/Aaru.Images/AppleNIB/Read.cs index 1f520410b..17dafcab0 100644 --- a/Aaru.Images/AppleNIB/Read.cs +++ b/Aaru.Images/AppleNIB/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Decoders.Floppy; -namespace Aaru.DiscImages; - public sealed partial class AppleNib { /// @@ -52,7 +52,7 @@ public sealed partial class AppleNib if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] buffer = new byte[stream.Length]; + var buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); AaruConsole.DebugWriteLine("Apple NIB Plugin", "Decoding whole image"); @@ -61,10 +61,10 @@ public sealed partial class AppleNib Dictionary rawSectors = new(); - int spt = 0; - bool allTracksEqual = true; + var spt = 0; + var allTracksEqual = true; - for(int i = 1; i < tracks.Count; i++) + for(var i = 1; i < tracks.Count; i++) allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length; if(allTracksEqual) @@ -91,16 +91,16 @@ public sealed partial class AppleNib skewing.SequenceEqual(_dosSkewing) ? "" : "Pro"); } - for(int i = 0; i < tracks.Count; i++) + for(var i = 0; i < tracks.Count; i++) foreach(Apple2.RawSector sector in tracks[i].sectors) if(skewed && spt != 0) { - ulong sectorNo = (ulong)((((sector.addressField.sector[0] & 0x55) << 1) | - (sector.addressField.sector[1] & 0x55)) & 0xFF); + var sectorNo = (ulong)((((sector.addressField.sector[0] & 0x55) << 1) | + (sector.addressField.sector[1] & 0x55)) & 0xFF); AaruConsole.DebugWriteLine("Apple NIB Plugin", - "Hardware sector {0} of track {1} goes to logical sector {2}", - sectorNo, i, skewing[sectorNo] + (ulong)(i * spt)); + "Hardware sector {0} of track {1} goes to logical sector {2}", sectorNo, + i, skewing[sectorNo] + (ulong)(i * spt)); rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector); _imageInfo.Sectors++; @@ -172,8 +172,7 @@ public sealed partial class AppleNib if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - return _cookedSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError - : ErrorNumber.SectorNotFound; + return _cookedSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } /// @@ -257,8 +256,7 @@ public sealed partial class AppleNib if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; - return _longSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError - : ErrorNumber.SectorNotFound; + return _longSectors.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } /// diff --git a/Aaru.Images/AppleNIB/Unsupported.cs b/Aaru.Images/AppleNIB/Unsupported.cs index 2c9bf1f1b..2565a2583 100644 --- a/Aaru.Images/AppleNIB/Unsupported.cs +++ b/Aaru.Images/AppleNIB/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class AppleNib { /// diff --git a/Aaru.Images/Apridisk/Apridisk.cs b/Aaru.Images/Apridisk/Apridisk.cs index 7581759b8..1f3bb363a 100644 --- a/Aaru.Images/Apridisk/Apridisk.cs +++ b/Aaru.Images/Apridisk/Apridisk.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Check writing /// /// Implements reading and writing Apridisk disk images diff --git a/Aaru.Images/Apridisk/Compression.cs b/Aaru.Images/Apridisk/Compression.cs index cedf254a0..7e187d8fc 100644 --- a/Aaru.Images/Apridisk/Compression.cs +++ b/Aaru.Images/Apridisk/Compression.cs @@ -30,16 +30,16 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; -namespace Aaru.DiscImages; - public sealed partial class Apridisk { static uint Decompress(byte[] compressed, out byte[] decompressed) { - int readp = 0; + var readp = 0; int cLen = compressed.Length; var buffer = new MemoryStream(); @@ -47,10 +47,10 @@ public sealed partial class Apridisk while(cLen >= 3) { - ushort blklen = BitConverter.ToUInt16(compressed, readp); + var blklen = BitConverter.ToUInt16(compressed, readp); readp += 2; - for(int i = 0; i < blklen; i++) + for(var i = 0; i < blklen; i++) buffer.WriteByte(compressed[readp]); uLen += blklen; diff --git a/Aaru.Images/Apridisk/Enums.cs b/Aaru.Images/Apridisk/Enums.cs index 8a7cf8844..724b227cc 100644 --- a/Aaru.Images/Apridisk/Enums.cs +++ b/Aaru.Images/Apridisk/Enums.cs @@ -36,12 +36,15 @@ public sealed partial class Apridisk { enum RecordType : uint { - Deleted = 0xE31D0000, Sector = 0xE31D0001, Comment = 0xE31D0002, + Deleted = 0xE31D0000, + Sector = 0xE31D0001, + Comment = 0xE31D0002, Creator = 0xE31D0003 } enum CompressType : ushort { - Uncompresed = 0x9E90, Compressed = 0x3E5A + Uncompresed = 0x9E90, + Compressed = 0x3E5A } } \ No newline at end of file diff --git a/Aaru.Images/Apridisk/Helpers.cs b/Aaru.Images/Apridisk/Helpers.cs index f010e9cd6..7dd89376c 100644 --- a/Aaru.Images/Apridisk/Helpers.cs +++ b/Aaru.Images/Apridisk/Helpers.cs @@ -36,9 +36,9 @@ public sealed partial class Apridisk { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); - byte head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); - byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); + var cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + var head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); + var sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } diff --git a/Aaru.Images/Apridisk/Identify.cs b/Aaru.Images/Apridisk/Identify.cs index 73bd0fe14..1d9b502d5 100644 --- a/Aaru.Images/Apridisk/Identify.cs +++ b/Aaru.Images/Apridisk/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class Apridisk { /// @@ -47,7 +47,7 @@ public sealed partial class Apridisk if(stream.Length < _signature.Length) return false; - byte[] sigB = new byte[_signature.Length]; + var sigB = new byte[_signature.Length]; stream.Read(sigB, 0, _signature.Length); return sigB.SequenceEqual(_signature); diff --git a/Aaru.Images/Apridisk/Properties.cs b/Aaru.Images/Apridisk/Properties.cs index b1a0261b8..4cc60912f 100644 --- a/Aaru.Images/Apridisk/Properties.cs +++ b/Aaru.Images/Apridisk/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Apridisk { /// @@ -47,7 +47,7 @@ public sealed partial class Apridisk /// public string Name => "ACT Apricot Disk Image"; /// - public Guid Id => new Guid("43408CF3-6DB3-449F-A779-2B0E497C5B14"); + public Guid Id => new("43408CF3-6DB3-449F-A779-2B0E497C5B14"); /// public string Author => "Natalia Portillo"; /// @@ -71,11 +71,11 @@ public sealed partial class Apridisk { MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.Apricot_35, MediaType.ATARI_35_DS_DD, MediaType.ATARI_35_DS_DD_11, MediaType.ATARI_35_SS_DD, MediaType.ATARI_35_SS_DD_11, MediaType.DMF, - MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, - MediaType.DOS_35_HD, MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, - MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, - MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, - MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II + MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD, + MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, MediaType.DOS_525_DS_DD_9, + MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, MediaType.FDFORMAT_35_DD, + MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, MediaType.RX50, + MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => new[] diff --git a/Aaru.Images/Apridisk/Read.cs b/Aaru.Images/Apridisk/Read.cs index 27756d87b..b884607ba 100644 --- a/Aaru.Images/Apridisk/Read.cs +++ b/Aaru.Images/Apridisk/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Apridisk { /// @@ -58,7 +58,7 @@ public sealed partial class Apridisk // Count cylinders while(stream.Position < stream.Length) { - byte[] recB = new byte[recordSize]; + var recB = new byte[recordSize]; stream.Read(recB, 0, recordSize); Record record = Marshal.SpanToStructureLittleEndian(recB); @@ -74,7 +74,7 @@ public sealed partial class Apridisk case RecordType.Comment: AaruConsole.DebugWriteLine("Apridisk plugin", "Found comment record at {0}", stream.Position); stream.Seek(record.headerSize - recordSize, SeekOrigin.Current); - byte[] commentB = new byte[record.dataSize]; + var commentB = new byte[record.dataSize]; stream.Read(commentB, 0, commentB.Length); _imageInfo.Comments = StringHandlers.CToString(commentB); AaruConsole.DebugWriteLine("Apridisk plugin", "Comment: \"{0}\"", _imageInfo.Comments); @@ -83,7 +83,7 @@ public sealed partial class Apridisk case RecordType.Creator: AaruConsole.DebugWriteLine("Apridisk plugin", "Found creator record at {0}", stream.Position); stream.Seek(record.headerSize - recordSize, SeekOrigin.Current); - byte[] creatorB = new byte[record.dataSize]; + var creatorB = new byte[record.dataSize]; stream.Read(creatorB, 0, creatorB.Length); _imageInfo.Creator = StringHandlers.CToString(creatorB); AaruConsole.DebugWriteLine("Apridisk plugin", "Creator: \"{0}\"", _imageInfo.Creator); @@ -126,7 +126,7 @@ public sealed partial class Apridisk _sectorsData = new byte[totalCylinders][][][]; // Total sectors per track - uint[][] spts = new uint[totalCylinders][]; + var spts = new uint[totalCylinders][]; _imageInfo.Cylinders = (ushort)totalCylinders; _imageInfo.Heads = (byte)totalHeads; @@ -136,12 +136,12 @@ public sealed partial class Apridisk totalCylinders, totalHeads, maxSector); // Create heads - for(int i = 0; i < totalCylinders; i++) + for(var i = 0; i < totalCylinders; i++) { _sectorsData[i] = new byte[totalHeads][][]; spts[i] = new uint[totalHeads]; - for(int j = 0; j < totalHeads; j++) + for(var j = 0; j < totalHeads; j++) _sectorsData[i][j] = new byte[maxSector + 1][]; } @@ -154,7 +154,7 @@ public sealed partial class Apridisk while(stream.Position < stream.Length) { - byte[] recB = new byte[recordSize]; + var recB = new byte[recordSize]; stream.Read(recB, 0, recordSize); Record record = Marshal.SpanToStructureLittleEndian(recB); @@ -172,15 +172,14 @@ public sealed partial class Apridisk case RecordType.Sector: stream.Seek(record.headerSize - recordSize, SeekOrigin.Current); - byte[] data = new byte[record.dataSize]; + var data = new byte[record.dataSize]; stream.Read(data, 0, data.Length); spts[record.cylinder][record.head]++; uint realLength = record.dataSize; if(record.compression == CompressType.Compressed) - realLength = - Decompress(data, out _sectorsData[record.cylinder][record.head][record.sector]); + realLength = Decompress(data, out _sectorsData[record.cylinder][record.head][record.sector]); else _sectorsData[record.cylinder][record.head][record.sector] = data; @@ -193,8 +192,7 @@ public sealed partial class Apridisk } } - AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} bytes per sector", - _imageInfo.SectorSize); + AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} bytes per sector", _imageInfo.SectorSize); // Count sectors per track uint spt = uint.MaxValue; diff --git a/Aaru.Images/Apridisk/Structs.cs b/Aaru.Images/Apridisk/Structs.cs index 08f5e5ad6..86c190ed7 100644 --- a/Aaru.Images/Apridisk/Structs.cs +++ b/Aaru.Images/Apridisk/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Apridisk { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/Apridisk/Unsupported.cs b/Aaru.Images/Apridisk/Unsupported.cs index 4779382cd..4764d6592 100644 --- a/Aaru.Images/Apridisk/Unsupported.cs +++ b/Aaru.Images/Apridisk/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Apridisk { /// diff --git a/Aaru.Images/Apridisk/Write.cs b/Aaru.Images/Apridisk/Write.cs index 1f6e8fd49..cb211d4da 100644 --- a/Aaru.Images/Apridisk/Write.cs +++ b/Aaru.Images/Apridisk/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Apridisk { /// @@ -176,7 +176,7 @@ public sealed partial class Apridisk _writingStream.Seek(0, SeekOrigin.Begin); _writingStream.Write(_signature, 0, _signature.Length); - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; for(ushort c = 0; c < _imageInfo.Cylinders; c++) { diff --git a/Aaru.Images/BLU/BLU.cs b/Aaru.Images/BLU/BLU.cs index 7ec646a30..f2847edb7 100644 --- a/Aaru.Images/BLU/BLU.cs +++ b/Aaru.Images/BLU/BLU.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading Basic Lisa Utility disk images public sealed partial class Blu : IWritableImage, IVerifiableSectorsImage { diff --git a/Aaru.Images/BLU/Identify.cs b/Aaru.Images/BLU/Identify.cs index 57dd8f9b9..be14f685b 100644 --- a/Aaru.Images/BLU/Identify.cs +++ b/Aaru.Images/BLU/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Blu { /// @@ -48,7 +48,7 @@ public sealed partial class Blu if(stream.Length < 0x200) return false; - byte[] header = new byte[0x17]; + var header = new byte[0x17]; stream.Read(header, 0, 0x17); var tmpHdr = new BluHeader @@ -61,7 +61,7 @@ public sealed partial class Blu tmpHdr.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF; tmpHdr.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15); - for(int i = 0; i < 0xD; i++) + for(var i = 0; i < 0xD; i++) if(tmpHdr.DeviceName[i] < 0x20) return false; diff --git a/Aaru.Images/BLU/Properties.cs b/Aaru.Images/BLU/Properties.cs index e56be049d..9598c75ba 100644 --- a/Aaru.Images/BLU/Properties.cs +++ b/Aaru.Images/BLU/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Blu { /// @@ -46,7 +46,7 @@ public sealed partial class Blu /// public string Name => "Basic Lisa Utility"; /// - public Guid Id => new Guid("A153E2F8-4235-432D-9A7F-20807B0BCD74"); + public Guid Id => new("A153E2F8-4235-432D-9A7F-20807B0BCD74"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/BLU/Read.cs b/Aaru.Images/BLU/Read.cs index b4dc530a7..765ad151b 100644 --- a/Aaru.Images/BLU/Read.cs +++ b/Aaru.Images/BLU/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Blu { /// @@ -53,7 +53,7 @@ public sealed partial class Blu DeviceName = new byte[0x0D] }; - byte[] header = new byte[0x17]; + var header = new byte[0x17]; stream.Read(header, 0, 0x17); Array.Copy(header, 0, _imageHeader.DeviceName, 0, 0x0D); _imageHeader.DeviceType = BigEndianBitConverter.ToUInt32(header, 0x0C) & 0x00FFFFFF; @@ -67,7 +67,7 @@ public sealed partial class Blu AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceBlock = {0}", _imageHeader.DeviceBlocks); AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.bytesPerBlock = {0}", _imageHeader.BytesPerBlock); - for(int i = 0; i < 0xD; i++) + for(var i = 0; i < 0xD; i++) if(_imageHeader.DeviceName[i] < 0x20) return ErrorNumber.InvalidArgument; @@ -83,14 +83,13 @@ public sealed partial class Blu _imageInfo.Sectors = _imageHeader.DeviceBlocks; _imageInfo.ImageSize = _imageHeader.DeviceBlocks * _imageHeader.BytesPerBlock; _bptag = _imageHeader.BytesPerBlock - 0x200; - byte[] hdrTag = new byte[_bptag]; + var hdrTag = new byte[_bptag]; Array.Copy(header, 0x200, hdrTag, 0, _bptag); switch(StringHandlers.CToString(_imageHeader.DeviceName)) { case PROFILE_NAME: - _imageInfo.MediaType = - _imageInfo.Sectors == 0x2600 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; + _imageInfo.MediaType = _imageInfo.Sectors == 0x2600 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; _imageInfo.Cylinders = 152; _imageInfo.Heads = 4; @@ -98,8 +97,7 @@ public sealed partial class Blu break; case PROFILE10_NAME: - _imageInfo.MediaType = - _imageInfo.Sectors == 0x4C00 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; + _imageInfo.MediaType = _imageInfo.Sectors == 0x4C00 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; _imageInfo.Cylinders = 304; _imageInfo.Heads = 4; @@ -152,8 +150,7 @@ public sealed partial class Blu } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -171,17 +168,17 @@ public sealed partial class Blu return ErrorNumber.OutOfRange; var ms = new MemoryStream(); - int seek = 0; - int read = 0x200; + var seek = 0; + var read = 0x200; int skip = _bptag; Stream stream = _bluImageFilter.GetDataForkStream(); stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { stream.Seek(seek, SeekOrigin.Current); - byte[] sector = new byte[read]; + var sector = new byte[read]; stream.Read(sector, 0, read); ms.Write(sector, 0, read); stream.Seek(skip, SeekOrigin.Current); @@ -210,17 +207,17 @@ public sealed partial class Blu return ErrorNumber.SectorNotFound; var ms = new MemoryStream(); - int seek = 0x200; + var seek = 0x200; int read = _bptag; - int skip = 0; + var skip = 0; Stream stream = _bluImageFilter.GetDataForkStream(); stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { stream.Seek(seek, SeekOrigin.Current); - byte[] sector = new byte[read]; + var sector = new byte[read]; stream.Read(sector, 0, read); ms.Write(sector, 0, read); stream.Seek(skip, SeekOrigin.Current); diff --git a/Aaru.Images/BLU/Unsupported.cs b/Aaru.Images/BLU/Unsupported.cs index 87d04c366..f9f3e15dc 100644 --- a/Aaru.Images/BLU/Unsupported.cs +++ b/Aaru.Images/BLU/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Blu { /// diff --git a/Aaru.Images/BLU/Verify.cs b/Aaru.Images/BLU/Verify.cs index bc4928c97..3df159eb4 100644 --- a/Aaru.Images/BLU/Verify.cs +++ b/Aaru.Images/BLU/Verify.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; - namespace Aaru.DiscImages; +using System.Collections.Generic; + public sealed partial class Blu { // TODO: Check tag checksums diff --git a/Aaru.Images/BLU/Write.cs b/Aaru.Images/BLU/Write.cs index 03a27d2dc..126a5d042 100644 --- a/Aaru.Images/BLU/Write.cs +++ b/Aaru.Images/BLU/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Schemas; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.DiscImages; - public sealed partial class Blu { /// @@ -130,7 +130,7 @@ public sealed partial class Blu return false; } - _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -164,7 +164,7 @@ public sealed partial class Blu return false; } - _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -253,7 +253,7 @@ public sealed partial class Blu newTag ??= new byte[longSectorSize - 512]; - _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin); _writingStream.Write(data, 0, 512); _writingStream.Write(newTag, 0, newTag.Length); @@ -304,7 +304,7 @@ public sealed partial class Blu // Sony tag, convert to Profile case 12 when longSectorSize == 532: oldTag = new byte[12]; - Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 12); + Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 12); newTag = LisaTag.DecodeSonyTag(oldTag)?.ToProfile().GetBytes(); break; @@ -312,7 +312,7 @@ public sealed partial class Blu // Sony tag, convert to Priam case 12: oldTag = new byte[12]; - Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 12); + Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 12); newTag = LisaTag.DecodeSonyTag(oldTag)?.ToPriam().GetBytes(); break; @@ -320,14 +320,14 @@ public sealed partial class Blu // Profile tag, copy to Profile case 20 when longSectorSize == 532: newTag = new byte[20]; - Array.Copy(data, (givenSectorSize * i) + 512, newTag, 0, 20); + Array.Copy(data, givenSectorSize * i + 512, newTag, 0, 20); break; // Profile tag, convert to Priam case 20: oldTag = new byte[20]; - Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 20); + Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 20); newTag = LisaTag.DecodeProfileTag(oldTag)?.ToPriam().GetBytes(); break; @@ -335,7 +335,7 @@ public sealed partial class Blu // Priam tag, convert to Profile case 24 when longSectorSize == 532: oldTag = new byte[24]; - Array.Copy(data, (givenSectorSize * i) + 512, oldTag, 0, 24); + Array.Copy(data, givenSectorSize * i + 512, oldTag, 0, 24); newTag = LisaTag.DecodePriamTag(oldTag)?.ToProfile().GetBytes(); break; @@ -343,7 +343,7 @@ public sealed partial class Blu // Priam tag, copy to Priam case 24: newTag = new byte[24]; - Array.Copy(data, (givenSectorSize * i) + 512, newTag, 0, 24); + Array.Copy(data, givenSectorSize * i + 512, newTag, 0, 24); break; case 0: @@ -358,8 +358,8 @@ public sealed partial class Blu newTag ??= new byte[longSectorSize - 512]; - _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); - _writingStream.Write(data, (int)(givenSectorSize * i), 512); + _writingStream.Seek(longSectorSize + (long)sectorAddress * longSectorSize, SeekOrigin.Begin); + _writingStream.Write(data, (int)(givenSectorSize * i), 512); _writingStream.Write(newTag, 0, newTag.Length); } @@ -380,7 +380,7 @@ public sealed partial class Blu byte[] markerTag = Encoding.UTF8.GetBytes("Aaru " + Version.GetVersion()); byte[] driveName; - byte[] driveType = new byte[3]; + var driveType = new byte[3]; byte[] driveBlocks = BigEndianBitConverter.GetBytes((uint)_imageInfo.Sectors); int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; byte[] blockSize = BigEndianBitConverter.GetBytes((ushort)longSectorSize); diff --git a/Aaru.Images/BlindWrite4/BlindWrite4.cs b/Aaru.Images/BlindWrite4/BlindWrite4.cs index 3c8ff1fb8..a336d5c1f 100644 --- a/Aaru.Images/BlindWrite4/BlindWrite4.cs +++ b/Aaru.Images/BlindWrite4/BlindWrite4.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Too many unknowns, plus a completely unknown footer, to make this writable /// /// Implements reading BlindWrite 4 disc images diff --git a/Aaru.Images/BlindWrite4/Constants.cs b/Aaru.Images/BlindWrite4/Constants.cs index 2a2064247..86a4f6b29 100644 --- a/Aaru.Images/BlindWrite4/Constants.cs +++ b/Aaru.Images/BlindWrite4/Constants.cs @@ -37,7 +37,6 @@ public sealed partial class BlindWrite4 /// "BLINDWRITE TOC FILE" readonly byte[] _bw4Signature = { - 0x42, 0x4C, 0x49, 0x4E, 0x44, 0x57, 0x52, 0x49, 0x54, 0x45, 0x20, 0x54, 0x4F, 0x43, 0x20, 0x46, 0x49, 0x4C, - 0x45 + 0x42, 0x4C, 0x49, 0x4E, 0x44, 0x57, 0x52, 0x49, 0x54, 0x45, 0x20, 0x54, 0x4F, 0x43, 0x20, 0x46, 0x49, 0x4C, 0x45 }; } \ No newline at end of file diff --git a/Aaru.Images/BlindWrite4/Enums.cs b/Aaru.Images/BlindWrite4/Enums.cs index bd9bde985..8b1621dfb 100644 --- a/Aaru.Images/BlindWrite4/Enums.cs +++ b/Aaru.Images/BlindWrite4/Enums.cs @@ -36,6 +36,8 @@ public sealed partial class BlindWrite4 { enum TrackType : byte { - Audio = 0, Mode1 = 1, Mode2 = 2 + Audio = 0, + Mode1 = 1, + Mode2 = 2 } } \ No newline at end of file diff --git a/Aaru.Images/BlindWrite4/Identify.cs b/Aaru.Images/BlindWrite4/Identify.cs index 98b423a09..b98bc5c73 100644 --- a/Aaru.Images/BlindWrite4/Identify.cs +++ b/Aaru.Images/BlindWrite4/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite4 { /// @@ -47,7 +47,7 @@ public sealed partial class BlindWrite4 if(stream.Length < 19) return false; - byte[] signature = new byte[19]; + var signature = new byte[19]; stream.Read(signature, 0, 19); return _bw4Signature.SequenceEqual(signature); diff --git a/Aaru.Images/BlindWrite4/Properties.cs b/Aaru.Images/BlindWrite4/Properties.cs index 0b2e3c828..3c57f4ce9 100644 --- a/Aaru.Images/BlindWrite4/Properties.cs +++ b/Aaru.Images/BlindWrite4/Properties.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite4 { /// @@ -46,7 +46,7 @@ public sealed partial class BlindWrite4 /// public string Name => "BlindWrite 4"; /// - public Guid Id => new Guid("664568B2-15D4-4E64-8A7A-20BDA8B8386F"); + public Guid Id => new("664568B2-15D4-4E64-8A7A-20BDA8B8386F"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/BlindWrite4/Read.cs b/Aaru.Images/BlindWrite4/Read.cs index 9a393a0db..e87054983 100644 --- a/Aaru.Images/BlindWrite4/Read.cs +++ b/Aaru.Images/BlindWrite4/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Globalization; @@ -45,8 +47,6 @@ using Aaru.Decoders.CD; using Aaru.Helpers; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite4 { /// @@ -58,10 +58,10 @@ public sealed partial class BlindWrite4 if(stream.Length < 19) return ErrorNumber.InvalidArgument; - byte[] tmpArray = new byte[19]; - byte[] tmpUShort = new byte[2]; - byte[] tmpUInt = new byte[4]; - byte[] tmpULong = new byte[8]; + var tmpArray = new byte[19]; + var tmpUShort = new byte[2]; + var tmpUInt = new byte[4]; + var tmpULong = new byte[8]; stream.Read(tmpArray, 0, 19); @@ -153,7 +153,7 @@ public sealed partial class BlindWrite4 _bwTracks = new List(); - for(int i = 0; i < _header.TrackDescriptors; i++) + for(var i = 0; i < _header.TrackDescriptors; i++) { AaruConsole.DebugWriteLine("BlindWrite4 plugin", "stream.Position = {0}", stream.Position); @@ -210,7 +210,7 @@ public sealed partial class BlindWrite4 track.unknown13 = new uint[2]; - for(int j = 0; j < track.unknown13.Length; j++) + for(var j = 0; j < track.unknown13.Length; j++) { stream.Read(tmpUInt, 0, 4); track.unknown13[j] = BitConverter.ToUInt32(tmpUInt, 0); @@ -326,9 +326,9 @@ public sealed partial class BlindWrite4 AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.offset = {0}", track.offset); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.subchannel = {0}", track.subchannel); - for(int j = 0; j < track.unknown1.Length; j++) - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown1[{1}] = 0x{0:X8}", - track.unknown1[j], j); + for(var j = 0; j < track.unknown1.Length; j++) + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown1[{1}] = 0x{0:X8}", track.unknown1[j], + j); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown2 = {0}", track.unknown2); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown3 = {0}", track.unknown3); @@ -349,9 +349,9 @@ public sealed partial class BlindWrite4 AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.pregap = {0}", track.pregap); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.startSector = {0}", track.startSector); - for(int j = 0; j < track.unknown13.Length; j++) - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown13[{1}] = 0x{0:X8}", - track.unknown13[j], j); + for(var j = 0; j < track.unknown13.Length; j++) + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.unknown13[{1}] = 0x{0:X8}", track.unknown13[j], + j); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.titleLen = {0}", track.titleLen); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.title = {0}", track.title); @@ -398,45 +398,37 @@ public sealed partial class BlindWrite4 break; _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.DataFile.ToLower(CultureInfo. - CurrentCulture))); + _header.DataFile.ToLower(CultureInfo.CurrentCulture))); if(_dataFilter != null) break; _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.DataFile.ToUpper(CultureInfo. - CurrentCulture))); + _header.DataFile.ToUpper(CultureInfo.CurrentCulture))); if(_dataFilter != null) break; - _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last())); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries).Last())); if(_dataFilter != null) break; - _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last().ToLower(CultureInfo.CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries).Last().ToLower(CultureInfo.CurrentCulture))); if(_dataFilter != null) break; - _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile. - Split(new[] - { - '\\' - }, StringSplitOptions.RemoveEmptyEntries). - Last().ToUpper(CultureInfo.CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.DataFile.Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries).Last().ToUpper(CultureInfo.CurrentCulture))); if(_dataFilter != null) break; @@ -459,11 +451,9 @@ public sealed partial class BlindWrite4 _subFilter = ((((filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile)) ?? filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.SubchannelFile. - ToLower(CultureInfo.CurrentCulture)))) ?? + _header.SubchannelFile.ToLower(CultureInfo.CurrentCulture)))) ?? filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - _header.SubchannelFile. - ToUpper(CultureInfo.CurrentCulture)))) ?? + _header.SubchannelFile.ToUpper(CultureInfo.CurrentCulture)))) ?? filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, _header.SubchannelFile.Split(new[] { '\\' @@ -498,8 +488,7 @@ public sealed partial class BlindWrite4 if(!string.IsNullOrEmpty(bwTrack.filename)) do { - track.Filter = - filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename)); + track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename)); if(track.Filter != null) break; @@ -518,38 +507,32 @@ public sealed partial class BlindWrite4 if(track.Filter != null) break; - track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - bwTrack.filename.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). + track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename. + Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries). Last())); if(track.Filter != null) break; - track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - bwTrack.filename.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). + track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename. + Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries). Last().ToLower(CultureInfo. CurrentCulture))); if(track.Filter != null) break; - track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - bwTrack.filename.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). + track.Filter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, bwTrack.filename. + Split(new[] + { + '\\' + }, StringSplitOptions.RemoveEmptyEntries). Last().ToUpper(CultureInfo. CurrentCulture))); @@ -560,9 +543,9 @@ public sealed partial class BlindWrite4 track.File = _dataFilter.Filename; - track.FileOffset = bwTrack.offset + ((150 - bwTrack.pregapOffsetAdjustment) * 2352); + track.FileOffset = bwTrack.offset + (150 - bwTrack.pregapOffsetAdjustment) * 2352; - track.SubchannelOffset = ((bwTrack.offset / 2352) + (150 - bwTrack.pregapOffsetAdjustment)) * 96; + track.SubchannelOffset = (bwTrack.offset / 2352 + (150 - bwTrack.pregapOffsetAdjustment)) * 96; if(bwTrack.pregap > 0) { @@ -755,11 +738,11 @@ public sealed partial class BlindWrite4 _imageInfo.LastModificationTime = _dataFilter.LastWriteTime; _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - bool data = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; foreach(Track bwTrack in Tracks) { @@ -792,7 +775,7 @@ public sealed partial class BlindWrite4 Sessions.Count > 1 && mode2) _imageInfo.MediaType = MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = MediaType.CDROM; @@ -830,8 +813,7 @@ public sealed partial class BlindWrite4 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -892,7 +874,7 @@ public sealed partial class BlindWrite4 uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.Type) { @@ -947,9 +929,9 @@ public sealed partial class BlindWrite4 buffer = br.ReadBytes((int)(sectorSize * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, sectorSize * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -961,7 +943,7 @@ public sealed partial class BlindWrite4 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1155,7 +1137,7 @@ public sealed partial class BlindWrite4 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); diff --git a/Aaru.Images/BlindWrite4/Structs.cs b/Aaru.Images/BlindWrite4/Structs.cs index 36eb60b12..d98d3757d 100644 --- a/Aaru.Images/BlindWrite4/Structs.cs +++ b/Aaru.Images/BlindWrite4/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite4 { struct Header diff --git a/Aaru.Images/BlindWrite4/Verify.cs b/Aaru.Images/BlindWrite4/Verify.cs index c6af330f5..31fe2df7a 100644 --- a/Aaru.Images/BlindWrite4/Verify.cs +++ b/Aaru.Images/BlindWrite4/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite4 { /// @@ -58,10 +58,10 @@ public sealed partial class BlindWrite4 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class BlindWrite4 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/BlindWrite5/BlindWrite5.cs b/Aaru.Images/BlindWrite5/BlindWrite5.cs index 4ea43dcd0..5714d5759 100644 --- a/Aaru.Images/BlindWrite5/BlindWrite5.cs +++ b/Aaru.Images/BlindWrite5/BlindWrite5.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Too many unknowns to make this writable /// /// Implements reading BlindWrite 5/6/7 disc images diff --git a/Aaru.Images/BlindWrite5/Enums.cs b/Aaru.Images/BlindWrite5/Enums.cs index c76d954bb..4360ab3f1 100644 --- a/Aaru.Images/BlindWrite5/Enums.cs +++ b/Aaru.Images/BlindWrite5/Enums.cs @@ -30,22 +30,28 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class BlindWrite5 { enum TrackType : byte { - NotData = 0, Audio = 1, Mode1 = 2, - Mode2 = 3, Mode2F1 = 4, Mode2F2 = 5, + NotData = 0, + Audio = 1, + Mode1 = 2, + Mode2 = 3, + Mode2F1 = 4, + Mode2F2 = 5, Dvd = 6 } enum TrackSubchannel : byte { - None = 0, Q16 = 2, Linear = 4 + None = 0, + Q16 = 2, + Linear = 4 } } \ No newline at end of file diff --git a/Aaru.Images/BlindWrite5/Helpers.cs b/Aaru.Images/BlindWrite5/Helpers.cs index e1c0c7853..730ab3712 100644 --- a/Aaru.Images/BlindWrite5/Helpers.cs +++ b/Aaru.Images/BlindWrite5/Helpers.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using Aaru.CommonTypes; using Aaru.Decoders.SCSI.MMC; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { static CommonTypes.Enums.TrackType BlindWriteTrackTypeToTrackType(TrackType trackType) diff --git a/Aaru.Images/BlindWrite5/Identify.cs b/Aaru.Images/BlindWrite5/Identify.cs index 8edc86643..bfa4ae10a 100644 --- a/Aaru.Images/BlindWrite5/Identify.cs +++ b/Aaru.Images/BlindWrite5/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { /// @@ -47,10 +47,10 @@ public sealed partial class BlindWrite5 if(stream.Length < 276) return false; - byte[] signature = new byte[16]; + var signature = new byte[16]; stream.Read(signature, 0, 16); - byte[] footer = new byte[16]; + var footer = new byte[16]; stream.Seek(-16, SeekOrigin.End); stream.Read(footer, 0, 16); diff --git a/Aaru.Images/BlindWrite5/Properties.cs b/Aaru.Images/BlindWrite5/Properties.cs index 079a597e1..c94f9f718 100644 --- a/Aaru.Images/BlindWrite5/Properties.cs +++ b/Aaru.Images/BlindWrite5/Properties.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { /// @@ -46,7 +46,7 @@ public sealed partial class BlindWrite5 /// public string Name => "BlindWrite 5"; /// - public Guid Id => new Guid("9CB7A381-0509-4F9F-B801-3F65434BC3EE"); + public Guid Id => new("9CB7A381-0509-4F9F-B801-3F65434BC3EE"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index a508fbde6..4e9cda78e 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Globalization; @@ -51,8 +53,6 @@ using Aaru.Helpers; using DMI = Aaru.Decoders.Xbox.DMI; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { /// @@ -64,31 +64,28 @@ public sealed partial class BlindWrite5 if(stream.Length < 276) return ErrorNumber.InvalidArgument; - byte[] hdr = new byte[260]; + var hdr = new byte[260]; stream.Read(hdr, 0, 260); _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.signature = {0}", StringHandlers.CToString(_header.signature)); - for(int i = 0; i < _header.unknown1.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown1[{1}] = 0x{0:X8}", _header.unknown1[i], - i); + for(var i = 0; i < _header.unknown1.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown1[{1}] = 0x{0:X8}", _header.unknown1[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.profile = {0}", _header.profile); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.sessions = {0}", _header.sessions); - for(int i = 0; i < _header.unknown2.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown2[{1}] = 0x{0:X8}", _header.unknown2[i], - i); + for(var i = 0; i < _header.unknown2.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown2[{1}] = 0x{0:X8}", _header.unknown2[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcnIsValid = {0}", _header.mcnIsValid); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcn = {0}", StringHandlers.CToString(_header.mcn)); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown3 = 0x{0:X4}", _header.unknown3); - for(int i = 0; i < _header.unknown4.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown4[{1}] = 0x{0:X8}", _header.unknown4[i], - i); + for(var i = 0; i < _header.unknown4.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown4[{1}] = 0x{0:X8}", _header.unknown4[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.pmaLen = {0}", _header.pmaLen); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.atipLen = {0}", _header.atipLen); @@ -96,16 +93,14 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.cdInfoLen = {0}", _header.cdInfoLen); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.bcaLen = {0}", _header.bcaLen); - for(int i = 0; i < _header.unknown5.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown5[{1}] = 0x{0:X8}", _header.unknown5[i], - i); + for(var i = 0; i < _header.unknown5.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown5[{1}] = 0x{0:X8}", _header.unknown5[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdStrLen = {0}", _header.dvdStrLen); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdInfoLen = {0}", _header.dvdInfoLen); - for(int i = 0; i < _header.unknown6.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown6[{1}] = 0x{0:X2}", _header.unknown6[i], - i); + for(var i = 0; i < _header.unknown6.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown6[{1}] = 0x{0:X2}", _header.unknown6[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.manufacturer = {0}", StringHandlers.CToString(_header.manufacturer)); @@ -148,7 +143,7 @@ public sealed partial class BlindWrite5 if(_unkBlock.Length > 0) stream.Read(_unkBlock, 0, _unkBlock.Length); - byte[] temp = new byte[_header.pmaLen]; + var temp = new byte[_header.pmaLen]; if(temp.Length > 0) { @@ -247,20 +242,20 @@ public sealed partial class BlindWrite5 _discInformation = null; // How many data blocks - byte[] tmpArray = new byte[4]; + var tmpArray = new byte[4]; stream.Read(tmpArray, 0, tmpArray.Length); - uint dataBlockCount = BitConverter.ToUInt32(tmpArray, 0); + var dataBlockCount = BitConverter.ToUInt32(tmpArray, 0); stream.Read(tmpArray, 0, tmpArray.Length); - uint dataPathLen = BitConverter.ToUInt32(tmpArray, 0); - byte[] dataPathBytes = new byte[dataPathLen]; + var dataPathLen = BitConverter.ToUInt32(tmpArray, 0); + var dataPathBytes = new byte[dataPathLen]; stream.Read(dataPathBytes, 0, dataPathBytes.Length); _dataPath = Encoding.Unicode.GetString(dataPathBytes); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Data path: {0}", _dataPath); _dataFiles = new List(); - for(int cD = 0; cD < dataBlockCount; cD++) + for(var cD = 0; cD < dataBlockCount; cD++) { tmpArray = new byte[52]; @@ -299,15 +294,15 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.type = 0x{0:X8}", dataFile.Type); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.length = {0}", dataFile.Length); - for(int i = 0; i < dataFile.Unknown1.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.unknown1[{1}] = {0}", - dataFile.Unknown1[i], i); + for(var i = 0; i < dataFile.Unknown1.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.unknown1[{1}] = {0}", dataFile.Unknown1[i], + i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.offset = {0}", dataFile.Offset); - for(int i = 0; i < dataFile.Unknown2.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.unknown2[{1}] = {0}", - dataFile.Unknown2[i], i); + for(var i = 0; i < dataFile.Unknown2.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.unknown2[{1}] = {0}", dataFile.Unknown2[i], + i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.startLba = {0}", dataFile.StartLba); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.sectors = {0}", dataFile.Sectors); @@ -318,7 +313,7 @@ public sealed partial class BlindWrite5 _bwSessions = new List(); - for(int ses = 0; ses < _header.sessions; ses++) + for(var ses = 0; ses < _header.sessions; ses++) { var session = new SessionDescriptor(); tmpArray = new byte[16]; @@ -338,15 +333,13 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].start = {1}", ses, session.Start); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].end = {1}", ses, session.End); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].firstTrack = {1}", ses, - session.FirstTrack); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].firstTrack = {1}", ses, session.FirstTrack); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].lastTrack = {1}", ses, - session.LastTrack); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].lastTrack = {1}", ses, session.LastTrack); - for(int tSeq = 0; tSeq < session.Entries; tSeq++) + for(var tSeq = 0; tSeq < session.Entries; tSeq++) { - byte[] trk = new byte[72]; + var trk = new byte[72]; stream.Read(trk, 0, 72); session.Tracks[tSeq] = Marshal.ByteArrayToStructureLittleEndian(trk); @@ -361,16 +354,15 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].type = {2}", ses, tSeq, session.Tracks[tSeq].type); - for(int i = 0; i < session.Tracks[tSeq].unknown1.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", - "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", ses, tSeq, i, - session.Tracks[tSeq].unknown1[i]); + for(var i = 0; i < session.Tracks[tSeq].unknown1.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown1[{2}] = 0x{3:X2}", + ses, tSeq, i, session.Tracks[tSeq].unknown1[i]); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown2 = 0x{2:X8}", ses, tSeq, session.Tracks[tSeq].unknown2); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].subchannel = {2}", ses, - tSeq, session.Tracks[tSeq].subchannel); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].subchannel = {2}", ses, tSeq, + session.Tracks[tSeq].subchannel); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown3 = 0x{2:X2}", ses, tSeq, session.Tracks[tSeq].unknown3); @@ -414,21 +406,19 @@ public sealed partial class BlindWrite5 AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].pregap = {2}", ses, tSeq, session.Tracks[tSeq].pregap); - for(int i = 0; i < session.Tracks[tSeq].unknown6.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", - "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", ses, tSeq, i, - session.Tracks[tSeq].unknown6[i]); + for(var i = 0; i < session.Tracks[tSeq].unknown6.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown6[{2}] = 0x{3:X8}", + ses, tSeq, i, session.Tracks[tSeq].unknown6[i]); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].startLba = {2}", ses, - tSeq, session.Tracks[tSeq].startLba); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].startLba = {2}", ses, tSeq, + session.Tracks[tSeq].startLba); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].sectors = {2}", ses, tSeq, session.Tracks[tSeq].sectors); - for(int i = 0; i < session.Tracks[tSeq].unknown7.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", - "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", ses, tSeq, i, - session.Tracks[tSeq].unknown7[i]); + for(var i = 0; i < session.Tracks[tSeq].unknown7.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown7[{2}] = 0x{3:X8}", + ses, tSeq, i, session.Tracks[tSeq].unknown7[i]); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].session = {2}", ses, tSeq, session.Tracks[tSeq].session); @@ -441,7 +431,7 @@ public sealed partial class BlindWrite5 continue; { - for(int i = 0; i < session.Tracks[tSeq].unknown9.Length; i++) + for(var i = 0; i < session.Tracks[tSeq].unknown9.Length; i++) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", ses, tSeq, i, session.Tracks[tSeq].unknown9[i]); @@ -458,7 +448,7 @@ public sealed partial class BlindWrite5 tmpArray = new byte[4]; stream.Read(tmpArray, 0, tmpArray.Length); - byte[] footer = new byte[16]; + var footer = new byte[16]; stream.Read(footer, 0, footer.Length); if(_bw5Footer.SequenceEqual(footer)) @@ -514,8 +504,7 @@ public sealed partial class BlindWrite5 if(filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, path)) != null) { - chars.FileFilter = - filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, path)); + chars.FileFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, path)); chars.FilePath = path; } @@ -531,19 +520,17 @@ public sealed partial class BlindWrite5 chars.FileFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToLower(CultureInfo. - CurrentCulture))); + path.ToLower(CultureInfo.CurrentCulture))); } else if(filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToUpper(CultureInfo. - CurrentCulture))) != null) + path.ToUpper(CultureInfo.CurrentCulture))) != + null) { chars.FilePath = path.ToUpper(CultureInfo.CurrentCulture); chars.FileFilter = filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, - path.ToUpper(CultureInfo. - CurrentCulture))); + path.ToUpper(CultureInfo.CurrentCulture))); } else if(filtersList.GetFilter(Path.Combine(imageFilter.ParentFolder, dataFile.Filename.ToLower(CultureInfo. @@ -602,8 +589,7 @@ public sealed partial class BlindWrite5 break; default: - AaruConsole.ErrorWriteLine("BlindWrite5 found unknown subchannel size: {0}", - sectorSize - 2352); + AaruConsole.ErrorWriteLine("BlindWrite5 found unknown subchannel size: {0}", sectorSize - 2352); return ErrorNumber.NotSupported; } @@ -630,7 +616,7 @@ public sealed partial class BlindWrite5 ulong offsetBytes = 0; _offsetMap = new Dictionary(); - bool isDvd = false; + var isDvd = false; byte firstSession = byte.MaxValue; byte lastSession = 0; _trackFlags = new Dictionary(); @@ -657,7 +643,7 @@ public sealed partial class BlindWrite5 foreach(TrackDescriptor trk in ses.Tracks) { - byte adrCtl = (byte)((trk.adr << 4) + trk.ctl); + var adrCtl = (byte)((trk.adr << 4) + trk.ctl); fullTocStream.WriteByte((byte)trk.session); fullTocStream.WriteByte(adrCtl); fullTocStream.WriteByte(0x00); @@ -768,13 +754,10 @@ public sealed partial class BlindWrite5 track.StartSector = (ulong)(trk.startLba + trk.pregap); track.EndSector = (ulong)(trk.sectors + trk.startLba) - 1; - List 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")) @@ -783,8 +766,8 @@ public sealed partial class BlindWrite5 _filePaths.FirstOrDefault(f => Path.GetExtension(f.FilePath).ToLowerInvariant() == ".b00"); string filename = Path.GetFileNameWithoutExtension(splitStartChars.FilePath); - bool lowerCaseExtension = false; - bool lowerCaseFileName = false; + var lowerCaseExtension = false; + var lowerCaseFileName = false; string basePath; bool version5 = string.Compare(Path.GetExtension(imageFilter.Filename), ".B5T", @@ -794,11 +777,8 @@ public sealed partial class BlindWrite5 string firstExtensionLower = version5 ? "b5i" : "b6i"; if(File.Exists(Path.Combine(imageFilter.ParentFolder, $"{filename}.{firstExtension}"))) - { basePath = imageFilter.ParentFolder; - } - else if(File.Exists(Path.Combine(imageFilter.ParentFolder, - $"{filename}.{firstExtensionLower}"))) + else if(File.Exists(Path.Combine(imageFilter.ParentFolder, $"{filename}.{firstExtensionLower}"))) { basePath = imageFilter.ParentFolder; lowerCaseExtension = true; @@ -818,9 +798,7 @@ public sealed partial class BlindWrite5 } else if(File.Exists(Path.Combine(_dataPath, $"{filename}.{firstExtension}"))) - { basePath = _dataPath; - } else if(File.Exists(Path.Combine(_dataPath, $"{filename}.{firstExtensionLower}"))) { basePath = _dataPath; @@ -842,9 +820,7 @@ public sealed partial class BlindWrite5 else if(File.Exists(Path.Combine(_dataPath.ToLower(CultureInfo.CurrentCulture), $"{filename}.{firstExtension}"))) - { basePath = _dataPath.ToLower(CultureInfo.CurrentCulture); - } else if(File.Exists(Path.Combine(_dataPath.ToLower(CultureInfo.CurrentCulture), $"{filename}.{firstExtensionLower}"))) { @@ -867,9 +843,7 @@ public sealed partial class BlindWrite5 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, $"{filename}.{firstExtensionLower}"))) { @@ -893,13 +867,10 @@ public sealed partial class BlindWrite5 else if(File.Exists(Path.Combine(imageFilter.ParentFolder, _dataPath.ToLower(CultureInfo.CurrentCulture), $"{filename}.{firstExtension}"))) - { basePath = Path.Combine(imageFilter.ParentFolder, _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)); @@ -926,17 +897,14 @@ public sealed partial class BlindWrite5 lowerCaseExtension = true; } else if(File.Exists(Path.Combine("", $"{filename}.{firstExtension}"))) - { basePath = ""; - } else if(File.Exists(Path.Combine("", $"{filename}.{firstExtensionLower}"))) { basePath = ""; lowerCaseExtension = true; } - else if( - File.Exists(Path.Combine("", - $"{filename.ToLower(CultureInfo.CurrentCulture)}.{firstExtension}"))) + else if(File.Exists(Path.Combine("", + $"{filename.ToLower(CultureInfo.CurrentCulture)}.{firstExtension}"))) { basePath = ""; lowerCaseFileName = true; @@ -981,8 +949,7 @@ public sealed partial class BlindWrite5 track.File = $"{filename}.{extension}"; if(trk.startLba >= 0) - track.FileOffset = - (ulong)((trk.startLba * splitStartChars.SectorSize) + splitStartChars.Offset); + track.FileOffset = (ulong)(trk.startLba * splitStartChars.SectorSize + splitStartChars.Offset); else track.FileOffset = (ulong)(trk.startLba * -1 * splitStartChars.SectorSize); @@ -1191,8 +1158,7 @@ public sealed partial class BlindWrite5 break; case DiskCategory.Nintendo: - _imageInfo.MediaType = - pfi0.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; + _imageInfo.MediaType = pfi0.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; break; case DiskCategory.UMD: @@ -1210,11 +1176,11 @@ public sealed partial class BlindWrite5 else if(_imageInfo.MediaType == MediaType.CD || _imageInfo.MediaType == MediaType.CDROM) { - bool data = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; foreach(Track bwTrack in Tracks) { @@ -1249,7 +1215,7 @@ public sealed partial class BlindWrite5 Sessions.Count > 1 && mode2) _imageInfo.MediaType = MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = MediaType.CDROM; @@ -1264,8 +1230,8 @@ public sealed partial class BlindWrite5 if(string.Compare(Path.GetExtension(imageFilter.Filename), ".B5T", StringComparison.OrdinalIgnoreCase) == 0) _imageInfo.ApplicationVersion = "5"; - else if(string.Compare(Path.GetExtension(imageFilter.Filename), ".B6T", - StringComparison.OrdinalIgnoreCase) == 0) + else if(string.Compare(Path.GetExtension(imageFilter.Filename), ".B6T", StringComparison.OrdinalIgnoreCase) == + 0) _imageInfo.ApplicationVersion = "6"; _imageInfo.Version = "5"; @@ -1286,7 +1252,7 @@ public sealed partial class BlindWrite5 if(_atip != null) { - byte[] atipTmp = new byte[_atip.Length + 4]; + var atipTmp = new byte[_atip.Length + 4]; Array.Copy(_atip, 0, atipTmp, 4, _atip.Length); atipTmp[0] = (byte)((_atip.Length & 0xFF00) >> 8); atipTmp[1] = (byte)(_atip.Length & 0xFF); @@ -1303,7 +1269,7 @@ public sealed partial class BlindWrite5 } } - bool isBd = false; + var isBd = false; if(_imageInfo.MediaType == MediaType.BDR || _imageInfo.MediaType == MediaType.BDRE || @@ -1432,8 +1398,7 @@ public sealed partial class BlindWrite5 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -1489,9 +1454,8 @@ public sealed partial class BlindWrite5 if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; - DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = - characteristics.StartLba let lastSector = - firstSector + characteristics.Sectors - 1 let wantedSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba + let lastSector = firstSector + characteristics.Sectors - 1 let wantedSector = (int)(sectorAddress + aaruTrack.StartSector) where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); @@ -1503,7 +1467,7 @@ public sealed partial class BlindWrite5 uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.Type) { @@ -1577,9 +1541,9 @@ public sealed partial class BlindWrite5 buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1591,7 +1555,7 @@ public sealed partial class BlindWrite5 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1617,9 +1581,8 @@ public sealed partial class BlindWrite5 if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; - DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = - characteristics.StartLba let lastSector = - firstSector + characteristics.Sectors - 1 let wantedSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba + let lastSector = firstSector + characteristics.Sectors - 1 let wantedSector = (int)(sectorAddress + aaruTrack.StartSector) where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); @@ -2070,7 +2033,7 @@ public sealed partial class BlindWrite5 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2082,11 +2045,11 @@ public sealed partial class BlindWrite5 return ErrorNumber.NoError; buffer = chars.Subchannel switch - { - TrackSubchannelType.Q16Interleaved => Subchannel.ConvertQToRaw(buffer), - TrackSubchannelType.PackedInterleaved => Subchannel.Interleave(buffer), - _ => buffer - }; + { + TrackSubchannelType.Q16Interleaved => Subchannel.ConvertQToRaw(buffer), + TrackSubchannelType.PackedInterleaved => Subchannel.Interleave(buffer), + _ => buffer + }; return ErrorNumber.NoError; } @@ -2127,9 +2090,8 @@ public sealed partial class BlindWrite5 if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; - DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = - characteristics.StartLba let lastSector = - firstSector + characteristics.Sectors - 1 let wantedSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba + let lastSector = firstSector + characteristics.Sectors - 1 let wantedSector = (int)(sectorAddress + aaruTrack.StartSector) where wantedSector >= firstSector && wantedSector <= lastSector select characteristics).FirstOrDefault(); @@ -2197,7 +2159,7 @@ public sealed partial class BlindWrite5 sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); diff --git a/Aaru.Images/BlindWrite5/Structs.cs b/Aaru.Images/BlindWrite5/Structs.cs index b8a3c4100..2dc6e114d 100644 --- a/Aaru.Images/BlindWrite5/Structs.cs +++ b/Aaru.Images/BlindWrite5/Structs.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Decoders.SCSI.MMC; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/BlindWrite5/Verify.cs b/Aaru.Images/BlindWrite5/Verify.cs index 9afb4fd86..6ee07319b 100644 --- a/Aaru.Images/BlindWrite5/Verify.cs +++ b/Aaru.Images/BlindWrite5/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class BlindWrite5 { /// @@ -58,10 +58,10 @@ public sealed partial class BlindWrite5 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class BlindWrite5 if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/ByteAddressable/AtariLynx.cs b/Aaru.Images/ByteAddressable/AtariLynx.cs index c34d97308..5a547c616 100644 --- a/Aaru.Images/ByteAddressable/AtariLynx.cs +++ b/Aaru.Images/ByteAddressable/AtariLynx.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -12,8 +14,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - public class AtariLynx : IByteAddressableImage { byte[] _data; @@ -48,9 +48,9 @@ public class AtariLynx : IByteAddressableImage return false; stream.Position = 0; - byte[] magicBytes = new byte[4]; + var magicBytes = new byte[4]; stream.Read(magicBytes, 0, 4); - uint magic = BitConverter.ToUInt32(magicBytes, 0); + var magic = BitConverter.ToUInt32(magicBytes, 0); // "LYNX" return magic == 0x584E594C; @@ -69,14 +69,14 @@ public class AtariLynx : IByteAddressableImage return ErrorNumber.InvalidArgument; stream.Position = 0x0; - byte[] magicBytes = new byte[4]; + var magicBytes = new byte[4]; stream.Read(magicBytes, 0, 4); - uint magic = BitConverter.ToUInt32(magicBytes, 0); + var magic = BitConverter.ToUInt32(magicBytes, 0); if(magic != 0x584E594C) return ErrorNumber.InvalidArgument; - byte[] headerBytes = new byte[64]; + var headerBytes = new byte[64]; stream.Position = 0; stream.Read(headerBytes, 0, 64); @@ -168,8 +168,8 @@ public class AtariLynx : IByteAddressableImage HandyHeader header = new() { - Bank0Length = (short)(_data.Length > 4 * 131072 ? 4 * 131072 / 256 : _data.Length / 256), - Bank1Length = (short)(_data.Length > 4 * 131072 ? (_data.Length - (4 * 131072)) / 256 : 0), + Bank0Length = (short)(_data.Length > 4 * 131072 ? 4 * 131072 / 256 : _data.Length / 256), + Bank1Length = (short)(_data.Length > 4 * 131072 ? (_data.Length - 4 * 131072) / 256 : 0), Magic = 0x584E594C, Manufacturer = new byte[16], Name = new byte[32], @@ -271,7 +271,6 @@ public class AtariLynx : IByteAddressableImage return ErrorNumber.NoError; } - /// public ErrorNumber GetMappings(out LinearMemoryMap mappings) { @@ -397,11 +396,10 @@ public class AtariLynx : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; + var foundRom = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -410,7 +408,6 @@ public class AtariLynx : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; diff --git a/Aaru.Images/ByteAddressable/GameBoy.cs b/Aaru.Images/ByteAddressable/GameBoy.cs index cf6b6e01d..db896642e 100644 --- a/Aaru.Images/ByteAddressable/GameBoy.cs +++ b/Aaru.Images/ByteAddressable/GameBoy.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -12,8 +14,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - public class GameBoy : IByteAddressableImage { byte[] _data; @@ -48,9 +48,9 @@ public class GameBoy : IByteAddressableImage return false; stream.Position = 0x104; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); return magic == 0x0B000DCC6666EDCE; } @@ -68,9 +68,9 @@ public class GameBoy : IByteAddressableImage return ErrorNumber.InvalidArgument; stream.Position = 0x104; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); if(magic != 0x0B000DCC6666EDCE) return ErrorNumber.InvalidArgument; @@ -92,7 +92,7 @@ public class GameBoy : IByteAddressableImage Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0x100, Marshal.SizeOf
()); - byte[] name = new byte[(header.Name[^1] & 0x80) == 0x80 ? 15 : 16]; + var name = new byte[(header.Name[^1] & 0x80) == 0x80 ? 15 : 16]; Array.Copy(header.Name, 0, name, 0, name.Length); _imageInfo.MediaTitle = StringHandlers.CToString(name); @@ -251,8 +251,8 @@ public class GameBoy : IByteAddressableImage Header header = Marshal.ByteArrayToStructureBigEndian
(_data, 0x100, Marshal.SizeOf
()); - bool hasMapper = false; - bool hasSaveRam = false; + var hasMapper = false; + var hasSaveRam = false; string mapperManufacturer = null; string mapperName = null; @@ -472,7 +472,7 @@ public class GameBoy : IByteAddressableImage if(header.SramSize > 0) hasSaveRam = true; - int devices = 1; + var devices = 1; if(hasSaveRam) devices++; @@ -491,7 +491,6 @@ public class GameBoy : IByteAddressableImage }; if(hasSaveRam) - { mappings.Devices[1] = new LinearMemoryDevice { Type = LinearMemoryType.SaveRAM, @@ -501,17 +500,14 @@ public class GameBoy : IByteAddressableImage Length = DecodeSaveRamSize(header.SramSize) } }; - } if(hasMapper) - { mappings.Devices[^1] = new LinearMemoryDevice { Type = LinearMemoryType.Mapper, Manufacturer = mapperManufacturer, Model = mapperName }; - } return ErrorNumber.NoError; } @@ -610,13 +606,12 @@ public class GameBoy : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundSaveRam = false; - bool foundMapper = false; + var foundRom = false; + var foundSaveRam = false; + var foundMapper = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -633,7 +628,6 @@ public class GameBoy : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; @@ -958,65 +952,66 @@ public class GameBoy : IByteAddressableImage } static uint DecodeRomSize(byte headerRomType) => headerRomType switch - { - 0 => 32768, - 1 => 65536, - 2 => 131072, - 3 => 262144, - 4 => 524288, - 5 => 1048576, - 6 => 2097152, - 7 => 4194304, - 8 => 8388608, - 0x52 => 1179648, - 0x53 => 1310720, - 0x54 => 1572864, - _ => 0 - }; + { + 0 => 32768, + 1 => 65536, + 2 => 131072, + 3 => 262144, + 4 => 524288, + 5 => 1048576, + 6 => 2097152, + 7 => 4194304, + 8 => 8388608, + 0x52 => 1179648, + 0x53 => 1310720, + 0x54 => 1572864, + _ => 0 + }; static uint DecodeSaveRamSize(byte headerRamType) => headerRamType switch - { - 0 => 0, - 1 => 2048, - 2 => 8192, - 3 => 32768, - 4 => 131072, - 5 => 65536, - _ => 0 - }; + { + 0 => 0, + 1 => 2048, + 2 => 8192, + 3 => 32768, + 4 => 131072, + 5 => 65536, + _ => 0 + }; static string DecodeCartridgeType(byte headerRomType) => headerRomType switch - { - 0x00 => "ROM only", - 0x01 => "ROM and MBC1", - 0x02 => "ROM, MBC1 and RAM", - 0x03 => "ROM, MBC1, RAM and battery", - 0x05 => "ROM and MBC2", - 0x06 => "ROM, MBC2 and battery", - 0x08 => "ROM and RAM", - 0x09 => "ROM, RAM and battery", - 0x0B => "ROM and MMM01", - 0x0C => "ROM, MMM01 and RAM", - 0x0D => "ROM, MMM01, RAM and battery", - 0x0F => "ROM, MBC3, timer and battery", - 0x10 => "ROM, MBC3, RAM, timer and battery", - 0x11 => "ROM and MBC3", - 0x12 => "ROM, MBC3 and RAM", - 0x13 => "ROM, MBC3, RAM and battery", - 0x19 => "ROM and MBC5", - 0x1A => "ROM, MBC5 and RAM", - 0x1B => "ROM, MBC5, RAM and battery", - 0x1C => "ROM, MBC5 and vibration motor", - 0x1D => "ROM, MBC5, RAM and vibration motor", - 0x1E => "ROM, MBC5, RAM, battery and vibration motor", - 0x20 => "ROM and MBC6", - 0x22 => "ROM, MBC7, RAM, battery, light sensor and vibration motor", - 0xFC => "Pocket Camera", - 0xFD => "ROM and TAMA5", - 0xFE => "ROM and HuC-3", - 0xFF => "ROM and HuC-1", - _ => "Unknown" - }; + { + 0x00 => "ROM only", + 0x01 => "ROM and MBC1", + 0x02 => "ROM, MBC1 and RAM", + 0x03 => "ROM, MBC1, RAM and battery", + 0x05 => "ROM and MBC2", + 0x06 => "ROM, MBC2 and battery", + 0x08 => "ROM and RAM", + 0x09 => "ROM, RAM and battery", + 0x0B => "ROM and MMM01", + 0x0C => "ROM, MMM01 and RAM", + 0x0D => "ROM, MMM01, RAM and battery", + 0x0F => "ROM, MBC3, timer and battery", + 0x10 => "ROM, MBC3, RAM, timer and battery", + 0x11 => "ROM and MBC3", + 0x12 => "ROM, MBC3 and RAM", + 0x13 => "ROM, MBC3, RAM and battery", + 0x19 => "ROM and MBC5", + 0x1A => "ROM, MBC5 and RAM", + 0x1B => "ROM, MBC5, RAM and battery", + 0x1C => "ROM, MBC5 and vibration motor", + 0x1D => "ROM, MBC5, RAM and vibration motor", + 0x1E => "ROM, MBC5, RAM, battery and vibration motor", + 0x20 => "ROM and MBC6", + 0x22 => + "ROM, MBC7, RAM, battery, light sensor and vibration motor", + 0xFC => "Pocket Camera", + 0xFD => "ROM and TAMA5", + 0xFE => "ROM and HuC-3", + 0xFF => "ROM and HuC-1", + _ => "Unknown" + }; [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")] struct Header diff --git a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs index 203a9776e..64c8253ce 100644 --- a/Aaru.Images/ByteAddressable/GameBoyAdvance.cs +++ b/Aaru.Images/ByteAddressable/GameBoyAdvance.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -12,8 +14,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - public class GameBoyAdvance : IByteAddressableImage { byte[] _data; @@ -48,9 +48,9 @@ public class GameBoyAdvance : IByteAddressableImage return false; stream.Position = 4; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); return magic == 0x21A29A6951AEFF24; } @@ -68,9 +68,9 @@ public class GameBoyAdvance : IByteAddressableImage return ErrorNumber.InvalidArgument; stream.Position = 4; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); if(magic != 0x21A29A6951AEFF24) return ErrorNumber.InvalidArgument; @@ -342,12 +342,11 @@ public class GameBoyAdvance : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundSaveRam = false; + var foundRom = false; + var foundSaveRam = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -360,7 +359,6 @@ public class GameBoyAdvance : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; diff --git a/Aaru.Images/ByteAddressable/MasterSystem.cs b/Aaru.Images/ByteAddressable/MasterSystem.cs index 23fac24d6..d5d973aa0 100644 --- a/Aaru.Images/ByteAddressable/MasterSystem.cs +++ b/Aaru.Images/ByteAddressable/MasterSystem.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -11,8 +13,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - public class MasterSystem : IByteAddressableImage { byte[] _data; @@ -49,9 +49,9 @@ public class MasterSystem : IByteAddressableImage return false; stream.Position = 0x7ff0; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); if(magic == 0x4147455320524D54) return true; @@ -84,12 +84,12 @@ public class MasterSystem : IByteAddressableImage if(stream.Length % 8192 != 0) return ErrorNumber.InvalidArgument; - int headerPosition = 0; + var headerPosition = 0; stream.Position = 0x7ff0; - byte[] magicBytes = new byte[8]; + var magicBytes = new byte[8]; stream.Read(magicBytes, 0, 8); - ulong magic = BitConverter.ToUInt64(magicBytes, 0); + var magic = BitConverter.ToUInt64(magicBytes, 0); if(magic != 0x0B000DCC6666EDCE) headerPosition = 0x7ff0; @@ -134,9 +134,9 @@ public class MasterSystem : IByteAddressableImage var sb = new StringBuilder(); - int productCode = (header.ProductCode[0] & 0xF) + ((header.ProductCode[0] & 0xF0) * 10) + - ((header.ProductCode[1] & 0xF) * 100) + ((header.ProductCode[1] & 0xF0) * 1000) + - (((header.VersionAndProduct & 0xF0) >> 4) * 10000); + int productCode = (header.ProductCode[0] & 0xF) + (header.ProductCode[0] & 0xF0) * 10 + + (header.ProductCode[1] & 0xF) * 100 + (header.ProductCode[1] & 0xF0) * 1000 + + ((header.VersionAndProduct & 0xF0) >> 4) * 10000; sb.AppendFormat("Product code: {0}", productCode).AppendLine(); @@ -186,18 +186,18 @@ public class MasterSystem : IByteAddressableImage int sizeCode = header.SizeAndRegion & 0xF; _romSize = sizeCode switch - { - 0 => 262144, - 1 => 524288, - 2 => 1048576, - 0xA => 8192, - 0xB => 16384, - 0xC => 32768, - 0xD => 49152, - 0xE => 65536, - 0xF => 131072, - _ => 0 - }; + { + 0 => 262144, + 1 => 524288, + 2 => 1048576, + 0xA => 8192, + 0xB => 16384, + 0xC => 32768, + 0xD => 49152, + 0xE => 65536, + 0xF => 131072, + _ => 0 + }; sb.AppendFormat("Region: {0}", region).AppendLine(); sb.AppendFormat("Cartridge type: {0}", cartType).AppendLine(); @@ -443,11 +443,10 @@ public class MasterSystem : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; + var foundRom = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -456,7 +455,6 @@ public class MasterSystem : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; diff --git a/Aaru.Images/ByteAddressable/NES.cs b/Aaru.Images/ByteAddressable/NES.cs index 9d64001ae..30ed72188 100644 --- a/Aaru.Images/ByteAddressable/NES.cs +++ b/Aaru.Images/ByteAddressable/NES.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.IO; @@ -11,10 +13,9 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Database; using Aaru.Database.Models; +using Aaru.Settings; using Schemas; -namespace Aaru.DiscImages.ByteAddressable; - public class Nes : IByteAddressableImage { int _chrLen; @@ -62,9 +63,9 @@ public class Nes : IByteAddressableImage return false; stream.Position = 0; - byte[] magicBytes = new byte[4]; + var magicBytes = new byte[4]; stream.Read(magicBytes, 0, 8); - uint magic = BitConverter.ToUInt32(magicBytes, 0); + var magic = BitConverter.ToUInt32(magicBytes, 0); return magic == 0x1A53454E; } @@ -82,9 +83,9 @@ public class Nes : IByteAddressableImage return ErrorNumber.InvalidArgument; stream.Position = 0; - byte[] header = new byte[16]; + var header = new byte[16]; stream.Read(header, 0, 8); - uint magic = BitConverter.ToUInt32(header, 0); + var magic = BitConverter.ToUInt32(header, 0); if(magic != 0x1A53454E) return ErrorNumber.InvalidArgument; @@ -302,12 +303,12 @@ public class Nes : IByteAddressableImage return false; } - byte[] header = new byte[16]; + var header = new byte[16]; if(_nesHeaderInfo is null) { string hash = Sha256Context.Data(_data, out _).ToLowerInvariant(); - using var ctx = AaruContext.Create(Settings.Settings.MainDbPath); + using var ctx = AaruContext.Create(Settings.MainDbPath); _nesHeaderInfo = ctx.NesHeaders.FirstOrDefault(hdr => hdr.Sha256 == hash); } @@ -350,11 +351,12 @@ public class Nes : IByteAddressableImage header[12] = (byte)_nesHeaderInfo.TimingMode; header[13] = _nesHeaderInfo.ConsoleType switch - { - NesConsoleType.Vs => (byte)(((int)_nesHeaderInfo.VsHardwareType << 4) | (int)_nesHeaderInfo.VsPpuType), - NesConsoleType.Extended => (byte)_nesHeaderInfo.ExtendedConsoleType, - _ => header[13] - }; + { + NesConsoleType.Vs => (byte)(((int)_nesHeaderInfo.VsHardwareType << 4) | + (int)_nesHeaderInfo.VsPpuType), + NesConsoleType.Extended => (byte)_nesHeaderInfo.ExtendedConsoleType, + _ => header[13] + }; header[14] = 0; @@ -662,23 +664,22 @@ public class Nes : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundChrRom = false; - bool foundInstRom = false; - bool foundProm = false; - bool foundRam = false; - bool foundChrRam = false; - bool foundNvram = false; - bool foundChrNvram = false; - bool foundMapper = false; - bool foundSubMapper = false; + var foundRom = false; + var foundChrRom = false; + var foundInstRom = false; + var foundProm = false; + var foundRam = false; + var foundChrRam = false; + var foundNvram = false; + var foundChrNvram = false; + var foundMapper = false; + var foundSubMapper = false; Regex regex; Match match; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -730,7 +731,6 @@ public class Nes : IByteAddressableImage match = regex.Match(map.Description); if(match.Success) - { if(ushort.TryParse(match.Groups["mapper"].Value, out ushort mapper)) { if(_nesHeaderInfo is null) @@ -740,7 +740,6 @@ public class Nes : IByteAddressableImage foundMapper = true; } - } break; case LinearMemoryType.Mapper when !foundSubMapper: @@ -748,7 +747,6 @@ public class Nes : IByteAddressableImage match = regex.Match(map.Description); if(match.Success) - { if(byte.TryParse(match.Groups["mapper"].Value, out byte mapper)) { if(_nesHeaderInfo is null) @@ -758,12 +756,10 @@ public class Nes : IByteAddressableImage foundSubMapper = true; } - } break; default: return ErrorNumber.InvalidArgument; } - } return foundRom && foundMapper ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; } diff --git a/Aaru.Images/ByteAddressable/Nintendo64.cs b/Aaru.Images/ByteAddressable/Nintendo64.cs index 46496d8ba..7fe3be24c 100644 --- a/Aaru.Images/ByteAddressable/Nintendo64.cs +++ b/Aaru.Images/ByteAddressable/Nintendo64.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -44,8 +46,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - /// /// Implements support for Nintendo 64 cartridge dumps public class Nintendo64 : IByteAddressableImage @@ -88,9 +88,9 @@ public class Nintendo64 : IByteAddressableImage return false; stream.Position = 0; - byte[] magicBytes = new byte[4]; + var magicBytes = new byte[4]; stream.Read(magicBytes, 0, 4); - uint magic = BitConverter.ToUInt32(magicBytes, 0); + var magic = BitConverter.ToUInt32(magicBytes, 0); switch(magic) { @@ -119,9 +119,9 @@ public class Nintendo64 : IByteAddressableImage return ErrorNumber.InvalidArgument; stream.Position = 0; - byte[] magicBytes = new byte[4]; + var magicBytes = new byte[4]; stream.Read(magicBytes, 0, 4); - uint magic = BitConverter.ToUInt32(magicBytes, 0); + var magic = BitConverter.ToUInt32(magicBytes, 0); switch(magic) { @@ -169,9 +169,9 @@ public class Nintendo64 : IByteAddressableImage if(_littleEndian) { - byte[] tmp = new byte[_data.Length]; + var tmp = new byte[_data.Length]; - for(int i = 0; i < _data.Length; i += 4) + for(var i = 0; i < _data.Length; i += 4) { tmp[i] = _data[i + 3]; tmp[i + 1] = _data[i + 2]; @@ -184,9 +184,9 @@ public class Nintendo64 : IByteAddressableImage if(_interleaved) { - byte[] tmp = new byte[_data.Length]; + var tmp = new byte[_data.Length]; - for(int i = 0; i < _data.Length; i += 2) + for(var i = 0; i < _data.Length; i += 2) { tmp[i] = _data[i + 1]; tmp[i + 1] = _data[i]; @@ -216,7 +216,7 @@ public class Nintendo64 : IByteAddressableImage sb.AppendFormat("Region: {0}", DecodeCountryCode(header.CountryCode)).AppendLine(); sb.AppendFormat("Cartridge ID: {0}", _imageInfo.MediaPartNumber).AppendLine(); sb.AppendFormat("Cartridge type: {0}", (char)header.CartridgeType).AppendLine(); - sb.AppendFormat("Version: {0}.{1}", (header.Version / 10) + 1, header.Version % 10).AppendLine(); + sb.AppendFormat("Version: {0}.{1}", header.Version / 10 + 1, header.Version % 10).AppendLine(); sb.AppendFormat("CRC1: 0x{0:X8}", header.Crc1).AppendLine(); sb.AppendFormat("CRC2: 0x{0:X8}", header.Crc2).AppendLine(); @@ -669,12 +669,11 @@ public class Nintendo64 : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundSaveRam = false; + var foundRom = false; + var foundSaveRam = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -689,7 +688,6 @@ public class Nintendo64 : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; @@ -830,9 +828,9 @@ public class Nintendo64 : IByteAddressableImage if(_interleaved) { - byte[] tmp = new byte[_data.Length]; + var tmp = new byte[_data.Length]; - for(int i = 0; i < _data.Length; i += 2) + for(var i = 0; i < _data.Length; i += 2) { tmp[i] = _data[i + 1]; tmp[i + 1] = _data[i]; @@ -861,29 +859,29 @@ public class Nintendo64 : IByteAddressableImage public bool SetMetadata(ImageInfo metadata) => true; static string DecodeCountryCode(byte countryCode) => countryCode switch - { - 0x37 => "Beta", - 0x41 => "Asia (NTSC)", - 0x42 => "Brazil", - 0x43 => "China", - 0x44 => "Germany", - 0x45 => "North America", - 0x46 => "France", - 0x47 => "Gateway 64 (NTSC)", - 0x48 => "Netherlands", - 0x49 => "Italy", - 0x4A => "Japan", - 0x4B => "Korea", - 0x4C => "Gateway 64 (PAL)", - 0x4E => "Canada", - 0x50 => "Europe", - 0x53 => "Spain", - 0x55 => "Australia", - 0x57 => "Scandinavia", - 0x58 => "Europe", - 0x59 => "Europe", - _ => "Unknown" - }; + { + 0x37 => "Beta", + 0x41 => "Asia (NTSC)", + 0x42 => "Brazil", + 0x43 => "China", + 0x44 => "Germany", + 0x45 => "North America", + 0x46 => "France", + 0x47 => "Gateway 64 (NTSC)", + 0x48 => "Netherlands", + 0x49 => "Italy", + 0x4A => "Japan", + 0x4B => "Korea", + 0x4C => "Gateway 64 (PAL)", + 0x4E => "Canada", + 0x50 => "Europe", + 0x53 => "Spain", + 0x55 => "Australia", + 0x57 => "Scandinavia", + 0x58 => "Europe", + 0x59 => "Europe", + _ => "Unknown" + }; [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "MemberCanBePrivate.Local")] struct Header diff --git a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs index 09db5170e..b0a29583a 100644 --- a/Aaru.Images/ByteAddressable/SegaMegaDrive.cs +++ b/Aaru.Images/ByteAddressable/SegaMegaDrive.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -44,8 +46,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - /// /// Implements support for Sega Mega Drive, 32X, Genesis and Pico cartridge dumps public class SegaMegaDrive : IByteAddressableImage @@ -90,7 +90,7 @@ public class SegaMegaDrive : IByteAddressableImage if(stream.Length % 512 != 0) return false; - byte[] buffer = new byte[4]; + var buffer = new byte[4]; stream.Position = 256; stream.Read(buffer, 0, 4); @@ -106,7 +106,7 @@ public class SegaMegaDrive : IByteAddressableImage if(buffer[0] == 0x45 && buffer[1] == 0x41) { - stream.Position = (stream.Length / 2) + 256; + stream.Position = stream.Length / 2 + 256; stream.Read(buffer, 0, 2); // SG @@ -142,7 +142,7 @@ public class SegaMegaDrive : IByteAddressableImage if(stream.Length % 512 != 0) return ErrorNumber.InvalidArgument; - byte[] buffer = new byte[4]; + var buffer = new byte[4]; stream.Position = 256; stream.Read(buffer, 0, 4); @@ -154,7 +154,7 @@ public class SegaMegaDrive : IByteAddressableImage if(buffer[0] == 0x45 && buffer[1] == 0x41) { - stream.Position = (stream.Length / 2) + 256; + stream.Position = stream.Length / 2 + 256; stream.Read(buffer, 0, 2); // SG @@ -195,18 +195,18 @@ public class SegaMegaDrive : IByteAddressableImage // Interleaves every 16KiB if(_smd) { - byte[] tmp = new byte[_data.Length]; - byte[] bankIn = new byte[16384]; - byte[] bankOut = new byte[16384]; + var tmp = new byte[_data.Length]; + var bankIn = new byte[16384]; + var bankOut = new byte[16384]; - for(int b = 0; b < _data.Length / 16384; b++) + for(var b = 0; b < _data.Length / 16384; b++) { Array.Copy(_data, b * 16384, bankIn, 0, 16384); - for(int i = 0; i < 8192; i++) + for(var i = 0; i < 8192; i++) { - bankOut[(i * 2) + 1] = bankIn[i]; - bankOut[i * 2] = bankIn[i + 8192]; + bankOut[i * 2 + 1] = bankIn[i]; + bankOut[i * 2] = bankIn[i + 8192]; } Array.Copy(bankOut, 0, tmp, b * 16384, 16384); @@ -216,13 +216,13 @@ public class SegaMegaDrive : IByteAddressableImage } else if(_interleaved) { - byte[] tmp = new byte[_data.Length]; - int half = _data.Length / 2; + var tmp = new byte[_data.Length]; + int half = _data.Length / 2; - for(int i = 0; i < half; i++) + for(var i = 0; i < half; i++) { - tmp[i * 2] = _data[i]; - tmp[(i * 2) + 1] = _data[i + half]; + tmp[i * 2] = _data[i]; + tmp[i * 2 + 1] = _data[i + half]; } _data = tmp; @@ -330,11 +330,11 @@ public class SegaMegaDrive : IByteAddressableImage _imageInfo.MediaTitle = StringHandlers.SpacePaddedToString(header.DomesticTitle, encoding); _imageInfo.MediaType = StringHandlers.SpacePaddedToString(header.SystemType, encoding) switch - { - "SEGA 32X" => MediaType._32XCartridge, - "SEGA PICO" => MediaType.SegaPicoCartridge, - _ => MediaType.MegaDriveCartridge - }; + { + "SEGA 32X" => MediaType._32XCartridge, + "SEGA PICO" => MediaType.SegaPicoCartridge, + _ => MediaType.MegaDriveCartridge + }; _imageInfo.Sectors = (ulong)_data.Length; _imageInfo.XmlMediaType = XmlMediaType.LinearMedia; @@ -390,13 +390,13 @@ public class SegaMegaDrive : IByteAddressableImage if(_interleaved) { - byte[] tmp = new byte[_data.Length]; - int half = _data.Length / 2; + var tmp = new byte[_data.Length]; + int half = _data.Length / 2; - for(int i = 0; i < half; i++) + for(var i = 0; i < half; i++) { tmp[i] = _data[i * 2]; - tmp[i + half] = _data[(i * 2) + 1]; + tmp[i + half] = _data[i * 2 + 1]; } _data = tmp; @@ -418,18 +418,18 @@ public class SegaMegaDrive : IByteAddressableImage _dataStream.Write(smdHeader, 0, smdHeader.Length); - byte[] tmp = new byte[_data.Length]; - byte[] bankIn = new byte[16384]; - byte[] bankOut = new byte[16384]; + var tmp = new byte[_data.Length]; + var bankIn = new byte[16384]; + var bankOut = new byte[16384]; - for(int b = 0; b < _data.Length / 16384; b++) + for(var b = 0; b < _data.Length / 16384; b++) { Array.Copy(_data, b * 16384, bankIn, 0, 16384); - for(int i = 0; i < 8192; i++) + for(var i = 0; i < 8192; i++) { - bankOut[i] = bankIn[(i * 2) + 1]; - bankOut[i + 8192] = bankIn[i * 2]; + bankOut[i] = bankIn[i * 2 + 1]; + bankOut[i + 8192] = bankIn[i * 2]; } Array.Copy(bankOut, 0, tmp, b * 16384, 16384); @@ -722,12 +722,11 @@ public class SegaMegaDrive : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundSaveRam = false; + var foundRom = false; + var foundSaveRam = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -740,7 +739,6 @@ public class SegaMegaDrive : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; diff --git a/Aaru.Images/ByteAddressable/SuperNintendo.cs b/Aaru.Images/ByteAddressable/SuperNintendo.cs index 6ca4b8ee7..149754c75 100644 --- a/Aaru.Images/ByteAddressable/SuperNintendo.cs +++ b/Aaru.Images/ByteAddressable/SuperNintendo.cs @@ -1,3 +1,5 @@ +namespace Aaru.DiscImages.ByteAddressable; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -12,8 +14,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages.ByteAddressable; - public class SuperNintendo : IByteAddressableImage { byte[] _data; @@ -43,7 +43,7 @@ public class SuperNintendo : IByteAddressableImage return false; Header header; - byte[] headerBytes = new byte[48]; + var headerBytes = new byte[48]; if(stream.Length > 0x40FFFF) { @@ -92,8 +92,8 @@ public class SuperNintendo : IByteAddressableImage if(stream.Length % 32768 != 0) return ErrorNumber.InvalidArgument; - bool found = false; - byte[] headerBytes = new byte[48]; + var found = false; + var headerBytes = new byte[48]; if(stream.Length > 0x40FFFF) { @@ -343,7 +343,7 @@ public class SuperNintendo : IByteAddressableImage bool hasFlash = _header.OldMakerCode == 0x33 && _header.ExpansionFlashSize > 0; bool hasBattery = chipset is 2 or 5 or 6 or 9 or 0xA; - int devices = 1; + var devices = 1; if(hasRam) devices++; @@ -367,8 +367,8 @@ public class SuperNintendo : IByteAddressableImage } }; - int pos = 1; - ulong addr = (ulong)_data.Length; + var pos = 1; + var addr = (ulong)_data.Length; if(hasRam) { @@ -403,7 +403,6 @@ public class SuperNintendo : IByteAddressableImage } if(hasFlash) - { mappings.Devices[pos] = new LinearMemoryDevice { Type = LinearMemoryType.NOR, @@ -413,7 +412,6 @@ public class SuperNintendo : IByteAddressableImage Length = (ulong)(1 << _header.ExpansionRamSize) * 1024 } }; - } return ErrorNumber.NoError; } @@ -512,14 +510,13 @@ public class SuperNintendo : IByteAddressableImage return ErrorNumber.ReadOnly; } - bool foundRom = false; - bool foundRam = false; - bool foundExtraRam = false; - bool foundFlash = false; + var foundRom = false; + var foundRam = false; + var foundExtraRam = false; + var foundFlash = false; // Sanitize foreach(LinearMemoryDevice map in mappings.Devices) - { switch(map.Type) { case LinearMemoryType.ROM when !foundRom: @@ -549,7 +546,6 @@ public class SuperNintendo : IByteAddressableImage break; default: return ErrorNumber.InvalidArgument; } - } // Cannot save in this image format anyway return foundRom ? ErrorNumber.NoError : ErrorNumber.InvalidArgument; @@ -651,24 +647,24 @@ public class SuperNintendo : IByteAddressableImage return "None"; return ((chipset & 0xF0) >> 4) switch - { - 0 => "DSP", - 1 => "GSU", - 2 => "OBC1", - 3 => "SA-1", - 4 => "S-DD1", - 5 => "S-RTC", - 0xE => "Other", - 0xF => subtype switch - { - 0 => "SPC7110", - 1 => "ST010/ST011", - 2 => "ST018", - 0x10 => "CX4", - _ => "Unknown" - }, - _ => "Unknown" - }; + { + 0 => "DSP", + 1 => "GSU", + 2 => "OBC1", + 3 => "SA-1", + 4 => "S-DD1", + 5 => "S-RTC", + 0xE => "Other", + 0xF => subtype switch + { + 0 => "SPC7110", + 1 => "ST010/ST011", + 2 => "ST018", + 0x10 => "CX4", + _ => "Unknown" + }, + _ => "Unknown" + }; } static string DecodeChipset(byte chipset) @@ -720,38 +716,38 @@ public class SuperNintendo : IByteAddressableImage } static string DecodeRegion(byte headerRegion) => headerRegion switch - { - 0 => "Japan", - 1 => "USA and Canada", - 2 => "Europe, Oceania, Asia", - 3 => "Sweden/Scandinavia", - 4 => "Finland", - 5 => "Denmark", - 6 => "France", - 7 => "Netherlands", - 8 => "Spain", - 9 => "Germany, Austria, Switzerland", - 10 => "Italy", - 11 => "China, Hong Kong", - 12 => "Indonesia", - 13 => "South Korea", - 15 => "Canada", - 16 => "Brazil", - 17 => "Australia", - _ => "Unknown" - }; + { + 0 => "Japan", + 1 => "USA and Canada", + 2 => "Europe, Oceania, Asia", + 3 => "Sweden/Scandinavia", + 4 => "Finland", + 5 => "Denmark", + 6 => "France", + 7 => "Netherlands", + 8 => "Spain", + 9 => "Germany, Austria, Switzerland", + 10 => "Italy", + 11 => "China, Hong Kong", + 12 => "Indonesia", + 13 => "South Korea", + 15 => "Canada", + 16 => "Brazil", + 17 => "Australia", + _ => "Unknown" + }; static string DecodeManufacturer(byte oldMakerCode, string makerCode) { // TODO: Add full table if(oldMakerCode != 0x33) - makerCode = $"{((oldMakerCode >> 4) * 36) + (oldMakerCode & 0x0f)}"; + makerCode = $"{(oldMakerCode >> 4) * 36 + (oldMakerCode & 0x0f)}"; return makerCode switch - { - "01" => "Nintendo", - _ => "Unknown" - }; + { + "01" => "Nintendo", + _ => "Unknown" + }; } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local"), diff --git a/Aaru.Images/CDRDAO/CDRDAO.cs b/Aaru.Images/CDRDAO/CDRDAO.cs index bdfb9aa8f..6efbfbd52 100644 --- a/Aaru.Images/CDRDAO/CDRDAO.cs +++ b/Aaru.Images/CDRDAO/CDRDAO.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -namespace Aaru.DiscImages; - // TODO: Doesn't support compositing from several files // TODO: Doesn't support silences that are not in files /// diff --git a/Aaru.Images/CDRDAO/Helpers.cs b/Aaru.Images/CDRDAO/Helpers.cs index bac44b467..99606489d 100644 --- a/Aaru.Images/CDRDAO/Helpers.cs +++ b/Aaru.Images/CDRDAO/Helpers.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { static ushort CdrdaoTrackTypeToCookedBytesPerSector(string trackType) diff --git a/Aaru.Images/CDRDAO/Identify.cs b/Aaru.Images/CDRDAO/Identify.cs index a9c859dd3..025821255 100644 --- a/Aaru.Images/CDRDAO/Identify.cs +++ b/Aaru.Images/CDRDAO/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { /// @@ -46,14 +46,14 @@ public sealed partial class Cdrdao try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - byte[] testArray = new byte[512]; + var testArray = new byte[512]; imageFilter.GetDataForkStream().Read(testArray, 0, 512); imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); // Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin - bool twoConsecutiveNulls = false; + var twoConsecutiveNulls = false; - for(int i = 0; i < 512; i++) + for(var i = 0; i < 512; i++) { if(i >= imageFilter.GetDataForkStream().Length) break; diff --git a/Aaru.Images/CDRDAO/Properties.cs b/Aaru.Images/CDRDAO/Properties.cs index e560f8ad9..753ec1435 100644 --- a/Aaru.Images/CDRDAO/Properties.cs +++ b/Aaru.Images/CDRDAO/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { /// @@ -173,21 +173,20 @@ public sealed partial class Cdrdao /// public IEnumerable SupportedSectorTags => new[] { - SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, - SectorTagType.CdSectorEdc, SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubchannel, - SectorTagType.CdSectorSubHeader, SectorTagType.CdSectorSync, SectorTagType.CdTrackFlags, - SectorTagType.CdTrackIsrc + SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, SectorTagType.CdSectorEdc, + SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubchannel, SectorTagType.CdSectorSubHeader, + SectorTagType.CdSectorSync, SectorTagType.CdTrackFlags, SectorTagType.CdTrackIsrc }; /// public IEnumerable SupportedMediaTypes => new[] { - MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, - MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, - MediaType.CDV, MediaType.DDCD, MediaType.DDCDR, MediaType.DDCDRW, MediaType.MEGACD, MediaType.PS1CD, - MediaType.PS2CD, MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SATURNCD, MediaType.ThreeDO, - MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, MediaType.PCFX, MediaType.CDTV, MediaType.CD32, - MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, - MediaType.VideoNowColor, MediaType.VideoNowXp, MediaType.CVD, MediaType.PCD + MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, MediaType.CDMRW, + MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, MediaType.CDV, + MediaType.DDCD, MediaType.DDCDR, MediaType.DDCDRW, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, + MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SATURNCD, MediaType.ThreeDO, MediaType.VCD, MediaType.VCDHD, + MediaType.NeoGeoCD, MediaType.PCFX, MediaType.CDTV, MediaType.CD32, MediaType.Nuon, MediaType.Playdia, + MediaType.Pippin, MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, MediaType.VideoNowColor, + MediaType.VideoNowXp, MediaType.CVD, MediaType.PCD }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => new[] diff --git a/Aaru.Images/CDRDAO/Read.cs b/Aaru.Images/CDRDAO/Read.cs index 51256c1b9..4654f94ae 100644 --- a/Aaru.Images/CDRDAO/Read.cs +++ b/Aaru.Images/CDRDAO/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -44,8 +46,6 @@ using Aaru.Console; using Aaru.Decoders.CD; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { /// @@ -60,7 +60,7 @@ public sealed partial class Cdrdao { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); _tocStream = new StreamReader(imageFilter.GetDataForkStream()); - bool inTrack = false; + var inTrack = false; // Initialize all RegExs var regexComment = new Regex(REGEX_COMMENT); @@ -108,12 +108,12 @@ public sealed partial class Cdrdao currentTrack.Indexes = new Dictionary(); currentTrack.Pregap = 0; ulong currentSector = 0; - int nextIndex = 2; + var nextIndex = 2; var commentBuilder = new StringBuilder(); _tocStream = new StreamReader(_cdrdaoFilter.GetDataForkStream()); string line; - int lineNumber = 0; + var lineNumber = 0; while(_tocStream.Peek() >= 0) { @@ -234,9 +234,8 @@ public sealed partial class Cdrdao lineNumber, matchTrack.Groups["type"].Value); else AaruConsole.DebugWriteLine("CDRDAO plugin", - "Found TRACK type \"{1}\" subchannel {2} at line {0}", - lineNumber, matchTrack.Groups["type"].Value, - matchTrack.Groups["subchan"].Value); + "Found TRACK type \"{1}\" subchannel {2} at line {0}", lineNumber, + matchTrack.Groups["type"].Value, matchTrack.Groups["subchan"].Value); if(inTrack) { @@ -284,8 +283,7 @@ public sealed partial class Cdrdao break; default: { - AaruConsole. - ErrorWriteLine($"Track mode {matchTrack.Groups["type"].Value} is unsupported"); + AaruConsole.ErrorWriteLine($"Track mode {matchTrack.Groups["type"].Value} is unsupported"); return ErrorNumber.NotSupported; } @@ -351,11 +349,10 @@ public sealed partial class Cdrdao string[] lengthString = matchFile.Groups["length"].Value.Split(':'); - ulong nextIndexPos = (ulong.Parse(lengthString[0]) * 60 * 75) + - (ulong.Parse(lengthString[1]) * 75) + ulong.Parse(lengthString[2]); + ulong nextIndexPos = ulong.Parse(lengthString[0]) * 60 * 75 + ulong.Parse(lengthString[1]) * 75 + + ulong.Parse(lengthString[2]); - currentTrack.Indexes.Add(nextIndex, - nextIndexPos + currentTrack.Pregap + currentTrack.StartSector); + currentTrack.Indexes.Add(nextIndex, nextIndexPos + currentTrack.Pregap + currentTrack.StartSector); } else if(matchPregap.Success) { @@ -368,8 +365,8 @@ public sealed partial class Cdrdao { string[] lengthString = matchPregap.Groups["address"].Value.Split(':'); - currentTrack.Pregap = (ulong.Parse(lengthString[0]) * 60 * 75) + - (ulong.Parse(lengthString[1]) * 75) + ulong.Parse(lengthString[2]); + currentTrack.Pregap = ulong.Parse(lengthString[0]) * 60 * 75 + + ulong.Parse(lengthString[1]) * 75 + ulong.Parse(lengthString[2]); } else currentTrack.Pregap = currentTrack.Sectors; @@ -382,8 +379,8 @@ public sealed partial class Cdrdao currentTrack.Indexes.Add(0, currentTrack.StartSector); string[] lengthString = matchZeroPregap.Groups["length"].Value.Split(':'); - currentTrack.Pregap = (ulong.Parse(lengthString[0]) * 60 * 75) + - (ulong.Parse(lengthString[1]) * 75) + ulong.Parse(lengthString[2]); + currentTrack.Pregap = ulong.Parse(lengthString[0]) * 60 * 75 + ulong.Parse(lengthString[1]) * 75 + + ulong.Parse(lengthString[2]); } else if(matchZeroData.Success) AaruConsole.DebugWriteLine("CDRDAO plugin", "Found ZERO \"{1}\" at line {0}", lineNumber, @@ -397,8 +394,8 @@ public sealed partial class Cdrdao if(matchAudioFile.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found AUDIOFILE \"{1}\" at line {0}", - lineNumber, matchAudioFile.Groups["filename"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found AUDIOFILE \"{1}\" at line {0}", lineNumber, + matchAudioFile.Groups["filename"].Value); filtersList = new FiltersList(); @@ -420,8 +417,8 @@ public sealed partial class Cdrdao { string[] startString = matchAudioFile.Groups["start"].Value.Split(':'); - startSectors = (ulong.Parse(startString[0]) * 60 * 75) + - (ulong.Parse(startString[1]) * 75) + ulong.Parse(startString[2]); + startSectors = ulong.Parse(startString[0]) * 60 * 75 + ulong.Parse(startString[1]) * 75 + + ulong.Parse(startString[2]); } currentTrack.Trackfile.Offset += startSectors * currentTrack.Bps; @@ -430,9 +427,8 @@ public sealed partial class Cdrdao { string[] lengthString = matchAudioFile.Groups["length"].Value.Split(':'); - currentTrack.Sectors = (ulong.Parse(lengthString[0]) * 60 * 75) + - (ulong.Parse(lengthString[1]) * 75) + - ulong.Parse(lengthString[2]); + currentTrack.Sectors = ulong.Parse(lengthString[0]) * 60 * 75 + + ulong.Parse(lengthString[1]) * 75 + ulong.Parse(lengthString[2]); } else currentTrack.Sectors = @@ -441,8 +437,8 @@ public sealed partial class Cdrdao } else if(matchFile.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found DATAFILE \"{1}\" at line {0}", - lineNumber, matchFile.Groups["filename"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found DATAFILE \"{1}\" at line {0}", lineNumber, + matchFile.Groups["filename"].Value); filtersList = new FiltersList(); @@ -462,9 +458,8 @@ public sealed partial class Cdrdao { string[] lengthString = matchFile.Groups["length"].Value.Split(':'); - currentTrack.Sectors = (ulong.Parse(lengthString[0]) * 60 * 75) + - (ulong.Parse(lengthString[1]) * 75) + - ulong.Parse(lengthString[2]); + currentTrack.Sectors = ulong.Parse(lengthString[0]) * 60 * 75 + + ulong.Parse(lengthString[1]) * 75 + ulong.Parse(lengthString[2]); } else currentTrack.Sectors = @@ -483,8 +478,8 @@ public sealed partial class Cdrdao } else if(matchPerformer.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found PERFORMER \"{1}\" at line {0}", - lineNumber, matchPerformer.Groups["performer"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found PERFORMER \"{1}\" at line {0}", lineNumber, + matchPerformer.Groups["performer"].Value); if(inTrack) currentTrack.Performer = matchPerformer.Groups["performer"].Value; @@ -493,8 +488,8 @@ public sealed partial class Cdrdao } else if(matchSongwriter.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found SONGWRITER \"{1}\" at line {0}", - lineNumber, matchSongwriter.Groups["songwriter"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found SONGWRITER \"{1}\" at line {0}", lineNumber, + matchSongwriter.Groups["songwriter"].Value); if(inTrack) currentTrack.Songwriter = matchSongwriter.Groups["songwriter"].Value; @@ -503,8 +498,8 @@ public sealed partial class Cdrdao } else if(matchComposer.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found COMPOSER \"{1}\" at line {0}", - lineNumber, matchComposer.Groups["composer"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found COMPOSER \"{1}\" at line {0}", lineNumber, + matchComposer.Groups["composer"].Value); if(inTrack) currentTrack.Composer = matchComposer.Groups["composer"].Value; @@ -513,8 +508,8 @@ public sealed partial class Cdrdao } else if(matchArranger.Success) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "Found ARRANGER \"{1}\" at line {0}", - lineNumber, matchArranger.Groups["arranger"].Value); + AaruConsole.DebugWriteLine("CDRDAO plugin", "Found ARRANGER \"{1}\" at line {0}", lineNumber, + matchArranger.Groups["arranger"].Value); if(inTrack) currentTrack.Arranger = matchArranger.Groups["arranger"].Value; @@ -634,10 +629,9 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine("CDRDAO plugin", "Track information:"); AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc contains {0} tracks", _discimage.Tracks.Count); - for(int i = 0; i < _discimage.Tracks.Count; i++) + for(var i = 0; i < _discimage.Tracks.Count; i++) { - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTrack {0} information:", - _discimage.Tracks[i].Sequence); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTrack {0} information:", _discimage.Tracks[i].Sequence); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\t{0} bytes per sector", _discimage.Tracks[i].Bps); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPregap: {0} sectors", _discimage.Tracks[i].Pregap); @@ -645,8 +639,7 @@ public sealed partial class Cdrdao AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tData: {0} sectors starting at sector {1}", _discimage.Tracks[i].Sectors, _discimage.Tracks[i].StartSector); - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPostgap: {0} sectors", - _discimage.Tracks[i].Postgap); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPostgap: {0} sectors", _discimage.Tracks[i].Postgap); if(_discimage.Tracks[i].Flag4Ch) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTrack is flagged as quadraphonic"); @@ -687,14 +680,12 @@ public sealed partial class Cdrdao if(_discimage.Tracks[i].Performer == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPerformer is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPerformer: {0}", - _discimage.Tracks[i].Performer); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPerformer: {0}", _discimage.Tracks[i].Performer); if(_discimage.Tracks[i].Songwriter == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tSongwriter is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tSongwriter: {0}", - _discimage.Tracks[i].Songwriter); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tSongwriter: {0}", _discimage.Tracks[i].Songwriter); if(_discimage.Tracks[i].Title == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTitle is not set."); @@ -710,7 +701,7 @@ public sealed partial class Cdrdao ulong byteOffset = 0; ulong partitionSequence = 0; - for(int i = 0; i < _discimage.Tracks.Count; i++) + for(var i = 0; i < _discimage.Tracks.Count; i++) { ulong index0Len = 0; @@ -912,8 +903,7 @@ public sealed partial class Cdrdao } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -985,7 +975,7 @@ public sealed partial class Cdrdao uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.Tracktype) { @@ -1062,9 +1052,9 @@ public sealed partial class Cdrdao buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1076,7 +1066,7 @@ public sealed partial class Cdrdao sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1088,7 +1078,7 @@ public sealed partial class Cdrdao if(aaruTrack.Tracktype != CDRDAO_TRACK_TYPE_AUDIO) return ErrorNumber.NoError; - byte[] swapped = new byte[buffer.Length]; + var swapped = new byte[buffer.Length]; for(long i = 0; i < buffer.Length; i += 2) { @@ -1297,7 +1287,7 @@ public sealed partial class Cdrdao sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1414,7 +1404,7 @@ public sealed partial class Cdrdao sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1427,8 +1417,8 @@ public sealed partial class Cdrdao { case CDRDAO_TRACK_TYPE_MODE1: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { @@ -1444,15 +1434,14 @@ public sealed partial class Cdrdao } case CDRDAO_TRACK_TYPE_MODE2_FORM1: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { Array.Copy(buffer, i * 2048, fullSector, 24, 2048); - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, - (long)(sectorAddress + i)); + _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, (long)(sectorAddress + i)); _sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form1); Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352); @@ -1464,15 +1453,14 @@ public sealed partial class Cdrdao } case CDRDAO_TRACK_TYPE_MODE2_FORM2: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { Array.Copy(buffer, i * 2324, fullSector, 24, 2324); - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form2, - (long)(sectorAddress + i)); + _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form2, (long)(sectorAddress + i)); _sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form2); Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352); @@ -1485,8 +1473,8 @@ public sealed partial class Cdrdao case CDRDAO_TRACK_TYPE_MODE2: case CDRDAO_TRACK_TYPE_MODE2_MIX: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { @@ -1505,7 +1493,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru case CDRDAO_TRACK_TYPE_AUDIO: { - byte[] swapped = new byte[buffer.Length]; + var swapped = new byte[buffer.Length]; for(long i = 0; i < buffer.Length; i += 2) { diff --git a/Aaru.Images/CDRDAO/Structs.cs b/Aaru.Images/CDRDAO/Structs.cs index eeb1cf59c..6b22bc605 100644 --- a/Aaru.Images/CDRDAO/Structs.cs +++ b/Aaru.Images/CDRDAO/Structs.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { [SuppressMessage("ReSharper", "NotAccessedField.Local")] diff --git a/Aaru.Images/CDRDAO/Verify.cs b/Aaru.Images/CDRDAO/Verify.cs index a55e43af3..9d7561dfc 100644 --- a/Aaru.Images/CDRDAO/Verify.cs +++ b/Aaru.Images/CDRDAO/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { /// @@ -58,10 +58,10 @@ public sealed partial class Cdrdao if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class Cdrdao if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 9cd8dcb1b..267c5189b 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class Cdrdao { /// @@ -88,8 +88,7 @@ public sealed partial class Cdrdao // TODO: Separate tracks try { - _writingBaseName = - Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); } @@ -149,8 +148,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -185,7 +183,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -197,7 +195,7 @@ public sealed partial class Cdrdao } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -216,8 +214,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -259,7 +256,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -274,7 +271,7 @@ public sealed partial class Cdrdao { case TrackSubchannelType.None: trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -285,7 +282,7 @@ public sealed partial class Cdrdao case TrackSubchannelType.Raw: case TrackSubchannelType.RawInterleaved: trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96))), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)), SeekOrigin.Begin); for(uint i = 0; i < length; i++) @@ -315,8 +312,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -344,7 +340,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -355,10 +351,10 @@ public sealed partial class Cdrdao data = swapped; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize))), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -377,8 +373,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -413,7 +408,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -424,12 +419,12 @@ public sealed partial class Cdrdao data = swapped; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); for(uint i = 0; i < length; i++) { trackStream. - Seek((long)(track.FileOffset + ((i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize))), + Seek((long)(track.FileOffset + (i + sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + subchannelSize)), SeekOrigin.Begin); trackStream.Write(data, (int)(i * track.RawBytesPerSector), track.RawBytesPerSector); @@ -531,8 +526,7 @@ public sealed partial class Cdrdao bool data = _writingTracks.Count(t => t.Type != TrackType.Audio) > 0; - bool mode2 = _writingTracks.Count(t => t.Type == TrackType.CdMode2Form1 || - t.Type == TrackType.CdMode2Form2 || + bool mode2 = _writingTracks.Count(t => t.Type == TrackType.CdMode2Form1 || t.Type == TrackType.CdMode2Form2 || t.Type == TrackType.CdMode2Formless) > 0; if(mode2) @@ -595,8 +589,7 @@ public sealed partial class Cdrdao { _descriptorStream.WriteLine("{0}PRE_EMPHASIS", flags.HasFlag(CdFlags.PreEmphasis) ? "" : "NO "); - _descriptorStream.WriteLine("{0}_CHANNEL_AUDIO", - flags.HasFlag(CdFlags.FourChannel) ? "FOUR" : "TWO"); + _descriptorStream.WriteLine("{0}_CHANNEL_AUDIO", flags.HasFlag(CdFlags.FourChannel) ? "FOUR" : "TWO"); } if(_trackIsrcs.TryGetValue((byte)track.Sequence, out string isrc) && @@ -659,8 +652,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -718,7 +710,7 @@ public sealed partial class Cdrdao } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96))) + track.RawBytesPerSector, + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)(track.RawBytesPerSector + 96)) + track.RawBytesPerSector, SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -743,8 +735,7 @@ public sealed partial class Cdrdao } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -786,7 +777,7 @@ 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, + 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/CDRWin.cs b/Aaru.Images/CDRWin/CDRWin.cs index 363621174..ddc9db5c5 100644 --- a/Aaru.Images/CDRWin/CDRWin.cs +++ b/Aaru.Images/CDRWin/CDRWin.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -namespace Aaru.DiscImages; - // TODO: Implement track flags /// Implements reading and writing CDRWin cuesheet disc images public sealed partial class CdrWin : IWritableOpticalImage, IVerifiableImage diff --git a/Aaru.Images/CDRWin/Helpers.cs b/Aaru.Images/CDRWin/Helpers.cs index cdd071552..47a92c1f8 100644 --- a/Aaru.Images/CDRWin/Helpers.cs +++ b/Aaru.Images/CDRWin/Helpers.cs @@ -30,22 +30,22 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { static int CdrWinMsfToLba(string msf) { string[] msfElements = msf.Split(':'); - int minute = int.Parse(msfElements[0]); - int second = int.Parse(msfElements[1]); - int frame = int.Parse(msfElements[2]); + var minute = int.Parse(msfElements[0]); + var second = int.Parse(msfElements[1]); + var frame = int.Parse(msfElements[2]); - int sectors = (minute * 60 * 75) + (second * 75) + frame; + int sectors = minute * 60 * 75 + second * 75 + frame; return sectors; } diff --git a/Aaru.Images/CDRWin/Identify.cs b/Aaru.Images/CDRWin/Identify.cs index fcf623334..5c057b362 100644 --- a/Aaru.Images/CDRWin/Identify.cs +++ b/Aaru.Images/CDRWin/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { // Due to .cue format, this method must parse whole file, ignoring errors (those will be returned by OpenImage()). @@ -49,14 +49,14 @@ public sealed partial class CdrWin try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - byte[] testArray = new byte[512]; + var testArray = new byte[512]; imageFilter.GetDataForkStream().Read(testArray, 0, 512); imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); // Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin - bool twoConsecutiveNulls = false; + var twoConsecutiveNulls = false; - for(int i = 0; i < 512; i++) + for(var i = 0; i < 512; i++) { if(i >= imageFilter.GetDataForkStream().Length) break; diff --git a/Aaru.Images/CDRWin/Properties.cs b/Aaru.Images/CDRWin/Properties.cs index 0764242d3..b03352452 100644 --- a/Aaru.Images/CDRWin/Properties.cs +++ b/Aaru.Images/CDRWin/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { /// @@ -76,9 +76,9 @@ public sealed partial class CdrWin { List tracks = new(); - ulong previousStartSector = 0; - ulong gdRomSession2Offset = 45000; - string previousTrackFile = ""; + ulong previousStartSector = 0; + ulong gdRomSession2Offset = 45000; + var previousTrackFile = ""; foreach(CdrWinTrack cdrTrack in _discImage.Tracks) { @@ -170,27 +170,27 @@ public sealed partial class CdrWin /// public IEnumerable SupportedSectorTags => new[] { - SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, - SectorTagType.CdSectorEdc, SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, - SectorTagType.CdSectorSync, SectorTagType.CdTrackFlags, SectorTagType.CdTrackIsrc + SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, SectorTagType.CdSectorEdc, + SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, SectorTagType.CdSectorSync, + SectorTagType.CdTrackFlags, SectorTagType.CdTrackIsrc }; /// public IEnumerable SupportedMediaTypes => new[] { MediaType.BDR, MediaType.BDRE, MediaType.BDREXL, MediaType.BDROM, MediaType.UHDBD, MediaType.BDRXL, - MediaType.CBHD, MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, - MediaType.CDMIDI, MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, - MediaType.CDRW, MediaType.CDV, MediaType.DDCD, MediaType.DDCDR, MediaType.DDCDRW, MediaType.DVDDownload, - MediaType.DVDPR, MediaType.DVDPRDL, MediaType.DVDPRW, MediaType.DVDPRWDL, MediaType.DVDR, MediaType.DVDRAM, - MediaType.DVDRDL, MediaType.DVDROM, MediaType.DVDRW, MediaType.DVDRWDL, MediaType.EVD, MediaType.FDDVD, - MediaType.DTSCD, MediaType.FVD, MediaType.HDDVDR, MediaType.HDDVDRAM, MediaType.HDDVDRDL, - MediaType.HDDVDROM, MediaType.HDDVDRW, MediaType.HDDVDRWDL, MediaType.HDVMD, MediaType.HVD, - MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, MediaType.PS2DVD, MediaType.PS3BD, - MediaType.PS3DVD, MediaType.PS4BD, MediaType.PS5BD, MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SVOD, - MediaType.SATURNCD, MediaType.ThreeDO, MediaType.UDO, MediaType.UDO2, MediaType.UDO2_WORM, MediaType.UMD, - MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, MediaType.PCFX, MediaType.CDTV, MediaType.CD32, - MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, - MediaType.VideoNowColor, MediaType.VideoNowXp, MediaType.CVD, MediaType.PCD + MediaType.CBHD, MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, + MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, + MediaType.CDV, MediaType.DDCD, MediaType.DDCDR, MediaType.DDCDRW, MediaType.DVDDownload, MediaType.DVDPR, + MediaType.DVDPRDL, MediaType.DVDPRW, MediaType.DVDPRWDL, MediaType.DVDR, MediaType.DVDRAM, MediaType.DVDRDL, + MediaType.DVDROM, MediaType.DVDRW, MediaType.DVDRWDL, MediaType.EVD, MediaType.FDDVD, MediaType.DTSCD, + MediaType.FVD, MediaType.HDDVDR, MediaType.HDDVDRAM, MediaType.HDDVDRDL, MediaType.HDDVDROM, MediaType.HDDVDRW, + MediaType.HDDVDRWDL, MediaType.HDVMD, MediaType.HVD, MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, + MediaType.PS2CD, MediaType.PS2DVD, MediaType.PS3BD, MediaType.PS3DVD, MediaType.PS4BD, MediaType.PS5BD, + MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SVOD, MediaType.SATURNCD, MediaType.ThreeDO, MediaType.UDO, + MediaType.UDO2, MediaType.UDO2_WORM, MediaType.UMD, MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, + MediaType.PCFX, MediaType.CDTV, MediaType.CD32, MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, + MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, MediaType.VideoNowColor, MediaType.VideoNowXp, + MediaType.CVD, MediaType.PCD }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => new[] diff --git a/Aaru.Images/CDRWin/Read.cs b/Aaru.Images/CDRWin/Read.cs index b76a91dc6..2fe3732cc 100644 --- a/Aaru.Images/CDRWin/Read.cs +++ b/Aaru.Images/CDRWin/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -46,8 +48,6 @@ using Schemas; using Session = Aaru.CommonTypes.Structs.Session; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { /// @@ -62,8 +62,8 @@ public sealed partial class CdrWin { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); _cueStream = new StreamReader(imageFilter.GetDataForkStream()); - int lineNumber = 0; - bool inTrack = false; + var lineNumber = 0; + var inTrack = false; byte currentSession = 1; // Initialize all RegExs @@ -126,7 +126,7 @@ public sealed partial class CdrWin var currentFile = new CdrWinTrackFile(); long currentFileOffsetSector = 0; - int trackCount = 0; + var trackCount = 0; Dictionary leadouts = new(); @@ -140,7 +140,7 @@ public sealed partial class CdrWin if(!matchTrack.Success) continue; - uint trackSeq = uint.Parse(matchTrack.Groups[1].Value); + var trackSeq = uint.Parse(matchTrack.Groups[1].Value); if(trackCount + 1 != trackSeq) { @@ -159,18 +159,18 @@ public sealed partial class CdrWin return ErrorNumber.InvalidArgument; } - CdrWinTrack[] cueTracks = new CdrWinTrack[trackCount]; + var cueTracks = new CdrWinTrack[trackCount]; lineNumber = 0; imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); _cueStream = new StreamReader(imageFilter.GetDataForkStream()); - var filtersList = new FiltersList(); - bool inTruripDiscHash = false; - bool inTruripTrackHash = false; - bool firstTrackInSession = false; - int currentEmptyPregap = 0; - int cumulativeEmptyPregap = 0; + var filtersList = new FiltersList(); + var inTruripDiscHash = false; + var inTruripTrackHash = false; + var firstTrackInSession = false; + var currentEmptyPregap = 0; + var cumulativeEmptyPregap = 0; const ulong gdRomSession2Offset = 45000; @@ -233,8 +233,7 @@ public sealed partial class CdrWin if(matchTruripTrackCrc32.Success) { - AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", - lineNumber, + AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", lineNumber, matchTruripTrackCrc32.Groups[1].Value == "Trk" ? "track" : "gap", matchTruripTrackCrc32.Groups[2].Value); @@ -243,8 +242,7 @@ public sealed partial class CdrWin if(matchTruripTrackMd5.Success) { - AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", - lineNumber, + AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", lineNumber, matchTruripTrackMd5.Groups[1].Value == "Trk" ? "track" : "gap", matchTruripTrackMd5.Groups[2].Value); @@ -253,8 +251,7 @@ public sealed partial class CdrWin if(matchTruripTrackSha1.Success) { - AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", - lineNumber, + AaruConsole.DebugWriteLine("CDRWin plugin", "Found CRC32 for {1} {2} at line {0}", lineNumber, matchTruripTrackSha1.Groups[1].Value == "Trk" ? "track" : "gap", matchTruripTrackSha1.Groups[2].Value); @@ -290,19 +287,16 @@ public sealed partial class CdrWin DumpHardwareType existingDump = DumpHardware.FirstOrDefault(d => d.Manufacturer == matchDumpExtent.Groups["manufacturer"]. - Value && - d.Model == matchDumpExtent.Groups["model"].Value && + Value && d.Model == matchDumpExtent.Groups["model"].Value && d.Firmware == matchDumpExtent.Groups["firmware"].Value && - d.Serial == matchDumpExtent.Groups["serial"].Value && + d.Serial == matchDumpExtent.Groups["serial"].Value && d.Software.Name == matchDumpExtent.Groups["application"]. - Value && - d.Software.Version == matchDumpExtent. - Groups["version"].Value && + Value && + d.Software.Version == matchDumpExtent.Groups["version"].Value && d.Software.OperatingSystem == matchDumpExtent. Groups["os"].Value); if(existingDump is null) - { DumpHardware.Add(new DumpHardwareType { Extents = new[] @@ -324,9 +318,7 @@ public sealed partial class CdrWin OperatingSystem = matchDumpExtent.Groups["os"].Value } }); - } else - { existingDump.Extents = new List(existingDump.Extents) { new() @@ -335,7 +327,6 @@ public sealed partial class CdrWin End = extentEnd } }.OrderBy(e => e.Start).ToArray(); - } } else if(matchDicMediaType.Success && !inTrack) @@ -377,8 +368,7 @@ public sealed partial class CdrWin } else if(matchRedumpHdArea.Success) { - AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM HIGH-DENSITY AREA at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CDRWin plugin", "Found REM HIGH-DENSITY AREA at line {0}", lineNumber); _discImage.IsRedumpGigadisc = true; currentSession = 2; @@ -412,9 +402,8 @@ public sealed partial class CdrWin else if(matchTruripTrack.Success) { AaruConsole.DebugWriteLine("CDRWin plugin", - "Found REM Gap Append Method: {1} [{2}] HASHES at line {0}", - lineNumber, matchTruripTrack.Groups[1].Value, - matchTruripTrack.Groups[2].Value); + "Found REM Gap Append Method: {1} [{2}] HASHES at line {0}", lineNumber, + matchTruripTrack.Groups[1].Value, matchTruripTrack.Groups[2].Value); inTruripTrackHash = true; _discImage.IsTrurip = true; @@ -466,8 +455,7 @@ public sealed partial class CdrWin _discImage.Barcode = matchBarCode.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine($"Found barcode field in incorrect place at line {lineNumber}"); + AaruConsole.ErrorWriteLine($"Found barcode field in incorrect place at line {lineNumber}"); return ErrorNumber.InvalidArgument; } @@ -503,8 +491,7 @@ public sealed partial class CdrWin _discImage.DiscId = matchDiskId.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine($"Found CDDB ID field in incorrect place at line {lineNumber}"); + AaruConsole.ErrorWriteLine($"Found CDDB ID field in incorrect place at line {lineNumber}"); return ErrorNumber.InvalidArgument; } @@ -543,7 +530,7 @@ public sealed partial class CdrWin // Check if file exists if(currentFile.DataFilter == null) if(datafile[0] == '/' || - (datafile[0] == '/' && datafile[1] == '.')) // UNIX absolute path + datafile[0] == '/' && datafile[1] == '.') // UNIX absolute path { var unixPath = new Regex("^(.+)/([^/]+)$"); Match unixPathMatch = unixPath.Match(datafile); @@ -575,9 +562,9 @@ public sealed partial class CdrWin return ErrorNumber.NoSuchFile; } } - else if((datafile[1] == ':' && datafile[2] == '\\') || - (datafile[0] == '\\' && datafile[1] == '\\') || - (datafile[0] == '.' && datafile[1] == '\\')) // Windows absolute path + else if(datafile[1] == ':' && datafile[2] == '\\' || + datafile[0] == '\\' && datafile[1] == '\\' || + datafile[0] == '.' && datafile[1] == '\\') // Windows absolute path { var winPath = new @@ -654,8 +641,7 @@ public sealed partial class CdrWin if(!inTrack) { - AaruConsole. - ErrorWriteLine($"Found FLAGS field in incorrect place at line {lineNumber}"); + AaruConsole.ErrorWriteLine($"Found FLAGS field in incorrect place at line {lineNumber}"); return ErrorNumber.InvalidArgument; } @@ -685,8 +671,8 @@ public sealed partial class CdrWin return ErrorNumber.InvalidArgument; } - ushort index = ushort.Parse(matchIndex.Groups[1].Value); - int offset = CdrWinMsfToLba(matchIndex.Groups[2].Value) + cumulativeEmptyPregap; + var index = ushort.Parse(matchIndex.Groups[1].Value); + int offset = CdrWinMsfToLba(matchIndex.Groups[2].Value) + cumulativeEmptyPregap; if(index != 0 && index != 1 && @@ -698,16 +684,15 @@ public sealed partial class CdrWin } if(index == 0 || - (index == 1 && !currentTrack.Indexes.ContainsKey(0))) + index == 1 && !currentTrack.Indexes.ContainsKey(0)) if((int)(currentTrack.Sequence - 2) >= 0 && offset > 1) { cueTracks[currentTrack.Sequence - 2].Sectors = (ulong)(offset - (int)currentFileOffsetSector); - currentFile.Offset += - cueTracks[currentTrack.Sequence - 2].Sectors * - cueTracks[currentTrack.Sequence - 2].Bps; + currentFile.Offset += cueTracks[currentTrack.Sequence - 2].Sectors * + cueTracks[currentTrack.Sequence - 2].Bps; AaruConsole.DebugWriteLine("CDRWin plugin", "Sets currentFile.offset to {0}", currentFile.Offset); @@ -721,7 +706,7 @@ public sealed partial class CdrWin cueTracks[currentTrack.Sequence - 2].Bps); } - if((index == 0 || (index == 1 && !currentTrack.Indexes.ContainsKey(0))) && + if((index == 0 || index == 1 && !currentTrack.Indexes.ContainsKey(0)) && currentTrack.Sequence == 1) { AaruConsole.DebugWriteLine("CDRWin plugin", "Sets currentFile.offset to {0}", @@ -779,8 +764,7 @@ public sealed partial class CdrWin _discImage.Mcn = matchMcn.Groups[1].Value; else { - AaruConsole. - ErrorWriteLine($"Found CATALOG field in incorrect place at line {lineNumber}"); + AaruConsole.ErrorWriteLine($"Found CATALOG field in incorrect place at line {lineNumber}"); return ErrorNumber.InvalidArgument; } @@ -946,18 +930,18 @@ public sealed partial class CdrWin ErrorWriteLine("The data files are missing a pregap or hidden track contents, will do best effort to make the rest of the image readable."); } - Session[] sessions = new Session[currentSession]; + var sessions = new Session[currentSession]; - for(int s = 1; s <= sessions.Length; s++) + for(var s = 1; s <= sessions.Length; s++) { - bool firstTrackRead = false; + var firstTrackRead = false; sessions[s - 1].Sequence = (ushort)s; ulong sessionSectors = 0; - int lastSessionTrack = 0; - int firstSessionTrk = 0; + var lastSessionTrack = 0; + var firstSessionTrk = 0; - for(int i = 0; i < cueTracks.Length; i++) + for(var i = 0; i < cueTracks.Length; i++) if(cueTracks[i].Session == s) { if(!firstTrackRead) @@ -1015,12 +999,10 @@ public sealed partial class CdrWin } if(firstSessionTrack.Indexes.TryGetValue(1, out sessionStart)) - { sessions[s - 1].StartSector = (ulong)sessionStart; - } } - for(int t = 1; t <= cueTracks.Length; t++) + for(var t = 1; t <= cueTracks.Length; t++) { if(cueTracks[t - 1].Indexes.TryGetValue(0, out int idx0) && cueTracks[t - 1].Indexes.TryGetValue(1, out int idx1)) @@ -1035,17 +1017,17 @@ public sealed partial class CdrWin { Stream track1Stream = _discImage.Tracks[0].TrackFile.DataFilter.GetDataForkStream(); - bool foundSync = true; + var foundSync = true; var rnd = new Random(); // We check 32 random positions, to prevent coincidence of data - for(int i = 0; i < 32; i++) + for(var i = 0; i < 32; i++) { int next = rnd.Next(cueTracks[^1].Indexes[1]); track1Stream.Position = next * 2352; - byte[] data = new byte[16]; + var data = new byte[16]; track1Stream.Read(data, 0, 16); // If the position is not MODEx/2352, it can't be a correct Cuesheet. @@ -1083,9 +1065,7 @@ public sealed partial class CdrWin if(!string.IsNullOrWhiteSpace(_discImage.AaruMediaType) && Enum.TryParse(_discImage.AaruMediaType, true, out MediaType mediaType)) - { _discImage.MediaType = mediaType; - } else if(_discImage.IsRedumpGigadisc) _discImage.MediaType = MediaType.GDROM; else if(_discImage.MediaType == MediaType.Unknown) @@ -1094,15 +1074,15 @@ public sealed partial class CdrWin if(_discImage.MediaType == MediaType.Unknown || _discImage.MediaType == MediaType.CD) { - bool data = false; - bool cdg = false; - bool cdi = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var cdg = false; + var cdi = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; - for(int i = 0; i < _discImage.Tracks.Count; i++) + for(var i = 0; i < _discImage.Tracks.Count; i++) { // First track is audio firstAudio |= i == 0 && _discImage.Tracks[i].TrackType == CDRWIN_TRACK_TYPE_AUDIO; @@ -1149,7 +1129,7 @@ public sealed partial class CdrWin sessions.Length > 1 && mode2) _discImage.MediaType = MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _discImage.MediaType = MediaType.CDROMXA; else if(!audio) _discImage.MediaType = MediaType.CDROM; @@ -1201,8 +1181,7 @@ public sealed partial class CdrWin if(_discImage.OriginalMediaType == null) AaruConsole.DebugWriteLine("CDRWin plugin", "\tISOBuster disc type not set."); else - AaruConsole.DebugWriteLine("CDRWin plugin", "\tISOBuster disc type: {0}", - _discImage.OriginalMediaType); + AaruConsole.DebugWriteLine("CDRWin plugin", "\tISOBuster disc type: {0}", _discImage.OriginalMediaType); AaruConsole.DebugWriteLine("CDRWin plugin", "\tGuessed disk type: {0}", _discImage.MediaType); @@ -1229,17 +1208,15 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine("CDRWin plugin", "Track information:"); AaruConsole.DebugWriteLine("CDRWin plugin", "\tDisc contains {0} tracks", _discImage.Tracks.Count); - for(int i = 0; i < _discImage.Tracks.Count; i++) + for(var i = 0; i < _discImage.Tracks.Count; i++) { - AaruConsole.DebugWriteLine("CDRWin plugin", "\tTrack {0} information:", - _discImage.Tracks[i].Sequence); + AaruConsole.DebugWriteLine("CDRWin plugin", "\tTrack {0} information:", _discImage.Tracks[i].Sequence); AaruConsole.DebugWriteLine("CDRWin plugin", "\t\t{0} bytes per sector", _discImage.Tracks[i].Bps); AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPregap: {0} sectors", _discImage.Tracks[i].Pregap); AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tData: {0} sectors", _discImage.Tracks[i].Sectors); - AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPostgap: {0} sectors", - _discImage.Tracks[i].Postgap); + AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPostgap: {0} sectors", _discImage.Tracks[i].Postgap); if(_discImage.Tracks[i].Flag4Ch) AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tTrack is flagged as quadraphonic"); @@ -1288,14 +1265,12 @@ public sealed partial class CdrWin if(_discImage.Tracks[i].Performer == null) AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPerformer is not set."); else - AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPerformer: {0}", - _discImage.Tracks[i].Performer); + AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tPerformer: {0}", _discImage.Tracks[i].Performer); if(_discImage.Tracks[i].Songwriter == null) AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tSongwriter is not set."); else - AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tSongwriter: {0}", - _discImage.Tracks[i].Songwriter); + AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tSongwriter: {0}", _discImage.Tracks[i].Songwriter); if(_discImage.Tracks[i].Title == null) AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tTitle is not set."); @@ -1306,9 +1281,9 @@ public sealed partial class CdrWin foreach(CdrWinTrack track in _discImage.Tracks) _imageInfo.ImageSize += track.Bps * track.Sectors; - int currentSector = 0; - int currentFileStartSector = 0; - string currentFilePath = ""; + var currentSector = 0; + var currentFileStartSector = 0; + var currentFilePath = ""; firstTrackInSession = true; foreach(CdrWinTrack track in _discImage.Tracks) @@ -1340,12 +1315,11 @@ public sealed partial class CdrWin currentSector += (int)track.Sectors; } - for(int s = 0; s < sessions.Length; s++) + for(var s = 0; s < sessions.Length; s++) { 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); + _discImage.Tracks[(int)sessions[s].StartTrack - 1].Indexes.TryGetValue(1, out sessionTrackStart); sessions[s].StartSector = (ulong)(sessionTrackStart > 0 ? sessionTrackStart : 0); @@ -1356,7 +1330,7 @@ public sealed partial class CdrWin sessions[s].EndSector += _discImage.Tracks[(int)sessions[s].EndTrack - 1].Sectors - 1; } - for(int s = 1; s <= sessions.Length; s++) + for(var s = 1; s <= sessions.Length; s++) _discImage.Sessions.Add(sessions[s - 1]); _imageInfo.Sectors = _discImage.Sessions.OrderByDescending(s => s.EndSector).First().EndSector + 1; @@ -1364,7 +1338,7 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine("CDRWin plugin", "Session information:"); AaruConsole.DebugWriteLine("CDRWin plugin", "\tDisc contains {0} sessions", _discImage.Sessions.Count); - for(int i = 0; i < _discImage.Sessions.Count; i++) + for(var i = 0; i < _discImage.Sessions.Count; i++) { AaruConsole.DebugWriteLine("CDRWin plugin", "\tSession {0} information:", i + 1); @@ -1374,11 +1348,9 @@ public sealed partial class CdrWin AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tStarting sector: {0}", _discImage.Sessions[i].StartSector); - AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding track: {0}", - _discImage.Sessions[i].EndTrack); + AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding track: {0}", _discImage.Sessions[i].EndTrack); - AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding sector: {0}", - _discImage.Sessions[i].EndSector); + AaruConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding sector: {0}", _discImage.Sessions[i].EndSector); } AaruConsole.DebugWriteLine("CDRWin plugin", "Building offset map"); @@ -1389,7 +1361,7 @@ public sealed partial class CdrWin _offsetMap = new Dictionary(); - for(int i = 0; i < _discImage.Tracks.Count; i++) + for(var i = 0; i < _discImage.Tracks.Count; i++) { if(_discImage.Tracks[i].Sequence == 1 && i != 0) @@ -1579,13 +1551,11 @@ public sealed partial class CdrWin _sectorBuilder = new SectorBuilder(); - int mediaTypeAsInt = (int)_discImage.MediaType; + var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = (mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39) || mediaTypeAsInt == 112 || - mediaTypeAsInt == 113 || (mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152) || - mediaTypeAsInt == 154 || mediaTypeAsInt == 155 || - (mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179) || - (mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749); + _isCd = mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39 || mediaTypeAsInt == 112 || mediaTypeAsInt == 113 || + mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152 || mediaTypeAsInt == 154 || mediaTypeAsInt == 155 || + mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179 || mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749; if(currentSession > 1 && leadouts.Count == 0 && @@ -1618,8 +1588,7 @@ public sealed partial class CdrWin track.Indexes.Remove(0); track.Pregap = 0; - for(int s = 0; s < sessions.Length; s++) - { + for(var s = 0; s < sessions.Length; s++) if(sessions[s].Sequence > 1 && track.Sequence == sessions[s].StartTrack) { @@ -1627,7 +1596,6 @@ public sealed partial class CdrWin track.Sectors -= 150; sessions[s].StartSector = (ulong)track.Indexes[1]; } - } } _discImage.Sessions = sessions.ToList(); @@ -1669,8 +1637,7 @@ public sealed partial class CdrWin } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -1731,7 +1698,7 @@ public sealed partial class CdrWin uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.TrackType) { @@ -1813,8 +1780,7 @@ public sealed partial class CdrWin ulong pregapPos = _lostPregap - sectorAddress; - ErrorNumber errno = - ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); + ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); if(errno != ErrorNumber.NoError) return errno; @@ -1866,9 +1832,9 @@ public sealed partial class CdrWin buffer = br.ReadBytes((int)(sectorSize * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, sectorSize * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1880,7 +1846,7 @@ public sealed partial class CdrWin sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2112,8 +2078,7 @@ public sealed partial class CdrWin ulong pregapPos = _lostPregap - sectorAddress; - ErrorNumber errno = - ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); + ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); if(errno != ErrorNumber.NoError) return errno; @@ -2137,7 +2102,7 @@ public sealed partial class CdrWin sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2254,8 +2219,7 @@ public sealed partial class CdrWin ulong pregapPos = _lostPregap - sectorAddress; - ErrorNumber errno = - ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); + ErrorNumber errno = ReadSectors(_lostPregap, (uint)(length - pregapPos), track, out byte[] presentData); if(errno != ErrorNumber.NoError) return errno; @@ -2305,7 +2269,7 @@ public sealed partial class CdrWin sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2318,8 +2282,8 @@ public sealed partial class CdrWin { case CDRWIN_TRACK_TYPE_MODE1: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { @@ -2335,15 +2299,14 @@ public sealed partial class CdrWin } case CDRWIN_TRACK_TYPE_MODE2_FORM1: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { Array.Copy(buffer, i * 2048, fullSector, 24, 2048); - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, - (long)(sectorAddress + i)); + _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, (long)(sectorAddress + i)); _sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form1); Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352); @@ -2355,15 +2318,14 @@ public sealed partial class CdrWin } case CDRWIN_TRACK_TYPE_MODE2_FORM2: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { Array.Copy(buffer, i * 2324, fullSector, 24, 2324); - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form2, - (long)(sectorAddress + i)); + _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form2, (long)(sectorAddress + i)); _sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form2); Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352); @@ -2376,8 +2338,8 @@ public sealed partial class CdrWin case CDRWIN_TRACK_TYPE_MODE2_FORMLESS: case CDRWIN_TRACK_TYPE_CDI: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/CDRWin/Structs.cs b/Aaru.Images/CDRWin/Structs.cs index dc2eee170..7d669e3e4 100644 --- a/Aaru.Images/CDRWin/Structs.cs +++ b/Aaru.Images/CDRWin/Structs.cs @@ -30,15 +30,17 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; + // ReSharper disable NotAccessedField.Local namespace Aaru.DiscImages; +using System.Collections.Generic; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; + public sealed partial class CdrWin { struct CdrWinTrackFile diff --git a/Aaru.Images/CDRWin/Verify.cs b/Aaru.Images/CDRWin/Verify.cs index 418c9ea07..5c6bbc5dd 100644 --- a/Aaru.Images/CDRWin/Verify.cs +++ b/Aaru.Images/CDRWin/Verify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { /// @@ -54,8 +54,8 @@ public sealed partial class CdrWin 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)) { @@ -166,10 +166,10 @@ public sealed partial class CdrWin if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -199,14 +199,15 @@ public sealed partial class CdrWin { failingLbas = new List(); unknownLbas = new List(); - var errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); + ErrorNumber errno = ReadSectorsLong(sectorAddress, length, track, out byte[] buffer); if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; - for(int i = 0; i < length; i++) + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; + + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index 108114d6d..733431d29 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CdrWin { /// @@ -87,8 +87,7 @@ public sealed partial class CdrWin // TODO: Separate tracks try { - _writingBaseName = - Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); } @@ -106,12 +105,11 @@ public sealed partial class CdrWin Tracks = new List() }; - int mediaTypeAsInt = (int)_discImage.MediaType; + var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = (mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39) || mediaTypeAsInt == 112 || mediaTypeAsInt == 113 || - (mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152) || mediaTypeAsInt == 154 || - mediaTypeAsInt == 155 || (mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179) || - (mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749); + _isCd = mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39 || mediaTypeAsInt == 112 || mediaTypeAsInt == 113 || + mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152 || mediaTypeAsInt == 154 || mediaTypeAsInt == 155 || + mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179 || mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749; if(_isCd) { @@ -168,8 +166,7 @@ public sealed partial class CdrWin } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -202,7 +199,7 @@ public sealed partial class CdrWin } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -221,8 +218,7 @@ public sealed partial class CdrWin } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -262,7 +258,7 @@ public sealed partial class CdrWin } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -281,8 +277,7 @@ public sealed partial class CdrWin } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -308,7 +303,7 @@ public sealed partial class CdrWin } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -327,8 +322,7 @@ public sealed partial class CdrWin } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -361,7 +355,7 @@ public sealed partial class CdrWin } trackStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); trackStream.Write(data, 0, data.Length); @@ -446,7 +440,7 @@ public sealed partial class CdrWin _writingStreams.First().Value.Close(); } - int currentSession = 0; + var currentSession = 0; if(!string.IsNullOrWhiteSpace(_discImage.Comment)) { @@ -472,7 +466,6 @@ public sealed partial class CdrWin } if(DumpHardware != null) - { foreach(var dumpData in from dump in DumpHardware from extent in dump.Extents.OrderBy(e => e.Start) select new { @@ -486,11 +479,8 @@ public sealed partial class CdrWin extent.Start, extent.End }) - { _descriptorStream. WriteLine($"REM METADATA DUMP EXTENT: {dumpData.Application} | {dumpData.ApplicationVersion} | {dumpData.OperatingSystem} | {dumpData.Manufacturer} | {dumpData.Model} | {dumpData.Firmware} | {dumpData.Serial} | {dumpData.Start}:{dumpData.End}"); - } - } if(!string.IsNullOrEmpty(_discImage.CdTextFile)) _descriptorStream.WriteLine("CDTEXTFILE \"{0}\"", Path.GetFileName(_discImage.CdTextFile)); @@ -505,8 +495,7 @@ public sealed partial class CdrWin _descriptorStream.WriteLine("UPC_EAN {0}", _discImage.Barcode); if(!_separateTracksWriting) - _descriptorStream.WriteLine("FILE \"{0}\" BINARY", - Path.GetFileName(_writingStreams.First().Value.Name)); + _descriptorStream.WriteLine("FILE \"{0}\" BINARY", Path.GetFileName(_writingStreams.First().Value.Name)); Track trackZero = null; @@ -584,8 +573,8 @@ public sealed partial class CdrWin if(currentSession >= lastSession) continue; - Track lastTrackInSession = _writingTracks.Where(t => t.Session == currentSession). - OrderBy(t => t.Sequence).LastOrDefault(); + Track lastTrackInSession = _writingTracks.Where(t => t.Session == currentSession).OrderBy(t => t.Sequence). + LastOrDefault(); if(track.Sequence != lastTrackInSession.Sequence) continue; @@ -622,8 +611,7 @@ public sealed partial class CdrWin } Track track = - _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && - sectorAddress <= trk.EndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { diff --git a/Aaru.Images/CHD/CHD.cs b/Aaru.Images/CHD/CHD.cs index 047b3ca2d..919a7affc 100644 --- a/Aaru.Images/CHD/CHD.cs +++ b/Aaru.Images/CHD/CHD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -namespace Aaru.DiscImages; - // TODO: Implement PCMCIA support /// Implements reading MAME CHD disk images [SuppressMessage("ReSharper", "NotAccessedField.Local")] diff --git a/Aaru.Images/CHD/Constants.cs b/Aaru.Images/CHD/Constants.cs index 2aa3b1011..f33dcf87d 100644 --- a/Aaru.Images/CHD/Constants.cs +++ b/Aaru.Images/CHD/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Chd { diff --git a/Aaru.Images/CHD/Enums.cs b/Aaru.Images/CHD/Enums.cs index f6c0d0824..9acac069e 100644 --- a/Aaru.Images/CHD/Enums.cs +++ b/Aaru.Images/CHD/Enums.cs @@ -30,22 +30,25 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Chd { enum Compression : uint { - None = 0, Zlib = 1, ZlibPlus = 2, - Av = 3 + None = 0, + Zlib = 1, + ZlibPlus = 2, + Av = 3 } enum Flags : uint { - HasParent = 1, Writable = 2 + HasParent = 1, + Writable = 2 } enum EntryFlagsV3 : byte @@ -68,13 +71,20 @@ public sealed partial class Chd enum TrackTypeOld : uint { - Mode1 = 0, Mode1Raw, Mode2, - Mode2Form1, Mode2Form2, Mode2FormMix, - Mode2Raw, Audio + Mode1 = 0, + Mode1Raw, + Mode2, + Mode2Form1, + Mode2Form2, + Mode2FormMix, + Mode2Raw, + Audio } enum SubTypeOld : uint { - Cooked = 0, Raw, None + Cooked = 0, + Raw, + None } } \ No newline at end of file diff --git a/Aaru.Images/CHD/Helpers.cs b/Aaru.Images/CHD/Helpers.cs index da57a9919..8b193997e 100644 --- a/Aaru.Images/CHD/Helpers.cs +++ b/Aaru.Images/CHD/Helpers.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.Helpers; using SharpCompress.Compressors; using SharpCompress.Compressors.Deflate; -namespace Aaru.DiscImages; - public sealed partial class Chd { Track GetTrack(ulong sector) @@ -73,7 +73,7 @@ public sealed partial class Chd ulong offset = _hunkTable[hunkNo] & 0x00000FFFFFFFFFFF; ulong length = _hunkTable[hunkNo] >> 44; - byte[] compHunk = new byte[length]; + var compHunk = new byte[length]; _imageStream.Seek((long)offset, SeekOrigin.Begin); _imageStream.Read(compHunk, 0, compHunk.Length); @@ -104,7 +104,7 @@ public sealed partial class Chd break; case 3: - byte[] entryBytes = new byte[16]; + var entryBytes = new byte[16]; Array.Copy(_hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16); MapEntryV3 entry = Marshal.ByteArrayToStructureBigEndian(entryBytes); @@ -122,7 +122,7 @@ public sealed partial class Chd case Compression.ZlibPlus: if(_isHdd) { - byte[] zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb]; + var zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb]; _imageStream.Seek((long)entry.offset, SeekOrigin.Begin); _imageStream.Read(zHunk, 0, zHunk.Length); @@ -153,15 +153,14 @@ public sealed partial class Chd break; case Compression.Av: - AaruConsole. - ErrorWriteLine($"Unsupported compression {(Compression)_hdrCompression}"); + AaruConsole.ErrorWriteLine($"Unsupported compression {(Compression)_hdrCompression}"); return ErrorNumber.NotImplemented; } break; case EntryFlagsV3.Uncompressed: - uncompressedV3: + uncompressedV3: buffer = new byte[_bytesPerHunk]; _imageStream.Seek((long)entry.offset, SeekOrigin.Begin); _imageStream.Read(buffer, 0, buffer.Length); @@ -172,7 +171,7 @@ public sealed partial class Chd byte[] mini; mini = BigEndianBitConverter.GetBytes(entry.offset); - for(int i = 0; i < _bytesPerHunk; i++) + for(var i = 0; i < _bytesPerHunk; i++) buffer[i] = mini[i % 8]; break; diff --git a/Aaru.Images/CHD/Identify.cs b/Aaru.Images/CHD/Identify.cs index 0394ae628..6d9c8b713 100644 --- a/Aaru.Images/CHD/Identify.cs +++ b/Aaru.Images/CHD/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class Chd { /// @@ -43,7 +43,7 @@ public sealed partial class Chd { Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] magic = new byte[8]; + var magic = new byte[8]; stream.Read(magic, 0, 8); return _chdTag.SequenceEqual(magic); diff --git a/Aaru.Images/CHD/Properties.cs b/Aaru.Images/CHD/Properties.cs index 100f3c59c..0c2e81c88 100644 --- a/Aaru.Images/CHD/Properties.cs +++ b/Aaru.Images/CHD/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; @@ -37,8 +39,6 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Chd { /// diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index 2c4e762cc..72c665bef 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -47,8 +49,6 @@ using Aaru.Decoders.CD; using Aaru.Helpers; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class Chd { /// @@ -57,19 +57,19 @@ public sealed partial class Chd { Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] magic = new byte[8]; + var magic = new byte[8]; stream.Read(magic, 0, 8); if(!_chdTag.SequenceEqual(magic)) return ErrorNumber.InvalidArgument; // Read length - byte[] buffer = new byte[4]; + var buffer = new byte[4]; stream.Read(buffer, 0, 4); - uint length = BitConverter.ToUInt32(buffer.Reverse().ToArray(), 0); + var length = BitConverter.ToUInt32(buffer.Reverse().ToArray(), 0); buffer = new byte[4]; stream.Read(buffer, 0, 4); - uint version = BitConverter.ToUInt32(buffer.Reverse().ToArray(), 0); + var version = BitConverter.ToUInt32(buffer.Reverse().ToArray(), 0); buffer = new byte[length]; stream.Seek(0, SeekOrigin.Begin); @@ -83,8 +83,7 @@ public sealed partial class Chd { HeaderV1 hdrV1 = Marshal.ByteArrayToStructureBigEndian(buffer); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV1.tag = \"{0}\"", - Encoding.ASCII.GetString(hdrV1.tag)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV1.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV1.tag)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV1.length = {0} bytes", hdrV1.length); AaruConsole.DebugWriteLine("CHD plugin", "hdrV1.version = {0}", hdrV1.version); @@ -108,11 +107,11 @@ public sealed partial class Chd _hunkTable = new ulong[hdrV1.totalhunks]; - uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV1.totalhunks * 8 / 512); + var hunkSectorCount = (uint)Math.Ceiling((double)hdrV1.totalhunks * 8 / 512); - byte[] hunkSectorBytes = new byte[512]; + var hunkSectorBytes = new byte[512]; - for(int i = 0; i < hunkSectorCount; i++) + for(var i = 0; i < hunkSectorCount; i++) { stream.Read(hunkSectorBytes, 0, 512); @@ -123,11 +122,10 @@ public sealed partial class Chd // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(_hunkTable.Length >= (i * 512 / 8) + (512 / 8)) + if(_hunkTable.Length >= i * 512 / 8 + 512 / 8) Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, - _hunkTable.Length - (i * 512 / 8)); + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - i * 512 / 8); } DateTime end = DateTime.UtcNow; @@ -157,8 +155,7 @@ public sealed partial class Chd { HeaderV2 hdrV2 = Marshal.ByteArrayToStructureBigEndian(buffer); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.tag = \"{0}\"", - Encoding.ASCII.GetString(hdrV2.tag)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV2.tag)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.length = {0} bytes", hdrV2.length); AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.version = {0}", hdrV2.version); @@ -185,11 +182,11 @@ public sealed partial class Chd _hunkTable = new ulong[hdrV2.totalhunks]; // How many sectors uses the BAT - uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV2.totalhunks * 8 / 512); + var hunkSectorCount = (uint)Math.Ceiling((double)hdrV2.totalhunks * 8 / 512); - byte[] hunkSectorBytes = new byte[512]; + var hunkSectorBytes = new byte[512]; - for(int i = 0; i < hunkSectorCount; i++) + for(var i = 0; i < hunkSectorCount; i++) { stream.Read(hunkSectorBytes, 0, 512); @@ -200,11 +197,10 @@ public sealed partial class Chd // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(_hunkTable.Length >= (i * 512 / 8) + (512 / 8)) + if(_hunkTable.Length >= i * 512 / 8 + 512 / 8) Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, - _hunkTable.Length - (i * 512 / 8)); + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - i * 512 / 8); } DateTime end = DateTime.UtcNow; @@ -234,8 +230,7 @@ public sealed partial class Chd { HeaderV3 hdrV3 = Marshal.ByteArrayToStructureBigEndian(buffer); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.tag = \"{0}\"", - Encoding.ASCII.GetString(hdrV3.tag)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV3.tag)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.length = {0} bytes", hdrV3.length); AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.version = {0}", hdrV3.version); @@ -254,8 +249,7 @@ public sealed partial class Chd AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.hunkbytes = {0}", hdrV3.hunkbytes); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.sha1 = {0}", - ArrayHelpers.ByteArrayToHex(hdrV3.sha1)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV3.sha1)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV3.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV3.parentsha1) ? "null" @@ -287,8 +281,7 @@ public sealed partial class Chd { HeaderV4 hdrV4 = Marshal.ByteArrayToStructureBigEndian(buffer); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.tag = \"{0}\"", - Encoding.ASCII.GetString(hdrV4.tag)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV4.tag)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.length = {0} bytes", hdrV4.length); AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.version = {0}", hdrV4.version); @@ -301,8 +294,7 @@ public sealed partial class Chd AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.metaoffset = {0}", hdrV4.metaoffset); AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.hunkbytes = {0}", hdrV4.hunkbytes); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.sha1 = {0}", - ArrayHelpers.ByteArrayToHex(hdrV4.sha1)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV4.sha1)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV4.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV4.parentsha1) ? "null" @@ -342,27 +334,22 @@ public sealed partial class Chd HeaderV5 hdrV5 = Marshal.ByteArrayToStructureBigEndian(buffer); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.tag = \"{0}\"", - Encoding.ASCII.GetString(hdrV5.tag)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.tag = \"{0}\"", Encoding.ASCII.GetString(hdrV5.tag)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.length = {0} bytes", hdrV5.length); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.version = {0}", hdrV5.version); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.compressor0 = \"{0}\"", - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(hdrV5.compressor0))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor0))); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.compressor1 = \"{0}\"", - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(hdrV5.compressor1))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor1))); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.compressor2 = \"{0}\"", - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(hdrV5.compressor2))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor2))); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.compressor3 = \"{0}\"", - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(hdrV5.compressor3))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(hdrV5.compressor3))); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.logicalbytes = {0}", hdrV5.logicalbytes); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.mapoffset = {0}", hdrV5.mapoffset); @@ -370,8 +357,7 @@ public sealed partial class Chd AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.hunkbytes = {0}", hdrV5.hunkbytes); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.unitbytes = {0}", hdrV5.unitbytes); - AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.sha1 = {0}", - ArrayHelpers.ByteArrayToHex(hdrV5.sha1)); + AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.sha1 = {0}", ArrayHelpers.ByteArrayToHex(hdrV5.sha1)); AaruConsole.DebugWriteLine("CHD plugin", "hdrV5.parentsha1 = {0}", ArrayHelpers.ArrayIsNullOrEmpty(hdrV5.parentsha1) ? "null" @@ -388,13 +374,13 @@ public sealed partial class Chd _hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes]; - uint hunkSectorCount = (uint)Math.Ceiling((double)_hunkTableSmall.Length * 4 / 512); + var hunkSectorCount = (uint)Math.Ceiling((double)_hunkTableSmall.Length * 4 / 512); - byte[] hunkSectorBytes = new byte[512]; + var hunkSectorBytes = new byte[512]; stream.Seek((long)hdrV5.mapoffset, SeekOrigin.Begin); - for(int i = 0; i < hunkSectorCount; i++) + for(var i = 0; i < hunkSectorCount; i++) { stream.Read(hunkSectorBytes, 0, 512); @@ -407,11 +393,11 @@ public sealed partial class Chd // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(_hunkTableSmall.Length >= (i * 512 / 4) + (512 / 4)) + if(_hunkTableSmall.Length >= i * 512 / 4 + 512 / 4) 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)); + _hunkTableSmall.Length - i * 512 / 4); } DateTime end = DateTime.UtcNow; @@ -461,11 +447,11 @@ public sealed partial class Chd while(nextMetaOff > 0) { - byte[] hdrBytes = new byte[16]; + var hdrBytes = new byte[16]; stream.Seek((long)nextMetaOff, SeekOrigin.Begin); stream.Read(hdrBytes, 0, hdrBytes.Length); MetadataHeader header = Marshal.ByteArrayToStructureBigEndian(hdrBytes); - byte[] meta = new byte[header.flagsAndLength & 0xFFFFFF]; + var meta = new byte[header.flagsAndLength & 0xFFFFFF]; stream.Read(meta, 0, meta.Length); AaruConsole.DebugWriteLine("CHD plugin", "Found metadata \"{0}\"", @@ -516,7 +502,7 @@ public sealed partial class Chd return ErrorNumber.NotSupported; } - uint chdTracksNumber = BigEndianBitConverter.ToUInt32(meta, 0); + var chdTracksNumber = BigEndianBitConverter.ToUInt32(meta, 0); // Byteswapped if(chdTracksNumber > 99) @@ -528,12 +514,12 @@ public sealed partial class Chd { var chdTrack = new TrackOld { - type = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 0)), - subType = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 4)), - dataSize = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 8)), - subSize = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 12)), - frames = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 16)), - extraFrames = BigEndianBitConverter.ToUInt32(meta, (int)(4 + (i * 24) + 20)) + type = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 0)), + subType = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 4)), + dataSize = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 8)), + subSize = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 12)), + frames = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 16)), + extraFrames = BigEndianBitConverter.ToUInt32(meta, (int)(4 + i * 24 + 20)) }; var aaruTrack = new Track(); @@ -664,8 +650,8 @@ public sealed partial class Chd { _isCdrom = true; - uint trackNo = uint.Parse(chtrMatch.Groups["track"].Value); - uint frames = uint.Parse(chtrMatch.Groups["frames"].Value); + var trackNo = uint.Parse(chtrMatch.Groups["track"].Value); + var frames = uint.Parse(chtrMatch.Groups["frames"].Value); string subtype = chtrMatch.Groups["sub_type"].Value; string tracktype = chtrMatch.Groups["track_type"].Value; @@ -809,12 +795,12 @@ public sealed partial class Chd { _isCdrom = true; - uint trackNo = uint.Parse(cht2Match.Groups["track"].Value); - uint frames = uint.Parse(cht2Match.Groups["frames"].Value); + var trackNo = uint.Parse(cht2Match.Groups["track"].Value); + var frames = uint.Parse(cht2Match.Groups["frames"].Value); string subtype = cht2Match.Groups["sub_type"].Value; string trackType = cht2Match.Groups["track_type"].Value; - uint pregap = uint.Parse(cht2Match.Groups["pregap"].Value); + var pregap = uint.Parse(cht2Match.Groups["pregap"].Value); // What is this, really? Same as track type? string pregapType = cht2Match.Groups["pgtype"].Value; @@ -826,7 +812,7 @@ public sealed partial class Chd // or of any data track followed by an audio track, according to Yellow Book. // It is indistinguishable from normal data. // TODO: Does CHD store it, or like CDRWin, ignores it? - uint postgap = uint.Parse(cht2Match.Groups["postgap"].Value); + var postgap = uint.Parse(cht2Match.Groups["postgap"].Value); if(trackNo != currentTrack) { @@ -993,17 +979,17 @@ public sealed partial class Chd { _isGdrom = true; - uint trackNo = uint.Parse(chgdMatch.Groups["track"].Value); - uint frames = uint.Parse(chgdMatch.Groups["frames"].Value); + var trackNo = uint.Parse(chgdMatch.Groups["track"].Value); + var frames = uint.Parse(chgdMatch.Groups["frames"].Value); string subtype = chgdMatch.Groups["sub_type"].Value; string trackType = chgdMatch.Groups["track_type"].Value; // TODO: Check pregap, postgap and pad behaviour - uint pregap = uint.Parse(chgdMatch.Groups["pregap"].Value); + var pregap = uint.Parse(chgdMatch.Groups["pregap"].Value); string pregapType = chgdMatch.Groups["pgtype"].Value; string pregapSubType = chgdMatch.Groups["pgsub"].Value; - uint postgap = uint.Parse(chgdMatch.Groups["postgap"].Value); - uint pad = uint.Parse(chgdMatch.Groups["pad"].Value); + var postgap = uint.Parse(chgdMatch.Groups["postgap"].Value); + var pad = uint.Parse(chgdMatch.Groups["pad"].Value); if(trackNo != currentTrack) { @@ -1231,13 +1217,12 @@ public sealed partial class Chd var partition = new Partition { Description = aaruTrack.Description, - Size = (aaruTrack.EndSector - (ulong)aaruTrack.Indexes[1] + 1) * - (ulong)aaruTrack.RawBytesPerSector, - Length = aaruTrack.EndSector - (ulong)aaruTrack.Indexes[1] + 1, + Size = (aaruTrack.EndSector - (ulong)aaruTrack.Indexes[1] + 1) * (ulong)aaruTrack.RawBytesPerSector, + Length = aaruTrack.EndSector - (ulong)aaruTrack.Indexes[1] + 1, Sequence = aaruTrack.Sequence, - Offset = partPos, - Start = (ulong)aaruTrack.Indexes[1], - Type = aaruTrack.Type.ToString() + Offset = partPos, + Start = (ulong)aaruTrack.Indexes[1], + Type = aaruTrack.Type.ToString() }; partPos += partition.Length; @@ -1380,7 +1365,7 @@ public sealed partial class Chd } uint sectorOffset; - bool mode2 = false; + var mode2 = false; switch(track.Type) { @@ -1458,7 +1443,7 @@ public sealed partial class Chd if(mode2) buffer = Sector.GetUserDataFromMode2(sector); else if(track.Type == TrackType.Audio && _swapAudio) - for(int i = 0; i < 2352; i += 2) + for(var i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; @@ -1703,7 +1688,7 @@ public sealed partial class Chd buffer = new byte[sectorSize]; if(track.Type == TrackType.Audio && _swapAudio) - for(int i = 0; i < 2352; i += 2) + for(var i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; @@ -1712,7 +1697,7 @@ public sealed partial class Chd Array.Copy(sector, sectorOffset, buffer, 0, sectorSize); if(track.Type == TrackType.Audio && _swapAudio) - for(int i = 0; i < 2352; i += 2) + for(var i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; @@ -1795,7 +1780,7 @@ public sealed partial class Chd if(!_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) { track = GetTrack(sectorAddress); - uint sectorSize = (uint)track.RawBytesPerSector; + var sectorSize = (uint)track.RawBytesPerSector; ulong hunkNo = sectorAddress / _sectorsPerHunk; ulong secOff = sectorAddress * sectorSize % (_sectorsPerHunk * sectorSize); @@ -1817,7 +1802,7 @@ public sealed partial class Chd buffer = new byte[track.RawBytesPerSector]; if(track.Type == TrackType.Audio && _swapAudio) - for(int i = 0; i < 2352; i += 2) + for(var i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; @@ -1829,7 +1814,7 @@ public sealed partial class Chd { case TrackType.CdMode1 when track.RawBytesPerSector == 2048: { - byte[] fullSector = new byte[2352]; + var fullSector = new byte[2352]; Array.Copy(buffer, 0, fullSector, 16, 2048); _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode1, (long)sectorAddress); @@ -1841,7 +1826,7 @@ public sealed partial class Chd } case TrackType.CdMode2Form1 when track.RawBytesPerSector == 2048: { - byte[] fullSector = new byte[2352]; + var fullSector = new byte[2352]; Array.Copy(buffer, 0, fullSector, 24, 2048); _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, (long)sectorAddress); @@ -1853,7 +1838,7 @@ public sealed partial class Chd } case TrackType.CdMode2Form1 when track.RawBytesPerSector == 2324: { - byte[] fullSector = new byte[2352]; + var fullSector = new byte[2352]; Array.Copy(buffer, 0, fullSector, 24, 2324); _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form2, (long)sectorAddress); @@ -1865,7 +1850,7 @@ public sealed partial class Chd } case TrackType.CdMode2Formless when track.RawBytesPerSector == 2336: { - byte[] fullSector = new byte[2352]; + var fullSector = new byte[2352]; _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Formless, (long)sectorAddress); Array.Copy(buffer, 0, fullSector, 16, 2336); @@ -1976,8 +1961,7 @@ public sealed partial class Chd { buffer = null; - return _isHdd ? ErrorNumber.NotSupported - : ReadSectorLong(GetAbsoluteSector(sectorAddress, track), out buffer); + return _isHdd ? ErrorNumber.NotSupported : ReadSectorLong(GetAbsoluteSector(sectorAddress, track), out buffer); } /// diff --git a/Aaru.Images/CHD/Structs.cs b/Aaru.Images/CHD/Structs.cs index e5f1550c4..99ea52ce6 100644 --- a/Aaru.Images/CHD/Structs.cs +++ b/Aaru.Images/CHD/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class Chd { diff --git a/Aaru.Images/CHD/Verify.cs b/Aaru.Images/CHD/Verify.cs index ec0ed0594..6b725f297 100644 --- a/Aaru.Images/CHD/Verify.cs +++ b/Aaru.Images/CHD/Verify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Chd { /// @@ -66,10 +66,10 @@ public sealed partial class Chd if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -108,10 +108,10 @@ public sealed partial class Chd if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/CPCDSK/CPCDSK.cs b/Aaru.Images/CPCDSK/CPCDSK.cs index 79c00d55b..14ffe41c3 100644 --- a/Aaru.Images/CPCDSK/CPCDSK.cs +++ b/Aaru.Images/CPCDSK/CPCDSK.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading CPCDSK disk images public sealed partial class Cpcdsk : IMediaImage diff --git a/Aaru.Images/CPCDSK/Helpers.cs b/Aaru.Images/CPCDSK/Helpers.cs index e218ce82a..f8fd4e0ba 100644 --- a/Aaru.Images/CPCDSK/Helpers.cs +++ b/Aaru.Images/CPCDSK/Helpers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.Decoders.Floppy; - namespace Aaru.DiscImages; +using Aaru.Decoders.Floppy; + public sealed partial class Cpcdsk { static int SizeCodeToBytes(IBMSectorSizeCode code) diff --git a/Aaru.Images/CPCDSK/Identify.cs b/Aaru.Images/CPCDSK/Identify.cs index dc9c1df8a..590d6c402 100644 --- a/Aaru.Images/CPCDSK/Identify.cs +++ b/Aaru.Images/CPCDSK/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class Cpcdsk { /// @@ -49,17 +49,15 @@ public sealed partial class Cpcdsk if(stream.Length < 512) return false; - byte[] headerB = new byte[256]; + var headerB = new byte[256]; stream.Read(headerB, 0, 256); int pos; for(pos = 0; pos < 254; pos++) - { if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break; - } if(pos >= 254) return false; diff --git a/Aaru.Images/CPCDSK/Properties.cs b/Aaru.Images/CPCDSK/Properties.cs index 6ee901312..60dba683d 100644 --- a/Aaru.Images/CPCDSK/Properties.cs +++ b/Aaru.Images/CPCDSK/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Cpcdsk { /// @@ -44,7 +44,7 @@ public sealed partial class Cpcdsk /// public string Name => "CPCEMU Disk-File and Extended CPC Disk-File"; /// - public Guid Id => new Guid("724B16CC-ADB9-492E-BA07-CAEEC1012B16"); + public Guid Id => new("724B16CC-ADB9-492E-BA07-CAEEC1012B16"); /// public string Format => _extended ? "CPCEMU Extended disk image" : "CPCEMU disk image"; /// diff --git a/Aaru.Images/CPCDSK/Read.cs b/Aaru.Images/CPCDSK/Read.cs index 8ae6bf690..032a03044 100644 --- a/Aaru.Images/CPCDSK/Read.cs +++ b/Aaru.Images/CPCDSK/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Decoders.Floppy; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Cpcdsk { /// @@ -56,17 +56,15 @@ public sealed partial class Cpcdsk if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] headerB = new byte[256]; + var headerB = new byte[256]; stream.Read(headerB, 0, 256); int pos; for(pos = 0; pos < 254; pos++) - { if(headerB[pos] == 0x0D && headerB[pos + 1] == 0x0A) break; - } if(pos >= 254) return ErrorNumber.InvalidArgument; @@ -88,8 +86,7 @@ public sealed partial class Cpcdsk AaruConsole.DebugWriteLine("CPCDSK plugin", "magic = \"{0}\"", magic); - AaruConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"", - StringHandlers.CToString(header.magic)); + AaruConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"", StringHandlers.CToString(header.magic)); AaruConsole.DebugWriteLine("CPCDSK plugin", "header.creator = \"{0}\"", StringHandlers.CToString(header.creator)); @@ -100,34 +97,34 @@ public sealed partial class Cpcdsk if(!_extended) AaruConsole.DebugWriteLine("CPCDSK plugin", "header.tracksize = {0}", header.tracksize); else - for(int i = 0; i < header.tracks; i++) + for(var i = 0; i < header.tracks; i++) { - for(int j = 0; j < header.sides; j++) + for(var j = 0; j < header.sides; j++) AaruConsole.DebugWriteLine("CPCDSK plugin", "Track {0} Side {1} size = {2}", i, j, - header.tracksizeTable[(i * header.sides) + j] * 256); + header.tracksizeTable[i * header.sides + j] * 256); } ulong currentSector = 0; _sectors = new Dictionary(); _addressMarks = new Dictionary(); ulong readtracks = 0; - bool allTracksSameSize = true; + var allTracksSameSize = true; ulong sectorsPerTrack = 0; // Seek to first track descriptor stream.Seek(256, SeekOrigin.Begin); - for(int i = 0; i < header.tracks; i++) + for(var i = 0; i < header.tracks; i++) { - for(int j = 0; j < header.sides; j++) + for(var j = 0; j < header.sides; j++) { // Track not stored in image - if(_extended && header.tracksizeTable[(i * header.sides) + j] == 0) + if(_extended && header.tracksizeTable[i * header.sides + j] == 0) continue; long trackPos = stream.Position; - byte[] trackB = new byte[256]; + var trackB = new byte[256]; stream.Read(trackB, 0, 256); TrackInfo trackInfo = Marshal.ByteArrayToStructureLittleEndian(trackB); @@ -145,28 +142,26 @@ public sealed partial class Cpcdsk AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].bps = {0}", SizeCodeToBytes(trackInfo.bps), i, j); - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].dataRate = {0}", trackInfo.dataRate, - i, j); - - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].filler = 0x{0:X2}", - trackInfo.filler, i, j); - - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].gap3 = 0x{0:X2}", trackInfo.gap3, i, + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].dataRate = {0}", trackInfo.dataRate, i, j); - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].padding = {0}", trackInfo.padding, - i, j); + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].filler = 0x{0:X2}", trackInfo.filler, i, + j); + + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].gap3 = 0x{0:X2}", trackInfo.gap3, i, j); + + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].padding = {0}", trackInfo.padding, i, + j); AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].recordingMode = {0}", trackInfo.recordingMode, i, j); - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].sectors = {0}", trackInfo.sectors, - i, j); + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].sectors = {0}", trackInfo.sectors, i, + j); AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].side = {0}", trackInfo.side, i, j); - AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].track = {0}", trackInfo.track, i, - j); + AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].track = {0}", trackInfo.track, i, j); if(trackInfo.sectors != sectorsPerTrack) if(sectorsPerTrack == 0) @@ -177,7 +172,7 @@ public sealed partial class Cpcdsk Dictionary thisTrackSectors = new(); Dictionary thisTrackAddressMarks = new(); - for(int k = 1; k <= trackInfo.sectors; k++) + for(var k = 1; k <= trackInfo.sectors; k++) { AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].sector[{3}].id = 0x{0:X2}", trackInfo.sectorsInfo[k - 1].id, i, j, k); @@ -203,25 +198,25 @@ public sealed partial class Cpcdsk int sectLen = _extended ? trackInfo.sectorsInfo[k - 1].len : SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size); - byte[] sector = new byte[sectLen]; + var sector = new byte[sectLen]; stream.Read(sector, 0, sectLen); if(sectLen < SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)) { - byte[] temp = new byte[SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)]; + var temp = new byte[SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)]; Array.Copy(sector, 0, temp, 0, sector.Length); sector = temp; } else if(sectLen > SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)) { - byte[] temp = new byte[SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)]; + var temp = new byte[SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size)]; Array.Copy(sector, 0, temp, 0, temp.Length); sector = temp; } thisTrackSectors[(trackInfo.sectorsInfo[k - 1].id & 0x3F) - 1] = sector; - byte[] amForCrc = new byte[8]; + var amForCrc = new byte[8]; amForCrc[0] = 0xA1; amForCrc[1] = 0xA1; amForCrc[2] = 0xA1; @@ -233,7 +228,7 @@ public sealed partial class Cpcdsk CRC16IBMContext.Data(amForCrc, 8, out byte[] amCrc); - byte[] addressMark = new byte[22]; + var addressMark = new byte[22]; Array.Copy(amForCrc, 0, addressMark, 12, 8); Array.Copy(amCrc, 0, addressMark, 20, 2); @@ -254,8 +249,8 @@ public sealed partial class Cpcdsk if(_extended) { - stream.Seek(header.tracksizeTable[(i * header.sides) + j] * 256, SeekOrigin.Current); - _imageInfo.ImageSize += (ulong)(header.tracksizeTable[(i * header.sides) + j] * 256) - 256; + stream.Seek(header.tracksizeTable[i * header.sides + j] * 256, SeekOrigin.Current); + _imageInfo.ImageSize += (ulong)(header.tracksizeTable[i * header.sides + j] * 256) - 256; } else { @@ -327,8 +322,7 @@ public sealed partial class Cpcdsk if(tag != SectorTagType.FloppyAddressMark) return ErrorNumber.NotSupported; - return _addressMarks.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError - : ErrorNumber.SectorNotFound; + return _addressMarks.TryGetValue(sectorAddress, out buffer) ? ErrorNumber.NoError : ErrorNumber.SectorNotFound; } /// diff --git a/Aaru.Images/CPCDSK/Structs.cs b/Aaru.Images/CPCDSK/Structs.cs index 26805f514..79f428c31 100644 --- a/Aaru.Images/CPCDSK/Structs.cs +++ b/Aaru.Images/CPCDSK/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.Decoders.Floppy; -namespace Aaru.DiscImages; - public sealed partial class Cpcdsk { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/CPCDSK/Unsupported.cs b/Aaru.Images/CPCDSK/Unsupported.cs index 747981855..61ffc74d4 100644 --- a/Aaru.Images/CPCDSK/Unsupported.cs +++ b/Aaru.Images/CPCDSK/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Cpcdsk { /// diff --git a/Aaru.Images/CisCopy/CisCopy.cs b/Aaru.Images/CisCopy/CisCopy.cs index 2c7154390..10c898276 100644 --- a/Aaru.Images/CisCopy/CisCopy.cs +++ b/Aaru.Images/CisCopy/CisCopy.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /* This is a very simple format created by a German application called CisCopy, aka CCOPY.EXE, with extension .DCF. * First byte indicates the floppy type, limited to standard formats. * Indeed if the floppy is not DOS formatted, user must choose from the list of supported formats manually. diff --git a/Aaru.Images/CisCopy/Enums.cs b/Aaru.Images/CisCopy/Enums.cs index deadcdfc4..ca0185c6c 100644 --- a/Aaru.Images/CisCopy/Enums.cs +++ b/Aaru.Images/CisCopy/Enums.cs @@ -30,27 +30,35 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + public sealed partial class CisCopy { [SuppressMessage("ReSharper", "InconsistentNaming")] enum DiskType : byte { - MD1DD8 = 1, MD1DD = 2, MD2DD8 = 3, - MD2DD = 4, MF2DD = 5, MD2HD = 6, + MD1DD8 = 1, + MD1DD = 2, + MD2DD8 = 3, + MD2DD = 4, + MF2DD = 5, + MD2HD = 6, MF2HD = 7 } enum Compression : byte { - None = 0, Normal = 1, High = 2 + None = 0, + Normal = 1, + High = 2 } enum TrackType : byte { - Copied = 0x4C, Omitted = 0xFA, OmittedAlternate = 0xFE + Copied = 0x4C, + Omitted = 0xFA, + OmittedAlternate = 0xFE } } \ No newline at end of file diff --git a/Aaru.Images/CisCopy/Identify.cs b/Aaru.Images/CisCopy/Identify.cs index 16ef6b1d7..e59068e4c 100644 --- a/Aaru.Images/CisCopy/Identify.cs +++ b/Aaru.Images/CisCopy/Identify.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class CisCopy { /// @@ -64,10 +64,10 @@ public sealed partial class CisCopy default: return false; } - byte[] trackBytes = new byte[tracks]; + var trackBytes = new byte[tracks]; stream.Read(trackBytes, 0, tracks); - for(int i = 0; i < tracks; i++) + for(var i = 0; i < tracks; i++) if(trackBytes[i] != (byte)TrackType.Copied && trackBytes[i] != (byte)TrackType.Omitted && trackBytes[i] != (byte)TrackType.OmittedAlternate) @@ -83,37 +83,37 @@ public sealed partial class CisCopy switch(type) { case DiskType.MD1DD8: - if(stream.Length > (40 * 1 * 8 * 512) + 82) + if(stream.Length > 40 * 1 * 8 * 512 + 82) return false; break; case DiskType.MD1DD: - if(stream.Length > (40 * 1 * 9 * 512) + 82) + if(stream.Length > 40 * 1 * 9 * 512 + 82) return false; break; case DiskType.MD2DD8: - if(stream.Length > (40 * 2 * 8 * 512) + 82) + if(stream.Length > 40 * 2 * 8 * 512 + 82) return false; break; case DiskType.MD2DD: - if(stream.Length > (40 * 2 * 9 * 512) + 82) + if(stream.Length > 40 * 2 * 9 * 512 + 82) return false; break; case DiskType.MF2DD: - if(stream.Length > (80 * 2 * 9 * 512) + 162) + if(stream.Length > 80 * 2 * 9 * 512 + 162) return false; break; case DiskType.MD2HD: - if(stream.Length > (80 * 2 * 15 * 512) + 162) + if(stream.Length > 80 * 2 * 15 * 512 + 162) return false; break; case DiskType.MF2HD: - if(stream.Length > (80 * 2 * 18 * 512) + 162) + 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 29277532e..0ab93c07d 100644 --- a/Aaru.Images/CisCopy/Properties.cs +++ b/Aaru.Images/CisCopy/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CisCopy { /// public string Name => "CisCopy Disk Image (DC-File)"; /// - public Guid Id => new Guid("EDF20CC7-6012-49E2-9E92-663A53E42130"); + public Guid Id => new("EDF20CC7-6012-49E2-9E92-663A53E42130"); /// public string Format => "CisCopy"; /// diff --git a/Aaru.Images/CisCopy/Read.cs b/Aaru.Images/CisCopy/Read.cs index d27d25494..ee5f19195 100644 --- a/Aaru.Images/CisCopy/Read.cs +++ b/Aaru.Images/CisCopy/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class CisCopy { /// @@ -72,7 +72,7 @@ public sealed partial class CisCopy return ErrorNumber.InvalidArgument; } - byte[] trackBytes = new byte[tracks]; + var trackBytes = new byte[tracks]; stream.Read(trackBytes, 0, tracks); var cmpr = (Compression)stream.ReadByte(); @@ -84,7 +84,7 @@ public sealed partial class CisCopy return ErrorNumber.NotImplemented; } - int trackSize = 0; + var trackSize = 0; switch(type) { @@ -109,7 +109,7 @@ public sealed partial class CisCopy break; } - int headStep = 1; + var headStep = 1; if(type == DiskType.MD1DD || type == DiskType.MD1DD8) @@ -117,9 +117,9 @@ public sealed partial class CisCopy var decodedImage = new MemoryStream(); - for(int i = 0; i < tracks; i += headStep) + for(var i = 0; i < tracks; i += headStep) { - byte[] track = new byte[trackSize]; + var track = new byte[trackSize]; if((TrackType)trackBytes[i] == TrackType.Copied) stream.Read(track, 0, trackSize); @@ -207,8 +207,7 @@ public sealed partial class CisCopy } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -223,8 +222,7 @@ public sealed partial class CisCopy buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, - length * _imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, length * _imageInfo.SectorSize); return ErrorNumber.NoError; } diff --git a/Aaru.Images/CisCopy/Unsupported.cs b/Aaru.Images/CisCopy/Unsupported.cs index 4fd2c6ddf..8caeedd95 100644 --- a/Aaru.Images/CisCopy/Unsupported.cs +++ b/Aaru.Images/CisCopy/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class CisCopy { /// diff --git a/Aaru.Images/CisCopy/Write.cs b/Aaru.Images/CisCopy/Write.cs index 9e7386dab..40ac7de6a 100644 --- a/Aaru.Images/CisCopy/Write.cs +++ b/Aaru.Images/CisCopy/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CisCopy { /// @@ -137,13 +137,13 @@ public sealed partial class CisCopy break; } - int headStep = 1; + var headStep = 1; if(diskType == DiskType.MD1DD || diskType == DiskType.MD1DD8) headStep = 2; - for(int i = 0; i < tracks; i += headStep) + for(var i = 0; i < tracks; i += headStep) { _writingStream.WriteByte((byte)TrackType.Copied); diff --git a/Aaru.Images/CloneCD/CloneCD.cs b/Aaru.Images/CloneCD/CloneCD.cs index 3d499b4f8..1dc4480e9 100644 --- a/Aaru.Images/CloneCD/CloneCD.cs +++ b/Aaru.Images/CloneCD/CloneCD.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: CloneCD stores subchannel deinterleaved /// /// Implements reading and writing CloneCD disc images diff --git a/Aaru.Images/CloneCD/Helpers.cs b/Aaru.Images/CloneCD/Helpers.cs index 6afed1573..5585b31d3 100644 --- a/Aaru.Images/CloneCD/Helpers.cs +++ b/Aaru.Images/CloneCD/Helpers.cs @@ -34,9 +34,8 @@ namespace Aaru.DiscImages; public sealed partial class CloneCd { - static ulong GetLba(int minute, int second, int frame) => - (ulong)((minute * 60 * 75) + (second * 75) + frame - 150); + static ulong GetLba(int minute, int second, int frame) => (ulong)(minute * 60 * 75 + second * 75 + frame - 150); static long MsfToLba((byte minute, byte second, byte frame) msf) => - (msf.minute * 60 * 75) + (msf.second * 75) + msf.frame - 150; + msf.minute * 60 * 75 + msf.second * 75 + msf.frame - 150; } \ No newline at end of file diff --git a/Aaru.Images/CloneCD/Identify.cs b/Aaru.Images/CloneCD/Identify.cs index 2052421ca..86843c269 100644 --- a/Aaru.Images/CloneCD/Identify.cs +++ b/Aaru.Images/CloneCD/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class CloneCd { /// @@ -48,14 +48,14 @@ public sealed partial class CloneCd try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - byte[] testArray = new byte[512]; + var testArray = new byte[512]; imageFilter.GetDataForkStream().Read(testArray, 0, 512); imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); // Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin - bool twoConsecutiveNulls = false; + var twoConsecutiveNulls = false; - for(int i = 0; i < 512; i++) + for(var i = 0; i < 512; i++) { if(i >= imageFilter.GetDataForkStream().Length) break; diff --git a/Aaru.Images/CloneCD/Properties.cs b/Aaru.Images/CloneCD/Properties.cs index f7ededa94..633efd232 100644 --- a/Aaru.Images/CloneCD/Properties.cs +++ b/Aaru.Images/CloneCD/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CloneCd { /// @@ -60,7 +60,7 @@ public sealed partial class CloneCd /// public string Name => "CloneCD"; /// - public Guid Id => new Guid("EE9C2975-2E79-427A-8EE9-F86F19165784"); + public Guid Id => new("EE9C2975-2E79-427A-8EE9-F86F19165784"); /// public string Format => "CloneCD"; /// @@ -83,20 +83,20 @@ public sealed partial class CloneCd /// public IEnumerable SupportedSectorTags => new[] { - SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, - SectorTagType.CdSectorEdc, SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, - SectorTagType.CdSectorSync, SectorTagType.CdTrackFlags, SectorTagType.CdSectorSubchannel + SectorTagType.CdSectorEcc, SectorTagType.CdSectorEccP, SectorTagType.CdSectorEccQ, SectorTagType.CdSectorEdc, + SectorTagType.CdSectorHeader, SectorTagType.CdSectorSubHeader, SectorTagType.CdSectorSync, + SectorTagType.CdTrackFlags, SectorTagType.CdSectorSubchannel }; /// public IEnumerable SupportedMediaTypes => new[] { - MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, - MediaType.CDMRW, MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, - MediaType.CDV, MediaType.DTSCD, MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, - MediaType.SuperCDROM2, MediaType.SVCD, MediaType.SATURNCD, MediaType.ThreeDO, MediaType.VCD, - MediaType.VCDHD, MediaType.NeoGeoCD, MediaType.PCFX, MediaType.CDTV, MediaType.CD32, MediaType.Nuon, - MediaType.Playdia, MediaType.Pippin, MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, - MediaType.VideoNowColor, MediaType.VideoNowXp, MediaType.CVD, MediaType.PCD + MediaType.CD, MediaType.CDDA, MediaType.CDEG, MediaType.CDG, MediaType.CDI, MediaType.CDMIDI, MediaType.CDMRW, + MediaType.CDPLUS, MediaType.CDR, MediaType.CDROM, MediaType.CDROMXA, MediaType.CDRW, MediaType.CDV, + MediaType.DTSCD, MediaType.JaguarCD, MediaType.MEGACD, MediaType.PS1CD, MediaType.PS2CD, MediaType.SuperCDROM2, + MediaType.SVCD, MediaType.SATURNCD, MediaType.ThreeDO, MediaType.VCD, MediaType.VCDHD, MediaType.NeoGeoCD, + MediaType.PCFX, MediaType.CDTV, MediaType.CD32, MediaType.Nuon, MediaType.Playdia, MediaType.Pippin, + MediaType.FMTOWNS, MediaType.MilCD, MediaType.VideoNow, MediaType.VideoNowColor, MediaType.VideoNowXp, + MediaType.CVD, MediaType.PCD }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/CloneCD/Read.cs b/Aaru.Images/CloneCD/Read.cs index ce53a9673..c4a8f6755 100644 --- a/Aaru.Images/CloneCD/Read.cs +++ b/Aaru.Images/CloneCD/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Decoders.CD; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class CloneCd { /// @@ -59,7 +59,7 @@ public sealed partial class CloneCd { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); _cueStream = new StreamReader(imageFilter.GetDataForkStream()); - int lineNumber = 0; + var lineNumber = 0; var ccdIdRegex = new Regex(CCD_IDENTIFIER); var discIdRegex = new Regex(DISC_IDENTIFIER); @@ -94,12 +94,12 @@ public sealed partial class CloneCd var trkModeRegex = new Regex(TRACK_MODE); var trkIndexRegex = new Regex(TRACK_INDEX); - bool inCcd = false; - bool inDisk = false; - bool inSession = false; - bool inEntry = false; - bool inTrack = false; - bool inCdText = false; + var inCcd = false; + var inDisk = false; + var inSession = false; + var inEntry = false; + var inTrack = false; + var inCdText = false; var cdtMs = new MemoryStream(); int minSession = int.MaxValue; int maxSession = int.MinValue; @@ -194,8 +194,7 @@ public sealed partial class CloneCd Match discCatMatch = discCatRegex.Match(line); if(discEntMatch.Success) - AaruConsole.DebugWriteLine("CloneCD plugin", "Found TocEntries at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CloneCD plugin", "Found TocEntries at line {0}", lineNumber); else if(discSessMatch.Success) AaruConsole.DebugWriteLine("CloneCD plugin", "Found Sessions at line {0}", lineNumber); else if(discScrMatch.Success) @@ -206,8 +205,7 @@ public sealed partial class CloneCd _scrambled |= discScrMatch.Groups["value"].Value == "1"; } else if(cdtLenMatch.Success) - AaruConsole.DebugWriteLine("CloneCD plugin", "Found CDTextLength at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CloneCD plugin", "Found CDTextLength at line {0}", lineNumber); else if(discCatMatch.Success) { AaruConsole.DebugWriteLine("CloneCD plugin", "Found Catalog at line {0}", lineNumber); @@ -226,8 +224,7 @@ public sealed partial class CloneCd lineNumber); else if(cdtEntMatch.Success) { - AaruConsole.DebugWriteLine("CloneCD plugin", "Found CD-Text Entry at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CloneCD plugin", "Found CD-Text Entry at line {0}", lineNumber); string[] bytes = cdtEntMatch.Groups["value"].Value.Split(new[] { @@ -246,11 +243,9 @@ public sealed partial class CloneCd Match sessSubcMatch = sessSubcRegex.Match(line); if(sessPregMatch.Success) - AaruConsole.DebugWriteLine("CloneCD plugin", "Found PreGapMode at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CloneCD plugin", "Found PreGapMode at line {0}", lineNumber); else if(sessSubcMatch.Success) - AaruConsole.DebugWriteLine("CloneCD plugin", "Found PreGapSubC at line {0}", - lineNumber); + AaruConsole.DebugWriteLine("CloneCD plugin", "Found PreGapSubC at line {0}", lineNumber); } else if(inEntry) { @@ -353,8 +348,8 @@ public sealed partial class CloneCd else if(trkIndexMatch.Success && currentTrackEntry > 0) { - byte indexNo = Convert.ToByte(trkIndexMatch.Groups["index"].Value, 10); - int indexLba = Convert.ToInt32(trkIndexMatch.Groups["lba"].Value, 10); + var indexNo = Convert.ToByte(trkIndexMatch.Groups["index"].Value, 10); + var indexLba = Convert.ToInt32(trkIndexMatch.Groups["lba"].Value, 10); if(!trackIndexes.TryGetValue(currentTrackEntry, out _)) trackIndexes[currentTrackEntry] = new Dictionary(); @@ -379,7 +374,7 @@ public sealed partial class CloneCd toc.TrackDescriptors = entries.ToArray(); toc.LastCompleteSession = (byte)maxSession; toc.FirstCompleteSession = (byte)minSession; - toc.DataLength = (ushort)((entries.Count * 11) + 2); + toc.DataLength = (ushort)(entries.Count * 11 + 2); var tocMs = new MemoryStream(); tocMs.WriteByte(toc.FirstCompleteSession); tocMs.WriteByte(toc.LastCompleteSession); @@ -418,9 +413,9 @@ public sealed partial class CloneCd filtersList = new FiltersList(); _subFilter = filtersList.GetFilter(subFile); - int curSessionNo = 0; - var currentTrack = new Track(); - bool firstTrackInSession = true; + var curSessionNo = 0; + var currentTrack = new Track(); + var firstTrackInSession = true; Tracks = new List(); ulong leadOutStart = 0; @@ -561,7 +556,7 @@ public sealed partial class CloneCd break; case 6: { - uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); + var id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); AaruConsole.DebugWriteLine("CloneCD plugin", "Disc ID: {0:X6}", id & 0x00FFFFFF); _imageInfo.MediaSerialNumber = $"{id & 0x00FFFFFF:X6}"; @@ -613,30 +608,27 @@ public sealed partial class CloneCd if(trackModes.TryGetValue((byte)tmpTrack.Sequence, out int trackMode)) tmpTrack.Type = trackMode switch - { - 0 => TrackType.Audio, - 1 => TrackType.CdMode1, - 2 => TrackType.CdMode2Formless, - _ => TrackType.Data - }; + { + 0 => TrackType.Audio, + 1 => TrackType.CdMode1, + 2 => TrackType.CdMode2Formless, + _ => TrackType.Data + }; 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)) // Untested as of 20210711 tmpTrack.Indexes[index] = value; - } if(tmpTrack.Type == TrackType.Data) - { - for(int s = 225; s < 750; s++) + for(var s = 225; s < 750; s++) { - byte[] syncTest = new byte[12]; - byte[] sectTest = new byte[2352]; + var syncTest = new byte[12]; + var sectTest = new byte[2352]; - long pos = (long)tmpTrack.FileOffset + (s * 2352); + long pos = (long)tmpTrack.FileOffset + s * 2352; if(pos >= _dataStream.Length + 2352 || s >= (int)(tmpTrack.EndSector - tmpTrack.StartSector)) @@ -684,9 +676,9 @@ public sealed partial class CloneCd if(sectTest[15] != 2) continue; - byte[] subHdr1 = new byte[4]; - byte[] subHdr2 = new byte[4]; - byte[] empHdr = new byte[4]; + var subHdr1 = new byte[4]; + var subHdr2 = new byte[4]; + var empHdr = new byte[4]; Array.Copy(sectTest, 16, subHdr1, 0, 4); Array.Copy(sectTest, 20, subHdr2, 0, 4); @@ -761,7 +753,6 @@ public sealed partial class CloneCd break; } - } else { if(_imageInfo.SectorSize < 2352) @@ -839,13 +830,13 @@ public sealed partial class CloneCd Sessions.Add(currentSession); - bool data = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; - for(int i = 0; i < Tracks.Count; i++) + for(var i = 0; i < Tracks.Count; i++) { // First track is audio firstAudio |= i == 0 && Tracks[i].Type == TrackType.Audio; @@ -881,7 +872,7 @@ public sealed partial class CloneCd Sessions.Count > 1 && mode2) _imageInfo.MediaType = MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = MediaType.CDROM; @@ -928,8 +919,7 @@ public sealed partial class CloneCd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -995,7 +985,7 @@ public sealed partial class CloneCd uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.Type) { @@ -1031,7 +1021,7 @@ public sealed partial class CloneCd buffer = new byte[sectorSize * length]; - _dataStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * 2352), SeekOrigin.Begin); if(mode2) { @@ -1039,9 +1029,9 @@ public sealed partial class CloneCd _dataStream.Read(buffer, 0, buffer.Length); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, sectorSize * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1053,9 +1043,9 @@ public sealed partial class CloneCd sectorSkip == 0) _dataStream.Read(buffer, 0, buffer.Length); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; _dataStream.Seek(sectorOffset, SeekOrigin.Current); _dataStream.Read(sector, 0, sector.Length); _dataStream.Seek(sectorSkip, SeekOrigin.Current); @@ -1106,7 +1096,7 @@ public sealed partial class CloneCd return ErrorNumber.NoError; case SectorTagType.CdSectorSubchannel: buffer = new byte[96 * length]; - _subStream.Seek((long)(aaruTrack.SubchannelOffset + (sectorAddress * 96)), SeekOrigin.Begin); + _subStream.Seek((long)(aaruTrack.SubchannelOffset + sectorAddress * 96), SeekOrigin.Begin); _subStream.Read(buffer, 0, buffer.Length); buffer = Subchannel.Interleave(buffer); @@ -1318,15 +1308,15 @@ public sealed partial class CloneCd buffer = new byte[sectorSize * length]; - _dataStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * 2352), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) _dataStream.Read(buffer, 0, buffer.Length); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; _dataStream.Seek(sectorOffset, SeekOrigin.Current); _dataStream.Read(sector, 0, sector.Length); _dataStream.Seek(sectorSkip, SeekOrigin.Current); @@ -1372,7 +1362,7 @@ public sealed partial class CloneCd buffer = new byte[2352 * length]; - _dataStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * 2352), SeekOrigin.Begin); _dataStream.Read(buffer, 0, buffer.Length); return ErrorNumber.NoError; diff --git a/Aaru.Images/CloneCD/Verify.cs b/Aaru.Images/CloneCD/Verify.cs index b50ef9440..49a257fe2 100644 --- a/Aaru.Images/CloneCD/Verify.cs +++ b/Aaru.Images/CloneCD/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class CloneCd { /// @@ -58,10 +58,10 @@ public sealed partial class CloneCd if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class CloneCd if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/CloneCD/Write.cs b/Aaru.Images/CloneCD/Write.cs index 7c0e4c5a4..910cd3b43 100644 --- a/Aaru.Images/CloneCD/Write.cs +++ b/Aaru.Images/CloneCD/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class CloneCd { /// @@ -67,8 +67,7 @@ public sealed partial class CloneCd try { - _writingBaseName = - Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); @@ -161,8 +160,7 @@ public sealed partial class CloneCd return false; } - Track track = - Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -179,7 +177,7 @@ public sealed partial class CloneCd } _dataStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); _dataStream.Write(data, 0, data.Length); @@ -197,8 +195,7 @@ public sealed partial class CloneCd return false; } - Track track = - Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -222,7 +219,7 @@ public sealed partial class CloneCd } _dataStream. - Seek((long)(track.FileOffset + ((sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector)), + Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * (ulong)track.RawBytesPerSector), SeekOrigin.Begin); _dataStream.Write(data, 0, data.Length); @@ -276,8 +273,7 @@ public sealed partial class CloneCd newTrack.FileOffset = currentDataOffset; newTrack.SubchannelOffset = currentSubchannelOffset; - currentDataOffset += (ulong)newTrack.RawBytesPerSector * - (newTrack.EndSector - newTrack.StartSector + 1); + currentDataOffset += (ulong)newTrack.RawBytesPerSector * (newTrack.EndSector - newTrack.StartSector + 1); currentSubchannelOffset += subchannelSize * (newTrack.EndSector - newTrack.StartSector + 1); @@ -309,7 +305,7 @@ public sealed partial class CloneCd // Easy, just decode the real toc if(_fullToc != null) { - byte[] tmp = new byte[_fullToc.Length + 2]; + var tmp = new byte[_fullToc.Length + 2]; Array.Copy(BigEndianBitConverter.GetBytes((ushort)_fullToc.Length), 0, tmp, 0, 2); Array.Copy(_fullToc, 0, tmp, 2, _fullToc.Length); nullableToc = FullTOC.Decode(tmp); @@ -329,7 +325,7 @@ public sealed partial class CloneCd if(!string.IsNullOrEmpty(_catalog)) _descriptorStream.WriteLine("CATALOG={0}", _catalog); - for(int i = 1; i <= toc.LastCompleteSession; i++) + for(var i = 1; i <= toc.LastCompleteSession; i++) { _descriptorStream.WriteLine("[Session {0}]", i); @@ -365,7 +361,7 @@ public sealed partial class CloneCd _descriptorStream.WriteLine("PreGapSubC=0"); } - for(int i = 0; i < toc.TrackDescriptors.Length; i++) + for(var i = 0; i < toc.TrackDescriptors.Length; i++) { long alba = MsfToLba((toc.TrackDescriptors[i].Min, toc.TrackDescriptors[i].Sec, toc.TrackDescriptors[i].Frame)); @@ -430,8 +426,7 @@ public sealed partial class CloneCd return false; } - Track track = - Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -485,7 +480,7 @@ public sealed partial class CloneCd return false; } - _subStream.Seek((long)(track.SubchannelOffset + ((sectorAddress - track.StartSector) * 96)), + _subStream.Seek((long)(track.SubchannelOffset + (sectorAddress - track.StartSector) * 96), SeekOrigin.Begin); _subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); @@ -509,8 +504,7 @@ public sealed partial class CloneCd return false; } - Track track = - Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); + Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector); if(track is null) { @@ -553,7 +547,7 @@ public sealed partial class CloneCd return false; } - _subStream.Seek((long)(track.SubchannelOffset + ((sectorAddress - track.StartSector) * 96)), + _subStream.Seek((long)(track.SubchannelOffset + (sectorAddress - track.StartSector) * 96), SeekOrigin.Begin); _subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); diff --git a/Aaru.Images/CopyQM/Constants.cs b/Aaru.Images/CopyQM/Constants.cs index 60597ace0..e7f2074d0 100644 --- a/Aaru.Images/CopyQM/Constants.cs +++ b/Aaru.Images/CopyQM/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class CopyQm { diff --git a/Aaru.Images/CopyQM/CopyQM.cs b/Aaru.Images/CopyQM/CopyQM.cs index 83afea61a..0bc31921a 100644 --- a/Aaru.Images/CopyQM/CopyQM.cs +++ b/Aaru.Images/CopyQM/CopyQM.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading CopyQM disk images public sealed partial class CopyQm : IMediaImage, IVerifiableImage { diff --git a/Aaru.Images/CopyQM/Identify.cs b/Aaru.Images/CopyQM/Identify.cs index 397032542..4522021c7 100644 --- a/Aaru.Images/CopyQM/Identify.cs +++ b/Aaru.Images/CopyQM/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class CopyQm { /// @@ -47,10 +47,10 @@ public sealed partial class CopyQm if(stream.Length < 133) return false; - byte[] hdr = new byte[133]; + var hdr = new byte[133]; stream.Read(hdr, 0, 133); - ushort magic = BitConverter.ToUInt16(hdr, 0); + var magic = BitConverter.ToUInt16(hdr, 0); return magic == COPYQM_MAGIC && hdr[0x02] == COPYQM_MARK && 133 + hdr[0x6F] < stream.Length; } diff --git a/Aaru.Images/CopyQM/Properties.cs b/Aaru.Images/CopyQM/Properties.cs index 87ca5540b..70b786e08 100644 --- a/Aaru.Images/CopyQM/Properties.cs +++ b/Aaru.Images/CopyQM/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CopyQm { /// @@ -44,7 +44,7 @@ public sealed partial class CopyQm /// public string Name => "Sydex CopyQM"; /// - public Guid Id => new Guid("147E927D-3A92-4E0C-82CD-142F5A4FA76D"); + public Guid Id => new("147E927D-3A92-4E0C-82CD-142F5A4FA76D"); /// public string Format => "Sydex CopyQM"; /// diff --git a/Aaru.Images/CopyQM/Read.cs b/Aaru.Images/CopyQM/Read.cs index f20d347b6..64d360f63 100644 --- a/Aaru.Images/CopyQM/Read.cs +++ b/Aaru.Images/CopyQM/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class CopyQm { /// @@ -48,7 +48,7 @@ public sealed partial class CopyQm Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] hdr = new byte[133]; + var hdr = new byte[133]; stream.Read(hdr, 0, 133); _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); @@ -83,7 +83,7 @@ public sealed partial class CopyQm AaruConsole.DebugWriteLine("CopyQM plugin", "header.skew = {0}", _header.skew); AaruConsole.DebugWriteLine("CopyQM plugin", "header.drive = {0}", _header.drive); - byte[] cmt = new byte[_header.commentLength]; + var cmt = new byte[_header.commentLength]; stream.Read(cmt, 0, _header.commentLength); _imageInfo.Comments = StringHandlers.CToString(cmt); _decodedImage = new MemoryStream(); @@ -92,20 +92,20 @@ public sealed partial class CopyQm while(stream.Position + 2 < stream.Length) { - byte[] runLengthBytes = new byte[2]; + var runLengthBytes = new byte[2]; if(stream.Read(runLengthBytes, 0, 2) != 2) break; - short runLength = BitConverter.ToInt16(runLengthBytes, 0); + var runLength = BitConverter.ToInt16(runLengthBytes, 0); if(runLength < 0) { - byte repeatedByte = (byte)stream.ReadByte(); - byte[] repeatedArray = new byte[runLength * -1]; + var repeatedByte = (byte)stream.ReadByte(); + var repeatedArray = new byte[runLength * -1]; ArrayHelpers.ArrayFill(repeatedArray, repeatedByte); - for(int i = 0; i < runLength * -1; i++) + for(var i = 0; i < runLength * -1; i++) { _decodedImage.WriteByte(repeatedByte); @@ -115,31 +115,30 @@ public sealed partial class CopyQm } else if(runLength > 0) { - byte[] nonRepeated = new byte[runLength]; + var nonRepeated = new byte[runLength]; stream.Read(nonRepeated, 0, runLength); _decodedImage.Write(nonRepeated, 0, runLength); foreach(byte c in nonRepeated) - _calculatedDataCrc = - _copyQmCrcTable[(c ^ _calculatedDataCrc) & 0x3F] ^ (_calculatedDataCrc >> 8); + _calculatedDataCrc = _copyQmCrcTable[(c ^ _calculatedDataCrc) & 0x3F] ^ (_calculatedDataCrc >> 8); } } // In case there is omitted data long sectors = _header.sectorsPerTrack * _header.heads * _header.totalCylinders; - long fillingLen = (sectors * _header.sectorSize) - _decodedImage.Length; + long fillingLen = sectors * _header.sectorSize - _decodedImage.Length; if(fillingLen > 0) { - byte[] filling = new byte[fillingLen]; + var filling = new byte[fillingLen]; ArrayHelpers.ArrayFill(filling, (byte)0xF6); _decodedImage.Write(filling, 0, filling.Length); } - int sum = 0; + var sum = 0; - for(int i = 0; i < hdr.Length - 1; i++) + for(var i = 0; i < hdr.Length - 1; i++) sum += hdr[i]; _headerChecksumOk = ((-1 * sum) & 0xFF) == _header.headerChecksum; @@ -159,8 +158,8 @@ public sealed partial class CopyQm _imageInfo.SectorSize = _header.sectorSize; _imageInfo.MediaType = Geometry.GetMediaType((_header.totalCylinders, (byte)_header.heads, - _header.sectorsPerTrack, _header.sectorSize, - MediaEncoding.MFM, false)); + _header.sectorsPerTrack, _header.sectorSize, MediaEncoding.MFM, + false)); switch(_imageInfo.MediaType) { @@ -196,8 +195,7 @@ public sealed partial class CopyQm } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -212,8 +210,7 @@ public sealed partial class CopyQm buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, - length * _imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, length * _imageInfo.SectorSize); return ErrorNumber.NoError; } diff --git a/Aaru.Images/CopyQM/Structs.cs b/Aaru.Images/CopyQM/Structs.cs index 00f098525..385195478 100644 --- a/Aaru.Images/CopyQM/Structs.cs +++ b/Aaru.Images/CopyQM/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class CopyQm { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/CopyQM/Unsupported.cs b/Aaru.Images/CopyQM/Unsupported.cs index b62c7f41b..36a444ed7 100644 --- a/Aaru.Images/CopyQM/Unsupported.cs +++ b/Aaru.Images/CopyQM/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class CopyQm { /// diff --git a/Aaru.Images/CopyTape/CopyTape.cs b/Aaru.Images/CopyTape/CopyTape.cs index 20633ab21..e08fb787a 100644 --- a/Aaru.Images/CopyTape/CopyTape.cs +++ b/Aaru.Images/CopyTape/CopyTape.cs @@ -1,11 +1,11 @@ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing copytape tape images public sealed partial class CopyTape : IWritableTapeImage diff --git a/Aaru.Images/CopyTape/Identify.cs b/Aaru.Images/CopyTape/Identify.cs index 72bd6db30..71561be37 100644 --- a/Aaru.Images/CopyTape/Identify.cs +++ b/Aaru.Images/CopyTape/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class CopyTape { /// @@ -45,7 +45,7 @@ public sealed partial class CopyTape if(imageFilter.DataForkLength <= 16) return false; - byte[] header = new byte[16]; + var header = new byte[16]; Stream strm = imageFilter.GetDataForkStream(); strm.Position = 0; diff --git a/Aaru.Images/CopyTape/Properties.cs b/Aaru.Images/CopyTape/Properties.cs index 899bb5ec0..c4d3c7f84 100644 --- a/Aaru.Images/CopyTape/Properties.cs +++ b/Aaru.Images/CopyTape/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CopyTape { /// @@ -46,7 +46,7 @@ public sealed partial class CopyTape /// public string Name => "CopyTape"; /// - public Guid Id => new Guid("C537D41E-D6A7-4922-9AA9-8E8442D0E340"); + public Guid Id => new("C537D41E-D6A7-4922-9AA9-8E8442D0E340"); /// public string Author => "Natalia Portillo"; /// @@ -71,31 +71,30 @@ public sealed partial class CopyTape /// public IEnumerable SupportedMediaTypes => new[] { - MediaType.UnknownTape, MediaType.ADR2120, MediaType.ADR260, MediaType.ADR30, MediaType.ADR50, - MediaType.AIT1, MediaType.AIT1Turbo, MediaType.AIT2, MediaType.AIT2Turbo, MediaType.AIT3, MediaType.AIT3Ex, - MediaType.AIT3Turbo, MediaType.AIT4, MediaType.AIT5, MediaType.AITETurbo, MediaType.SAIT1, MediaType.SAIT2, - MediaType.Ditto, MediaType.DittoMax, MediaType.DigitalAudioTape, MediaType.DAT160, MediaType.DAT320, - MediaType.DAT72, MediaType.DDS1, MediaType.DDS2, MediaType.DDS3, MediaType.DDS4, MediaType.CompactTapeI, - MediaType.CompactTapeII, MediaType.DECtapeII, MediaType.DLTtapeIII, MediaType.DLTtapeIIIxt, - MediaType.DLTtapeIV, MediaType.DLTtapeS4, MediaType.SDLT1, MediaType.SDLT2, MediaType.VStapeI, - MediaType.Exatape15m, MediaType.Exatape22m, MediaType.Exatape22mAME, MediaType.Exatape28m, - MediaType.Exatape40m, MediaType.Exatape45m, MediaType.Exatape54m, MediaType.Exatape75m, - MediaType.Exatape76m, MediaType.Exatape80m, MediaType.Exatape106m, MediaType.Exatape160mXL, - MediaType.Exatape112m, MediaType.Exatape125m, MediaType.Exatape150m, MediaType.Exatape170m, - MediaType.Exatape225m, MediaType.IBM3470, MediaType.IBM3480, MediaType.IBM3490, MediaType.IBM3490E, - MediaType.IBM3592, MediaType.LTO, MediaType.LTO2, MediaType.LTO3, MediaType.LTO3WORM, MediaType.LTO4, - MediaType.LTO4WORM, MediaType.LTO5, MediaType.LTO5WORM, MediaType.LTO6, MediaType.LTO6WORM, MediaType.LTO7, - MediaType.LTO7WORM, MediaType.MLR1, MediaType.MLR1SL, MediaType.MLR3, MediaType.SLR1, MediaType.SLR2, - MediaType.SLR3, MediaType.SLR32, MediaType.SLR32SL, MediaType.SLR4, MediaType.SLR5, MediaType.SLR5SL, - MediaType.SLR6, MediaType.SLRtape7, MediaType.SLRtape7SL, MediaType.SLRtape24, MediaType.SLRtape24SL, - MediaType.SLRtape40, MediaType.SLRtape50, MediaType.SLRtape60, MediaType.SLRtape75, MediaType.SLRtape100, - MediaType.SLRtape140, MediaType.QIC11, MediaType.QIC120, MediaType.QIC1350, MediaType.QIC150, - MediaType.QIC24, MediaType.QIC3010, MediaType.QIC3020, MediaType.QIC3080, MediaType.QIC3095, + MediaType.UnknownTape, MediaType.ADR2120, MediaType.ADR260, MediaType.ADR30, MediaType.ADR50, MediaType.AIT1, + MediaType.AIT1Turbo, MediaType.AIT2, MediaType.AIT2Turbo, MediaType.AIT3, MediaType.AIT3Ex, MediaType.AIT3Turbo, + MediaType.AIT4, MediaType.AIT5, MediaType.AITETurbo, MediaType.SAIT1, MediaType.SAIT2, MediaType.Ditto, + MediaType.DittoMax, MediaType.DigitalAudioTape, MediaType.DAT160, MediaType.DAT320, MediaType.DAT72, + MediaType.DDS1, MediaType.DDS2, MediaType.DDS3, MediaType.DDS4, MediaType.CompactTapeI, MediaType.CompactTapeII, + MediaType.DECtapeII, MediaType.DLTtapeIII, MediaType.DLTtapeIIIxt, MediaType.DLTtapeIV, MediaType.DLTtapeS4, + MediaType.SDLT1, MediaType.SDLT2, MediaType.VStapeI, MediaType.Exatape15m, MediaType.Exatape22m, + MediaType.Exatape22mAME, MediaType.Exatape28m, MediaType.Exatape40m, MediaType.Exatape45m, MediaType.Exatape54m, + MediaType.Exatape75m, MediaType.Exatape76m, MediaType.Exatape80m, MediaType.Exatape106m, + MediaType.Exatape160mXL, MediaType.Exatape112m, MediaType.Exatape125m, MediaType.Exatape150m, + MediaType.Exatape170m, MediaType.Exatape225m, MediaType.IBM3470, MediaType.IBM3480, MediaType.IBM3490, + MediaType.IBM3490E, MediaType.IBM3592, MediaType.LTO, MediaType.LTO2, MediaType.LTO3, MediaType.LTO3WORM, + MediaType.LTO4, MediaType.LTO4WORM, MediaType.LTO5, MediaType.LTO5WORM, MediaType.LTO6, MediaType.LTO6WORM, + MediaType.LTO7, MediaType.LTO7WORM, MediaType.MLR1, MediaType.MLR1SL, MediaType.MLR3, MediaType.SLR1, + MediaType.SLR2, MediaType.SLR3, MediaType.SLR32, MediaType.SLR32SL, MediaType.SLR4, MediaType.SLR5, + MediaType.SLR5SL, MediaType.SLR6, MediaType.SLRtape7, MediaType.SLRtape7SL, MediaType.SLRtape24, + MediaType.SLRtape24SL, MediaType.SLRtape40, MediaType.SLRtape50, MediaType.SLRtape60, MediaType.SLRtape75, + MediaType.SLRtape100, MediaType.SLRtape140, MediaType.QIC11, MediaType.QIC120, MediaType.QIC1350, + MediaType.QIC150, MediaType.QIC24, MediaType.QIC3010, MediaType.QIC3020, MediaType.QIC3080, MediaType.QIC3095, MediaType.QIC320, MediaType.QIC40, MediaType.QIC525, MediaType.QIC80, MediaType.STK4480, MediaType.STK4490, MediaType.STK9490, MediaType.T9840A, MediaType.T9840B, MediaType.T9840C, MediaType.T9840D, MediaType.T9940A, - MediaType.T9940B, MediaType.T10000A, MediaType.T10000B, MediaType.T10000C, MediaType.T10000D, - MediaType.Travan, MediaType.Travan1Ex, MediaType.Travan3, MediaType.Travan3Ex, MediaType.Travan4, - MediaType.Travan5, MediaType.Travan7, MediaType.VXA1, MediaType.VXA2, MediaType.VXA3 + MediaType.T9940B, MediaType.T10000A, MediaType.T10000B, MediaType.T10000C, MediaType.T10000D, MediaType.Travan, + MediaType.Travan1Ex, MediaType.Travan3, MediaType.Travan3Ex, MediaType.Travan4, MediaType.Travan5, + MediaType.Travan7, MediaType.VXA1, MediaType.VXA2, MediaType.VXA3 }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/CopyTape/Read.cs b/Aaru.Images/CopyTape/Read.cs index 25ea56996..c902b3bb2 100644 --- a/Aaru.Images/CopyTape/Read.cs +++ b/Aaru.Images/CopyTape/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Text; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class CopyTape { /// @@ -59,12 +59,12 @@ public sealed partial class CopyTape _imageStream = imageFilter.GetDataForkStream(); _imageStream.Position = 0; - byte[] header = new byte[9]; - byte[] blockHeader = new byte[16]; - ulong currentBlock = 0; - uint currentFile = 0; - ulong currentFileStart = 0; - bool inFile = false; + var header = new byte[9]; + var blockHeader = new byte[16]; + ulong currentBlock = 0; + uint currentFile = 0; + ulong currentFileStart = 0; + var inFile = false; Files = new List(); @@ -198,8 +198,8 @@ public sealed partial class CopyTape _imageStream.Position = _blockPositionCache[sectorAddress]; - byte[] blockHeader = new byte[16]; - var blockRx = new Regex(BLOCK_REGEX); + var blockHeader = new byte[16]; + var blockRx = new Regex(BLOCK_REGEX); _imageStream.Read(blockHeader, 0, 16); string mark = Encoding.ASCII.GetString(blockHeader); diff --git a/Aaru.Images/CopyTape/Unsupported.cs b/Aaru.Images/CopyTape/Unsupported.cs index 80376452d..1dd226402 100644 --- a/Aaru.Images/CopyTape/Unsupported.cs +++ b/Aaru.Images/CopyTape/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class CopyTape { /// diff --git a/Aaru.Images/CopyTape/Write.cs b/Aaru.Images/CopyTape/Write.cs index 952b46c82..8ac103916 100644 --- a/Aaru.Images/CopyTape/Write.cs +++ b/Aaru.Images/CopyTape/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class CopyTape { FileStream _dataStream; diff --git a/Aaru.Images/D88/Constants.cs b/Aaru.Images/D88/Constants.cs index 694e79745..93327ae66 100644 --- a/Aaru.Images/D88/Constants.cs +++ b/Aaru.Images/D88/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class D88 { diff --git a/Aaru.Images/D88/D88.cs b/Aaru.Images/D88/D88.cs index 693e77725..f90047a46 100644 --- a/Aaru.Images/D88/D88.cs +++ b/Aaru.Images/D88/D88.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // Information from Quasi88's FORMAT.TXT file // Japanese comments copied from there // TODO: Solve media types diff --git a/Aaru.Images/D88/Enums.cs b/Aaru.Images/D88/Enums.cs index 25e295181..12c7478e3 100644 --- a/Aaru.Images/D88/Enums.cs +++ b/Aaru.Images/D88/Enums.cs @@ -30,21 +30,24 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class D88 { enum DiskType : byte { - D2 = 0x00, Dd2 = 0x10, Hd2 = 0x20 + D2 = 0x00, + Dd2 = 0x10, + Hd2 = 0x20 } enum DensityType : byte { - Mfm = 0x00, Fm = 0x40 + Mfm = 0x00, + Fm = 0x40 } /// Status as returned by PC-98 BIOS ステータスは、PC-98x1 のBIOS が返してくるステータスで、 diff --git a/Aaru.Images/D88/Identify.cs b/Aaru.Images/D88/Identify.cs index ead26eb40..c0ebce3ed 100644 --- a/Aaru.Images/D88/Identify.cs +++ b/Aaru.Images/D88/Identify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using System.Text; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class D88 { /// @@ -53,21 +53,19 @@ public sealed partial class D88 if(stream.Length < Marshal.SizeOf
()) return false; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); Header hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); - AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"", - StringHandlers.CToString(hdr.name, shiftjis)); + AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); - AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_type = {0} ({1})", hdr.disk_type, - (byte)hdr.disk_type); + AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_type = {0} ({1})", hdr.disk_type, (byte)hdr.disk_type); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_size = {0}", hdr.disk_size); @@ -82,7 +80,7 @@ public sealed partial class D88 if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false; - int counter = 0; + var counter = 0; foreach(int t in hdr.track_table) { diff --git a/Aaru.Images/D88/Properties.cs b/Aaru.Images/D88/Properties.cs index 94c24d71e..7dd40ee58 100644 --- a/Aaru.Images/D88/Properties.cs +++ b/Aaru.Images/D88/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class D88 { /// public string Name => "D88 Disk Image"; /// - public Guid Id => new Guid("669EDC77-EC41-4720-A88C-49C38CFFBAA0"); + public Guid Id => new("669EDC77-EC41-4720-A88C-49C38CFFBAA0"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/D88/Read.cs b/Aaru.Images/D88/Read.cs index 9553ccfa7..8b5be993f 100644 --- a/Aaru.Images/D88/Read.cs +++ b/Aaru.Images/D88/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Decoders.Floppy; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class D88 { /// @@ -57,20 +57,18 @@ public sealed partial class D88 if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); Header hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); - AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"", - StringHandlers.CToString(hdr.name, shiftjis)); + AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); - AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_type = {0} ({1})", hdr.disk_type, - (byte)hdr.disk_type); + AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_type = {0} ({1})", hdr.disk_type, (byte)hdr.disk_type); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_size = {0}", hdr.disk_size); @@ -85,7 +83,7 @@ public sealed partial class D88 if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return ErrorNumber.InvalidArgument; - int trkCounter = 0; + var trkCounter = 0; foreach(int t in hdr.track_table) { @@ -120,10 +118,10 @@ public sealed partial class D88 short spt = sechdr.spt; IBMSectorSizeCode bps = sechdr.n; - bool allEqual = true; + var allEqual = true; _sectorsData = new List(); - for(int i = 0; i < trkCounter; i++) + for(var i = 0; i < trkCounter; i++) { stream.Seek(hdr.track_table[i], SeekOrigin.Begin); stream.Read(hdrB, 0, hdrB.Length); @@ -385,8 +383,7 @@ public sealed partial class D88 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -401,7 +398,7 @@ public sealed partial class D88 var ms = new MemoryStream(); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) ms.Write(_sectorsData[(int)sectorAddress + i], 0, _sectorsData[(int)sectorAddress + i].Length); buffer = ms.ToArray(); diff --git a/Aaru.Images/D88/Structs.cs b/Aaru.Images/D88/Structs.cs index bc57fd8a7..55fe97c5c 100644 --- a/Aaru.Images/D88/Structs.cs +++ b/Aaru.Images/D88/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.Decoders.Floppy; -namespace Aaru.DiscImages; - public sealed partial class D88 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/D88/Unsupported.cs b/Aaru.Images/D88/Unsupported.cs index f5e852bde..f8e5c1380 100644 --- a/Aaru.Images/D88/Unsupported.cs +++ b/Aaru.Images/D88/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class D88 { /// diff --git a/Aaru.Images/DART/Constants.cs b/Aaru.Images/DART/Constants.cs index c2a1e640f..24eb07722 100644 --- a/Aaru.Images/DART/Constants.cs +++ b/Aaru.Images/DART/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Dart { @@ -73,7 +73,7 @@ public sealed partial class Dart const int TAG_SECTOR_SIZE = 12; const int DATA_SIZE = SECTORS_PER_BLOCK * SECTOR_SIZE; const int TAG_SIZE = SECTORS_PER_BLOCK * TAG_SECTOR_SIZE; - const int BUFFER_SIZE = (SECTORS_PER_BLOCK * SECTOR_SIZE) + (SECTORS_PER_BLOCK * TAG_SECTOR_SIZE); + const int BUFFER_SIZE = SECTORS_PER_BLOCK * SECTOR_SIZE + SECTORS_PER_BLOCK * TAG_SECTOR_SIZE; const string DART_REGEX = @"(?\S+), tag checksum=\$(?[0123456789ABCDEF]{8}), data checksum=\$(?[0123456789ABCDEF]{8})$"; diff --git a/Aaru.Images/DART/DART.cs b/Aaru.Images/DART/DART.cs index 515d30fa2..a48ac7ff3 100644 --- a/Aaru.Images/DART/DART.cs +++ b/Aaru.Images/DART/DART.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading Apple DART disk images public sealed partial class Dart : IMediaImage diff --git a/Aaru.Images/DART/Identify.cs b/Aaru.Images/DART/Identify.cs index 87a273964..e5eb0fb8c 100644 --- a/Aaru.Images/DART/Identify.cs +++ b/Aaru.Images/DART/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Dart { /// @@ -47,7 +47,7 @@ public sealed partial class Dart return false; stream.Seek(0, SeekOrigin.Begin); - byte[] headerB = new byte[Marshal.SizeOf
()]; + var headerB = new byte[Marshal.SizeOf
()]; stream.Read(headerB, 0, Marshal.SizeOf
()); Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); @@ -55,7 +55,7 @@ public sealed partial class Dart if(header.srcCmp > COMPRESS_NONE) return false; - int expectedMaxSize = 84 + (header.srcSize * 2 * 524); + int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { diff --git a/Aaru.Images/DART/Properties.cs b/Aaru.Images/DART/Properties.cs index 4610fa6e5..e6d22fa1f 100644 --- a/Aaru.Images/DART/Properties.cs +++ b/Aaru.Images/DART/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Dart { /// public string Name => "Apple Disk Archival/Retrieval Tool"; /// - public Guid Id => new Guid("B3E06BF8-F98D-4F9B-BBE2-342C373BAF3E"); + public Guid Id => new("B3E06BF8-F98D-4F9B-BBE2-342C373BAF3E"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index 943ea403c..62a16f417 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; @@ -43,8 +45,6 @@ using Claunia.Encoding; using Claunia.RsrcFork; using Version = Resources.Version; -namespace Aaru.DiscImages; - public sealed partial class Dart { /// @@ -56,7 +56,7 @@ public sealed partial class Dart return ErrorNumber.InvalidArgument; stream.Seek(0, SeekOrigin.Begin); - byte[] headerB = new byte[Marshal.SizeOf
()]; + var headerB = new byte[Marshal.SizeOf
()]; stream.Read(headerB, 0, Marshal.SizeOf
()); Header header = Marshal.ByteArrayToStructureBigEndian
(headerB); @@ -64,7 +64,7 @@ public sealed partial class Dart if(header.srcCmp > COMPRESS_NONE) return ErrorNumber.NotSupported; - int expectedMaxSize = 84 + (header.srcSize * 2 * 524); + int expectedMaxSize = 84 + header.srcSize * 2 * 524; switch(header.srcType) { @@ -117,9 +117,9 @@ public sealed partial class Dart else bLength = new short[BLOCK_ARRAY_LEN_LOW]; - for(int i = 0; i < bLength.Length; i++) + for(var i = 0; i < bLength.Length; i++) { - byte[] tmpShort = new byte[2]; + var tmpShort = new byte[2]; stream.Read(tmpShort, 0, 2); bLength[i] = BigEndianBitConverter.ToInt16(tmpShort, 0); } @@ -130,7 +130,7 @@ public sealed partial class Dart foreach(short l in bLength) if(l != 0) { - byte[] buffer = new byte[BUFFER_SIZE]; + var buffer = new byte[BUFFER_SIZE]; if(l == -1) { @@ -323,8 +323,7 @@ public sealed partial class Dart } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -343,8 +342,7 @@ public sealed partial class Dart buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(_dataCache, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, - length * _imageInfo.SectorSize); + Array.Copy(_dataCache, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, length * _imageInfo.SectorSize); return ErrorNumber.NoError; } @@ -407,7 +405,7 @@ public sealed partial class Dart _imageInfo.SectorSize); Array.Copy(tags, i * TAG_SECTOR_SIZE, buffer, - (i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE)) + _imageInfo.SectorSize, TAG_SECTOR_SIZE); + i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE) + _imageInfo.SectorSize, TAG_SECTOR_SIZE); } return ErrorNumber.NoError; diff --git a/Aaru.Images/DART/Structs.cs b/Aaru.Images/DART/Structs.cs index 11ff87456..01636ad3e 100644 --- a/Aaru.Images/DART/Structs.cs +++ b/Aaru.Images/DART/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Dart { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/DART/Unsupported.cs b/Aaru.Images/DART/Unsupported.cs index 05461cf2d..4c8833826 100644 --- a/Aaru.Images/DART/Unsupported.cs +++ b/Aaru.Images/DART/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Dart { /// diff --git a/Aaru.Images/DIM/DIM.cs b/Aaru.Images/DIM/DIM.cs index 1beb612cb..d3c347b8e 100644 --- a/Aaru.Images/DIM/DIM.cs +++ b/Aaru.Images/DIM/DIM.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: What are the real supported floppies for this image format? /// /// Implements reading DIM disk images diff --git a/Aaru.Images/DIM/Enums.cs b/Aaru.Images/DIM/Enums.cs index 430ce8db5..6ba7b99f6 100644 --- a/Aaru.Images/DIM/Enums.cs +++ b/Aaru.Images/DIM/Enums.cs @@ -36,7 +36,11 @@ public sealed partial class Dim { enum DiskType : byte { - Hd2 = 0, Hs2 = 1, Hc2 = 2, - Hde2 = 3, Hq2 = 9, N88 = 17 + Hd2 = 0, + Hs2 = 1, + Hc2 = 2, + Hde2 = 3, + Hq2 = 9, + N88 = 17 } } \ No newline at end of file diff --git a/Aaru.Images/DIM/Identify.cs b/Aaru.Images/DIM/Identify.cs index dc2d0b2a7..786434e9b 100644 --- a/Aaru.Images/DIM/Identify.cs +++ b/Aaru.Images/DIM/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class Dim { /// diff --git a/Aaru.Images/DIM/Properties.cs b/Aaru.Images/DIM/Properties.cs index 4f1b373cf..d07a6a2b6 100644 --- a/Aaru.Images/DIM/Properties.cs +++ b/Aaru.Images/DIM/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Dim { /// diff --git a/Aaru.Images/DIM/Read.cs b/Aaru.Images/DIM/Read.cs index ceb3b6ca1..e55ebcbc7 100644 --- a/Aaru.Images/DIM/Read.cs +++ b/Aaru.Images/DIM/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using System.Text; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Dim { /// @@ -74,8 +74,7 @@ public sealed partial class Dim case DiskType.Hd2: if(diskSize % (2 * 8 * 1024) != 0) { - AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", - diskSize / (2 * 8 * 1024)); + AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", diskSize / (2 * 8 * 1024)); return ErrorNumber.NotSupported; } @@ -107,8 +106,7 @@ public sealed partial class Dim case DiskType.Hc2: if(diskSize % (2 * 15 * 512) != 0) { - AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", - diskSize / (2 * 15 * 512)); + AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", diskSize / (2 * 15 * 512)); return ErrorNumber.NotSupported; } @@ -140,8 +138,7 @@ public sealed partial class Dim case DiskType.Hq2: if(diskSize % (2 * 18 * 512) != 0) { - AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", - diskSize / (2 * 18 * 512)); + AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", diskSize / (2 * 18 * 512)); return ErrorNumber.NotSupported; } @@ -171,8 +168,7 @@ public sealed partial class Dim } else { - AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", - diskSize / (2 * 26 * 256)); + AaruConsole.ErrorWriteLine("DIM shows unknown image with {0} tracks", diskSize / (2 * 26 * 256)); return ErrorNumber.NotSupported; } @@ -241,8 +237,7 @@ public sealed partial class Dim } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -259,7 +254,7 @@ public sealed partial class Dim Stream stream = _dimImageFilter.GetDataForkStream(); - stream.Seek((long)(DATA_OFFSET + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(DATA_OFFSET + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); diff --git a/Aaru.Images/DIM/Unsupported.cs b/Aaru.Images/DIM/Unsupported.cs index 6d9654020..a3a78b80b 100644 --- a/Aaru.Images/DIM/Unsupported.cs +++ b/Aaru.Images/DIM/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Dim { /// diff --git a/Aaru.Images/DiscFerret/DiscFerret.cs b/Aaru.Images/DiscFerret/DiscFerret.cs index 0649ae5ff..d015f9e57 100644 --- a/Aaru.Images/DiscFerret/DiscFerret.cs +++ b/Aaru.Images/DiscFerret/DiscFerret.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading DiscFerret flux images public sealed partial class DiscFerret : IMediaImage, IVerifiableSectorsImage { diff --git a/Aaru.Images/DiscFerret/Identify.cs b/Aaru.Images/DiscFerret/Identify.cs index b4d8a3388..84b2277f5 100644 --- a/Aaru.Images/DiscFerret/Identify.cs +++ b/Aaru.Images/DiscFerret/Identify.cs @@ -30,21 +30,21 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class DiscFerret { /// public bool Identify(IFilter imageFilter) { - byte[] magicB = new byte[4]; + var magicB = new byte[4]; Stream stream = imageFilter.GetDataForkStream(); stream.Read(magicB, 0, 4); - uint magic = BitConverter.ToUInt32(magicB, 0); + var magic = BitConverter.ToUInt32(magicB, 0); return magic == DFI_MAGIC || magic == DFI_MAGIC2; } diff --git a/Aaru.Images/DiscFerret/Properties.cs b/Aaru.Images/DiscFerret/Properties.cs index 56a8f04c6..fb509a033 100644 --- a/Aaru.Images/DiscFerret/Properties.cs +++ b/Aaru.Images/DiscFerret/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DiscFerret { /// public string Name => "DiscFerret"; /// - public Guid Id => new Guid("70EA7B9B-5323-42EB-9B40-8DDA37C5EB4D"); + public Guid Id => new("70EA7B9B-5323-42EB-9B40-8DDA37C5EB4D"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index d92fb8d32..f78b369d9 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -38,17 +40,15 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class DiscFerret { /// public ErrorNumber Open(IFilter imageFilter) { - byte[] magicB = new byte[4]; + var magicB = new byte[4]; Stream stream = imageFilter.GetDataForkStream(); stream.Read(magicB, 0, 4); - uint magic = BitConverter.ToUInt32(magicB, 0); + var magic = BitConverter.ToUInt32(magicB, 0); if(magic != DFI_MAGIC && magic != DFI_MAGIC2) @@ -64,7 +64,7 @@ public sealed partial class DiscFerret { long thisOffset = stream.Position; - byte[] blk = new byte[Marshal.SizeOf()]; + var blk = new byte[Marshal.SizeOf()]; stream.Read(blk, 0, Marshal.SizeOf()); BlockHeader blockHeader = Marshal.ByteArrayToStructureBigEndian(blk); @@ -73,11 +73,9 @@ public sealed partial class DiscFerret AaruConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.head = {1}", thisOffset, blockHeader.head); - AaruConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.sector = {1}", thisOffset, - blockHeader.sector); + AaruConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.sector = {1}", thisOffset, blockHeader.sector); - AaruConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.length = {1}", thisOffset, - blockHeader.length); + AaruConsole.DebugWriteLine("DiscFerret plugin", "block@{0}.length = {1}", thisOffset, blockHeader.length); if(stream.Position + blockHeader.length > stream.Length) { @@ -135,8 +133,7 @@ public sealed partial class DiscFerret } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) diff --git a/Aaru.Images/DiscFerret/Structs.cs b/Aaru.Images/DiscFerret/Structs.cs index ab322b4fd..6268e7d48 100644 --- a/Aaru.Images/DiscFerret/Structs.cs +++ b/Aaru.Images/DiscFerret/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class DiscFerret { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/DiscFerret/Verify.cs b/Aaru.Images/DiscFerret/Verify.cs index 7a16f0248..3925092d2 100644 --- a/Aaru.Images/DiscFerret/Verify.cs +++ b/Aaru.Images/DiscFerret/Verify.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; -namespace Aaru.DiscImages; - public sealed partial class DiscFerret { /// diff --git a/Aaru.Images/DiscJuggler/DiscJuggler.cs b/Aaru.Images/DiscJuggler/DiscJuggler.cs index 0919096e5..0a6c42075 100644 --- a/Aaru.Images/DiscJuggler/DiscJuggler.cs +++ b/Aaru.Images/DiscJuggler/DiscJuggler.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -namespace Aaru.DiscImages; - // Support separate data files? Never seen a DiscJuggler image using them anyways... // TODO: Too many unknowns to make this writable /// diff --git a/Aaru.Images/DiscJuggler/Helpers.cs b/Aaru.Images/DiscJuggler/Helpers.cs index 1d01c66d6..826bae33f 100644 --- a/Aaru.Images/DiscJuggler/Helpers.cs +++ b/Aaru.Images/DiscJuggler/Helpers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; - namespace Aaru.DiscImages; +using Aaru.CommonTypes; + public sealed partial class DiscJuggler { static MediaType DecodeCdiMediumType(ushort type) diff --git a/Aaru.Images/DiscJuggler/Identify.cs b/Aaru.Images/DiscJuggler/Identify.cs index a60cf7146..392d56e69 100644 --- a/Aaru.Images/DiscJuggler/Identify.cs +++ b/Aaru.Images/DiscJuggler/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class DiscJuggler { /// @@ -45,16 +45,16 @@ public sealed partial class DiscJuggler _imageStream = imageFilter.GetDataForkStream(); _imageStream.Seek(-4, SeekOrigin.End); - byte[] dscLenB = new byte[4]; + var dscLenB = new byte[4]; _imageStream.Read(dscLenB, 0, 4); - int dscLen = BitConverter.ToInt32(dscLenB, 0); + var dscLen = BitConverter.ToInt32(dscLenB, 0); AaruConsole.DebugWriteLine("DiscJuggler plugin", "dscLen = {0}", dscLen); if(dscLen >= _imageStream.Length) return false; - byte[] descriptor = new byte[dscLen]; + var descriptor = new byte[dscLen]; _imageStream.Seek(-dscLen, SeekOrigin.End); _imageStream.Read(descriptor, 0, dscLen); diff --git a/Aaru.Images/DiscJuggler/Properties.cs b/Aaru.Images/DiscJuggler/Properties.cs index 0cf299c5a..a5af5ba7f 100644 --- a/Aaru.Images/DiscJuggler/Properties.cs +++ b/Aaru.Images/DiscJuggler/Properties.cs @@ -30,20 +30,20 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DiscJuggler { /// public string Name => "DiscJuggler"; /// - public Guid Id => new Guid("2444DBC6-CD35-424C-A227-39B0C4DB01B2"); + public Guid Id => new("2444DBC6-CD35-424C-A227-39B0C4DB01B2"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/DiscJuggler/Read.cs b/Aaru.Images/DiscJuggler/Read.cs index bc0ceb15d..6c05e5fe9 100644 --- a/Aaru.Images/DiscJuggler/Read.cs +++ b/Aaru.Images/DiscJuggler/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -44,8 +46,6 @@ using Aaru.Decoders.CD; using Aaru.Helpers; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class DiscJuggler { /// @@ -55,14 +55,14 @@ public sealed partial class DiscJuggler // Read size of image descriptor _imageStream.Seek(-4, SeekOrigin.End); - byte[] dscLenB = new byte[4]; + var dscLenB = new byte[4]; _imageStream.Read(dscLenB, 0, 4); - int dscLen = BitConverter.ToInt32(dscLenB, 0); + var dscLen = BitConverter.ToInt32(dscLenB, 0); if(dscLen >= _imageStream.Length) return ErrorNumber.InvalidArgument; - byte[] descriptor = new byte[dscLen]; + var descriptor = new byte[dscLen]; _imageStream.Seek(-dscLen, SeekOrigin.End); _imageStream.Read(descriptor, 0, dscLen); @@ -71,7 +71,7 @@ public sealed partial class DiscJuggler descriptor[0] == 0) return ErrorNumber.InvalidArgument; - int position = 1; + var position = 1; ushort sessionSequence = 0; Sessions = new List(); @@ -107,7 +107,7 @@ public sealed partial class DiscJuggler descriptor[position + 13] != 0xFF || descriptor[position + 14] != 0xFF) { - bool nextFound = false; + var nextFound = false; // But on generated (not dumped) image, it can have some data between last written session and // next open one, so depend on if we already got a track @@ -163,7 +163,7 @@ public sealed partial class DiscJuggler }; position += 15; - bool addedATrack = false; + var addedATrack = false; // Read track for(byte t = 0; t < maxT; t++) @@ -174,7 +174,7 @@ public sealed partial class DiscJuggler // Skip unknown position += 16; - byte[] trackFilenameB = new byte[descriptor[position]]; + var trackFilenameB = new byte[descriptor[position]]; position++; Array.Copy(descriptor, position, trackFilenameB, 0, trackFilenameB.Length); position += trackFilenameB.Length; @@ -189,27 +189,27 @@ public sealed partial class DiscJuggler AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tmediumType = {0}", mediumType); // Read indices - ushort maxI = BitConverter.ToUInt16(descriptor, position); + var maxI = BitConverter.ToUInt16(descriptor, position); position += 2; AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tmaxI = {0}", maxI); // This is not really the index position, but, the index length, go figure for(ushort i = 0; i < maxI; i++) { - int index = BitConverter.ToInt32(descriptor, position); + var index = BitConverter.ToInt32(descriptor, position); track.Indexes.Add(i, index); position += 4; AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tindex[{1}] = {0}", index, i); } // Read CD-Text - uint maxC = BitConverter.ToUInt32(descriptor, position); + var maxC = BitConverter.ToUInt32(descriptor, position); position += 4; AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tmaxC = {0}", maxC); for(uint c = 0; c < maxC; c++) { - for(int cb = 0; cb < 18; cb++) + for(var cb = 0; cb < 18; cb++) { int bLen = descriptor[position]; position++; @@ -218,7 +218,7 @@ public sealed partial class DiscJuggler if(bLen <= 0) continue; - byte[] textBlk = new byte[bLen]; + var textBlk = new byte[bLen]; Array.Copy(descriptor, position, textBlk, 0, bLen); position += bLen; @@ -233,7 +233,7 @@ public sealed partial class DiscJuggler } position += 2; - uint trackMode = BitConverter.ToUInt32(descriptor, position); + var trackMode = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\ttrackMode = {0}", trackMode); position += 4; @@ -262,7 +262,7 @@ public sealed partial class DiscJuggler track.StartSector = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\ttrackStart = {0}", track.StartSector); position += 4; - uint trackLen = BitConverter.ToUInt32(descriptor, position); + var trackLen = BitConverter.ToUInt32(descriptor, position); // DiscJuggler counts the first track pregap start as 0 instead of -150, we need to adjust appropriately if(track.StartSector == 0) @@ -270,7 +270,7 @@ public sealed partial class DiscJuggler else track.StartSector -= 150; - int leftLen = (int)trackLen; + var leftLen = (int)trackLen; // Convert index length to index position foreach(KeyValuePair idx in track.Indexes.Reverse()) @@ -303,21 +303,21 @@ public sealed partial class DiscJuggler // Skip unknown position += 16; - uint readMode = BitConverter.ToUInt32(descriptor, position); + var readMode = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\treadMode = {0}", readMode); position += 4; - uint trackCtl = BitConverter.ToUInt32(descriptor, position); + var trackCtl = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\ttrackCtl = {0}", trackCtl); position += 4; // Skip unknown position += 9; - byte[] isrc = new byte[12]; + var isrc = new byte[12]; Array.Copy(descriptor, position, isrc, 0, 12); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tisrc = {0}", StringHandlers.CToString(isrc)); position += 12; - uint isrcValid = BitConverter.ToUInt32(descriptor, position); + var isrcValid = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tisrc_valid = {0}", isrcValid); position += 4; @@ -335,7 +335,7 @@ public sealed partial class DiscJuggler AaruConsole.DebugWriteLine("DiscJuggler plugin", "\ttrackFollows = {0}", trackFollows); position += 2; - uint endAddress = BitConverter.ToUInt32(descriptor, position); + var endAddress = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "\tendAddress = {0}", endAddress); position += 4; @@ -662,7 +662,7 @@ public sealed partial class DiscJuggler position += 16; AaruConsole.DebugWriteLine("DiscJuggler plugin", "Current position = {0}", position); - byte[] filenameB = new byte[descriptor[position]]; + var filenameB = new byte[descriptor[position]]; position++; Array.Copy(descriptor, position, filenameB, 0, filenameB.Length); position += filenameB.Length; @@ -676,11 +676,11 @@ public sealed partial class DiscJuggler position += 2; AaruConsole.DebugWriteLine("DiscJuggler plugin", "mediumType = {0}", mediumType); - uint discSize = BitConverter.ToUInt32(descriptor, position); + var discSize = BitConverter.ToUInt32(descriptor, position); position += 4; AaruConsole.DebugWriteLine("DiscJuggler plugin", "discSize = {0}", discSize); - byte[] volidB = new byte[descriptor[position]]; + var volidB = new byte[descriptor[position]]; position++; Array.Copy(descriptor, position, volidB, 0, volidB.Length); position += volidB.Length; @@ -690,15 +690,15 @@ public sealed partial class DiscJuggler // Skip unknown position += 9; - byte[] mcn = new byte[13]; + var mcn = new byte[13]; Array.Copy(descriptor, position, mcn, 0, 13); AaruConsole.DebugWriteLine("DiscJuggler plugin", "mcn = {0}", StringHandlers.CToString(mcn)); position += 13; - uint mcnValid = BitConverter.ToUInt32(descriptor, position); + var mcnValid = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "mcn_valid = {0}", mcnValid); position += 4; - uint cdtextLen = BitConverter.ToUInt32(descriptor, position); + var cdtextLen = BitConverter.ToUInt32(descriptor, position); AaruConsole.DebugWriteLine("DiscJuggler plugin", "cdtextLen = {0}", cdtextLen); position += 4; @@ -719,13 +719,13 @@ public sealed partial class DiscJuggler if(_imageInfo.MediaType == MediaType.CDROM) { - bool data = false; - bool mode2 = false; - bool firstaudio = false; - bool firstdata = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstaudio = false; + var firstdata = false; + var audio = false; - for(int i = 0; i < Tracks.Count; i++) + for(var i = 0; i < Tracks.Count; i++) { // First track is audio firstaudio |= i == 0 && Tracks[i].Type == TrackType.Audio; @@ -758,7 +758,7 @@ public sealed partial class DiscJuggler Sessions.Count > 1 && mode2) _imageInfo.MediaType = MediaType.CDPLUS; - else if((firstdata && audio) || mode2) + else if(firstdata && audio || mode2) _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = MediaType.CDROM; @@ -821,8 +821,7 @@ public sealed partial class DiscJuggler } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -884,7 +883,7 @@ public sealed partial class DiscJuggler uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch(aaruTrack.Type) { @@ -942,7 +941,7 @@ public sealed partial class DiscJuggler buffer = new byte[sectorSize * length]; - _imageStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * (sectorOffset + sectorSize + sectorSkip))), + _imageStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * (sectorOffset + sectorSize + sectorSkip)), SeekOrigin.Begin); if(mode2) @@ -952,9 +951,9 @@ public sealed partial class DiscJuggler buffer = new byte[(aaruTrack.RawBytesPerSector + sectorSkip) * length]; _imageStream.Read(buffer, 0, buffer.Length); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[aaruTrack.RawBytesPerSector]; + var sector = new byte[aaruTrack.RawBytesPerSector]; Array.Copy(buffer, (aaruTrack.RawBytesPerSector + sectorSkip) * i, sector, 0, aaruTrack.RawBytesPerSector); @@ -969,9 +968,9 @@ public sealed partial class DiscJuggler sectorSkip == 0) _imageStream.Read(buffer, 0, buffer.Length); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; _imageStream.Seek(sectorOffset, SeekOrigin.Current); _imageStream.Read(sector, 0, sector.Length); _imageStream.Seek(sectorSkip, SeekOrigin.Current); @@ -1208,16 +1207,16 @@ public sealed partial class DiscJuggler buffer = new byte[sectorSize * length]; - _imageStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * (sectorOffset + sectorSize + sectorSkip))), + _imageStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * (sectorOffset + sectorSize + sectorSkip)), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) _imageStream.Read(buffer, 0, buffer.Length); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; _imageStream.Seek(sectorOffset, SeekOrigin.Current); _imageStream.Read(sector, 0, sector.Length); _imageStream.Seek(sectorSkip, SeekOrigin.Current); @@ -1269,7 +1268,7 @@ public sealed partial class DiscJuggler if(length + sectorAddress > aaruTrack.EndSector - aaruTrack.StartSector + 1) return ErrorNumber.OutOfRange; - uint sectorSize = (uint)aaruTrack.RawBytesPerSector; + var sectorSize = (uint)aaruTrack.RawBytesPerSector; uint sectorSkip = 0; switch(aaruTrack.SubchannelType) @@ -1291,15 +1290,14 @@ public sealed partial class DiscJuggler buffer = new byte[sectorSize * length]; - _imageStream.Seek((long)(aaruTrack.FileOffset + (sectorAddress * (sectorSize + sectorSkip))), - SeekOrigin.Begin); + _imageStream.Seek((long)(aaruTrack.FileOffset + sectorAddress * (sectorSize + sectorSkip)), SeekOrigin.Begin); if(sectorSkip == 0) _imageStream.Read(buffer, 0, buffer.Length); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; _imageStream.Read(sector, 0, sector.Length); _imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); @@ -1309,8 +1307,8 @@ public sealed partial class DiscJuggler { case TrackType.CdMode1 when aaruTrack.RawBytesPerSector == 2048: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { @@ -1326,8 +1324,8 @@ public sealed partial class DiscJuggler } case TrackType.CdMode2Formless when aaruTrack.RawBytesPerSector == 2336: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/DiscJuggler/Verify.cs b/Aaru.Images/DiscJuggler/Verify.cs index 3f841268f..9900f226f 100644 --- a/Aaru.Images/DiscJuggler/Verify.cs +++ b/Aaru.Images/DiscJuggler/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class DiscJuggler { /// @@ -58,10 +58,10 @@ public sealed partial class DiscJuggler if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class DiscJuggler if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/DiskCopy42/DiskCopy42.cs b/Aaru.Images/DiskCopy42/DiskCopy42.cs index 771f2772a..627e0c9b0 100644 --- a/Aaru.Images/DiskCopy42/DiskCopy42.cs +++ b/Aaru.Images/DiskCopy42/DiskCopy42.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // Checked using several images and strings inside Apple's DiskImages.framework /// Implements reading and writing Apple DiskCopy 4.2 disk images [SuppressMessage("ReSharper", "InconsistentNaming")] diff --git a/Aaru.Images/DiskCopy42/Identify.cs b/Aaru.Images/DiskCopy42/Identify.cs index 4269402a1..8c872b242 100644 --- a/Aaru.Images/DiskCopy42/Identify.cs +++ b/Aaru.Images/DiskCopy42/Identify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; @@ -37,8 +39,6 @@ using Aaru.Console; using Aaru.Helpers; using Claunia.Encoding; -namespace Aaru.DiscImages; - public sealed partial class DiskCopy42 { /// @@ -46,8 +46,8 @@ public sealed partial class DiskCopy42 { Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] buffer = new byte[0x58]; - byte[] pString = new byte[64]; + var buffer = new byte[0x58]; + var pString = new byte[64]; stream.Read(buffer, 0, 0x58); // Incorrect pascal string length, not DC42 @@ -104,8 +104,7 @@ public sealed partial class DiskCopy42 tmpHeader.Format != kSigmaFormatTwiggy && tmpHeader.Format != kNotStandardFormat) { - AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.format = 0x{0:X2} value", - tmpHeader.Format); + AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.format = 0x{0:X2} value", tmpHeader.Format); return false; } @@ -119,8 +118,7 @@ public sealed partial class DiskCopy42 tmpHeader.FmtByte != kFmtNotStandard && tmpHeader.FmtByte != kMacOSXFmtByte) { - AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", - tmpHeader.FmtByte); + AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", tmpHeader.FmtByte); return false; } diff --git a/Aaru.Images/DiskCopy42/Properties.cs b/Aaru.Images/DiskCopy42/Properties.cs index acad7d941..4d0bd8b2e 100644 --- a/Aaru.Images/DiskCopy42/Properties.cs +++ b/Aaru.Images/DiskCopy42/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DiskCopy42 { /// @@ -46,7 +46,7 @@ public sealed partial class DiskCopy42 /// public string Name => "Apple DiskCopy 4.2"; /// - public Guid Id => new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); + public Guid Id => new("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/DiskCopy42/Read.cs b/Aaru.Images/DiskCopy42/Read.cs index f65bdf411..114ab4a15 100644 --- a/Aaru.Images/DiskCopy42/Read.cs +++ b/Aaru.Images/DiskCopy42/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; @@ -42,8 +44,6 @@ using Claunia.Encoding; using Claunia.RsrcFork; using Version = Resources.Version; -namespace Aaru.DiscImages; - public sealed partial class DiskCopy42 { /// @@ -51,8 +51,8 @@ public sealed partial class DiskCopy42 { Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] buffer = new byte[0x58]; - byte[] pString = new byte[64]; + var buffer = new byte[0x58]; + var pString = new byte[64]; stream.Read(buffer, 0, 0x58); IsWriting = false; @@ -123,8 +123,7 @@ public sealed partial class DiskCopy42 header.FmtByte != kFmtNotStandard && header.FmtByte != kMacOSXFmtByte) { - AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", - header.FmtByte); + AaruConsole.DebugWriteLine("DC42 plugin", "Unknown tmp_header.fmtByte = 0x{0:X2} value", header.FmtByte); return ErrorNumber.NotSupported; } @@ -161,7 +160,7 @@ public sealed partial class DiskCopy42 imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); } - imageInfo.ImageSize = (imageInfo.Sectors * imageInfo.SectorSize) + (imageInfo.Sectors * bptag); + imageInfo.ImageSize = imageInfo.Sectors * imageInfo.SectorSize + imageInfo.Sectors * bptag; imageInfo.CreationTime = imageFilter.CreationTime; imageInfo.LastModificationTime = imageFilter.LastWriteTime; imageInfo.MediaTitle = header.DiskName; @@ -226,8 +225,8 @@ public sealed partial class DiskCopy42 if(imageInfo.MediaType == MediaType.AppleFileWare) { - byte[] data = new byte[header.DataSize]; - byte[] tags = new byte[header.TagSize]; + var data = new byte[header.DataSize]; + var tags = new byte[header.TagSize]; twiggyCache = new byte[header.DataSize]; twiggyCacheTags = new byte[header.TagSize]; @@ -241,8 +240,8 @@ public sealed partial class DiskCopy42 tagStream.Seek(tagOffset, SeekOrigin.Begin); tagStream.Read(tags, 0, (int)header.TagSize); - ushort mfsMagic = BigEndianBitConverter.ToUInt16(data, (data.Length / 2) + 0x400); - ushort mfsAllBlocks = BigEndianBitConverter.ToUInt16(data, (data.Length / 2) + 0x412); + var mfsMagic = BigEndianBitConverter.ToUInt16(data, data.Length / 2 + 0x400); + var mfsAllBlocks = BigEndianBitConverter.ToUInt16(data, data.Length / 2 + 0x412); // Detect a Macintosh Twiggy if(mfsMagic == 0xD2D7 && @@ -260,10 +259,10 @@ public sealed partial class DiskCopy42 Array.Copy(data, 0, twiggyCache, 0, header.DataSize / 2); Array.Copy(tags, 0, twiggyCacheTags, 0, header.TagSize / 2); - int copiedSectors = 0; - int sectorsToCopy = 0; + var copiedSectors = 0; + var sectorsToCopy = 0; - for(int i = 0; i < 46; i++) + for(var i = 0; i < 46; i++) { if(i >= 0 && i <= 3) @@ -297,12 +296,11 @@ public sealed partial class DiskCopy42 i <= 45) sectorsToCopy = 15; - 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; @@ -467,8 +465,7 @@ public sealed partial class DiskCopy42 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -493,7 +490,7 @@ public sealed partial class DiskCopy42 else { Stream stream = dc42ImageFilter.GetDataForkStream(); - stream.Seek((long)(dataOffset + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(dataOffset + sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); } @@ -524,7 +521,7 @@ public sealed partial class DiskCopy42 else { Stream stream = dc42ImageFilter.GetDataForkStream(); - stream.Seek((long)(tagOffset + (sectorAddress * bptag)), SeekOrigin.Begin); + stream.Seek((long)(tagOffset + sectorAddress * bptag), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * bptag)); } @@ -563,7 +560,7 @@ public sealed partial class DiskCopy42 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); + Array.Copy(tags, i * bptag, buffer, i * (imageInfo.SectorSize + bptag) + imageInfo.SectorSize, bptag); } return ErrorNumber.NoError; diff --git a/Aaru.Images/DiskCopy42/Unsupported.cs b/Aaru.Images/DiskCopy42/Unsupported.cs index ba3364547..caea054cf 100644 --- a/Aaru.Images/DiskCopy42/Unsupported.cs +++ b/Aaru.Images/DiskCopy42/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class DiskCopy42 { /// diff --git a/Aaru.Images/DiskCopy42/Verify.cs b/Aaru.Images/DiskCopy42/Verify.cs index 6a6ecf465..dda00dacb 100644 --- a/Aaru.Images/DiskCopy42/Verify.cs +++ b/Aaru.Images/DiskCopy42/Verify.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class DiskCopy42 { /// public bool? VerifyMediaImage() { - byte[] data = new byte[header.DataSize]; - byte[] tags = new byte[header.TagSize]; - uint tagsChk = 0; + var data = new byte[header.DataSize]; + var tags = new byte[header.TagSize]; + uint tagsChk = 0; AaruConsole.DebugWriteLine("DC42 plugin", "Reading data"); Stream dataStream = dc42ImageFilter.GetDataForkStream(); diff --git a/Aaru.Images/DiskCopy42/Write.cs b/Aaru.Images/DiskCopy42/Write.cs index bf4480928..119aee92b 100644 --- a/Aaru.Images/DiskCopy42/Write.cs +++ b/Aaru.Images/DiskCopy42/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes; @@ -39,8 +41,6 @@ using Aaru.Helpers; using Claunia.Encoding; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DiskCopy42 { /// @@ -48,8 +48,8 @@ public sealed partial class DiskCopy42 uint sectorSize) { header = new Header(); - bool tags = false; - bool macosx = false; + var tags = false; + var macosx = false; if(options != null && options.TryGetValue("macosx", out string tmpOption)) @@ -246,7 +246,7 @@ public sealed partial class DiskCopy42 return false; } - writingStream.Seek((long)(dataOffset + (sectorAddress * 512)), SeekOrigin.Begin); + writingStream.Seek((long)(dataOffset + sectorAddress * 512), SeekOrigin.Begin); writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -278,7 +278,7 @@ public sealed partial class DiskCopy42 return false; } - writingStream.Seek((long)(dataOffset + (sectorAddress * 512)), SeekOrigin.Begin); + writingStream.Seek((long)(dataOffset + sectorAddress * 512), SeekOrigin.Begin); writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -317,9 +317,9 @@ public sealed partial class DiskCopy42 return false; } - writingStream.Seek((long)(dataOffset + (sectorAddress * 512)), SeekOrigin.Begin); + writingStream.Seek((long)(dataOffset + sectorAddress * 512), SeekOrigin.Begin); writingStream.Write(data, 0, 512); - writingStream.Seek((long)(tagOffset + (sectorAddress * 12)), SeekOrigin.Begin); + writingStream.Seek((long)(tagOffset + sectorAddress * 12), SeekOrigin.Begin); writingStream.Write(data, 512, 12); ErrorMessage = ""; @@ -360,12 +360,12 @@ public sealed partial class DiskCopy42 for(uint i = 0; i < length; i++) { - writingStream.Seek((long)(dataOffset + ((sectorAddress + i) * 512)), SeekOrigin.Begin); - writingStream.Write(data, (int)((i * 524) + 0), 512); + writingStream.Seek((long)(dataOffset + (sectorAddress + i) * 512), SeekOrigin.Begin); + writingStream.Write(data, (int)(i * 524 + 0), 512); - writingStream.Seek((long)(tagOffset + ((sectorAddress + i) * 12)), SeekOrigin.Begin); + writingStream.Seek((long)(tagOffset + (sectorAddress + i) * 12), SeekOrigin.Begin); - writingStream.Write(data, (int)((i * 524) + 512), 12); + writingStream.Write(data, (int)(i * 524 + 512), 12); } ErrorMessage = ""; @@ -388,7 +388,7 @@ public sealed partial class DiskCopy42 header.TagSize = 0; writingStream.Seek(0x54, SeekOrigin.Begin); - byte[] data = new byte[header.DataSize]; + var data = new byte[header.DataSize]; writingStream.Read(data, 0, (int)header.DataSize); header.DataChecksum = CheckSum(data); writingStream.Seek(0x54 + header.DataSize, SeekOrigin.Begin); diff --git a/Aaru.Images/DiskDupe/DiskDupe.cs b/Aaru.Images/DiskDupe/DiskDupe.cs index dbc49bbb5..100f25695 100644 --- a/Aaru.Images/DiskDupe/DiskDupe.cs +++ b/Aaru.Images/DiskDupe/DiskDupe.cs @@ -55,15 +55,17 @@ * that DDI files are easy to recognize. */ -using System.Collections.Generic; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; + // ReSharper disable NotAccessedField.Local namespace Aaru.DiscImages; +using System.Collections.Generic; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; + /// /// Implements reading DiskDupe disk images public sealed partial class DiskDupe : IMediaImage diff --git a/Aaru.Images/DiskDupe/Helpers.cs b/Aaru.Images/DiskDupe/Helpers.cs index fc65c5893..43ace6d37 100644 --- a/Aaru.Images/DiskDupe/Helpers.cs +++ b/Aaru.Images/DiskDupe/Helpers.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class DiskDupe { bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets) @@ -45,7 +45,7 @@ public sealed partial class DiskDupe int numTracks; int trackLen; // the length of a single track, in bytes TrackInfo[] trackMap; - byte[] buffer = new byte[6]; + var buffer = new byte[6]; FileHeader fHeader; long[] trackOffsets; @@ -80,7 +80,7 @@ public sealed partial class DiskDupe _diskTypes[fHeader.diskType].spt); // read the trackmap and store the track offsets - for(int i = 0; i < numTracks; i++) + for(var i = 0; i < numTracks; i++) { stream.Read(buffer, 0, 6); trackMap[i] = Marshal.ByteArrayToStructureBigEndian(buffer); diff --git a/Aaru.Images/DiskDupe/Identify.cs b/Aaru.Images/DiskDupe/Identify.cs index 46417f5cf..3dd2711c3 100644 --- a/Aaru.Images/DiskDupe/Identify.cs +++ b/Aaru.Images/DiskDupe/Identify.cs @@ -31,11 +31,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class DiskDupe { /// diff --git a/Aaru.Images/DiskDupe/Properties.cs b/Aaru.Images/DiskDupe/Properties.cs index 9a65da65e..bd58d9b7e 100644 --- a/Aaru.Images/DiskDupe/Properties.cs +++ b/Aaru.Images/DiskDupe/Properties.cs @@ -31,19 +31,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DiskDupe { /// public string Name => "DiskDupe DDI Disk Image"; /// - public Guid Id => new Guid("5439B4A2-5F38-33A7-B8DC-3910D296B3DD"); + public Guid Id => new("5439B4A2-5F38-33A7-B8DC-3910D296B3DD"); /// public string Author => "Michael Drüing"; /// diff --git a/Aaru.Images/DiskDupe/Read.cs b/Aaru.Images/DiskDupe/Read.cs index e147153e2..ca1dfa85c 100644 --- a/Aaru.Images/DiskDupe/Read.cs +++ b/Aaru.Images/DiskDupe/Read.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class DiskDupe { public ErrorNumber Open(IFilter imageFilter) @@ -86,8 +86,8 @@ public sealed partial class DiskDupe public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) { buffer = null; - int trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); - int sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); + var trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); + var sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -103,7 +103,7 @@ public sealed partial class DiskDupe { Stream strm = _ddiImageFilter.GetDataForkStream(); - strm.Seek(_trackOffsets[trackNum] + (sectorOffset * _imageInfo.SectorSize), SeekOrigin.Begin); + strm.Seek(_trackOffsets[trackNum] + sectorOffset * _imageInfo.SectorSize, SeekOrigin.Begin); strm.Read(buffer, 0, (int)_imageInfo.SectorSize); } diff --git a/Aaru.Images/DiskDupe/Structs.cs b/Aaru.Images/DiskDupe/Structs.cs index 36d34e5cd..d3abcf0d3 100644 --- a/Aaru.Images/DiskDupe/Structs.cs +++ b/Aaru.Images/DiskDupe/Structs.cs @@ -31,11 +31,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class DiskDupe { @@ -49,31 +49,31 @@ public sealed partial class DiskDupe readonly DiskType[] _diskTypes = { - new DiskType + new() { cyl = 0, hd = 0, spt = 0 }, // Type 0 - invalid - new DiskType + new() { cyl = 40, hd = 2, spt = 9 }, // Type 1 - 360k - new DiskType + new() { cyl = 80, hd = 2, spt = 15 }, // Type 2 - 1.2m - new DiskType + new() { cyl = 80, hd = 2, spt = 9 }, // Type 3 - 720k - new DiskType + new() { cyl = 80, hd = 2, diff --git a/Aaru.Images/DiskDupe/Unsupported.cs b/Aaru.Images/DiskDupe/Unsupported.cs index e90462587..8ae32bdb5 100644 --- a/Aaru.Images/DiskDupe/Unsupported.cs +++ b/Aaru.Images/DiskDupe/Unsupported.cs @@ -31,10 +31,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class DiskDupe { /// diff --git a/Aaru.Images/DriDiskCopy/DriDiskCopy.cs b/Aaru.Images/DriDiskCopy/DriDiskCopy.cs index d3f4be529..da8265926 100644 --- a/Aaru.Images/DriDiskCopy/DriDiskCopy.cs +++ b/Aaru.Images/DriDiskCopy/DriDiskCopy.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing DR-DOS' DISKCOPY disk images public sealed partial class DriDiskCopy : IWritableImage diff --git a/Aaru.Images/DriDiskCopy/Enums.cs b/Aaru.Images/DriDiskCopy/Enums.cs index 43435d4aa..dfd0ff1c9 100644 --- a/Aaru.Images/DriDiskCopy/Enums.cs +++ b/Aaru.Images/DriDiskCopy/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class DriDiskCopy { diff --git a/Aaru.Images/DriDiskCopy/Identify.cs b/Aaru.Images/DriDiskCopy/Identify.cs index 76614da83..07fb6eef0 100644 --- a/Aaru.Images/DriDiskCopy/Identify.cs +++ b/Aaru.Images/DriDiskCopy/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class DriDiskCopy { /// @@ -48,7 +48,7 @@ public sealed partial class DriDiskCopy if((stream.Length - Marshal.SizeOf
()) % 512 != 0) return false; - byte[] buffer = new byte[Marshal.SizeOf
()]; + var buffer = new byte[Marshal.SizeOf
()]; stream.Seek(-buffer.Length, SeekOrigin.End); stream.Read(buffer, 0, buffer.Length); @@ -59,13 +59,11 @@ public sealed partial class DriDiskCopy AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.signature = \"{0}\"", sig); AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.five = {0}", tmpFooter.bpb.five); - AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb._driveCode = {0}", - tmpFooter.bpb._driveCode); + AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb._driveCode = {0}", tmpFooter.bpb._driveCode); AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown = {0}", tmpFooter.bpb.unknown); - AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.cylinders = {0}", - tmpFooter.bpb.cylinders); + AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.cylinders = {0}", tmpFooter.bpb.cylinders); AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.unknown2 = {0}", tmpFooter.bpb.unknown2); AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "tmp_footer.bpb.bps = {0}", tmpFooter.bpb.bps); @@ -101,6 +99,6 @@ public sealed partial class DriDiskCopy if(tmpFooter.bpb.sptrack * tmpFooter.bpb.cylinders * tmpFooter.bpb.heads != tmpFooter.bpb.sectors) return false; - return (tmpFooter.bpb.sectors * tmpFooter.bpb.bps) + Marshal.SizeOf
() == stream.Length; + return tmpFooter.bpb.sectors * tmpFooter.bpb.bps + Marshal.SizeOf
() == stream.Length; } } \ No newline at end of file diff --git a/Aaru.Images/DriDiskCopy/Properties.cs b/Aaru.Images/DriDiskCopy/Properties.cs index 780d7a7c1..857df2250 100644 --- a/Aaru.Images/DriDiskCopy/Properties.cs +++ b/Aaru.Images/DriDiskCopy/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DriDiskCopy { /// @@ -47,7 +47,7 @@ public sealed partial class DriDiskCopy /// public string Name => "Digital Research DiskCopy"; /// - public Guid Id => new Guid("9F0BE551-8BAB-4038-8B5A-691F1BF5FFF3"); + public Guid Id => new("9F0BE551-8BAB-4038-8B5A-691F1BF5FFF3"); /// public string Author => "Natalia Portillo"; /// @@ -69,11 +69,11 @@ public sealed partial class DriDiskCopy { MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.Apricot_35, MediaType.ATARI_35_DS_DD, MediaType.ATARI_35_DS_DD_11, MediaType.ATARI_35_SS_DD, MediaType.ATARI_35_SS_DD_11, MediaType.DMF, - MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, - MediaType.DOS_35_HD, MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, - MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, - MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, - MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II + MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD, + MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, MediaType.DOS_525_DS_DD_9, + MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, MediaType.FDFORMAT_35_DD, + MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, MediaType.RX50, + MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/DriDiskCopy/Read.cs b/Aaru.Images/DriDiskCopy/Read.cs index eddbbae90..f5369ac16 100644 --- a/Aaru.Images/DriDiskCopy/Read.cs +++ b/Aaru.Images/DriDiskCopy/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class DriDiskCopy { /// @@ -50,7 +50,7 @@ public sealed partial class DriDiskCopy if((stream.Length - Marshal.SizeOf
()) % 512 != 0) return ErrorNumber.InvalidArgument; - byte[] buffer = new byte[Marshal.SizeOf
()]; + var buffer = new byte[Marshal.SizeOf
()]; stream.Seek(-buffer.Length, SeekOrigin.End); stream.Read(buffer, 0, buffer.Length); @@ -67,7 +67,7 @@ public sealed partial class DriDiskCopy if(_footer.bpb.sptrack * _footer.bpb.cylinders * _footer.bpb.heads != _footer.bpb.sectors) return ErrorNumber.InvalidArgument; - if((_footer.bpb.sectors * _footer.bpb.bps) + Marshal.SizeOf
() != stream.Length) + if(_footer.bpb.sectors * _footer.bpb.bps + Marshal.SizeOf
() != stream.Length) return ErrorNumber.InvalidArgument; _imageInfo.Cylinders = _footer.bpb.cylinders; @@ -83,8 +83,8 @@ public sealed partial class DriDiskCopy _imageInfo.CreationTime = imageFilter.CreationTime; _imageInfo.LastModificationTime = imageFilter.LastWriteTime; - AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "Image application = {0} version {1}", - _imageInfo.Application, _imageInfo.ApplicationVersion); + AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "Image application = {0} version {1}", _imageInfo.Application, + _imageInfo.ApplicationVersion); // Correct some incorrect data in images of NEC 2HD disks if(_imageInfo.Cylinders == 77 && @@ -129,8 +129,7 @@ public sealed partial class DriDiskCopy } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) diff --git a/Aaru.Images/DriDiskCopy/Structs.cs b/Aaru.Images/DriDiskCopy/Structs.cs index 57f8517f4..52dce7c62 100644 --- a/Aaru.Images/DriDiskCopy/Structs.cs +++ b/Aaru.Images/DriDiskCopy/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class DriDiskCopy { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/DriDiskCopy/Unsupported.cs b/Aaru.Images/DriDiskCopy/Unsupported.cs index ec878ffe8..d5c819e22 100644 --- a/Aaru.Images/DriDiskCopy/Unsupported.cs +++ b/Aaru.Images/DriDiskCopy/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class DriDiskCopy { /// diff --git a/Aaru.Images/DriDiskCopy/Write.cs b/Aaru.Images/DriDiskCopy/Write.cs index 7caf5ccef..675131ecf 100644 --- a/Aaru.Images/DriDiskCopy/Write.cs +++ b/Aaru.Images/DriDiskCopy/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class DriDiskCopy { /// @@ -109,8 +109,8 @@ public sealed partial class DriDiskCopy } }; - Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0, - _footer.signature, 0, 49); + Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0, _footer.signature, + 0, 49); _footer.bpbcopy = _footer.bpb; @@ -218,7 +218,7 @@ public sealed partial class DriDiskCopy return false; } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_footer, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/GDI/GDI.cs b/Aaru.Images/GDI/GDI.cs index eff52d410..fe901e291 100644 --- a/Aaru.Images/GDI/GDI.cs +++ b/Aaru.Images/GDI/GDI.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -namespace Aaru.DiscImages; - // TODO: There seems no be no clear definition on how to treat pregaps that are not included in the file, so this is just appending it to start of track // TODO: This format doesn't support to specify pregaps that are included in the file (like Redump ones) /// diff --git a/Aaru.Images/GDI/Identify.cs b/Aaru.Images/GDI/Identify.cs index e8911a293..d0158c9d1 100644 --- a/Aaru.Images/GDI/Identify.cs +++ b/Aaru.Images/GDI/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class Gdi { // Due to .gdi format, this method must parse whole file, ignoring errors (those will be returned by OpenImage()). @@ -47,14 +47,14 @@ public sealed partial class Gdi try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - byte[] testArray = new byte[512]; + var testArray = new byte[512]; imageFilter.GetDataForkStream().Read(testArray, 0, 512); imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); // Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin - bool twoConsecutiveNulls = false; + var twoConsecutiveNulls = false; - for(int i = 0; i < 512; i++) + for(var i = 0; i < 512; i++) { if(i >= imageFilter.GetDataForkStream().Length) break; @@ -77,9 +77,9 @@ public sealed partial class Gdi } _gdiStream = new StreamReader(imageFilter.GetDataForkStream()); - int lineNumber = 0; - int tracksFound = 0; - int tracks = 0; + var lineNumber = 0; + var tracksFound = 0; + var tracks = 0; while(_gdiStream.Peek() >= 0) { diff --git a/Aaru.Images/GDI/Properties.cs b/Aaru.Images/GDI/Properties.cs index 85732409a..f47dd6fbf 100644 --- a/Aaru.Images/GDI/Properties.cs +++ b/Aaru.Images/GDI/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class Gdi { /// diff --git a/Aaru.Images/GDI/Read.cs b/Aaru.Images/GDI/Read.cs index 573106fdd..8fe2aed04 100644 --- a/Aaru.Images/GDI/Read.cs +++ b/Aaru.Images/GDI/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Decoders.CD; using Session = Aaru.CommonTypes.Structs.Session; -namespace Aaru.DiscImages; - public sealed partial class Gdi { /// @@ -57,8 +57,8 @@ public sealed partial class Gdi { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); _gdiStream = new StreamReader(imageFilter.GetDataForkStream()); - int lineNumber = 0; - bool highDensity = false; + var lineNumber = 0; + var highDensity = false; // Initialize all RegExs var regexTrack = new Regex(REGEX_TRACK); @@ -105,8 +105,8 @@ public sealed partial class Gdi "Found track {0} starts at {1} flags {2} type {3} file {4} offset {5} at line {6}", trackMatch.Groups["track"].Value, trackMatch.Groups["start"].Value, trackMatch.Groups["flags"].Value, trackMatch.Groups["type"].Value, - trackMatch.Groups["filename"].Value, - trackMatch.Groups["offset"].Value, lineNumber); + trackMatch.Groups["filename"].Value, trackMatch.Groups["offset"].Value, + lineNumber); var filtersList = new FiltersList(); @@ -152,16 +152,15 @@ public sealed partial class Gdi currentStart += currentTrack.Sectors; currentTrack.HighDensity = highDensity; - currentTrack.TrackType = - (currentTrack.Flags & 0x4) == 0x4 ? TrackType.CdMode1 : TrackType.Audio; + currentTrack.TrackType = (currentTrack.Flags & 0x4) == 0x4 ? TrackType.CdMode1 : TrackType.Audio; _discImage.Tracks.Add(currentTrack); } } - Session[] sessions = new Session[2]; + var sessions = new Session[2]; - for(int s = 0; s < sessions.Length; s++) + for(var s = 0; s < sessions.Length; s++) if(s == 0) { sessions[s].Sequence = 1; @@ -216,26 +215,24 @@ public sealed partial class Gdi AaruConsole.DebugWriteLine("GDI plugin", "Session information:"); AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} sessions", _discImage.Sessions.Count); - for(int i = 0; i < _discImage.Sessions.Count; i++) + for(var i = 0; i < _discImage.Sessions.Count; i++) { AaruConsole.DebugWriteLine("GDI plugin", "\tSession {0} information:", i + 1); - AaruConsole.DebugWriteLine("GDI plugin", "\t\tStarting track: {0}", - _discImage.Sessions[i].StartTrack); + AaruConsole.DebugWriteLine("GDI plugin", "\t\tStarting track: {0}", _discImage.Sessions[i].StartTrack); AaruConsole.DebugWriteLine("GDI plugin", "\t\tStarting sector: {0}", _discImage.Sessions[i].StartSector); AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding track: {0}", _discImage.Sessions[i].EndTrack); - AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding sector: {0}", - _discImage.Sessions[i].EndSector); + AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding sector: {0}", _discImage.Sessions[i].EndSector); } AaruConsole.DebugWriteLine("GDI plugin", "Track information:"); AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} tracks", _discImage.Tracks.Count); - for(int i = 0; i < _discImage.Tracks.Count; i++) + for(var i = 0; i < _discImage.Tracks.Count; i++) { AaruConsole.DebugWriteLine("GDI plugin", "\tTrack {0} information:", _discImage.Tracks[i].Sequence); AaruConsole.DebugWriteLine("GDI plugin", "\t\t{0} bytes per sector", _discImage.Tracks[i].Bps); @@ -264,7 +261,7 @@ public sealed partial class Gdi Partitions = new List(); ulong byteOffset = 0; - for(int i = 0; i < _discImage.Tracks.Count; i++) + for(var i = 0; i < _discImage.Tracks.Count; i++) { if(_discImage.Tracks[i].Sequence == 1 && i != 0) @@ -302,8 +299,8 @@ public sealed partial class Gdi _imageInfo.SectorSize = 2352; // All others - foreach(GdiTrack unused in _discImage.Tracks.Where(track => (track.Flags & 0x4) == 0x4 && - track.Bps == 2352)) + foreach(GdiTrack unused in + _discImage.Tracks.Where(track => (track.Flags & 0x4) == 0x4 && track.Bps == 2352)) { _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); @@ -339,8 +336,7 @@ public sealed partial class Gdi } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -360,8 +356,7 @@ public sealed partial class Gdi buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value - from gdiTrack in _discImage.Tracks - where gdiTrack.Sequence == kvp.Key + from gdiTrack in _discImage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key, out buffer); @@ -380,8 +375,7 @@ public sealed partial class Gdi buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value - from gdiTrack in _discImage.Tracks - where gdiTrack.Sequence == kvp.Key + from gdiTrack in _discImage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer); @@ -479,8 +473,8 @@ public sealed partial class Gdi _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - - (aaruTrack.Pregap * aaruTrack.Bps)); + long pos = aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip) - + aaruTrack.Pregap * aaruTrack.Bps); if(pos < 0) pos = 0; @@ -499,7 +493,7 @@ public sealed partial class Gdi } else { - int bufferPos = (int)((length - remainingSectors) * sectorSize); + var bufferPos = (int)((length - remainingSectors) * sectorSize); for(ulong i = 0; i < remainingSectors; i++) { @@ -667,8 +661,8 @@ public sealed partial class Gdi _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - - (aaruTrack.Pregap * aaruTrack.Bps)); + long pos = aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip) - + aaruTrack.Pregap * aaruTrack.Bps); if(pos < 0) pos = 0; @@ -687,7 +681,7 @@ public sealed partial class Gdi } else { - int bufferPos = (int)((length - remainingSectors) * sectorSize); + var bufferPos = (int)((length - remainingSectors) * sectorSize); for(ulong i = 0; i < remainingSectors; i++) { @@ -716,8 +710,7 @@ public sealed partial class Gdi buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetMap where sectorAddress >= kvp.Value - from gdiTrack in _discImage.Tracks - where gdiTrack.Sequence == kvp.Key + from gdiTrack in _discImage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key, out buffer); @@ -809,8 +802,8 @@ public sealed partial class Gdi _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - - (aaruTrack.Pregap * aaruTrack.Bps)); + long pos = aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip) - + aaruTrack.Pregap * aaruTrack.Bps); if(pos < 0) pos = 0; @@ -829,7 +822,7 @@ public sealed partial class Gdi } else { - int bufferPos = (int)((length - remainingSectors) * sectorSize); + var bufferPos = (int)((length - remainingSectors) * sectorSize); for(ulong i = 0; i < remainingSectors; i++) { @@ -845,8 +838,8 @@ public sealed partial class Gdi { case TrackType.CdMode1 when aaruTrack.Bps == 2048: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/GDI/Structs.cs b/Aaru.Images/GDI/Structs.cs index 0a8e5bf39..15dba3078 100644 --- a/Aaru.Images/GDI/Structs.cs +++ b/Aaru.Images/GDI/Structs.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - public sealed partial class Gdi { struct GdiTrack diff --git a/Aaru.Images/GDI/Unsupported.cs b/Aaru.Images/GDI/Unsupported.cs index 9d9319635..43e95452e 100644 --- a/Aaru.Images/GDI/Unsupported.cs +++ b/Aaru.Images/GDI/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Gdi { /// diff --git a/Aaru.Images/GDI/Verify.cs b/Aaru.Images/GDI/Verify.cs index 5ca1c8500..96fe18104 100644 --- a/Aaru.Images/GDI/Verify.cs +++ b/Aaru.Images/GDI/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Gdi { /// @@ -58,10 +58,10 @@ public sealed partial class Gdi if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class Gdi if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/HDCopy/HDCopy.cs b/Aaru.Images/HDCopy/HDCopy.cs index 32251b822..b8abe5bea 100644 --- a/Aaru.Images/HDCopy/HDCopy.cs +++ b/Aaru.Images/HDCopy/HDCopy.cs @@ -63,24 +63,26 @@ * diskette image. Fortunately, the HD-Copy header is highly recognizable. */ -using System.Collections.Generic; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; + // ReSharper disable NotAccessedField.Local namespace Aaru.DiscImages; +using System.Collections.Generic; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.CommonTypes.Structs; + /// /// Implements reading HD-Copy disk images public sealed partial class HdCopy : IMediaImage { /// Every track that has been read is cached here - readonly Dictionary _trackCache = new Dictionary(); + readonly Dictionary _trackCache = new(); /// The offset in the file where each track starts, or -1 if the track is not present - readonly Dictionary _trackOffset = new Dictionary(); + readonly Dictionary _trackOffset = new(); /// The HDCP file header after the image has been opened FileHeader _fileHeader; diff --git a/Aaru.Images/HDCopy/Helpers.cs b/Aaru.Images/HDCopy/Helpers.cs index 070084266..16e8f8a03 100644 --- a/Aaru.Images/HDCopy/Helpers.cs +++ b/Aaru.Images/HDCopy/Helpers.cs @@ -31,28 +31,28 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class HdCopy { bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref long dataStartOffset) { - int numTracks = 82; + var numTracks = 82; stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < 16 + (2 * 82)) + if(stream.Length < 16 + 2 * 82) return false; FileHeader fheader; /* assume it's a regular HD-Copy file without the disk name */ - dataStartOffset = 2 + (2 * numTracks); + dataStartOffset = 2 + 2 * numTracks; fheader.lastCylinder = (byte)stream.ReadByte(); fheader.sectorsPerTrack = (byte)stream.ReadByte(); @@ -64,7 +64,7 @@ public sealed partial class HdCopy fheader.lastCylinder = (byte)stream.ReadByte(); fheader.sectorsPerTrack = (byte)stream.ReadByte(); numTracks = 84; - dataStartOffset = 16 + (2 * numTracks); + dataStartOffset = 16 + 2 * numTracks; } fheader.trackMap = new byte[2 * numTracks]; @@ -88,7 +88,7 @@ public sealed partial class HdCopy return false; // all other tracks must be either present (=1) or absent (=0) - for(int i = 0; i < 2 * numTracks; i++) + for(var i = 0; i < 2 * numTracks; i++) if(fheader.trackMap[i] > 1) return false; @@ -100,8 +100,8 @@ public sealed partial class HdCopy ErrorNumber ReadTrackIntoCache(Stream stream, int trackNum) { - byte[] trackData = new byte[_imageInfo.SectorSize * _imageInfo.SectorsPerTrack]; - byte[] blkHeader = new byte[3]; + var trackData = new byte[_imageInfo.SectorSize * _imageInfo.SectorsPerTrack]; + var blkHeader = new byte[3]; // check that track is present if(_trackOffset[trackNum] == -1) @@ -115,15 +115,15 @@ public sealed partial class HdCopy // read the compressed track data stream.Read(blkHeader, 0, 3); - short compressedLength = (short)(BitConverter.ToInt16(blkHeader, 0) - 1); - byte escapeByte = blkHeader[2]; + var compressedLength = (short)(BitConverter.ToInt16(blkHeader, 0) - 1); + byte escapeByte = blkHeader[2]; - byte[] cBuffer = new byte[compressedLength]; + var cBuffer = new byte[compressedLength]; stream.Read(cBuffer, 0, compressedLength); // decompress the data - int sIndex = 0; // source buffer position - int dIndex = 0; // destination buffer position + var sIndex = 0; // source buffer position + var dIndex = 0; // destination buffer position while(sIndex < compressedLength) if(cBuffer[sIndex] == escapeByte) @@ -133,7 +133,7 @@ public sealed partial class HdCopy byte fillCount = cBuffer[sIndex++]; // fill destination buffer - for(int i = 0; i < fillCount; i++) + for(var i = 0; i < fillCount; i++) trackData[dIndex++] = fillByte; } else diff --git a/Aaru.Images/HDCopy/Identify.cs b/Aaru.Images/HDCopy/Identify.cs index f280de120..609a1e472 100644 --- a/Aaru.Images/HDCopy/Identify.cs +++ b/Aaru.Images/HDCopy/Identify.cs @@ -31,11 +31,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class HdCopy { /// diff --git a/Aaru.Images/HDCopy/Properties.cs b/Aaru.Images/HDCopy/Properties.cs index 8fe351750..578265f56 100644 --- a/Aaru.Images/HDCopy/Properties.cs +++ b/Aaru.Images/HDCopy/Properties.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class HdCopy { /// @@ -46,7 +46,7 @@ public sealed partial class HdCopy /// public string Name => "HD-Copy disk image"; /// - public Guid Id => new Guid("8D57483F-71A5-42EC-9B87-66AEC439C792"); + public Guid Id => new("8D57483F-71A5-42EC-9B87-66AEC439C792"); /// public string Author => "Michael Drüing"; /// diff --git a/Aaru.Images/HDCopy/Read.cs b/Aaru.Images/HDCopy/Read.cs index 0bd2bb3e7..6ca0a86a6 100644 --- a/Aaru.Images/HDCopy/Read.cs +++ b/Aaru.Images/HDCopy/Read.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class HdCopy { /// @@ -55,8 +55,7 @@ public sealed partial class HdCopy if(!TryReadHeader(stream, ref fheader, ref currentOffset)) return ErrorNumber.InvalidArgument; - AaruConsole.DebugWriteLine("HDCP plugin", - "Detected HD-Copy image with {0} tracks and {1} sectors per track.", + AaruConsole.DebugWriteLine("HDCP plugin", "Detected HD-Copy image with {0} tracks and {1} sectors per track.", fheader.lastCylinder + 1, fheader.sectorsPerTrack); _imageInfo.Cylinders = (uint)fheader.lastCylinder + 1; @@ -77,7 +76,7 @@ public sealed partial class HdCopy false)); // build table of track offsets - for(int i = 0; i < _imageInfo.Cylinders * 2; i++) + for(var i = 0; i < _imageInfo.Cylinders * 2; i++) if(fheader.trackMap[i] == 0) _trackOffset[i] = -1; else @@ -86,16 +85,16 @@ public sealed partial class HdCopy if(currentOffset + 3 >= stream.Length) return ErrorNumber.InvalidArgument; - byte[] blkHeader = new byte[2]; + var blkHeader = new byte[2]; stream.Read(blkHeader, 0, 2); - short blkLength = BitConverter.ToInt16(blkHeader, 0); + var blkLength = BitConverter.ToInt16(blkHeader, 0); // assume block sizes are positive if(blkLength < 0) return ErrorNumber.InvalidArgument; - AaruConsole.DebugWriteLine("HDCP plugin", "Track {0} offset 0x{1:x8}, size={2:x4}", i, - currentOffset, blkLength); + AaruConsole.DebugWriteLine("HDCP plugin", "Track {0} offset 0x{1:x8}, size={2:x4}", i, currentOffset, + blkLength); _trackOffset[i] = currentOffset; @@ -120,8 +119,8 @@ public sealed partial class HdCopy public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) { buffer = null; - int trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); - int sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); + var trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); + var sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -144,8 +143,7 @@ public sealed partial class HdCopy return errno; } - Array.Copy(_trackCache[trackNum], sectorOffset * _imageInfo.SectorSize, buffer, 0, - _imageInfo.SectorSize); + Array.Copy(_trackCache[trackNum], sectorOffset * _imageInfo.SectorSize, buffer, 0, _imageInfo.SectorSize); } return ErrorNumber.NoError; diff --git a/Aaru.Images/HDCopy/Structs.cs b/Aaru.Images/HDCopy/Structs.cs index f784108ee..5b5ce9e07 100644 --- a/Aaru.Images/HDCopy/Structs.cs +++ b/Aaru.Images/HDCopy/Structs.cs @@ -31,11 +31,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class HdCopy { diff --git a/Aaru.Images/HDCopy/Unsupported.cs b/Aaru.Images/HDCopy/Unsupported.cs index 9ef0e4424..a8ee6d24c 100644 --- a/Aaru.Images/HDCopy/Unsupported.cs +++ b/Aaru.Images/HDCopy/Unsupported.cs @@ -31,10 +31,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class HdCopy { /// diff --git a/Aaru.Images/IMD/Constants.cs b/Aaru.Images/IMD/Constants.cs index 4da544fb6..dc069df0b 100644 --- a/Aaru.Images/IMD/Constants.cs +++ b/Aaru.Images/IMD/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Imd { diff --git a/Aaru.Images/IMD/Enums.cs b/Aaru.Images/IMD/Enums.cs index 893e5b28d..30219c7a1 100644 --- a/Aaru.Images/IMD/Enums.cs +++ b/Aaru.Images/IMD/Enums.cs @@ -52,8 +52,14 @@ public sealed partial class Imd enum SectorType : byte { - Unavailable = 0, Normal = 1, Compressed = 2, - Deleted = 3, CompressedDeleted = 4, Error = 5, - CompressedError = 6, DeletedError = 7, CompressedDeletedError = 8 + Unavailable = 0, + Normal = 1, + Compressed = 2, + Deleted = 3, + CompressedDeleted = 4, + Error = 5, + CompressedError = 6, + DeletedError = 7, + CompressedDeletedError = 8 } } \ No newline at end of file diff --git a/Aaru.Images/IMD/IMD.cs b/Aaru.Images/IMD/IMD.cs index 1b4f98e24..07553ea4b 100644 --- a/Aaru.Images/IMD/IMD.cs +++ b/Aaru.Images/IMD/IMD.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading IMageDisk disk images public sealed partial class Imd : IMediaImage diff --git a/Aaru.Images/IMD/Identify.cs b/Aaru.Images/IMD/Identify.cs index 67bad2e03..ce72efb28 100644 --- a/Aaru.Images/IMD/Identify.cs +++ b/Aaru.Images/IMD/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Imd { /// @@ -49,7 +49,7 @@ public sealed partial class Imd if(stream.Length < 4) return false; - byte[] hdr = new byte[stream.Length < 256 ? stream.Length : 256]; + var hdr = new byte[stream.Length < 256 ? stream.Length : 256]; stream.Read(hdr, 0, hdr.Length); string hdrStr = StringHandlers.CToString(hdr, Encoding.ASCII); diff --git a/Aaru.Images/IMD/Properties.cs b/Aaru.Images/IMD/Properties.cs index 9bb57abbe..c05a3a006 100644 --- a/Aaru.Images/IMD/Properties.cs +++ b/Aaru.Images/IMD/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Imd { /// public string Name => "Dunfield's IMD"; /// - public Guid Id => new Guid("0D67162E-38A3-407D-9B1A-CF40080A48CB"); + public Guid Id => new("0D67162E-38A3-407D-9B1A-CF40080A48CB"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/IMD/Read.cs b/Aaru.Images/IMD/Read.cs index 39f6c0789..dbdaa7e3d 100644 --- a/Aaru.Images/IMD/Read.cs +++ b/Aaru.Images/IMD/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Imd { /// @@ -54,7 +54,7 @@ public sealed partial class Imd for(uint i = 0; i < stream.Length; i++) { - byte b = (byte)stream.ReadByte(); + var b = (byte)stream.ReadByte(); if(b == 0x1A) break; @@ -75,14 +75,14 @@ public sealed partial class Imd while(stream.Position + 5 < stream.Length) { mode = (TransferRate)stream.ReadByte(); - byte cylinder = (byte)stream.ReadByte(); - byte head = (byte)stream.ReadByte(); - byte spt = (byte)stream.ReadByte(); - byte n = (byte)stream.ReadByte(); - byte[] idmap = new byte[spt]; - byte[] cylmap = new byte[spt]; - byte[] headmap = new byte[spt]; - ushort[] bps = new ushort[spt]; + var cylinder = (byte)stream.ReadByte(); + var head = (byte)stream.ReadByte(); + var spt = (byte)stream.ReadByte(); + var n = (byte)stream.ReadByte(); + var idmap = new byte[spt]; + var cylmap = new byte[spt]; + var headmap = new byte[spt]; + var bps = new ushort[spt]; if(cylinder != currentCylinder) { @@ -103,14 +103,14 @@ public sealed partial class Imd if(n == 0xFF) { - byte[] bpsbytes = new byte[spt * 2]; + var bpsbytes = new byte[spt * 2]; stream.Read(bpsbytes, 0, bpsbytes.Length); - for(int i = 0; i < spt; i++) + for(var i = 0; i < spt; i++) bps[i] = BitConverter.ToUInt16(bpsbytes, i * 2); } else - for(int i = 0; i < spt; i++) + for(var i = 0; i < spt; i++) bps[i] = (ushort)(128 << n); if(spt > _imageInfo.SectorsPerTrack) @@ -118,10 +118,10 @@ public sealed partial class Imd SortedDictionary track = new(); - for(int i = 0; i < spt; i++) + for(var i = 0; i < spt; i++) { - var type = (SectorType)stream.ReadByte(); - byte[] data = new byte[bps[i]]; + var type = (SectorType)stream.ReadByte(); + var data = new byte[bps[i]]; // TODO; Handle disks with different bps in track 0 if(bps[i] > _imageInfo.SectorSize) @@ -150,7 +150,7 @@ public sealed partial class Imd case SectorType.CompressedDeleted: case SectorType.CompressedError: case SectorType.CompressedDeletedError: - byte filling = (byte)stream.ReadByte(); + var filling = (byte)stream.ReadByte(); ArrayHelpers.ArrayFill(data, filling); if(!track.ContainsKey(idmap[i])) @@ -219,8 +219,7 @@ public sealed partial class Imd } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -235,7 +234,7 @@ public sealed partial class Imd var ms = new MemoryStream(); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) ms.Write(_sectorsData[(int)sectorAddress + i], 0, _sectorsData[(int)sectorAddress + i].Length); buffer = ms.ToArray(); diff --git a/Aaru.Images/IMD/Unsupported.cs b/Aaru.Images/IMD/Unsupported.cs index 3b2e1e436..e1c0402ba 100644 --- a/Aaru.Images/IMD/Unsupported.cs +++ b/Aaru.Images/IMD/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Imd { /// diff --git a/Aaru.Images/KryoFlux/Constants.cs b/Aaru.Images/KryoFlux/Constants.cs index e0fbbee95..6d7cfe611 100644 --- a/Aaru.Images/KryoFlux/Constants.cs +++ b/Aaru.Images/KryoFlux/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class KryoFlux { diff --git a/Aaru.Images/KryoFlux/Enums.cs b/Aaru.Images/KryoFlux/Enums.cs index f2cfdb893..65914716c 100644 --- a/Aaru.Images/KryoFlux/Enums.cs +++ b/Aaru.Images/KryoFlux/Enums.cs @@ -30,26 +30,39 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class KryoFlux { [SuppressMessage("ReSharper", "InconsistentNaming")] enum BlockIds : byte { - Flux2 = 0x00, Flux2_1 = 0x01, Flux2_2 = 0x02, - Flux2_3 = 0x03, Flux2_4 = 0x04, Flux2_5 = 0x05, - Flux2_6 = 0x06, Flux2_7 = 0x07, Nop1 = 0x08, - Nop2 = 0x09, Nop3 = 0x0A, Ovl16 = 0x0B, - Flux3 = 0x0C, Oob = 0x0D + Flux2 = 0x00, + Flux2_1 = 0x01, + Flux2_2 = 0x02, + Flux2_3 = 0x03, + Flux2_4 = 0x04, + Flux2_5 = 0x05, + Flux2_6 = 0x06, + Flux2_7 = 0x07, + Nop1 = 0x08, + Nop2 = 0x09, + Nop3 = 0x0A, + Ovl16 = 0x0B, + Flux3 = 0x0C, + Oob = 0x0D } enum OobTypes : byte { - Invalid = 0x00, StreamInfo = 0x01, Index = 0x02, - StreamEnd = 0x03, KFInfo = 0x04, EOF = 0x0D + Invalid = 0x00, + StreamInfo = 0x01, + Index = 0x02, + StreamEnd = 0x03, + KFInfo = 0x04, + EOF = 0x0D } } \ No newline at end of file diff --git a/Aaru.Images/KryoFlux/Identify.cs b/Aaru.Images/KryoFlux/Identify.cs index 29043b3af..159c1ec74 100644 --- a/Aaru.Images/KryoFlux/Identify.cs +++ b/Aaru.Images/KryoFlux/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class KryoFlux { /// @@ -47,7 +47,7 @@ public sealed partial class KryoFlux if(stream.Length < Marshal.SizeOf()) return false; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.Read(hdr, 0, Marshal.SizeOf()); OobBlock header = Marshal.ByteArrayToStructureLittleEndian(hdr); diff --git a/Aaru.Images/KryoFlux/KryoFlux.cs b/Aaru.Images/KryoFlux/KryoFlux.cs index 408f67868..51cfb471e 100644 --- a/Aaru.Images/KryoFlux/KryoFlux.cs +++ b/Aaru.Images/KryoFlux/KryoFlux.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading KryoFlux flux images [SuppressMessage("ReSharper", "InconsistentNaming")] public sealed partial class KryoFlux : IMediaImage, IVerifiableSectorsImage diff --git a/Aaru.Images/KryoFlux/Properties.cs b/Aaru.Images/KryoFlux/Properties.cs index dce4967ed..9df7ba75c 100644 --- a/Aaru.Images/KryoFlux/Properties.cs +++ b/Aaru.Images/KryoFlux/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class KryoFlux { ImageInfo _imageInfo; @@ -47,7 +47,7 @@ public sealed partial class KryoFlux /// public string Name => "KryoFlux STREAM"; /// - public Guid Id => new Guid("4DBC95E4-93EE-4F7A-9492-919887E60EFE"); + public Guid Id => new("4DBC95E4-93EE-4F7A-9492-919887E60EFE"); /// public string Format => "KryoFlux STREAM"; /// diff --git a/Aaru.Images/KryoFlux/Read.cs b/Aaru.Images/KryoFlux/Read.cs index c2791b3c3..bb1a4c21f 100644 --- a/Aaru.Images/KryoFlux/Read.cs +++ b/Aaru.Images/KryoFlux/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Globalization; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Filters; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class KryoFlux { /// @@ -54,7 +54,7 @@ public sealed partial class KryoFlux if(stream.Length < Marshal.SizeOf()) return ErrorNumber.InvalidArgument; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.Read(hdr, 0, Marshal.SizeOf()); OobBlock header = Marshal.ByteArrayToStructureLittleEndian(hdr); @@ -77,7 +77,7 @@ public sealed partial class KryoFlux tracks = new SortedDictionary(); byte step = 1; byte heads = 2; - bool topHead = false; + var topHead = false; string basename = Path.Combine(imageFilter.ParentFolder, imageFilter.Filename.Substring(0, imageFilter.Filename.Length - 8)); @@ -138,7 +138,7 @@ public sealed partial class KryoFlux while(trackStream.Position < trackStream.Length) { - byte blockId = (byte)trackStream.ReadByte(); + var blockId = (byte)trackStream.ReadByte(); switch(blockId) { @@ -146,7 +146,7 @@ public sealed partial class KryoFlux { trackStream.Position--; - byte[] oob = new byte[Marshal.SizeOf()]; + var oob = new byte[Marshal.SizeOf()]; trackStream.Read(oob, 0, Marshal.SizeOf()); OobBlock oobBlk = Marshal.ByteArrayToStructureLittleEndian(oob); @@ -165,7 +165,7 @@ public sealed partial class KryoFlux break; } - byte[] kfinfo = new byte[oobBlk.length]; + var kfinfo = new byte[oobBlk.length]; trackStream.Read(kfinfo, 0, oobBlk.length); string kfinfoStr = StringHandlers.CToString(kfinfo); @@ -176,7 +176,7 @@ public sealed partial class KryoFlux DateTime blockDate = DateTime.Now; DateTime blockTime = DateTime.Now; - bool foundDate = false; + var foundDate = false; foreach(string[] kvp in lines.Select(line => line.Split('=')).Where(kvp => kvp.Length == 2)) { @@ -265,8 +265,7 @@ public sealed partial class KryoFlux } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => diff --git a/Aaru.Images/KryoFlux/Structs.cs b/Aaru.Images/KryoFlux/Structs.cs index 43c014bcf..e0eb7c375 100644 --- a/Aaru.Images/KryoFlux/Structs.cs +++ b/Aaru.Images/KryoFlux/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class KryoFlux { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/KryoFlux/Verify.cs b/Aaru.Images/KryoFlux/Verify.cs index 0385d1acf..716292114 100644 --- a/Aaru.Images/KryoFlux/Verify.cs +++ b/Aaru.Images/KryoFlux/Verify.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; -namespace Aaru.DiscImages; - public sealed partial class KryoFlux { /// diff --git a/Aaru.Images/MaxiDisk/Enums.cs b/Aaru.Images/MaxiDisk/Enums.cs index 7d75d6569..71805aebd 100644 --- a/Aaru.Images/MaxiDisk/Enums.cs +++ b/Aaru.Images/MaxiDisk/Enums.cs @@ -30,18 +30,26 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class MaxiDisk { enum HdkDiskTypes : byte { - Dos360 = 0, Maxi420 = 1, Dos720 = 2, - Maxi800 = 3, Dos1200 = 4, Maxi1400 = 5, - Dos1440 = 6, Mac1440 = 7, Maxi1600 = 8, - Dmf = 9, Dos2880 = 10, Maxi3200 = 11 + Dos360 = 0, + Maxi420 = 1, + Dos720 = 2, + Maxi800 = 3, + Dos1200 = 4, + Maxi1400 = 5, + Dos1440 = 6, + Mac1440 = 7, + Maxi1600 = 8, + Dmf = 9, + Dos2880 = 10, + Maxi3200 = 11 } } \ No newline at end of file diff --git a/Aaru.Images/MaxiDisk/Identify.cs b/Aaru.Images/MaxiDisk/Identify.cs index 1235bc0d9..0a3773291 100644 --- a/Aaru.Images/MaxiDisk/Identify.cs +++ b/Aaru.Images/MaxiDisk/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class MaxiDisk { /// @@ -47,7 +47,7 @@ public sealed partial class MaxiDisk if(stream.Length < 8) return false; - byte[] buffer = new byte[8]; + var buffer = new byte[8]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); @@ -59,8 +59,7 @@ public sealed partial class MaxiDisk AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.cylinders = {0}", tmpHeader.cylinders); AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.bytesPerSector = {0}", tmpHeader.bytesPerSector); - AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.sectorsPerTrack = {0}", - tmpHeader.sectorsPerTrack); + AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.sectorsPerTrack = {0}", tmpHeader.sectorsPerTrack); AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown2 = {0}", tmpHeader.unknown2); AaruConsole.DebugWriteLine("MAXI Disk plugin", "tmp_header.unknown3 = {0}", tmpHeader.unknown3); @@ -83,8 +82,8 @@ public sealed partial class MaxiDisk if(tmpHeader.bytesPerSector > 7) return false; - int expectedFileSize = (tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack * - (128 << tmpHeader.bytesPerSector)) + 8; + int expectedFileSize = tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack * + (128 << tmpHeader.bytesPerSector) + 8; return expectedFileSize == stream.Length; } diff --git a/Aaru.Images/MaxiDisk/MaxiDisk.cs b/Aaru.Images/MaxiDisk/MaxiDisk.cs index 67041e751..0651d9e91 100644 --- a/Aaru.Images/MaxiDisk/MaxiDisk.cs +++ b/Aaru.Images/MaxiDisk/MaxiDisk.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing MaxiDisk disk images public sealed partial class MaxiDisk : IWritableImage diff --git a/Aaru.Images/MaxiDisk/Properties.cs b/Aaru.Images/MaxiDisk/Properties.cs index 1a9ecd005..e082b05c5 100644 --- a/Aaru.Images/MaxiDisk/Properties.cs +++ b/Aaru.Images/MaxiDisk/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class MaxiDisk { /// @@ -48,7 +48,7 @@ public sealed partial class MaxiDisk /// public string Name => "MAXI Disk image"; /// - public Guid Id => new Guid("D27D924A-7034-466E-ADE1-B81EF37E469E"); + public Guid Id => new("D27D924A-7034-466E-ADE1-B81EF37E469E"); /// public string Format => "MAXI Disk"; /// diff --git a/Aaru.Images/MaxiDisk/Read.cs b/Aaru.Images/MaxiDisk/Read.cs index 4d0a46383..1b125e44a 100644 --- a/Aaru.Images/MaxiDisk/Read.cs +++ b/Aaru.Images/MaxiDisk/Read.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class MaxiDisk { /// @@ -48,7 +48,7 @@ public sealed partial class MaxiDisk if(stream.Length < 8) return ErrorNumber.InvalidArgument; - byte[] buffer = new byte[8]; + var buffer = new byte[8]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); @@ -72,8 +72,8 @@ public sealed partial class MaxiDisk if(tmpHeader.bytesPerSector > 7) return ErrorNumber.InvalidArgument; - int expectedFileSize = (tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack * - (128 << tmpHeader.bytesPerSector)) + 8; + int expectedFileSize = tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack * + (128 << tmpHeader.bytesPerSector) + 8; if(expectedFileSize != stream.Length) return ErrorNumber.InvalidArgument; @@ -100,8 +100,7 @@ public sealed partial class MaxiDisk } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -117,7 +116,7 @@ public sealed partial class MaxiDisk buffer = new byte[length * _imageInfo.SectorSize]; Stream stream = _hdkImageFilter.GetDataForkStream(); - stream.Seek((long)(8 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(8 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return ErrorNumber.NoError; diff --git a/Aaru.Images/MaxiDisk/Structs.cs b/Aaru.Images/MaxiDisk/Structs.cs index f8d40a4f6..a7298e54e 100644 --- a/Aaru.Images/MaxiDisk/Structs.cs +++ b/Aaru.Images/MaxiDisk/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class MaxiDisk { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/MaxiDisk/Unsupported.cs b/Aaru.Images/MaxiDisk/Unsupported.cs index 497c0e06c..e35bc9a7f 100644 --- a/Aaru.Images/MaxiDisk/Unsupported.cs +++ b/Aaru.Images/MaxiDisk/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class MaxiDisk { /// diff --git a/Aaru.Images/MaxiDisk/Write.cs b/Aaru.Images/MaxiDisk/Write.cs index 15fd668c2..553af2446 100644 --- a/Aaru.Images/MaxiDisk/Write.cs +++ b/Aaru.Images/MaxiDisk/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class MaxiDisk { /// @@ -146,7 +146,7 @@ public sealed partial class MaxiDisk return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -180,7 +180,7 @@ public sealed partial class MaxiDisk return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -230,7 +230,7 @@ public sealed partial class MaxiDisk i >>= 1; } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/NDIF/Constants.cs b/Aaru.Images/NDIF/Constants.cs index 85f3a1fb8..189106f1a 100644 --- a/Aaru.Images/NDIF/Constants.cs +++ b/Aaru.Images/NDIF/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Ndif { diff --git a/Aaru.Images/NDIF/Identify.cs b/Aaru.Images/NDIF/Identify.cs index c2a152376..cd1d86a2c 100644 --- a/Aaru.Images/NDIF/Identify.cs +++ b/Aaru.Images/NDIF/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; using Claunia.RsrcFork; -namespace Aaru.DiscImages; - public sealed partial class Ndif { /// @@ -56,7 +56,7 @@ public sealed partial class Ndif Resource rsrc = rsrcFork.GetResource(NDIF_RESOURCE); Stream dataFork = imageFilter.GetDataForkStream(); - byte[] udifMagic = new byte[4]; + var udifMagic = new byte[4]; dataFork.Read(udifMagic, 0, 4); if(BitConverter.ToUInt32(udifMagic, 0) == 0x796C6F6B) diff --git a/Aaru.Images/NDIF/NDIF.cs b/Aaru.Images/NDIF/NDIF.cs index 734575ebc..f1e56fe39 100644 --- a/Aaru.Images/NDIF/NDIF.cs +++ b/Aaru.Images/NDIF/NDIF.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Detect OS X encrypted images // TODO: Check checksum // TODO: Implement segments diff --git a/Aaru.Images/NDIF/Properties.cs b/Aaru.Images/NDIF/Properties.cs index 725f2dae2..931b7f6cf 100644 --- a/Aaru.Images/NDIF/Properties.cs +++ b/Aaru.Images/NDIF/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Ndif { /// @@ -44,7 +44,7 @@ public sealed partial class Ndif /// public string Name => "Apple New Disk Image Format"; /// - public Guid Id => new Guid("5A7FF7D8-491E-458D-8674-5B5EADBECC24"); + public Guid Id => new("5A7FF7D8-491E-458D-8674-5B5EADBECC24"); /// public string Format => "Apple New Disk Image Format"; /// diff --git a/Aaru.Images/NDIF/Read.cs b/Aaru.Images/NDIF/Read.cs index 2ff270198..e15797234 100644 --- a/Aaru.Images/NDIF/Read.cs +++ b/Aaru.Images/NDIF/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -44,8 +46,6 @@ using Claunia.Encoding; using Claunia.RsrcFork; using Version = Resources.Version; -namespace Aaru.DiscImages; - public sealed partial class Ndif { /// @@ -95,13 +95,11 @@ public sealed partial class Ndif AaruConsole.DebugWriteLine("NDIF plugin", "footer.driver = {0}", _header.driver); AaruConsole.DebugWriteLine("NDIF plugin", "footer.name = {0}", - StringHandlers.PascalToString(_header.name, - Encoding.GetEncoding("macintosh"))); + StringHandlers.PascalToString(_header.name, Encoding.GetEncoding("macintosh"))); AaruConsole.DebugWriteLine("NDIF plugin", "footer.sectors = {0}", _header.sectors); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.maxSectorsPerChunk = {0}", - _header.maxSectorsPerChunk); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.maxSectorsPerChunk = {0}", _header.maxSectorsPerChunk); AaruConsole.DebugWriteLine("NDIF plugin", "footer.dataOffset = {0}", _header.dataOffset); AaruConsole.DebugWriteLine("NDIF plugin", "footer.crc = 0x{0:X7}", _header.crc); @@ -120,17 +118,17 @@ public sealed partial class Ndif // Block chunks and headers _chunks = new Dictionary(); - for(int i = 0; i < _header.chunks; i++) + for(var i = 0; i < _header.chunks; i++) { // Obsolete read-only NDIF only prepended the header and then put the image without any kind of block references. // So let's falsify a block chunk - var bChnk = new BlockChunk(); - byte[] sector = new byte[4]; - Array.Copy(bcem, 128 + 0 + (i * 12), sector, 1, 3); + var bChnk = new BlockChunk(); + var sector = new byte[4]; + Array.Copy(bcem, 128 + 0 + i * 12, sector, 1, 3); bChnk.sector = BigEndianBitConverter.ToUInt32(sector, 0); - bChnk.type = bcem[128 + 3 + (i * 12)]; - bChnk.offset = BigEndianBitConverter.ToUInt32(bcem, 128 + 4 + (i * 12)); - bChnk.length = BigEndianBitConverter.ToUInt32(bcem, 128 + 8 + (i * 12)); + bChnk.type = bcem[128 + 3 + i * 12]; + bChnk.offset = BigEndianBitConverter.ToUInt32(bcem, 128 + 4 + i * 12); + bChnk.length = BigEndianBitConverter.ToUInt32(bcem, 128 + 8 + i * 12); AaruConsole.DebugWriteLine("NDIF plugin", "bHdr.chunk[{0}].type = 0x{1:X2}", i, bChnk.type); AaruConsole.DebugWriteLine("NDIF plugin", "bHdr.chunk[{0}].sector = {1}", i, bChnk.sector); @@ -161,9 +159,9 @@ public sealed partial class Ndif } // TODO: Handle compressed chunks - if((bChnk.type > CHUNK_TYPE_COPY && bChnk.type < CHUNK_TYPE_KENCODE) || - (bChnk.type > CHUNK_TYPE_ADC && bChnk.type < CHUNK_TYPE_STUFFIT) || - (bChnk.type > CHUNK_TYPE_STUFFIT && bChnk.type < CHUNK_TYPE_END) || + if(bChnk.type > CHUNK_TYPE_COPY && bChnk.type < CHUNK_TYPE_KENCODE || + bChnk.type > CHUNK_TYPE_ADC && bChnk.type < CHUNK_TYPE_STUFFIT || + bChnk.type > CHUNK_TYPE_STUFFIT && bChnk.type < CHUNK_TYPE_END || bChnk.type == 1) { AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found"); @@ -339,7 +337,7 @@ public sealed partial class Ndif return ErrorNumber.NoError; var currentChunk = new BlockChunk(); - bool chunkFound = false; + var chunkFound = false; ulong chunkStartSector = 0; foreach(KeyValuePair kvp in _chunks.Where(kvp => sectorAddress >= kvp.Key)) @@ -361,7 +359,7 @@ public sealed partial class Ndif { if(!_chunkCache.TryGetValue(chunkStartSector, out byte[] data)) { - byte[] cmpBuffer = new byte[currentChunk.length]; + var cmpBuffer = new byte[currentChunk.length]; _imageStream.Seek(currentChunk.offset, SeekOrigin.Begin); _imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); var cmpMs = new MemoryStream(cmpBuffer); @@ -371,7 +369,7 @@ public sealed partial class Ndif { case CHUNK_TYPE_ADC: { - byte[] tmpBuffer = new byte[_bufferSize]; + var tmpBuffer = new byte[_bufferSize]; realSize = ADC.DecodeBuffer(cmpBuffer, tmpBuffer); data = new byte[realSize]; Array.Copy(tmpBuffer, 0, data, 0, realSize); @@ -381,7 +379,7 @@ public sealed partial class Ndif case CHUNK_TYPE_RLE: { - byte[] tmpBuffer = new byte[_bufferSize]; + var tmpBuffer = new byte[_bufferSize]; realSize = AppleRle.DecodeBuffer(cmpBuffer, tmpBuffer); data = new byte[realSize]; Array.Copy(tmpBuffer, 0, data, 0, realSize); diff --git a/Aaru.Images/NDIF/Structs.cs b/Aaru.Images/NDIF/Structs.cs index ed0ba53f9..ab526f70a 100644 --- a/Aaru.Images/NDIF/Structs.cs +++ b/Aaru.Images/NDIF/Structs.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class Ndif { diff --git a/Aaru.Images/NDIF/Unsupported.cs b/Aaru.Images/NDIF/Unsupported.cs index 8ad9f711d..1e125d054 100644 --- a/Aaru.Images/NDIF/Unsupported.cs +++ b/Aaru.Images/NDIF/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Ndif { /// diff --git a/Aaru.Images/NHDr0/Identify.cs b/Aaru.Images/NHDr0/Identify.cs index 348324888..d35de626a 100644 --- a/Aaru.Images/NHDr0/Identify.cs +++ b/Aaru.Images/NHDr0/Identify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using System.Text; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Nhdr0 { /// @@ -53,7 +53,7 @@ public sealed partial class Nhdr0 if(stream.Length < Marshal.SizeOf
()) return false; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); _nhdhdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); diff --git a/Aaru.Images/NHDr0/NHDr0.cs b/Aaru.Images/NHDr0/NHDr0.cs index 48fd7510c..5703115b4 100644 --- a/Aaru.Images/NHDr0/NHDr0.cs +++ b/Aaru.Images/NHDr0/NHDr0.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // Info from http://www.geocities.jp/t98next/nhdr0.txt /// /// Implements reading and writing T98-Next disk images diff --git a/Aaru.Images/NHDr0/Properties.cs b/Aaru.Images/NHDr0/Properties.cs index 357f9016d..738bd8f7c 100644 --- a/Aaru.Images/NHDr0/Properties.cs +++ b/Aaru.Images/NHDr0/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Nhdr0 { /// public string Name => "T98-Next NHD r0 Disk Image"; /// - public Guid Id => new Guid("6ECACD0A-8F4D-4465-8815-AEA000D370E3"); + public Guid Id => new("6ECACD0A-8F4D-4465-8815-AEA000D370E3"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/NHDr0/Read.cs b/Aaru.Images/NHDr0/Read.cs index 051186620..ab71b7777 100644 --- a/Aaru.Images/NHDr0/Read.cs +++ b/Aaru.Images/NHDr0/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Nhdr0 { /// @@ -53,7 +53,7 @@ public sealed partial class Nhdr0 if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); _nhdhdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); @@ -78,8 +78,7 @@ public sealed partial class Nhdr0 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -96,7 +95,7 @@ public sealed partial class Nhdr0 Stream stream = _nhdImageFilter.GetDataForkStream(); - stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); diff --git a/Aaru.Images/NHDr0/Structs.cs b/Aaru.Images/NHDr0/Structs.cs index db61fe078..dbaa8590f 100644 --- a/Aaru.Images/NHDr0/Structs.cs +++ b/Aaru.Images/NHDr0/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Nhdr0 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/NHDr0/Unsupported.cs b/Aaru.Images/NHDr0/Unsupported.cs index 0b3b5fc14..1399d8656 100644 --- a/Aaru.Images/NHDr0/Unsupported.cs +++ b/Aaru.Images/NHDr0/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Nhdr0 { /// diff --git a/Aaru.Images/NHDr0/Write.cs b/Aaru.Images/NHDr0/Write.cs index 018f511c2..b409fc687 100644 --- a/Aaru.Images/NHDr0/Write.cs +++ b/Aaru.Images/NHDr0/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Nhdr0 { /// @@ -119,7 +119,7 @@ public sealed partial class Nhdr0 return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -153,7 +153,7 @@ public sealed partial class Nhdr0 return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -235,7 +235,7 @@ public sealed partial class Nhdr0 commentBytes.Length >= 0x100 ? 0x100 : commentBytes.Length); } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/Nero/Enums.cs b/Aaru.Images/Nero/Enums.cs index f47ba0982..433776123 100644 --- a/Aaru.Images/Nero/Enums.cs +++ b/Aaru.Images/Nero/Enums.cs @@ -30,19 +30,25 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Diagnostics.CodeAnalysis; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Nero { enum DaoMode : ushort { - Data = 0x0000, DataM2F1 = 0x0002, DataM2F2 = 0x0003, - DataRaw = 0x0005, DataM2Raw = 0x0006, Audio = 0x0007, - AudioAlt = 0x0008, DataRawSub = 0x000F, AudioSub = 0x0010, + Data = 0x0000, + DataM2F1 = 0x0002, + DataM2F2 = 0x0003, + DataRaw = 0x0005, + DataM2Raw = 0x0006, + Audio = 0x0007, + AudioAlt = 0x0008, + DataRawSub = 0x000F, + AudioSub = 0x0010, DataM2RawSub = 0x0011 } diff --git a/Aaru.Images/Nero/Helpers.cs b/Aaru.Images/Nero/Helpers.cs index bc36c02b5..62f531df8 100644 --- a/Aaru.Images/Nero/Helpers.cs +++ b/Aaru.Images/Nero/Helpers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Nero { static CommonTypes.MediaType NeroMediaTypeToMediaType(NeroMediaTypes type) diff --git a/Aaru.Images/Nero/Identify.cs b/Aaru.Images/Nero/Identify.cs index af194f593..1ef7ca83b 100644 --- a/Aaru.Images/Nero/Identify.cs +++ b/Aaru.Images/Nero/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Nero { /// @@ -47,7 +47,7 @@ public sealed partial class Nero var footerV2 = new FooterV2(); _imageStream.Seek(-8, SeekOrigin.End); - byte[] buffer = new byte[8]; + var buffer = new byte[8]; _imageStream.Read(buffer, 0, 8); footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4); diff --git a/Aaru.Images/Nero/Nero.cs b/Aaru.Images/Nero/Nero.cs index b793840bd..97954e08c 100644 --- a/Aaru.Images/Nero/Nero.cs +++ b/Aaru.Images/Nero/Nero.cs @@ -30,6 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +#pragma warning disable 414 +#pragma warning disable 169 + +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -39,15 +44,9 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Decoders.CD; -#pragma warning disable 414 -#pragma warning disable 169 - -namespace Aaru.DiscImages; - /// /// Implements reading Nero Burning ROM disc images -[SuppressMessage("ReSharper", "NotAccessedField.Local"), - SuppressMessage("ReSharper", "CollectionNeverQueried.Local")] +[SuppressMessage("ReSharper", "NotAccessedField.Local"), SuppressMessage("ReSharper", "CollectionNeverQueried.Local")] public sealed partial class Nero : IOpticalMediaImage { bool _imageNewFormat; diff --git a/Aaru.Images/Nero/Properties.cs b/Aaru.Images/Nero/Properties.cs index 3e17995a6..85ef2fb87 100644 --- a/Aaru.Images/Nero/Properties.cs +++ b/Aaru.Images/Nero/Properties.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Nero { /// @@ -45,7 +45,7 @@ public sealed partial class Nero /// public string Name => "Nero Burning ROM image"; /// - public Guid Id => new Guid("D160F9FF-5941-43FC-B037-AD81DD141F05"); + public Guid Id => new("D160F9FF-5941-43FC-B037-AD81DD141F05"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/Nero/Read.cs b/Aaru.Images/Nero/Read.cs index 01861179d..be410380f 100644 --- a/Aaru.Images/Nero/Read.cs +++ b/Aaru.Images/Nero/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Decoders.CD; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Nero { /// @@ -58,7 +58,7 @@ public sealed partial class Nero var footerV2 = new FooterV2(); _imageStream.Seek(-8, SeekOrigin.End); - byte[] buffer = new byte[8]; + var buffer = new byte[8]; _imageStream.Read(buffer, 0, 8); footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4); @@ -101,7 +101,7 @@ public sealed partial class Nero else _imageStream.Seek(footerV1.FirstChunkOffset, SeekOrigin.Begin); - bool parsing = true; + var parsing = true; ushort currentSession = 1; uint currentTrack = 1; @@ -111,18 +111,18 @@ public sealed partial class Nero _imageInfo.MediaType = CommonTypes.MediaType.CD; _imageInfo.Sectors = 0; _imageInfo.SectorSize = 0; - bool oldFormat = false; - int currentLba = -150; - bool corruptedTrackMode = false; + var oldFormat = false; + int currentLba = -150; + var corruptedTrackMode = false; // Parse chunks while(parsing) { - byte[] chunkHeaderBuffer = new byte[8]; + var chunkHeaderBuffer = new byte[8]; _imageStream.Read(chunkHeaderBuffer, 0, 8); - uint chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0); - uint chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); + var chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0); + var chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); AaruConsole.DebugWriteLine("Nero plugin", "ChunkID = 0x{0:X8} (\"{1}\")", chunkId, Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); @@ -143,42 +143,42 @@ public sealed partial class Nero Entries = new List() }; - byte[] tmpBuffer = new byte[8]; + var tmpBuffer = new byte[8]; - for(int i = 0; i < newCuesheetV1.ChunkSize; i += 8) + for(var i = 0; i < newCuesheetV1.ChunkSize; i += 8) { var entry = new CueEntryV1(); _imageStream.Read(tmpBuffer, 0, 8); entry.Mode = tmpBuffer[0]; - entry.TrackNumber = (byte)((((tmpBuffer[1] & 0xF0) >> 4) * 10) + (tmpBuffer[1] & 0xF)); - entry.IndexNumber = (byte)((((tmpBuffer[2] & 0xF0) >> 4) * 10) + (tmpBuffer[2] & 0xF)); + entry.TrackNumber = (byte)(((tmpBuffer[1] & 0xF0) >> 4) * 10 + (tmpBuffer[1] & 0xF)); + entry.IndexNumber = (byte)(((tmpBuffer[2] & 0xF0) >> 4) * 10 + (tmpBuffer[2] & 0xF)); entry.Dummy = BigEndianBitConverter.ToUInt16(tmpBuffer, 3); - entry.Minute = (byte)((((tmpBuffer[5] & 0xF0) >> 4) * 10) + (tmpBuffer[5] & 0xF)); - entry.Second = (byte)((((tmpBuffer[6] & 0xF0) >> 4) * 10) + (tmpBuffer[6] & 0xF)); - entry.Frame = (byte)((((tmpBuffer[7] & 0xF0) >> 4) * 10) + (tmpBuffer[7] & 0xF)); + entry.Minute = (byte)(((tmpBuffer[5] & 0xF0) >> 4) * 10 + (tmpBuffer[5] & 0xF)); + entry.Second = (byte)(((tmpBuffer[6] & 0xF0) >> 4) * 10 + (tmpBuffer[6] & 0xF)); + entry.Frame = (byte)(((tmpBuffer[7] & 0xF0) >> 4) * 10 + (tmpBuffer[7] & 0xF)); - AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1:X2}", i / 8 + 1, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", - (i / 8) + 1, entry.TrackNumber); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", i / 8 + 1, + entry.TrackNumber); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", - (i / 8) + 1, entry.IndexNumber); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", i / 8 + 1, + entry.IndexNumber); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X4}", i / 8 + 1, entry.Dummy); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Minute = {1:X2}", i / 8 + 1, entry.Minute); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Second = {1:X2}", i / 8 + 1, entry.Second); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Frame = {1:X2}", i / 8 + 1, entry.Frame); newCuesheetV1.Entries.Add(entry); @@ -204,33 +204,33 @@ public sealed partial class Nero Entries = new List() }; - byte[] tmpBuffer = new byte[8]; + var tmpBuffer = new byte[8]; - for(int i = 0; i < newCuesheetV2.ChunkSize; i += 8) + for(var i = 0; i < newCuesheetV2.ChunkSize; i += 8) { var entry = new CueEntryV2(); _imageStream.Read(tmpBuffer, 0, 8); entry.Mode = tmpBuffer[0]; - entry.TrackNumber = (byte)((((tmpBuffer[1] & 0xF0) >> 4) * 10) + (tmpBuffer[1] & 0xF)); - entry.IndexNumber = (byte)((((tmpBuffer[2] & 0xF0) >> 4) * 10) + (tmpBuffer[2] & 0xF)); + entry.TrackNumber = (byte)(((tmpBuffer[1] & 0xF0) >> 4) * 10 + (tmpBuffer[1] & 0xF)); + entry.IndexNumber = (byte)(((tmpBuffer[2] & 0xF0) >> 4) * 10 + (tmpBuffer[2] & 0xF)); entry.Dummy = tmpBuffer[3]; entry.LbaStart = BigEndianBitConverter.ToInt32(tmpBuffer, 4); - AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", (i / 8) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Cuesheet entry {0}", i / 8 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = 0x{1:X2}", i / 8 + 1, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", - (i / 8) + 1, entry.TrackNumber); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = {1:X2}", i / 8 + 1, + entry.TrackNumber); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", - (i / 8) + 1, entry.IndexNumber); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].IndexNumber = {1:X2}", i / 8 + 1, + entry.IndexNumber); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Dummy = {1:X2}", i / 8 + 1, entry.Dummy); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", (i / 8) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].LBAStart = {1}", i / 8 + 1, entry.LbaStart); newCuesheetV2.Entries.Add(entry); @@ -255,7 +255,7 @@ public sealed partial class Nero ChunkSizeBe = chunkLength }; - byte[] tmpBuffer = new byte[22]; + var tmpBuffer = new byte[22]; _imageStream.Read(tmpBuffer, 0, 22); _neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); _neroDaov1.Upc = new byte[14]; @@ -271,20 +271,17 @@ public sealed partial class Nero AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.UPC = \"{0}\"", StringHandlers.CToString(_neroDaov1.Upc)); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.TocType = 0x{0:X4}", - _neroDaov1.TocType); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.TocType = 0x{0:X4}", _neroDaov1.TocType); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.FirstTrack = {0}", - _neroDaov1.FirstTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.FirstTrack = {0}", _neroDaov1.FirstTrack); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", - _neroDaov1.LastTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", _neroDaov1.LastTrack); _upc = _neroDaov1.Upc; tmpBuffer = new byte[30]; - for(int i = 0; i < _neroDaov1.ChunkSizeBe - 22; i += 30) + for(var i = 0; i < _neroDaov1.ChunkSizeBe - 22; i += 30) { var entry = new DaoEntryV1(); _imageStream.Read(tmpBuffer, 0, 30); @@ -313,28 +310,28 @@ public sealed partial class Nero } } - AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1, StringHandlers.CToString(entry.Isrc)); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", - (i / 32) + 1, entry.SectorSize); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", i / 32 + 1, + entry.SectorSize); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 32) + 1, entry.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", i / 32 + 1, + entry.Unknown); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", - (i / 32) + 1, entry.EndOfTrack); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", i / 32 + 1, + entry.EndOfTrack); _neroDaov1.Tracks.Add(entry); @@ -374,7 +371,7 @@ public sealed partial class Nero ChunkSizeBe = chunkLength }; - byte[] tmpBuffer = new byte[22]; + var tmpBuffer = new byte[22]; _imageStream.Read(tmpBuffer, 0, 22); _neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); _neroDaov2.Upc = new byte[14]; @@ -392,18 +389,15 @@ public sealed partial class Nero AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.UPC = \"{0}\"", StringHandlers.CToString(_neroDaov2.Upc)); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.TocType = 0x{0:X4}", - _neroDaov2.TocType); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.TocType = 0x{0:X4}", _neroDaov2.TocType); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.FirstTrack = {0}", - _neroDaov2.FirstTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.FirstTrack = {0}", _neroDaov2.FirstTrack); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", - _neroDaov2.LastTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", _neroDaov2.LastTrack); tmpBuffer = new byte[42]; - for(int i = 0; i < _neroDaov2.ChunkSizeBe - 22; i += 42) + for(var i = 0; i < _neroDaov2.ChunkSizeBe - 22; i += 42) { var entry = new DaoEntryV2(); _imageStream.Read(tmpBuffer, 0, 42); @@ -432,28 +426,28 @@ public sealed partial class Nero } } - AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", (i / 32) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Disc-At-Once entry {0}", i / 32 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].ISRC = \"{1}\"", i / 32 + 1, StringHandlers.CToString(entry.Isrc)); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", - (i / 32) + 1, entry.SectorSize); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].SectorSize = {1}", i / 32 + 1, + entry.SectorSize); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = {1:X2}", - (i / 32) + 1, entry.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = {1:X2}", i / 32 + 1, + entry.Unknown); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index0 = {1}", i / 32 + 1, entry.Index0); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Index1 = {1}", i / 32 + 1, entry.Index1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", - (i / 32) + 1, entry.EndOfTrack); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", i / 32 + 1, + entry.EndOfTrack); _neroDaov2.Tracks.Add(entry); @@ -495,9 +489,9 @@ public sealed partial class Nero Packs = new List() }; - byte[] tmpBuffer = new byte[18]; + var tmpBuffer = new byte[18]; - for(int i = 0; i < _cdtxt.ChunkSize; i += 18) + for(var i = 0; i < _cdtxt.ChunkSize; i += 18) { var entry = new CdTextPack(); _imageStream.Read(tmpBuffer, 0, 18); @@ -510,24 +504,24 @@ public sealed partial class Nero Array.Copy(tmpBuffer, 4, entry.Text, 0, 12); entry.Crc = BigEndianBitConverter.ToUInt16(tmpBuffer, 16); - AaruConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", (i / 18) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "CD-TEXT entry {0}", i / 18 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackType = 0x{1:X2}", - (i / 18) + 1, entry.PackType); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackType = 0x{1:X2}", i / 18 + 1, + entry.PackType); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].TrackNumber = 0x{1:X2}", - (i / 18) + 1, entry.TrackNumber); + i / 18 + 1, entry.TrackNumber); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].PackNumber = 0x{1:X2}", - (i / 18) + 1, entry.PackNumber); + i / 18 + 1, entry.PackNumber); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].BlockNumber = 0x{1:X2}", - (i / 18) + 1, entry.BlockNumber); + i / 18 + 1, entry.BlockNumber); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", (i / 18) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Text = \"{1}\"", i / 18 + 1, StringHandlers.CToString(entry.Text)); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", (i / 18) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", i / 18 + 1, entry.Crc); _cdtxt.Packs.Add(entry); @@ -550,9 +544,9 @@ public sealed partial class Nero Tracks = new List() }; - byte[] tmpBuffer = new byte[12]; + var tmpBuffer = new byte[12]; - for(int i = 0; i < _taoV0.ChunkSize; i += 12) + for(var i = 0; i < _taoV0.ChunkSize; i += 12) { var entry = new TaoEntryV0(); _imageStream.Read(tmpBuffer, 0, 12); @@ -561,16 +555,16 @@ public sealed partial class Nero entry.Length = BigEndianBitConverter.ToUInt32(tmpBuffer, 4); entry.Mode = BigEndianBitConverter.ToUInt32(tmpBuffer, 8); - AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 20) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 20 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 20) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 20 + 1, entry.Offset); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", - (i / 20) + 1, entry.Length); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", i / 20 + 1, + entry.Length); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 20) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 20 + 1, (DaoMode)entry.Mode, entry.Mode); _taoV0.Tracks.Add(entry); @@ -613,9 +607,9 @@ public sealed partial class Nero Tracks = new List() }; - byte[] tmpBuffer = new byte[20]; + var tmpBuffer = new byte[20]; - for(int i = 0; i < _taoV1.ChunkSize; i += 20) + for(var i = 0; i < _taoV1.ChunkSize; i += 20) { var entry = new TaoEntryV1(); _imageStream.Read(tmpBuffer, 0, 20); @@ -626,22 +620,22 @@ public sealed partial class Nero entry.StartLba = BigEndianBitConverter.ToUInt32(tmpBuffer, 12); entry.Unknown = BigEndianBitConverter.ToUInt32(tmpBuffer, 16); - AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 20) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 20 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 20) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 20 + 1, entry.Offset); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", - (i / 20) + 1, entry.Length); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", i / 20 + 1, + entry.Length); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 20) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 20 + 1, (DaoMode)entry.Mode, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 20) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 20 + 1, entry.StartLba); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 20) + 1, entry.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", i / 20 + 1, + entry.Unknown); _taoV1.Tracks.Add(entry); @@ -683,9 +677,9 @@ public sealed partial class Nero Tracks = new List() }; - byte[] tmpBuffer = new byte[32]; + var tmpBuffer = new byte[32]; - for(int i = 0; i < _taoV2.ChunkSize; i += 32) + for(var i = 0; i < _taoV2.ChunkSize; i += 32) { var entry = new TaoEntryV2(); _imageStream.Read(tmpBuffer, 0, 32); @@ -697,24 +691,24 @@ public sealed partial class Nero entry.Unknown = BigEndianBitConverter.ToUInt32(tmpBuffer, 24); entry.Sectors = BigEndianBitConverter.ToUInt32(tmpBuffer, 28); - AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", (i / 32) + 1); + AaruConsole.DebugWriteLine("Nero plugin", "Track-at-Once entry {0}", i / 32 + 1); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Offset = {1}", i / 32 + 1, entry.Offset); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", - (i / 32) + 1, entry.Length); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Length = {1} bytes", i / 32 + 1, + entry.Length); AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Mode = {1} (0x{2:X4})", - (i / 32) + 1, (DaoMode)entry.Mode, entry.Mode); + i / 32 + 1, (DaoMode)entry.Mode, entry.Mode); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].StartLBA = {1}", i / 32 + 1, entry.StartLba); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", - (i / 32) + 1, entry.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", i / 32 + 1, + entry.Unknown); - AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", (i / 32) + 1, + AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", i / 32 + 1, entry.Sectors); _taoV2.Tracks.Add(entry); @@ -759,9 +753,9 @@ public sealed partial class Nero AaruConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes", chunkLength); - byte[] tmpBuffer = new byte[4]; + var tmpBuffer = new byte[4]; _imageStream.Read(tmpBuffer, 0, 4); - uint sessionTracks = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); + var sessionTracks = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); _neroSessions.Add(currentSession, sessionTracks); AaruConsole.DebugWriteLine("Nero plugin", "\tSession {0} has {1} tracks", currentSession, @@ -783,7 +777,7 @@ public sealed partial class Nero ChunkSize = chunkLength }; - byte[] tmpBuffer = new byte[4]; + var tmpBuffer = new byte[4]; _imageStream.Read(tmpBuffer, 0, 4); _mediaType.Type = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); @@ -806,7 +800,7 @@ public sealed partial class Nero ChunkSize = chunkLength }; - byte[] tmpBuffer = new byte[4]; + var tmpBuffer = new byte[4]; _imageStream.Read(tmpBuffer, 0, 4); _discInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); @@ -827,12 +821,11 @@ public sealed partial class Nero ChunkSize = chunkLength }; - byte[] tmpBuffer = new byte[4]; + var tmpBuffer = new byte[4]; _imageStream.Read(tmpBuffer, 0, 4); _relo.Unknown = BigEndianBitConverter.ToUInt32(tmpBuffer, 0); - AaruConsole.DebugWriteLine("Nero plugin", "\tneroRELO.Unknown = 0x{0:X4} ({0})", - _relo.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\tneroRELO.Unknown = 0x{0:X4} ({0})", _relo.Unknown); break; } @@ -848,7 +841,7 @@ public sealed partial class Nero ChunkSize = chunkLength }; - byte[] tmpBuffer = new byte[2]; + var tmpBuffer = new byte[2]; _imageStream.Read(tmpBuffer, 0, 2); _toc.Unknown = BigEndianBitConverter.ToUInt16(tmpBuffer, 0); @@ -868,8 +861,7 @@ public sealed partial class Nero break; } - AaruConsole.DebugWriteLine("Nero plugin", "\tneroTOC.Unknown = 0x{0:X4} ({0})", - _toc.Unknown); + AaruConsole.DebugWriteLine("Nero plugin", "\tneroTOC.Unknown = 0x{0:X4} ({0})", _toc.Unknown); break; } @@ -885,8 +877,7 @@ public sealed partial class Nero default: { AaruConsole.DebugWriteLine("Nero plugin", "Unknown chunk ID \"{0}\", skipping...", - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(chunkId))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(chunkId))); _imageStream.Seek(chunkLength, SeekOrigin.Current); @@ -951,7 +942,7 @@ public sealed partial class Nero var currentSessionStruct = new CommonTypes.Structs.Session(); ulong partitionSequence = 0; ulong partitionStartByte = 0; - int trackCounter = 1; + var trackCounter = 1; _trackFlags = new Dictionary(); if(currentSessionMaxTrack == 0) @@ -964,8 +955,7 @@ public sealed partial class Nero { if(neroTrack.Offset >= (_imageNewFormat ? footerV2.FirstChunkOffset : footerV1.FirstChunkOffset)) { - AaruConsole. - ErrorWriteLine("This image contains a track that is set to start outside the file."); + AaruConsole.ErrorWriteLine("This image contains a track that is set to start outside the file."); AaruConsole.ErrorWriteLine("Breaking track processing and trying recovery of information."); @@ -986,7 +976,7 @@ public sealed partial class Nero OrderBy(e => e.IndexNumber)) { track.Indexes[entry.IndexNumber] = - (entry.Minute * 60 * 75) + (entry.Second * 75) + entry.Frame - 150; + entry.Minute * 60 * 75 + entry.Second * 75 + entry.Frame - 150; _trackFlags[entry.TrackNumber] = (byte)((entry.Mode & 0xF0) >> 4); } @@ -1054,7 +1044,7 @@ public sealed partial class Nero // Common track data track.Description = StringHandlers.CToString(neroTrack.Isrc); - track.EndSector = (neroTrack.Length / neroTrack.SectorSize) + track.StartSector - 1; + track.EndSector = neroTrack.Length / neroTrack.SectorSize + track.StartSector - 1; track.Sequence = neroTrack.Sequence; track.Session = currentSession; track.Type = NeroTrackModeToTrackType((DaoMode)neroTrack.Mode); @@ -1067,7 +1057,6 @@ public sealed partial class Nero // Flags not set for this track if(!_trackFlags.ContainsKey(track.Sequence)) - { switch(track.Type) { case TrackType.Audio: @@ -1083,7 +1072,6 @@ public sealed partial class Nero break; } - } // If ISRC is not empty if(!string.IsNullOrWhiteSpace(track.Description)) @@ -1094,8 +1082,8 @@ public sealed partial class Nero _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); } - bool rawMode1 = false; - bool rawMode2 = false; + var rawMode1 = false; + var rawMode2 = false; switch((DaoMode)neroTrack.Mode) { @@ -1221,8 +1209,7 @@ public sealed partial class Nero // Add to offset map _offsetmap.Add(track.Sequence, track.StartSector); - AaruConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", track.Sequence, - track.StartSector); + AaruConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", track.Sequence, track.StartSector); // Create partition var partition = new Partition @@ -1264,8 +1251,8 @@ public sealed partial class Nero // Common track data track.Description = StringHandlers.CToString(_neroTracks[1].Isrc); - track.EndSector = ((_imageNewFormat ? footerV2.FirstChunkOffset : footerV1.FirstChunkOffset) / - _neroTracks[1].SectorSize) - 150; + track.EndSector = (_imageNewFormat ? footerV2.FirstChunkOffset : footerV1.FirstChunkOffset) / + _neroTracks[1].SectorSize - 150; track.Sequence = _neroTracks[1].Sequence; track.Session = currentSession; @@ -1276,9 +1263,9 @@ public sealed partial class Nero track.SubchannelType = TrackSubchannelType.None; track.Indexes[1] = 0; - bool rawMode1 = false; - bool rawMode2 = false; - int subSize = 0; + var rawMode1 = false; + var rawMode2 = false; + var subSize = 0; switch((DaoMode)_neroTracks[1].Mode) { @@ -1441,13 +1428,13 @@ public sealed partial class Nero if(_imageInfo.MediaType == CommonTypes.MediaType.Unknown || _imageInfo.MediaType == CommonTypes.MediaType.CD) { - bool data = false; - bool mode2 = false; - bool firstAudio = false; - bool firstData = false; - bool audio = false; + var data = false; + var mode2 = false; + var firstAudio = false; + var firstData = false; + var audio = false; - for(int i = 0; i < _neroTracks.Count; i++) + for(var i = 0; i < _neroTracks.Count; i++) { // First track is audio firstAudio |= i == 0 && ((DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || @@ -1489,7 +1476,7 @@ public sealed partial class Nero Sessions.Count > 1 && mode2) _imageInfo.MediaType = CommonTypes.MediaType.CDPLUS; - else if((firstData && audio) || mode2) + else if(firstData && audio || mode2) _imageInfo.MediaType = CommonTypes.MediaType.CDROMXA; else if(!audio) _imageInfo.MediaType = CommonTypes.MediaType.CDROM; @@ -1584,8 +1571,7 @@ public sealed partial class Nero } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => @@ -1605,9 +1591,9 @@ public sealed partial class Nero buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value - from track in Tracks where track.Sequence == kvp.Key - where sectorAddress - kvp.Value <= - track.EndSector - track.StartSector select kvp) + from track in Tracks where track.Sequence == kvp.Key + where sectorAddress - kvp.Value <= track.EndSector - track.StartSector + select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key, out buffer); return ErrorNumber.SectorNotFound; @@ -1619,9 +1605,9 @@ public sealed partial class Nero buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value - from track in Tracks where track.Sequence == kvp.Key - where sectorAddress - kvp.Value <= - track.EndSector - track.StartSector select kvp) + from track in Tracks where track.Sequence == kvp.Key + where sectorAddress - kvp.Value <= track.EndSector - track.StartSector + select kvp) { return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer); @@ -1645,7 +1631,7 @@ public sealed partial class Nero uint sectorOffset; uint sectorSize; uint sectorSkip; - bool mode2 = false; + var mode2 = false; switch((DaoMode)aaruTrack.Mode) { @@ -1734,9 +1720,8 @@ public sealed partial class Nero _imageStream = _neroFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(mode2) { @@ -1744,9 +1729,9 @@ public sealed partial class Nero buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize); sector = Sector.GetUserData(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1758,7 +1743,7 @@ public sealed partial class Nero sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2069,15 +2054,14 @@ public sealed partial class Nero _imageStream = _neroFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2102,9 +2086,9 @@ public sealed partial class Nero buffer = null; foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value - from track in Tracks where track.Sequence == kvp.Key - where sectorAddress - kvp.Value <= - track.EndSector - track.StartSector select kvp) + from track in Tracks where track.Sequence == kvp.Key + where sectorAddress - kvp.Value <= track.EndSector - track.StartSector + select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key, out buffer); return ErrorNumber.SectorNotFound; @@ -2180,15 +2164,14 @@ public sealed partial class Nero _imageStream = _neroFilter.GetDataForkStream(); var br = new BinaryReader(_imageStream); - br.BaseStream. - Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), - SeekOrigin.Begin); + br.BaseStream.Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), + SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -2201,8 +2184,8 @@ public sealed partial class Nero { case DaoMode.Data: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { @@ -2218,15 +2201,14 @@ public sealed partial class Nero } case DaoMode.DataM2F1: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { Array.Copy(buffer, i * 2048, fullSector, 24, 2048); - _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, - (long)(sectorAddress + i)); + _sectorBuilder.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, (long)(sectorAddress + i)); _sectorBuilder.ReconstructEcc(ref fullSector, TrackType.CdMode2Form1); Array.Copy(fullSector, 0, fullBuffer, i * 2352, 2352); @@ -2238,8 +2220,8 @@ public sealed partial class Nero } case DaoMode.DataM2F2: { - byte[] fullSector = new byte[2352]; - byte[] fullBuffer = new byte[2352 * length]; + var fullSector = new byte[2352]; + var fullBuffer = new byte[2352 * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/Nero/Structs.cs b/Aaru.Images/Nero/Structs.cs index b18beb9db..25a761951 100644 --- a/Aaru.Images/Nero/Structs.cs +++ b/Aaru.Images/Nero/Structs.cs @@ -30,13 +30,15 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; + // ReSharper disable NotAccessedField.Local namespace Aaru.DiscImages; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class Nero { diff --git a/Aaru.Images/Nero/Verify.cs b/Aaru.Images/Nero/Verify.cs index 31fd5d7c8..86390608d 100644 --- a/Aaru.Images/Nero/Verify.cs +++ b/Aaru.Images/Nero/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class Nero { /// @@ -58,10 +58,10 @@ public sealed partial class Nero if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -96,10 +96,10 @@ public sealed partial class Nero if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/Parallels/Constants.cs b/Aaru.Images/Parallels/Constants.cs index 1c81b5b8c..06819afb6 100644 --- a/Aaru.Images/Parallels/Constants.cs +++ b/Aaru.Images/Parallels/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Parallels { diff --git a/Aaru.Images/Parallels/Identify.cs b/Aaru.Images/Parallels/Identify.cs index 56b3379a9..a16d41d6c 100644 --- a/Aaru.Images/Parallels/Identify.cs +++ b/Aaru.Images/Parallels/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Parallels { /// @@ -48,7 +48,7 @@ public sealed partial class Parallels if(stream.Length < 512) return false; - byte[] pHdrB = new byte[Marshal.SizeOf
()]; + var pHdrB = new byte[Marshal.SizeOf
()]; stream.Read(pHdrB, 0, Marshal.SizeOf
()); _pHdr = Marshal.ByteArrayToStructureLittleEndian
(pHdrB); diff --git a/Aaru.Images/Parallels/Parallels.cs b/Aaru.Images/Parallels/Parallels.cs index db0d022dc..02d10fd2d 100644 --- a/Aaru.Images/Parallels/Parallels.cs +++ b/Aaru.Images/Parallels/Parallels.cs @@ -30,16 +30,18 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable NotAccessedField.Local + +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -// ReSharper disable NotAccessedField.Local - -namespace Aaru.DiscImages; - /// /// Implements reading and writing Parallels' disk images public sealed partial class Parallels : IWritableImage diff --git a/Aaru.Images/Parallels/Properties.cs b/Aaru.Images/Parallels/Properties.cs index 92706840f..8370ddc26 100644 --- a/Aaru.Images/Parallels/Properties.cs +++ b/Aaru.Images/Parallels/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Parallels { /// public string Name => "Parallels disk image"; /// - public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); + public Guid Id => new("E314DE35-C103-48A3-AD36-990F68523C46"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/Parallels/Read.cs b/Aaru.Images/Parallels/Read.cs index 271bca7d1..38c2d55a4 100644 --- a/Aaru.Images/Parallels/Read.cs +++ b/Aaru.Images/Parallels/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Parallels { /// @@ -53,7 +53,7 @@ public sealed partial class Parallels if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] pHdrB = new byte[Marshal.SizeOf
()]; + var pHdrB = new byte[Marshal.SizeOf
()]; stream.Read(pHdrB, 0, Marshal.SizeOf
()); _pHdr = Marshal.ByteArrayToStructureLittleEndian
(pHdrB); @@ -74,10 +74,10 @@ public sealed partial class Parallels AaruConsole.DebugWriteLine("Parallels plugin", "Reading BAT"); _bat = new uint[_pHdr.bat_entries]; - byte[] batB = new byte[_pHdr.bat_entries * 4]; + var batB = new byte[_pHdr.bat_entries * 4]; stream.Read(batB, 0, batB.Length); - for(int i = 0; i < _bat.Length; i++) + for(var i = 0; i < _bat.Length; i++) _bat[i] = BitConverter.ToUInt32(batB, i * 4); _clusterBytes = _pHdr.cluster_size * 512; @@ -85,7 +85,7 @@ public sealed partial class Parallels if(_pHdr.data_off > 0) _dataOffset = _pHdr.data_off * 512; else - _dataOffset = ((stream.Position / _clusterBytes) + (stream.Position % _clusterBytes)) * _clusterBytes; + _dataOffset = (stream.Position / _clusterBytes + stream.Position % _clusterBytes) * _clusterBytes; _sectorCache = new Dictionary(); @@ -143,7 +143,7 @@ public sealed partial class Parallels else imageOff = batOff * 512UL; - byte[] cluster = new byte[_clusterBytes]; + var cluster = new byte[_clusterBytes]; _imageStream.Seek((long)imageOff, SeekOrigin.Begin); _imageStream.Read(cluster, 0, (int)_clusterBytes); buffer = new byte[512]; diff --git a/Aaru.Images/Parallels/Structs.cs b/Aaru.Images/Parallels/Structs.cs index f43b45b51..2be17f0b8 100644 --- a/Aaru.Images/Parallels/Structs.cs +++ b/Aaru.Images/Parallels/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Parallels { /// Parallels disk image header, little-endian diff --git a/Aaru.Images/Parallels/Unsupported.cs b/Aaru.Images/Parallels/Unsupported.cs index 49e05a183..4277f5afd 100644 --- a/Aaru.Images/Parallels/Unsupported.cs +++ b/Aaru.Images/Parallels/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Parallels { /// diff --git a/Aaru.Images/Parallels/Write.cs b/Aaru.Images/Parallels/Write.cs index 575a3caa7..85968c30d 100644 --- a/Aaru.Images/Parallels/Write.cs +++ b/Aaru.Images/Parallels/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Parallels { // TODO: Support extended @@ -88,14 +88,14 @@ public sealed partial class Parallels return false; } - uint batEntries = (uint)(sectors * sectorSize / DEFAULT_CLUSTER_SIZE); + var batEntries = (uint)(sectors * sectorSize / DEFAULT_CLUSTER_SIZE); if(sectors * sectorSize % DEFAULT_CLUSTER_SIZE > 0) batEntries++; - uint headerSectors = (uint)Marshal.SizeOf
() + (batEntries * 4); + uint headerSectors = (uint)Marshal.SizeOf
() + batEntries * 4; - if((uint)Marshal.SizeOf
() + (batEntries % 4) > 0) + if((uint)Marshal.SizeOf
() + batEntries % 4 > 0) headerSectors++; _pHdr = new Header @@ -208,7 +208,7 @@ public sealed partial class Parallels for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[512]; + var tmp = new byte[512]; Array.Copy(data, i * 512, tmp, 0, 512); if(!WriteSector(tmp, sectorAddress + i)) @@ -271,7 +271,7 @@ public sealed partial class Parallels } } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_pHdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/PartClone/Identify.cs b/Aaru.Images/PartClone/Identify.cs index 8e4e6dc26..0b5e357d1 100644 --- a/Aaru.Images/PartClone/Identify.cs +++ b/Aaru.Images/PartClone/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class PartClone { /// @@ -48,7 +48,7 @@ public sealed partial class PartClone if(stream.Length < 512) return false; - byte[] pHdrB = new byte[Marshal.SizeOf
()]; + var pHdrB = new byte[Marshal.SizeOf
()]; stream.Read(pHdrB, 0, Marshal.SizeOf
()); _pHdr = Marshal.ByteArrayToStructureLittleEndian
(pHdrB); @@ -57,7 +57,7 @@ public sealed partial class PartClone stream.Seek((long)_pHdr.totalBlocks, SeekOrigin.Current); - byte[] bitmagic = new byte[8]; + var bitmagic = new byte[8]; stream.Read(bitmagic, 0, 8); return _partCloneMagic.SequenceEqual(_pHdr.magic) && _biTmAgIc.SequenceEqual(bitmagic); diff --git a/Aaru.Images/PartClone/PartClone.cs b/Aaru.Images/PartClone/PartClone.cs index 7865fcf63..2dc2f0802 100644 --- a/Aaru.Images/PartClone/PartClone.cs +++ b/Aaru.Images/PartClone/PartClone.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading partclone disk images public sealed partial class PartClone : IMediaImage, IVerifiableImage { diff --git a/Aaru.Images/PartClone/Properties.cs b/Aaru.Images/PartClone/Properties.cs index deae37b14..c6b9cdabc 100644 --- a/Aaru.Images/PartClone/Properties.cs +++ b/Aaru.Images/PartClone/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class PartClone { /// public string Name => "PartClone disk image"; /// - public Guid Id => new Guid("AB1D7518-B548-4099-A4E2-C29C53DDE0C3"); + public Guid Id => new("AB1D7518-B548-4099-A4E2-C29C53DDE0C3"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/PartClone/Read.cs b/Aaru.Images/PartClone/Read.cs index 5b3a7a502..30ad54503 100644 --- a/Aaru.Images/PartClone/Read.cs +++ b/Aaru.Images/PartClone/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class PartClone { /// @@ -54,7 +54,7 @@ public sealed partial class PartClone if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] pHdrB = new byte[Marshal.SizeOf
()]; + var pHdrB = new byte[Marshal.SizeOf
()]; stream.Read(pHdrB, 0, Marshal.SizeOf
()); _pHdr = Marshal.ByteArrayToStructureLittleEndian
(pHdrB); @@ -63,8 +63,7 @@ public sealed partial class PartClone AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.filesystem = {0}", StringHandlers.CToString(_pHdr.filesystem)); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.version = {0}", - StringHandlers.CToString(_pHdr.version)); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.version = {0}", StringHandlers.CToString(_pHdr.version)); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.blockSize = {0}", _pHdr.blockSize); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.deviceSize = {0}", _pHdr.deviceSize); @@ -75,7 +74,7 @@ public sealed partial class PartClone AaruConsole.DebugWriteLine("PartClone plugin", "Reading bytemap {0} bytes", _byteMap.Length); stream.Read(_byteMap, 0, _byteMap.Length); - byte[] bitmagic = new byte[8]; + var bitmagic = new byte[8]; stream.Read(bitmagic, 0, 8); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.bitmagic = {0}", StringHandlers.CToString(bitmagic)); @@ -123,8 +122,7 @@ public sealed partial class PartClone DateTime end = DateTime.Now; - AaruConsole.DebugWriteLine("PartClone plugin", "Took {0} seconds to fill extents", - (end - start).TotalSeconds); + AaruConsole.DebugWriteLine("PartClone plugin", "Took {0} seconds to fill extents", (end - start).TotalSeconds); _sectorCache = new Dictionary(); @@ -186,7 +184,7 @@ public sealed partial class PartClone var ms = new MemoryStream(); - bool allEmpty = true; + var allEmpty = true; for(uint i = 0; i < length; i++) if(_byteMap[sectorAddress + i] != 0) diff --git a/Aaru.Images/PartClone/Structs.cs b/Aaru.Images/PartClone/Structs.cs index 362b03f68..8ec3dec16 100644 --- a/Aaru.Images/PartClone/Structs.cs +++ b/Aaru.Images/PartClone/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class PartClone { /// PartClone disk image header, little-endian diff --git a/Aaru.Images/PartClone/Unsupported.cs b/Aaru.Images/PartClone/Unsupported.cs index d6ee9f889..876e406bb 100644 --- a/Aaru.Images/PartClone/Unsupported.cs +++ b/Aaru.Images/PartClone/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class PartClone { /// diff --git a/Aaru.Images/Partimage/Constants.cs b/Aaru.Images/Partimage/Constants.cs index 51b2f5215..2e93fd447 100644 --- a/Aaru.Images/Partimage/Constants.cs +++ b/Aaru.Images/Partimage/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Partimage { diff --git a/Aaru.Images/Partimage/Enums.cs b/Aaru.Images/Partimage/Enums.cs index f5d0abe9e..211c7572d 100644 --- a/Aaru.Images/Partimage/Enums.cs +++ b/Aaru.Images/Partimage/Enums.cs @@ -30,17 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Partimage { enum PCompression : uint { - None = 0, Gzip = 1, Bzip2 = 2, - Lzo = 3 + None = 0, + Gzip = 1, + Bzip2 = 2, + Lzo = 3 } enum PEncryption : uint diff --git a/Aaru.Images/Partimage/Identify.cs b/Aaru.Images/Partimage/Identify.cs index b917471cf..10d653605 100644 --- a/Aaru.Images/Partimage/Identify.cs +++ b/Aaru.Images/Partimage/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Partimage { /// @@ -48,7 +48,7 @@ public sealed partial class Partimage if(stream.Length < 512) return false; - byte[] pHdrB = new byte[Marshal.SizeOf
()]; + var pHdrB = new byte[Marshal.SizeOf
()]; stream.Read(pHdrB, 0, Marshal.SizeOf
()); _cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian
(pHdrB); diff --git a/Aaru.Images/Partimage/Partimage.cs b/Aaru.Images/Partimage/Partimage.cs index d753025df..e083582ac 100644 --- a/Aaru.Images/Partimage/Partimage.cs +++ b/Aaru.Images/Partimage/Partimage.cs @@ -30,6 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +#pragma warning disable 649 + +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; @@ -37,10 +41,6 @@ using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -#pragma warning disable 649 - -namespace Aaru.DiscImages; - /// Implements reading partimage disk images public sealed partial class Partimage : IMediaImage, IVerifiableImage { diff --git a/Aaru.Images/Partimage/Properties.cs b/Aaru.Images/Partimage/Properties.cs index 30e956628..06818748a 100644 --- a/Aaru.Images/Partimage/Properties.cs +++ b/Aaru.Images/Partimage/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Partimage { /// @@ -45,7 +45,7 @@ public sealed partial class Partimage /// public string Name => "Partimage disk image"; /// - public Guid Id => new Guid("AAFDB99D-2B77-49EA-831C-C9BB58C68C95"); + public Guid Id => new("AAFDB99D-2B77-49EA-831C-C9BB58C68C95"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/Partimage/Read.cs b/Aaru.Images/Partimage/Read.cs index 308a99846..f67a1ad38 100644 --- a/Aaru.Images/Partimage/Read.cs +++ b/Aaru.Images/Partimage/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Partimage { /// @@ -53,7 +53,7 @@ public sealed partial class Partimage if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, Marshal.SizeOf
()); _cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian
(hdrB); @@ -63,8 +63,7 @@ public sealed partial class Partimage AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.version = {0}", StringHandlers.CToString(_cVolumeHeader.version)); - AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.volumeNumber = {0}", - _cVolumeHeader.volumeNumber); + AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.volumeNumber = {0}", _cVolumeHeader.volumeNumber); AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.identificator = {0:X16}", _cVolumeHeader.identificator); @@ -146,8 +145,7 @@ public sealed partial class Partimage AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_zone = {0}", _cMainHeader.dateCreate.Timezone); - var dateCreate = new DateTime(1900 + (int)_cMainHeader.dateCreate.Year, - (int)_cMainHeader.dateCreate.Month + 1, + var dateCreate = new DateTime(1900 + (int)_cMainHeader.dateCreate.Year, (int)_cMainHeader.dateCreate.Month + 1, (int)_cMainHeader.dateCreate.DayOfMonth, (int)_cMainHeader.dateCreate.Hour, (int)_cMainHeader.dateCreate.Minute, (int)_cMainHeader.dateCreate.Second); @@ -253,8 +251,7 @@ public sealed partial class Partimage AaruConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBlockSize = {0}", localHeader.qwBlockSize); AaruConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwUsedBlocks = {0}", localHeader.qwUsedBlocks); - AaruConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBlocksCount = {0}", - localHeader.qwBlocksCount); + AaruConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBlocksCount = {0}", localHeader.qwBlocksCount); AaruConsole.DebugWriteLine("Partimage plugin", "CLocalHeader.qwBitmapSize = {0}", localHeader.qwBitmapSize); @@ -359,8 +356,7 @@ public sealed partial class Partimage DateTime end = DateTime.Now; - AaruConsole.DebugWriteLine("Partimage plugin", "Took {0} seconds to fill extents", - (end - start).TotalSeconds); + AaruConsole.DebugWriteLine("Partimage plugin", "Took {0} seconds to fill extents", (end - start).TotalSeconds); _sectorCache = new Dictionary(); @@ -410,7 +406,7 @@ public sealed partial class Partimage (long)(blockOff * _imageInfo.SectorSize) + // How many bytes of CRC blocks to skip - ((long)(blockOff / (CHECK_FREQUENCY / _imageInfo.SectorSize)) * Marshal.SizeOf()); + (long)(blockOff / (CHECK_FREQUENCY / _imageInfo.SectorSize)) * Marshal.SizeOf(); buffer = new byte[_imageInfo.SectorSize]; _imageStream.Seek(imageOff, SeekOrigin.Begin); @@ -437,7 +433,7 @@ public sealed partial class Partimage var ms = new MemoryStream(); - bool allEmpty = true; + var allEmpty = true; for(uint i = 0; i < length; i++) if((_bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) != 0) diff --git a/Aaru.Images/Partimage/Structs.cs b/Aaru.Images/Partimage/Structs.cs index b8c767641..e31645a38 100644 --- a/Aaru.Images/Partimage/Structs.cs +++ b/Aaru.Images/Partimage/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedType.Local")] public sealed partial class Partimage { diff --git a/Aaru.Images/Partimage/Unsupported.cs b/Aaru.Images/Partimage/Unsupported.cs index 21a74544b..5f60052e6 100644 --- a/Aaru.Images/Partimage/Unsupported.cs +++ b/Aaru.Images/Partimage/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Partimage { /// diff --git a/Aaru.Images/QCOW/Identify.cs b/Aaru.Images/QCOW/Identify.cs index ba07261c2..cc9a82072 100644 --- a/Aaru.Images/QCOW/Identify.cs +++ b/Aaru.Images/QCOW/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Qcow { /// @@ -47,7 +47,7 @@ public sealed partial class Qcow if(stream.Length < 512) return false; - byte[] qHdrB = new byte[48]; + var qHdrB = new byte[48]; stream.Read(qHdrB, 0, 48); _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); diff --git a/Aaru.Images/QCOW/Properties.cs b/Aaru.Images/QCOW/Properties.cs index 68e2e8222..bc81177c6 100644 --- a/Aaru.Images/QCOW/Properties.cs +++ b/Aaru.Images/QCOW/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Qcow { /// @@ -47,7 +47,7 @@ public sealed partial class Qcow /// public string Name => "QEMU Copy-On-Write disk image"; /// - public Guid Id => new Guid("A5C35765-9FE2-469D-BBBF-ACDEBDB7B954"); + public Guid Id => new("A5C35765-9FE2-469D-BBBF-ACDEBDB7B954"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/QCOW/QCOW.cs b/Aaru.Images/QCOW/QCOW.cs index a6235605d..f54060773 100644 --- a/Aaru.Images/QCOW/QCOW.cs +++ b/Aaru.Images/QCOW/QCOW.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing QEMU's Copy On Write disk images public sealed partial class Qcow : IWritableImage diff --git a/Aaru.Images/QCOW/Read.cs b/Aaru.Images/QCOW/Read.cs index 5a01ac1a4..f0b6428e7 100644 --- a/Aaru.Images/QCOW/Read.cs +++ b/Aaru.Images/QCOW/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using SharpCompress.Compressors; using SharpCompress.Compressors.Deflate; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qcow { /// @@ -56,7 +56,7 @@ public sealed partial class Qcow if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] qHdrB = new byte[48]; + var qHdrB = new byte[48]; stream.Read(qHdrB, 0, 48); _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); @@ -136,7 +136,7 @@ public sealed partial class Qcow AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", _l2Size); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", _imageInfo.Sectors); - byte[] l1TableB = new byte[_l1Size * 8]; + var l1TableB = new byte[_l1Size * 8]; stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); stream.Read(l1TableB, 0, (int)_l1Size * 8); _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); @@ -146,10 +146,10 @@ public sealed partial class Qcow _l1Table[i] = Swapping.Swap(_l1Table[i]); _l1Mask = 0; - int c = 0; + var c = 0; _l1Shift = _qHdr.l2_bits + _qHdr.cluster_bits; - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -162,14 +162,14 @@ public sealed partial class Qcow _l2Mask = 0; - for(int i = 0; i < _qHdr.l2_bits; i++) + for(var i = 0; i < _qHdr.l2_bits; i++) _l2Mask = (_l2Mask << 1) + 1; _l2Mask <<= _qHdr.cluster_bits; _sectorMask = 0; - for(int i = 0; i < _qHdr.cluster_bits; i++) + for(var i = 0; i < _qHdr.cluster_bits; i++) _sectorMask = (_sectorMask << 1) + 1; AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", _l1Mask); @@ -240,7 +240,7 @@ public sealed partial class Qcow if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { _imageStream.Seek((long)_l1Table[l1Off], SeekOrigin.Begin); - byte[] l2TableB = new byte[_l2Size * 8]; + var l2TableB = new byte[_l2Size * 8]; _imageStream.Read(l2TableB, 0, _l2Size * 8); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); @@ -273,7 +273,7 @@ public sealed partial class Qcow ulong realOff = offset & offMask; ulong compSize = (offset & compSizeMask) >> (63 - _qHdr.cluster_bits); - byte[] zCluster = new byte[compSize]; + var zCluster = new byte[compSize]; _imageStream.Seek((long)realOff, SeekOrigin.Begin); _imageStream.Read(zCluster, 0, (int)compSize); diff --git a/Aaru.Images/QCOW/Structs.cs b/Aaru.Images/QCOW/Structs.cs index d2bee2a0a..200fb1ad9 100644 --- a/Aaru.Images/QCOW/Structs.cs +++ b/Aaru.Images/QCOW/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Qcow { /// QCOW header, big-endian diff --git a/Aaru.Images/QCOW/Unsupported.cs b/Aaru.Images/QCOW/Unsupported.cs index c2453723c..6959b6092 100644 --- a/Aaru.Images/QCOW/Unsupported.cs +++ b/Aaru.Images/QCOW/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Qcow { /// diff --git a/Aaru.Images/QCOW/Write.cs b/Aaru.Images/QCOW/Write.cs index e2e87212d..cc3eb87d9 100644 --- a/Aaru.Images/QCOW/Write.cs +++ b/Aaru.Images/QCOW/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qcow { /// @@ -109,10 +109,10 @@ public sealed partial class Qcow _l1Table = new ulong[_l1Size]; _l1Mask = 0; - int c = 0; + var c = 0; _l1Shift = _qHdr.l2_bits + _qHdr.cluster_bits; - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -125,17 +125,17 @@ public sealed partial class Qcow _l2Mask = 0; - for(int i = 0; i < _qHdr.l2_bits; i++) + for(var i = 0; i < _qHdr.l2_bits; i++) _l2Mask = (_l2Mask << 1) + 1; _l2Mask <<= _qHdr.cluster_bits; _sectorMask = 0; - for(int i = 0; i < _qHdr.cluster_bits; i++) + for(var i = 0; i < _qHdr.cluster_bits; i++) _sectorMask = (_sectorMask << 1) + 1; - byte[] empty = new byte[_qHdr.l1_table_offset + (_l1Size * 8)]; + var empty = new byte[_qHdr.l1_table_offset + _l1Size * 8]; _writingStream.Write(empty, 0, empty.Length); IsWriting = true; @@ -195,7 +195,7 @@ public sealed partial class Qcow { _writingStream.Seek(0, SeekOrigin.End); _l1Table[l1Off] = (ulong)((_writingStream.Length + _clusterSize - 1) / _clusterSize * _clusterSize); - byte[] l2TableB = new byte[_l2Size * 8]; + var l2TableB = new byte[_l2Size * 8]; _writingStream.Position = (long)_l1Table[l1Off]; _writingStream.Write(l2TableB, 0, l2TableB.Length); } @@ -204,18 +204,18 @@ public sealed partial class Qcow ulong l2Off = (byteAddress & _l2Mask) >> _qHdr.cluster_bits; - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); - byte[] entry = new byte[8]; + var entry = new byte[8]; _writingStream.Read(entry, 0, 8); - ulong offset = BigEndianBitConverter.ToUInt64(entry, 0); + var offset = BigEndianBitConverter.ToUInt64(entry, 0); if(offset == 0) { offset = (ulong)_writingStream.Length; - byte[] cluster = new byte[_clusterSize]; + var cluster = new byte[_clusterSize]; entry = BigEndianBitConverter.GetBytes(offset); - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); _writingStream.Write(entry, 0, 8); _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(cluster, 0, cluster.Length); @@ -260,7 +260,7 @@ public sealed partial class Qcow for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[_imageInfo.SectorSize]; + var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) diff --git a/Aaru.Images/QCOW2/Constants.cs b/Aaru.Images/QCOW2/Constants.cs index 89fac536f..9b7d3c2f9 100644 --- a/Aaru.Images/QCOW2/Constants.cs +++ b/Aaru.Images/QCOW2/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Qcow2 { diff --git a/Aaru.Images/QCOW2/Identify.cs b/Aaru.Images/QCOW2/Identify.cs index 4aad7333e..9100e2e20 100644 --- a/Aaru.Images/QCOW2/Identify.cs +++ b/Aaru.Images/QCOW2/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Qcow2 { /// @@ -48,7 +48,7 @@ public sealed partial class Qcow2 if(stream.Length < 512) return false; - byte[] qHdrB = new byte[Marshal.SizeOf
()]; + var qHdrB = new byte[Marshal.SizeOf
()]; stream.Read(qHdrB, 0, Marshal.SizeOf
()); _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); diff --git a/Aaru.Images/QCOW2/Properties.cs b/Aaru.Images/QCOW2/Properties.cs index 961058220..d25132576 100644 --- a/Aaru.Images/QCOW2/Properties.cs +++ b/Aaru.Images/QCOW2/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Qcow2 { /// @@ -47,7 +47,7 @@ public sealed partial class Qcow2 /// public string Name => "QEMU Copy-On-Write disk image v2"; /// - public Guid Id => new Guid("F20107CB-95B3-4398-894B-975261F1E8C5"); + public Guid Id => new("F20107CB-95B3-4398-894B-975261F1E8C5"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/QCOW2/QCOW2.cs b/Aaru.Images/QCOW2/QCOW2.cs index 6ec0c69a0..7d7e54d96 100644 --- a/Aaru.Images/QCOW2/QCOW2.cs +++ b/Aaru.Images/QCOW2/QCOW2.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing QEMU's Copy On Write v2 and v3 disk images public sealed partial class Qcow2 : IWritableImage diff --git a/Aaru.Images/QCOW2/Read.cs b/Aaru.Images/QCOW2/Read.cs index a1861e8fb..0e9746a57 100644 --- a/Aaru.Images/QCOW2/Read.cs +++ b/Aaru.Images/QCOW2/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using SharpCompress.Compressors; using SharpCompress.Compressors.Deflate; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qcow2 { /// @@ -56,7 +56,7 @@ public sealed partial class Qcow2 if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] qHdrB = new byte[Marshal.SizeOf
()]; + var qHdrB = new byte[Marshal.SizeOf
()]; stream.Read(qHdrB, 0, Marshal.SizeOf
()); _qHdr = Marshal.SpanToStructureBigEndian
(qHdrB); @@ -71,8 +71,7 @@ public sealed partial class Qcow2 AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_table_offset = {0}", _qHdr.l1_table_offset); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_offset = {0}", _qHdr.refcount_table_offset); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_clusters = {0}", - _qHdr.refcount_table_clusters); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_clusters = {0}", _qHdr.refcount_table_clusters); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.nb_snapshots = {0}", _qHdr.nb_snapshots); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.snapshots_offset = {0}", _qHdr.snapshots_offset); @@ -141,7 +140,7 @@ public sealed partial class Qcow2 AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", _l2Size); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", _imageInfo.Sectors); - byte[] l1TableB = new byte[_qHdr.l1_size * 8]; + var l1TableB = new byte[_qHdr.l1_size * 8]; stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); stream.Read(l1TableB, 0, (int)_qHdr.l1_size * 8); _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); @@ -151,10 +150,10 @@ public sealed partial class Qcow2 _l1Table[i] = Swapping.Swap(_l1Table[i]); _l1Mask = 0; - int c = 0; + var c = 0; _l1Shift = (int)(_l2Bits + _qHdr.cluster_bits); - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -167,14 +166,14 @@ public sealed partial class Qcow2 _l2Mask = 0; - for(int i = 0; i < _l2Bits; i++) + for(var i = 0; i < _l2Bits; i++) _l2Mask = (_l2Mask << 1) + 1; _l2Mask <<= (int)_qHdr.cluster_bits; _sectorMask = 0; - for(int i = 0; i < _qHdr.cluster_bits; i++) + for(var i = 0; i < _qHdr.cluster_bits; i++) _sectorMask = (_sectorMask << 1) + 1; AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", _l1Mask); @@ -243,7 +242,7 @@ public sealed partial class Qcow2 if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { _imageStream.Seek((long)(_l1Table[l1Off] & QCOW_FLAGS_MASK), SeekOrigin.Begin); - byte[] l2TableB = new byte[_l2Size * 8]; + var l2TableB = new byte[_l2Size * 8]; _imageStream.Read(l2TableB, 0, _l2Size * 8); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); @@ -270,14 +269,14 @@ public sealed partial class Qcow2 if((offset & QCOW_COMPRESSED) == QCOW_COMPRESSED) { ulong compSizeMask = (ulong)(1 << (int)(_qHdr.cluster_bits - 8)) - 1; - byte countbits = (byte)(_qHdr.cluster_bits - 8); + var countbits = (byte)(_qHdr.cluster_bits - 8); compSizeMask <<= 62 - countbits; ulong offMask = ~compSizeMask & QCOW_FLAGS_MASK; ulong realOff = offset & offMask; ulong compSize = (((offset & compSizeMask) >> (62 - countbits)) + 1) * 512; - byte[] zCluster = new byte[compSize]; + var zCluster = new byte[compSize]; _imageStream.Seek((long)realOff, SeekOrigin.Begin); _imageStream.Read(zCluster, 0, (int)compSize); diff --git a/Aaru.Images/QCOW2/Structs.cs b/Aaru.Images/QCOW2/Structs.cs index 4980d1551..cc4cf4193 100644 --- a/Aaru.Images/QCOW2/Structs.cs +++ b/Aaru.Images/QCOW2/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Qcow2 { /// QCOW header, big-endian diff --git a/Aaru.Images/QCOW2/Unsupported.cs b/Aaru.Images/QCOW2/Unsupported.cs index 23b9a588d..320886a25 100644 --- a/Aaru.Images/QCOW2/Unsupported.cs +++ b/Aaru.Images/QCOW2/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Qcow2 { /// diff --git a/Aaru.Images/QCOW2/Write.cs b/Aaru.Images/QCOW2/Write.cs index e1a1943a1..5331d9da3 100644 --- a/Aaru.Images/QCOW2/Write.cs +++ b/Aaru.Images/QCOW2/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qcow2 { /// @@ -108,10 +108,10 @@ public sealed partial class Qcow2 _l2Size = 1 << _l2Bits; _l1Mask = 0; - int c = 0; + var c = 0; _l1Shift = (int)(_l2Bits + _qHdr.cluster_bits); - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -124,14 +124,14 @@ public sealed partial class Qcow2 _l2Mask = 0; - for(int i = 0; i < _l2Bits; i++) + for(var i = 0; i < _l2Bits; i++) _l2Mask = (_l2Mask << 1) + 1; _l2Mask <<= (int)_qHdr.cluster_bits; _sectorMask = 0; - for(int i = 0; i < _qHdr.cluster_bits; i++) + for(var i = 0; i < _qHdr.cluster_bits; i++) _sectorMask = (_sectorMask << 1) + 1; _qHdr.l1_size = (uint)(((long)_qHdr.size + (1 << _l1Shift) - 1) >> _l1Shift); @@ -163,7 +163,7 @@ public sealed partial class Qcow2 if(l1TableClusters == 0) l1TableClusters = 1; - byte[] empty = new byte[_qHdr.l1_table_offset + (l1TableClusters * (ulong)_clusterSize)]; + var empty = new byte[_qHdr.l1_table_offset + l1TableClusters * (ulong)_clusterSize]; _writingStream.Write(empty, 0, empty.Length); IsWriting = true; @@ -223,7 +223,7 @@ public sealed partial class Qcow2 { _writingStream.Seek(0, SeekOrigin.End); _l1Table[l1Off] = (ulong)_writingStream.Position; - byte[] l2TableB = new byte[_l2Size * 8]; + var l2TableB = new byte[_l2Size * 8]; _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(l2TableB, 0, l2TableB.Length); } @@ -232,18 +232,18 @@ public sealed partial class Qcow2 ulong l2Off = (byteAddress & _l2Mask) >> (int)_qHdr.cluster_bits; - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); - byte[] entry = new byte[8]; + var entry = new byte[8]; _writingStream.Read(entry, 0, 8); - ulong offset = BigEndianBitConverter.ToUInt64(entry, 0); + var offset = BigEndianBitConverter.ToUInt64(entry, 0); if(offset == 0) { offset = (ulong)_writingStream.Length; - byte[] cluster = new byte[_clusterSize]; + var cluster = new byte[_clusterSize]; entry = BigEndianBitConverter.GetBytes(offset); - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); _writingStream.Write(entry, 0, 8); _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(cluster, 0, cluster.Length); @@ -262,7 +262,7 @@ public sealed partial class Qcow2 { refBlockOffset = (ulong)_writingStream.Length; _refCountTable[refCountTableIndex] = refBlockOffset; - byte[] cluster = new byte[_clusterSize]; + var cluster = new byte[_clusterSize]; _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(cluster, 0, cluster.Length); } @@ -310,7 +310,7 @@ public sealed partial class Qcow2 for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[_imageInfo.SectorSize]; + var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) diff --git a/Aaru.Images/QED/Constants.cs b/Aaru.Images/QED/Constants.cs index 6881a384b..e5566d988 100644 --- a/Aaru.Images/QED/Constants.cs +++ b/Aaru.Images/QED/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Qed { diff --git a/Aaru.Images/QED/Helpers.cs b/Aaru.Images/QED/Helpers.cs index 220eb4b05..d05b3c7ed 100644 --- a/Aaru.Images/QED/Helpers.cs +++ b/Aaru.Images/QED/Helpers.cs @@ -45,7 +45,7 @@ public sealed partial class Qed static int Ctz32(uint val) { - int cnt = 0; + var cnt = 0; if((val & 0xFFFF) == 0) { diff --git a/Aaru.Images/QED/Identify.cs b/Aaru.Images/QED/Identify.cs index a7e6e4f3f..cc2dd8b15 100644 --- a/Aaru.Images/QED/Identify.cs +++ b/Aaru.Images/QED/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Qed { /// @@ -47,7 +47,7 @@ public sealed partial class Qed if(stream.Length < 512) return false; - byte[] qHdrB = new byte[68]; + var qHdrB = new byte[68]; stream.Read(qHdrB, 0, 68); _qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); diff --git a/Aaru.Images/QED/Properties.cs b/Aaru.Images/QED/Properties.cs index f2c840877..8f45cc844 100644 --- a/Aaru.Images/QED/Properties.cs +++ b/Aaru.Images/QED/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Qed { /// @@ -47,7 +47,7 @@ public sealed partial class Qed /// public string Name => "QEMU Enhanced Disk image"; /// - public Guid Id => new Guid("B9DBB155-A69A-4C10-BF91-96BF431B9BB6"); + public Guid Id => new("B9DBB155-A69A-4C10-BF91-96BF431B9BB6"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/QED/QED.cs b/Aaru.Images/QED/QED.cs index 4c32d824d..17730ba45 100644 --- a/Aaru.Images/QED/QED.cs +++ b/Aaru.Images/QED/QED.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing QEMU Enhanced Disk images public sealed partial class Qed : IWritableImage diff --git a/Aaru.Images/QED/Read.cs b/Aaru.Images/QED/Read.cs index 94aa3bdc2..b0e735fdd 100644 --- a/Aaru.Images/QED/Read.cs +++ b/Aaru.Images/QED/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qed { /// @@ -53,7 +53,7 @@ public sealed partial class Qed if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] qHdrB = new byte[68]; + var qHdrB = new byte[68]; stream.Read(qHdrB, 0, 68); _qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); @@ -72,63 +72,74 @@ public sealed partial class Qed if(_qHdr.image_size <= 1) { AaruConsole.ErrorWriteLine("Image size is too small"); + return ErrorNumber.InvalidArgument; } + if(!IsPowerOfTwo(_qHdr.cluster_size)) { AaruConsole.ErrorWriteLine("Cluster size must be a power of 2"); + return ErrorNumber.InvalidArgument; } + if(_qHdr.cluster_size < 4096 || _qHdr.cluster_size > 67108864) { AaruConsole.ErrorWriteLine("Cluster size must be between 4 Kbytes and 64 Mbytes"); - return ErrorNumber.InvalidArgument; - } - if(!IsPowerOfTwo(_qHdr.table_size)) - { - AaruConsole.ErrorWriteLine("Table size must be a power of 2"); - return ErrorNumber.InvalidArgument; - } - if(_qHdr.table_size < 1 || - _qHdr.table_size > 16) - { - AaruConsole.ErrorWriteLine( - "Table size must be between 1 and 16 clusters"); - return ErrorNumber.InvalidArgument; - } - if((_qHdr.features & QED_FEATURE_MASK) > 0) - { - AaruConsole.ErrorWriteLine( - $"Image uses unknown incompatible features {_qHdr.features & QED_FEATURE_MASK:X}"); return ErrorNumber.InvalidArgument; } + + if(!IsPowerOfTwo(_qHdr.table_size)) + { + AaruConsole.ErrorWriteLine("Table size must be a power of 2"); + + return ErrorNumber.InvalidArgument; + } + + if(_qHdr.table_size < 1 || + _qHdr.table_size > 16) + { + AaruConsole.ErrorWriteLine("Table size must be between 1 and 16 clusters"); + + return ErrorNumber.InvalidArgument; + } + + if((_qHdr.features & QED_FEATURE_MASK) > 0) + { + AaruConsole. + ErrorWriteLine($"Image uses unknown incompatible features {_qHdr.features & QED_FEATURE_MASK:X}"); + + return ErrorNumber.InvalidArgument; + } + if((_qHdr.features & QED_FEATURE_BACKING_FILE) == QED_FEATURE_BACKING_FILE) { AaruConsole.ErrorWriteLine("Differencing images not yet supported"); return ErrorNumber.NotImplemented; } + _clusterSectors = _qHdr.cluster_size / 512; _tableSize = _qHdr.cluster_size * _qHdr.table_size / 8; AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterSectors = {0}", _clusterSectors); AaruConsole.DebugWriteLine("QED plugin", "qHdr.tableSize = {0}", _tableSize); - byte[] l1TableB = new byte[_tableSize * 8]; + var l1TableB = new byte[_tableSize * 8]; stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); stream.Read(l1TableB, 0, (int)_tableSize * 8); AaruConsole.DebugWriteLine("QED plugin", "Reading L1 table"); _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); _l1Mask = 0; - int c = 0; + var c = 0; _clusterBits = Ctz32(_qHdr.cluster_size); _l2Mask = (_tableSize - 1) << _clusterBits; _l1Shift = _clusterBits + Ctz32(_tableSize); - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -141,7 +152,7 @@ public sealed partial class Qed _sectorMask = 0; - for(int i = 0; i < _clusterBits; i++) + for(var i = 0; i < _clusterBits; i++) _sectorMask = (_sectorMask << 1) + 1; AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterBits = {0}", _clusterBits); @@ -210,7 +221,7 @@ public sealed partial class Qed if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { _imageStream.Seek((long)_l1Table[l1Off], SeekOrigin.Begin); - byte[] l2TableB = new byte[_tableSize * 8]; + var l2TableB = new byte[_tableSize * 8]; _imageStream.Read(l2TableB, 0, (int)_tableSize * 8); AaruConsole.DebugWriteLine("QED plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); diff --git a/Aaru.Images/QED/Structs.cs b/Aaru.Images/QED/Structs.cs index 0d40a9b6e..3f9ca59cb 100644 --- a/Aaru.Images/QED/Structs.cs +++ b/Aaru.Images/QED/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Qed { /// QED header, big-endian diff --git a/Aaru.Images/QED/Unsupported.cs b/Aaru.Images/QED/Unsupported.cs index 2cbce8ce6..07e00134f 100644 --- a/Aaru.Images/QED/Unsupported.cs +++ b/Aaru.Images/QED/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Qed { /// diff --git a/Aaru.Images/QED/Write.cs b/Aaru.Images/QED/Write.cs index 64725f1bf..5f82fe668 100644 --- a/Aaru.Images/QED/Write.cs +++ b/Aaru.Images/QED/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Qed { /// @@ -105,12 +105,12 @@ public sealed partial class Qed _l1Table = new ulong[_tableSize]; _l1Mask = 0; - int c = 0; + var c = 0; _clusterBits = Ctz32(_qHdr.cluster_size); _l2Mask = (_tableSize - 1) << _clusterBits; _l1Shift = _clusterBits + Ctz32(_tableSize); - for(int i = 0; i < 64; i++) + for(var i = 0; i < 64; i++) { _l1Mask <<= 1; @@ -123,10 +123,10 @@ public sealed partial class Qed _sectorMask = 0; - for(int i = 0; i < _clusterBits; i++) + for(var i = 0; i < _clusterBits; i++) _sectorMask = (_sectorMask << 1) + 1; - byte[] empty = new byte[_qHdr.l1_table_offset + (_tableSize * 8)]; + var empty = new byte[_qHdr.l1_table_offset + _tableSize * 8]; _writingStream.Write(empty, 0, empty.Length); IsWriting = true; @@ -186,7 +186,7 @@ public sealed partial class Qed { _writingStream.Seek(0, SeekOrigin.End); _l1Table[l1Off] = (ulong)_writingStream.Position; - byte[] l2TableB = new byte[_tableSize * 8]; + var l2TableB = new byte[_tableSize * 8]; _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(l2TableB, 0, l2TableB.Length); } @@ -195,18 +195,18 @@ public sealed partial class Qed ulong l2Off = (byteAddress & _l2Mask) >> _clusterBits; - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); - byte[] entry = new byte[8]; + var entry = new byte[8]; _writingStream.Read(entry, 0, 8); - ulong offset = BitConverter.ToUInt64(entry, 0); + var offset = BitConverter.ToUInt64(entry, 0); if(offset == 0) { offset = (ulong)_writingStream.Length; - byte[] cluster = new byte[_qHdr.cluster_size]; + var cluster = new byte[_qHdr.cluster_size]; entry = BitConverter.GetBytes(offset); - _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + l2Off * 8), SeekOrigin.Begin); _writingStream.Write(entry, 0, 8); _writingStream.Seek(0, SeekOrigin.End); _writingStream.Write(cluster, 0, cluster.Length); @@ -251,7 +251,7 @@ public sealed partial class Qed for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[_imageInfo.SectorSize]; + var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) @@ -289,7 +289,7 @@ public sealed partial class Qed return false; } - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; MemoryMarshal.Write(hdr, ref _qHdr); _writingStream.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Images/RayDIM/Enums.cs b/Aaru.Images/RayDIM/Enums.cs index 85f00f34f..1d2316ff0 100644 --- a/Aaru.Images/RayDIM/Enums.cs +++ b/Aaru.Images/RayDIM/Enums.cs @@ -30,17 +30,20 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class RayDim { [SuppressMessage("ReSharper", "InconsistentNaming")] enum RayDiskTypes : byte { - Md2dd = 1, Md2hd = 2, Mf2dd = 3, - Mf2hd = 4, Mf2ed = 5 + Md2dd = 1, + Md2hd = 2, + Mf2dd = 3, + Mf2hd = 4, + Mf2ed = 5 } } \ No newline at end of file diff --git a/Aaru.Images/RayDIM/Identify.cs b/Aaru.Images/RayDIM/Identify.cs index e9071ff4f..8eb436847 100644 --- a/Aaru.Images/RayDIM/Identify.cs +++ b/Aaru.Images/RayDIM/Identify.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class RayDim { /// @@ -48,7 +48,7 @@ public sealed partial class RayDim if(stream.Length < Marshal.SizeOf
()) return false; - byte[] buffer = new byte[Marshal.SizeOf
()]; + var buffer = new byte[Marshal.SizeOf
()]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); @@ -60,8 +60,7 @@ public sealed partial class RayDim AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.diskType = {0}", header.diskType); AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.heads = {0}", header.heads); - AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.cylinders = {0}", - header.cylinders); + AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.cylinders = {0}", header.cylinders); AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.sectorsPerTrack = {0}", header.sectorsPerTrack); @@ -69,8 +68,7 @@ public sealed partial class RayDim var sx = new Regex(REGEX_SIGNATURE); Match sm = sx.Match(signature); - AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.signature matches? = {0}", - sm.Success); + AaruConsole.DebugWriteLine("Ray Arachelian's Disk IMage plugin", "header.signature matches? = {0}", sm.Success); return sm.Success; } diff --git a/Aaru.Images/RayDIM/Properties.cs b/Aaru.Images/RayDIM/Properties.cs index c07f16fe0..e189f673a 100644 --- a/Aaru.Images/RayDIM/Properties.cs +++ b/Aaru.Images/RayDIM/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class RayDim { /// public string Name => "Ray Arachelian's Disk IMage"; /// - public Guid Id => new Guid("F541F4E7-C1E3-4A2D-B07F-D863E87AB961"); + public Guid Id => new("F541F4E7-C1E3-4A2D-B07F-D863E87AB961"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/RayDIM/RayDIM.cs b/Aaru.Images/RayDIM/RayDIM.cs index 998887394..e6d6d2ba2 100644 --- a/Aaru.Images/RayDIM/RayDIM.cs +++ b/Aaru.Images/RayDIM/RayDIM.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing Ray Arachellian's DIM disk images public sealed partial class RayDim : IWritableImage diff --git a/Aaru.Images/RayDIM/Read.cs b/Aaru.Images/RayDIM/Read.cs index c4b3db247..21e5549bc 100644 --- a/Aaru.Images/RayDIM/Read.cs +++ b/Aaru.Images/RayDIM/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text.RegularExpressions; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class RayDim { /// @@ -49,7 +49,7 @@ public sealed partial class RayDim if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; - byte[] buffer = new byte[Marshal.SizeOf
()]; + var buffer = new byte[Marshal.SizeOf
()]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); @@ -71,10 +71,10 @@ public sealed partial class RayDim _imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack; _imageInfo.SectorSize = 512; - byte[] sectors = new byte[_imageInfo.SectorsPerTrack * _imageInfo.SectorSize]; + var sectors = new byte[_imageInfo.SectorsPerTrack * _imageInfo.SectorSize]; _disk = new MemoryStream(); - for(int i = 0; i < _imageInfo.SectorsPerTrack * _imageInfo.SectorSize; i++) + for(var i = 0; i < _imageInfo.SectorsPerTrack * _imageInfo.SectorSize; i++) { stream.Read(sectors, 0, sectors.Length); stream.Seek(_imageInfo.SectorsPerTrack, SeekOrigin.Current); @@ -109,8 +109,7 @@ public sealed partial class RayDim } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) diff --git a/Aaru.Images/RayDIM/Structs.cs b/Aaru.Images/RayDIM/Structs.cs index 5c8f20ca1..d0d125a4b 100644 --- a/Aaru.Images/RayDIM/Structs.cs +++ b/Aaru.Images/RayDIM/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class RayDim { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/RayDIM/Unsupported.cs b/Aaru.Images/RayDIM/Unsupported.cs index 514143911..e8b5496a9 100644 --- a/Aaru.Images/RayDIM/Unsupported.cs +++ b/Aaru.Images/RayDIM/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class RayDim { /// diff --git a/Aaru.Images/RayDIM/Write.cs b/Aaru.Images/RayDIM/Write.cs index 1bc557ef6..69c28a34d 100644 --- a/Aaru.Images/RayDIM/Write.cs +++ b/Aaru.Images/RayDIM/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class RayDim { /// @@ -132,7 +132,7 @@ public sealed partial class RayDim return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -166,7 +166,7 @@ public sealed partial class RayDim return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -241,7 +241,7 @@ public sealed partial class RayDim header.signature[0x4A] = 0x00; - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/RsIde/Enums.cs b/Aaru.Images/RsIde/Enums.cs index 4484d9e4e..2bee07bfe 100644 --- a/Aaru.Images/RsIde/Enums.cs +++ b/Aaru.Images/RsIde/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.DiscImages; +using System; + public sealed partial class RsIde { [Flags] diff --git a/Aaru.Images/RsIde/Helpers.cs b/Aaru.Images/RsIde/Helpers.cs index 686eafb82..35ab41ee8 100644 --- a/Aaru.Images/RsIde/Helpers.cs +++ b/Aaru.Images/RsIde/Helpers.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Text; -namespace Aaru.DiscImages; - public sealed partial class RsIde { static byte[] ScrambleAtaString(string text, int length) @@ -43,23 +43,23 @@ public sealed partial class RsIde if(inbuf.Length % 2 != 0) { - byte[] tmpbuf = new byte[inbuf.Length + 1]; + var tmpbuf = new byte[inbuf.Length + 1]; Array.Copy(inbuf, 0, tmpbuf, 0, inbuf.Length); tmpbuf[^1] = 0x20; inbuf = tmpbuf; } - byte[] outbuf = new byte[inbuf.Length]; + var outbuf = new byte[inbuf.Length]; - for(int i = 0; i < length; i += 2) + for(var i = 0; i < length; i += 2) { outbuf[i] = inbuf[i + 1]; outbuf[i + 1] = inbuf[i]; } - byte[] retBuf = new byte[length]; + var retBuf = new byte[length]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) retBuf[i] = 0x20; Array.Copy(outbuf, 0, retBuf, 0, outbuf.Length >= length ? length : outbuf.Length); diff --git a/Aaru.Images/RsIde/Identify.cs b/Aaru.Images/RsIde/Identify.cs index d58c1c19c..51ef18693 100644 --- a/Aaru.Images/RsIde/Identify.cs +++ b/Aaru.Images/RsIde/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class RsIde { /// @@ -44,7 +44,7 @@ public sealed partial class RsIde Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] magic = new byte[7]; + var magic = new byte[7]; stream.Read(magic, 0, magic.Length); return magic.SequenceEqual(_signature); diff --git a/Aaru.Images/RsIde/Properties.cs b/Aaru.Images/RsIde/Properties.cs index 501597025..2fa872e87 100644 --- a/Aaru.Images/RsIde/Properties.cs +++ b/Aaru.Images/RsIde/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class RsIde { /// public string Name => "RS-IDE Hard Disk Image"; /// - public Guid Id => new Guid("47C3E78D-2BE2-4BA5-AA6B-FEE27C86FC65"); + public Guid Id => new("47C3E78D-2BE2-4BA5-AA6B-FEE27C86FC65"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/RsIde/Read.cs b/Aaru.Images/RsIde/Read.cs index 7ecabdad5..fedd825de 100644 --- a/Aaru.Images/RsIde/Read.cs +++ b/Aaru.Images/RsIde/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs.Devices.ATA; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class RsIde { /// @@ -49,7 +49,7 @@ public sealed partial class RsIde Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); Header hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); @@ -104,8 +104,7 @@ public sealed partial class RsIde } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -122,7 +121,7 @@ public sealed partial class RsIde Stream stream = _rsIdeImageFilter.GetDataForkStream(); - stream.Seek((long)(_dataOff + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(_dataOff + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); diff --git a/Aaru.Images/RsIde/RsIde.cs b/Aaru.Images/RsIde/RsIde.cs index 489770a7e..3e433bd63 100644 --- a/Aaru.Images/RsIde/RsIde.cs +++ b/Aaru.Images/RsIde/RsIde.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing RS-IDE disk images public sealed partial class RsIde : IWritableImage diff --git a/Aaru.Images/RsIde/Structs.cs b/Aaru.Images/RsIde/Structs.cs index 256dfc1a2..aff5049ee 100644 --- a/Aaru.Images/RsIde/Structs.cs +++ b/Aaru.Images/RsIde/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class RsIde { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/RsIde/Unsupported.cs b/Aaru.Images/RsIde/Unsupported.cs index 55a8fb7b5..720f313f5 100644 --- a/Aaru.Images/RsIde/Unsupported.cs +++ b/Aaru.Images/RsIde/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class RsIde { /// diff --git a/Aaru.Images/RsIde/Write.cs b/Aaru.Images/RsIde/Write.cs index f83d4497f..e9dc98c7a 100644 --- a/Aaru.Images/RsIde/Write.cs +++ b/Aaru.Images/RsIde/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Version = Aaru.CommonTypes.Interop.Version; -namespace Aaru.DiscImages; - public sealed partial class RsIde { /// @@ -143,7 +143,7 @@ public sealed partial class RsIde return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -177,7 +177,7 @@ public sealed partial class RsIde return false; } - _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + (sectorAddress * _imageInfo.SectorSize)), + _writingStream.Seek((long)((ulong)Marshal.SizeOf
() + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); @@ -254,18 +254,17 @@ public sealed partial class RsIde { var ataId = new Identify.IdentifyDevice { - GeneralConfiguration = - CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.UltraFastIDE | - CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.Fixed | - CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.NotMFM | CommonTypes.Structs. - Devices.ATA.Identify.GeneralConfigurationBit.SoftSector, - Cylinders = (ushort)_imageInfo.Cylinders, - Heads = (ushort)_imageInfo.Heads, + GeneralConfiguration = CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.UltraFastIDE | + CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.Fixed | + CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.NotMFM | + CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.SoftSector, + Cylinders = (ushort)_imageInfo.Cylinders, + Heads = (ushort)_imageInfo.Heads, SectorsPerTrack = (ushort)_imageInfo.SectorsPerTrack, - VendorWord47 = 0x80, + VendorWord47 = 0x80, Capabilities = CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.DMASupport | - CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY | CommonTypes.Structs. - Devices.ATA.Identify.CapabilitiesBit.LBASupport, + CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY | + CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.LBASupport, ExtendedIdentify = CommonTypes.Structs.Devices.ATA.Identify.ExtendedIdentifyBit.Words54to58Valid, CurrentCylinders = (ushort)_imageInfo.Cylinders, CurrentHeads = (ushort)_imageInfo.Heads, @@ -288,17 +287,16 @@ public sealed partial class RsIde if(string.IsNullOrEmpty(_imageInfo.DriveSerialNumber)) _imageInfo.DriveSerialNumber = $"{new Random().NextDouble():16X}"; - byte[] ataIdBytes = new byte[Marshal.SizeOf()]; + var ataIdBytes = new byte[Marshal.SizeOf()]; IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512); System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, true); - System.Runtime.InteropServices.Marshal.Copy(ptr, ataIdBytes, 0, - Marshal.SizeOf()); + System.Runtime.InteropServices.Marshal.Copy(ptr, ataIdBytes, 0, Marshal.SizeOf()); System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr); - Array.Copy(ScrambleAtaString(_imageInfo.DriveManufacturer + " " + _imageInfo.DriveModel, 40), 0, - ataIdBytes, 27 * 2, 40); + Array.Copy(ScrambleAtaString(_imageInfo.DriveManufacturer + " " + _imageInfo.DriveModel, 40), 0, ataIdBytes, + 27 * 2, 40); Array.Copy(ScrambleAtaString(_imageInfo.DriveFirmwareRevision, 8), 0, ataIdBytes, 23 * 2, 8); Array.Copy(ScrambleAtaString(_imageInfo.DriveSerialNumber, 20), 0, ataIdBytes, 10 * 2, 20); @@ -307,7 +305,7 @@ public sealed partial class RsIde else Array.Copy(_identify, 0, header.identify, 0, 106); - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/SaveDskF/Identify.cs b/Aaru.Images/SaveDskF/Identify.cs index a049b9700..8c0ab6011 100644 --- a/Aaru.Images/SaveDskF/Identify.cs +++ b/Aaru.Images/SaveDskF/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class SaveDskF { /// @@ -47,7 +47,7 @@ public sealed partial class SaveDskF if(stream.Length < 41) return false; - byte[] hdr = new byte[40]; + var hdr = new byte[40]; stream.Read(hdr, 0, 40); _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); diff --git a/Aaru.Images/SaveDskF/Properties.cs b/Aaru.Images/SaveDskF/Properties.cs index cb7ebc513..9da5c335c 100644 --- a/Aaru.Images/SaveDskF/Properties.cs +++ b/Aaru.Images/SaveDskF/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class SaveDskF { /// public string Name => "IBM SaveDskF"; /// - public Guid Id => new Guid("288CE058-1A51-4034-8C45-5A256CAE1461"); + public Guid Id => new("288CE058-1A51-4034-8C45-5A256CAE1461"); /// public ImageInfo Info => _imageInfo; /// @@ -68,11 +68,11 @@ public sealed partial class SaveDskF { MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.Apricot_35, MediaType.ATARI_35_DS_DD, MediaType.ATARI_35_DS_DD_11, MediaType.ATARI_35_SS_DD, MediaType.ATARI_35_SS_DD_11, MediaType.DMF, - MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, - MediaType.DOS_35_HD, MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, - MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, - MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, - MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II + MediaType.DMF_82, MediaType.DOS_35_DS_DD_8, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD, + MediaType.DOS_35_SS_DD_8, MediaType.DOS_35_SS_DD_9, MediaType.DOS_525_DS_DD_8, MediaType.DOS_525_DS_DD_9, + MediaType.DOS_525_HD, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, MediaType.FDFORMAT_35_DD, + MediaType.FDFORMAT_35_HD, MediaType.FDFORMAT_525_DD, MediaType.FDFORMAT_525_HD, MediaType.RX50, + MediaType.XDF_35, MediaType.XDF_525, MediaType.MetaFloppy_Mod_I, MediaType.MetaFloppy_Mod_II }; /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => diff --git a/Aaru.Images/SaveDskF/Read.cs b/Aaru.Images/SaveDskF/Read.cs index f2fdf6d6e..04efb1bd6 100644 --- a/Aaru.Images/SaveDskF/Read.cs +++ b/Aaru.Images/SaveDskF/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class SaveDskF { /// @@ -49,7 +49,7 @@ public sealed partial class SaveDskF Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] hdr = new byte[40]; + var hdr = new byte[40]; stream.Read(hdr, 0, 40); _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); @@ -78,7 +78,7 @@ public sealed partial class SaveDskF _header.magic == SDF_MAGIC_OLD) _header.dataOffset = 512; - byte[] cmt = new byte[_header.dataOffset - _header.commentOffset]; + var cmt = new byte[_header.dataOffset - _header.commentOffset]; stream.Seek(_header.commentOffset, SeekOrigin.Begin); stream.Read(cmt, 0, cmt.Length); @@ -109,9 +109,8 @@ public sealed partial class SaveDskF _imageInfo.Sectors = (ulong)(_header.sectorsPerTrack * _header.heads * _header.cylinders); _imageInfo.SectorSize = _header.sectorSize; - _imageInfo.MediaType = Geometry.GetMediaType((_header.cylinders, (byte)_header.heads, - _header.sectorsPerTrack, _header.sectorSize, - MediaEncoding.MFM, false)); + _imageInfo.MediaType = Geometry.GetMediaType((_header.cylinders, (byte)_header.heads, _header.sectorsPerTrack, + _header.sectorSize, MediaEncoding.MFM, false)); _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; @@ -141,8 +140,7 @@ public sealed partial class SaveDskF } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -157,8 +155,7 @@ public sealed partial class SaveDskF buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, - length * _imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, length * _imageInfo.SectorSize); return ErrorNumber.NoError; } diff --git a/Aaru.Images/SaveDskF/SaveDskF.cs b/Aaru.Images/SaveDskF/SaveDskF.cs index ef4e4cf69..945adb11a 100644 --- a/Aaru.Images/SaveDskF/SaveDskF.cs +++ b/Aaru.Images/SaveDskF/SaveDskF.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading and writing IBM's SaveDskF disk images public sealed partial class SaveDskF : IWritableImage, IVerifiableImage { diff --git a/Aaru.Images/SaveDskF/Structs.cs b/Aaru.Images/SaveDskF/Structs.cs index 782a9de87..79e23b7a2 100644 --- a/Aaru.Images/SaveDskF/Structs.cs +++ b/Aaru.Images/SaveDskF/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class SaveDskF { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/SaveDskF/Unsupported.cs b/Aaru.Images/SaveDskF/Unsupported.cs index ff13756d8..869ed9475 100644 --- a/Aaru.Images/SaveDskF/Unsupported.cs +++ b/Aaru.Images/SaveDskF/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class SaveDskF { /// diff --git a/Aaru.Images/SaveDskF/Write.cs b/Aaru.Images/SaveDskF/Write.cs index b90ec5a6d..781460708 100644 --- a/Aaru.Images/SaveDskF/Write.cs +++ b/Aaru.Images/SaveDskF/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class SaveDskF { /// @@ -77,7 +77,7 @@ public sealed partial class SaveDskF return false; } - _writingStream.Seek((long)(512 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(512 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -109,7 +109,7 @@ public sealed partial class SaveDskF return false; } - _writingStream.Seek((long)(512 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Seek((long)(512 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -154,7 +154,7 @@ public sealed partial class SaveDskF : commentsBytes.Length); } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/SuperCardPro/Enums.cs b/Aaru.Images/SuperCardPro/Enums.cs index b324d0c5a..dbb4b4d17 100644 --- a/Aaru.Images/SuperCardPro/Enums.cs +++ b/Aaru.Images/SuperCardPro/Enums.cs @@ -30,22 +30,36 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.DiscImages; +using System; + public sealed partial class SuperCardPro { public enum ScpDiskType : byte { - Commodore64 = 0x00, CommodoreAmiga = 0x04, AtariFMSS = 0x10, - AtariFMDS = 0x11, AtariFSEx = 0x12, AtariSTSS = 0x14, - AtariSTDS = 0x15, AppleII = 0x20, AppleIIPro = 0x21, - Apple400K = 0x24, Apple800K = 0x25, Apple144 = 0x26, - PC360K = 0x30, PC720K = 0x31, PC12M = 0x32, - PC144M = 0x33, TandySSSD = 0x40, TandySSDD = 0x41, - TandyDSSD = 0x42, TandyDSDD = 0x43, Ti994A = 0x50, - RolandD20 = 0x60 + Commodore64 = 0x00, + CommodoreAmiga = 0x04, + AtariFMSS = 0x10, + AtariFMDS = 0x11, + AtariFSEx = 0x12, + AtariSTSS = 0x14, + AtariSTDS = 0x15, + AppleII = 0x20, + AppleIIPro = 0x21, + Apple400K = 0x24, + Apple800K = 0x25, + Apple144 = 0x26, + PC360K = 0x30, + PC720K = 0x31, + PC12M = 0x32, + PC144M = 0x33, + TandySSSD = 0x40, + TandySSDD = 0x41, + TandyDSSD = 0x42, + TandyDSDD = 0x43, + Ti994A = 0x50, + RolandD20 = 0x60 } [Flags] diff --git a/Aaru.Images/SuperCardPro/Helpers.cs b/Aaru.Images/SuperCardPro/Helpers.cs index 1e210a6f7..426bb317f 100644 --- a/Aaru.Images/SuperCardPro/Helpers.cs +++ b/Aaru.Images/SuperCardPro/Helpers.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; -namespace Aaru.DiscImages; - public sealed partial class SuperCardPro { static string ReadPStringUtf8(Stream stream, uint position) @@ -44,15 +44,15 @@ public sealed partial class SuperCardPro return null; stream.Position = position; - byte[] lenB = new byte[2]; + var lenB = new byte[2]; stream.Read(lenB, 0, 2); - ushort len = BitConverter.ToUInt16(lenB, 0); + var len = BitConverter.ToUInt16(lenB, 0); if(len == 0 || len + stream.Position >= stream.Length) return null; - byte[] str = new byte[len]; + var str = new byte[len]; stream.Read(str, 0, len); return Encoding.UTF8.GetString(str); diff --git a/Aaru.Images/SuperCardPro/Identify.cs b/Aaru.Images/SuperCardPro/Identify.cs index 9d0d41f44..c9bcc6eb6 100644 --- a/Aaru.Images/SuperCardPro/Identify.cs +++ b/Aaru.Images/SuperCardPro/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class SuperCardPro { /// @@ -49,7 +49,7 @@ public sealed partial class SuperCardPro if(stream.Length < Marshal.SizeOf()) return false; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.Read(hdr, 0, Marshal.SizeOf()); Header = Marshal.ByteArrayToStructureLittleEndian(hdr); diff --git a/Aaru.Images/SuperCardPro/Properties.cs b/Aaru.Images/SuperCardPro/Properties.cs index 942efbf76..f1a1a4a4a 100644 --- a/Aaru.Images/SuperCardPro/Properties.cs +++ b/Aaru.Images/SuperCardPro/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class SuperCardPro { /// @@ -44,7 +44,7 @@ public sealed partial class SuperCardPro /// public string Name => "SuperCardPro"; /// - public Guid Id => new Guid("C5D3182E-1D45-4767-A205-E6E5C83444DC"); + public Guid Id => new("C5D3182E-1D45-4767-A205-E6E5C83444DC"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/SuperCardPro/Read.cs b/Aaru.Images/SuperCardPro/Read.cs index 96a1208b6..6cef125bd 100644 --- a/Aaru.Images/SuperCardPro/Read.cs +++ b/Aaru.Images/SuperCardPro/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class SuperCardPro { /// @@ -53,7 +53,7 @@ public sealed partial class SuperCardPro if(_scpStream.Length < Marshal.SizeOf()) return ErrorNumber.InvalidArgument; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; _scpStream.Read(hdr, 0, Marshal.SizeOf()); Header = Marshal.ByteArrayToStructureLittleEndian(hdr); @@ -97,8 +97,8 @@ public sealed partial class SuperCardPro if(!trk.Signature.SequenceEqual(_trkSignature)) { - AaruConsole.DebugWriteLine("SuperCardPro plugin", - "Track header at {0} contains incorrect signature.", Header.offsets[t]); + AaruConsole.DebugWriteLine("SuperCardPro plugin", "Track header at {0} contains incorrect signature.", + Header.offsets[t]); continue; } @@ -115,7 +115,7 @@ public sealed partial class SuperCardPro for(byte r = 0; r < Header.revolutions; r++) { - byte[] rev = new byte[Marshal.SizeOf()]; + var rev = new byte[Marshal.SizeOf()]; _scpStream.Read(rev, 0, Marshal.SizeOf()); trk.Entries[r] = Marshal.ByteArrayToStructureLittleEndian(rev); @@ -134,9 +134,9 @@ public sealed partial class SuperCardPro while(_scpStream.Position >= position) { - byte[] footerSig = new byte[4]; + var footerSig = new byte[4]; _scpStream.Read(footerSig, 0, 4); - uint footerMagic = BitConverter.ToUInt32(footerSig, 0); + var footerMagic = BitConverter.ToUInt32(footerSig, 0); if(footerMagic == FOOTER_SIGNATURE) { @@ -144,7 +144,7 @@ public sealed partial class SuperCardPro AaruConsole.DebugWriteLine("SuperCardPro plugin", "Found footer at {0}", _scpStream.Position); - byte[] ftr = new byte[Marshal.SizeOf
()]; + var ftr = new byte[Marshal.SizeOf
()]; _scpStream.Read(ftr, 0, Marshal.SizeOf
()); Footer footer = Marshal.ByteArrayToStructureLittleEndian
(ftr); @@ -167,8 +167,7 @@ public sealed partial class SuperCardPro AaruConsole.DebugWriteLine("SuperCardPro plugin", "footer.commentsOffset = 0x{0:X8}", footer.commentsOffset); - AaruConsole.DebugWriteLine("SuperCardPro plugin", "footer.creationTime = {0}", - footer.creationTime); + AaruConsole.DebugWriteLine("SuperCardPro plugin", "footer.creationTime = {0}", footer.creationTime); AaruConsole.DebugWriteLine("SuperCardPro plugin", "footer.modificationTime = {0}", footer.modificationTime); @@ -265,8 +264,7 @@ public sealed partial class SuperCardPro } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) => diff --git a/Aaru.Images/SuperCardPro/Structs.cs b/Aaru.Images/SuperCardPro/Structs.cs index ec17e337d..912cb3f56 100644 --- a/Aaru.Images/SuperCardPro/Structs.cs +++ b/Aaru.Images/SuperCardPro/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class SuperCardPro { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/SuperCardPro/SuperCardPro.cs b/Aaru.Images/SuperCardPro/SuperCardPro.cs index 3a0839c7d..87725cbcf 100644 --- a/Aaru.Images/SuperCardPro/SuperCardPro.cs +++ b/Aaru.Images/SuperCardPro/SuperCardPro.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// Implements reading SuperCardPro flux images public sealed partial class SuperCardPro : IMediaImage, IVerifiableImage, IVerifiableSectorsImage { diff --git a/Aaru.Images/SuperCardPro/Verify.cs b/Aaru.Images/SuperCardPro/Verify.cs index ff819df0a..1359a2b52 100644 --- a/Aaru.Images/SuperCardPro/Verify.cs +++ b/Aaru.Images/SuperCardPro/Verify.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; -namespace Aaru.DiscImages; - public sealed partial class SuperCardPro { /// @@ -43,13 +43,13 @@ public sealed partial class SuperCardPro if(Header.flags.HasFlag(ScpFlags.Writable)) return null; - byte[] wholeFile = new byte[_scpStream.Length]; - uint sum = 0; + var wholeFile = new byte[_scpStream.Length]; + uint sum = 0; _scpStream.Position = 0; _scpStream.Read(wholeFile, 0, wholeFile.Length); - for(int i = 0x10; i < wholeFile.Length; i++) + for(var i = 0x10; i < wholeFile.Length; i++) sum += wholeFile[i]; return Header.checksum == sum; diff --git a/Aaru.Images/T98/Identify.cs b/Aaru.Images/T98/Identify.cs index b27b37729..427d44189 100644 --- a/Aaru.Images/T98/Identify.cs +++ b/Aaru.Images/T98/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class T98 { /// @@ -48,19 +48,19 @@ public sealed partial class T98 if(stream.Length % 256 != 0) return false; - byte[] hdrB = new byte[256]; + var hdrB = new byte[256]; stream.Read(hdrB, 0, hdrB.Length); - for(int i = 4; i < 256; i++) + for(var i = 4; i < 256; i++) if(hdrB[i] != 0) return false; - int cylinders = BitConverter.ToInt32(hdrB, 0); + var cylinders = BitConverter.ToInt32(hdrB, 0); AaruConsole.DebugWriteLine("T98 plugin", "cylinders = {0}", cylinders); // This format is expanding, so length can be smaller // Just grow it, I won't risk false positives... - return stream.Length == (cylinders * 8 * 33 * 256) + 256; + return stream.Length == cylinders * 8 * 33 * 256 + 256; } } \ No newline at end of file diff --git a/Aaru.Images/T98/Properties.cs b/Aaru.Images/T98/Properties.cs index fe5f54423..e2078c1f6 100644 --- a/Aaru.Images/T98/Properties.cs +++ b/Aaru.Images/T98/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,14 +39,12 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class T98 { /// public string Name => "T98 Hard Disk Image"; /// - public Guid Id => new Guid("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); + public Guid Id => new("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); /// public ImageInfo Info => _imageInfo; /// diff --git a/Aaru.Images/T98/Read.cs b/Aaru.Images/T98/Read.cs index d7dadb151..cadd4daf0 100644 --- a/Aaru.Images/T98/Read.cs +++ b/Aaru.Images/T98/Read.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class T98 { /// @@ -49,14 +49,14 @@ public sealed partial class T98 if(stream.Length % 256 != 0) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[256]; + var hdrB = new byte[256]; stream.Read(hdrB, 0, hdrB.Length); - for(int i = 4; i < 256; i++) + for(var i = 4; i < 256; i++) if(hdrB[i] != 0) return ErrorNumber.InvalidArgument; - int cylinders = BitConverter.ToInt32(hdrB, 0); + var cylinders = BitConverter.ToInt32(hdrB, 0); _imageInfo.MediaType = MediaType.GENERIC_HDD; @@ -64,7 +64,7 @@ public sealed partial class T98 _imageInfo.CreationTime = imageFilter.CreationTime; _imageInfo.LastModificationTime = imageFilter.LastWriteTime; _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.Filename); - _imageInfo.Sectors = (ulong)((stream.Length / 256) - 1); + _imageInfo.Sectors = (ulong)(stream.Length / 256 - 1); _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; _imageInfo.SectorSize = 256; _imageInfo.Cylinders = (uint)cylinders; @@ -77,8 +77,7 @@ public sealed partial class T98 } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -95,7 +94,7 @@ public sealed partial class T98 Stream stream = _t98ImageFilter.GetDataForkStream(); - stream.Seek((long)(256 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(256 + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); diff --git a/Aaru.Images/T98/T98.cs b/Aaru.Images/T98/T98.cs index f6e5819dc..b9322203b 100644 --- a/Aaru.Images/T98/T98.cs +++ b/Aaru.Images/T98/T98.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing T98 disk images public sealed partial class T98 : IWritableImage diff --git a/Aaru.Images/T98/Unsupported.cs b/Aaru.Images/T98/Unsupported.cs index 25e40f6e9..f77291b89 100644 --- a/Aaru.Images/T98/Unsupported.cs +++ b/Aaru.Images/T98/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class T98 { /// diff --git a/Aaru.Images/T98/Write.cs b/Aaru.Images/T98/Write.cs index 91c957cc2..8856b1da2 100644 --- a/Aaru.Images/T98/Write.cs +++ b/Aaru.Images/T98/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class T98 { /// @@ -117,7 +117,7 @@ public sealed partial class T98 return false; } - _writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); + _writingStream.Seek((long)(256 + sectorAddress * 256), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -149,7 +149,7 @@ public sealed partial class T98 return false; } - _writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); + _writingStream.Seek((long)(256 + sectorAddress * 256), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -183,7 +183,7 @@ public sealed partial class T98 return false; } - int cylinders = (int)(_imageInfo.Sectors / 33 / 8); + var cylinders = (int)(_imageInfo.Sectors / 33 / 8); _writingStream.Seek(0, SeekOrigin.Begin); _writingStream.Write(BitConverter.GetBytes(cylinders), 0, 4); diff --git a/Aaru.Images/TeleDisk/Constants.cs b/Aaru.Images/TeleDisk/Constants.cs index 656d4a6dc..c300f87f2 100644 --- a/Aaru.Images/TeleDisk/Constants.cs +++ b/Aaru.Images/TeleDisk/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class TeleDisk { diff --git a/Aaru.Images/TeleDisk/Helpers.cs b/Aaru.Images/TeleDisk/Helpers.cs index 65ba6770d..3486abca2 100644 --- a/Aaru.Images/TeleDisk/Helpers.cs +++ b/Aaru.Images/TeleDisk/Helpers.cs @@ -30,34 +30,34 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class TeleDisk { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); - byte head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); - byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); + var cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + var head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); + var sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } static ushort TeleDiskCrc(ushort crc, byte[] buffer) { - int counter = 0; + var counter = 0; while(counter < buffer.Length) { crc ^= (ushort)((buffer[counter] & 0xFF) << 8); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) if((crc & 0x8000) > 0) crc = (ushort)((crc << 1) ^ TELE_DISK_CRC_POLY); else @@ -118,16 +118,16 @@ public sealed partial class TeleDisk break; case DATA_BLOCK_PATTERN: { - int ins = 0; - int outs = 0; + var ins = 0; + var outs = 0; while(ins < encodedData.Length) { - byte[] repeatValue = new byte[2]; + var repeatValue = new byte[2]; - ushort repeatNumber = BitConverter.ToUInt16(encodedData, ins); + var repeatNumber = BitConverter.ToUInt16(encodedData, ins); Array.Copy(encodedData, ins + 2, repeatValue, 0, 2); - byte[] decodedPiece = new byte[repeatNumber * 2]; + var decodedPiece = new byte[repeatNumber * 2]; ArrayHelpers.ArrayFill(decodedPiece, repeatValue); Array.Copy(decodedPiece, 0, decodedData, outs, decodedPiece.Length); ins += 4; @@ -140,19 +140,18 @@ public sealed partial class TeleDisk AaruConsole.DebugWriteLine("TeleDisk plugin", "(Block pattern decoder): Processed input: {0} bytes", ins); - AaruConsole.DebugWriteLine("TeleDisk plugin", - "(Block pattern decoder): Output data size: {0} bytes", + AaruConsole.DebugWriteLine("TeleDisk plugin", "(Block pattern decoder): Output data size: {0} bytes", decodedData.Length); - AaruConsole.DebugWriteLine("TeleDisk plugin", - "(Block pattern decoder): Processed Output: {0} bytes", outs); + AaruConsole.DebugWriteLine("TeleDisk plugin", "(Block pattern decoder): Processed Output: {0} bytes", + outs); break; } case DATA_BLOCK_RLE: { - int ins = 0; - int outs = 0; + var ins = 0; + var outs = 0; while(ins < encodedData.Length) { @@ -170,10 +169,10 @@ public sealed partial class TeleDisk else { length = (byte)(encoding * 2); - byte run = encodedData[ins + 1]; - byte[] part = new byte[length]; + byte run = encodedData[ins + 1]; + var part = new byte[length]; Array.Copy(encodedData, ins + 2, part, 0, length); - byte[] piece = new byte[length * run]; + var piece = new byte[length * run]; ArrayHelpers.ArrayFill(piece, part); Array.Copy(piece, 0, decodedData, outs, piece.Length); ins += 2 + length; @@ -212,13 +211,11 @@ public sealed partial class TeleDisk { switch(_totalDiskSize) { - case 143360: - return _imageInfo.SectorSize == 256 ? MediaType.MetaFloppy_Mod_I : MediaType.Unknown; + case 143360: return _imageInfo.SectorSize == 256 ? MediaType.MetaFloppy_Mod_I : MediaType.Unknown; case 163840: { // Acorn disk uses 256 bytes/sector - return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_40 - : MediaType.DOS_525_SS_DD_8; + return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_40 : MediaType.DOS_525_SS_DD_8; // DOS disks use 512 bytes/sector } @@ -229,13 +226,11 @@ public sealed partial class TeleDisk // DOS disks use 512 bytes/sector } - case 315392: - return _imageInfo.SectorSize == 256 ? MediaType.MetaFloppy_Mod_II : MediaType.Unknown; + case 315392: return _imageInfo.SectorSize == 256 ? MediaType.MetaFloppy_Mod_II : MediaType.Unknown; case 327680: { // Acorn disk uses 256 bytes/sector - return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_80 - : MediaType.DOS_525_DS_DD_8; + return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_80 : MediaType.DOS_525_DS_DD_8; // DOS disks use 512 bytes/sector } @@ -336,8 +331,8 @@ public sealed partial class TeleDisk } default: { - AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown drive type {1} with {0} bytes", - _totalDiskSize, _header.DriveType); + AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown drive type {1} with {0} bytes", _totalDiskSize, + _header.DriveType); return MediaType.Unknown; } diff --git a/Aaru.Images/TeleDisk/Identify.cs b/Aaru.Images/TeleDisk/Identify.cs index d06e9400e..55c7c87ed 100644 --- a/Aaru.Images/TeleDisk/Identify.cs +++ b/Aaru.Images/TeleDisk/Identify.cs @@ -30,20 +30,20 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class TeleDisk { /// public bool Identify(IFilter imageFilter) { _header = new Header(); - byte[] headerBytes = new byte[12]; + var headerBytes = new byte[12]; Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); @@ -65,7 +65,7 @@ public sealed partial class TeleDisk _header.Sides = headerBytes[9]; _header.Crc = BitConverter.ToUInt16(headerBytes, 10); - byte[] headerBytesForCrc = new byte[10]; + var headerBytesForCrc = new byte[10]; Array.Copy(headerBytes, headerBytesForCrc, 10); ushort calculatedHeaderCrc = TeleDiskCrc(0x0000, headerBytesForCrc); diff --git a/Aaru.Images/TeleDisk/Properties.cs b/Aaru.Images/TeleDisk/Properties.cs index a7fbebf9a..7b860bc90 100644 --- a/Aaru.Images/TeleDisk/Properties.cs +++ b/Aaru.Images/TeleDisk/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class TeleDisk { /// @@ -45,7 +45,7 @@ public sealed partial class TeleDisk /// public string Name => "Sydex TeleDisk"; /// - public Guid Id => new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); + public Guid Id => new("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/TeleDisk/Read.cs b/Aaru.Images/TeleDisk/Read.cs index 18a63a9df..998e97230 100644 --- a/Aaru.Images/TeleDisk/Read.cs +++ b/Aaru.Images/TeleDisk/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; @@ -38,15 +40,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Compression; using Aaru.Console; -namespace Aaru.DiscImages; - public sealed partial class TeleDisk { /// public ErrorNumber Open(IFilter imageFilter) { _header = new Header(); - byte[] headerBytes = new byte[12]; + var headerBytes = new byte[12]; _inStream = imageFilter.GetDataForkStream(); var stream = new MemoryStream(); _inStream.Seek(0, SeekOrigin.Begin); @@ -74,7 +74,7 @@ public sealed partial class TeleDisk _imageInfo.Version = $"{(_header.Version & 0xF0) >> 4}.{_header.Version & 0x0F}"; _imageInfo.Application = _imageInfo.Version; - byte[] headerBytesForCrc = new byte[10]; + var headerBytesForCrc = new byte[10]; Array.Copy(headerBytes, headerBytesForCrc, 10); ushort calculatedHeaderCrc = TeleDiskCrc(0x0000, headerBytesForCrc); @@ -132,7 +132,7 @@ public sealed partial class TeleDisk else { // Not using Stream.CopyTo() because it's failing with LZIP - byte[] copybuf = new byte[_inStream.Length]; + var copybuf = new byte[_inStream.Length]; _inStream.Seek(0, SeekOrigin.Begin); _inStream.Read(copybuf, 0, copybuf.Length); stream.Seek(0, SeekOrigin.Begin); @@ -147,7 +147,7 @@ public sealed partial class TeleDisk { _commentHeader = new CommentBlockHeader(); - byte[] commentHeaderBytes = new byte[10]; + var commentHeaderBytes = new byte[10]; stream.Read(commentHeaderBytes, 0, 10); _commentHeader.Crc = BitConverter.ToUInt16(commentHeaderBytes, 0); @@ -162,7 +162,7 @@ public sealed partial class TeleDisk _commentBlock = new byte[_commentHeader.Length]; stream.Read(_commentBlock, 0, _commentHeader.Length); - byte[] commentBlockForCrc = new byte[_commentHeader.Length + 8]; + var commentBlockForCrc = new byte[_commentHeader.Length + 8]; Array.Copy(commentHeaderBytes, 2, commentBlockForCrc, 0, 8); Array.Copy(_commentBlock, 0, commentBlockForCrc, 8, _commentHeader.Length); @@ -172,8 +172,7 @@ public sealed partial class TeleDisk AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.crc = 0x{0:X4}", _commentHeader.Crc); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tCalculated CRC = 0x{0:X4}", cmtcrc); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.length = {0} bytes", - _commentHeader.Length); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.length = {0} bytes", _commentHeader.Length); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.year = {0}", _commentHeader.Year); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.month = {0}", _commentHeader.Month); @@ -184,7 +183,7 @@ public sealed partial class TeleDisk _aDiskCrcHasFailed |= cmtcrc != _commentHeader.Crc; - for(int i = 0; i < _commentBlock.Length; i++) + for(var i = 0; i < _commentBlock.Length; i++) // Replace NULLs, used by TeleDisk as newline markers, with UNIX newline marker if(_commentBlock[i] == 0x00) @@ -216,7 +215,7 @@ public sealed partial class TeleDisk int totalCylinders = -1; int totalHeads = -1; int maxSector = -1; - int totalSectors = 0; + var totalSectors = 0; long currentPos = stream.Position; _imageInfo.SectorSize = uint.MaxValue; _imageInfo.SectorsPerTrack = uint.MaxValue; @@ -243,9 +242,9 @@ public sealed partial class TeleDisk for(byte processedSectors = 0; processedSectors < teleDiskTrack.Sectors; processedSectors++) { - var teleDiskSector = new SectorHeader(); - var teleDiskData = new DataHeader(); - byte[] dataSizeBytes = new byte[2]; + var teleDiskSector = new SectorHeader(); + var teleDiskData = new DataHeader(); + var dataSizeBytes = new byte[2]; teleDiskSector.Cylinder = (byte)stream.ReadByte(); teleDiskSector.Head = (byte)stream.ReadByte(); @@ -264,7 +263,7 @@ public sealed partial class TeleDisk teleDiskData.DataSize = BitConverter.ToUInt16(dataSizeBytes, 0); teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it teleDiskData.DataEncoding = (byte)stream.ReadByte(); - byte[] data = new byte[teleDiskData.DataSize]; + var data = new byte[teleDiskData.DataSize]; stream.Read(data, 0, teleDiskData.DataSize); } @@ -286,8 +285,8 @@ public sealed partial class TeleDisk return ErrorNumber.InvalidArgument; } - bool hasLeadOutOnHead0 = false; - bool hasLeadOutOnHead1 = false; + var hasLeadOutOnHead0 = false; + var hasLeadOutOnHead1 = false; _imageInfo.Cylinders = (ushort)totalCylinders; _imageInfo.Heads = (byte)totalHeads; @@ -321,9 +320,9 @@ public sealed partial class TeleDisk for(byte processedSectors = 0; processedSectors < teleDiskTrack.Sectors; processedSectors++) { - var teleDiskSector = new SectorHeader(); - var teleDiskData = new DataHeader(); - byte[] dataSizeBytes = new byte[2]; + var teleDiskSector = new SectorHeader(); + var teleDiskData = new DataHeader(); + var dataSizeBytes = new byte[2]; teleDiskSector.Cylinder = (byte)stream.ReadByte(); teleDiskSector.Head = (byte)stream.ReadByte(); @@ -340,7 +339,7 @@ public sealed partial class TeleDisk teleDiskData.DataSize = BitConverter.ToUInt16(dataSizeBytes, 0); teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it teleDiskData.DataEncoding = (byte)stream.ReadByte(); - byte[] data = new byte[teleDiskData.DataSize]; + var data = new byte[teleDiskData.DataSize]; stream.Read(data, 0, teleDiskData.DataSize); } } @@ -348,19 +347,19 @@ public sealed partial class TeleDisk _sectorsData = new byte[totalCylinders][][][]; // Total sectors per track - uint[][] spts = new uint[totalCylinders][]; + var spts = new uint[totalCylinders][]; AaruConsole.DebugWriteLine("TeleDisk plugin", "Found {0} cylinders and {1} heads with a maximum sector number of {2}", totalCylinders, totalHeads, maxSector); // Create heads - for(int i = 0; i < totalCylinders; i++) + for(var i = 0; i < totalCylinders; i++) { _sectorsData[i] = new byte[totalHeads][][]; spts[i] = new uint[totalHeads]; - for(int j = 0; j < totalHeads; j++) + for(var j = 0; j < totalHeads; j++) _sectorsData[i][j] = new byte[maxSector + 1][]; } @@ -369,8 +368,8 @@ public sealed partial class TeleDisk while(true) { - var teleDiskTrack = new TrackHeader(); - byte[] tdTrackForCrc = new byte[3]; + var teleDiskTrack = new TrackHeader(); + var tdTrackForCrc = new byte[3]; teleDiskTrack.Sectors = (byte)stream.ReadByte(); teleDiskTrack.Cylinder = (byte)stream.ReadByte(); @@ -381,7 +380,7 @@ public sealed partial class TeleDisk tdTrackForCrc[1] = teleDiskTrack.Cylinder; tdTrackForCrc[2] = teleDiskTrack.Head; - byte tdTrackCalculatedCrc = (byte)(TeleDiskCrc(0, tdTrackForCrc) & 0xFF); + var tdTrackCalculatedCrc = (byte)(TeleDiskCrc(0, tdTrackForCrc) & 0xFF); AaruConsole.DebugWriteLine("TeleDisk plugin", "Track follows"); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tTrack cylinder: {0}\t", teleDiskTrack.Cylinder); @@ -397,8 +396,8 @@ public sealed partial class TeleDisk { AaruConsole.DebugWriteLine("TeleDisk plugin", "End of disk image arrived"); - AaruConsole.DebugWriteLine("TeleDisk plugin", "Total of {0} data sectors, for {1} bytes", - totalSectors, _totalDiskSize); + AaruConsole.DebugWriteLine("TeleDisk plugin", "Total of {0} data sectors, for {1} bytes", totalSectors, + _totalDiskSize); break; } @@ -407,7 +406,7 @@ public sealed partial class TeleDisk { var teleDiskSector = new SectorHeader(); var teleDiskData = new DataHeader(); - byte[] dataSizeBytes = new byte[2]; + var dataSizeBytes = new byte[2]; byte[] decodedData; teleDiskSector.Cylinder = (byte)stream.ReadByte(); @@ -419,8 +418,7 @@ public sealed partial class TeleDisk AaruConsole.DebugWriteLine("TeleDisk plugin", "\tSector follows"); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tAddressMark cylinder: {0}", - teleDiskSector.Cylinder); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tAddressMark cylinder: {0}", teleDiskSector.Cylinder); AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tAddressMark head: {0}", teleDiskSector.Head); @@ -433,9 +431,8 @@ public sealed partial class TeleDisk AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector CRC (plus headers): 0x{0:X2}", teleDiskSector.Crc); - uint lba = (uint)((teleDiskSector.Cylinder * _header.Sides * _imageInfo.SectorsPerTrack) + - (teleDiskSector.Head * _imageInfo.SectorsPerTrack) + - (teleDiskSector.SectorNumber - 1)); + var lba = (uint)(teleDiskSector.Cylinder * _header.Sides * _imageInfo.SectorsPerTrack + + teleDiskSector.Head * _imageInfo.SectorsPerTrack + (teleDiskSector.SectorNumber - 1)); if((teleDiskSector.Flags & FLAGS_SECTOR_DATALESS) != FLAGS_SECTOR_DATALESS && (teleDiskSector.Flags & FLAGS_SECTOR_SKIPPED) != FLAGS_SECTOR_SKIPPED) @@ -445,7 +442,7 @@ public sealed partial class TeleDisk teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it _imageInfo.ImageSize += teleDiskData.DataSize; teleDiskData.DataEncoding = (byte)stream.ReadByte(); - byte[] data = new byte[teleDiskData.DataSize]; + var data = new byte[teleDiskData.DataSize]; stream.Read(data, 0, teleDiskData.DataSize); AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tData size (in-image): {0}", @@ -454,21 +451,20 @@ public sealed partial class TeleDisk AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tData encoding: 0x{0:X2}", teleDiskData.DataEncoding); - ErrorNumber errno = DecodeTeleDiskData(teleDiskSector.SectorSize, teleDiskData.DataEncoding, - data, out decodedData); + ErrorNumber errno = DecodeTeleDiskData(teleDiskSector.SectorSize, teleDiskData.DataEncoding, data, + out decodedData); if(errno != ErrorNumber.NoError) return errno; - byte tdSectorCalculatedCrc = (byte)(TeleDiskCrc(0, decodedData) & 0xFF); + var tdSectorCalculatedCrc = (byte)(TeleDiskCrc(0, decodedData) & 0xFF); if(tdSectorCalculatedCrc != teleDiskSector.Crc) { AaruConsole.DebugWriteLine("TeleDisk plugin", "Sector {0}:{3}:{4} calculated CRC 0x{1:X2} differs from stored CRC 0x{2:X2}", - teleDiskTrack.Cylinder, tdSectorCalculatedCrc, - teleDiskSector.Crc, teleDiskTrack.Cylinder, - teleDiskSector.SectorNumber); + teleDiskTrack.Cylinder, tdSectorCalculatedCrc, teleDiskSector.Crc, + teleDiskTrack.Cylinder, teleDiskSector.SectorNumber); if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) != FLAGS_SECTOR_NO_ID) _sectorsWhereCrcHasFailed.Add(lba); @@ -484,16 +480,14 @@ public sealed partial class TeleDisk if(_sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null) AaruConsole.DebugWriteLine("TeleDisk plugin", - (teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == - FLAGS_SECTOR_DUPLICATE + (teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == FLAGS_SECTOR_DUPLICATE ? "\t\tSector {0} on cylinder {1} head {2} is duplicate, and marked so" : "\t\tSector {0} on cylinder {1} head {2} is duplicate, but is not marked so", teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head); else { - _sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = - decodedData; + _sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = decodedData; _totalDiskSize += (uint)decodedData.Length; } @@ -503,13 +497,13 @@ public sealed partial class TeleDisk var leadOutMs = new MemoryStream(); if(hasLeadOutOnHead0) - for(int i = 0; i < _sectorsData[totalCylinders - 1][0].Length; i++) + for(var i = 0; i < _sectorsData[totalCylinders - 1][0].Length; i++) if(_sectorsData[totalCylinders - 1][0][i] != null) leadOutMs.Write(_sectorsData[totalCylinders - 1][0][i], 0, _sectorsData[totalCylinders - 1][0][i].Length); if(hasLeadOutOnHead1) - for(int i = 0; i < _sectorsData[totalCylinders - 1][1].Length; i++) + for(var i = 0; i < _sectorsData[totalCylinders - 1][1].Length; i++) if(_sectorsData[totalCylinders - 1][1][i] != null) leadOutMs.Write(_sectorsData[totalCylinders - 1][1][i], 0, _sectorsData[totalCylinders - 1][1][i].Length); diff --git a/Aaru.Images/TeleDisk/TeleDisk.cs b/Aaru.Images/TeleDisk/TeleDisk.cs index 1a77a873d..8977cb152 100644 --- a/Aaru.Images/TeleDisk/TeleDisk.cs +++ b/Aaru.Images/TeleDisk/TeleDisk.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // Created following notes from Dave Dunfield // http://www.classiccmp.org/dunfield/img54306/td0notes.txt /// Implements reading of Sydex TeleDisk disk images diff --git a/Aaru.Images/TeleDisk/Unsupported.cs b/Aaru.Images/TeleDisk/Unsupported.cs index 2745c8ef1..835da6937 100644 --- a/Aaru.Images/TeleDisk/Unsupported.cs +++ b/Aaru.Images/TeleDisk/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class TeleDisk { /// diff --git a/Aaru.Images/TeleDisk/Verify.cs b/Aaru.Images/TeleDisk/Verify.cs index f7a3a051f..59f0e322c 100644 --- a/Aaru.Images/TeleDisk/Verify.cs +++ b/Aaru.Images/TeleDisk/Verify.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Collections.Generic; - namespace Aaru.DiscImages; +using System.Collections.Generic; + public sealed partial class TeleDisk { /// diff --git a/Aaru.Images/UDIF/Constants.cs b/Aaru.Images/UDIF/Constants.cs index 2d03faa6a..301f799ac 100644 --- a/Aaru.Images/UDIF/Constants.cs +++ b/Aaru.Images/UDIF/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Udif { diff --git a/Aaru.Images/UDIF/Identify.cs b/Aaru.Images/UDIF/Identify.cs index a5d262762..1a633dfe6 100644 --- a/Aaru.Images/UDIF/Identify.cs +++ b/Aaru.Images/UDIF/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Udif { /// @@ -47,7 +47,7 @@ public sealed partial class Udif return false; stream.Seek(-Marshal.SizeOf
(), SeekOrigin.End); - byte[] footerB = new byte[Marshal.SizeOf
()]; + var footerB = new byte[Marshal.SizeOf
()]; stream.Read(footerB, 0, Marshal.SizeOf
()); _footer = Marshal.ByteArrayToStructureBigEndian
(footerB); @@ -57,7 +57,7 @@ public sealed partial class Udif // Old UDIF as created by DiskCopy 6.5 using "OBSOLETE" format. (DiskCopy 5 rumored format?) stream.Seek(0, SeekOrigin.Begin); - byte[] headerB = new byte[Marshal.SizeOf
()]; + var headerB = new byte[Marshal.SizeOf
()]; stream.Read(headerB, 0, Marshal.SizeOf
()); _footer = Marshal.ByteArrayToStructureBigEndian
(headerB); diff --git a/Aaru.Images/UDIF/Properties.cs b/Aaru.Images/UDIF/Properties.cs index 72ccc6eb2..0a3be582b 100644 --- a/Aaru.Images/UDIF/Properties.cs +++ b/Aaru.Images/UDIF/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Udif { /// @@ -47,7 +47,7 @@ public sealed partial class Udif /// public string Name => "Apple Universal Disk Image Format"; /// - public Guid Id => new Guid("5BEB9002-CF3D-429C-8E06-9A96F49203FF"); + public Guid Id => new("5BEB9002-CF3D-429C-8E06-9A96F49203FF"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/UDIF/Read.cs b/Aaru.Images/UDIF/Read.cs index f45bc239a..e20af8d15 100644 --- a/Aaru.Images/UDIF/Read.cs +++ b/Aaru.Images/UDIF/Read.cs @@ -30,6 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +#pragma warning disable 612 + +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -46,10 +50,6 @@ using Ionic.Zlib; using SharpCompress.Compressors.Xz; using Version = Resources.Version; -#pragma warning disable 612 - -namespace Aaru.DiscImages; - public sealed partial class Udif { /// @@ -61,7 +61,7 @@ public sealed partial class Udif return ErrorNumber.InvalidArgument; stream.Seek(-Marshal.SizeOf
(), SeekOrigin.End); - byte[] footerB = new byte[Marshal.SizeOf
()]; + var footerB = new byte[Marshal.SizeOf
()]; stream.Read(footerB, 0, Marshal.SizeOf
()); _footer = Marshal.ByteArrayToStructureBigEndian
(footerB); @@ -129,7 +129,7 @@ public sealed partial class Udif _footer.rsrcForkLen != 0) { AaruConsole.DebugWriteLine("UDIF plugin", "Reading resource fork."); - byte[] rsrcB = new byte[_footer.rsrcForkLen]; + var rsrcB = new byte[_footer.rsrcForkLen]; stream.Seek((long)_footer.rsrcForkOff, SeekOrigin.Begin); stream.Read(rsrcB, 0, rsrcB.Length); @@ -171,7 +171,7 @@ public sealed partial class Udif else if(_footer.plistLen != 0) { AaruConsole.DebugWriteLine("UDIF plugin", "Reading property list."); - byte[] plistB = new byte[_footer.plistLen]; + var plistB = new byte[_footer.plistLen]; stream.Seek((long)_footer.plistOff, SeekOrigin.Begin); stream.Read(plistB, 0, plistB.Length); @@ -242,7 +242,7 @@ public sealed partial class Udif AaruConsole.DebugWriteLine("UDIF plugin", "Reading resource fork."); Stream rsrcStream = imageFilter.GetResourceForkStream(); - byte[] rsrcB = new byte[rsrcStream.Length]; + var rsrcB = new byte[rsrcStream.Length]; rsrcStream.Position = 0; rsrcStream.Read(rsrcB, 0, rsrcB.Length); @@ -347,7 +347,7 @@ public sealed partial class Udif foreach(byte[] blkxBytes in blkxList) { - byte[] bHdrB = new byte[Marshal.SizeOf()]; + var bHdrB = new byte[Marshal.SizeOf()]; Array.Copy(blkxBytes, 0, bHdrB, 0, Marshal.SizeOf()); BlockHeader bHdr = Marshal.ByteArrayToStructureBigEndian(bHdrB); @@ -375,11 +375,11 @@ public sealed partial class Udif if(bHdr.buffers > _buffersize) _buffersize = bHdr.buffers * SECTOR_SIZE; - for(int i = 0; i < bHdr.chunks; i++) + for(var i = 0; i < bHdr.chunks; i++) { - byte[] bChnkB = new byte[Marshal.SizeOf()]; + var bChnkB = new byte[Marshal.SizeOf()]; - Array.Copy(blkxBytes, Marshal.SizeOf() + (Marshal.SizeOf() * i), bChnkB, 0, + Array.Copy(blkxBytes, Marshal.SizeOf() + Marshal.SizeOf() * i, bChnkB, 0, Marshal.SizeOf()); BlockChunk bChnk = Marshal.ByteArrayToStructureBigEndian(bChnkB); @@ -420,8 +420,8 @@ public sealed partial class Udif return ErrorNumber.NotImplemented; } - if((bChnk.type > CHUNK_TYPE_NOCOPY && bChnk.type < CHUNK_TYPE_COMMNT) || - (bChnk.type > CHUNK_TYPE_LZMA && bChnk.type < CHUNK_TYPE_END)) + if(bChnk.type > CHUNK_TYPE_NOCOPY && bChnk.type < CHUNK_TYPE_COMMNT || + bChnk.type > CHUNK_TYPE_LZMA && bChnk.type < CHUNK_TYPE_END) { AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found"); @@ -466,7 +466,7 @@ public sealed partial class Udif return ErrorNumber.NoError; var readChunk = new BlockChunk(); - bool chunkFound = false; + var chunkFound = false; ulong chunkStartSector = 0; foreach(KeyValuePair kvp in _chunks.Where(kvp => sectorAddress >= kvp.Key)) @@ -488,7 +488,7 @@ public sealed partial class Udif { if(!_chunkCache.TryGetValue(chunkStartSector, out byte[] data)) { - byte[] cmpBuffer = new byte[readChunk.length]; + var cmpBuffer = new byte[readChunk.length]; _imageStream.Seek((long)(readChunk.offset + _footer.dataForkOff), SeekOrigin.Begin); _imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); var cmpMs = new MemoryStream(cmpBuffer); @@ -517,7 +517,7 @@ public sealed partial class Udif { #endif byte[] tmpBuffer; - int realSize = 0; + var realSize = 0; switch(readChunk.type) { diff --git a/Aaru.Images/UDIF/Structs.cs b/Aaru.Images/UDIF/Structs.cs index dec322e66..e5c27c385 100644 --- a/Aaru.Images/UDIF/Structs.cs +++ b/Aaru.Images/UDIF/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - public sealed partial class Udif { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/UDIF/UDIF.cs b/Aaru.Images/UDIF/UDIF.cs index 9954648e8..799b0a916 100644 --- a/Aaru.Images/UDIF/UDIF.cs +++ b/Aaru.Images/UDIF/UDIF.cs @@ -30,6 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +#pragma warning disable 612 + +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.Checksums; @@ -37,10 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -#pragma warning disable 612 - -namespace Aaru.DiscImages; - /// /// Implements reading and writing Apple's Universal Disk Image Format disk images public sealed partial class Udif : IWritableImage diff --git a/Aaru.Images/UDIF/Unsupported.cs b/Aaru.Images/UDIF/Unsupported.cs index e43aaaaa8..a09cbdcfa 100644 --- a/Aaru.Images/UDIF/Unsupported.cs +++ b/Aaru.Images/UDIF/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Udif { /// diff --git a/Aaru.Images/UDIF/Write.cs b/Aaru.Images/UDIF/Write.cs index b3e5c66be..324bd5b85 100644 --- a/Aaru.Images/UDIF/Write.cs +++ b/Aaru.Images/UDIF/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Helpers; using Claunia.PropertyList; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Udif { /// @@ -223,7 +223,7 @@ public sealed partial class Udif for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[_imageInfo.SectorSize]; + var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) diff --git a/Aaru.Images/UkvFdi/Enums.cs b/Aaru.Images/UkvFdi/Enums.cs index a021603b6..0bd9780d5 100644 --- a/Aaru.Images/UkvFdi/Enums.cs +++ b/Aaru.Images/UkvFdi/Enums.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Diagnostics.CodeAnalysis; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class UkvFdi { @@ -47,8 +47,12 @@ public sealed partial class UkvFdi [Flags] enum SectorFlags : byte { - CrcOk128 = 0x01, CrcOk256 = 0x02, CrcOk512 = 0x04, - CrcOk1024 = 0x08, CrcOk2048 = 0x10, CrcOk4096 = 0x20, + CrcOk128 = 0x01, + CrcOk256 = 0x02, + CrcOk512 = 0x04, + CrcOk1024 = 0x08, + CrcOk2048 = 0x10, + CrcOk4096 = 0x20, Deleted = 0x80 } } \ No newline at end of file diff --git a/Aaru.Images/UkvFdi/Helpers.cs b/Aaru.Images/UkvFdi/Helpers.cs index 0bbb84cf3..71e3fdbfb 100644 --- a/Aaru.Images/UkvFdi/Helpers.cs +++ b/Aaru.Images/UkvFdi/Helpers.cs @@ -36,9 +36,9 @@ public sealed partial class UkvFdi { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); - byte head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); - byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); + var cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + var head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); + var sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1); return (cylinder, head, sector); } diff --git a/Aaru.Images/UkvFdi/Identify.cs b/Aaru.Images/UkvFdi/Identify.cs index 17caf7d80..d0c081c65 100644 --- a/Aaru.Images/UkvFdi/Identify.cs +++ b/Aaru.Images/UkvFdi/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class UkvFdi { /// @@ -48,7 +48,7 @@ public sealed partial class UkvFdi if(stream.Length < Marshal.SizeOf
()) return false; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); Header hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); diff --git a/Aaru.Images/UkvFdi/Properties.cs b/Aaru.Images/UkvFdi/Properties.cs index 588b6cd27..95f810828 100644 --- a/Aaru.Images/UkvFdi/Properties.cs +++ b/Aaru.Images/UkvFdi/Properties.cs @@ -30,19 +30,19 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class UkvFdi { /// public string Name => "Spectrum Floppy Disk Image"; /// - public Guid Id => new Guid("DADFC9B2-67C1-42A3-B124-825528163FC0"); + public Guid Id => new("DADFC9B2-67C1-42A3-B124-825528163FC0"); /// public string Format => "Spectrum floppy disk image"; /// diff --git a/Aaru.Images/UkvFdi/Read.cs b/Aaru.Images/UkvFdi/Read.cs index 81c1e5620..685de806b 100644 --- a/Aaru.Images/UkvFdi/Read.cs +++ b/Aaru.Images/UkvFdi/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using Aaru.CommonTypes; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class UkvFdi { /// @@ -51,7 +51,7 @@ public sealed partial class UkvFdi if(stream.Length < Marshal.SizeOf
()) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf
()]; + var hdrB = new byte[Marshal.SizeOf
()]; stream.Read(hdrB, 0, hdrB.Length); Header hdr = Marshal.ByteArrayToStructureLittleEndian
(hdrB); @@ -64,7 +64,7 @@ public sealed partial class UkvFdi AaruConsole.DebugWriteLine("UkvFdi plugin", "hdr.heads = {0}", hdr.heads); stream.Seek(hdr.descOff, SeekOrigin.Begin); - byte[] description = new byte[hdr.dataOff - hdr.descOff]; + var description = new byte[hdr.dataOff - hdr.descOff]; stream.Read(description, 0, description.Length); _imageInfo.Comments = StringHandlers.CToString(description); @@ -72,8 +72,8 @@ public sealed partial class UkvFdi stream.Seek(0xE + hdr.addInfoLen, SeekOrigin.Begin); - long spt = long.MaxValue; - uint[][][] sectorsOff = new uint[hdr.cylinders][][]; + long spt = long.MaxValue; + var sectorsOff = new uint[hdr.cylinders][][]; _sectorsData = new byte[hdr.cylinders][][][]; _imageInfo.Cylinders = hdr.cylinders; @@ -87,11 +87,11 @@ public sealed partial class UkvFdi for(ushort head = 0; head < hdr.heads; head++) { - byte[] sctB = new byte[4]; + var sctB = new byte[4]; stream.Read(sctB, 0, 4); stream.Seek(2, SeekOrigin.Current); - byte sectors = (byte)stream.ReadByte(); - uint trkOff = BitConverter.ToUInt32(sctB, 0); + var sectors = (byte)stream.ReadByte(); + var trkOff = BitConverter.ToUInt32(sctB, 0); AaruConsole.DebugWriteLine("UkvFdi plugin", "trkhdr.c = {0}", cyl); AaruConsole.DebugWriteLine("UkvFdi plugin", "trkhdr.h = {0}", head); @@ -107,14 +107,14 @@ public sealed partial class UkvFdi for(ushort sec = 0; sec < sectors; sec++) { - byte c = (byte)stream.ReadByte(); - byte h = (byte)stream.ReadByte(); - byte r = (byte)stream.ReadByte(); - byte n = (byte)stream.ReadByte(); - var f = (SectorFlags)stream.ReadByte(); - byte[] offB = new byte[2]; + var c = (byte)stream.ReadByte(); + var h = (byte)stream.ReadByte(); + var r = (byte)stream.ReadByte(); + var n = (byte)stream.ReadByte(); + var f = (SectorFlags)stream.ReadByte(); + var offB = new byte[2]; stream.Read(offB, 0, 2); - ushort secOff = BitConverter.ToUInt16(offB, 0); + var secOff = BitConverter.ToUInt16(offB, 0); AaruConsole.DebugWriteLine("UkvFdi plugin", "sechdr.c = {0}", c); AaruConsole.DebugWriteLine("UkvFdi plugin", "sechdr.h = {0}", h); @@ -138,7 +138,7 @@ public sealed partial class UkvFdi // Read sectors for(ushort cyl = 0; cyl < hdr.cylinders; cyl++) { - bool emptyCyl = false; + var emptyCyl = false; for(ushort head = 0; head < hdr.heads; head++) { @@ -163,7 +163,7 @@ public sealed partial class UkvFdi { _sectorsData[cyl][head] = new byte[spt][]; - for(int i = 0; i < spt; i++) + for(var i = 0; i < spt; i++) _sectorsData[cyl][head][i] = new byte[_imageInfo.SectorSize]; } } diff --git a/Aaru.Images/UkvFdi/Structs.cs b/Aaru.Images/UkvFdi/Structs.cs index 8a8f836d0..0ca51c13c 100644 --- a/Aaru.Images/UkvFdi/Structs.cs +++ b/Aaru.Images/UkvFdi/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class UkvFdi { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/UkvFdi/UkvFdi.cs b/Aaru.Images/UkvFdi/UkvFdi.cs index 90471181e..a1a7f57e6 100644 --- a/Aaru.Images/UkvFdi/UkvFdi.cs +++ b/Aaru.Images/UkvFdi/UkvFdi.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading UKV FDI disk images public sealed partial class UkvFdi : IMediaImage diff --git a/Aaru.Images/UkvFdi/Unsupported.cs b/Aaru.Images/UkvFdi/Unsupported.cs index c546e9f12..90e149ef5 100644 --- a/Aaru.Images/UkvFdi/Unsupported.cs +++ b/Aaru.Images/UkvFdi/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class UkvFdi { /// diff --git a/Aaru.Images/VDI/Enums.cs b/Aaru.Images/VDI/Enums.cs index 559a3ca48..0c235d9f7 100644 --- a/Aaru.Images/VDI/Enums.cs +++ b/Aaru.Images/VDI/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Vdi { diff --git a/Aaru.Images/VDI/Identify.cs b/Aaru.Images/VDI/Identify.cs index f274f7df1..73923a284 100644 --- a/Aaru.Images/VDI/Identify.cs +++ b/Aaru.Images/VDI/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Vdi { /// @@ -47,7 +47,7 @@ public sealed partial class Vdi if(stream.Length < 512) return false; - byte[] vHdrB = new byte[Marshal.SizeOf
()]; + var vHdrB = new byte[Marshal.SizeOf
()]; stream.Read(vHdrB, 0, Marshal.SizeOf
()); _vHdr = Marshal.ByteArrayToStructureLittleEndian
(vHdrB); diff --git a/Aaru.Images/VDI/Properties.cs b/Aaru.Images/VDI/Properties.cs index 69a4ac532..318322ecf 100644 --- a/Aaru.Images/VDI/Properties.cs +++ b/Aaru.Images/VDI/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Vdi { /// @@ -47,7 +47,7 @@ public sealed partial class Vdi /// public string Name => "VirtualBox Disk Image"; /// - public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); + public Guid Id => new("E314DE35-C103-48A3-AD36-990F68523C46"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/VDI/Read.cs b/Aaru.Images/VDI/Read.cs index 0e0bc9754..d23fac076 100644 --- a/Aaru.Images/VDI/Read.cs +++ b/Aaru.Images/VDI/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Vdi { /// @@ -53,7 +53,7 @@ public sealed partial class Vdi if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] vHdrB = new byte[Marshal.SizeOf
()]; + var vHdrB = new byte[Marshal.SizeOf
()]; stream.Read(vHdrB, 0, Marshal.SizeOf
()); _vHdr = Marshal.ByteArrayToStructureLittleEndian
(vHdrB); @@ -97,7 +97,7 @@ public sealed partial class Vdi DateTime start = DateTime.UtcNow; AaruConsole.DebugWriteLine("VirtualBox plugin", "Reading Image Block Map"); stream.Seek(_vHdr.offsetBlocks, SeekOrigin.Begin); - byte[] ibmB = new byte[_vHdr.blocks * 4]; + var ibmB = new byte[_vHdr.blocks * 4]; stream.Read(ibmB, 0, ibmB.Length); _ibm = MemoryMarshal.Cast(ibmB).ToArray(); DateTime end = DateTime.UtcNow; @@ -218,9 +218,9 @@ public sealed partial class Vdi return ErrorNumber.NoError; } - ulong imageOff = _vHdr.offsetData + ((ulong)ibmOff * _vHdr.blockSize); + ulong imageOff = _vHdr.offsetData + (ulong)ibmOff * _vHdr.blockSize; - byte[] cluster = new byte[_vHdr.blockSize]; + var cluster = new byte[_vHdr.blockSize]; _imageStream.Seek((long)imageOff, SeekOrigin.Begin); _imageStream.Read(cluster, 0, (int)_vHdr.blockSize); buffer = new byte[_vHdr.sectorSize]; diff --git a/Aaru.Images/VDI/Structs.cs b/Aaru.Images/VDI/Structs.cs index 2483ad73b..9d1db5e49 100644 --- a/Aaru.Images/VDI/Structs.cs +++ b/Aaru.Images/VDI/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - public sealed partial class Vdi { /// VDI disk image header, little-endian diff --git a/Aaru.Images/VDI/Unsupported.cs b/Aaru.Images/VDI/Unsupported.cs index cc2171416..e67435675 100644 --- a/Aaru.Images/VDI/Unsupported.cs +++ b/Aaru.Images/VDI/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Vdi { /// diff --git a/Aaru.Images/VDI/VDI.cs b/Aaru.Images/VDI/VDI.cs index 0cc4b4e9d..6e523a528 100644 --- a/Aaru.Images/VDI/VDI.cs +++ b/Aaru.Images/VDI/VDI.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // TODO: Support version 0 // TODO: Support fixed images /// diff --git a/Aaru.Images/VDI/Write.cs b/Aaru.Images/VDI/Write.cs index e83c7e223..be18eb459 100644 --- a/Aaru.Images/VDI/Write.cs +++ b/Aaru.Images/VDI/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -42,8 +44,6 @@ using Aaru.Helpers; using Schemas; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class Vdi { /// @@ -89,12 +89,12 @@ public sealed partial class Vdi return false; } - uint ibmEntries = (uint)(sectors * sectorSize / DEFAULT_BLOCK_SIZE); + var ibmEntries = (uint)(sectors * sectorSize / DEFAULT_BLOCK_SIZE); if(sectors * sectorSize % DEFAULT_BLOCK_SIZE > 0) ibmEntries++; - uint headerSectors = 1 + (ibmEntries * 4 / sectorSize); + uint headerSectors = 1 + ibmEntries * 4 / sectorSize; if(ibmEntries * 4 % sectorSize != 0) headerSectors++; @@ -178,7 +178,7 @@ public sealed partial class Vdi _vHdr.allocatedBlocks++; } - ulong imageOff = _vHdr.offsetData + ((ulong)ibmOff * _vHdr.blockSize); + ulong imageOff = _vHdr.offsetData + (ulong)ibmOff * _vHdr.blockSize; _writingStream.Seek((long)imageOff, SeekOrigin.Begin); _writingStream.Seek((long)secOff, SeekOrigin.Current); @@ -220,7 +220,7 @@ public sealed partial class Vdi for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[_imageInfo.SectorSize]; + var tmp = new byte[_imageInfo.SectorSize]; Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) @@ -287,7 +287,7 @@ public sealed partial class Vdi } } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_vHdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/VHD/Constants.cs b/Aaru.Images/VHD/Constants.cs index 1d4984ebf..c386fb88e 100644 --- a/Aaru.Images/VHD/Constants.cs +++ b/Aaru.Images/VHD/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Vhd { diff --git a/Aaru.Images/VHD/Helpers.cs b/Aaru.Images/VHD/Helpers.cs index 70a64a6e2..9e485d75b 100644 --- a/Aaru.Images/VHD/Helpers.cs +++ b/Aaru.Images/VHD/Helpers.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Linq; -namespace Aaru.DiscImages; - public sealed partial class Vhd { static uint VhdChecksum(IEnumerable data) diff --git a/Aaru.Images/VHD/Identify.cs b/Aaru.Images/VHD/Identify.cs index e2c16b0aa..aea839107 100644 --- a/Aaru.Images/VHD/Identify.cs +++ b/Aaru.Images/VHD/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Vhd { /// @@ -43,8 +43,8 @@ public sealed partial class Vhd { Stream imageStream = imageFilter.GetDataForkStream(); - byte[] headerCookieBytes = new byte[8]; - byte[] footerCookieBytes = new byte[8]; + var headerCookieBytes = new byte[8]; + var footerCookieBytes = new byte[8]; if(imageStream.Length % 2 == 0) imageStream.Seek(-512, SeekOrigin.End); @@ -55,8 +55,8 @@ public sealed partial class Vhd imageStream.Seek(0, SeekOrigin.Begin); imageStream.Read(headerCookieBytes, 0, 8); - ulong headerCookie = BigEndianBitConverter.ToUInt64(headerCookieBytes, 0); - ulong footerCookie = BigEndianBitConverter.ToUInt64(footerCookieBytes, 0); + var headerCookie = BigEndianBitConverter.ToUInt64(headerCookieBytes, 0); + var footerCookie = BigEndianBitConverter.ToUInt64(footerCookieBytes, 0); return headerCookie == IMAGE_COOKIE || footerCookie == IMAGE_COOKIE; } diff --git a/Aaru.Images/VHD/Properties.cs b/Aaru.Images/VHD/Properties.cs index abf0fa66d..8d606451f 100644 --- a/Aaru.Images/VHD/Properties.cs +++ b/Aaru.Images/VHD/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Vhd { /// @@ -47,7 +47,7 @@ public sealed partial class Vhd /// public string Name => "VirtualPC"; /// - public Guid Id => new Guid("8014d88f-64cd-4484-9441-7635c632958a"); + public Guid Id => new("8014d88f-64cd-4484-9441-7635c632958a"); /// public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/VHD/Read.cs b/Aaru.Images/VHD/Read.cs index 57ab5cd2f..db6388a7f 100644 --- a/Aaru.Images/VHD/Read.cs +++ b/Aaru.Images/VHD/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Runtime.InteropServices; @@ -41,15 +43,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Vhd { /// public ErrorNumber Open(IFilter imageFilter) { Stream imageStream = imageFilter.GetDataForkStream(); - byte[] header = new byte[512]; + var header = new byte[512]; byte[] footer; imageStream.Seek(0, SeekOrigin.Begin); @@ -68,10 +68,10 @@ public sealed partial class Vhd imageStream.Read(footer, 0, 511); } - uint headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40); - uint footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40); - ulong headerCookie = BigEndianBitConverter.ToUInt64(header, 0); - ulong footerCookie = BigEndianBitConverter.ToUInt64(footer, 0); + var headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40); + var footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40); + var headerCookie = BigEndianBitConverter.ToUInt64(header, 0); + var footerCookie = BigEndianBitConverter.ToUInt64(footer, 0); header[0x40] = 0; header[0x41] = 0; @@ -155,13 +155,11 @@ public sealed partial class Vhd Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter. CreatorApplication))); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorVersion = 0x{0:X8}", - _thisFooter.CreatorVersion); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorVersion = 0x{0:X8}", _thisFooter.CreatorVersion); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorHostOS = 0x{0:X8} (\"{1}\")", _thisFooter.CreatorHostOs, - Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(_thisFooter.CreatorHostOs))); + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter.CreatorHostOs))); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.originalSize = {0}", _thisFooter.OriginalSize); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.currentSize = {0}", _thisFooter.CurrentSize); @@ -258,8 +256,7 @@ public sealed partial class Vhd break; default: - _imageInfo.ApplicationVersion = - $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } @@ -284,8 +281,7 @@ public sealed partial class Vhd break; default: - _imageInfo.ApplicationVersion = - $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } @@ -350,10 +346,10 @@ public sealed partial class Vhd _thisFooter.DiskType == TYPE_DIFFERENCING) { imageStream.Seek((long)_thisFooter.Offset, SeekOrigin.Begin); - byte[] dynamicBytes = new byte[1024]; + var dynamicBytes = new byte[1024]; imageStream.Read(dynamicBytes, 0, 1024); - uint dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24); + var dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24); dynamicBytes[0x24] = 0; dynamicBytes[0x25] = 0; @@ -362,9 +358,8 @@ public sealed partial class Vhd uint dynamicChecksumCalculated = VhdChecksum(dynamicBytes); - AaruConsole.DebugWriteLine("VirtualPC plugin", - "Dynamic header checksum = 0x{0:X8}, calculated = 0x{1:X8}", dynamicChecksum, - dynamicChecksumCalculated); + AaruConsole.DebugWriteLine("VirtualPC plugin", "Dynamic header checksum = 0x{0:X8}, calculated = 0x{1:X8}", + dynamicChecksum, dynamicChecksumCalculated); if(dynamicChecksum != dynamicChecksumCalculated) { @@ -380,7 +375,7 @@ public sealed partial class Vhd Reserved2 = new byte[256] }; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) _thisDynamic.LocatorEntries[i] = new ParentLocatorEntry(); _thisDynamic.Cookie = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x00); @@ -395,22 +390,22 @@ public sealed partial class Vhd _thisDynamic.Reserved = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x3C); _thisDynamic.ParentName = Encoding.BigEndianUnicode.GetString(dynamicBytes, 0x40, 512); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { _thisDynamic.LocatorEntries[i].PlatformCode = - BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x00 + (24 * i)); + BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x00 + 24 * i); _thisDynamic.LocatorEntries[i].PlatformDataSpace = - BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x04 + (24 * i)); + BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x04 + 24 * i); _thisDynamic.LocatorEntries[i].PlatformDataLength = - BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x08 + (24 * i)); + BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x08 + 24 * i); _thisDynamic.LocatorEntries[i].Reserved = - BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x0C + (24 * i)); + BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x0C + 24 * i); _thisDynamic.LocatorEntries[i].PlatformDataOffset = - BigEndianBitConverter.ToUInt64(dynamicBytes, 0x240 + 0x10 + (24 * i)); + BigEndianBitConverter.ToUInt64(dynamicBytes, 0x240 + 0x10 + 24 * i); } Array.Copy(dynamicBytes, 0x300, _thisDynamic.Reserved2, 0, 256); @@ -440,7 +435,7 @@ public sealed partial class Vhd AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved = 0x{0:X8}", _thisDynamic.Reserved); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformCode = 0x{1:X8} (\"{2}\")", i, @@ -448,20 +443,17 @@ public sealed partial class Vhd Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisDynamic. LocatorEntries[i].PlatformCode))); - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}].platformDataSpace = {1}", i, + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataSpace = {1}", i, _thisDynamic.LocatorEntries[i].PlatformDataSpace); - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}].platformDataLength = {1}", i, - _thisDynamic.LocatorEntries[i].PlatformDataLength); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataLength = {1}", + i, _thisDynamic.LocatorEntries[i].PlatformDataLength); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].reserved = 0x{1:X8}", i, _thisDynamic.LocatorEntries[i].Reserved); - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}].platformDataOffset = {1}", i, - _thisDynamic.LocatorEntries[i].PlatformDataOffset); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataOffset = {1}", + i, _thisDynamic.LocatorEntries[i].PlatformDataOffset); } AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentName = \"{0}\"", _thisDynamic.ParentName); @@ -479,16 +471,16 @@ public sealed partial class Vhd _blockAllocationTable = new uint[_thisDynamic.MaxTableEntries]; - byte[] bat = new byte[_thisDynamic.MaxTableEntries * 4]; + var bat = new byte[_thisDynamic.MaxTableEntries * 4]; imageStream.Seek((long)_thisDynamic.TableOffset, SeekOrigin.Begin); imageStream.Read(bat, 0, bat.Length); ReadOnlySpan span = bat; - _blockAllocationTable = MemoryMarshal.Cast(span). - Slice(0, (int)_thisDynamic.MaxTableEntries).ToArray(); + _blockAllocationTable = MemoryMarshal.Cast(span).Slice(0, (int)_thisDynamic.MaxTableEntries). + ToArray(); - for(int i = 0; i < _blockAllocationTable.Length; i++) + for(var i = 0; i < _blockAllocationTable.Length; i++) _blockAllocationTable[i] = Swapping.Swap(_blockAllocationTable[i]); DateTime endTime = DateTime.UtcNow; @@ -522,7 +514,7 @@ public sealed partial class Vhd { _locatorEntriesData = new byte[8][]; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) if(_thisDynamic.LocatorEntries[i].PlatformCode != 0x00000000) { _locatorEntriesData[i] = new byte[_thisDynamic.LocatorEntries[i].PlatformDataLength]; @@ -535,23 +527,20 @@ public sealed partial class Vhd { case PLATFORM_CODE_WINDOWS_ABSOLUTE: case PLATFORM_CODE_WINDOWS_RELATIVE: - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}] = \"{1}\"", i, - Encoding.ASCII.GetString(_locatorEntriesData[i])); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", + i, Encoding.ASCII.GetString(_locatorEntriesData[i])); break; case PLATFORM_CODE_WINDOWS_ABSOLUTE_U: case PLATFORM_CODE_WINDOWS_RELATIVE_U: - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}] = \"{1}\"", i, - Encoding.BigEndianUnicode. - GetString(_locatorEntriesData[i])); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", + i, + Encoding.BigEndianUnicode.GetString(_locatorEntriesData[i])); break; case PLATFORM_CODE_MACINTOSH_URI: - AaruConsole.DebugWriteLine("VirtualPC plugin", - "dynamic.locatorEntries[{0}] = \"{1}\"", i, - Encoding.UTF8.GetString(_locatorEntriesData[i])); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", + i, Encoding.UTF8.GetString(_locatorEntriesData[i])); break; default: @@ -562,8 +551,8 @@ public sealed partial class Vhd } } - int currentLocator = 0; - bool locatorFound = false; + var currentLocator = 0; + var locatorFound = false; string parentPath = null; while(!locatorFound && @@ -583,8 +572,7 @@ public sealed partial class Vhd break; case PLATFORM_CODE_MACINTOSH_URI: parentPath = - Uri.UnescapeDataString(Encoding.UTF8. - GetString(_locatorEntriesData[currentLocator])); + Uri.UnescapeDataString(Encoding.UTF8.GetString(_locatorEntriesData[currentLocator])); if(parentPath.StartsWith("file://localhost", StringComparison.InvariantCulture)) parentPath = parentPath.Remove(0, 16); @@ -647,8 +635,7 @@ public sealed partial class Vhd if(!_parentImage.Identify(parentFilter)) { - AaruConsole. - ErrorWriteLine("(VirtualPC plugin): Parent image is not a Virtual PC disk image"); + AaruConsole.ErrorWriteLine("(VirtualPC plugin): Parent image is not a Virtual PC disk image"); return ErrorNumber.InvalidArgument; } @@ -703,10 +690,10 @@ public sealed partial class Vhd case TYPE_DIFFERENCING: { // Block number for BAT searching - uint blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); + var blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); // Sector number inside of block - uint sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); + var sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); if(_blockAllocationTable[blockNumber] == 0xFFFFFFFF) { @@ -715,20 +702,20 @@ public sealed partial class Vhd return ErrorNumber.NoError; } - byte[] bitmap = new byte[_bitmapSize * 512]; + var bitmap = new byte[_bitmapSize * 512]; // Offset of block in file long blockOffset = _blockAllocationTable[blockNumber] * 512L; - int bitmapByte = (int)Math.Floor((double)sectorInBlock / 8); - int bitmapBit = (int)(sectorInBlock % 8); + var bitmapByte = (int)Math.Floor((double)sectorInBlock / 8); + var bitmapBit = (int)(sectorInBlock % 8); Stream thisStream = _thisFilter.GetDataForkStream(); thisStream.Seek(blockOffset, SeekOrigin.Begin); thisStream.Read(bitmap, 0, (int)_bitmapSize * 512); - byte mask = (byte)(1 << (7 - bitmapBit)); + var mask = (byte)(1 << (7 - bitmapBit)); bool dirty = (bitmap[bitmapByte] & mask) == mask; /* @@ -796,13 +783,13 @@ public sealed partial class Vhd case TYPE_DYNAMIC: { // Block number for BAT searching - uint blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); + var blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); // Sector number inside of block - uint sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); + var sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); // How many sectors before reaching end of block - uint remainingInBlock = (_thisDynamic.BlockSize / 512) - sectorInBlock; + uint remainingInBlock = _thisDynamic.BlockSize / 512 - sectorInBlock; // Data that needs to be read from another block byte[] suffix = null; @@ -828,7 +815,7 @@ public sealed partial class Vhd uint sectorOffset = _blockAllocationTable[blockNumber] + _bitmapSize + sectorInBlock; // Data that can be read in this block - byte[] prefix = new byte[sectorsToReadHere * 512]; + var prefix = new byte[sectorsToReadHere * 512]; // 0xFFFFFFFF means unallocated if(_blockAllocationTable[blockNumber] != 0xFFFFFFFF) diff --git a/Aaru.Images/VHD/Structs.cs b/Aaru.Images/VHD/Structs.cs index 7c004a863..38e0addf2 100644 --- a/Aaru.Images/VHD/Structs.cs +++ b/Aaru.Images/VHD/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; - namespace Aaru.DiscImages; +using System; + public sealed partial class Vhd { struct HardDiskFooter diff --git a/Aaru.Images/VHD/Unsupported.cs b/Aaru.Images/VHD/Unsupported.cs index 5f8ebc477..3148dd076 100644 --- a/Aaru.Images/VHD/Unsupported.cs +++ b/Aaru.Images/VHD/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Vhd { /// diff --git a/Aaru.Images/VHD/VHD.cs b/Aaru.Images/VHD/VHD.cs index c27d33b2b..cc6cb2d80 100644 --- a/Aaru.Images/VHD/VHD.cs +++ b/Aaru.Images/VHD/VHD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// /// Supports Connectix/Microsoft Virtual PC hard disk image format. Until Virtual PC 5 there existed no format, diff --git a/Aaru.Images/VHD/Write.cs b/Aaru.Images/VHD/Write.cs index af5004a15..a94f16afa 100644 --- a/Aaru.Images/VHD/Write.cs +++ b/Aaru.Images/VHD/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Schemas; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using Version = System.Version; -namespace Aaru.DiscImages; - public sealed partial class Vhd { /// @@ -121,7 +121,7 @@ public sealed partial class Vhd return false; } - _writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Seek((long)(0 + sectorAddress * 512), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -154,7 +154,7 @@ public sealed partial class Vhd return false; } - _writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Seek((long)(0 + sectorAddress * 512), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -235,7 +235,7 @@ public sealed partial class Vhd footer.Offset = footer.DiskType == TYPE_FIXED ? ulong.MaxValue : 512; - byte[] footerBytes = new byte[512]; + var footerBytes = new byte[512]; Array.Copy(BigEndianBitConverter.GetBytes(footer.Cookie), 0, footerBytes, 0x00, 8); Array.Copy(BigEndianBitConverter.GetBytes(footer.Features), 0, footerBytes, 0x08, 4); Array.Copy(BigEndianBitConverter.GetBytes(footer.Version), 0, footerBytes, 0x0C, 4); diff --git a/Aaru.Images/VHDX/Constants.cs b/Aaru.Images/VHDX/Constants.cs index b7b0afb68..6dfa0ecc4 100644 --- a/Aaru.Images/VHDX/Constants.cs +++ b/Aaru.Images/VHDX/Constants.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Diagnostics.CodeAnalysis; -namespace Aaru.DiscImages; - [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class Vhdx { @@ -79,13 +79,13 @@ public sealed partial class Vhdx const ulong BAT_RESERVED_MASK = 0x3FFF8; const int MAX_CACHE_SIZE = 16777216; - readonly Guid _batGuid = new Guid("2DC27766-F623-4200-9D64-115E9BFD4A08"); - readonly Guid _fileParametersGuid = new Guid("CAA16737-FA36-4D43-B3B6-33F0AA44E76B"); - readonly Guid _logicalSectorSizeGuid = new Guid("8141BF1D-A96F-4709-BA47-F233A8FAAB5F"); - readonly Guid _metadataGuid = new Guid("8B7CA206-4790-4B9A-B8FE-575F050F886E"); - readonly Guid _page83DataGuid = new Guid("BECA12AB-B2E6-4523-93EF-C309E000C746"); - readonly Guid _parentLocatorGuid = new Guid("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C"); - readonly Guid _parentTypeVhdxGuid = new Guid("B04AEFB7-D19E-4A81-B789-25B8E9445913"); - readonly Guid _physicalSectorSizeGuid = new Guid("CDA348C7-445D-4471-9CC9-E9885251C556"); - readonly Guid _virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8"); + readonly Guid _batGuid = new("2DC27766-F623-4200-9D64-115E9BFD4A08"); + readonly Guid _fileParametersGuid = new("CAA16737-FA36-4D43-B3B6-33F0AA44E76B"); + readonly Guid _logicalSectorSizeGuid = new("8141BF1D-A96F-4709-BA47-F233A8FAAB5F"); + readonly Guid _metadataGuid = new("8B7CA206-4790-4B9A-B8FE-575F050F886E"); + readonly Guid _page83DataGuid = new("BECA12AB-B2E6-4523-93EF-C309E000C746"); + readonly Guid _parentLocatorGuid = new("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C"); + readonly Guid _parentTypeVhdxGuid = new("B04AEFB7-D19E-4A81-B789-25B8E9445913"); + readonly Guid _physicalSectorSizeGuid = new("CDA348C7-445D-4471-9CC9-E9885251C556"); + readonly Guid _virtualDiskSizeGuid = new("2FA54224-CD1B-4876-B211-5DBED83BF4B8"); } \ No newline at end of file diff --git a/Aaru.Images/VHDX/Helpers.cs b/Aaru.Images/VHDX/Helpers.cs index 14aa276e6..9b6c353af 100644 --- a/Aaru.Images/VHDX/Helpers.cs +++ b/Aaru.Images/VHDX/Helpers.cs @@ -36,9 +36,9 @@ public sealed partial class Vhdx { bool CheckBitmap(ulong sectorAddress) { - long index = (long)(sectorAddress / 8); - int shift = (int)(sectorAddress % 8); - byte val = (byte)(1 << shift); + var index = (long)(sectorAddress / 8); + var shift = (int)(sectorAddress % 8); + var val = (byte)(1 << shift); if(index > _sectorBitmap.LongLength) return false; diff --git a/Aaru.Images/VHDX/Identify.cs b/Aaru.Images/VHDX/Identify.cs index e4ab70c01..9f4300486 100644 --- a/Aaru.Images/VHDX/Identify.cs +++ b/Aaru.Images/VHDX/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Vhdx { /// @@ -47,7 +47,7 @@ public sealed partial class Vhdx if(stream.Length < 512) return false; - byte[] vhdxIdB = new byte[Marshal.SizeOf()]; + var vhdxIdB = new byte[Marshal.SizeOf()]; stream.Read(vhdxIdB, 0, Marshal.SizeOf()); _id = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); diff --git a/Aaru.Images/VHDX/Properties.cs b/Aaru.Images/VHDX/Properties.cs index b87886b2c..cbd872ea7 100644 --- a/Aaru.Images/VHDX/Properties.cs +++ b/Aaru.Images/VHDX/Properties.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Vhdx { /// @@ -45,7 +45,7 @@ public sealed partial class Vhdx /// public string Name => "Microsoft VHDX"; /// - public Guid Id => new Guid("536B141B-D09C-4799-AB70-34631286EB9D"); + public Guid Id => new("536B141B-D09C-4799-AB70-34631286EB9D"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/VHDX/Read.cs b/Aaru.Images/VHDX/Read.cs index 3f12101fd..f4fd5ba4d 100644 --- a/Aaru.Images/VHDX/Read.cs +++ b/Aaru.Images/VHDX/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Vhdx { /// @@ -53,7 +53,7 @@ public sealed partial class Vhdx if(stream.Length < 512) return ErrorNumber.InvalidArgument; - byte[] vhdxIdB = new byte[Marshal.SizeOf()]; + var vhdxIdB = new byte[Marshal.SizeOf()]; stream.Read(vhdxIdB, 0, Marshal.SizeOf()); _id = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); @@ -63,7 +63,7 @@ public sealed partial class Vhdx _imageInfo.Application = Encoding.Unicode.GetString(_id.creator); stream.Seek(64 * 1024, SeekOrigin.Begin); - byte[] vHdrB = new byte[Marshal.SizeOf
()]; + var vHdrB = new byte[Marshal.SizeOf
()]; stream.Read(vHdrB, 0, Marshal.SizeOf
()); _vHdr = Marshal.ByteArrayToStructureLittleEndian
(vHdrB); @@ -83,7 +83,7 @@ public sealed partial class Vhdx } stream.Seek(192 * 1024, SeekOrigin.Begin); - byte[] vRegTableB = new byte[Marshal.SizeOf()]; + var vRegTableB = new byte[Marshal.SizeOf()]; stream.Read(vRegTableB, 0, Marshal.SizeOf()); _vRegHdr = Marshal.ByteArrayToStructureLittleEndian(vRegTableB); @@ -104,9 +104,9 @@ public sealed partial class Vhdx _vRegs = new RegionTableEntry[_vRegHdr.entries]; - for(int i = 0; i < _vRegs.Length; i++) + for(var i = 0; i < _vRegs.Length; i++) { - byte[] vRegB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vRegs[i])]; + var vRegB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vRegs[i])]; stream.Read(vRegB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vRegs[i])); _vRegs[i] = Marshal.ByteArrayToStructureLittleEndian(vRegB); @@ -140,15 +140,15 @@ public sealed partial class Vhdx uint fileParamsOff = 0, vdSizeOff = 0, p83Off = 0, logOff = 0, physOff = 0, parentOff = 0; stream.Seek(_metadataOffset, SeekOrigin.Begin); - byte[] metTableB = new byte[Marshal.SizeOf()]; + var metTableB = new byte[Marshal.SizeOf()]; stream.Read(metTableB, 0, Marshal.SizeOf()); _vMetHdr = Marshal.ByteArrayToStructureLittleEndian(metTableB); _vMets = new MetadataTableEntry[_vMetHdr.entries]; - for(int i = 0; i < _vMets.Length; i++) + for(var i = 0; i < _vMets.Length; i++) { - byte[] vMetB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vMets[i])]; + var vMetB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vMets[i])]; stream.Read(vMetB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vMets[i])); _vMets[i] = Marshal.ByteArrayToStructureLittleEndian(vMetB); @@ -248,7 +248,7 @@ public sealed partial class Vhdx (_vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT) { stream.Seek(parentOff + _metadataOffset, SeekOrigin.Begin); - byte[] vParHdrB = new byte[Marshal.SizeOf()]; + var vParHdrB = new byte[Marshal.SizeOf()]; stream.Read(vParHdrB, 0, Marshal.SizeOf()); _vParHdr = Marshal.ByteArrayToStructureLittleEndian(vParHdrB); @@ -262,9 +262,9 @@ public sealed partial class Vhdx _vPars = new ParentLocatorEntry[_vParHdr.keyValueCount]; - for(int i = 0; i < _vPars.Length; i++) + for(var i = 0; i < _vPars.Length; i++) { - byte[] vParB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vPars[i])]; + var vParB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vPars[i])]; stream.Read(vParB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vPars[i])); _vPars[i] = Marshal.ByteArrayToStructureLittleEndian(vParB); } @@ -280,12 +280,12 @@ public sealed partial class Vhdx _vParHdr.locatorType == _parentTypeVhdxGuid) { _parentImage = new Vhdx(); - bool parentWorks = false; + var parentWorks = false; foreach(ParentLocatorEntry parentEntry in _vPars) { stream.Seek(parentEntry.keyOffset + _metadataOffset, SeekOrigin.Begin); - byte[] tmpKey = new byte[parentEntry.keyLength]; + var tmpKey = new byte[parentEntry.keyLength]; stream.Read(tmpKey, 0, tmpKey.Length); string entryType = Encoding.Unicode.GetString(tmpKey); @@ -294,14 +294,13 @@ public sealed partial class Vhdx if(string.Compare(entryType, RELATIVE_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0) { stream.Seek(parentEntry.valueOffset + _metadataOffset, SeekOrigin.Begin); - byte[] tmpVal = new byte[parentEntry.valueLength]; + var tmpVal = new byte[parentEntry.valueLength]; stream.Read(tmpVal, 0, tmpVal.Length); string entryValue = Encoding.Unicode.GetString(tmpVal); try { - parentFilter = - new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, entryValue)); + parentFilter = new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, entryValue)); if(parentFilter != null && _parentImage.Open(parentFilter) == ErrorNumber.NoError) @@ -320,8 +319,7 @@ public sealed partial class Vhdx try { - parentFilter = - new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, relEntry)); + parentFilter = new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, relEntry)); if(parentFilter == null || _parentImage.Open(parentFilter) != ErrorNumber.NoError) @@ -340,14 +338,13 @@ public sealed partial class Vhdx string.Compare(entryType, ABSOLUTE_WIN32_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0) { stream.Seek(parentEntry.valueOffset + _metadataOffset, SeekOrigin.Begin); - byte[] tmpVal = new byte[parentEntry.valueLength]; + var tmpVal = new byte[parentEntry.valueLength]; stream.Read(tmpVal, 0, tmpVal.Length); string entryValue = Encoding.Unicode.GetString(tmpVal); try { - parentFilter = - new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, entryValue)); + parentFilter = new FiltersList().GetFilter(Path.Combine(imageFilter.ParentFolder, entryValue)); if(parentFilter == null || _parentImage.Open(parentFilter) != ErrorNumber.NoError) @@ -394,13 +391,13 @@ public sealed partial class Vhdx batEntries = sectorBitmapBlocks * (_chunkRatio - 1); } else - batEntries = (long)(_dataBlocks + ((_dataBlocks - 1) / (ulong)_chunkRatio)); + batEntries = (long)(_dataBlocks + (_dataBlocks - 1) / (ulong)_chunkRatio); AaruConsole.DebugWriteLine("VHDX plugin", "Reading BAT"); long readChunks = 0; _blockAllocationTable = new ulong[_dataBlocks]; - byte[] batB = new byte[batEntries * 8]; + var batB = new byte[batEntries * 8]; stream.Seek(_batOffset, SeekOrigin.Begin); stream.Read(batB, 0, batB.Length); @@ -410,14 +407,14 @@ public sealed partial class Vhdx if(readChunks == _chunkRatio) { if(_hasParent) - _sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); + _sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize)); readChunks = 0; skipSize += 8; } else { - _blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); + _blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize)); readChunks++; } @@ -436,7 +433,7 @@ public sealed partial class Vhdx break; case SECTOR_BITMAP_PRESENT: stream.Seek((long)((pt & BAT_FILE_OFFSET_MASK) * 1048576), SeekOrigin.Begin); - byte[] bmp = new byte[1048576]; + var bmp = new byte[1048576]; stream.Read(bmp, 0, bmp.Length); sectorBmpMs.Write(bmp, 0, bmp.Length); diff --git a/Aaru.Images/VHDX/Structs.cs b/Aaru.Images/VHDX/Structs.cs index 9abc16d1e..5cae93cde 100644 --- a/Aaru.Images/VHDX/Structs.cs +++ b/Aaru.Images/VHDX/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Runtime.InteropServices; -namespace Aaru.DiscImages; - public sealed partial class Vhdx { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/VHDX/Unsupported.cs b/Aaru.Images/VHDX/Unsupported.cs index 3b6dcf86a..43053c7a2 100644 --- a/Aaru.Images/VHDX/Unsupported.cs +++ b/Aaru.Images/VHDX/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Vhdx { /// diff --git a/Aaru.Images/VHDX/VHDX.cs b/Aaru.Images/VHDX/VHDX.cs index 17cdea8dc..4c23e896c 100644 --- a/Aaru.Images/VHDX/VHDX.cs +++ b/Aaru.Images/VHDX/VHDX.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable NotAccessedField.Local + +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -37,10 +43,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -// ReSharper disable NotAccessedField.Local - -namespace Aaru.DiscImages; - /// /// Implements reading Hyper-V disk images public sealed partial class Vhdx : IMediaImage diff --git a/Aaru.Images/VMware/Constants.cs b/Aaru.Images/VMware/Constants.cs index 0418550d7..7071758f8 100644 --- a/Aaru.Images/VMware/Constants.cs +++ b/Aaru.Images/VMware/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.DiscImages; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "UnusedMember.Local")] public sealed partial class VMware { diff --git a/Aaru.Images/VMware/Identify.cs b/Aaru.Images/VMware/Identify.cs index e74be30cd..a64e43e3e 100644 --- a/Aaru.Images/VMware/Identify.cs +++ b/Aaru.Images/VMware/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class VMware { /// @@ -44,12 +44,12 @@ public sealed partial class VMware { Stream stream = imageFilter.GetDataForkStream(); - byte[] ddfMagic = new byte[0x15]; + var ddfMagic = new byte[0x15]; if(stream.Length > Marshal.SizeOf()) { stream.Seek(0, SeekOrigin.Begin); - byte[] vmEHdrB = new byte[Marshal.SizeOf()]; + var vmEHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmEHdrB, 0, Marshal.SizeOf()); _vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); @@ -63,7 +63,7 @@ public sealed partial class VMware _vmCHdr.magic == VMWARE_COW_MAGIC; stream.Seek(0, SeekOrigin.Begin); - byte[] vmCHdrB = new byte[Marshal.SizeOf()]; + var vmCHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmCHdrB, 0, Marshal.SizeOf()); _vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); diff --git a/Aaru.Images/VMware/Properties.cs b/Aaru.Images/VMware/Properties.cs index c910aa8d6..ccc70641f 100644 --- a/Aaru.Images/VMware/Properties.cs +++ b/Aaru.Images/VMware/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class VMware { /// @@ -47,7 +47,7 @@ public sealed partial class VMware /// public string Name => "VMware disk image"; /// - public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); + public Guid Id => new("E314DE35-C103-48A3-AD36-990F68523C46"); /// public string Author => "Natalia Portillo"; /// @@ -72,8 +72,8 @@ public sealed partial class VMware /// public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions => new[] { - ("adapter_type", typeof(string), - "Type of adapter type. Possible values: ide, lsilogic, buslogic, legacyESX.", "ide"), + ("adapter_type", typeof(string), "Type of adapter type. Possible values: ide, lsilogic, buslogic, legacyESX.", + "ide"), ("hwversion", typeof(uint), "VDMK hardware version.", 4), ("sparse", typeof(bool), "Use sparse extents.", false), ("split", typeof(bool), "Split data file at 2GiB.", (object)false) diff --git a/Aaru.Images/VMware/Read.cs b/Aaru.Images/VMware/Read.cs index f7a55dc31..778fc2042 100644 --- a/Aaru.Images/VMware/Read.cs +++ b/Aaru.Images/VMware/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -43,8 +45,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.DiscImages; - public sealed partial class VMware { /// @@ -54,12 +54,12 @@ public sealed partial class VMware _vmEHdr = new ExtentHeader(); _vmCHdr = new CowHeader(); - bool embedded = false; + var embedded = false; if(stream.Length > Marshal.SizeOf()) { stream.Seek(0, SeekOrigin.Begin); - byte[] vmEHdrB = new byte[Marshal.SizeOf()]; + var vmEHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmEHdrB, 0, Marshal.SizeOf()); _vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); } @@ -67,14 +67,14 @@ public sealed partial class VMware if(stream.Length > Marshal.SizeOf()) { stream.Seek(0, SeekOrigin.Begin); - byte[] vmCHdrB = new byte[Marshal.SizeOf()]; + var vmCHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmCHdrB, 0, Marshal.SizeOf()); _vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); } - var ddfStream = new MemoryStream(); - bool vmEHdrSet = false; - bool cowD = false; + var ddfStream = new MemoryStream(); + var vmEHdrSet = false; + var cowD = false; if(_vmEHdr.magic == VMWARE_EXTENT_MAGIC) { @@ -89,7 +89,7 @@ public sealed partial class VMware return ErrorNumber.InvalidArgument; } - byte[] ddfEmbed = new byte[_vmEHdr.descriptorSize * SECTOR_SIZE]; + var ddfEmbed = new byte[_vmEHdr.descriptorSize * SECTOR_SIZE]; stream.Seek((long)(_vmEHdr.descriptorOffset * SECTOR_SIZE), SeekOrigin.Begin); stream.Read(ddfEmbed, 0, ddfEmbed.Length); @@ -104,7 +104,7 @@ public sealed partial class VMware } else { - byte[] ddfMagic = new byte[0x15]; + var ddfMagic = new byte[0x15]; stream.Seek(0, SeekOrigin.Begin); stream.Read(ddfMagic, 0, 0x15); @@ -116,7 +116,7 @@ public sealed partial class VMware } stream.Seek(0, SeekOrigin.Begin); - byte[] ddfExternal = new byte[imageFilter.DataForkLength]; + var ddfExternal = new byte[imageFilter.DataForkLength]; stream.Read(ddfExternal, 0, ddfExternal.Length); ddfStream.Write(ddfExternal, 0, ddfExternal.Length); } @@ -128,7 +128,7 @@ public sealed partial class VMware if(cowD) { - int cowCount = 1; + var cowCount = 1; string basePath = Path.GetFileNameWithoutExtension(imageFilter.BasePath); while(true) @@ -149,7 +149,7 @@ public sealed partial class VMware if(stream.Length > Marshal.SizeOf()) { extentStream.Seek(0, SeekOrigin.Begin); - byte[] vmCHdrB = new byte[Marshal.SizeOf()]; + var vmCHdrB = new byte[Marshal.SizeOf()]; extentStream.Read(vmCHdrB, 0, Marshal.SizeOf()); CowHeader extHdrCow = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); @@ -167,8 +167,7 @@ public sealed partial class VMware }; AaruConsole.DebugWriteLine("VMware plugin", "{0} {1} {2} \"{3}\" {4}", newExtent.Access, - newExtent.Sectors, newExtent.Type, newExtent.Filename, - newExtent.Offset); + newExtent.Sectors, newExtent.Type, newExtent.Filename, newExtent.Offset); _extents.Add(currentSector, newExtent); currentSector += newExtent.Sectors; @@ -250,8 +249,7 @@ public sealed partial class VMware newExtent.Type = matchExtent.Groups["type"].Value; AaruConsole.DebugWriteLine("VMware plugin", "{0} {1} {2} \"{3}\" {4}", newExtent.Access, - newExtent.Sectors, newExtent.Type, newExtent.Filename, - newExtent.Offset); + newExtent.Sectors, newExtent.Type, newExtent.Filename, newExtent.Offset); _extents.Add(currentSector, newExtent); currentSector += newExtent.Sectors; @@ -351,7 +349,7 @@ public sealed partial class VMware return ErrorNumber.InvalidArgument; } - byte[] extentHdrB = new byte[Marshal.SizeOf()]; + var extentHdrB = new byte[Marshal.SizeOf()]; extentStream.Read(extentHdrB, 0, Marshal.SizeOf()); ExtentHeader extentHdr = Marshal.ByteArrayToStructureLittleEndian(extentHdrB); @@ -458,8 +456,7 @@ public sealed partial class VMware AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.spt = {0}", _vmCHdr.spt); AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.generation = {0}", _vmCHdr.generation); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.name = {0}", - StringHandlers.CToString(_vmCHdr.name)); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.name = {0}", StringHandlers.CToString(_vmCHdr.name)); AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.description = {0}", StringHandlers.CToString(_vmCHdr.description)); @@ -487,15 +484,15 @@ public sealed partial class VMware return ErrorNumber.InOutError; } - AaruConsole.DebugWriteLine("VMware plugin", "{0} sectors in {1} grains in {2} tables", - _imageInfo.Sectors, grains, gdEntries); + AaruConsole.DebugWriteLine("VMware plugin", "{0} sectors in {1} grains in {2} tables", _imageInfo.Sectors, + grains, gdEntries); Stream gdStream = _gdFilter.GetDataForkStream(); gdStream.Seek(gdOffset * SECTOR_SIZE, SeekOrigin.Begin); AaruConsole.DebugWriteLine("VMware plugin", "Reading grain directory"); - byte[] gdBytes = new byte[gdEntries * 4]; + var gdBytes = new byte[gdEntries * 4]; gdStream.Read(gdBytes, 0, gdBytes.Length); Span gd = MemoryMarshal.Cast(gdBytes); @@ -505,7 +502,7 @@ public sealed partial class VMware foreach(uint gtOff in gd) { - byte[] gtBytes = new byte[gtEsPerGt * 4]; + var gtBytes = new byte[gtEsPerGt * 4]; gdStream.Seek(gtOff * SECTOR_SIZE, SeekOrigin.Begin); gdStream.Read(gtBytes, 0, gtBytes.Length); @@ -593,7 +590,7 @@ public sealed partial class VMware return ErrorNumber.NoError; var currentExtent = new Extent(); - bool extentFound = false; + var extentFound = false; ulong extentStartSector = 0; foreach(KeyValuePair kvp in _extents.Where(kvp => sectorAddress >= kvp.Key)) diff --git a/Aaru.Images/VMware/Structs.cs b/Aaru.Images/VMware/Structs.cs index c43149355..7b194fc8e 100644 --- a/Aaru.Images/VMware/Structs.cs +++ b/Aaru.Images/VMware/Structs.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Runtime.InteropServices; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class VMware { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/VMware/Unsupported.cs b/Aaru.Images/VMware/Unsupported.cs index 88159b0ba..db442c2ee 100644 --- a/Aaru.Images/VMware/Unsupported.cs +++ b/Aaru.Images/VMware/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class VMware { /// diff --git a/Aaru.Images/VMware/VMware.cs b/Aaru.Images/VMware/VMware.cs index 571801ab9..bb7157276 100644 --- a/Aaru.Images/VMware/VMware.cs +++ b/Aaru.Images/VMware/VMware.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading VMware disk images public sealed partial class VMware : IWritableImage diff --git a/Aaru.Images/VMware/Write.cs b/Aaru.Images/VMware/Write.cs index 1aa1de569..40b402ad4 100644 --- a/Aaru.Images/VMware/Write.cs +++ b/Aaru.Images/VMware/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class VMware { /// @@ -146,8 +146,7 @@ public sealed partial class VMware try { - _writingBaseName = - Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); diff --git a/Aaru.Images/Virtual98/Identify.cs b/Aaru.Images/Virtual98/Identify.cs index 692f5ca24..182ae3a6c 100644 --- a/Aaru.Images/Virtual98/Identify.cs +++ b/Aaru.Images/Virtual98/Identify.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using System.Text; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Virtual98 { /// @@ -53,7 +53,7 @@ public sealed partial class Virtual98 if(stream.Length < Marshal.SizeOf()) return false; - byte[] hdrB = new byte[Marshal.SizeOf()]; + var hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); _v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); diff --git a/Aaru.Images/Virtual98/Properties.cs b/Aaru.Images/Virtual98/Properties.cs index e13b98e68..79539982e 100644 --- a/Aaru.Images/Virtual98/Properties.cs +++ b/Aaru.Images/Virtual98/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Virtual98 { /// @@ -46,7 +46,7 @@ public sealed partial class Virtual98 /// public string Name => "Virtual98 Disk Image"; /// - public Guid Id => new Guid("C0CDE13D-04D0-4913-8740-AFAA44D0A107"); + public Guid Id => new("C0CDE13D-04D0-4913-8740-AFAA44D0A107"); /// public string Author => "Natalia Portillo"; /// diff --git a/Aaru.Images/Virtual98/Read.cs b/Aaru.Images/Virtual98/Read.cs index 9df57d836..9b7353333 100644 --- a/Aaru.Images/Virtual98/Read.cs +++ b/Aaru.Images/Virtual98/Read.cs @@ -30,7 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System; +namespace Aaru.DiscImages; + using System.IO; using System.Text; using Aaru.CommonTypes; @@ -38,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class Virtual98 { /// @@ -54,7 +53,7 @@ public sealed partial class Virtual98 if(stream.Length < Marshal.SizeOf()) return ErrorNumber.InvalidArgument; - byte[] hdrB = new byte[Marshal.SizeOf()]; + var hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); _v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); @@ -85,6 +84,7 @@ public sealed partial class Virtual98 public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) { buffer = null; + if(sectorAddress > _imageInfo.Sectors - 1) return ErrorNumber.OutOfRange; @@ -96,12 +96,12 @@ public sealed partial class Virtual98 Stream stream = _nhdImageFilter.GetDataForkStream(); // V98 are lazy allocated - if((long)(0xDC + (sectorAddress * _imageInfo.SectorSize)) >= stream.Length) + if((long)(0xDC + sectorAddress * _imageInfo.SectorSize) >= stream.Length) return ErrorNumber.NoError; - stream.Seek((long)(0xDC + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(0xDC + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); - int toRead = (int)(length * _imageInfo.SectorSize); + var toRead = (int)(length * _imageInfo.SectorSize); if(toRead + stream.Position > stream.Length) toRead = (int)(stream.Length - stream.Position); diff --git a/Aaru.Images/Virtual98/Structs.cs b/Aaru.Images/Virtual98/Structs.cs index ceee545b4..03f65018f 100644 --- a/Aaru.Images/Virtual98/Structs.cs +++ b/Aaru.Images/Virtual98/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class Virtual98 { [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Images/Virtual98/Unsupported.cs b/Aaru.Images/Virtual98/Unsupported.cs index 31c0bcb1f..ac814e71a 100644 --- a/Aaru.Images/Virtual98/Unsupported.cs +++ b/Aaru.Images/Virtual98/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class Virtual98 { /// diff --git a/Aaru.Images/Virtual98/Virtual98.cs b/Aaru.Images/Virtual98/Virtual98.cs index 8991d43f3..922a0f3a3 100644 --- a/Aaru.Images/Virtual98/Virtual98.cs +++ b/Aaru.Images/Virtual98/Virtual98.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - // Info from Neko Project II emulator /// /// Implements reading Virtual98 disk images diff --git a/Aaru.Images/Virtual98/Write.cs b/Aaru.Images/Virtual98/Write.cs index abf886dca..74e1fe5e8 100644 --- a/Aaru.Images/Virtual98/Write.cs +++ b/Aaru.Images/Virtual98/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class Virtual98 { /// @@ -126,7 +126,7 @@ public sealed partial class Virtual98 return false; } - _writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Seek((long)(0xDC + sectorAddress * 512), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -158,7 +158,7 @@ public sealed partial class Virtual98 return false; } - _writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Seek((long)(0xDC + sectorAddress * 512), SeekOrigin.Begin); _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -235,10 +235,9 @@ public sealed partial class Virtual98 }; if(commentsBytes != null) - Array.Copy(commentsBytes, 0, _v98Hdr.comment, 0, - commentsBytes.Length >= 128 ? 128 : commentsBytes.Length); + Array.Copy(commentsBytes, 0, _v98Hdr.comment, 0, commentsBytes.Length >= 128 ? 128 : commentsBytes.Length); - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); System.Runtime.InteropServices.Marshal.StructureToPtr(_v98Hdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); diff --git a/Aaru.Images/WCDiskImage/Identify.cs b/Aaru.Images/WCDiskImage/Identify.cs index d52be1616..8ac181e43 100644 --- a/Aaru.Images/WCDiskImage/Identify.cs +++ b/Aaru.Images/WCDiskImage/Identify.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Text; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class WCDiskImage { /// @@ -49,7 +49,7 @@ public sealed partial class WCDiskImage if(stream.Length < 32) return false; - byte[] header = new byte[32]; + var header = new byte[32]; stream.Read(header, 0, 32); FileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); diff --git a/Aaru.Images/WCDiskImage/Properties.cs b/Aaru.Images/WCDiskImage/Properties.cs index a343ba05f..c0eb850d8 100644 --- a/Aaru.Images/WCDiskImage/Properties.cs +++ b/Aaru.Images/WCDiskImage/Properties.cs @@ -31,13 +31,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class WCDiskImage { /// @@ -46,7 +46,7 @@ public sealed partial class WCDiskImage /// public string Name => "d2f disk image"; /// - public Guid Id => new Guid("DDE01493-BCA2-41C2-A269-7E56D3716D2F"); + public Guid Id => new("DDE01493-BCA2-41C2-A269-7E56D3716D2F"); /// public string Author => "Michael Drüing"; /// diff --git a/Aaru.Images/WCDiskImage/Read.cs b/Aaru.Images/WCDiskImage/Read.cs index 9c4254ecc..2032b7c4a 100644 --- a/Aaru.Images/WCDiskImage/Read.cs +++ b/Aaru.Images/WCDiskImage/Read.cs @@ -31,6 +31,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.IO; using System.Text; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.DiscImages; - public sealed partial class WCDiskImage { /// @@ -52,7 +52,7 @@ public sealed partial class WCDiskImage Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - byte[] header = new byte[32]; + var header = new byte[32]; stream.Read(header, 0, 32); FileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); @@ -79,11 +79,11 @@ public sealed partial class WCDiskImage false)); /* buffer the entire disk in memory */ - for(int cyl = 0; cyl < _imageInfo.Cylinders; cyl++) + for(var cyl = 0; cyl < _imageInfo.Cylinders; cyl++) { - for(int head = 0; head < _imageInfo.Heads; head++) + for(var head = 0; head < _imageInfo.Heads; head++) { - var errno =ReadTrack(stream, cyl, head); + ErrorNumber errno = ReadTrack(stream, cyl, head); if(errno != ErrorNumber.NoError) return errno; @@ -128,7 +128,7 @@ public sealed partial class WCDiskImage if(fheader.extraFlags.HasFlag(ExtraFlag.Comment)) { AaruConsole.DebugWriteLine("d2f plugin", "Comment present, reading"); - byte[] sheaderBuffer = new byte[6]; + var sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); SectorHeader sheader = Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); @@ -140,7 +140,7 @@ public sealed partial class WCDiskImage return ErrorNumber.InvalidArgument; } - byte[] comm = new byte[sheader.crc]; + var comm = new byte[sheader.crc]; stream.Read(comm, 0, sheader.crc); comments += Encoding.ASCII.GetString(comm) + Environment.NewLine; } @@ -148,7 +148,7 @@ public sealed partial class WCDiskImage if(fheader.extraFlags.HasFlag(ExtraFlag.Directory)) { AaruConsole.DebugWriteLine("d2f plugin", "Directory listing present, reading"); - byte[] sheaderBuffer = new byte[6]; + var sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); SectorHeader sheader = Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); @@ -160,7 +160,7 @@ public sealed partial class WCDiskImage return ErrorNumber.InvalidArgument; } - byte[] dir = new byte[sheader.crc]; + var dir = new byte[sheader.crc]; stream.Read(dir, 0, sheader.crc); comments += Encoding.ASCII.GetString(dir); } @@ -179,7 +179,7 @@ public sealed partial class WCDiskImage public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) { int sectorNumber = (int)(sectorAddress % _imageInfo.SectorsPerTrack) + 1; - int trackNumber = (int)(sectorAddress / _imageInfo.SectorsPerTrack); + var trackNumber = (int)(sectorAddress / _imageInfo.SectorsPerTrack); int headNumber = _imageInfo.Heads > 1 ? trackNumber % 2 : 0; int cylinderNumber = _imageInfo.Heads > 1 ? trackNumber / 2 : trackNumber; @@ -245,10 +245,10 @@ public sealed partial class WCDiskImage byte[] crc; short calculatedCRC; - for(int sect = 1; sect < _imageInfo.SectorsPerTrack + 1; sect++) + for(var sect = 1; sect < _imageInfo.SectorsPerTrack + 1; sect++) { /* read the sector header */ - byte[] sheaderBuffer = new byte[6]; + var sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); SectorHeader sheader = Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); @@ -299,7 +299,7 @@ public sealed partial class WCDiskImage AaruConsole.DebugWriteLine("d2f plugin", "CHS {0},{1},{2}: RepeatByte sector, fill byte 0x{0:x2}", cyl, head, sect, sheader.crc & 0xff); */ - for(int i = 0; i < 512; i++) + for(var i = 0; i < 512; i++) sectorData[i] = (byte)(sheader.crc & 0xff); _sectorCache[(cyl, head, sect)] = sectorData; diff --git a/Aaru.Images/WCDiskImage/Structs.cs b/Aaru.Images/WCDiskImage/Structs.cs index 2cea45b4b..a13ed310d 100644 --- a/Aaru.Images/WCDiskImage/Structs.cs +++ b/Aaru.Images/WCDiskImage/Structs.cs @@ -31,10 +31,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.DiscImages; +using System.Runtime.InteropServices; + public sealed partial class WCDiskImage { /// The expected signature of a proper image file. diff --git a/Aaru.Images/WCDiskImage/Unsupported.cs b/Aaru.Images/WCDiskImage/Unsupported.cs index c41efee51..c919b0e45 100644 --- a/Aaru.Images/WCDiskImage/Unsupported.cs +++ b/Aaru.Images/WCDiskImage/Unsupported.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class WCDiskImage { /// diff --git a/Aaru.Images/WCDiskImage/WCDiskImage.cs b/Aaru.Images/WCDiskImage/WCDiskImage.cs index c996bbd04..153819212 100644 --- a/Aaru.Images/WCDiskImage/WCDiskImage.cs +++ b/Aaru.Images/WCDiskImage/WCDiskImage.cs @@ -31,28 +31,26 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Manages floppy disk images created with d2f by DataPackRat [SuppressMessage("ReSharper", "NotAccessedField.Local"), SuppressMessage("ReSharper", "InconsistentNaming")] public sealed partial class WCDiskImage : IMediaImage { - readonly Dictionary<(int cylinder, int head, int sector), bool> _badSectors = - new Dictionary<(int cylinder, int head, int sector), bool>(); + readonly Dictionary<(int cylinder, int head, int sector), bool> _badSectors = new(); /// The file header after the image has been opened FileHeader _fileHeader; ImageInfo _imageInfo; /* the sectors are cached here */ - readonly Dictionary<(int cylinder, int head, int sector), byte[]> _sectorCache = - new Dictionary<(int cylinder, int head, int sector), byte[]>(); + readonly Dictionary<(int cylinder, int head, int sector), byte[]> _sectorCache = new(); /// The ImageFilter we're reading from, after the file has been opened IFilter _wcImageFilter; diff --git a/Aaru.Images/ZZZRawImage/Constants.cs b/Aaru.Images/ZZZRawImage/Constants.cs index b8cc93319..3ff05179e 100644 --- a/Aaru.Images/ZZZRawImage/Constants.cs +++ b/Aaru.Images/ZZZRawImage/Constants.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes.Enums; - namespace Aaru.DiscImages; +using Aaru.CommonTypes.Enums; + public sealed partial class ZZZRawImage { readonly byte[] _cdSync = diff --git a/Aaru.Images/ZZZRawImage/Helpers.cs b/Aaru.Images/ZZZRawImage/Helpers.cs index 8d5187b02..b8e328ce5 100644 --- a/Aaru.Images/ZZZRawImage/Helpers.cs +++ b/Aaru.Images/ZZZRawImage/Helpers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using Aaru.CommonTypes; - namespace Aaru.DiscImages; +using Aaru.CommonTypes; + public sealed partial class ZZZRawImage { MediaType CalculateDiskType() diff --git a/Aaru.Images/ZZZRawImage/Identify.cs b/Aaru.Images/ZZZRawImage/Identify.cs index 9b0bb1768..77cc02012 100644 --- a/Aaru.Images/ZZZRawImage/Identify.cs +++ b/Aaru.Images/ZZZRawImage/Identify.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.IO; using System.Linq; using Aaru.CommonTypes.Interfaces; -namespace Aaru.DiscImages; - public sealed partial class ZZZRawImage { /// @@ -58,7 +58,7 @@ public sealed partial class ZZZRawImage case ".256": return imageFilter.DataForkLength % 256 == 0; case ".2352" when imageFilter.DataForkLength % 2352 == 0 && imageFilter.DataForkLength <= 846720000: case ".2448" when imageFilter.DataForkLength % 2448 == 0 && imageFilter.DataForkLength <= 881280000: - byte[] sync = new byte[12]; + var sync = new byte[12]; Stream stream = imageFilter.GetDataForkStream(); stream.Position = 0; stream.Read(sync, 0, 12); @@ -75,10 +75,10 @@ public sealed partial class ZZZRawImage return true; // Only for single track data CDs - if((imageFilter.DataForkLength % 2352 == 0 && imageFilter.DataForkLength <= 846720000) || - (imageFilter.DataForkLength % 2448 == 0 && imageFilter.DataForkLength <= 881280000)) + if(imageFilter.DataForkLength % 2352 == 0 && imageFilter.DataForkLength <= 846720000 || + imageFilter.DataForkLength % 2448 == 0 && imageFilter.DataForkLength <= 881280000) { - byte[] sync = new byte[12]; + var sync = new byte[12]; Stream stream = imageFilter.GetDataForkStream(); stream.Position = 0; stream.Read(sync, 0, 12); diff --git a/Aaru.Images/ZZZRawImage/Properties.cs b/Aaru.Images/ZZZRawImage/Properties.cs index 8d4b078a0..251bbacff 100644 --- a/Aaru.Images/ZZZRawImage/Properties.cs +++ b/Aaru.Images/ZZZRawImage/Properties.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Schemas; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class ZZZRawImage { /// @@ -171,7 +171,8 @@ public sealed partial class ZZZRawImage public CICMMetadataType CicmMetadata { get; private set; } /// public IEnumerable SupportedMediaTags => _readWriteSidecars.Concat(_writeOnlySidecars). - OrderBy(t => t.tag).Select(t => t.tag).ToArray(); + OrderBy(t => t.tag).Select(t => t.tag). + ToArray(); /// public IEnumerable SupportedSectorTags => new SectorTagType[] @@ -221,8 +222,8 @@ public sealed partial class ZZZRawImage /// public IEnumerable KnownExtensions => new[] { - ".adf", ".adl", ".d81", ".dsk", ".hdf", ".ima", ".img", ".iso", ".ssd", ".st", ".1kn", ".2kn", ".4kn", - ".8kn", ".16kn", ".32kn", ".64kn", ".512e", ".512", ".128", ".256" + ".adf", ".adl", ".d81", ".dsk", ".hdf", ".ima", ".img", ".iso", ".ssd", ".st", ".1kn", ".2kn", ".4kn", ".8kn", + ".16kn", ".32kn", ".64kn", ".512e", ".512", ".128", ".256" }; /// public bool IsWriting { get; private set; } diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index 4595b4e1e..3c7cf175d 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using System.IO; @@ -52,8 +54,6 @@ using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; using Session = Aaru.CommonTypes.Structs.Session; using TrackType = Aaru.CommonTypes.Enums.TrackType; -namespace Aaru.DiscImages; - public sealed partial class ZZZRawImage { /// @@ -342,8 +342,8 @@ public sealed partial class ZZZRawImage if(_imageInfo.ImageSize % 2352 == 0 || _imageInfo.ImageSize % 2448 == 0) { - byte[] sync = new byte[12]; - byte[] header = new byte[4]; + var sync = new byte[12]; + var header = new byte[4]; stream.Seek(0, SeekOrigin.Begin); stream.Read(sync, 0, 12); stream.Read(header, 0, 4); @@ -384,7 +384,7 @@ public sealed partial class ZZZRawImage continue; AaruConsole.DebugWriteLine("ZZZRawImage Plugin", "Found media tag {0}", sidecar.tag); - byte[] data = new byte[filter.DataForkLength]; + var data = new byte[filter.DataForkLength]; filter.GetDataForkStream().Read(data, 0, data.Length); _mediaTags.Add(sidecar.tag, data); } @@ -502,9 +502,7 @@ public sealed partial class ZZZRawImage if(DMI.IsXbox(dmi) || DMI.IsXbox360(dmi)) if(DMI.IsXbox(dmi)) - { _imageInfo.MediaType = MediaType.XGD; - } else if(DMI.IsXbox360(dmi)) { _imageInfo.MediaType = MediaType.XGD2; @@ -1058,16 +1056,13 @@ public sealed partial class ZZZRawImage _imageInfo.DriveModel = StringHandlers.CToString(scsiInq.Value.ProductIdentification).Trim(); - _imageInfo.DriveFirmwareRevision = - StringHandlers.CToString(scsiInq.Value.ProductRevisionLevel).Trim(); + _imageInfo.DriveFirmwareRevision = StringHandlers.CToString(scsiInq.Value.ProductRevisionLevel).Trim(); _imageInfo.MediaType = MediaTypeFromDevice.GetFromScsi((byte)devType, _imageInfo.DriveManufacturer, - _imageInfo.DriveModel, mediumType, - densityCode, _imageInfo.Sectors, - _imageInfo.SectorSize, + _imageInfo.DriveModel, mediumType, densityCode, + _imageInfo.Sectors, _imageInfo.SectorSize, _mediaTags.ContainsKey(MediaTagType. - USB_Descriptors), - _rawCompactDisc); + USB_Descriptors), _rawCompactDisc); } if(_imageInfo.MediaType == MediaType.Unknown) @@ -1219,8 +1214,7 @@ public sealed partial class ZZZRawImage } /// - public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => - ReadSectors(sectorAddress, 1, out buffer); + public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer) => ReadSectors(sectorAddress, 1, out buffer); /// public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) @@ -1263,9 +1257,9 @@ public sealed partial class ZZZRawImage buffer = br.ReadBytes((int)((sectorSize + sectorSkip) * length)); - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { - byte[] sector = new byte[sectorSize]; + var sector = new byte[sectorSize]; Array.Copy(buffer, (sectorSize + sectorSkip) * i, sector, 0, sectorSize); sector = Sector.GetUserDataFromMode2(sector); mode2Ms.Write(sector, 0, sector.Length); @@ -1277,7 +1271,7 @@ public sealed partial class ZZZRawImage sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1404,7 +1398,7 @@ public sealed partial class ZZZRawImage buffer = null; if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - (!_rawCompactDisc && tag != SectorTagType.CdTrackFlags)) + !_rawCompactDisc && tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported; return ReadSectorsTag(sectorAddress, 1, tag, out buffer); @@ -1416,7 +1410,7 @@ public sealed partial class ZZZRawImage buffer = null; if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - (!_rawCompactDisc && tag != SectorTagType.CdTrackFlags)) + !_rawCompactDisc && tag != SectorTagType.CdTrackFlags) return ErrorNumber.NotSupported; if(tag == SectorTagType.CdTrackFlags) @@ -1453,7 +1447,6 @@ public sealed partial class ZZZRawImage sectorSize = 96; } else - { switch(tag) { case SectorTagType.CdSectorSync: @@ -1521,7 +1514,6 @@ public sealed partial class ZZZRawImage default: return ErrorNumber.NotSupported; } - } buffer = new byte[sectorSize * length]; @@ -1533,7 +1525,7 @@ public sealed partial class ZZZRawImage sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { br.BaseStream.Seek(sectorOffset, SeekOrigin.Current); byte[] sector = br.ReadBytes((int)sectorSize); @@ -1579,7 +1571,7 @@ public sealed partial class ZZZRawImage if(sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { byte[] sector = br.ReadBytes((int)sectorSize); br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); diff --git a/Aaru.Images/ZZZRawImage/Verify.cs b/Aaru.Images/ZZZRawImage/Verify.cs index 2956ba86f..9b389f9b0 100644 --- a/Aaru.Images/ZZZRawImage/Verify.cs +++ b/Aaru.Images/ZZZRawImage/Verify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System; using System.Collections.Generic; using Aaru.Checksums; using Aaru.CommonTypes.Enums; -namespace Aaru.DiscImages; - public sealed partial class ZZZRawImage { /// @@ -72,10 +72,10 @@ public sealed partial class ZZZRawImage if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); @@ -121,10 +121,10 @@ public sealed partial class ZZZRawImage if(errno != ErrorNumber.NoError) return null; - int bps = (int)(buffer.Length / length); - byte[] sector = new byte[bps]; + var bps = (int)(buffer.Length / length); + var sector = new byte[bps]; - for(int i = 0; i < length; i++) + for(var i = 0; i < length; i++) { Array.Copy(buffer, i * bps, sector, 0, bps); bool? sectorStatus = CdChecksums.CheckCdSector(sector); diff --git a/Aaru.Images/ZZZRawImage/Write.cs b/Aaru.Images/ZZZRawImage/Write.cs index 906afe979..afab0844f 100644 --- a/Aaru.Images/ZZZRawImage/Write.cs +++ b/Aaru.Images/ZZZRawImage/Write.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.IO; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Schemas; -namespace Aaru.DiscImages; - public sealed partial class ZZZRawImage { /// @@ -264,8 +264,7 @@ public sealed partial class ZZZRawImage if(suffix == null) continue; - var tagStream = new FileStream(_basePath + suffix, FileMode.Create, FileAccess.ReadWrite, - FileShare.None); + var tagStream = new FileStream(_basePath + suffix, FileMode.Create, FileAccess.ReadWrite, FileShare.None); tagStream.Write(tag.Value, 0, tag.Value.Length); tagStream.Close(); diff --git a/Aaru.Images/ZZZRawImage/ZZZRawImage.cs b/Aaru.Images/ZZZRawImage/ZZZRawImage.cs index 4f89f0240..3448f5983 100644 --- a/Aaru.Images/ZZZRawImage/ZZZRawImage.cs +++ b/Aaru.Images/ZZZRawImage/ZZZRawImage.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.DiscImages; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -37,8 +39,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; -namespace Aaru.DiscImages; - /// /// Implements reading and writing raw (sector by sector) images [SuppressMessage("ReSharper", "InconsistentNaming")] diff --git a/Aaru.Partitions/Aaru.Partitions.csproj b/Aaru.Partitions/Aaru.Partitions.csproj index 811714a7d..d1eff4118 100644 --- a/Aaru.Partitions/Aaru.Partitions.csproj +++ b/Aaru.Partitions/Aaru.Partitions.csproj @@ -1,135 +1,130 @@  - - Debug - AnyCPU - 2.0 - {DA7AB65D-B5BA-4003-8893-A51BB071BA2F} - Library - Aaru.Partitions - Aaru.Partitions - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Partitions - $(Version) - net6 - CS0649 - 10 - Partitioning schemes implemented by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - full - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {DA7AB65D-B5BA-4003-8893-A51BB071BA2F} + Library + Aaru.Partitions + Aaru.Partitions + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Partitions + $(Version) + net6 + CS0649 + 10 + Partitioning schemes implemented by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + full + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Aaru.Partitions/Acorn.cs b/Aaru.Partitions/Acorn.cs index 5e7b49d41..bf40737e1 100644 --- a/Aaru.Partitions/Acorn.cs +++ b/Aaru.Partitions/Acorn.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of Acorn partitions public sealed class Acorn : IPartition @@ -86,9 +86,9 @@ public sealed class Acorn : IPartition AcornBootBlock bootBlock = Marshal.ByteArrayToStructureLittleEndian(sector); - int checksum = 0; + var checksum = 0; - for(int i = 0; i < 0x1FF; i++) + for(var i = 0; i < 0x1FF; i++) checksum = (checksum & 0xFF) + (checksum >> 8) + sector[i]; int heads = bootBlock.discRecord.heads + ((bootBlock.discRecord.lowsector >> 6) & 1); @@ -109,9 +109,9 @@ public sealed class Acorn : IPartition { var part = new Partition { - Size = ((ulong)bootBlock.discRecord.disc_size_high * 0x100000000) + bootBlock.discRecord.disc_size, - Length = (((ulong)bootBlock.discRecord.disc_size_high * 0x100000000) + - bootBlock.discRecord.disc_size) / imagePlugin.Info.SectorSize, + Size = (ulong)bootBlock.discRecord.disc_size_high * 0x100000000 + bootBlock.discRecord.disc_size, + Length = ((ulong)bootBlock.discRecord.disc_size_high * 0x100000000 + bootBlock.discRecord.disc_size) / + imagePlugin.Info.SectorSize, Type = "ADFS", Name = StringHandlers.CToString(bootBlock.discRecord.disc_name, Encoding.GetEncoding("iso-8859-1")) }; diff --git a/Aaru.Partitions/AppleMap.cs b/Aaru.Partitions/AppleMap.cs index 7377a1cf1..eccc74fb0 100644 --- a/Aaru.Partitions/AppleMap.cs +++ b/Aaru.Partitions/AppleMap.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -42,8 +44,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - // Information about structures learnt from Inside Macintosh // Constants from image testing /// @@ -92,7 +92,7 @@ public sealed class AppleMap : IPartition if(sectorSize == 256) { - byte[] tmp = new byte[512]; + var tmp = new byte[512]; Array.Copy(ddmSector, 0, tmp, 0, 256); ddmSector = tmp; maxDrivers = 29; @@ -117,20 +117,20 @@ public sealed class AppleMap : IPartition { ddm.sbMap = new AppleDriverEntry[ddm.sbDrvrCount]; - for(int i = 0; i < ddm.sbDrvrCount; i++) + for(var i = 0; i < ddm.sbDrvrCount; i++) { - byte[] tmp = new byte[8]; - Array.Copy(ddmSector, 18 + (i * 8), tmp, 0, 8); + var tmp = new byte[8]; + Array.Copy(ddmSector, 18 + i * 8, tmp, 0, 8); ddm.sbMap[i] = Marshal.ByteArrayToStructureBigEndian(tmp); - AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddBlock = {0}", - ddm.sbMap[i].ddBlock, i); + AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddBlock = {0}", ddm.sbMap[i].ddBlock, + i); - AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", - ddm.sbMap[i].ddSize, i); + AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", ddm.sbMap[i].ddSize, + i); - AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddType = {0}", - ddm.sbMap[i].ddType, i); + AaruConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddType = {0}", ddm.sbMap[i].ddType, + i); if(ddm.sbMap[i].ddSize == 0) continue; @@ -165,9 +165,9 @@ public sealed class AppleMap : IPartition // This is the easy one, no sector size mixing if(oldMap.pdSig == APM_MAGIC_OLD) { - for(int i = 2; i < partSector.Length; i += 12) + for(var i = 2; i < partSector.Length; i += 12) { - byte[] tmp = new byte[12]; + var tmp = new byte[12]; Array.Copy(partSector, i, tmp, 0, 12); AppleMapOldPartitionEntry oldEntry = @@ -179,8 +179,8 @@ public sealed class AppleMap : IPartition AaruConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdSize = {0}", oldEntry.pdSize, (i - 2) / 12); - AaruConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdFSID = 0x{0:X8}", - oldEntry.pdFSID, (i - 2) / 12); + AaruConsole.DebugWriteLine("AppleMap Plugin", "old_map.sbMap[{1}].pdFSID = 0x{0:X8}", oldEntry.pdFSID, + (i - 2) / 12); if(oldEntry.pdSize == 0 && oldEntry.pdFSID == 0) @@ -219,7 +219,7 @@ public sealed class AppleMap : IPartition // If sector is bigger than 512 if(ddmSector.Length > 512) { - byte[] tmp = new byte[512]; + var tmp = new byte[512]; Array.Copy(ddmSector, 512, tmp, 0, 512); entry = Marshal.ByteArrayToStructureBigEndian(tmp); @@ -230,7 +230,7 @@ public sealed class AppleMap : IPartition entrySize = 512; entryCount = entry.entries; skipDdm = 512; - sectorsToRead = ((entryCount + 1) * 512 / sectorSize) + 1; + sectorsToRead = (entryCount + 1) * 512 / sectorSize + 1; } else { @@ -274,13 +274,13 @@ public sealed class AppleMap : IPartition AaruConsole.DebugWriteLine("AppleMap Plugin", "skip_ddm = {0}", skipDdm); AaruConsole.DebugWriteLine("AppleMap Plugin", "sectors_to_read = {0}", sectorsToRead); - byte[] copy = new byte[entries.Length - skipDdm]; + var copy = new byte[entries.Length - skipDdm]; Array.Copy(entries, skipDdm, copy, 0, copy.Length); entries = copy; - for(int i = 0; i < entryCount; i++) + for(var i = 0; i < entryCount; i++) { - byte[] tmp = new byte[entrySize]; + var tmp = new byte[entrySize]; Array.Copy(entries, i * entrySize, tmp, 0, entrySize); entry = Marshal.ByteArrayToStructureBigEndian(tmp); @@ -310,16 +310,13 @@ public sealed class AppleMap : IPartition AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].boot_size = {1}", i, entry.boot_size); - AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address = 0x{1:X8}", i, - entry.load_address); + AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address = 0x{1:X8}", i, entry.load_address); - AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address2 = 0x{1:X8}", i, - entry.load_address2); + AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].load_address2 = 0x{1:X8}", i, entry.load_address2); AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point = 0x{1:X8}", i, entry.entry_point); - AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point2 = 0x{1:X8}", i, - entry.entry_point2); + AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].entry_point2 = 0x{1:X8}", i, entry.entry_point2); AaruConsole.DebugWriteLine("AppleMap Plugin", "dpme[{0}].checksum = 0x{1:X8}", i, entry.checksum); @@ -343,8 +340,8 @@ public sealed class AppleMap : IPartition Name = StringHandlers.CToString(entry.name), Offset = entry.start * entrySize, Size = entry.sectors * entrySize, - Start = (entry.start * entrySize / sectorSize) + sectorOffset, - Length = entry.sectors * entrySize / sectorSize, + Start = entry.start * entrySize / sectorSize + sectorOffset, + Length = entry.sectors * entrySize / sectorSize, Scheme = Name }; @@ -370,8 +367,7 @@ public sealed class AppleMap : IPartition if(flags.HasFlag(AppleMapFlags.Bootable)) { - sb.AppendFormat("First boot sector: {0}", entry.first_boot_block * entrySize / sectorSize). - AppendLine(); + sb.AppendFormat("First boot sector: {0}", entry.first_boot_block * entrySize / sectorSize).AppendLine(); sb.AppendFormat("Boot is {0} bytes.", entry.boot_size).AppendLine(); sb.AppendFormat("Boot load address: 0x{0:X8}", entry.load_address).AppendLine(); @@ -395,9 +391,8 @@ public sealed class AppleMap : IPartition // Some CD and DVDs end with an Apple_Free that expands beyond the disc size... else if(partition.Start < imagePlugin.Info.Sectors) { - AaruConsole.DebugWriteLine("AppleMap Plugin", - "Cutting last partition end ({0}) to media size ({1})", partition.End, - imagePlugin.Info.Sectors - 1); + AaruConsole.DebugWriteLine("AppleMap Plugin", "Cutting last partition end ({0}) to media size ({1})", + partition.End, imagePlugin.Info.Sectors - 1); partition.Length = imagePlugin.Info.Sectors - partition.Start; partitions.Add(partition); diff --git a/Aaru.Partitions/Apricot.cs b/Aaru.Partitions/Apricot.cs index 2e0f21d4a..e59103470 100644 --- a/Aaru.Partitions/Apricot.cs +++ b/Aaru.Partitions/Apricot.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -40,8 +42,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of Apricot partitions public sealed class Apricot : IPartition @@ -130,8 +130,7 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.copyProtected = {0}", label.copyProtected); AaruConsole.DebugWriteLine("Apricot partitions", "label.bootType = {0} ({1})", label.bootType, - label.bootType < _bootTypeCodes.Length ? _bootTypeCodes[label.bootType] - : "Unknown"); + label.bootType < _bootTypeCodes.Length ? _bootTypeCodes[label.bootType] : "Unknown"); AaruConsole.DebugWriteLine("Apricot partitions", "label.partitionCount = {0}", label.partitionCount); AaruConsole.DebugWriteLine("Apricot partitions", "label.winchester = {0}", label.winchester); @@ -171,13 +170,11 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.media = {0}", label.mainBPB.media); AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.spfat = {0}", label.mainBPB.spfat); - AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.diskType = {0} ({1})", - label.mainBPB.diskType, + AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.diskType = {0} ({1})", label.mainBPB.diskType, label.mainBPB.diskType < _diskTypeCodes.Length ? _diskTypeCodes[label.mainBPB.diskType] : "Unknown"); - AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.startSector = {0}", - label.mainBPB.startSector); + AaruConsole.DebugWriteLine("Apricot partitions", "label.mainBPB.startSector = {0}", label.mainBPB.startSector); AaruConsole.DebugWriteLine("Apricot partitions", "label.fontName = \"{0}\"", StringHandlers.CToString(label.fontName)); @@ -190,8 +187,7 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.diagnosticsFlag = {0}", label.diagnosticsFlag); AaruConsole.DebugWriteLine("Apricot partitions", "label.prnDevice = {0} ({1})", label.prnDevice, - label.prnDevice < _printDevices.Length ? _printDevices[label.prnDevice] - : "Unknown"); + label.prnDevice < _printDevices.Length ? _printDevices[label.prnDevice] : "Unknown"); AaruConsole.DebugWriteLine("Apricot partitions", "label.bellVolume = {0}", label.bellVolume); AaruConsole.DebugWriteLine("Apricot partitions", "label.enableCache = {0}", label.enableCache); @@ -206,8 +202,7 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.autorepeat = {0}", label.autorepeat); AaruConsole.DebugWriteLine("Apricot partitions", "label.autorepeatLeadIn = {0}", label.autorepeatLeadIn); - AaruConsole.DebugWriteLine("Apricot partitions", "label.autorepeatInterval = {0}", - label.autorepeatInterval); + AaruConsole.DebugWriteLine("Apricot partitions", "label.autorepeatInterval = {0}", label.autorepeatInterval); AaruConsole.DebugWriteLine("Apricot partitions", "label.microscreenMode = {0}", label.microscreenMode); @@ -240,8 +235,7 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.parityCheck = {0}", label.parityCheck); AaruConsole.DebugWriteLine("Apricot partitions", "label.parityType = {0} ({1})", label.parityType, - label.parityType < _parityTypes.Length ? _parityTypes[label.parityType] - : "Unknown"); + label.parityType < _parityTypes.Length ? _parityTypes[label.parityType] : "Unknown"); AaruConsole.DebugWriteLine("Apricot partitions", "label.txXonXoff = {0}", label.txXonXoff); AaruConsole.DebugWriteLine("Apricot partitions", "label.rxXonXoff = {0}", label.rxXonXoff); @@ -280,16 +274,16 @@ public sealed class Apricot : IPartition AaruConsole.DebugWriteLine("Apricot partitions", "label.spareRamDisk is null? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(label.spareRamDisk)); - for(int i = 0; i < 32; i++) + for(var i = 0; i < 32; i++) AaruConsole.DebugWriteLine("Apricot partitions", "label.badBlocks[{1}] = {0}", label.badBlocks[i], i); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { - AaruConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].bps = {0}", - label.partitions[i].bps, i); + AaruConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].bps = {0}", label.partitions[i].bps, + i); - AaruConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spc = {0}", - label.partitions[i].spc, i); + AaruConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].spc = {0}", label.partitions[i].spc, + i); AaruConsole.DebugWriteLine("Apricot partitions", "label.partitions[{1}].rsectors = {0}", label.partitions[i].rsectors, i); diff --git a/Aaru.Partitions/Atari.cs b/Aaru.Partitions/Atari.cs index 0b6baeee9..54e14aea6 100644 --- a/Aaru.Partitions/Atari.cs +++ b/Aaru.Partitions/Atari.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Text; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Helpers; using Spectre.Console; -namespace Aaru.Partitions; - /// /// Implements decoding of Atari GEMDOS partitions public sealed class AtariPartitions : IPartition @@ -88,22 +88,22 @@ public sealed class AtariPartitions : IPartition Array.Copy(sector, 0, table.Boot, 0, 342); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { - table.IcdEntries[i].Type = BigEndianBitConverter.ToUInt32(sector, 342 + (i * 12) + 0); - table.IcdEntries[i].Start = BigEndianBitConverter.ToUInt32(sector, 342 + (i * 12) + 4); - table.IcdEntries[i].Length = BigEndianBitConverter.ToUInt32(sector, 342 + (i * 12) + 8); + table.IcdEntries[i].Type = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 0); + table.IcdEntries[i].Start = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 4); + table.IcdEntries[i].Length = BigEndianBitConverter.ToUInt32(sector, 342 + i * 12 + 8); } Array.Copy(sector, 438, table.Unused, 0, 12); table.Size = BigEndianBitConverter.ToUInt32(sector, 450); - for(int i = 0; i < 4; i++) + for(var i = 0; i < 4; i++) { - table.Entries[i].Type = BigEndianBitConverter.ToUInt32(sector, 454 + (i * 12) + 0); - table.Entries[i].Start = BigEndianBitConverter.ToUInt32(sector, 454 + (i * 12) + 4); - table.Entries[i].Length = BigEndianBitConverter.ToUInt32(sector, 454 + (i * 12) + 8); + table.Entries[i].Type = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 0); + table.Entries[i].Start = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 4); + table.Entries[i].Length = BigEndianBitConverter.ToUInt32(sector, 454 + i * 12 + 8); } table.BadStart = BigEndianBitConverter.ToUInt32(sector, 502); @@ -114,13 +114,13 @@ public sealed class AtariPartitions : IPartition sha1Ctx.Update(table.Boot); AaruConsole.DebugWriteLine("Atari partition plugin", "Boot code SHA1: {0}", sha1Ctx.End()); - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { - AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.icdEntries[{0}].flag = 0x{1:X2}"), i, - (table.IcdEntries[i].Type & 0xFF000000) >> 24); + AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.icdEntries[{0}].flag = 0x{1:X2}"), + i, (table.IcdEntries[i].Type & 0xFF000000) >> 24); - AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.icdEntries[{0}].type = 0x{1:X6}"), i, - table.IcdEntries[i].Type & 0x00FFFFFF); + AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.icdEntries[{0}].type = 0x{1:X6}"), + i, table.IcdEntries[i].Type & 0x00FFFFFF); AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.icdEntries[{0}].start = {1}"), i, table.IcdEntries[i].Start); @@ -131,7 +131,7 @@ public sealed class AtariPartitions : IPartition AaruConsole.DebugWriteLine("Atari partition plugin", "table.size = {0}", table.Size); - for(int i = 0; i < 4; i++) + for(var i = 0; i < 4; i++) { AaruConsole.DebugWriteLine("Atari partition plugin", Markup.Escape("table.entries[{0}].flag = 0x{1:X2}"), i, (table.Entries[i].Type & 0xFF000000) >> 24); @@ -150,10 +150,10 @@ public sealed class AtariPartitions : IPartition AaruConsole.DebugWriteLine("Atari partition plugin", "table.badLength = {0}", table.BadLength); AaruConsole.DebugWriteLine("Atari partition plugin", "table.checksum = 0x{0:X4}", table.Checksum); - bool validTable = false; + var validTable = false; ulong partitionSequence = 0; - for(int i = 0; i < 4; i++) + for(var i = 0; i < 4; i++) { uint type = table.Entries[i].Type & 0x00FFFFFF; @@ -184,7 +184,7 @@ public sealed class AtariPartitions : IPartition sectorSize == 2352) sectorSize = 2048; - byte[] partType = new byte[3]; + var partType = new byte[3]; partType[0] = (byte)((type & 0xFF0000) >> 16); partType[1] = (byte)((type & 0x00FF00) >> 8); partType[2] = (byte)(type & 0x0000FF); @@ -264,19 +264,19 @@ public sealed class AtariPartitions : IPartition var extendedTable = new AtariTable(); extendedTable.Entries = new AtariEntry[4]; - for(int j = 0; j < 4; j++) + for(var j = 0; j < 4; j++) { extendedTable.Entries[j].Type = - BigEndianBitConverter.ToUInt32(extendedSector, 454 + (j * 12) + 0); + BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 0); extendedTable.Entries[j].Start = - BigEndianBitConverter.ToUInt32(extendedSector, 454 + (j * 12) + 4); + BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 4); extendedTable.Entries[j].Length = - BigEndianBitConverter.ToUInt32(extendedSector, 454 + (j * 12) + 8); + BigEndianBitConverter.ToUInt32(extendedSector, 454 + j * 12 + 8); } - for(int j = 0; j < 4; j++) + for(var j = 0; j < 4; j++) { uint extendedType = extendedTable.Entries[j].Type & 0x00FFFFFF; @@ -298,8 +298,7 @@ public sealed class AtariPartitions : IPartition if(extendedTable.Entries[j].Start > imagePlugin.Info.Sectors) continue; - if(extendedTable.Entries[j].Start + extendedTable.Entries[j].Length > - imagePlugin.Info.Sectors) + if(extendedTable.Entries[j].Start + extendedTable.Entries[j].Length > imagePlugin.Info.Sectors) AaruConsole.DebugWriteLine("Atari partition plugin", "WARNING: End of partition goes beyond device size"); @@ -309,7 +308,7 @@ public sealed class AtariPartitions : IPartition sectorSize == 2352) sectorSize = 2048; - byte[] partType = new byte[3]; + var partType = new byte[3]; partType[0] = (byte)((extendedType & 0xFF0000) >> 16); partType[1] = (byte)((extendedType & 0x00FF00) >> 8); partType[2] = (byte)(extendedType & 0x0000FF); @@ -386,7 +385,7 @@ public sealed class AtariPartitions : IPartition if(!validTable) return partitions.Count > 0; - for(int i = 0; i < 8; i++) + for(var i = 0; i < 8; i++) { uint type = table.IcdEntries[i].Type & 0x00FFFFFF; @@ -416,7 +415,7 @@ public sealed class AtariPartitions : IPartition sectorSize == 2352) sectorSize = 2048; - byte[] partType = new byte[3]; + var partType = new byte[3]; partType[0] = (byte)((type & 0xFF0000) >> 16); partType[1] = (byte)((type & 0x00FF00) >> 8); partType[2] = (byte)(type & 0x0000FF); diff --git a/Aaru.Partitions/BSD.cs b/Aaru.Partitions/BSD.cs index 3deba6c13..fb5b664b3 100644 --- a/Aaru.Partitions/BSD.cs +++ b/Aaru.Partitions/BSD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -42,8 +44,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of BSD disklabels [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -80,8 +80,8 @@ public sealed class BSD : IPartition if((MAX_LABEL_SIZE + _labelOffsets.Last()) % imagePlugin.Info.SectorSize > 0) run++; - var dl = new DiskLabel(); - bool found = false; + var dl = new DiskLabel(); + var found = false; foreach(ulong location in _labelLocations) { @@ -95,7 +95,7 @@ public sealed class BSD : IPartition foreach(uint offset in _labelOffsets) { - byte[] sector = new byte[MAX_LABEL_SIZE]; + var sector = new byte[MAX_LABEL_SIZE]; if(offset + MAX_LABEL_SIZE > tmp.Length) break; @@ -164,12 +164,11 @@ public sealed class BSD : IPartition AaruConsole.DebugWriteLine("BSD plugin", "dl.d_sbsize = {0}", dl.d_sbsize); ulong counter = 0; - bool addSectorOffset = false; + var addSectorOffset = false; - for(int i = 0; i < dl.d_npartitions && i < 22; i++) + for(var i = 0; i < dl.d_npartitions && i < 22; i++) { - AaruConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_offset = {0}", - dl.d_partitions[i].p_offset); + AaruConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_offset = {0}", dl.d_partitions[i].p_offset); AaruConsole.DebugWriteLine("BSD plugin", "dl.d_partitions[i].p_size = {0}", dl.d_partitions[i].p_size); @@ -251,13 +250,13 @@ public sealed class BSD : IPartition { dl = (DiskLabel)Marshal.SwapStructureMembersEndian(dl); - for(int i = 0; i < dl.d_drivedata.Length; i++) + for(var i = 0; i < dl.d_drivedata.Length; i++) dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]); - for(int i = 0; i < dl.d_spare.Length; i++) + for(var i = 0; i < dl.d_spare.Length; i++) dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]); - for(int i = 0; i < dl.d_partitions.Length; i++) + for(var i = 0; i < dl.d_partitions.Length; i++) dl.d_partitions[i] = (BSDPartition)Marshal.SwapStructureMembersEndian(dl.d_partitions[i]); return dl; diff --git a/Aaru.Partitions/DEC.cs b/Aaru.Partitions/DEC.cs index 7aa6bc2aa..3a1a143f8 100644 --- a/Aaru.Partitions/DEC.cs +++ b/Aaru.Partitions/DEC.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Linq; @@ -38,8 +40,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of DEC disklabels public sealed class DEC : IPartition @@ -55,8 +55,7 @@ public sealed class DEC : IPartition public string Author => "Natalia Portillo"; /// - public bool GetInformation(IMediaImage imagePlugin, out List partitions, - ulong sectorOffset) + public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { partitions = new List(); diff --git a/Aaru.Partitions/DragonFlyBSD.cs b/Aaru.Partitions/DragonFlyBSD.cs index 63320f110..e178fdc63 100644 --- a/Aaru.Partitions/DragonFlyBSD.cs +++ b/Aaru.Partitions/DragonFlyBSD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of DragonFly BSD disklabels [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -84,8 +84,8 @@ public sealed class DragonFlyBSD : IPartition { var part = new Partition { - Start = (entry.p_boffset / imagePlugin.Info.SectorSize) + sectorOffset, - Offset = entry.p_boffset + (sectorOffset * imagePlugin.Info.SectorSize), + Start = entry.p_boffset / imagePlugin.Info.SectorSize + sectorOffset, + Offset = entry.p_boffset + sectorOffset * imagePlugin.Info.SectorSize, Size = entry.p_bsize, Length = entry.p_bsize / imagePlugin.Info.SectorSize, Name = entry.p_stor_uuid.ToString(), diff --git a/Aaru.Partitions/GPT.cs b/Aaru.Partitions/GPT.cs index 7a9a4283c..0181061f1 100644 --- a/Aaru.Partitions/GPT.cs +++ b/Aaru.Partitions/GPT.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of the GUID Partition Table [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -73,8 +73,8 @@ public sealed class GuidPartitionTable : IPartition Header hdr; - ulong signature = BitConverter.ToUInt64(hdrBytes, 0); - bool misaligned = false; + var signature = BitConverter.ToUInt64(hdrBytes, 0); + var misaligned = false; AaruConsole.DebugWriteLine("GPT Plugin", "hdr.signature = 0x{0:X16}", signature); @@ -92,7 +92,7 @@ public sealed class GuidPartitionTable : IPartition if(signature == GPT_MAGIC) { AaruConsole.DebugWriteLine("GPT Plugin", "Found unaligned signature", signature); - byte[] real = new byte[512]; + var real = new byte[512]; Array.Copy(hdrBytes, 512, real, 0, 512); hdrBytes = real; misaligned = true; @@ -157,15 +157,15 @@ public sealed class GuidPartitionTable : IPartition if(errno != ErrorNumber.NoError) return false; - byte[] entriesBytes = new byte[temp.Length - (modulo * 512)]; + var entriesBytes = new byte[temp.Length - modulo * 512]; Array.Copy(temp, modulo * 512, entriesBytes, 0, entriesBytes.Length); List entries = new(); - for(int i = 0; i < hdr.entries; i++) + for(var i = 0; i < hdr.entries; i++) { try { - byte[] entryBytes = new byte[hdr.entriesSize]; + var entryBytes = new byte[hdr.entriesSize]; Array.Copy(entriesBytes, hdr.entriesSize * i, entryBytes, 0, hdr.entriesSize); entries.Add(Marshal.ByteArrayToStructureLittleEndian(entryBytes)); } diff --git a/Aaru.Partitions/Human68k.cs b/Aaru.Partitions/Human68k.cs index f647dc709..fbcc9701a 100644 --- a/Aaru.Partitions/Human68k.cs +++ b/Aaru.Partitions/Human68k.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - /// /// Implements decoding of Sharp's Human68K partitions public sealed class Human68K : IPartition @@ -101,7 +101,7 @@ public sealed class Human68K : IPartition if(table.magic != X68K_MAGIC) return false; - for(int i = 0; i < table.entries.Length; i++) + for(var i = 0; i < table.entries.Length; i++) table.entries[i] = (Entry)Marshal.SwapStructureMembersEndian(table.entries[i]); AaruConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size); diff --git a/Aaru.Partitions/MBR.cs b/Aaru.Partitions/MBR.cs index b4d81c2bc..7ab8994d3 100644 --- a/Aaru.Partitions/MBR.cs +++ b/Aaru.Partitions/MBR.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -41,8 +43,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Partitions; - // TODO: Support AAP extensions /// /// Implements decoding of Intel/Microsoft Master Boot Record and extensions @@ -63,8 +63,7 @@ public sealed class MBR : IPartition "FAT16 < 32 MiB", "Extended", "FAT16", "IFS (HPFS/NTFS)", // 0x08 - "AIX boot, OS/2, Commodore DOS", "AIX data, Coherent, QNX", "Coherent swap, OPUS, OS/2 Boot Manager", - "FAT32", + "AIX boot, OS/2, Commodore DOS", "AIX data, Coherent, QNX", "Coherent swap, OPUS, OS/2 Boot Manager", "FAT32", // 0x0C "FAT32 (LBA)", "Unknown", "FAT16 (LBA)", "Extended (LBA)", @@ -211,8 +210,7 @@ public sealed class MBR : IPartition "DR-DOS reserved", "DR-DOS reserved", "DR-DOS reserved", "DR-DOS secured FAT32", // 0xCC - "DR-DOS secured FAT32 (LBA)", "DR-DOS reserved", "DR-DOS secured FAT16 (LBA)", - "DR-DOS secured extended (LBA)", + "DR-DOS secured FAT32 (LBA)", "DR-DOS reserved", "DR-DOS secured FAT16 (LBA)", "DR-DOS secured extended (LBA)", // 0xD0 "Multiuser DOS secured FAT12", "Multiuser DOS secured FAT12", "Unknown", "Unknown", @@ -309,7 +307,7 @@ public sealed class MBR : IPartition if(errno != ErrorNumber.NoError) return false; - ulong signature = BitConverter.ToUInt64(hdrBytes, 0); + var signature = BitConverter.ToUInt64(hdrBytes, 0); AaruConsole.DebugWriteLine("MBR Plugin", "gpt.signature = 0x{0:X16}", signature); @@ -342,18 +340,18 @@ public sealed class MBR : IPartition foreach(PartitionEntry entry in entries) { - byte startSector = (byte)(entry.start_sector & 0x3F); - ushort startCylinder = (ushort)(((entry.start_sector & 0xC0) << 2) | entry.start_cylinder); - byte endSector = (byte)(entry.end_sector & 0x3F); - ushort endCylinder = (ushort)(((entry.end_sector & 0xC0) << 2) | entry.end_cylinder); - ulong lbaStart = entry.lba_start; - ulong lbaSectors = entry.lba_sectors; + var startSector = (byte)(entry.start_sector & 0x3F); + var startCylinder = (ushort)(((entry.start_sector & 0xC0) << 2) | entry.start_cylinder); + var endSector = (byte)(entry.end_sector & 0x3F); + var endCylinder = (ushort)(((entry.end_sector & 0xC0) << 2) | entry.end_cylinder); + ulong lbaStart = entry.lba_start; + ulong lbaSectors = entry.lba_sectors; // Let's start the fun... - bool valid = true; - bool extended = false; - bool minix = false; + var valid = true; + var extended = false; + var minix = false; if(entry.status != 0x00 && entry.status != 0x80) @@ -466,7 +464,7 @@ public sealed class MBR : IPartition if(!extended) continue; - bool processingExtended = true; + var processingExtended = true; ulong chainStart = lbaStart; while(processingExtended) @@ -487,14 +485,14 @@ public sealed class MBR : IPartition foreach(PartitionEntry ebrEntry in ebr.entries) { - bool extValid = true; + var extValid = true; startSector = (byte)(ebrEntry.start_sector & 0x3F); startCylinder = (ushort)(((ebrEntry.start_sector & 0xC0) << 2) | ebrEntry.start_cylinder); endSector = (byte)(ebrEntry.end_sector & 0x3F); endCylinder = (ushort)(((ebrEntry.end_sector & 0xC0) << 2) | ebrEntry.end_cylinder); ulong extStart = ebrEntry.lba_start; ulong extSectors = ebrEntry.lba_sectors; - bool extMinix = false; + var extMinix = false; AaruConsole.DebugWriteLine("MBR plugin", "ebr_entry.status {0}", ebrEntry.status); AaruConsole.DebugWriteLine("MBR plugin", "ebr_entry.type {0}", ebrEntry.type); @@ -511,17 +509,16 @@ public sealed class MBR : IPartition extValid &= ebrEntry.status == 0x00 || ebrEntry.status == 0x80; extValid &= ebrEntry.type != 0x00; - extValid &= ebrEntry.lba_start != 0 || ebrEntry.lba_sectors != 0 || - ebrEntry.start_cylinder != 0 || ebrEntry.start_head != 0 || - ebrEntry.start_sector != 0 || ebrEntry.end_cylinder != 0 || - ebrEntry.end_head != 0 || ebrEntry.end_sector != 0; + extValid &= ebrEntry.lba_start != 0 || ebrEntry.lba_sectors != 0 || ebrEntry.start_cylinder != 0 || + ebrEntry.start_head != 0 || ebrEntry.start_sector != 0 || ebrEntry.end_cylinder != 0 || + ebrEntry.end_head != 0 || ebrEntry.end_sector != 0; if(ebrEntry.lba_start == 0 && ebrEntry.lba_sectors == 0 && extValid) { - extStart = CHS.ToLBA(startCylinder, ebrEntry.start_head, startSector, - imagePlugin.Info.Heads, imagePlugin.Info.SectorsPerTrack); + extStart = CHS.ToLBA(startCylinder, ebrEntry.start_head, startSector, imagePlugin.Info.Heads, + imagePlugin.Info.SectorsPerTrack); extSectors = CHS.ToLBA(endCylinder, ebrEntry.end_head, ebrEntry.end_sector, imagePlugin.Info.Heads, imagePlugin.Info.SectorsPerTrack) - extStart; @@ -622,17 +619,17 @@ public sealed class MBR : IPartition if(mnx.magic != MBR_MAGIC) return false; - bool anyMnx = false; + var anyMnx = false; foreach(PartitionEntry mnxEntry in mnx.entries) { - bool mnxValid = true; - byte startSector = (byte)(mnxEntry.start_sector & 0x3F); - ushort startCylinder = (ushort)(((mnxEntry.start_sector & 0xC0) << 2) | mnxEntry.start_cylinder); - byte endSector = (byte)(mnxEntry.end_sector & 0x3F); - ushort endCylinder = (ushort)(((mnxEntry.end_sector & 0xC0) << 2) | mnxEntry.end_cylinder); - ulong mnxStart = mnxEntry.lba_start; - ulong mnxSectors = mnxEntry.lba_sectors; + var mnxValid = true; + var startSector = (byte)(mnxEntry.start_sector & 0x3F); + var startCylinder = (ushort)(((mnxEntry.start_sector & 0xC0) << 2) | mnxEntry.start_cylinder); + var endSector = (byte)(mnxEntry.end_sector & 0x3F); + var endCylinder = (ushort)(((mnxEntry.end_sector & 0xC0) << 2) | mnxEntry.end_cylinder); + ulong mnxStart = mnxEntry.lba_start; + ulong mnxSectors = mnxEntry.lba_sectors; AaruConsole.DebugWriteLine("MBR plugin", "mnx_entry.status {0}", mnxEntry.status); AaruConsole.DebugWriteLine("MBR plugin", "mnx_entry.type {0}", mnxEntry.type); diff --git a/Aaru.Partitions/NeXT.cs b/Aaru.Partitions/NeXT.cs index 8135c27b7..3e7562660 100644 --- a/Aaru.Partitions/NeXT.cs +++ b/Aaru.Partitions/NeXT.cs @@ -30,6 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// Information learnt from XNU source and testing against real disks +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -43,9 +48,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -// Information learnt from XNU source and testing against real disks -namespace Aaru.Partitions; - /// /// Implements decoding of NeXT disklabels [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] @@ -72,7 +74,7 @@ public sealed class NeXTDisklabel : IPartition /// public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { - bool magicFound = false; + var magicFound = false; byte[] labelSector; uint sectorSize; @@ -98,7 +100,7 @@ public sealed class NeXTDisklabel : IPartition if(errno != ErrorNumber.NoError) continue; - uint magic = BigEndianBitConverter.ToUInt32(labelSector, 0x00); + var magic = BigEndianBitConverter.ToUInt32(labelSector, 0x00); if(magic != NEXT_MAGIC1 && magic != NEXT_MAGIC2 && @@ -124,8 +126,8 @@ public sealed class NeXTDisklabel : IPartition if(errno != ErrorNumber.NoError) return false; - Label label = Marshal.ByteArrayToStructureBigEndian
(sector); diff --git a/Aaru.Partitions/SGI.cs b/Aaru.Partitions/SGI.cs index b4d37c8e7..5b51b61e5 100644 --- a/Aaru.Partitions/SGI.cs +++ b/Aaru.Partitions/SGI.cs @@ -30,6 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +#pragma warning disable 169 +#pragma warning disable 649 + +namespace Aaru.Partitions; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -40,11 +45,6 @@ using Aaru.Console; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; -#pragma warning disable 169 -#pragma warning disable 649 - -namespace Aaru.Partitions; - /// /// Implements decoding of the SGI Disk Volume Header [SuppressMessage("ReSharper", "InconsistentNaming")] @@ -60,8 +60,7 @@ public sealed class SGI : IPartition public string Author => "Natalia Portillo"; /// - public bool GetInformation(IMediaImage imagePlugin, out List partitions, - ulong sectorOffset) + public bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset) { partitions = new List(); @@ -73,14 +72,13 @@ public sealed class SGI : IPartition Label dvh = Marshal.ByteArrayToStructureBigEndian