diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index bc6ce2372..edf5148d4 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit bc6ce2372d54167c3734c7801cf97f785b2f0ef6 +Subproject commit edf5148d4924e99577a0c11c258a032a9247d414 diff --git a/Aaru.Compression/TeleDiskLzh.cs b/Aaru.Compression/TeleDiskLzh.cs index 486ab8e0c..a999866fe 100644 --- a/Aaru.Compression/TeleDiskLzh.cs +++ b/Aaru.Compression/TeleDiskLzh.cs @@ -183,7 +183,7 @@ namespace Aaru.Compression return count; // fatal error _tdctl.Bufpos = (ushort)((_tdctl.R - pos - 1) & (N - 1)); - _tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD); + _tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD); _tdctl.Bufndx = 0; } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index b4ddded45..8e490560b 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -49,6 +49,9 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Detects if a sector contains data + /// Sector contents + /// true if it contains Yellow Book data, false otherwise static bool IsData(byte[] sector) { if(sector?.Length != 2352) @@ -65,6 +68,11 @@ namespace Aaru.Core.Devices.Dumping return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2); } + /// Detects if a sector contains scrambled data + /// Sector contents + /// What LBA we intended to read + /// Offset in bytes, if found + /// true if it contains Yellow Book data, false otherwise static bool IsScrambledData(byte[] sector, int wantedLba, out int? offset) { offset = 0; @@ -83,30 +91,29 @@ namespace Aaru.Core.Devices.Dumping { Array.Copy(sector, i, testMark, 0, 12); - if(syncMark.SequenceEqual(testMark) && - (sector[i + 0xF] == 0x60 || sector[i + 0xF] == 0x61 || sector[i + 0xF] == 0x62)) + if(!syncMark.SequenceEqual(testMark) || + (sector[i + 0xF] != 0x60 && sector[i + 0xF] != 0x61 && sector[i + 0xF] != 0x62)) + continue; - { - // De-scramble M and S - int minute = sector[i + 12] ^ 0x01; - int second = sector[i + 13] ^ 0x80; - int frame = sector[i + 14]; + // De-scramble M and S + int minute = sector[i + 12] ^ 0x01; + int second = sector[i + 13] ^ 0x80; + 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); + // Convert to binary + 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; + // Calculate the first found LBA + int lba = ((minute * 60 * 75) + (second * 75) + frame) - 150; - // Calculate the difference between the found LBA and the requested one - int diff = wantedLba - lba; + // 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; - } + return true; } return false; @@ -114,7 +121,7 @@ namespace Aaru.Core.Devices.Dumping // TODO: Set pregap for Track 1 // TODO: Detect errors in sectors - /// Reads all CD user data + /// Reads all the hidden track in CD-i Ready discs /// Total number of positive sectors /// Size of the read sector in bytes /// Current read speed diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index 542481b57..b61918cf3 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -52,6 +52,25 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Retried errored sectors in CompactDisc + /// Extents with audio sectors + /// Size of the read sector in bytes + /// Current dump hardware try + /// Extents + /// Read offset + /// Device supports READ CD + /// Sectors needed to fix offset + /// Subchannel size in bytes + /// Drive's maximum supported subchannel + /// Supports reading EDC and ECC + /// Total commands duration + /// Disc tracks + /// Subchannel log + /// Subchannel desired to save + /// List of disc ISRCs + /// 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, MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog, @@ -307,11 +326,11 @@ namespace Aaru.Core.Devices.Dumping _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true); // Set tracks and go back - if(indexesChanged) - { - (_outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList()); - i--; - } + if(!indexesChanged) + continue; + + (_outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList()); + i--; } else { @@ -482,6 +501,18 @@ namespace Aaru.Core.Devices.Dumping EndProgress?.Invoke(); } + /// Retried errored subchannels in CompactDisc + /// Device supports READ CD + /// Subchannel size in bytes + /// Drive's maximum supported subchannel + /// Total commands duration + /// Disc tracks + /// Subchannel log + /// Subchannel desired to save + /// List of disc ISRCs + /// Disc media catalogue number + /// List of subchannels not yet dumped correctly + /// List of smallest pregap relative address per track void RetrySubchannel(bool readcd, uint subSize, MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog, MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary isrcs, ref string mcn, HashSet subchannelExtents, diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs index 624a5f6f8..67cb3a580 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Offset.cs @@ -41,6 +41,16 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Fix offset in audio/scrambled sectors + /// Offset in bytes + /// Sector size in bytes + /// How many extra sectors we got for offset + /// Subchannel type + /// How many sectors did we got + /// Subchannel size in bytes + /// 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) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs index 89693fa49..74f930e5d 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs @@ -37,6 +37,15 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Reads a sector using Plextor's D8h READ CDDA command with subchannel + /// Data buffer + /// Sense buffer + /// Fix sector to read + /// Sector size in bytes + /// How many sectors to read + /// Supported subchannel type + /// Time spent sending commands to the drive + /// true if an error occured, false otherwise bool ReadPlextorWithSubchannel(out byte[] cmdBuf, out byte[] senseBuf, uint firstSectorToRead, uint blockSize, uint blocksToRead, PlextorSubchannel supportedPlextorSubchannel, out double cmdDuration) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs index e27889981..c47eb579f 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs @@ -50,6 +50,12 @@ namespace Aaru.Core.Devices.Dumping partial class Dump { // TODO: Fix offset + /// Reads the first track pregap from a CompactDisc + /// Block size in bytes + /// Current speed + /// List of media tags + /// Subchannel the drive can read + /// Total time spent sending commands to a drive void ReadCdFirstTrackPregap(uint blockSize, ref double currentSpeed, Dictionary mediaTags, MmcSubchannel supportedSubchannel, ref double totalDuration) { @@ -125,6 +131,16 @@ namespace Aaru.Core.Devices.Dumping firstTrackPregapMs.Close(); } + /// Calculate track pregaps + /// Device + /// Dumping log + /// Progress update callback + /// List of tracks + /// Set if drive supports reading PQ subchannel + /// Set if drive supports reading RW subchannel + /// 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, Database.Models.Device dbDev, out bool inexactPositioning, bool dumping) @@ -512,9 +528,9 @@ namespace Aaru.Core.Devices.Dumping previousPregapIsPreviousTrack = false; // Pregap according to Q position - posQ = ((subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9]) - 150; - int diff = posQ - lba; - int pregapQ = (int)track.TrackStartSector - lba; + posQ = ((subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9]) - 150; + int diff = posQ - lba; + int pregapQ = (int)track.TrackStartSector - lba; if(diff != 0) { @@ -589,6 +605,13 @@ namespace Aaru.Core.Devices.Dumping } } + /// Reads a RAW subchannel sector for pregap calculation + /// Device + /// LBA + /// Database entry for device + /// Read subchannel + /// Set if it is an audio track + /// true if read correctly, false otherwise static bool GetSectorForPregapRaw(Device dev, uint lba, Database.Models.Device dbDev, out byte[] subBuf, bool audioTrack) { @@ -655,6 +678,12 @@ namespace Aaru.Core.Devices.Dumping return sense; } + /// Reads a Q16 subchannel sector for pregap calculation + /// Device + /// LBA + /// Read subchannel + /// Set if it is an audio track + /// true if read correctly, false otherwise static bool GetSectorForPregapQ16(Device dev, uint lba, out byte[] subBuf, bool audioTrack) { byte[] cmdBuf; @@ -707,6 +736,9 @@ namespace Aaru.Core.Devices.Dumping return sense; } + /// De-interleaves Q subchannel + /// Interleaved subchannel + /// De-interleaved Q subchannel static byte[] DeinterleaveQ(byte[] subchannel) { int[] q = new int[subchannel.Length / 8]; @@ -734,6 +766,8 @@ namespace Aaru.Core.Devices.Dumping return deQ; } + /// In place converts Q subchannel from binary to BCD numbering + /// Q subchannel static void BinaryToBcdQ(byte[] q) { q[1] = (byte)(((q[1] / 10) << 4) + (q[1] % 10)); @@ -747,6 +781,8 @@ namespace Aaru.Core.Devices.Dumping 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)); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs index d5d6bd067..d0302bd33 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs @@ -41,6 +41,12 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Check if the drive can read RW raw subchannel + /// Device + /// Dumping log + /// Progress update callback + /// LBA to try + /// true if read correctly, false otherwise public static bool SupportsRwSubchannel(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus, uint lba) { dumpLog?.WriteLine("Checking if drive supports full raw subchannel reading..."); @@ -51,6 +57,12 @@ namespace Aaru.Core.Devices.Dumping dev.Timeout, out _); } + /// Check if the drive can read RW raw subchannel + /// Device + /// Dumping log + /// Progress update callback + /// LBA to try + /// true if read correctly, false otherwise public static bool SupportsPqSubchannel(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus, uint lba) { dumpLog?.WriteLine("Checking if drive supports PQ subchannel reading..."); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs index 8521e8ee5..1fa0c06ce 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Tracks.cs @@ -239,47 +239,46 @@ namespace Aaru.Core.Devices.Dumping trackFlags?.Add(1, (byte)(leadoutTrackType == TrackType.Audio ? 0 : 4)); } - if(lastSector == 0) + if(lastSector != 0) + return trackList.ToArray(); + + sense = dev.ReadCapacity16(out cmdBuf, out _, dev.Timeout, out _); + + if(!sense) { - sense = dev.ReadCapacity16(out cmdBuf, out _, dev.Timeout, out _); + byte[] temp = new byte[8]; + + Array.Copy(cmdBuf, 0, temp, 0, 8); + Array.Reverse(temp); + lastSector = (long)BitConverter.ToUInt64(temp, 0); + } + else + { + sense = dev.ReadCapacity(out cmdBuf, out _, dev.Timeout, out _); if(!sense) - { - byte[] temp = new byte[8]; - - Array.Copy(cmdBuf, 0, temp, 0, 8); - Array.Reverse(temp); - lastSector = (long)BitConverter.ToUInt64(temp, 0); - } - else - { - sense = dev.ReadCapacity(out cmdBuf, out _, dev.Timeout, out _); - - if(!sense) - lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]; - } - - if(lastSector <= 0) - { - if(!force) - { - stoppingErrorMessage?. - Invoke("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors..."); - - dumpLog?. - WriteLine("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors..."); - - return null; - } - - updateStatus?. - Invoke("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before..."); - - dumpLog?.WriteLine("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before..."); - lastSector = 360000; - } + lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]; } + if(lastSector > 0) + return trackList.ToArray(); + + if(!force) + { + stoppingErrorMessage?. + Invoke("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors..."); + + dumpLog?.WriteLine("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors..."); + + return null; + } + + updateStatus?. + Invoke("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before..."); + + dumpLog?.WriteLine("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before..."); + lastSector = 360000; + return trackList.ToArray(); } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index f7eb067b4..9ec23ccff 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -49,6 +49,30 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Trims errored sectors in a CompactDisc + /// Extents with audio sectors + /// Size of the read sector in bytes + /// Current dump hardware try + /// Extents + /// Is trim a new one? + /// Read offset + /// Device supports READ(6) + /// Device supports READ(10) + /// Device supports READ(12) + /// Device supports READ(16) + /// Device supports READ CD + /// Sectors needed to fix offset + /// Subchannel size in bytes + /// Drive's maximum supported subchannel + /// Supports reading EDC and ECC + /// Total commands duration + /// Disc tracks + /// Subchannel log + /// Subchannel desired to save + /// List of disc ISRCs + /// 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, diff --git a/Aaru.Core/Devices/Dumping/Metadata.cs b/Aaru.Core/Devices/Dumping/Metadata.cs index fdf0af836..1c8321140 100644 --- a/Aaru.Core/Devices/Dumping/Metadata.cs +++ b/Aaru.Core/Devices/Dumping/Metadata.cs @@ -134,8 +134,7 @@ namespace Aaru.Core.Devices.Dumping if(mediaTags != null) foreach(KeyValuePair tag in mediaTags.Where(tag => _outputPlugin. - SupportedMediaTags. - Contains(tag.Key))) + SupportedMediaTags.Contains(tag.Key))) AddMediaTagToSidecar(_outputPath, tag, ref sidecar); UpdateStatus?.Invoke("Writing metadata sidecar"); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index 8728aaff6..c87c3ab9f 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -38,6 +38,21 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Dumps data when dumping from a SCSI Block Commands compliant device + /// Media blocks + /// Maximum number of blocks to read in a single command + /// Block size in bytes + /// Resume information + /// Correctly dump extents + /// Current speed + /// Minimum speed + /// Maximum speed + /// Total time spent in commands + /// SCSI reader + /// MHDD log + /// ImgBurn log + /// Total time spent writing to image + /// Set if we need to start a trim void ReadSbcData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardwareType currentTry, ExtentsULong extents, ref double currentSpeed, ref double minSpeed, ref double maxSpeed, ref double totalDuration, Reader scsiReader, MhddLog mhddLog, IbgLog ibgLog, diff --git a/Aaru.Core/Devices/Dumping/Sbc/Error.cs b/Aaru.Core/Devices/Dumping/Sbc/Error.cs index 0cf853fe1..7366b8e04 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Error.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Error.cs @@ -40,6 +40,12 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Retries errored data when dumping from a SCSI Block Commands compliant device + /// Resume information + /// Correctly dump extents + /// Total time spent in commands + /// SCSI reader + /// Blank extents void RetrySbcData(Reader scsiReader, DumpHardwareType currentTry, ExtentsULong extents, ref double totalDuration, ExtentsULong blankExtents) { diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 86e30514f..807ebcaa4 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -15,6 +15,25 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// + /// Dumps data when dumping from a SCSI Block Commands compliant device, optical variant (magneto-optical and + /// successors) + /// + /// Media blocks + /// Maximum number of blocks to read in a single command + /// Block size in bytes + /// Resume information + /// Correctly dump extents + /// Current speed + /// Minimum speed + /// Maximum speed + /// Total time spent in commands + /// SCSI reader + /// MHDD log + /// ImgBurn log + /// Total time spent writing to image + /// Set if we need to start a trim + /// Blank extents void ReadOpticalData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, DumpHardwareType currentTry, ExtentsULong extents, ref double currentSpeed, ref double minSpeed, ref double maxSpeed, ref double totalDuration, Reader scsiReader, MhddLog mhddLog, IbgLog ibgLog, diff --git a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs index 5c1377271..bfe032545 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs @@ -35,6 +35,11 @@ namespace Aaru.Core.Devices.Dumping { partial class Dump { + /// Trims data when dumping from a SCSI Block Commands compliant device + /// SCSI reader + /// Correctly dump extents + /// Resume information + /// Blank extents void TrimSbcData(Reader scsiReader, ExtentsULong extents, DumpHardwareType currentTry, ExtentsULong blankExtents) { diff --git a/Aaru.Core/Devices/Info/DeviceInfo.cs b/Aaru.Core/Devices/Info/DeviceInfo.cs index 784fde2c4..f98fbf3da 100644 --- a/Aaru.Core/Devices/Info/DeviceInfo.cs +++ b/Aaru.Core/Devices/Info/DeviceInfo.cs @@ -329,8 +329,7 @@ namespace Aaru.Core.Devices.Info for(byte i = 0; i < 4; i++) { plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, - out senseBuf, i, 256, dev.Timeout, - out _); + out senseBuf, i, 256, dev.Timeout, out _); if(plxtSense) break; @@ -347,7 +346,7 @@ namespace Aaru.Core.Devices.Info { if(dev.Model.StartsWith("CD-R ", StringComparison.Ordinal)) plxtSense = dev.PlextorReadEepromCdr(out plxtBuf, out senseBuf, dev.Timeout, - out _); + out _); break; } diff --git a/Aaru.Core/Devices/ReaderSCSI.cs b/Aaru.Core/Devices/ReaderSCSI.cs index 11ea6dc6f..7ed8389b4 100644 --- a/Aaru.Core/Devices/ReaderSCSI.cs +++ b/Aaru.Core/Devices/ReaderSCSI.cs @@ -216,150 +216,169 @@ namespace Aaru.Core.Devices } if(CanReadRaw && LongBlockSize == LogicalBlockSize) - if(LogicalBlockSize == 512) - foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 514, - - // Long sector sizes for SuperDisk - 536, 558, - - // Long sector sizes for 512-byte magneto-opticals - 600, 610, 630 - }) - { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); - - if(!testSense && - !_dev.Error) - { - _readLong16 = true; - LongBlockSize = testSize; - CanReadRaw = true; - - break; - } - - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, - out _); - - if(testSense || _dev.Error) - continue; - - _readLong10 = true; - LongBlockSize = testSize; - CanReadRaw = true; - - break; - } - else if(LogicalBlockSize == 1024) - foreach(ushort testSize in new ushort[] - { - // Long sector sizes for floppies - 1026, - - // Long sector sizes for 1024-byte magneto-opticals - 1200 - }) - { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _); - - if(!testSense && - !_dev.Error) - { - _readLong16 = true; - LongBlockSize = testSize; - CanReadRaw = true; - - break; - } - - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, _timeout, - out _); - - if(testSense || _dev.Error) - continue; - - _readLong10 = true; - LongBlockSize = testSize; - CanReadRaw = true; - - break; - } - else if(LogicalBlockSize == 2048) + switch(LogicalBlockSize) { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 2380, _timeout, out _); + case 512: + { + foreach(ushort testSize in new ushort[] + { + // Long sector sizes for floppies + 514, - if(!testSense && - !_dev.Error) - { - _readLong16 = true; - LongBlockSize = 2380; - CanReadRaw = true; + // Long sector sizes for SuperDisk + 536, 558, + + // Long sector sizes for 512-byte magneto-opticals + 600, 610, 630 + }) + { + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, + out _); + + if(!testSense && + !_dev.Error) + { + _readLong16 = true; + LongBlockSize = testSize; + CanReadRaw = true; + + break; + } + + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, + _timeout, out _); + + if(testSense || _dev.Error) + continue; + + _readLong10 = true; + LongBlockSize = testSize; + CanReadRaw = true; + + break; + } + + break; } - else + case 1024: { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 2380, _timeout, - out _); + foreach(ushort testSize in new ushort[] + { + // Long sector sizes for floppies + 1026, + + // Long sector sizes for 1024-byte magneto-opticals + 1200 + }) + { + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, + out _); + + if(!testSense && + !_dev.Error) + { + _readLong16 = true; + LongBlockSize = testSize; + CanReadRaw = true; + + break; + } + + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, testSize, + _timeout, out _); + + if(testSense || _dev.Error) + continue; + + _readLong10 = true; + LongBlockSize = testSize; + CanReadRaw = true; + + break; + } + + break; + } + case 2048: + { + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 2380, _timeout, out _); if(!testSense && !_dev.Error) { - _readLong10 = true; + _readLong16 = true; LongBlockSize = 2380; CanReadRaw = true; } - } - } - else if(LogicalBlockSize == 4096) - { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 4760, _timeout, out _); + else + { + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 2380, _timeout, + out _); - if(!testSense && - !_dev.Error) - { - _readLong16 = true; - LongBlockSize = 4760; - CanReadRaw = true; + if(!testSense && + !_dev.Error) + { + _readLong10 = true; + LongBlockSize = 2380; + CanReadRaw = true; + } + } + + break; } - else + case 4096: { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 4760, _timeout, - out _); + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 4760, _timeout, out _); if(!testSense && !_dev.Error) { - _readLong10 = true; + _readLong16 = true; LongBlockSize = 4760; CanReadRaw = true; } - } - } - else if(LogicalBlockSize == 8192) - { - testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 9424, _timeout, out _); + else + { + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 4760, _timeout, + out _); - if(!testSense && - !_dev.Error) - { - _readLong16 = true; - LongBlockSize = 9424; - CanReadRaw = true; + if(!testSense && + !_dev.Error) + { + _readLong10 = true; + LongBlockSize = 4760; + CanReadRaw = true; + } + } + + break; } - else + case 8192: { - testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 9424, _timeout, - out _); + testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 9424, _timeout, out _); if(!testSense && !_dev.Error) { - _readLong10 = true; + _readLong16 = true; LongBlockSize = 9424; CanReadRaw = true; } + else + { + testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 9424, _timeout, + out _); + + if(!testSense && + !_dev.Error) + { + _readLong10 = true; + LongBlockSize = 9424; + CanReadRaw = true; + } + } + + break; } } diff --git a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs index e6488a701..0a74c4492 100644 --- a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs +++ b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs @@ -292,12 +292,11 @@ namespace Aaru.Core.Devices.Report AaruConsole.Write("Reading LBA 0 as audio (scrambled)... "); report.GdRomSwapDiscCapabilities.Lba0ScrambledReadable = !_dev.ReadCd(out byte[] lba0ScrambledBuffer, - out byte[] lba0ScrambledSense, 0, - 2352, 1, MmcSectorTypes.Cdda, false, - false, false, MmcHeaderCodes.None, - true, false, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + out byte[] lba0ScrambledSense, 0, 2352, 1, + MmcSectorTypes.Cdda, false, false, false, + MmcHeaderCodes.None, true, false, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba0ScrambledData = lba0ScrambledBuffer; report.GdRomSwapDiscCapabilities.Lba0ScrambledSense = lba0ScrambledSense; @@ -311,15 +310,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba100000AudioSenseBuffer, + 100000, 2352, cluster, + MmcSectorTypes.Cdda, false, false, + false, MmcHeaderCodes.None, true, + false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba100000AudioData = lba100000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba100000AudioSense = lba100000AudioSenseBuffer; @@ -346,14 +343,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba50000AudioSenseBuffer, + 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; @@ -380,15 +376,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba450000AudioSenseBuffer, + 450000, 2352, cluster, + MmcSectorTypes.Cdda, false, false, + false, MmcHeaderCodes.None, true, + false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba450000AudioData = lba450000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba450000AudioSense = lba450000AudioSenseBuffer; @@ -415,15 +409,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba400000AudioSenseBuffer, + 400000, 2352, cluster, + MmcSectorTypes.Cdda, false, false, + false, MmcHeaderCodes.None, true, + false, MmcErrorField.None, + MmcSubchannel.None, _dev.Timeout, + out _); report.GdRomSwapDiscCapabilities.Lba400000AudioData = lba400000AudioBuffer; report.GdRomSwapDiscCapabilities.Lba400000AudioSense = lba400000AudioSenseBuffer; @@ -450,14 +442,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba45000AudioSenseBuffer, + 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; @@ -484,14 +475,13 @@ namespace Aaru.Core.Devices.Report while(true) { 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 _); + out byte[] lba44990AudioSenseBuffer, + 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; @@ -866,13 +856,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba100000Readable = !_dev.ReadCd(out byte[] lba100000Buffer, - out byte[] lba100000SenseBuffer, - 100000, 2352, cluster, - MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + out byte[] lba100000SenseBuffer, 100000, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000Data = lba100000Buffer; report.GdRomSwapDiscCapabilities.Lba100000Sense = lba100000SenseBuffer; @@ -896,12 +885,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba50000Readable = !_dev.ReadCd(out byte[] lba50000Buffer, - out byte[] lba50000SenseBuffer, 50000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba50000SenseBuffer, 50000, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba50000Data = lba50000Buffer; report.GdRomSwapDiscCapabilities.Lba50000Sense = lba50000SenseBuffer; @@ -925,13 +914,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba450000Readable = !_dev.ReadCd(out byte[] lba450000Buffer, - out byte[] lba450000SenseBuffer, - 450000, 2352, cluster, - MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + out byte[] lba450000SenseBuffer, 450000, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000Data = lba450000Buffer; report.GdRomSwapDiscCapabilities.Lba450000Sense = lba450000SenseBuffer; @@ -955,13 +943,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba400000Readable = !_dev.ReadCd(out byte[] lba400000Buffer, - out byte[] lba400000SenseBuffer, - 400000, 2352, cluster, - MmcSectorTypes.AllTypes, false, false, - true, MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.None, _dev.Timeout, - out _); + out byte[] lba400000SenseBuffer, 400000, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000Data = lba400000Buffer; report.GdRomSwapDiscCapabilities.Lba400000Sense = lba400000SenseBuffer; @@ -985,12 +972,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba45000Readable = !_dev.ReadCd(out byte[] lba45000Buffer, - out byte[] lba45000SenseBuffer, 45000, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba45000SenseBuffer, 45000, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba45000Data = lba45000Buffer; report.GdRomSwapDiscCapabilities.Lba45000Sense = lba45000SenseBuffer; @@ -1014,12 +1001,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba44990Readable = !_dev.ReadCd(out byte[] lba44990Buffer, - out byte[] lba44990SenseBuffer, 44990, - 2352, cluster, MmcSectorTypes.AllTypes, - false, false, true, - MmcHeaderCodes.AllHeaders, true, true, - MmcErrorField.None, MmcSubchannel.None, - _dev.Timeout, out _); + out byte[] lba44990SenseBuffer, 44990, + 2352, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.None, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba44990Data = lba44990Buffer; report.GdRomSwapDiscCapabilities.Lba44990Sense = lba44990SenseBuffer; @@ -1043,14 +1030,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba100000PqReadable = !_dev.ReadCd(out byte[] lba100000PqBuffer, - out byte[] lba100000PqSenseBuffer, - 100000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba100000PqSenseBuffer, + 100000, 2368, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer; report.GdRomSwapDiscCapabilities.Lba100000PqSense = lba100000PqSenseBuffer; @@ -1074,14 +1059,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba50000PqReadable = !_dev.ReadCd(out byte[] lba50000PqBuffer, - out byte[] lba50000PqSenseBuffer, - 50000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba50000PqSenseBuffer, 50000, + 2368, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba50000PqData = lba50000PqBuffer; report.GdRomSwapDiscCapabilities.Lba50000PqSense = lba50000PqSenseBuffer; @@ -1105,14 +1088,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba450000PqReadable = !_dev.ReadCd(out byte[] lba450000PqBuffer, - out byte[] lba450000PqSenseBuffer, - 450000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba450000PqSenseBuffer, + 450000, 2368, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer; report.GdRomSwapDiscCapabilities.Lba450000PqSense = lba450000PqSenseBuffer; @@ -1136,14 +1117,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba400000PqReadable = !_dev.ReadCd(out byte[] lba400000PqBuffer, - out byte[] lba400000PqSenseBuffer, - 400000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba400000PqSenseBuffer, + 400000, 2368, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Q16, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer; report.GdRomSwapDiscCapabilities.Lba400000PqSense = lba400000PqSenseBuffer; @@ -1167,14 +1146,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba45000PqReadable = !_dev.ReadCd(out byte[] lba45000PqBuffer, - out byte[] lba45000PqSenseBuffer, - 45000, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba45000PqSenseBuffer, 45000, + 2368, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba45000PqData = lba45000PqBuffer; report.GdRomSwapDiscCapabilities.Lba45000PqSense = lba45000PqSenseBuffer; @@ -1198,14 +1175,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba44990PqReadable = !_dev.ReadCd(out byte[] lba44990PqBuffer, - out byte[] lba44990PqSenseBuffer, - 44990, 2368, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Q16, _dev.Timeout, - out _); + out byte[] lba44990PqSenseBuffer, 44990, + 2368, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Q16, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba44990PqData = lba44990PqBuffer; report.GdRomSwapDiscCapabilities.Lba44990PqSense = lba44990PqSenseBuffer; @@ -1229,14 +1204,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba100000RwReadable = !_dev.ReadCd(out byte[] lba100000RwBuffer, - out byte[] lba100000RwSenseBuffer, - 100000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba100000RwSenseBuffer, + 100000, 2448, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Raw, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer; report.GdRomSwapDiscCapabilities.Lba100000RwSense = lba100000RwSenseBuffer; @@ -1260,14 +1233,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba50000RwReadable = !_dev.ReadCd(out byte[] lba50000RwBuffer, - out byte[] lba50000RwSenseBuffer, - 50000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba50000RwSenseBuffer, 50000, + 2448, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba50000RwData = lba50000RwBuffer; report.GdRomSwapDiscCapabilities.Lba50000RwSense = lba50000RwSenseBuffer; @@ -1291,14 +1262,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba450000RwReadable = !_dev.ReadCd(out byte[] lba450000RwBuffer, - out byte[] lba450000RwSenseBuffer, - 450000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba450000RwSenseBuffer, + 450000, 2448, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Raw, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer; report.GdRomSwapDiscCapabilities.Lba450000RwSense = lba450000RwSenseBuffer; @@ -1322,14 +1291,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba400000RwReadable = !_dev.ReadCd(out byte[] lba400000RwBuffer, - out byte[] lba400000RwSenseBuffer, - 400000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba400000RwSenseBuffer, + 400000, 2448, cluster, + MmcSectorTypes.AllTypes, false, false, + true, MmcHeaderCodes.AllHeaders, true, + true, MmcErrorField.None, + MmcSubchannel.Raw, _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer; report.GdRomSwapDiscCapabilities.Lba400000RwSense = lba400000RwSenseBuffer; @@ -1353,14 +1320,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba45000RwReadable = !_dev.ReadCd(out byte[] lba45000RwBuffer, - out byte[] lba45000RwSenseBuffer, - 45000, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba45000RwSenseBuffer, 45000, + 2448, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba45000RwData = lba45000RwBuffer; report.GdRomSwapDiscCapabilities.Lba45000RwSense = lba45000RwSenseBuffer; @@ -1384,14 +1349,12 @@ namespace Aaru.Core.Devices.Report while(true) { report.GdRomSwapDiscCapabilities.Lba44990RwReadable = !_dev.ReadCd(out byte[] lba44990RwBuffer, - out byte[] lba44990RwSenseBuffer, - 44990, 2448, cluster, - MmcSectorTypes.AllTypes, false, - false, true, - MmcHeaderCodes.AllHeaders, true, - true, MmcErrorField.None, - MmcSubchannel.Raw, _dev.Timeout, - out _); + out byte[] lba44990RwSenseBuffer, 44990, + 2448, cluster, MmcSectorTypes.AllTypes, + false, false, true, + MmcHeaderCodes.AllHeaders, true, true, + MmcErrorField.None, MmcSubchannel.Raw, + _dev.Timeout, out _); report.GdRomSwapDiscCapabilities.Lba44990RwData = lba44990RwBuffer; report.GdRomSwapDiscCapabilities.Lba44990RwSense = lba44990RwSenseBuffer; @@ -1596,13 +1559,9 @@ namespace Aaru.Core.Devices.Report ? _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 _); + 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/Scsi.cs b/Aaru.Core/Devices/Report/Scsi.cs index 425280421..4f183072c 100644 --- a/Aaru.Core/Devices/Report/Scsi.cs +++ b/Aaru.Core/Devices/Report/Scsi.cs @@ -425,7 +425,7 @@ namespace Aaru.Core.Devices.Report { mediaTest.MediumType = (byte)decMode.Value.Header.MediumType; - if(decMode?.Header.BlockDescriptors?.Length > 0) + if(decMode.Value.Header.BlockDescriptors?.Length > 0) mediaTest.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; } @@ -633,7 +633,7 @@ namespace Aaru.Core.Devices.Report { capabilities.MediumType = (byte)decMode.Value.Header.MediumType; - if(decMode?.Header.BlockDescriptors?.Length > 0) + if(decMode.Value.Header.BlockDescriptors?.Length > 0) capabilities.Density = (byte)decMode.Value.Header.BlockDescriptors[0].Density; } diff --git a/Aaru.Core/ImageFormat.cs b/Aaru.Core/ImageFormat.cs index 9bc2351f1..06e606213 100644 --- a/Aaru.Core/ImageFormat.cs +++ b/Aaru.Core/ImageFormat.cs @@ -53,10 +53,7 @@ namespace Aaru.Core // Check all but RAW plugin foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin => - imagePlugin.Id != - new - Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - ) + imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try { AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name); @@ -79,10 +76,7 @@ namespace Aaru.Core // Check only RAW plugin foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin => - imagePlugin.Id == - new - Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - ) + imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) try { AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name); diff --git a/Aaru.Core/Logging/SubchannelLog.cs b/Aaru.Core/Logging/SubchannelLog.cs index b20e505f9..7f158645b 100644 --- a/Aaru.Core/Logging/SubchannelLog.cs +++ b/Aaru.Core/Logging/SubchannelLog.cs @@ -164,17 +164,8 @@ namespace Aaru.Core.Logging if(raw) 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 && + 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; @@ -260,11 +251,11 @@ namespace Aaru.Core.Logging { long minute = (lba + 150) / 4500; long second = ((lba + 150) % 4500) / 75; - long frame = (lba + 150) % 4500 % 75; + long frame = (lba + 150) % 4500 % 75; string area = lba < 0 ? "Lead-In" : "Program"; _logSw.WriteLine($"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {message}"); _logSw.Flush(); } } -} +} \ No newline at end of file diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index 6275a79b2..bcda37e6e 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -42,7 +42,27 @@ namespace Aaru.Core.Media { public static class CompactDisc { - // Return true if indexes have changed + /// Writes subchannel data to an image + /// Subchannel read by drive + /// Subchannel user wants written to image + /// Subchannel data + /// Starting sector + /// How many sectors were read + /// Subchannel log + /// List of ISRCs + /// Current track number + /// Disc's MCN + /// List of tracks + /// List of subchannel extents + /// If we want to fix subchannel position + /// Output image + /// If we want to fix subchannel contents + /// If we want to fix Q subchannel CRC if the contents look sane + /// Dumping log + /// Status update callback + /// List of smallest known pregap per track + /// Set if we are dumping, otherwise converting + /// true if indexes have changed, false otherwise public static bool WriteSubchannelToImage(MmcSubchannel supportedSubchannel, MmcSubchannel desiredSubchannel, byte[] sub, ulong sectorAddress, uint length, SubchannelLog subLog, Dictionary isrcs, byte currentTrack, ref string mcn, @@ -52,9 +72,11 @@ namespace Aaru.Core.Media UpdateStatusHandler updateStatus, Dictionary smallestPregapLbaPerTrack, bool dumping) { + // We need to work in PW raw subchannels if(supportedSubchannel == MmcSubchannel.Q16) sub = Subchannel.ConvertQToRaw(sub); + // If not desired to fix, or to save, the subchannel, just save as is (or none) if(!fixSubchannelPosition && desiredSubchannel != MmcSubchannel.None) outputPlugin.WriteSectorsTag(sub, sectorAddress, length, SectorTagType.CdSectorSubchannel); @@ -76,17 +98,24 @@ namespace Aaru.Core.Media // Check subchannel for(int subPos = 0; subPos < deSub.Length; subPos += 96) { - long lba = (long)sectorAddress + (subPos / 96); - bool @fixed = false; - byte[] q = new byte[12]; + // Expected LBA + long lba = (long)sectorAddress + (subPos / 96); + + // We fixed the subchannel + bool @fixed = false; + + byte[] q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); + // Check Q CRC CRC16CCITTContext.Data(q, 10, out byte[] crc); bool crcOk = crc[0] == q[10] && crc[1] == q[11]; + // Start considering P to be OK bool pOk = true; int pWeight = 0; + // Check P and weight for(int p = subPos; p < subPos + 12; p++) { if(deSub[p] != 0 && @@ -121,6 +150,7 @@ namespace Aaru.Core.Media bool rwPacket = false; bool cdtextPacket = false; + // Check RW contents if(!rwOk) { byte[] sectorSub = new byte[96]; @@ -136,6 +166,7 @@ namespace Aaru.Core.Media rwOk = CheckCdTextPackets(sectorSub); } + // Fix P if(!pOk && fixSubchannel) { if(pWeight >= 48) @@ -151,6 +182,7 @@ namespace Aaru.Core.Media subLog.WritePFix(lba); } + // RW is not a known pattern or packet, fix it if(!rwOk && !rwPacket && !cdtextPacket && @@ -168,6 +200,7 @@ namespace Aaru.Core.Media byte smin, ssec, amin, asec, aframe; int aPos; + // Fix Q if(!crcOk && fixSubchannel && subPos > 0 && @@ -264,6 +297,17 @@ namespace Aaru.Core.Media return indexesChanged; } + /// Check subchannel for indexes + /// De-interleaved subchannel + /// List of ISRCs + /// Current track number + /// Disc's MCN + /// List of tracks + /// Dumping log + /// Status update callback + /// List of smallest known pregap per track + /// Set if we are dumping, otherwise converting + /// true if indexes have changed, false otherwise static bool CheckIndexesFromSubchannel(byte[] deSub, Dictionary isrcs, byte currentTrack, ref string mcn, Track[] tracks, DumpLog dumpLog, UpdateStatusHandler updateStatus, @@ -280,90 +324,118 @@ namespace Aaru.Core.Media CRC16CCITTContext.Data(q, 10, out byte[] crc); bool crcOk = crc[0] == q[10] && crc[1] == q[11]; - // ISRC - if((q[0] & 0x3) == 3) + switch(q[0] & 0x3) { - string isrc = Subchannel.DecodeIsrc(q); - - if(isrc == null || - isrc == "000000000000") - continue; - - if(!crcOk) - continue; - - if(!isrcs.ContainsKey(currentTrack)) + // ISRC + case 3: { - dumpLog?.WriteLine($"Found new ISRC {isrc} for track {currentTrack}."); - updateStatus?.Invoke($"Found new ISRC {isrc} for track {currentTrack}."); - } - else if(isrcs[currentTrack] != isrc) - { - dumpLog?. - WriteLine($"ISRC for track {currentTrack} changed from {isrcs[currentTrack]} to {isrc}."); + string isrc = Subchannel.DecodeIsrc(q); - updateStatus?. - Invoke($"ISRC for track {currentTrack} changed from {isrcs[currentTrack]} to {isrc}."); - } - - isrcs[currentTrack] = isrc; - } - else if((q[0] & 0x3) == 2) - { - string newMcn = Subchannel.DecodeMcn(q); - - if(newMcn == null || - newMcn == "0000000000000") - continue; - - if(!crcOk) - continue; - - if(mcn is null) - { - dumpLog?.WriteLine($"Found new MCN {newMcn}."); - updateStatus?.Invoke($"Found new MCN {newMcn}."); - } - else if(mcn != newMcn) - { - dumpLog?.WriteLine($"MCN changed from {mcn} to {newMcn}."); - updateStatus?.Invoke($"MCN changed from {mcn} to {newMcn}."); - } - - mcn = newMcn; - } - else if((q[0] & 0x3) == 1) - { - if(!crcOk) - continue; - - byte trackNo = (byte)(((q[1] / 16) * 10) + (q[1] & 0x0F)); - - for(int i = 0; i < tracks.Length; i++) - { - if(tracks[i].TrackSequence != trackNo) + if(isrc == null || + isrc == "000000000000") continue; - // Pregap - if(q[2] == 0 && - trackNo > 1) + if(!crcOk) + continue; + + if(!isrcs.ContainsKey(currentTrack)) { - 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; + dumpLog?.WriteLine($"Found new ISRC {isrc} for track {currentTrack}."); + updateStatus?.Invoke($"Found new ISRC {isrc} for track {currentTrack}."); + } + else if(isrcs[currentTrack] != isrc) + { + dumpLog?. + WriteLine($"ISRC for track {currentTrack} changed from {isrcs[currentTrack]} to {isrc}."); - // When we are dumping we calculate the pregap in reverse from index 1 back. - // When we are not, we go from index 0. - if(!smallestPregapLbaPerTrack.ContainsKey(trackNo)) - smallestPregapLbaPerTrack[trackNo] = dumping ? 1 : 0; + updateStatus?. + Invoke($"ISRC for track {currentTrack} changed from {isrcs[currentTrack]} to {isrc}."); + } - if(qPos < smallestPregapLbaPerTrack[trackNo]) + isrcs[currentTrack] = isrc; + + break; + } + + // MCN + case 2: + { + string newMcn = Subchannel.DecodeMcn(q); + + if(newMcn == null || + newMcn == "0000000000000") + continue; + + if(!crcOk) + continue; + + if(mcn is null) + { + dumpLog?.WriteLine($"Found new MCN {newMcn}."); + updateStatus?.Invoke($"Found new MCN {newMcn}."); + } + else if(mcn != newMcn) + { + dumpLog?.WriteLine($"MCN changed from {mcn} to {newMcn}."); + updateStatus?.Invoke($"MCN changed from {mcn} to {newMcn}."); + } + + mcn = newMcn; + + break; + } + + // Positioning + case 1 when !crcOk: continue; + case 1: + { + byte trackNo = (byte)(((q[1] / 16) * 10) + (q[1] & 0x0F)); + + for(int i = 0; i < tracks.Length; i++) + { + if(tracks[i].TrackSequence != trackNo) + continue; + + // Pregap + if(q[2] == 0 && + trackNo > 1) { - int dif = smallestPregapLbaPerTrack[trackNo] - qPos; - tracks[i].TrackPregap += (ulong)dif; - tracks[i].TrackStartSector -= (ulong)dif; - smallestPregapLbaPerTrack[trackNo] = qPos; + 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; + + // When we are dumping we calculate the pregap in reverse from index 1 back. + // When we are not, we go from index 0. + if(!smallestPregapLbaPerTrack.ContainsKey(trackNo)) + smallestPregapLbaPerTrack[trackNo] = dumping ? 1 : 0; + + if(qPos < smallestPregapLbaPerTrack[trackNo]) + { + int dif = smallestPregapLbaPerTrack[trackNo] - qPos; + tracks[i].TrackPregap += (ulong)dif; + tracks[i].TrackStartSector -= (ulong)dif; + smallestPregapLbaPerTrack[trackNo] = qPos; + + if(i > 0) + tracks[i - 1].TrackEndSector = tracks[i].TrackStartSector - 1; + + dumpLog?. + WriteLine($"Pregap for track {trackNo} set to {tracks[i].TrackPregap} sectors."); + + updateStatus?. + Invoke($"Pregap for track {trackNo} set to {tracks[i].TrackPregap} sectors."); + + status = true; + } + + if(tracks[i].TrackPregap >= (ulong)qPos) + continue; + + ulong oldPregap = tracks[i].TrackPregap; + + tracks[i].TrackPregap = (ulong)qPos; + tracks[i].TrackStartSector -= tracks[i].TrackPregap - oldPregap; if(i > 0) tracks[i - 1].TrackEndSector = tracks[i].TrackStartSector - 1; @@ -375,45 +447,31 @@ namespace Aaru.Core.Media Invoke($"Pregap for track {trackNo} set to {tracks[i].TrackPregap} sectors."); status = true; + + continue; } - if(tracks[i].TrackPregap >= (ulong)qPos) + if(q[2] == 0) continue; - ulong oldPregap = tracks[i].TrackPregap; + 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; - tracks[i].TrackPregap = (ulong)qPos; - tracks[i].TrackStartSector -= tracks[i].TrackPregap - oldPregap; + if(tracks[i].Indexes.ContainsKey(q[2]) && + aPos >= tracks[i].Indexes[q[2]]) + continue; - if(i > 0) - tracks[i - 1].TrackEndSector = tracks[i].TrackStartSector - 1; + dumpLog?.WriteLine($"Setting index {q[2]} for track {trackNo} to LBA {aPos}."); + updateStatus?.Invoke($"Setting index {q[2]} for track {trackNo} to LBA {aPos}."); - dumpLog?.WriteLine($"Pregap for track {trackNo} set to {tracks[i].TrackPregap} sectors."); - updateStatus?.Invoke($"Pregap for track {trackNo} set to {tracks[i].TrackPregap} sectors."); + tracks[i].Indexes[q[2]] = aPos; status = true; - - continue; } - 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; - - if(tracks[i].Indexes.ContainsKey(q[2]) && - aPos >= tracks[i].Indexes[q[2]]) - continue; - - dumpLog?.WriteLine($"Setting index {q[2]} for track {trackNo} to LBA {aPos}."); - updateStatus?.Invoke($"Setting index {q[2]} for track {trackNo} to LBA {aPos}."); - - tracks[i].Indexes[q[2]] = aPos; - - status = true; + break; } } } @@ -421,6 +479,11 @@ namespace Aaru.Core.Media return status; } + /// Detect RW packets + /// Subchannel data + /// Set if it contains a ZERO packet + /// Set if it contains a GRAPHICS, EXTENDED GRAPHICS or MIDI packet + /// Set if it contains a TEXT packet static void DetectRwPackets(byte[] subchannel, out bool zero, out bool rwPacket, out bool cdtextPacket) { zero = false; @@ -621,6 +684,9 @@ namespace Aaru.Core.Media cdtextPacket = true; } + /// Checks if subchannel contains a TEXT packet + /// Subchannel data + /// true if subchannel contains a TEXT packet, false otherwise static bool CheckCdTextPackets(byte[] subchannel) { byte[] cdTextPack1 = new byte[18]; @@ -759,6 +825,24 @@ namespace Aaru.Core.Media return false; } + /// Fixes Q subchannel + /// Deinterleaved subchannel data + /// Q subchannel + /// Position in deSub + /// Disc's MCN + /// Track ISRC + /// Set to true if we should fix the CRC, false otherwise + /// Set to true if we fixed the ADR, false otherwise + /// Set to true if we fixed the CONTROL, false otherwise + /// Set to true if we fixed the ZERO, false otherwise + /// Set to true if we fixed the TNO, false otherwise + /// Set to true if we fixed the INDEX, false otherwise + /// Set to true if we fixed the PMIN, PSEC and/or PFRAME, false otherwise + /// Set to true if we fixed the AMIN, ASEC and/or AFRAME, false otherwise + /// Set to true if we fixed the CRC, false otherwise + /// Set to true if we fixed the MCN, false otherwise + /// Set to true if we fixed the ISRC, false otherwise + /// true if it was fixed correctly, false otherwise static bool FixQSubchannel(byte[] deSub, byte[] q, int subPos, string mcn, string isrc, bool fixCrc, out bool fixedAdr, out bool controlFix, out bool fixedZero, out bool fixedTno, out bool fixedIndex, out bool fixedRelPos, out bool fixedAbsPos, out bool fixedCrc, @@ -892,28 +976,16 @@ namespace Aaru.Core.Media controlFix = true; } - if((q[0] & 0x3) == 1) + switch(q[0] & 0x3) { - // ZERO not zero - if(q[6] != 0) + // Positioning + case 1: { - q[6] = 0; - fixedZero = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - - if(preCrcOk && nextCrcOk) - { - if(preQ[1] == nextQ[1] && - preQ[1] != q[1]) + // ZERO not zero + if(q[6] != 0) { - q[1] = preQ[1]; - fixedTno = true; + q[6] = 0; + fixedZero = true; CRC16CCITTContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; @@ -921,84 +993,216 @@ namespace Aaru.Core.Media if(status) return true; } - } - if(preCrcOk && nextCrcOk) - { - if(preQ[2] == nextQ[2] && - preQ[2] != q[2]) + if(preCrcOk && nextCrcOk) { - q[2] = preQ[2]; - fixedIndex = true; + if(preQ[1] == nextQ[1] && + preQ[1] != q[1]) + { + q[1] = preQ[1]; + fixedTno = true; - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(status) - return true; + 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; - - 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 - if(q[2] > 0) - { - // Previous was not pregap either - if(preQ[2] > 0 && preCrcOk) + if(preCrcOk && nextCrcOk) { - 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; + if(preQ[2] == nextQ[2] && + preQ[2] != q[2]) + { + q[2] = preQ[2]; + fixedIndex = true; - dPos = pPos - rPos; + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + 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; + + 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 + if(q[2] > 0) + { + // 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; + + dPos = pPos - rPos; + + if(dPos != 1) + { + q[3] = preQ[3]; + q[4] = preQ[4]; + q[5] = preQ[5]; + + // BCD add 1, so 0x39 becomes 0x40 + if((q[5] & 0xF) == 9) + q[5] += 7; + else + q[5]++; + + // 74 frames, so from 0x00 to 0x74, BCD + if(q[5] >= 0x74) + { + // 0 frames + q[5] = 0; + + // Add 1 second + if((q[4] & 0xF) == 9) + q[4] += 7; + else + q[4]++; + + // 60 seconds, so from 0x00 to 0x59, BCD + if(q[4] >= 0x59) + { + // 0 seconds + q[4] = 0; + + // Add 1 minute + q[3]++; + } + } + + fixedRelPos = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; + } + } + + // Next is not pregap and we didn't fix relative position with previous + if(nextQ[2] > 0 && + 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; + + dPos = rPos - pPos; + + if(dPos != 1) + { + q[3] = nextQ[3]; + q[4] = nextQ[4]; + q[5] = nextQ[5]; + + // If frames is 0 + if(q[5] == 0) + { + // If seconds is 0 + if(q[4] == 0) + { + // BCD decrease minutes + if((q[3] & 0xF) == 0) + q[3] = (byte)((q[3] & 0xF0) - 0x10); + else + q[3]--; + + q[4] = 0x59; + q[5] = 0x73; + } + else + { + // BCD decrease seconds + if((q[4] & 0xF) == 0) + q[4] = (byte)((q[4] & 0xF0) - 0x10); + else + q[4]--; + + q[5] = 0x73; + } + } + + // BCD decrease frames + else if((q[5] & 0xF) == 0) + q[5] = (byte)((q[5] & 0xF0) - 0x10); + else + q[5]--; + + fixedRelPos = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; + } + } + } + + // 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; + + dPos = aPos - rPos; if(dPos != 1) { - q[3] = preQ[3]; - q[4] = preQ[4]; - q[5] = preQ[5]; + q[7] = preQ[7]; + q[8] = preQ[8]; + q[9] = preQ[9]; // BCD add 1, so 0x39 becomes 0x40 - if((q[5] & 0xF) == 9) - q[5] += 7; + if((q[9] & 0xF) == 9) + q[9] += 7; else - q[5]++; + q[9]++; // 74 frames, so from 0x00 to 0x74, BCD - if(q[5] >= 0x74) + if(q[9] >= 0x74) { // 0 frames - q[5] = 0; + q[9] = 0; // Add 1 second - if((q[4] & 0xF) == 9) - q[4] += 7; + if((q[8] & 0xF) == 9) + q[8] += 7; else - q[4]++; + q[8]++; // 60 seconds, so from 0x00 to 0x59, BCD - if(q[4] >= 0x59) + if(q[8] >= 0x59) { // 0 seconds - q[4] = 0; + q[8] = 0; // Add 1 minute - q[3]++; + q[7]++; } } - fixedRelPos = true; + fixedAbsPos = true; CRC16CCITTContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; @@ -1011,55 +1215,55 @@ namespace Aaru.Core.Media // Next is not pregap and we didn't fix relative position with previous if(nextQ[2] > 0 && nextCrcOk && - !fixedRelPos) + !fixedAbsPos) { - 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[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; if(dPos != 1) { - q[3] = nextQ[3]; - q[4] = nextQ[4]; - q[5] = nextQ[5]; + q[7] = nextQ[7]; + q[8] = nextQ[8]; + q[9] = nextQ[9]; // If frames is 0 - if(q[5] == 0) + if(q[9] == 0) { // If seconds is 0 - if(q[4] == 0) + if(q[8] == 0) { // BCD decrease minutes - if((q[3] & 0xF) == 0) - q[3] = (byte)((q[3] & 0xF0) - 0x10); + if((q[7] & 0xF) == 0) + q[7] = (byte)((q[7] & 0xF0) - 0x10); else - q[3]--; + q[7]--; - q[4] = 0x59; - q[5] = 0x73; + q[8] = 0x59; + q[9] = 0x73; } else { // BCD decrease seconds - if((q[4] & 0xF) == 0) - q[4] = (byte)((q[4] & 0xF0) - 0x10); + if((q[8] & 0xF) == 0) + q[8] = (byte)((q[8] & 0xF0) - 0x10); else - q[4]--; + q[8]--; - q[5] = 0x73; + q[9] = 0x73; } } // BCD decrease frames - else if((q[5] & 0xF) == 0) - q[5] = (byte)((q[5] & 0xF0) - 0x10); + else if((q[9] & 0xF) == 0) + q[9] = (byte)((q[9] & 0xF0) - 0x10); else - q[5]--; + q[9]--; - fixedRelPos = true; + fixedAbsPos = true; CRC16CCITTContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; @@ -1068,53 +1272,165 @@ namespace Aaru.Core.Media return true; } } + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + // Game Over + if(!fixCrc || status) + return false; + + // 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; + + 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; + + dPos = pPos - rPos; + + bool relOk = dPos == 1; + + if(q[0] != preQ[0] || + q[1] != preQ[1] || + q[2] != preQ[2] || + q[6] != 0 || + !absOk || + !relOk) + return false; + + CRC16CCITTContext.Data(q, 10, out qCrc); + q[10] = qCrc[0]; + q[11] = qCrc[1]; + + fixedCrc = true; + + return true; + } + + // 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; + + 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; + + dPos = rPos - pPos; + + bool relOk = dPos == 1; + + if(q[0] != nextQ[0] || + q[1] != nextQ[1] || + q[2] != nextQ[2] || + q[6] != 0 || + !absOk || + !relOk) + return false; + + CRC16CCITTContext.Data(q, 10, out qCrc); + q[10] = qCrc[0]; + q[11] = qCrc[1]; + + fixedCrc = true; + + return true; + } + + // Ok if previous and next are both BAD I won't rewrite the CRC at all + break; } - if(preCrcOk) + // MCN + case 2: { - 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; - - if(dPos != 1) + // Previous Q's CRC is correct + if(preCrcOk) { - q[7] = preQ[7]; - q[8] = preQ[8]; - q[9] = preQ[9]; + rframe = (byte)(((preQ[9] / 16) * 10) + (preQ[9] & 0x0F)); + aframe = (byte)(((q[9] / 16) * 10) + (q[9] & 0x0F)); - // BCD add 1, so 0x39 becomes 0x40 - if((q[9] & 0xF) == 9) - q[9] += 7; - else - q[9]++; - - // 74 frames, so from 0x00 to 0x74, BCD - if(q[9] >= 0x74) + if(aframe - rframe != 1) { - // 0 frames - q[9] = 0; + q[9] = preQ[9]; - // Add 1 second - if((q[8] & 0xF) == 9) - q[8] += 7; + if((q[9] & 0xF) == 9) + q[9] += 7; else - q[8]++; + q[9]++; - // 60 seconds, so from 0x00 to 0x59, BCD - if(q[8] >= 0x59) - { - // 0 seconds - q[8] = 0; + if(q[9] >= 0x74) + q[9] = 0; - // Add 1 minute - q[7]++; - } + fixedAbsPos = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; } + } - fixedAbsPos = true; + // 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)); + + if(aframe - rframe != 1) + { + q[9] = nextQ[9]; + + if(q[9] == 0) + q[9] = 0x73; + else if((q[9] & 0xF) == 0) + q[9] = (byte)((q[9] & 0xF0) - 0x10); + else + q[9]--; + + fixedAbsPos = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; + } + } + + // 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[8] = 0; + + fixedMcn = true; CRC16CCITTContext.Data(q, 10, out qCrc); status = qCrc[0] == q[10] && qCrc[1] == q[11]; @@ -1122,102 +1438,10 @@ namespace Aaru.Core.Media if(status) return true; } - } - // Next is not pregap and we didn't fix relative position with previous - if(nextQ[2] > 0 && - 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; - - dPos = rPos - pPos; - - if(dPos != 1) - { - q[7] = nextQ[7]; - q[8] = nextQ[8]; - q[9] = nextQ[9]; - - // If frames is 0 - if(q[9] == 0) - { - // If seconds is 0 - if(q[8] == 0) - { - // BCD decrease minutes - if((q[7] & 0xF) == 0) - q[7] = (byte)((q[7] & 0xF0) - 0x10); - else - q[7]--; - - q[8] = 0x59; - q[9] = 0x73; - } - else - { - // BCD decrease seconds - if((q[8] & 0xF) == 0) - q[8] = (byte)((q[8] & 0xF0) - 0x10); - else - q[8]--; - - q[9] = 0x73; - } - } - - // BCD decrease frames - else if((q[9] & 0xF) == 0) - q[9] = (byte)((q[9] & 0xF0) - 0x10); - else - q[9]--; - - fixedAbsPos = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - } - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - // Game Over - if(!fixCrc || status) - return false; - - 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; - - 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; - - dPos = pPos - rPos; - - bool relOk = dPos == 1; - - if(q[0] != preQ[0] || - q[1] != preQ[1] || - q[2] != preQ[2] || - q[6] != 0 || - !absOk || - !relOk) + if(!fixCrc || + !nextCrcOk || + !preCrcOk) return false; CRC16CCITTContext.Data(q, 10, out qCrc); @@ -1229,32 +1453,94 @@ namespace Aaru.Core.Media return true; } - if(nextCrcOk) + // ISRC + case 3: { - 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; + // 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)); - dPos = rPos - aPos; + if(aframe - rframe != 1) + { + q[9] = preQ[9]; - bool absOk = dPos == 1; + if((q[9] & 0xF) == 9) + q[9] += 7; + else + q[9]++; - 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; + if(q[9] >= 0x74) + q[9] = 0; - dPos = rPos - pPos; + fixedAbsPos = true; - bool relOk = dPos == 1; + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; - if(q[0] != nextQ[0] || - q[1] != nextQ[1] || - q[2] != nextQ[2] || - q[6] != 0 || - !absOk || - !relOk) + if(status) + return true; + } + } + + // 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)); + + if(aframe - rframe != 1) + { + q[9] = nextQ[9]; + + if(q[9] == 0) + q[9] = 0x73; + else if((q[9] & 0xF) == 0) + q[9] = (byte)((q[9] & 0xF0) - 0x10); + else + q[9]--; + + fixedAbsPos = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; + } + } + + // We know the ISRC + if(isrc != null) + { + byte i1 = Subchannel.GetIsrcCode(isrc[0]); + byte i2 = Subchannel.GetIsrcCode(isrc[1]); + byte i3 = Subchannel.GetIsrcCode(isrc[2]); + byte i4 = Subchannel.GetIsrcCode(isrc[3]); + byte i5 = Subchannel.GetIsrcCode(isrc[4]); + + q[1] = (byte)((i1 << 2) + ((i2 & 0x30) >> 4)); + 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); + + fixedIsrc = true; + + CRC16CCITTContext.Data(q, 10, out qCrc); + status = qCrc[0] == q[10] && qCrc[1] == q[11]; + + if(status) + return true; + } + + if(!fixCrc || + !nextCrcOk || + !preCrcOk) return false; CRC16CCITTContext.Data(q, 10, out qCrc); @@ -1265,193 +1551,22 @@ namespace Aaru.Core.Media return true; } - - // Ok if previous and next are both BAD I won't rewrite the CRC at all - } - else if((q[0] & 0x3) == 2) - { - if(preCrcOk) - { - rframe = (byte)(((preQ[9] / 16) * 10) + (preQ[9] & 0x0F)); - aframe = (byte)(((q[9] / 16) * 10) + (q[9] & 0x0F)); - - if(aframe - rframe != 1) - { - q[9] = preQ[9]; - - if((q[9] & 0xF) == 9) - q[9] += 7; - else - q[9]++; - - if(q[9] >= 0x74) - q[9] = 0; - - fixedAbsPos = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - } - else if(nextCrcOk) - { - rframe = (byte)(((nextQ[9] / 16) * 10) + (nextQ[9] & 0x0F)); - aframe = (byte)(((q[9] / 16) * 10) + (q[9] & 0x0F)); - - if(aframe - rframe != 1) - { - q[9] = nextQ[9]; - - if(q[9] == 0) - q[9] = 0x73; - else if((q[9] & 0xF) == 0) - q[9] = (byte)((q[9] & 0xF0) - 0x10); - else - q[9]--; - - fixedAbsPos = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - } - - 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[8] = 0; - - fixedMcn = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - - if(!fixCrc || - !nextCrcOk || - !preCrcOk) - return false; - - CRC16CCITTContext.Data(q, 10, out qCrc); - q[10] = qCrc[0]; - q[11] = qCrc[1]; - - fixedCrc = true; - - return true; - } - else if((q[0] & 0x3) == 3) - { - if(preCrcOk) - { - rframe = (byte)(((preQ[9] / 16) * 10) + (preQ[9] & 0x0F)); - aframe = (byte)(((q[9] / 16) * 10) + (q[9] & 0x0F)); - - if(aframe - rframe != 1) - { - q[9] = preQ[9]; - - if((q[9] & 0xF) == 9) - q[9] += 7; - else - q[9]++; - - if(q[9] >= 0x74) - q[9] = 0; - - fixedAbsPos = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - } - else if(nextCrcOk) - { - rframe = (byte)(((nextQ[9] / 16) * 10) + (nextQ[9] & 0x0F)); - aframe = (byte)(((q[9] / 16) * 10) + (q[9] & 0x0F)); - - if(aframe - rframe != 1) - { - q[9] = nextQ[9]; - - if(q[9] == 0) - q[9] = 0x73; - else if((q[9] & 0xF) == 0) - q[9] = (byte)((q[9] & 0xF0) - 0x10); - else - q[9]--; - - fixedAbsPos = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - } - - if(isrc != null) - { - byte i1 = Subchannel.GetIsrcCode(isrc[0]); - byte i2 = Subchannel.GetIsrcCode(isrc[1]); - byte i3 = Subchannel.GetIsrcCode(isrc[2]); - byte i4 = Subchannel.GetIsrcCode(isrc[3]); - byte i5 = Subchannel.GetIsrcCode(isrc[4]); - - q[1] = (byte)((i1 << 2) + ((i2 & 0x30) >> 4)); - 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); - - fixedIsrc = true; - - CRC16CCITTContext.Data(q, 10, out qCrc); - status = qCrc[0] == q[10] && qCrc[1] == q[11]; - - if(status) - return true; - } - - if(!fixCrc || - !nextCrcOk || - !preCrcOk) - return false; - - CRC16CCITTContext.Data(q, 10, out qCrc); - q[10] = qCrc[0]; - q[11] = qCrc[1]; - - fixedCrc = true; - - return true; } return false; } + /// Generates a correct subchannel all the missing ones + /// List of missing subchannels + /// List of tracks + /// Flags of tracks + /// Disc size + /// Subchannel log + /// Dump log + /// Progress initialization callback + /// Progress update callback + /// Progress finalization callback + /// Output image public static void GenerateSubchannels(HashSet subchannelExtents, Track[] tracks, Dictionary trackFlags, ulong blocks, SubchannelLog subLog, DumpLog dumpLog, InitProgressHandler initProgress, diff --git a/Aaru.Core/Partitions.cs b/Aaru.Core/Partitions.cs index f4de19f3c..d258d22c7 100644 --- a/Aaru.Core/Partitions.cs +++ b/Aaru.Core/Partitions.cs @@ -173,14 +173,11 @@ namespace Aaru.Core if(partitionableImage.Partitions != null) childPartitions.AddRange(partitionableImage.Partitions.Where(imagePartition => - !startLocations. - Contains(imagePartition. - Start))); + !startLocations.Contains(imagePartition.Start))); } - Partition[] childArray = childPartitions. - OrderBy(part => part.Start).ThenBy(part => part.Length). - ThenBy(part => part.Scheme).ToArray(); + Partition[] childArray = childPartitions.OrderBy(part => part.Start).ThenBy(part => part.Length). + ThenBy(part => part.Scheme).ToArray(); for(long i = 0; i < childArray.LongLength; i++) childArray[i].Sequence = (ulong)i; diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index b03e60b1c..ab7f37775 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -196,8 +196,7 @@ namespace Aaru.Core break; case MediaTagType.SD_CID: - if(sidecar.BlockMedia[0].SecureDigital == null) - sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType(); + sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType(); sidecar.BlockMedia[0].SecureDigital.CID = new DumpType { @@ -207,8 +206,7 @@ namespace Aaru.Core break; case MediaTagType.SD_CSD: - if(sidecar.BlockMedia[0].SecureDigital == null) - sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType(); + sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType(); sidecar.BlockMedia[0].SecureDigital.CSD = new DumpType { @@ -218,8 +216,7 @@ namespace Aaru.Core break; case MediaTagType.SD_SCR: - if(sidecar.BlockMedia[0].SecureDigital == null) - sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType(); + sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType(); sidecar.BlockMedia[0].SecureDigital.SCR = new DumpType { @@ -229,8 +226,7 @@ namespace Aaru.Core break; case MediaTagType.SD_OCR: - if(sidecar.BlockMedia[0].SecureDigital == null) - sidecar.BlockMedia[0].SecureDigital = new SecureDigitalType(); + sidecar.BlockMedia[0].SecureDigital ??= new SecureDigitalType(); sidecar.BlockMedia[0].SecureDigital.OCR = new DumpType { @@ -240,8 +236,7 @@ namespace Aaru.Core break; case MediaTagType.MMC_CID: - if(sidecar.BlockMedia[0].MultiMediaCard == null) - sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType(); + sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType(); sidecar.BlockMedia[0].MultiMediaCard.CID = new DumpType { @@ -251,8 +246,7 @@ namespace Aaru.Core break; case MediaTagType.MMC_CSD: - if(sidecar.BlockMedia[0].MultiMediaCard == null) - sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType(); + sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType(); sidecar.BlockMedia[0].MultiMediaCard.CSD = new DumpType { @@ -262,8 +256,7 @@ namespace Aaru.Core break; case MediaTagType.MMC_OCR: - if(sidecar.BlockMedia[0].MultiMediaCard == null) - sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType(); + sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType(); sidecar.BlockMedia[0].MultiMediaCard.OCR = new DumpType { @@ -273,8 +266,7 @@ namespace Aaru.Core break; case MediaTagType.MMC_ExtendedCSD: - if(sidecar.BlockMedia[0].MultiMediaCard == null) - sidecar.BlockMedia[0].MultiMediaCard = new MultiMediaCardType(); + sidecar.BlockMedia[0].MultiMediaCard ??= new MultiMediaCardType(); sidecar.BlockMedia[0].MultiMediaCard.ExtendedCSD = new DumpType { @@ -285,8 +277,7 @@ namespace Aaru.Core break; case MediaTagType.USB_Descriptors: - if(sidecar.BlockMedia[0].USB == null) - sidecar.BlockMedia[0].USB = new USBType(); + sidecar.BlockMedia[0].USB ??= new USBType(); sidecar.BlockMedia[0].USB.Descriptors = new DumpType { @@ -297,8 +288,7 @@ namespace Aaru.Core break; case MediaTagType.SCSI_MODESENSE_6: - if(sidecar.BlockMedia[0].SCSI == null) - sidecar.BlockMedia[0].SCSI = new SCSIType(); + sidecar.BlockMedia[0].SCSI ??= new SCSIType(); sidecar.BlockMedia[0].SCSI.ModeSense = new DumpType { @@ -309,8 +299,7 @@ namespace Aaru.Core break; case MediaTagType.SCSI_MODESENSE_10: - if(sidecar.BlockMedia[0].SCSI == null) - sidecar.BlockMedia[0].SCSI = new SCSIType(); + sidecar.BlockMedia[0].SCSI ??= new SCSIType(); sidecar.BlockMedia[0].SCSI.ModeSense10 = new DumpType { @@ -356,13 +345,13 @@ namespace Aaru.Core if(sectors - doneSectors >= sectorsToRead) { sector = image.ReadSectors(doneSectors, sectorsToRead); - UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, (long)sectors); + UpdateProgress2("Hashing sector {0} of {1}", (long)doneSectors, (long)sectors); doneSectors += sectorsToRead; } else { sector = image.ReadSectors(doneSectors, (uint)(sectors - doneSectors)); - UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, (long)sectors); + UpdateProgress2("Hashing sector {0} of {1}", (long)doneSectors, (long)sectors); doneSectors += sectors - doneSectors; } @@ -927,8 +916,8 @@ namespace Aaru.Core scpBlockTrackTypes.Add(scpBlockTrackType); } - sidecar.BlockMedia[0].Track = - scpBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); + sidecar.BlockMedia[0].Track = scpBlockTrackTypes.OrderBy(t => t.Cylinder). + ThenBy(t => t.Head).ToArray(); } else AaruConsole. @@ -1032,8 +1021,8 @@ namespace Aaru.Core kfBlockTrackTypes.Add(kfBlockTrackType); } - sidecar.BlockMedia[0].Track = - kfBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); + sidecar.BlockMedia[0].Track = kfBlockTrackTypes.OrderBy(t => t.Cylinder). + ThenBy(t => t.Head).ToArray(); } else AaruConsole. diff --git a/Aaru.Core/Sidecar/Helpers.cs b/Aaru.Core/Sidecar/Helpers.cs index bbd1509a4..c32c4cc86 100644 --- a/Aaru.Core/Sidecar/Helpers.cs +++ b/Aaru.Core/Sidecar/Helpers.cs @@ -72,8 +72,8 @@ namespace Aaru.Core { h = (lba + 150) / (75 * 60 * 60); lba -= h * (75 * 60 * 60); - m = (lba + 150) / (75 * 60); - lba -= m * (75 * 60); + m = (lba + 150) / (75 * 60); + lba -= m * (75 * 60); s = (lba + 150) / 75; lba -= s * 75; f = lba + 150; @@ -82,8 +82,8 @@ namespace Aaru.Core { h = (lba + (450150 * 2)) / (75 * 60 * 60); lba -= h * (75 * 60 * 60); - m = (lba + (450150 * 2)) / (75 * 60); - lba -= m * (75 * 60); + m = (lba + (450150 * 2)) / (75 * 60); + lba -= m * (75 * 60); s = (lba + (450150 * 2)) / 75; lba -= s * 75; f = lba + (450150 * 2); diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index 3819c7c0e..552403202 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -366,8 +366,7 @@ namespace Aaru.Core break; case MediaTagType.Xbox_SecuritySector: - if(sidecar.OpticalDisc[0].Xbox == null) - sidecar.OpticalDisc[0].Xbox = new XboxType(); + sidecar.OpticalDisc[0].Xbox ??= new XboxType(); sidecar.OpticalDisc[0].Xbox.SecuritySectors = new[] { @@ -388,8 +387,7 @@ namespace Aaru.Core break; case MediaTagType.Xbox_PFI: - if(sidecar.OpticalDisc[0].Xbox == null) - sidecar.OpticalDisc[0].Xbox = new XboxType(); + sidecar.OpticalDisc[0].Xbox ??= new XboxType(); sidecar.OpticalDisc[0].Xbox.PFI = new DumpType { @@ -400,8 +398,7 @@ namespace Aaru.Core break; case MediaTagType.Xbox_DMI: - if(sidecar.OpticalDisc[0].Xbox == null) - sidecar.OpticalDisc[0].Xbox = new XboxType(); + sidecar.OpticalDisc[0].Xbox ??= new XboxType(); sidecar.OpticalDisc[0].Xbox.DMI = new DumpType { @@ -601,7 +598,7 @@ namespace Aaru.Core { sector = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.TrackNumber); - UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, + UpdateProgress2("Hashing sector {0} of {1}", (long)doneSectors, (long)((trk.TrackEndSector - trk.TrackStartSector) + 1)); doneSectors += sectorsToRead; @@ -611,7 +608,7 @@ namespace Aaru.Core sector = image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors), xmlTrk.Sequence.TrackNumber); - UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors, + UpdateProgress2("Hashing sector {0} of {1}", (long)doneSectors, (long)((trk.TrackEndSector - trk.TrackStartSector) + 1)); doneSectors += sectors - doneSectors; @@ -689,7 +686,7 @@ namespace Aaru.Core sector = image.ReadSectorsTag(doneSectors, sectorsToRead, xmlTrk.Sequence.TrackNumber, SectorTagType.CdSectorSubchannel); - UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors, + UpdateProgress2("Hashing subchannel sector {0} of {1}", (long)doneSectors, (long)((trk.TrackEndSector - trk.TrackStartSector) + 1)); doneSectors += sectorsToRead; @@ -700,7 +697,7 @@ namespace Aaru.Core xmlTrk.Sequence.TrackNumber, SectorTagType.CdSectorSubchannel); - UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors, + UpdateProgress2("Hashing subchannel sector {0} of {1}", (long)doneSectors, (long)((trk.TrackEndSector - trk.TrackStartSector) + 1)); doneSectors += sectors - doneSectors; diff --git a/Aaru.Core/Statistics.cs b/Aaru.Core/Statistics.cs index df9aa29cf..37ca6fe98 100644 --- a/Aaru.Core/Statistics.cs +++ b/Aaru.Core/Statistics.cs @@ -720,21 +720,19 @@ namespace Aaru.Core { dto.OperatingSystems = new List(); - foreach(string osName in ctx. - OperatingSystems.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string osVersion in ctx. - OperatingSystems. - Where(c => !c.Synchronized && c.Name == osName). - Select(c => c.Version).Distinct()) + foreach(string osVersion in ctx.OperatingSystems. + Where(c => !c.Synchronized && c.Name == osName). + Select(c => c.Version).Distinct()) dto.OperatingSystems.Add(new OsStats { 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) }); } } @@ -743,22 +741,19 @@ namespace Aaru.Core { dto.RemoteApplications = new List(); - foreach(string remoteAppName in ctx. - RemoteApplications.Where(c => !c.Synchronized). - Select(c => c.Name).Distinct()) + foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string remoteAppVersion in ctx. - RemoteApplications. - Where(c => !c.Synchronized && - c.Name == remoteAppName). - Select(c => c.Version).Distinct()) + foreach(string remoteAppVersion in ctx.RemoteApplications. + Where(c => !c.Synchronized && + c.Name == remoteAppName). + Select(c => c.Version).Distinct()) dto.RemoteApplications.Add(new OsStats { - 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) }); } } @@ -780,21 +775,19 @@ namespace Aaru.Core { dto.RemoteOperatingSystems = new List(); - foreach(string remoteOsName in ctx. - RemoteOperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name).Distinct()) + foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string remoteOsVersion in ctx. - RemoteOperatingSystems. - Where(c => !c.Synchronized && c.Name == remoteOsName). - Select(c => c.Version).Distinct()) + foreach(string remoteOsVersion in ctx.RemoteOperatingSystems. + Where(c => !c.Synchronized && + c.Name == remoteOsName). + Select(c => c.Version).Distinct()) dto.RemoteOperatingSystems.Add(new OsStats { - name = remoteOsName, + name = remoteOsName, version = remoteOsVersion, - Value = ctx.RemoteOperatingSystems.LongCount(c => !c.Synchronized && - c.Name == remoteOsName && - c.Version == remoteOsVersion) + Value = ctx.RemoteOperatingSystems.LongCount(c => !c.Synchronized && + c.Name == remoteOsName && c.Version == remoteOsVersion) }); } } @@ -872,7 +865,7 @@ namespace Aaru.Core ctx.Filesystems.Update(existing); ctx.Filesystems.RemoveRange(ctx.Filesystems.Where(c => !c.Synchronized && - c.Name == nvs)); + c.Name == nvs)); } if(ctx.Filters.Any(c => !c.Synchronized)) @@ -909,7 +902,7 @@ namespace Aaru.Core ctx.MediaFormats.Update(existing); ctx.MediaFormats.RemoveRange(ctx.MediaFormats.Where(c => !c.Synchronized && - c.Name == nvs)); + c.Name == nvs)); } if(ctx.Partitions.Any(c => !c.Synchronized)) @@ -967,7 +960,7 @@ namespace Aaru.Core ctx.Medias.Update(existing); ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized && c.Type == media && - c.Real)); + c.Real)); } if(!ctx.Medias.Any(c => !c.Synchronized && c.Type == media && !c.Real)) @@ -989,7 +982,7 @@ namespace Aaru.Core ctx.Medias.Update(existing); ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized && c.Type == media && - !c.Real)); + !c.Real)); } } @@ -1001,18 +994,16 @@ namespace Aaru.Core } if(ctx.OperatingSystems.Any(c => !c.Synchronized)) - foreach(string osName in ctx. - OperatingSystems.Where(c => !c.Synchronized).Select(c => c.Name). - Distinct()) + foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string osVersion in ctx. - OperatingSystems. - Where(c => !c.Synchronized && c.Name == osName). - Select(c => c.Version).Distinct()) + foreach(string osVersion in ctx.OperatingSystems. + Where(c => !c.Synchronized && c.Name == osName). + Select(c => c.Version).Distinct()) { OperatingSystem existing = ctx.OperatingSystems.FirstOrDefault(c => c.Synchronized && c.Name == osName && - c.Version == osVersion) ?? + c.Version == osVersion) ?? new OperatingSystem { Synchronized = true, @@ -1021,34 +1012,31 @@ namespace Aaru.Core }; 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); - ctx.OperatingSystems.RemoveRange(ctx.OperatingSystems.Where(c => !c.Synchronized && - c.Name == osName && - c.Version == - osVersion)); + ctx.OperatingSystems.RemoveRange(ctx.OperatingSystems.Where(c => !c.Synchronized && + c.Name == osName && + c.Version == osVersion)); } } if(ctx.RemoteApplications.Any(c => !c.Synchronized)) - foreach(string remoteAppName in ctx. - RemoteApplications.Where(c => !c.Synchronized). - Select(c => c.Name).Distinct()) + foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string remoteAppVersion in ctx. - RemoteApplications. - Where(c => !c.Synchronized && - c.Name == remoteAppName). - Select(c => c.Version).Distinct()) + foreach(string remoteAppVersion in ctx.RemoteApplications. + Where(c => !c.Synchronized && + c.Name == remoteAppName). + Select(c => c.Version).Distinct()) { RemoteApplication existing = - ctx.RemoteApplications.FirstOrDefault(c => c.Synchronized && - c.Name == remoteAppName && - c.Version == remoteAppVersion) ?? + ctx.RemoteApplications.FirstOrDefault(c => c.Synchronized && + c.Name == remoteAppName && + c.Version == remoteAppVersion) ?? new RemoteApplication { Synchronized = true, @@ -1057,19 +1045,16 @@ namespace Aaru.Core }; existing.Count += - (ulong)ctx.RemoteApplications.LongCount(c => !c.Synchronized && - c.Name == remoteAppName && - c.Version == remoteAppVersion); + (ulong)ctx.RemoteApplications.LongCount(c => !c.Synchronized && + c.Name == remoteAppName && + c.Version == remoteAppVersion); ctx.RemoteApplications.Update(existing); ctx.RemoteApplications.RemoveRange(ctx.RemoteApplications.Where(c => - !c. - Synchronized && - c.Name == - remoteAppName && - c.Version == - remoteAppVersion)); + !c.Synchronized && + c.Name == remoteAppName && + c.Version == remoteAppVersion)); } } @@ -1094,19 +1079,17 @@ namespace Aaru.Core Where(c => !c.Synchronized && c.Name == nvs)); } - foreach(string remoteOsName in ctx. - RemoteOperatingSystems.Where(c => !c.Synchronized). - Select(c => c.Name).Distinct()) + foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized). + Select(c => c.Name).Distinct()) { - foreach(string remoteOsVersion in ctx. - RemoteOperatingSystems. - Where(c => !c.Synchronized && c.Name == remoteOsName). - Select(c => c.Version).Distinct()) + foreach(string remoteOsVersion in ctx.RemoteOperatingSystems. + Where(c => !c.Synchronized && c.Name == remoteOsName). + Select(c => c.Version).Distinct()) { RemoteOperatingSystem existing = - ctx.RemoteOperatingSystems.FirstOrDefault(c => c.Synchronized && - c.Name == remoteOsName && - c.Version == remoteOsVersion) ?? + ctx.RemoteOperatingSystems.FirstOrDefault(c => c.Synchronized && + c.Name == remoteOsName && + c.Version == remoteOsVersion) ?? new RemoteOperatingSystem { Synchronized = true, @@ -1115,19 +1098,16 @@ namespace Aaru.Core }; existing.Count += - (ulong)ctx.RemoteOperatingSystems.LongCount(c => !c.Synchronized && - c.Name == remoteOsName && - c.Version == remoteOsVersion); + (ulong)ctx.RemoteOperatingSystems.LongCount(c => !c.Synchronized && + c.Name == remoteOsName && + c.Version == remoteOsVersion); ctx.RemoteOperatingSystems.Update(existing); ctx.RemoteOperatingSystems.RemoveRange(ctx.RemoteOperatingSystems.Where(c => - !c. - Synchronized && - c.Name == - remoteOsName && - c.Version == - remoteOsVersion)); + !c.Synchronized && + c.Name == remoteOsName && + c.Version == remoteOsVersion)); } } diff --git a/Aaru.Database/Migrations/20181221032605_MediaStatistics.cs b/Aaru.Database/Migrations/20181221032605_MediaStatistics.cs index b8f738b25..bfa290829 100644 --- a/Aaru.Database/Migrations/20181221032605_MediaStatistics.cs +++ b/Aaru.Database/Migrations/20181221032605_MediaStatistics.cs @@ -5,37 +5,13 @@ namespace Aaru.Database.Migrations public partial class MediaStatistics : Migration { protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("Medias", table => - new - { - Id = - table. - Column - (). - Annotation("Sqlite:Autoincrement", - true), - Type = - table. - Column - (nullable - : true), - Real = - table. - Column - (), - Synchronized - = table. - Column - () - }, constraints - : table => table. - PrimaryKey("PK_Medias", - x => - x. - Id)); + new + { + Id = table.Column().Annotation("Sqlite:Autoincrement", true), + Type = table.Column(nullable: true), + Real = table.Column(), + Synchronized = table.Column() + }, constraints: table => table.PrimaryKey("PK_Medias", x => x.Id)); protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Medias"); } diff --git a/Aaru.Database/Migrations/20181221034941_SeenDevicesStatistics.cs b/Aaru.Database/Migrations/20181221034941_SeenDevicesStatistics.cs index 62ae25b39..60a760545 100644 --- a/Aaru.Database/Migrations/20181221034941_SeenDevicesStatistics.cs +++ b/Aaru.Database/Migrations/20181221034941_SeenDevicesStatistics.cs @@ -5,47 +5,15 @@ namespace Aaru.Database.Migrations public partial class SeenDevicesStatistics : Migration { protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("SeenDevices", - table => new - { - Id = table. - Column< - int - >(). - Annotation("Sqlite:Autoincrement", - true), - Manufacturer = - table. - Column - (nullable - : true), - Model = table. - Column< - string - >(nullable - : true), - Revision = - table. - Column - (nullable - : true), - Bus = table. - Column< - string - >(nullable - : true), - Synchronized = - table. - Column - () - }, constraints: - table => table. - PrimaryKey("PK_SeenDevices", - x => - x. - Id)); + table => new + { + Id = table.Column().Annotation("Sqlite:Autoincrement", true), + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Revision = table.Column(nullable: true), + Bus = table.Column(nullable: true), + Synchronized = table.Column() + }, constraints: table => table.PrimaryKey("PK_SeenDevices", x => x.Id)); protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("SeenDevices"); } diff --git a/Aaru.Database/Migrations/20181221041242_VersionStatistics.cs b/Aaru.Database/Migrations/20181221041242_VersionStatistics.cs index a3e72450e..264a07f0d 100644 --- a/Aaru.Database/Migrations/20181221041242_VersionStatistics.cs +++ b/Aaru.Database/Migrations/20181221041242_VersionStatistics.cs @@ -5,30 +5,12 @@ namespace Aaru.Database.Migrations public partial class VersionStatistics : Migration { protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("Versions", - table => new - { - Id = table. - Column< - int - >(). - Annotation("Sqlite:Autoincrement", - true), - Value = table. - Column< - string - >(nullable - : true), - Synchronized = - table. - Column - () - }, constraints: - table => table. - PrimaryKey("PK_Versions", - x => - x. - Id)); + table => new + { + Id = table.Column().Annotation("Sqlite:Autoincrement", true), + Value = table.Column(nullable: true), + Synchronized = table.Column() + }, constraints: table => table.PrimaryKey("PK_Versions", x => x.Id)); protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Versions"); } diff --git a/Aaru.Database/Migrations/20181225002740_AddCdOffsets.cs b/Aaru.Database/Migrations/20181225002740_AddCdOffsets.cs index a710e92d9..40933bf1d 100644 --- a/Aaru.Database/Migrations/20181225002740_AddCdOffsets.cs +++ b/Aaru.Database/Migrations/20181225002740_AddCdOffsets.cs @@ -6,56 +6,17 @@ namespace Aaru.Database.Migrations public partial class AddCdOffsets : Migration { protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("CdOffsets", - table => new - { - Manufacturer = - table. - Column - (nullable - : true), - Model = table. - Column< - string - >(nullable - : true), - Offset = - table. - Column - (), - Submissions = - table. - Column - (), - Agreement = - table. - Column - (), - Id = table. - Column< - int - >(). - Annotation("Sqlite:Autoincrement", - true), - AddedWhen = - table. - Column - (), - ModifiedWhen = - table. - Column - () - }, constraints: - table => table. - PrimaryKey("PK_CdOffsets", - x => - x. - Id)); + table => new + { + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Offset = table.Column(), + Submissions = table.Column(), + Agreement = table.Column(), + Id = table.Column().Annotation("Sqlite:Autoincrement", true), + AddedWhen = table.Column(), + ModifiedWhen = table.Column() + }, constraints: table => table.PrimaryKey("PK_CdOffsets", x => x.Id)); protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("CdOffsets"); } diff --git a/Aaru.Database/Migrations/AaruContextModelSnapshot.cs b/Aaru.Database/Migrations/AaruContextModelSnapshot.cs index 26c8257b5..fda5e6401 100644 --- a/Aaru.Database/Migrations/AaruContextModelSnapshot.cs +++ b/Aaru.Database/Migrations/AaruContextModelSnapshot.cs @@ -1760,17 +1760,22 @@ namespace Aaru.Database.Migrations b.ToTable("Versions"); }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). - HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull)); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", + b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). + HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). - HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade)); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", + b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). + HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null).WithMany("DensityCodes"). - HasForeignKey("SscSupportedMediaId").OnDelete(DeleteBehavior.Cascade)); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", + b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null). + WithMany("DensityCodes").HasForeignKey("SscSupportedMediaId"). + OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().HasForeignKey("FeaturesId"). - OnDelete(DeleteBehavior.SetNull)); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", + b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany(). + HasForeignKey("FeaturesId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b => { @@ -1832,8 +1837,9 @@ namespace Aaru.Database.Migrations OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia").HasForeignKey("SscId"). - OnDelete(DeleteBehavior.SetNull)); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", + b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia"). + HasForeignKey("SscId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.Database.Models.Device", b => { @@ -1895,8 +1901,9 @@ namespace Aaru.Database.Migrations OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.Database.Models.UsbProduct", b => b.HasOne("Aaru.Database.Models.UsbVendor", "Vendor").WithMany("Products").HasForeignKey("VendorId"). - OnDelete(DeleteBehavior.Cascade).IsRequired()); + modelBuilder.Entity("Aaru.Database.Models.UsbProduct", + b => b.HasOne("Aaru.Database.Models.UsbVendor", "Vendor").WithMany("Products"). + HasForeignKey("VendorId").OnDelete(DeleteBehavior.Cascade).IsRequired()); #pragma warning restore 612, 618 } } diff --git a/Aaru.Decoders b/Aaru.Decoders index 3c540f41b..a1870c543 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit 3c540f41b0fa586b876325cdde84ed2f5fedf39f +Subproject commit a1870c5437266a4130aecf14894d9784be0114e0 diff --git a/Aaru.Devices/Command.cs b/Aaru.Devices/Command.cs index d01bd81d2..eeaafeea4 100644 --- a/Aaru.Devices/Command.cs +++ b/Aaru.Devices/Command.cs @@ -38,6 +38,8 @@ 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 diff --git a/Aaru.Devices/Enums.cs b/Aaru.Devices/Enums.cs index 54d31473c..4367b0ab8 100644 --- a/Aaru.Devices/Enums.cs +++ b/Aaru.Devices/Enums.cs @@ -32,6 +32,9 @@ using System; +// ReSharper disable UnusedType.Global + +// ReSharper disable UnusedMember.Global // ReSharper disable MemberCanBeInternal // ReSharper disable InconsistentNaming @@ -282,7 +285,7 @@ namespace Aaru.Devices /// Enables usage of command SecurityErasePrepare = 0xF3, - /// Erases all user data and isables the security lock + /// Erases all user data and disables the security lock SecurityEraseUnit = 0xF4, /// Sets the security freeze lock preventing any security command from working until hardware reset @@ -367,7 +370,7 @@ namespace Aaru.Devices CheckMediaCardType = 0xD1, /// Device Configuration Overlay feature set - DevideConfiguration = 0xB1, + DeviceConfiguration = 0xB1, /// Requests the device to flush the write cache and write it to the media (48-bit) FlushCacheExt = 0xEA, @@ -416,19 +419,19 @@ namespace Aaru.Devices #endregion Commands defined on ATA/ATAPI-6 rev. 3b #region Commands defined on ATA/ATAPI-7 rev. 4b - /// Configurates the operating parameters for a stream + /// Configures the operating parameters for a stream ConfigureStream = 0x51, - /// Reads data on an alloted time using DMA + /// Reads data on an allotted time using DMA ReadStreamDmaExt = 0x2A, - /// Reads data on an alloted time using PIO + /// Reads data on an allotted time using PIO ReadStreamExt = 0x2B, - /// Writes data on an alloted time using DMA + /// Writes data on an allotted time using DMA WriteStreamDmaExt = 0x3A, - /// Writes data on an alloted time using PIO + /// Writes data on an allotted time using PIO WriteStreamExt = 0x3B, #endregion Commands defined on ATA/ATAPI-7 rev. 4b @@ -731,7 +734,7 @@ namespace Aaru.Devices /// Writes a File Mark on the device. SASI rev. 0c WriteFileMark = 0x0F, - /// Reserves the device for use by the iniator. SASI rev. 0a + /// Reserves the device for use by the initiator. SASI rev. 0a ReserveUnitOld = 0x12, /// Gets information about a device ANSI X3T9.3 No. 185 (SASI) @@ -758,7 +761,7 @@ namespace Aaru.Devices /// Gets the number of blocks in device. SASI rev. 0c ReadCapacityOld = 0x16, - /// Reserves the device for use by the iniator. ANSI X3T9.3 No. 185 (SASI) + /// Reserves the device for use by the initiator. ANSI X3T9.3 No. 185 (SASI) ReserveUnit = 0x16, /// Release the device from the reservation. ANSI X3T9.3 No. 185 (SASI) @@ -979,7 +982,7 @@ namespace Aaru.Devices /// Commands used to limit or grant access to LUNs SPC-4 rev. 16 AccessControlOut = 0x87, - /// Modifies the operating definition of the device with respect to commmands. SCSI-2 X3T9.2/375R rev. 10l + /// Modifies the operating definition of the device with respect to commands. SCSI-2 X3T9.2/375R rev. 10l ChangeDefinition = 0x40, /// Compares data between two devices ECMA-111 (SCSI-1) @@ -1213,7 +1216,7 @@ namespace Aaru.Devices /// Writes a single block several times SBC-2 rev. 4 WriteSame16 = 0x93, - /// Requets XOR data generated by an or command SBC-1 rev. 8c + /// Requests XOR data generated by an or command SBC-1 rev. 8c XdRead = 0x52, /// @@ -1228,7 +1231,7 @@ namespace Aaru.Devices /// XdWrite16 = 0x80, - /// Requets the target to XOR the sent data with the data on the medium and return the results + /// Requests the target to XOR the sent data with the data on the medium and return the results XdWriteRead = 0x53, /// @@ -1341,7 +1344,7 @@ namespace Aaru.Devices /// Requests the LUN to report events and statuses MMC-2 rev. 11a GetEventStatusNotification = 0x4A, - /// Provides a mehotd to profile the performance of the drive MMC-2 rev. 11a + /// Provides a method to profile the performance of the drive MMC-2 rev. 11a GetPerformance = 0xAC, /// Requests the device changer to load or unload a disc MMC-1 rev. 9 @@ -1386,7 +1389,7 @@ namespace Aaru.Devices /// Returns the recorded size of the CD MMC-1 rev. 9 ReadCdRecordedCapacity = 0x25, - /// Gets informationn about all discs: CD-ROM, CD-R and CD-RW MMC-1 rev. 9 + /// Gets information about all discs: CD-ROM, CD-R and CD-RW MMC-1 rev. 9 ReadDiscInformation = 0x51, /// Reads areas from the DVD or BD media MMC-5 rev. 2c @@ -1492,7 +1495,7 @@ namespace Aaru.Devices /// Erases the specified number of blocks Erase12 = 0xAC, - /// Searches the medium for a contiguos set of written or blank blocks + /// Searches the medium for a contiguous set of written or blank blocks MediumScan = 0x38, /// Reads blocks from device SCSI-2 X3T9.2/375R rev. 10l @@ -1501,7 +1504,7 @@ namespace Aaru.Devices /// Gets medium's defect data SCSI-2 X3T9.2/375R rev. 10l ReadDefectData12 = 0xB7, - /// Gets the maxium generation address for the specified block + /// Gets the maximum generation address for the specified block ReadGeneration = 0x29, /// Reads a specified generation of a specified block @@ -1870,7 +1873,7 @@ namespace Aaru.Devices /// Requests a device soft reset (COMRESET issue) SoftReset = 1, - /// No data is to be transfered + /// No data is to be transferred NonData = 3, /// Requests a device->host transfer using PIO @@ -1888,7 +1891,7 @@ namespace Aaru.Devices /// Requests device diagnostics DeviceDiagnostic = 8, - /// Requets device reset + /// Requests device reset DeviceReset = 9, /// Requests a device->host transfer using UltraDMA @@ -1904,7 +1907,7 @@ namespace Aaru.Devices ReturnResponse = 15 } - /// Indicates the STL which ATA register contains the length of data to be transfered + /// Indicates the STL which ATA register contains the length of data to be transferred public enum AtaTransferRegister : byte { /// There is no transfer @@ -2295,13 +2298,13 @@ namespace Aaru.Devices /// Plextor GigaRec GigaRec = 0x04, - /// Plextor accoustic management (disc related) + /// Plextor acoustic management (disc related) SilentDisc = 0x06, - /// Plextor accoustic management (tra related) + /// Plextor acoustic management (tra related) SilentTray = 0x07, - /// Plextor accoustic management + /// Plextor acoustic management Silent = 0x08, /// Plextor test write DVD+ @@ -2525,7 +2528,7 @@ namespace Aaru.Devices /// Writes a block (ADTC, R1) WriteBlock = 24, - /// Continuosly writes blocks until interrupted (ADTC, R1) + /// Continuously writes blocks until interrupted (ADTC, R1) WriteMultipleBlock = 25, /// Programs the Card Information register (ADTC, R1) @@ -2621,7 +2624,7 @@ namespace Aaru.Devices #endregion Class 1 SecureDigital Commands (Basic) #region Class 2 SecureDigital Commands (Block-oriented read) - /// 64 bytes of tuning pattern is sent for SDR50 and SDR104 optinal sampling point detection (ADTC, R1) + /// 64 bytes of tuning pattern is sent for SDR50 and SDR104 optimal sampling point detection (ADTC, R1) SendTuningBlock = 19, /// Speed class control command (AC, R1b) @@ -2676,9 +2679,9 @@ namespace Aaru.Devices 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, + ResponseR1 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR1B = ResponsePresent | ResponseCrc | ResponseOpcode | ResponseBusy, - ResponseR2 = ResponsePresent | Response136 | ResponseCrc, ResponseR3 = ResponsePresent, + ResponseR2 = ResponsePresent | Response136 | ResponseCrc, ResponseR3 = ResponsePresent, ResponseR4 = ResponsePresent, ResponseR5 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR6 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseR7 = ResponsePresent | ResponseCrc | ResponseOpcode, ResponseSpiR1 = ResponseSpiS1, diff --git a/Aaru.Devices/Remote/Remote.cs b/Aaru.Devices/Remote/Remote.cs index 0e738ee9f..9c2722d56 100644 --- a/Aaru.Devices/Remote/Remote.cs +++ b/Aaru.Devices/Remote/Remote.cs @@ -1392,18 +1392,17 @@ namespace Aaru.Devices.Remote static int Receive(Socket socket, byte[] buffer, int size, SocketFlags socketFlags) { - int gotten; int offset = 0; while(size > 0) { - gotten = socket.Receive(buffer, offset, size, socketFlags); + int got = socket.Receive(buffer, offset, size, socketFlags); - if(gotten <= 0) + if(got <= 0) break; - offset += gotten; - size -= gotten; + offset += got; + size -= got; } return offset; diff --git a/Aaru.Devices/Remote/Structs.cs b/Aaru.Devices/Remote/Structs.cs index 33344f34f..59bc0b231 100644 --- a/Aaru.Devices/Remote/Structs.cs +++ b/Aaru.Devices/Remote/Structs.cs @@ -83,7 +83,7 @@ namespace Aaru.Devices.Remote } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] - public struct AaruPacketResponseListDevices + public readonly struct AaruPacketResponseListDevices { public readonly AaruPacketHeader hdr; public readonly ushort devices; diff --git a/Aaru.Devices/Windows/Enums.cs b/Aaru.Devices/Windows/Enums.cs index cbd30877f..d15508ecc 100644 --- a/Aaru.Devices/Windows/Enums.cs +++ b/Aaru.Devices/Windows/Enums.cs @@ -34,6 +34,8 @@ using System; using System.Diagnostics.CodeAnalysis; +// ReSharper disable UnusedMember.Global + namespace Aaru.Devices.Windows { [Flags] diff --git a/Aaru.Devices/Windows/ListDevices.cs b/Aaru.Devices/Windows/ListDevices.cs index cf37d6a3e..5752e80a6 100644 --- a/Aaru.Devices/Windows/ListDevices.cs +++ b/Aaru.Devices/Windows/ListDevices.cs @@ -182,7 +182,8 @@ namespace Aaru.Devices.Windows info.Serial = HexStringToString(info.Serial).Trim(); } - if(string.IsNullOrEmpty(info.Vendor) || info.Vendor == "ATA") + if(string.IsNullOrEmpty(info.Vendor) || + info.Vendor == "ATA") { string[] pieces = info.Model?.Split(' '); diff --git a/Aaru.Devices/Windows/Usb.cs b/Aaru.Devices/Windows/Usb.cs index 05e399ca9..0635d2ac9 100644 --- a/Aaru.Devices/Windows/Usb.cs +++ b/Aaru.Devices/Windows/Usb.cs @@ -41,7 +41,7 @@ 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 accesing information from the USB bus + /// Implements functions for getting and accessing information from the USB bus [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] internal static partial class Usb { @@ -680,9 +680,7 @@ namespace Aaru.Devices.Windows nBytes, out nBytesReturned, IntPtr.Zero)) { driverKey = (UsbNodeConnectionDriverkeyName)Marshal.PtrToStructure(ptrDriverKey, - typeof( - UsbNodeConnectionDriverkeyName - )); + typeof(UsbNodeConnectionDriverkeyName)); device.DeviceDriverKey = driverKey.DriverKeyName; diff --git a/Aaru.Devices/Windows/UsbFunctions.cs b/Aaru.Devices/Windows/UsbFunctions.cs index 3cc8d9842..a5260c8a8 100644 --- a/Aaru.Devices/Windows/UsbFunctions.cs +++ b/Aaru.Devices/Windows/UsbFunctions.cs @@ -42,7 +42,7 @@ namespace Aaru.Devices.Windows // 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 accesing information from the USB bus + /// Implements functions for getting and accessing information from the USB bus internal static partial class Usb { const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080; @@ -313,7 +313,7 @@ namespace Aaru.Devices.Windows } [StructLayout(LayoutKind.Sequential)] - struct StorageDeviceNumber + readonly struct StorageDeviceNumber { internal readonly int DeviceType; internal readonly int DeviceNumber; diff --git a/Aaru.Filesystems/AODOS.cs b/Aaru.Filesystems/AODOS.cs index 9c7674e81..5a58620ff 100644 --- a/Aaru.Filesystems/AODOS.cs +++ b/Aaru.Filesystems/AODOS.cs @@ -111,7 +111,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootBlock + readonly struct BootBlock { /// A NOP opcode public readonly byte nop; diff --git a/Aaru.Filesystems/APFS.cs b/Aaru.Filesystems/APFS.cs index 1bee676a8..47f951fff 100644 --- a/Aaru.Filesystems/APFS.cs +++ b/Aaru.Filesystems/APFS.cs @@ -118,7 +118,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ContainerSuperBlock + readonly struct ContainerSuperBlock { public readonly ulong unknown1; // Varies between copies of the superblock public readonly ulong unknown2; diff --git a/Aaru.Filesystems/Acorn.cs b/Aaru.Filesystems/Acorn.cs index 0c7ab5c35..2edee0562 100644 --- a/Aaru.Filesystems/Acorn.cs +++ b/Aaru.Filesystems/Acorn.cs @@ -621,7 +621,7 @@ namespace Aaru.Filesystems /// Boot block, used in hard disks and ADFS-F and higher. [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootBlock + readonly struct BootBlock { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1C0)] public readonly byte[] spare; @@ -633,7 +633,7 @@ namespace Aaru.Filesystems /// Disc record, used in hard disks and ADFS-E and higher. [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DiscRecord + readonly struct DiscRecord { public readonly byte log2secsize; public readonly byte spt; @@ -663,7 +663,7 @@ namespace Aaru.Filesystems /// Free block map, sector 0, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OldMapSector0 + readonly struct OldMapSector0 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] public readonly byte[] freeStart; @@ -677,7 +677,7 @@ namespace Aaru.Filesystems /// Free block map, sector 1, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OldMapSector1 + readonly struct OldMapSector1 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] public readonly byte[] freeStart; @@ -691,7 +691,7 @@ namespace Aaru.Filesystems /// Free block map, sector 0, used in ADFS-E [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NewMap + readonly struct NewMap { public readonly byte zoneChecksum; public readonly ushort freeLink; @@ -701,7 +701,7 @@ namespace Aaru.Filesystems /// Directory header, common to "old" and "new" directories [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryHeader + readonly struct DirectoryHeader { public readonly byte masterSequence; public readonly uint magic; @@ -709,7 +709,7 @@ namespace Aaru.Filesystems /// Directory header, common to "old" and "new" directories [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public readonly byte[] name; @@ -723,7 +723,7 @@ namespace Aaru.Filesystems /// Directory tail, new format [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NewDirectoryTail + readonly struct NewDirectoryTail { public readonly byte lastMark; public readonly ushort reserved; @@ -740,7 +740,7 @@ namespace Aaru.Filesystems /// Directory tail, old format [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OldDirectoryTail + readonly struct OldDirectoryTail { public readonly byte lastMark; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] @@ -758,7 +758,7 @@ namespace Aaru.Filesystems /// Directory, old format [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OldDirectory + readonly struct OldDirectory { public readonly DirectoryHeader header; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 47)] @@ -768,7 +768,7 @@ namespace Aaru.Filesystems /// Directory, new format [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NewDirectory + readonly struct NewDirectory { public readonly DirectoryHeader header; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 77)] diff --git a/Aaru.Filesystems/AppleCommon/Structs.cs b/Aaru.Filesystems/AppleCommon/Structs.cs index dc741c20b..4eef6e09a 100644 --- a/Aaru.Filesystems/AppleCommon/Structs.cs +++ b/Aaru.Filesystems/AppleCommon/Structs.cs @@ -42,7 +42,7 @@ namespace Aaru.Filesystems { /// Should be sectors 0 and 1 in volume, followed by boot code [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootBlock // Should be sectors 0 and 1 in volume + readonly struct BootBlock // Should be sectors 0 and 1 in volume { /// 0x000, Signature, 0x4C4B if bootable public readonly ushort bbID; diff --git a/Aaru.Filesystems/AppleDOS/Structs.cs b/Aaru.Filesystems/AppleDOS/Structs.cs index b7cb9595b..5c80db1be 100644 --- a/Aaru.Filesystems/AppleDOS/Structs.cs +++ b/Aaru.Filesystems/AppleDOS/Structs.cs @@ -37,7 +37,7 @@ namespace Aaru.Filesystems public sealed partial class AppleDOS { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Vtoc + readonly struct Vtoc { public readonly byte unused1; public readonly byte catalogTrack; @@ -63,7 +63,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CatalogSector + readonly struct CatalogSector { public readonly byte unused1; public readonly byte trackOfNext; @@ -75,7 +75,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FileEntry + readonly struct FileEntry { public readonly byte extentTrack; public readonly byte extentSector; @@ -86,7 +86,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TrackSectorList + readonly struct TrackSectorList { public readonly byte unused1; public readonly byte nextListTrack; @@ -101,7 +101,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TrackSectorListEntry + readonly struct TrackSectorListEntry { public readonly byte track; public readonly byte sector; diff --git a/Aaru.Filesystems/AppleHFS/Enums.cs b/Aaru.Filesystems/AppleHFS/Enums.cs index c8760ee9c..9b5671663 100644 --- a/Aaru.Filesystems/AppleHFS/Enums.cs +++ b/Aaru.Filesystems/AppleHFS/Enums.cs @@ -33,6 +33,7 @@ // ReSharper disable InconsistentNaming // ReSharper disable UnusedMember.Local + namespace Aaru.Filesystems { public sealed partial class AppleHFS diff --git a/Aaru.Filesystems/AppleHFS/Structs.cs b/Aaru.Filesystems/AppleHFS/Structs.cs index aacd1bbbf..ecd2a336d 100644 --- a/Aaru.Filesystems/AppleHFS/Structs.cs +++ b/Aaru.Filesystems/AppleHFS/Structs.cs @@ -45,7 +45,7 @@ namespace Aaru.Filesystems { /// Master Directory Block, should be sector 2 in volume [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MasterDirectoryBlock // Should be sector 2 in volume + readonly struct MasterDirectoryBlock // Should be sector 2 in volume { /// 0x000, Signature, 0x4244 public readonly ushort drSigWord; @@ -133,7 +133,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NodeDescriptor + readonly struct NodeDescriptor { /// A link to the next node of this type, or null if this is the last one. public readonly uint ndFLink; @@ -151,7 +151,7 @@ namespace Aaru.Filesystems /// B*-tree header [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BTHdrRed + readonly struct BTHdrRed { /// Current depth of tree. public readonly ushort bthDepth; @@ -178,7 +178,7 @@ namespace Aaru.Filesystems /// Catalog key record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CatKeyRec + readonly struct CatKeyRec { /// Key length. public readonly sbyte ckrKeyLen; @@ -193,7 +193,7 @@ namespace Aaru.Filesystems /// Catalog data record header [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CatDataRec + readonly struct CatDataRec { public readonly CatDataType cdrType; public readonly sbyte cdrResvr2; @@ -201,7 +201,7 @@ namespace Aaru.Filesystems /// Directory record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdrDirRec + readonly struct CdrDirRec { public readonly CatDataRec dirHdr; /// Directory flags. @@ -227,7 +227,7 @@ namespace Aaru.Filesystems /// File record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdrFilRec + readonly struct CdrFilRec { public readonly CatDataRec filHdr; /// File flags. @@ -270,7 +270,7 @@ namespace Aaru.Filesystems /// Directory thread record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdrThdRec + readonly struct CdrThdRec { public readonly CatDataRec thdHdr; /// Reserved. @@ -285,7 +285,7 @@ namespace Aaru.Filesystems /// File thread record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdrFThdRec + readonly struct CdrFThdRec { public readonly CatDataRec fthdHdr; /// Reserved. @@ -300,7 +300,7 @@ namespace Aaru.Filesystems /// Extent descriptor [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtDescriptor + readonly struct ExtDescriptor { /// First allocation block public readonly ushort xdrStABN; @@ -310,7 +310,7 @@ namespace Aaru.Filesystems /// Extent data record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtDataRec + readonly struct ExtDataRec { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public readonly ExtDescriptor[] xdr; @@ -318,7 +318,7 @@ namespace Aaru.Filesystems /// Extent key record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtKeyRec + readonly struct ExtKeyRec { /// Key length. public readonly sbyte xkrKeyLen; diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index 6f5e153cd..6e821244d 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -105,8 +105,8 @@ namespace Aaru.Filesystems entry.flNam = new byte[_directoryBlocks[offset + 50] + 1]; Array.Copy(_directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length); - string lowerFilename = StringHandlers. - PascalToString(entry.flNam, Encoding).ToLowerInvariant().Replace('/', ':'); + string lowerFilename = StringHandlers.PascalToString(entry.flNam, Encoding).ToLowerInvariant(). + Replace('/', ':'); if(entry.flFlags.HasFlag(FileFlags.Used) && !_idToFilename.ContainsKey(entry.flFlNum) && diff --git a/Aaru.Filesystems/AtheOS.cs b/Aaru.Filesystems/AtheOS.cs index 4e22bdbbf..eef214ce2 100644 --- a/Aaru.Filesystems/AtheOS.cs +++ b/Aaru.Filesystems/AtheOS.cs @@ -168,7 +168,7 @@ namespace Aaru.Filesystems /// Be superblock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// 0x000, Volume name, 32 bytes [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] diff --git a/Aaru.Filesystems/BTRFS.cs b/Aaru.Filesystems/BTRFS.cs index be34bbfaa..55bcd04a2 100644 --- a/Aaru.Filesystems/BTRFS.cs +++ b/Aaru.Filesystems/BTRFS.cs @@ -201,7 +201,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)] public readonly byte[] checksum; @@ -243,7 +243,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DevItem + readonly struct DevItem { public readonly ulong id; public readonly ulong bytes; diff --git a/Aaru.Filesystems/CBM.cs b/Aaru.Filesystems/CBM.cs index ee2d1adcd..6df3577d7 100644 --- a/Aaru.Filesystems/CBM.cs +++ b/Aaru.Filesystems/CBM.cs @@ -170,7 +170,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BAM + readonly struct BAM { /// Track where directory starts public readonly byte directoryTrack; @@ -213,7 +213,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Header + readonly struct Header { /// Track where directory starts public readonly byte directoryTrack; diff --git a/Aaru.Filesystems/CPM/Structs.cs b/Aaru.Filesystems/CPM/Structs.cs index 90eeb88e4..a359c8f0a 100644 --- a/Aaru.Filesystems/CPM/Structs.cs +++ b/Aaru.Filesystems/CPM/Structs.cs @@ -69,7 +69,7 @@ namespace Aaru.Filesystems /// Amstrad superblock, for PCW [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AmstradSuperBlock + readonly struct AmstradSuperBlock { /// Format ID. 0 single-side, 3 double-side. 1 and 2 are for CPC but they don't use the superblock public readonly byte format; @@ -107,7 +107,7 @@ namespace Aaru.Filesystems /// Superblock found on CP/M-86 hard disk volumes [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HardDiskSuperBlock + readonly struct HardDiskSuperBlock { /// Value so the sum of all the superblock's sector bytes taken as 16-bit values gives 0 public readonly ushort checksum; @@ -186,7 +186,7 @@ namespace Aaru.Filesystems /// Volume label entry [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LabelEntry + readonly struct LabelEntry { /// Must be 0x20 public readonly byte signature; @@ -215,7 +215,7 @@ namespace Aaru.Filesystems /// CP/M 3 timestamp entry [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DateEntry + readonly struct DateEntry { /// Must be 0x21 public readonly byte signature; @@ -250,7 +250,7 @@ namespace Aaru.Filesystems /// Password entry [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PasswordEntry + readonly struct PasswordEntry { /// 16 + user number public readonly byte userNumber; @@ -275,7 +275,7 @@ namespace Aaru.Filesystems /// Timestamp for Z80DOS or DOS+ [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TrdPartyDateEntry + readonly struct TrdPartyDateEntry { /// Must be 0x21 public readonly byte signature; @@ -311,7 +311,7 @@ namespace Aaru.Filesystems /// Directory entry for <256 allocation blocks [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { /// User number. Bit 7 set in CP/M 1 means hidden public readonly byte statusUser; @@ -339,7 +339,7 @@ namespace Aaru.Filesystems /// Directory entry for >256 allocation blocks [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry16 + readonly struct DirectoryEntry16 { /// User number. Bit 7 set in CP/M 1 means hidden public readonly byte statusUser; diff --git a/Aaru.Filesystems/Cram.cs b/Aaru.Filesystems/Cram.cs index 8836c1c8d..78b56181c 100644 --- a/Aaru.Filesystems/Cram.cs +++ b/Aaru.Filesystems/Cram.cs @@ -123,7 +123,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { public readonly uint magic; public readonly uint size; diff --git a/Aaru.Filesystems/ECMA67.cs b/Aaru.Filesystems/ECMA67.cs index 71216579c..1a258c7ea 100644 --- a/Aaru.Filesystems/ECMA67.cs +++ b/Aaru.Filesystems/ECMA67.cs @@ -99,7 +99,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VolumeLabel + readonly struct VolumeLabel { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public readonly byte[] labelIdentifier; diff --git a/Aaru.Filesystems/EFS.cs b/Aaru.Filesystems/EFS.cs index d4de612f1..000666a40 100644 --- a/Aaru.Filesystems/EFS.cs +++ b/Aaru.Filesystems/EFS.cs @@ -219,7 +219,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct Superblock + readonly struct Superblock { /* 0: fs size incl. bb 0 (in bb) */ public readonly int sb_size; diff --git a/Aaru.Filesystems/F2FS.cs b/Aaru.Filesystems/F2FS.cs index c7affedc6..949140880 100644 --- a/Aaru.Filesystems/F2FS.cs +++ b/Aaru.Filesystems/F2FS.cs @@ -158,7 +158,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct Superblock + readonly struct Superblock { public readonly uint magic; public readonly ushort major_ver; diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 5669170e0..94069d231 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -514,100 +514,97 @@ namespace Aaru.Filesystems break; case 0xFE: - if(imagePlugin.Info.Sectors == 320 && - imagePlugin.Info.SectorSize == 512) + switch(imagePlugin.Info.Sectors) { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" SSDD."); - fakeBpb.bps = 512; - fakeBpb.spc = 1; - fakeBpb.rsectors = 1; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 64; - fakeBpb.sectors = 320; - fakeBpb.media = 0xFE; - fakeBpb.sptrk = 8; - fakeBpb.heads = 1; - fakeBpb.hsectors = 0; - fakeBpb.spfat = 1; - } - else if(imagePlugin.Info.Sectors == 2002 && - imagePlugin.Info.SectorSize == 128) - { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); - fakeBpb.bps = 128; - fakeBpb.spc = 4; - fakeBpb.rsectors = 1; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 68; - fakeBpb.sectors = 2002; - fakeBpb.media = 0xFE; - fakeBpb.sptrk = 26; - fakeBpb.heads = 1; - fakeBpb.hsectors = 0; - fakeBpb.spfat = 6; - } - else if(imagePlugin.Info.Sectors == 1232 && - imagePlugin.Info.SectorSize == 1024) - { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); - fakeBpb.bps = 1024; - fakeBpb.spc = 1; - fakeBpb.rsectors = 1; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 192; - fakeBpb.sectors = 1232; - fakeBpb.media = 0xFE; - fakeBpb.sptrk = 8; - fakeBpb.heads = 2; - fakeBpb.hsectors = 0; - fakeBpb.spfat = 2; - } - else if(imagePlugin.Info.Sectors == 616 && - imagePlugin.Info.SectorSize == 1024) - { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); - fakeBpb.bps = 1024; - fakeBpb.spc = 1; - fakeBpb.rsectors = 1; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 6192; - fakeBpb.sectors = 616; - fakeBpb.media = 0xFE; - fakeBpb.sptrk = 8; - fakeBpb.heads = 2; - fakeBpb.hsectors = 0; - } - else if(imagePlugin.Info.Sectors == 720 && - imagePlugin.Info.SectorSize == 128) - { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); - fakeBpb.bps = 128; - fakeBpb.spc = 2; - fakeBpb.rsectors = 54; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 64; - fakeBpb.sectors = 720; - fakeBpb.media = 0xFE; - fakeBpb.sptrk = 18; - fakeBpb.heads = 1; - fakeBpb.hsectors = 0; - fakeBpb.spfat = 4; - } - else if(imagePlugin.Info.Sectors == 640 && - imagePlugin.Info.SectorSize == 512) - { - AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" DSDD."); - fakeBpb.bps = 512; - fakeBpb.spc = 2; - fakeBpb.rsectors = 1; - fakeBpb.fats_no = 2; - fakeBpb.root_ent = 112; - fakeBpb.sectors = 640; - fakeBpb.media = 0xFF; - fakeBpb.sptrk = 8; - fakeBpb.heads = 2; - fakeBpb.hsectors = 0; - fakeBpb.spfat = 1; + case 320 when imagePlugin.Info.SectorSize == 512: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" SSDD."); + fakeBpb.bps = 512; + fakeBpb.spc = 1; + fakeBpb.rsectors = 1; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 64; + fakeBpb.sectors = 320; + fakeBpb.media = 0xFE; + fakeBpb.sptrk = 8; + fakeBpb.heads = 1; + fakeBpb.hsectors = 0; + fakeBpb.spfat = 1; + + break; + case 2002 when imagePlugin.Info.SectorSize == 128: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); + fakeBpb.bps = 128; + fakeBpb.spc = 4; + fakeBpb.rsectors = 1; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 68; + fakeBpb.sectors = 2002; + fakeBpb.media = 0xFE; + fakeBpb.sptrk = 26; + fakeBpb.heads = 1; + fakeBpb.hsectors = 0; + fakeBpb.spfat = 6; + + break; + case 1232 when imagePlugin.Info.SectorSize == 1024: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); + fakeBpb.bps = 1024; + fakeBpb.spc = 1; + fakeBpb.rsectors = 1; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 192; + fakeBpb.sectors = 1232; + fakeBpb.media = 0xFE; + fakeBpb.sptrk = 8; + fakeBpb.heads = 2; + fakeBpb.hsectors = 0; + fakeBpb.spfat = 2; + + break; + case 616 when imagePlugin.Info.SectorSize == 1024: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); + fakeBpb.bps = 1024; + fakeBpb.spc = 1; + fakeBpb.rsectors = 1; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 6192; + fakeBpb.sectors = 616; + fakeBpb.media = 0xFE; + fakeBpb.sptrk = 8; + fakeBpb.heads = 2; + fakeBpb.hsectors = 0; + + break; + case 720 when imagePlugin.Info.SectorSize == 128: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB."); + fakeBpb.bps = 128; + fakeBpb.spc = 2; + fakeBpb.rsectors = 54; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 64; + fakeBpb.sectors = 720; + fakeBpb.media = 0xFE; + fakeBpb.sptrk = 18; + fakeBpb.heads = 1; + fakeBpb.hsectors = 0; + fakeBpb.spfat = 4; + + break; + case 640 when imagePlugin.Info.SectorSize == 512: + AaruConsole.DebugWriteLine("FAT plugin", "Using hardcoded BPB for 5.25\" DSDD."); + fakeBpb.bps = 512; + fakeBpb.spc = 2; + fakeBpb.rsectors = 1; + fakeBpb.fats_no = 2; + fakeBpb.root_ent = 112; + fakeBpb.sectors = 640; + fakeBpb.media = 0xFF; + fakeBpb.sptrk = 8; + fakeBpb.heads = 2; + fakeBpb.hsectors = 0; + fakeBpb.spfat = 1; + + break; } break; diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index c69991e0c..3536b639c 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -142,7 +142,7 @@ namespace Aaru.Filesystems { DirectoryEntry dirent = Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, - Marshal.SizeOf()); + Marshal.SizeOf()); if(dirent.filename[0] == DIRENT_FINISHED) break; @@ -249,9 +249,7 @@ namespace Aaru.Filesystems { HumanDirectoryEntry humanEntry = Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, - Marshal. - SizeOf()); + Marshal.SizeOf()); completeEntry.HumanDirent = humanEntry; @@ -322,12 +320,7 @@ namespace Aaru.Filesystems if(_fat32 || _debug) { List> fat32EaSidecars = currentDirectory. - Where(t => - t.Key. - EndsWith(FAT32_EA_TAIL, - true, - _cultureInfo)). - ToList(); + Where(t => t.Key.EndsWith(FAT32_EA_TAIL, true, _cultureInfo)).ToList(); foreach(KeyValuePair sidecar in fat32EaSidecars) { diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index ccbda41e1..b03a6f3a6 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -796,7 +796,7 @@ namespace Aaru.Filesystems /// FAT32 FS Information Sector [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FsInfoSector + readonly struct FsInfoSector { /// Signature must be public readonly uint signature1; @@ -818,7 +818,7 @@ namespace Aaru.Filesystems /// Human68k Parameter Block, big endian, 512 bytes even on 256 bytes/sector. [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HumanParameterBlock + readonly struct HumanParameterBlock { /// 68k bra.S [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] @@ -850,7 +850,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public readonly byte[] filename; @@ -870,7 +870,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HumanDirectoryEntry + readonly struct HumanDirectoryEntry { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public readonly byte[] name1; @@ -886,7 +886,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LfnEntry + readonly struct LfnEntry { public readonly byte sequence; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] @@ -902,7 +902,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct EaHeader + readonly struct EaHeader { public readonly ushort magic; public readonly ushort cluster; @@ -915,7 +915,7 @@ namespace Aaru.Filesystems /// This structure is 256 bytes large, depending on the name, only part of it is written to disk [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct UmsdosDirectoryEntry + readonly struct UmsdosDirectoryEntry { /// if == 0, then this entry is not used public readonly byte name_len; diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index f8b468b6c..6fc694e89 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -133,7 +133,10 @@ namespace Aaru.Filesystems var eaMs = new MemoryStream(); uint[] rootDirectoryClusters = GetClusters(entryFat32Ea.start_cluster); - foreach(var buffer in rootDirectoryClusters.Select(cluster => _image.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), _sectorsPerCluster))) + foreach(byte[] buffer in rootDirectoryClusters.Select(cluster => + _image. + ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), + _sectorsPerCluster))) { eaMs.Write(buffer, 0, buffer.Length); } diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index e80264f06..d048217a2 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -126,11 +126,7 @@ namespace Aaru.Filesystems ByteArrayToStructureLittleEndian(directoryBuffer, pos, Marshal.SizeOf()) : Marshal.ByteArrayToStructureBigEndian(directoryBuffer, - pos, - Marshal. - SizeOf< - DirectoryEntry - >()); + pos, Marshal.SizeOf()); pos += Marshal.SizeOf(); diff --git a/Aaru.Filesystems/FATX/Structs.cs b/Aaru.Filesystems/FATX/Structs.cs index 23bec6dee..185269f8b 100644 --- a/Aaru.Filesystems/FATX/Structs.cs +++ b/Aaru.Filesystems/FATX/Structs.cs @@ -37,7 +37,7 @@ namespace Aaru.Filesystems public sealed partial class XboxFatPlugin { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock + readonly struct Superblock { public readonly uint magic; public readonly uint id; @@ -50,7 +50,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { public readonly byte filenameSize; public readonly Attributes attributes; diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index 7afe9e4c9..5369dafad 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -233,11 +233,7 @@ namespace Aaru.Filesystems ByteArrayToStructureLittleEndian(rootDirectoryBuffer, pos, Marshal.SizeOf()) : Marshal.ByteArrayToStructureBigEndian(rootDirectoryBuffer, - pos, - Marshal. - SizeOf< - DirectoryEntry - >()); + pos, Marshal.SizeOf()); pos += Marshal.SizeOf(); diff --git a/Aaru.Filesystems/Fossil.cs b/Aaru.Filesystems/Fossil.cs index 3e221245b..439b67f2d 100644 --- a/Aaru.Filesystems/Fossil.cs +++ b/Aaru.Filesystems/Fossil.cs @@ -134,7 +134,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Header + readonly struct Header { /// Magic number public readonly uint magic; @@ -153,7 +153,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// Magic number public readonly uint magic; diff --git a/Aaru.Filesystems/HAMMER.cs b/Aaru.Filesystems/HAMMER.cs index 124c8bcdd..43f82f00d 100644 --- a/Aaru.Filesystems/HAMMER.cs +++ b/Aaru.Filesystems/HAMMER.cs @@ -150,7 +150,7 @@ namespace Aaru.Filesystems /// Hammer superblock [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - struct SuperBlock + readonly struct SuperBlock { /// for a valid header public readonly ulong vol_signature; diff --git a/Aaru.Filesystems/HPFS.cs b/Aaru.Filesystems/HPFS.cs index fbb0e5927..8fe359d63 100644 --- a/Aaru.Filesystems/HPFS.cs +++ b/Aaru.Filesystems/HPFS.cs @@ -239,7 +239,7 @@ namespace Aaru.Filesystems /// BIOS Parameter Block, at sector 0 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock + readonly struct BiosParameterBlock { /// 0x000, Jump to boot code [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -294,7 +294,7 @@ namespace Aaru.Filesystems /// HPFS superblock at sector 16 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// 0x000, 0xF995E849 public readonly uint magic1; @@ -346,7 +346,7 @@ namespace Aaru.Filesystems /// HPFS spareblock at sector 17 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SpareBlock + readonly struct SpareBlock { /// 0x000, 0xF9911849 public readonly uint magic1; diff --git a/Aaru.Filesystems/HPOFS/Structs.cs b/Aaru.Filesystems/HPOFS/Structs.cs index 3d255979c..f0799ac4d 100644 --- a/Aaru.Filesystems/HPOFS/Structs.cs +++ b/Aaru.Filesystems/HPOFS/Structs.cs @@ -40,7 +40,7 @@ namespace Aaru.Filesystems { /// BIOS Parameter Block, at sector 0, little-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock + readonly struct BiosParameterBlock { /// 0x000, Jump to boot code [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -99,7 +99,7 @@ namespace Aaru.Filesystems /// Media Information Block, at sector 13, big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MediaInformationBlock + readonly struct MediaInformationBlock { /// Block identifier "MEDINFO " [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] @@ -149,7 +149,7 @@ namespace Aaru.Filesystems /// Volume Information Block, at sector 14, big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VolumeInformationBlock + readonly struct VolumeInformationBlock { /// Block identifier "VOLINFO " [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] @@ -186,7 +186,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Extent + readonly struct Extent { /// Extent length in sectors public readonly ushort length; @@ -197,7 +197,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SubFile + readonly struct SubFile { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public readonly Extent[] extents; @@ -222,7 +222,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Direct + readonly struct Direct { /// Unknown public readonly uint unknown; @@ -267,7 +267,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MasterRecord + readonly struct MasterRecord { /// "MAST" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] @@ -293,7 +293,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DciKey + readonly struct DciKey { /// Unknown public readonly byte unknown; @@ -312,7 +312,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DciEntry + readonly struct DciEntry { /// Key length public readonly ushort key_len; @@ -329,7 +329,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Dci + readonly struct Dci { /// "DATA" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index b9537f71c..4e5c7b56f 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -175,7 +175,7 @@ namespace Aaru.Filesystems torito = Marshal.ByteArrayToStructureLittleEndian(vdSector, hsOff, - 2048 - hsOff); + 2048 - hsOff); } break; @@ -675,7 +675,7 @@ namespace Aaru.Filesystems ElToritoValidationEntry valentry = Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, - EL_TORITO_ENTRY_SIZE); + EL_TORITO_ENTRY_SIZE); if(valentry.signature != EL_TORITO_MAGIC) goto exit_torito; @@ -684,7 +684,7 @@ namespace Aaru.Filesystems ElToritoInitialEntry initialEntry = Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, - EL_TORITO_ENTRY_SIZE); + EL_TORITO_ENTRY_SIZE); initialEntry.boot_type = (ElToritoEmulation)((byte)initialEntry.boot_type & 0xF); @@ -765,7 +765,7 @@ namespace Aaru.Filesystems { ElToritoSectionHeaderEntry sectionHeader = Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, - EL_TORITO_ENTRY_SIZE); + EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; @@ -779,7 +779,7 @@ namespace Aaru.Filesystems { ElToritoSectionEntry sectionEntry = Marshal.ByteArrayToStructureLittleEndian(vdSector, toritoOff, - EL_TORITO_ENTRY_SIZE); + EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; @@ -862,8 +862,7 @@ namespace Aaru.Filesystems { ElToritoSectionEntryExtension sectionExtension = Marshal.ByteArrayToStructureLittleEndian(vdSector, - toritoOff, - EL_TORITO_ENTRY_SIZE); + toritoOff, EL_TORITO_ENTRY_SIZE); toritoOff += EL_TORITO_ENTRY_SIZE; diff --git a/Aaru.Filesystems/ISO9660/PathTable.cs b/Aaru.Filesystems/ISO9660/PathTable.cs index b6a098e25..825339fe3 100644 --- a/Aaru.Filesystems/ISO9660/PathTable.cs +++ b/Aaru.Filesystems/ISO9660/PathTable.cs @@ -55,7 +55,7 @@ namespace Aaru.Filesystems data.Length <= Marshal.SizeOf() || data[Marshal.SizeOf()] != 0x00) return null; - + while(off < data.Length) { entry = @@ -98,9 +98,7 @@ namespace Aaru.Filesystems { HighSierraPathTableEntry entry = Marshal.ByteArrayToStructureBigEndian(data, off, - Marshal. - SizeOf()); + Marshal.SizeOf()); if(entry.name_len == 0) break; diff --git a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs index e051aee3e..52a8e0a53 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs @@ -38,7 +38,7 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AmigaEntry + readonly struct AmigaEntry { public readonly ushort signature; public readonly byte length; @@ -50,7 +50,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AmigaProtection + readonly struct AmigaProtection { public readonly byte User; public readonly byte Reserved; diff --git a/Aaru.Filesystems/ISO9660/Structs/Apple.cs b/Aaru.Filesystems/ISO9660/Structs/Apple.cs index 68767a7ab..40b70aea3 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Apple.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Apple.cs @@ -39,7 +39,7 @@ namespace Aaru.Filesystems { // Little-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleProDOSSystemUse + readonly struct AppleProDOSSystemUse { public readonly ushort signature; public readonly byte length; @@ -50,7 +50,7 @@ namespace Aaru.Filesystems // Big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleHFSSystemUse + readonly struct AppleHFSSystemUse { public readonly ushort signature; public readonly byte length; @@ -62,7 +62,7 @@ namespace Aaru.Filesystems // Little-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleProDOSOldSystemUse + readonly struct AppleProDOSOldSystemUse { public readonly ushort signature; public readonly AppleOldId id; @@ -72,7 +72,7 @@ namespace Aaru.Filesystems // Big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleHFSTypeCreatorSystemUse + readonly struct AppleHFSTypeCreatorSystemUse { public readonly ushort signature; public readonly AppleOldId id; @@ -82,7 +82,7 @@ namespace Aaru.Filesystems // Big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleHFSIconSystemUse + readonly struct AppleHFSIconSystemUse { public readonly ushort signature; public readonly AppleOldId id; @@ -94,7 +94,7 @@ namespace Aaru.Filesystems // Big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleHFSOldSystemUse + readonly struct AppleHFSOldSystemUse { public readonly ushort signature; public readonly AppleOldId id; diff --git a/Aaru.Filesystems/ISO9660/Structs/CDi.cs b/Aaru.Filesystems/ISO9660/Structs/CDi.cs index 0f89fa469..a2c3c94e2 100644 --- a/Aaru.Filesystems/ISO9660/Structs/CDi.cs +++ b/Aaru.Filesystems/ISO9660/Structs/CDi.cs @@ -91,7 +91,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FileStructureVolumeDescriptor + readonly struct FileStructureVolumeDescriptor { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] @@ -162,7 +162,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdiDirectoryRecord + readonly struct CdiDirectoryRecord { public readonly byte length; public readonly byte xattr_len; @@ -183,7 +183,7 @@ namespace Aaru.Filesystems // Follows filename on directory record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdiSystemArea + readonly struct CdiSystemArea { public readonly ushort group; public readonly ushort owner; diff --git a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs index 02ca59da7..a20159846 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs @@ -38,7 +38,7 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ElToritoBootRecord + readonly struct ElToritoBootRecord { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] @@ -54,7 +54,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ElToritoValidationEntry + readonly struct ElToritoValidationEntry { public readonly ElToritoIndicator header_id; public readonly ElToritoPlatform platform_id; @@ -80,7 +80,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ElToritoSectionHeaderEntry + readonly struct ElToritoSectionHeaderEntry { public readonly ElToritoIndicator header_id; public readonly ElToritoPlatform platform_id; @@ -90,7 +90,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ElToritoSectionEntry + readonly struct ElToritoSectionEntry { public readonly ElToritoIndicator bootable; public readonly ElToritoEmulation boot_type; @@ -105,7 +105,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ElToritoSectionEntryExtension + readonly struct ElToritoSectionEntryExtension { public readonly ElToritoIndicator extension_indicator; public readonly ElToritoFlags extension_flags; diff --git a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs index 1d357e4f8..255576477 100644 --- a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs @@ -92,7 +92,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HighSierraPrimaryVolumeDescriptor + readonly struct HighSierraPrimaryVolumeDescriptor { public readonly uint volume_lbn; public readonly uint volume_lbn_be; @@ -159,7 +159,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HighSierraDirectoryRecord + readonly struct HighSierraDirectoryRecord { public readonly byte length; public readonly byte xattr_len; @@ -180,7 +180,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HighSierraTimestamp + readonly struct HighSierraTimestamp { public readonly byte Years; public readonly byte Month; @@ -192,7 +192,7 @@ namespace Aaru.Filesystems // There are two tables one in little endian one in big endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HighSierraPathTableEntry + readonly struct HighSierraPathTableEntry { public readonly uint start_lbn; public readonly byte xattr_len; diff --git a/Aaru.Filesystems/ISO9660/Structs/ISO.cs b/Aaru.Filesystems/ISO9660/Structs/ISO.cs index 2a0fbd050..4f4e2466b 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ISO.cs @@ -93,7 +93,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PrimaryVolumeDescriptor + readonly struct PrimaryVolumeDescriptor { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] @@ -158,7 +158,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootRecord + readonly struct BootRecord { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] @@ -173,7 +173,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PartitionDescriptor + readonly struct PartitionDescriptor { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] @@ -193,7 +193,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryRecord + readonly struct DirectoryRecord { public readonly byte length; public readonly byte xattr_len; @@ -213,7 +213,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtendedAttributeRecord + readonly struct ExtendedAttributeRecord { public readonly ushort owner; public readonly ushort owner_be; @@ -246,7 +246,7 @@ namespace Aaru.Filesystems // There are two tables one in little endian one in big endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PathTableEntry + readonly struct PathTableEntry { public readonly byte name_len; public readonly byte xattr_len; @@ -257,7 +257,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct IsoTimestamp + readonly struct IsoTimestamp { public readonly byte Years; public readonly byte Month; diff --git a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs index e2b335e0d..5736462fb 100644 --- a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs @@ -41,7 +41,7 @@ namespace Aaru.Filesystems { // RRIP 1.10 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PosixAttributesOld + readonly struct PosixAttributesOld { public readonly ushort signature; public readonly byte length; @@ -58,7 +58,7 @@ namespace Aaru.Filesystems // RRIP 1.12 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PosixAttributes + readonly struct PosixAttributes { public readonly ushort signature; public readonly byte length; @@ -76,7 +76,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PosixDeviceNumber + readonly struct PosixDeviceNumber { public readonly ushort signature; public readonly byte length; @@ -88,7 +88,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SymbolicLink + readonly struct SymbolicLink { public readonly ushort signature; public readonly byte length; @@ -99,7 +99,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SymbolicLinkComponent + readonly struct SymbolicLinkComponent { public readonly SymlinkComponentFlags flags; public readonly byte length; @@ -108,7 +108,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AlternateName + readonly struct AlternateName { public readonly ushort signature; public readonly byte length; @@ -119,7 +119,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ChildLink + readonly struct ChildLink { public readonly ushort signature; public readonly byte length; @@ -129,7 +129,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ParentLink + readonly struct ParentLink { public readonly ushort signature; public readonly byte length; @@ -139,7 +139,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RelocatedDirectory + readonly struct RelocatedDirectory { public readonly ushort signature; public readonly byte length; @@ -147,7 +147,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Timestamps + readonly struct Timestamps { public readonly ushort signature; public readonly byte length; @@ -165,7 +165,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SparseFile + readonly struct SparseFile { public readonly ushort signature; public readonly byte length; diff --git a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs index 3ae8db13a..c7703d31e 100644 --- a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs @@ -40,7 +40,7 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ContinuationArea + readonly struct ContinuationArea { public readonly ushort signature; public readonly byte length; @@ -54,7 +54,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PaddingArea + readonly struct PaddingArea { public readonly ushort signature; public readonly byte length; @@ -62,7 +62,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct IndicatorArea + readonly struct IndicatorArea { public readonly ushort signature; public readonly byte length; @@ -72,7 +72,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TerminatorArea + readonly struct TerminatorArea { public readonly ushort signature; public readonly byte length; @@ -80,7 +80,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ReferenceArea + readonly struct ReferenceArea { public readonly ushort signature; public readonly byte length; @@ -96,7 +96,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SelectorArea + readonly struct SelectorArea { public readonly ushort signature; public readonly byte length; diff --git a/Aaru.Filesystems/ISO9660/Structs/XA.cs b/Aaru.Filesystems/ISO9660/Structs/XA.cs index e81d77989..9f9a2d69b 100644 --- a/Aaru.Filesystems/ISO9660/Structs/XA.cs +++ b/Aaru.Filesystems/ISO9660/Structs/XA.cs @@ -39,7 +39,7 @@ namespace Aaru.Filesystems { // Big-endian [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CdromXa + readonly struct CdromXa { public readonly ushort group; public readonly ushort user; diff --git a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs index 01ecc8cb8..aa500eb45 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs @@ -40,7 +40,7 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ZisofsHeader + readonly struct ZisofsHeader { public readonly ulong magic; public readonly uint uncomp_len; @@ -50,7 +50,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ZisofsEntry + readonly struct ZisofsEntry { public readonly ushort signature; public readonly byte length; diff --git a/Aaru.Filesystems/JFS.cs b/Aaru.Filesystems/JFS.cs index f494497f9..1fd5406af 100644 --- a/Aaru.Filesystems/JFS.cs +++ b/Aaru.Filesystems/JFS.cs @@ -212,7 +212,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Extent + readonly struct Extent { /// Leftmost 24 bits are extent length, rest 8 bits are most significant for public readonly uint len_addr; @@ -220,14 +220,14 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct TimeStruct + readonly struct TimeStruct { public readonly uint tv_sec; public readonly uint tv_nsec; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { public readonly uint s_magic; public readonly uint s_version; diff --git a/Aaru.Filesystems/LIF.cs b/Aaru.Filesystems/LIF.cs index 76307d813..01a97b2b5 100644 --- a/Aaru.Filesystems/LIF.cs +++ b/Aaru.Filesystems/LIF.cs @@ -109,7 +109,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SystemBlock + readonly struct SystemBlock { public readonly ushort magic; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index d15ca9be0..c5f369fd4 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -189,7 +189,7 @@ namespace Aaru.Filesystems.LisaFS for(int j = 0; j < extentsCount; j++) file.extents[j] = new Extent { - start = BigEndianBitConverter.ToInt32(sector, extentsOffset + (j * 6)), + start = BigEndianBitConverter.ToInt32(sector, extentsOffset + (j * 6)), length = BigEndianBitConverter.ToInt16(sector, extentsOffset + (j * 6) + 4) }; diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index 9d28c7cd4..f84d80c3d 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -181,7 +181,7 @@ namespace Aaru.Filesystems.LisaFS // Check that the MDDF is correct if(_mddf.mddf_block != i - _volumePrefix || _mddf.vol_size > _device.Info.Sectors || - _mddf.vol_size - 1 != _mddf.volsize_minus_one || + _mddf.vol_size - 1 != _mddf.volsize_minus_one || _mddf.vol_size - i - 1 != _mddf.volsize_minus_mddf_minus_one - _volumePrefix || _mddf.datasize > _mddf.blocksize || _mddf.blocksize < _device.Info.SectorSize || diff --git a/Aaru.Filesystems/Locus.cs b/Aaru.Filesystems/Locus.cs index ea31bd87c..3e38c1222 100644 --- a/Aaru.Filesystems/Locus.cs +++ b/Aaru.Filesystems/Locus.cs @@ -328,7 +328,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OldSuperblock + readonly struct OldSuperblock { public readonly uint s_magic; /* identifies this as a locus filesystem */ /* defined as a constant below */ diff --git a/Aaru.Filesystems/MicroDOS.cs b/Aaru.Filesystems/MicroDOS.cs index e0280c54f..fa22940a9 100644 --- a/Aaru.Filesystems/MicroDOS.cs +++ b/Aaru.Filesystems/MicroDOS.cs @@ -108,7 +108,7 @@ namespace Aaru.Filesystems // Followed by directory entries [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Block0 + readonly struct Block0 { /// BK starts booting here [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] @@ -140,7 +140,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { /// File status public readonly byte status; diff --git a/Aaru.Filesystems/MinixFS.cs b/Aaru.Filesystems/MinixFS.cs index 297653570..81f567ef3 100644 --- a/Aaru.Filesystems/MinixFS.cs +++ b/Aaru.Filesystems/MinixFS.cs @@ -324,7 +324,7 @@ namespace Aaru.Filesystems /// Superblock for Minix v1 and V2 filesystems [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// 0x00, inodes on volume public readonly ushort s_ninodes; diff --git a/Aaru.Filesystems/NILFS2.cs b/Aaru.Filesystems/NILFS2.cs index 4d2fcf0dd..e5abb03bc 100644 --- a/Aaru.Filesystems/NILFS2.cs +++ b/Aaru.Filesystems/NILFS2.cs @@ -162,7 +162,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock + readonly struct Superblock { public readonly uint rev_level; public readonly ushort minor_rev_level; diff --git a/Aaru.Filesystems/NTFS.cs b/Aaru.Filesystems/NTFS.cs index 626707450..148ee6f74 100644 --- a/Aaru.Filesystems/NTFS.cs +++ b/Aaru.Filesystems/NTFS.cs @@ -155,7 +155,7 @@ namespace Aaru.Filesystems /// NTFS $BOOT [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock + readonly struct BiosParameterBlock { // Start of BIOS Parameter Block /// 0x000, Jump to boot code diff --git a/Aaru.Filesystems/ODS.cs b/Aaru.Filesystems/ODS.cs index d65af6fbf..ead92e31a 100644 --- a/Aaru.Filesystems/ODS.cs +++ b/Aaru.Filesystems/ODS.cs @@ -273,7 +273,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HomeBlock + readonly struct HomeBlock { /// 0x000, LBN of THIS home block public readonly uint homelbn; diff --git a/Aaru.Filesystems/Opera/Structs.cs b/Aaru.Filesystems/Opera/Structs.cs index c90940832..8099a45f6 100644 --- a/Aaru.Filesystems/Opera/Structs.cs +++ b/Aaru.Filesystems/Opera/Structs.cs @@ -37,7 +37,7 @@ namespace Aaru.Filesystems public sealed partial class OperaFS { [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// 0x000, Record type, must be 1 public readonly byte record_type; @@ -71,7 +71,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryHeader + readonly struct DirectoryHeader { /// Next block from this directory, -1 if last public readonly int next_block; @@ -86,7 +86,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { /// File flags, see public readonly uint flags; diff --git a/Aaru.Filesystems/PCFX.cs b/Aaru.Filesystems/PCFX.cs index e0818156e..8145028b8 100644 --- a/Aaru.Filesystems/PCFX.cs +++ b/Aaru.Filesystems/PCFX.cs @@ -127,7 +127,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Header + readonly struct Header { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] signature; diff --git a/Aaru.Filesystems/PFS.cs b/Aaru.Filesystems/PFS.cs index 486879245..6a4707d8a 100644 --- a/Aaru.Filesystems/PFS.cs +++ b/Aaru.Filesystems/PFS.cs @@ -141,7 +141,7 @@ namespace Aaru.Filesystems /// Boot block, first 2 sectors [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootBlock + readonly struct BootBlock { /// "PFS\1" disk type public readonly uint diskType; @@ -150,7 +150,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RootBlock + readonly struct RootBlock { /// Disk type public readonly uint diskType; diff --git a/Aaru.Filesystems/QNX4.cs b/Aaru.Filesystems/QNX4.cs index 71937e043..1bfabbf1e 100644 --- a/Aaru.Filesystems/QNX4.cs +++ b/Aaru.Filesystems/QNX4.cs @@ -208,7 +208,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Inode + readonly struct Inode { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] di_fname; @@ -230,7 +230,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LinkInfo + readonly struct LinkInfo { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] public readonly byte[] dl_fname; @@ -242,7 +242,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtentBlock + readonly struct ExtentBlock { public readonly uint next_xblk; public readonly uint prev_xblk; @@ -258,7 +258,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock + readonly struct Superblock { public readonly Inode rootDir; public readonly Inode inode; diff --git a/Aaru.Filesystems/QNX6.cs b/Aaru.Filesystems/QNX6.cs index 845318b94..25f9449e8 100644 --- a/Aaru.Filesystems/QNX6.cs +++ b/Aaru.Filesystems/QNX6.cs @@ -167,7 +167,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RootNode + readonly struct RootNode { public readonly ulong size; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] @@ -179,7 +179,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { public readonly uint magic; public readonly uint checksum; @@ -204,7 +204,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AudiSuperBlock + readonly struct AudiSuperBlock { public readonly uint magic; public readonly uint checksum; diff --git a/Aaru.Filesystems/RBF.cs b/Aaru.Filesystems/RBF.cs index bc50315be..c2c1629a7 100644 --- a/Aaru.Filesystems/RBF.cs +++ b/Aaru.Filesystems/RBF.cs @@ -285,7 +285,7 @@ namespace Aaru.Filesystems /// Identification sector. Wherever the sector this resides on, becomes LSN 0. [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct IdSector + readonly struct IdSector { /// Sectors on disk [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -342,7 +342,7 @@ namespace Aaru.Filesystems /// big or little endian. /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NewIdSector + readonly struct NewIdSector { /// Magic number public readonly uint rid_sync; diff --git a/Aaru.Filesystems/RT11.cs b/Aaru.Filesystems/RT11.cs index 330225bf8..8fc2e4fa4 100644 --- a/Aaru.Filesystems/RT11.cs +++ b/Aaru.Filesystems/RT11.cs @@ -122,7 +122,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HomeBlock + readonly struct HomeBlock { /// Bad block replacement table [MarshalAs(UnmanagedType.ByValArray, SizeConst = 130)] diff --git a/Aaru.Filesystems/ReFS.cs b/Aaru.Filesystems/ReFS.cs index 2740a45c0..4dcd19427 100644 --- a/Aaru.Filesystems/ReFS.cs +++ b/Aaru.Filesystems/ReFS.cs @@ -152,7 +152,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VolumeHeader + readonly struct VolumeHeader { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public readonly byte[] jump; diff --git a/Aaru.Filesystems/Register.cs b/Aaru.Filesystems/Register.cs index 1c54e25a7..147435b29 100644 --- a/Aaru.Filesystems/Register.cs +++ b/Aaru.Filesystems/Register.cs @@ -48,10 +48,10 @@ namespace Aaru.Filesystems { public List GetAllChecksumPlugins() => null; - public List GetAllFilesystemPlugins() => Assembly. - GetExecutingAssembly().GetTypes(). - Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))). - Where(t => t.IsClass).ToList(); + public List GetAllFilesystemPlugins() => Assembly.GetExecutingAssembly().GetTypes(). + Where(t => t.GetInterfaces(). + Contains(typeof(IFilesystem))). + Where(t => t.IsClass).ToList(); public List GetAllFilterPlugins() => null; @@ -61,11 +61,11 @@ namespace Aaru.Filesystems public List GetAllPartitionPlugins() => null; - public List GetAllReadOnlyFilesystemPlugins() => Assembly. - GetExecutingAssembly().GetTypes(). - Where(t => t.GetInterfaces(). - Contains(typeof(IReadOnlyFilesystem))). - Where(t => t.IsClass).ToList(); + public List GetAllReadOnlyFilesystemPlugins() => Assembly.GetExecutingAssembly().GetTypes(). + Where(t => t.GetInterfaces(). + Contains(typeof(IReadOnlyFilesystem + ))).Where(t => t.IsClass). + ToList(); public List GetAllWritableFloppyImagePlugins() => null; diff --git a/Aaru.Filesystems/Reiser.cs b/Aaru.Filesystems/Reiser.cs index 3175c9106..8a26a682b 100644 --- a/Aaru.Filesystems/Reiser.cs +++ b/Aaru.Filesystems/Reiser.cs @@ -177,7 +177,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JournalParameters + readonly struct JournalParameters { public readonly uint journal_1stblock; public readonly uint journal_dev; diff --git a/Aaru.Filesystems/Reiser4.cs b/Aaru.Filesystems/Reiser4.cs index 3cf9df2f8..7f92c7bbe 100644 --- a/Aaru.Filesystems/Reiser4.cs +++ b/Aaru.Filesystems/Reiser4.cs @@ -135,7 +135,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock + readonly struct Superblock { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] magic; diff --git a/Aaru.Filesystems/SFS.cs b/Aaru.Filesystems/SFS.cs index 3411a2abf..7d0787ea7 100644 --- a/Aaru.Filesystems/SFS.cs +++ b/Aaru.Filesystems/SFS.cs @@ -130,7 +130,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RootBlock + readonly struct RootBlock { public readonly uint blockId; public readonly uint blockChecksum; diff --git a/Aaru.Filesystems/Squash.cs b/Aaru.Filesystems/Squash.cs index 564ea976c..936145f7d 100644 --- a/Aaru.Filesystems/Squash.cs +++ b/Aaru.Filesystems/Squash.cs @@ -157,7 +157,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { public readonly uint magic; public readonly uint inodes; diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index 4282c2f62..f90feb40c 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -183,11 +183,10 @@ namespace Aaru.Filesystems.UCSDPascal foreach(PascalFileEntry ent in _fileEntries.Where(ent => string.Compare(path, - StringHandlers. - PascalToString(ent.Filename, - Encoding), - StringComparison. - InvariantCultureIgnoreCase) == 0)) + StringHandlers.PascalToString(ent.Filename, + Encoding), + StringComparison. + InvariantCultureIgnoreCase) == 0)) { entry = ent; diff --git a/Aaru.Filesystems/UDF.cs b/Aaru.Filesystems/UDF.cs index 5af054fd0..7f908288f 100644 --- a/Aaru.Filesystems/UDF.cs +++ b/Aaru.Filesystems/UDF.cs @@ -237,16 +237,8 @@ namespace Aaru.Filesystems lvid.tag.tagLocation == lvd.integritySequenceExtent.location) lvidiu = Marshal.ByteArrayToStructureLittleEndian(sector, - (int) - ((lvid. - numberOfPartitions * - 8) + - 80), - System. - Runtime. - InteropServices. - Marshal. - SizeOf(lvidiu)); + (int)((lvid.numberOfPartitions * 8) + 80), + System.Runtime.InteropServices.Marshal.SizeOf(lvidiu)); else lvid = new LogicalVolumeIntegrityDescriptor(); @@ -313,16 +305,8 @@ namespace Aaru.Filesystems } static DateTime EcmaToDateTime(Timestamp timestamp) => DateHandlers.EcmaToDateTime(timestamp.typeAndZone, - timestamp.year, - timestamp.month, - timestamp.day, - timestamp.hour, - timestamp.minute, - timestamp.second, - timestamp.centiseconds, - timestamp. - hundredsMicroseconds, - timestamp.microseconds); + timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second, + timestamp.centiseconds, timestamp.hundredsMicroseconds, timestamp.microseconds); [Flags] enum EntityFlags : byte @@ -331,7 +315,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct EntityIdentifier + readonly struct EntityIdentifier { /// Entity flags public readonly EntityFlags flags; @@ -344,7 +328,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Timestamp + readonly struct Timestamp { public readonly ushort typeAndZone; public readonly short year; @@ -366,7 +350,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DescriptorTag + readonly struct DescriptorTag { public readonly TagIdentifier tagIdentifier; public readonly ushort descriptorVersion; @@ -379,14 +363,14 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ExtentDescriptor + readonly struct ExtentDescriptor { public readonly uint length; public readonly uint location; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CharacterSpecification + readonly struct CharacterSpecification { public readonly byte type; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] @@ -394,7 +378,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AnchorVolumeDescriptorPointer + readonly struct AnchorVolumeDescriptorPointer { public readonly DescriptorTag tag; public readonly ExtentDescriptor mainVolumeDescriptorSequenceExtent; @@ -404,7 +388,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PrimaryVolumeDescriptor + readonly struct PrimaryVolumeDescriptor { public readonly DescriptorTag tag; public readonly uint volumeDescriptorSequenceNumber; @@ -435,7 +419,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LogicalVolumeDescriptor + readonly struct LogicalVolumeDescriptor { public readonly DescriptorTag tag; public readonly uint volumeDescriptorSequenceNumber; @@ -455,7 +439,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LogicalVolumeIntegrityDescriptor + readonly struct LogicalVolumeIntegrityDescriptor { public readonly DescriptorTag tag; public readonly Timestamp recordingDateTime; @@ -472,7 +456,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LogicalVolumeIntegrityDescriptorImplementationUse + readonly struct LogicalVolumeIntegrityDescriptorImplementationUse { public readonly EntityIdentifier implementationId; public readonly uint files; diff --git a/Aaru.Filesystems/UNICOS.cs b/Aaru.Filesystems/UNICOS.cs index b51fb8b8f..d827efaee 100644 --- a/Aaru.Filesystems/UNICOS.cs +++ b/Aaru.Filesystems/UNICOS.cs @@ -148,7 +148,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct nc1ireg_sb + readonly struct nc1ireg_sb { public readonly ushort i_unused; /* reserved */ public readonly ushort i_nblk; /* number of blocks */ @@ -156,7 +156,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct nc1fdev_sb + readonly struct nc1fdev_sb { public readonly long fd_name; /* Physical device name */ public readonly uint fd_sblk; /* Start block number */ @@ -167,7 +167,7 @@ namespace Aaru.Filesystems [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - struct Superblock + readonly struct Superblock { public readonly ulong s_magic; /* magic number to indicate file system type */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] diff --git a/Aaru.Filesystems/VMfs.cs b/Aaru.Filesystems/VMfs.cs index 618e8664c..1df4e3dc7 100644 --- a/Aaru.Filesystems/VMfs.cs +++ b/Aaru.Filesystems/VMfs.cs @@ -122,13 +122,13 @@ namespace Aaru.Filesystems } [Flags] - enum VMfsFlags : byte + enum Flags : byte { RecyledFolder = 64, CaseSensitive = 128 } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VolumeInfo + readonly struct VolumeInfo { public readonly uint magic; public readonly uint version; diff --git a/Aaru.Filesystems/VxFS.cs b/Aaru.Filesystems/VxFS.cs index 17f731484..a57134cf1 100644 --- a/Aaru.Filesystems/VxFS.cs +++ b/Aaru.Filesystems/VxFS.cs @@ -119,7 +119,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// Magic number public readonly uint vs_magic; diff --git a/Aaru.Filesystems/XFS.cs b/Aaru.Filesystems/XFS.cs index e3e8b48e3..35a40c63e 100644 --- a/Aaru.Filesystems/XFS.cs +++ b/Aaru.Filesystems/XFS.cs @@ -226,7 +226,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock + readonly struct Superblock { public readonly uint magicnum; public readonly uint blocksize; diff --git a/Aaru.Filesystems/Xia.cs b/Aaru.Filesystems/Xia.cs index b5e553d0f..df0d85c4e 100644 --- a/Aaru.Filesystems/Xia.cs +++ b/Aaru.Filesystems/Xia.cs @@ -133,7 +133,7 @@ namespace Aaru.Filesystems /// Xia superblock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + readonly struct SuperBlock { /// 1st sector reserved for boot [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] @@ -174,7 +174,7 @@ namespace Aaru.Filesystems /// Xia directory entry [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry + readonly struct DirectoryEntry { public readonly uint d_ino; public readonly ushort d_rec_len; @@ -185,7 +185,7 @@ namespace Aaru.Filesystems /// Xia inode [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Inode + readonly struct Inode { public readonly ushort i_mode; public readonly ushort i_nlinks; diff --git a/Aaru.Filesystems/dump.cs b/Aaru.Filesystems/dump.cs index c3409862a..782689ba6 100644 --- a/Aaru.Filesystems/dump.cs +++ b/Aaru.Filesystems/dump.cs @@ -331,7 +331,7 @@ namespace Aaru.Filesystems // 32-bit AIX format record [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct spcl_aix + readonly struct spcl_aix { /// Record type public readonly int c_type; @@ -358,7 +358,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct s_spcl + readonly struct s_spcl { public readonly int c_type; /* record type (see below) */ public readonly int c_date; /* date of this dump */ @@ -392,7 +392,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct dinode + readonly struct dinode { public readonly ushort di_mode; /* 0: IFMT, permissions; see below. */ public readonly short di_nlink; /* 2: File link count. */ diff --git a/Aaru.Filesystems/exFAT.cs b/Aaru.Filesystems/exFAT.cs index a94ba7299..5e0360070 100644 --- a/Aaru.Filesystems/exFAT.cs +++ b/Aaru.Filesystems/exFAT.cs @@ -168,7 +168,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VolumeBootRecord + readonly struct VolumeBootRecord { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public readonly byte[] jump; @@ -199,7 +199,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OemParameter + readonly struct OemParameter { public readonly Guid OemParameterType; public readonly uint eraseBlockSize; @@ -214,7 +214,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OemParameterTable + readonly struct OemParameterTable { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public readonly OemParameter[] parameters; @@ -223,7 +223,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ChecksumSector + readonly struct ChecksumSector { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public readonly uint[] checksum; diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index 355d60573..121c56d71 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -73,14 +73,14 @@ namespace Aaru.Filters { 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - string _basePath; - DateTime _creationTime; - AppleDoubleEntry _dataFork; - AppleDoubleHeader _header; - string _headerPath; - DateTime _lastWriteTime; - bool _opened; - AppleDoubleEntry _rsrcFork; + string _basePath; + DateTime _creationTime; + Entry _dataFork; + Header _header; + string _headerPath; + DateTime _lastWriteTime; + bool _opened; + Entry _rsrcFork; public string Name => "AppleDouble"; public Guid Id => new Guid("1B2165EE-C9DF-4B21-BBBB-9E5892B2DF4D"); @@ -168,7 +168,7 @@ namespace Aaru.Filters { byte[] prodosB = new byte[26]; prodosStream.Read(prodosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(prodosB); + _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); if(_header.magic == MAGIC && @@ -186,7 +186,7 @@ namespace Aaru.Filters { byte[] unixB = new byte[26]; unixStream.Read(unixB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(unixB); + _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); if(_header.magic == MAGIC && @@ -204,7 +204,7 @@ namespace Aaru.Filters { byte[] dosB = new byte[26]; dosStream.Read(dosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(dosB); + _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); if(_header.magic == MAGIC && @@ -222,7 +222,7 @@ namespace Aaru.Filters { byte[] doslB = new byte[26]; doslStream.Read(doslB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(doslB); + _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); if(_header.magic == MAGIC && @@ -240,7 +240,7 @@ namespace Aaru.Filters { byte[] netatalkB = new byte[26]; netatalkStream.Read(netatalkB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(netatalkB); + _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); if(_header.magic == MAGIC && @@ -258,7 +258,7 @@ namespace Aaru.Filters { byte[] daveB = new byte[26]; daveStream.Read(daveB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(daveB); + _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); if(_header.magic == MAGIC && @@ -276,7 +276,7 @@ namespace Aaru.Filters { byte[] osxB = new byte[26]; osxStream.Read(osxB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(osxB); + _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); if(_header.magic == MAGIC && @@ -296,7 +296,7 @@ namespace Aaru.Filters byte[] unarB = new byte[26]; unarStream.Read(unarB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(unarB); + _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); @@ -355,7 +355,7 @@ namespace Aaru.Filters { byte[] prodosB = new byte[26]; prodosStream.Read(prodosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(prodosB); + _header = Marshal.ByteArrayToStructureBigEndian
(prodosB); prodosStream.Close(); if(_header.magic == MAGIC && @@ -373,7 +373,7 @@ namespace Aaru.Filters { byte[] unixB = new byte[26]; unixStream.Read(unixB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(unixB); + _header = Marshal.ByteArrayToStructureBigEndian
(unixB); unixStream.Close(); if(_header.magic == MAGIC && @@ -391,7 +391,7 @@ namespace Aaru.Filters { byte[] dosB = new byte[26]; dosStream.Read(dosB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(dosB); + _header = Marshal.ByteArrayToStructureBigEndian
(dosB); dosStream.Close(); if(_header.magic == MAGIC && @@ -409,7 +409,7 @@ namespace Aaru.Filters { byte[] doslB = new byte[26]; doslStream.Read(doslB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(doslB); + _header = Marshal.ByteArrayToStructureBigEndian
(doslB); doslStream.Close(); if(_header.magic == MAGIC && @@ -427,7 +427,7 @@ namespace Aaru.Filters { byte[] netatalkB = new byte[26]; netatalkStream.Read(netatalkB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(netatalkB); + _header = Marshal.ByteArrayToStructureBigEndian
(netatalkB); netatalkStream.Close(); if(_header.magic == MAGIC && @@ -445,7 +445,7 @@ namespace Aaru.Filters { byte[] daveB = new byte[26]; daveStream.Read(daveB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(daveB); + _header = Marshal.ByteArrayToStructureBigEndian
(daveB); daveStream.Close(); if(_header.magic == MAGIC && @@ -463,7 +463,7 @@ namespace Aaru.Filters { byte[] osxB = new byte[26]; osxStream.Read(osxB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(osxB); + _header = Marshal.ByteArrayToStructureBigEndian
(osxB); osxStream.Close(); if(_header.magic == MAGIC && @@ -481,7 +481,7 @@ namespace Aaru.Filters { byte[] unarB = new byte[26]; unarStream.Read(unarB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(unarB); + _header = Marshal.ByteArrayToStructureBigEndian
(unarB); unarStream.Close(); if(_header.magic == MAGIC && @@ -495,86 +495,81 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; fs.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - AppleDoubleEntry[] entries = new AppleDoubleEntry[_header.entries]; + Entry[] entries = new Entry[_header.entries]; for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; fs.Read(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } _creationTime = DateTime.UtcNow; _lastWriteTime = _creationTime; - foreach(AppleDoubleEntry entry in entries) - switch((AppleDoubleEntryID)entry.id) + foreach(Entry entry in entries) + switch((EntryId)entry.id) { - case AppleDoubleEntryID.DataFork: + case EntryId.DataFork: // AppleDouble have datafork in separated file break; - case AppleDoubleEntryID.FileDates: + case EntryId.FileDates: fs.Seek(entry.offset, SeekOrigin.Begin); byte[] datesB = new byte[16]; fs.Read(datesB, 0, 16); - AppleDoubleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); _creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); break; - case AppleDoubleEntryID.FileInfo: + case EntryId.FileInfo: fs.Seek(entry.offset, SeekOrigin.Begin); byte[] finfo = new byte[entry.length]; fs.Read(finfo, 0, finfo.Length); if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - AppleDoubleMacFileInfo macinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - AppleDoubleProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleDoubleUnixFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - AppleDoubleDOSFileInfo dosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; - case AppleDoubleEntryID.ResourceFork: + case EntryId.ResourceFork: _rsrcFork = entry; break; } - _dataFork = new AppleDoubleEntry + _dataFork = new Entry { - id = (uint)AppleDoubleEntryID.DataFork + id = (uint)EntryId.DataFork }; if(File.Exists(path)) @@ -589,7 +584,7 @@ namespace Aaru.Filters _basePath = path; } - enum AppleDoubleEntryID : uint + enum EntryId : uint { Invalid = 0, DataFork = 1, ResourceFork = 2, RealName = 3, Comment = 4, Icon = 5, @@ -600,7 +595,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleHeader + readonly struct Header { public readonly uint magic; public readonly uint version; @@ -610,7 +605,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleEntry + struct Entry { public uint id; public readonly uint offset; @@ -618,7 +613,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleFileDates + readonly struct FileDates { public readonly uint creationDate; public readonly uint modificationDate; @@ -627,7 +622,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleMacFileInfo + readonly struct MacFileInfo { public readonly uint creationDate; public readonly uint modificationDate; @@ -636,7 +631,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleUnixFileInfo + readonly struct UnixFileInfo { public readonly uint creationDate; public readonly uint accessDate; @@ -644,7 +639,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleDOSFileInfo + readonly struct DOSFileInfo { public readonly ushort modificationDate; public readonly ushort modificationTime; @@ -652,7 +647,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleProDOSFileInfo + readonly struct ProDOSFileInfo { public readonly uint creationDate; public readonly uint modificationDate; diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index 4bc27bbd8..4734f886e 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -73,15 +73,15 @@ namespace Aaru.Filters { 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - string _basePath; - byte[] _bytes; - DateTime _creationTime; - AppleSingleEntry _dataFork; - AppleSingleHeader _header; - bool _isBytes, _isStream, _isPath, _opened; - DateTime _lastWriteTime; - AppleSingleEntry _rsrcFork; - Stream _stream; + string _basePath; + byte[] _bytes; + DateTime _creationTime; + Entry _dataFork; + Header _header; + bool _isBytes, _isStream, _isPath, _opened; + DateTime _lastWriteTime; + Entry _rsrcFork; + Stream _stream; public string Name => "AppleSingle"; public Guid Id => new Guid("A69B20E8-F4D3-42BB-BD2B-4A7263394A05"); @@ -161,7 +161,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; Array.Copy(buffer, 0, hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } @@ -175,7 +175,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; stream.Seek(0, SeekOrigin.Begin); stream.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } @@ -192,7 +192,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; fstream.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); fstream.Close(); @@ -208,21 +208,21 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; ms.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; + Entry[] entries = new Entry[_header.entries]; for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; ms.Read(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } _creationTime = DateTime.UtcNow; _lastWriteTime = _creationTime; - foreach(AppleSingleEntry entry in entries) + foreach(Entry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: @@ -234,8 +234,7 @@ namespace Aaru.Filters byte[] datesB = new byte[16]; ms.Read(datesB, 0, 16); - AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); _creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); @@ -248,32 +247,28 @@ namespace Aaru.Filters if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleMacFileInfo macinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUnixFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleDOSFileInfo dosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); @@ -298,21 +293,21 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; stream.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; + Entry[] entries = new Entry[_header.entries]; for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; stream.Read(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } _creationTime = DateTime.UtcNow; _lastWriteTime = _creationTime; - foreach(AppleSingleEntry entry in entries) + foreach(Entry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: @@ -324,8 +319,7 @@ namespace Aaru.Filters byte[] datesB = new byte[16]; stream.Read(datesB, 0, 16); - AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); _creationTime = DateHandlers.MacToDateTime(dates.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); @@ -338,32 +332,28 @@ namespace Aaru.Filters if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleMacFileInfo macinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUnixFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleDOSFileInfo dosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); @@ -389,21 +379,21 @@ namespace Aaru.Filters byte[] hdrB = new byte[26]; fs.Read(hdrB, 0, 26); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; + Entry[] entries = new Entry[_header.entries]; for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; fs.Read(entry, 0, 12); - entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); + entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } _creationTime = DateTime.UtcNow; _lastWriteTime = _creationTime; - foreach(AppleSingleEntry entry in entries) + foreach(Entry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: @@ -415,8 +405,7 @@ namespace Aaru.Filters byte[] datesB = new byte[16]; fs.Read(datesB, 0, 16); - AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(datesB); + FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB); _creationTime = DateHandlers.MacToDateTime(dates.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); @@ -429,32 +418,28 @@ namespace Aaru.Filters if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleMacFileInfo macinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUnixFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleDOSFileInfo dosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); @@ -484,7 +469,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleHeader + readonly struct Header { public readonly uint magic; public readonly uint version; @@ -494,7 +479,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleEntry + readonly struct Entry { public readonly uint id; public readonly uint offset; @@ -502,7 +487,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleFileDates + readonly struct FileDates { public readonly uint creationDate; public readonly uint modificationDate; @@ -511,7 +496,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleMacFileInfo + readonly struct MacFileInfo { public readonly uint creationDate; public readonly uint modificationDate; @@ -520,7 +505,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleUnixFileInfo + readonly struct UnixFileInfo { public readonly uint creationDate; public readonly uint accessDate; @@ -528,7 +513,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleDOSFileInfo + readonly struct DOSFileInfo { public readonly ushort modificationDate; public readonly ushort modificationTime; @@ -536,7 +521,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleProDOSFileInfo + readonly struct ProDOSFileInfo { public readonly uint creationDate; public readonly uint modificationDate; diff --git a/Aaru.Filters/ForcedSeekStream.cs b/Aaru.Filters/ForcedSeekStream.cs index 52eaf0237..29c25e9a7 100644 --- a/Aaru.Filters/ForcedSeekStream.cs +++ b/Aaru.Filters/ForcedSeekStream.cs @@ -119,9 +119,9 @@ namespace Aaru.Filters } _backStream.Position = _backStream.Length; - long toposition = position - _backStream.Position; - int fullBufferReads = (int)(toposition / BUFFER_LEN); - int restToRead = (int)(toposition % BUFFER_LEN); + long toPosition = position - _backStream.Position; + int fullBufferReads = (int)(toPosition / BUFFER_LEN); + int restToRead = (int)(toPosition % BUFFER_LEN); byte[] buffer; for(int i = 0; i < fullBufferReads; i++) diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index 087194868..262ef3492 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -44,17 +44,17 @@ namespace Aaru.Filters /// Decodes MacBinary files public sealed class MacBinary : IFilter { - const uint MAGIC = 0x6D42494E; - string _basePath; - byte[] _bytes; - DateTime _creationTime; - long _dataForkOff; - string _filename; - MacBinaryHeader _header; - bool _isBytes, _isStream, _isPath, _opened; - DateTime _lastWriteTime; - long _rsrcForkOff; - Stream _stream; + const uint MAGIC = 0x6D42494E; + string _basePath; + byte[] _bytes; + DateTime _creationTime; + long _dataForkOff; + string _filename; + Header _header; + bool _isBytes, _isStream, _isPath, _opened; + DateTime _lastWriteTime; + long _rsrcForkOff; + Stream _stream; public string Name => "MacBinary"; public Guid Id => new Guid("D7C321D3-E51F-45DF-A150-F6BFDF0D7704"); @@ -134,7 +134,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; Array.Copy(buffer, 0, hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _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 && @@ -151,7 +151,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; stream.Seek(0, SeekOrigin.Begin); stream.Read(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _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 && @@ -171,7 +171,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; fstream.Read(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); fstream.Close(); @@ -190,7 +190,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; ms.Read(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); @@ -222,7 +222,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; stream.Read(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); @@ -255,7 +255,7 @@ namespace Aaru.Filters byte[] hdrB = new byte[128]; fs.Read(hdrB, 0, 128); - _header = Marshal.ByteArrayToStructureBigEndian(hdrB); + _header = Marshal.ByteArrayToStructureBigEndian
(hdrB); uint blocks = 1; blocks += (uint)(_header.secondaryHeaderLength / 128); @@ -282,7 +282,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MacBinaryHeader + struct Header { /// 0x00, MacBinary version, 0 public readonly byte version; diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index a0f6de25c..6aabb2c7b 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -115,10 +115,10 @@ namespace Aaru.Filters while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new PcExchangeEntry(); + var datEntry = new Entry(); byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); // TODO: Add support for encoding on filters string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); @@ -172,10 +172,10 @@ namespace Aaru.Filters while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new PcExchangeEntry(); + var datEntry = new Entry(); byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); @@ -226,7 +226,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PcExchangeEntry + readonly struct Entry { /// /// Name in Macintosh. If PCExchange version supports FAT's LFN they are the same. Illegal characters for FAT get diff --git a/Aaru.Filters/Register.cs b/Aaru.Filters/Register.cs index 08c962297..ce9aa86e6 100644 --- a/Aaru.Filters/Register.cs +++ b/Aaru.Filters/Register.cs @@ -50,10 +50,9 @@ namespace Aaru.Filters public List GetAllFilesystemPlugins() => null; - public List GetAllFilterPlugins() => Assembly. - GetExecutingAssembly().GetTypes(). - Where(t => t.GetInterfaces().Contains(typeof(IFilter))). - Where(t => t.IsClass).ToList(); + public List GetAllFilterPlugins() => Assembly.GetExecutingAssembly().GetTypes(). + Where(t => t.GetInterfaces().Contains(typeof(IFilter))). + Where(t => t.IsClass).ToList(); public List GetAllFloppyImagePlugins() => null; diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index d9047aa3f..271c94105 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -83,9 +83,10 @@ namespace Aaru.Gui void OnAboutClicked(object sender, EventArgs args) { - if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) || - !(desktop.MainWindow is MainWindow mainWindow) || - !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)) + if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteAboutCommand(); @@ -93,9 +94,10 @@ namespace Aaru.Gui void OnQuitClicked(object sender, EventArgs args) { - if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) || - !(desktop.MainWindow is MainWindow mainWindow) || - !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)) + if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteExitCommand(); @@ -103,9 +105,10 @@ namespace Aaru.Gui void OnPreferencesClicked(object sender, EventArgs args) { - if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) || - !(desktop.MainWindow is MainWindow mainWindow) || - !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)) + if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime + { + MainWindow: MainWindow { DataContext: MainWindowViewModel mainWindowViewModel } + })) return; mainWindowViewModel.ExecuteSettingsCommand(); diff --git a/Aaru.Gui/Controls/BlockMap.cs b/Aaru.Gui/Controls/BlockMap.cs index c31612b20..4a5fc039e 100644 --- a/Aaru.Gui/Controls/BlockMap.cs +++ b/Aaru.Gui/Controls/BlockMap.cs @@ -243,7 +243,7 @@ namespace Aaru.Gui.Controls case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Replace: { - if(!(e.NewItems is { } items)) + if(!(e.NewItems is {} items)) throw new ArgumentException("Invalid list of items"); using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null); @@ -264,8 +264,8 @@ namespace Aaru.Gui.Controls case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Move: { - if(!(e.NewItems is { } newItems) || - !(e.OldItems is { } oldItems)) + if(!(e.NewItems is {} newItems) || + !(e.OldItems is {} oldItems)) throw new ArgumentException("Invalid list of items"); using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null); diff --git a/Aaru.Gui/Main.cs b/Aaru.Gui/Main.cs index ff270aed9..5d62b75e5 100644 --- a/Aaru.Gui/Main.cs +++ b/Aaru.Gui/Main.cs @@ -44,8 +44,7 @@ namespace Aaru.Gui } // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() => AppBuilder. - Configure().UsePlatformDetect().LogToDebug(). - UseReactiveUI().UseManagedSystemDialogs(); + public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure().UsePlatformDetect().LogToDebug(). + UseReactiveUI().UseManagedSystemDialogs(); } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs index 52b3737d9..7cd5affac 100644 --- a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -286,7 +286,7 @@ pool with no way of using them to identify you."; else Settings.Settings.Current.Stats = null; - Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel; + Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL; Settings.Settings.SaveSettings(); _view.Close(); } diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index 3808ca8b5..87ce15d63 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -245,10 +245,8 @@ namespace Aaru.Gui.ViewModels.Panels string corrected = new string(chars); mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Unsupported filename", - $"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?", - ButtonEnum.YesNoCancel, - Icon.Warning). - ShowDialog(_view); + $"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?", + ButtonEnum.YesNoCancel, Icon.Warning).ShowDialog(_view); if(mboxResult == ButtonResult.Cancel) return; @@ -264,9 +262,8 @@ namespace Aaru.Gui.ViewModels.Panels if(File.Exists(outputPath)) { mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Existing file", - $"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?", - ButtonEnum.YesNoCancel, - Icon.Warning).ShowDialog(_view); + $"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?", + ButtonEnum.YesNoCancel, Icon.Warning).ShowDialog(_view); if(mboxResult == ButtonResult.Cancel) return; @@ -281,9 +278,8 @@ namespace Aaru.Gui.ViewModels.Panels 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; @@ -299,9 +295,8 @@ namespace Aaru.Gui.ViewModels.Panels if(error != Errno.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; @@ -349,9 +344,8 @@ namespace Aaru.Gui.ViewModels.Panels 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/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index e8b5d41b2..a3905ec9f 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -594,9 +594,8 @@ namespace Aaru.Gui.ViewModels.Windows Name = scheme }; - foreach(CommonTypes.Partition partition in partitions. - Where(p => p.Scheme == scheme). - OrderBy(p => p.Start)) + foreach(CommonTypes.Partition partition in partitions.Where(p => p.Scheme == scheme). + OrderBy(p => p.Start)) { var partitionModel = new PartitionModel { @@ -771,9 +770,8 @@ namespace Aaru.Gui.ViewModels.Windows 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/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs index edeaddd84..3290265e1 100644 --- a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs @@ -216,7 +216,7 @@ namespace Aaru.Gui.ViewModels.Windows Message = "Checking GDPR compliance..."; AaruConsole.WriteLine("Checking GDPR compliance..."); - if(Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) + if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL) { var settingsDialog = new SettingsDialog(); var settingsDialogViewModel = new SettingsViewModel(settingsDialog, true); diff --git a/Aaru.Gui/Views/Panels/DeviceInfo.xaml b/Aaru.Gui/Views/Panels/DeviceInfo.xaml index 38d89162a..676cfd20d 100644 --- a/Aaru.Gui/Views/Panels/DeviceInfo.xaml +++ b/Aaru.Gui/Views/Panels/DeviceInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Panels/FileSystem.xaml b/Aaru.Gui/Views/Panels/FileSystem.xaml index 1eb05eddf..bec51155a 100644 --- a/Aaru.Gui/Views/Panels/FileSystem.xaml +++ b/Aaru.Gui/Views/Panels/FileSystem.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Panels/ImageInfo.xaml b/Aaru.Gui/Views/Panels/ImageInfo.xaml index 6007ed676..1091e83e5 100644 --- a/Aaru.Gui/Views/Panels/ImageInfo.xaml +++ b/Aaru.Gui/Views/Panels/ImageInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Panels/MediaInfo.xaml b/Aaru.Gui/Views/Panels/MediaInfo.xaml index 9cfe20349..0f109d33a 100644 --- a/Aaru.Gui/Views/Panels/MediaInfo.xaml +++ b/Aaru.Gui/Views/Panels/MediaInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Panels/Partition.xaml b/Aaru.Gui/Views/Panels/Partition.xaml index 03524546e..71b321fde 100644 --- a/Aaru.Gui/Views/Panels/Partition.xaml +++ b/Aaru.Gui/Views/Panels/Partition.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Panels/Subdirectory.xaml b/Aaru.Gui/Views/Panels/Subdirectory.xaml index 73259a3b4..fd21867af 100644 --- a/Aaru.Gui/Views/Panels/Subdirectory.xaml +++ b/Aaru.Gui/Views/Panels/Subdirectory.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/AtaInfo.xaml b/Aaru.Gui/Views/Tabs/AtaInfo.xaml index 718578486..726b2aadd 100644 --- a/Aaru.Gui/Views/Tabs/AtaInfo.xaml +++ b/Aaru.Gui/Views/Tabs/AtaInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/BlurayInfo.xaml b/Aaru.Gui/Views/Tabs/BlurayInfo.xaml index a7d5e9ea1..c90896279 100644 --- a/Aaru.Gui/Views/Tabs/BlurayInfo.xaml +++ b/Aaru.Gui/Views/Tabs/BlurayInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml index efac33788..e7389dfbb 100644 --- a/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml +++ b/Aaru.Gui/Views/Tabs/CompactDiscInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/DvdInfo.xaml b/Aaru.Gui/Views/Tabs/DvdInfo.xaml index ad3436978..8c567197c 100644 --- a/Aaru.Gui/Views/Tabs/DvdInfo.xaml +++ b/Aaru.Gui/Views/Tabs/DvdInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml index 043c56926..56ab0c1b6 100644 --- a/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml +++ b/Aaru.Gui/Views/Tabs/DvdWritableInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml index faf29249b..c28c87dbe 100644 --- a/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml +++ b/Aaru.Gui/Views/Tabs/PcmciaInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/ScsiInfo.xaml b/Aaru.Gui/Views/Tabs/ScsiInfo.xaml index b93bf7238..47e849248 100644 --- a/Aaru.Gui/Views/Tabs/ScsiInfo.xaml +++ b/Aaru.Gui/Views/Tabs/ScsiInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml b/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml index bdd439d65..f6be7602a 100644 --- a/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml +++ b/Aaru.Gui/Views/Tabs/SdMmcInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Gui/Views/Tabs/XboxInfo.xaml b/Aaru.Gui/Views/Tabs/XboxInfo.xaml index 4f7335e24..1c44aabff 100644 --- a/Aaru.Gui/Views/Tabs/XboxInfo.xaml +++ b/Aaru.Gui/Views/Tabs/XboxInfo.xaml @@ -34,7 +34,7 @@ diff --git a/Aaru.Helpers b/Aaru.Helpers index 9aad86a67..8dfdfafcb 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit 9aad86a6707ccf18950e2958e0a5a7447b378a22 +Subproject commit 8dfdfafcb366196aa132a247d3dfbfe23639912f diff --git a/Aaru.Images/AaruFormat/CdEcc.cs b/Aaru.Images/AaruFormat/CdEcc.cs index e56560a40..3ddd9b84e 100644 --- a/Aaru.Images/AaruFormat/CdEcc.cs +++ b/Aaru.Images/AaruFormat/CdEcc.cs @@ -164,7 +164,7 @@ namespace Aaru.DiscImages eccA = _eccBTable[_eccFTable[eccA] ^ eccB]; - if(ecc[major + eccOffset] != eccA || + if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) return false; } @@ -199,7 +199,7 @@ namespace Aaru.DiscImages } eccA = _eccBTable[_eccFTable[eccA] ^ eccB]; - ecc[major + eccOffset] = eccA; + ecc[major + eccOffset] = eccA; ecc[major + majorCount + eccOffset] = (byte)(eccA ^ eccB); } } diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs index 612d53ddb..86ab05d18 100644 --- a/Aaru.Images/AaruFormat/Verify.cs +++ b/Aaru.Images/AaruFormat/Verify.cs @@ -91,7 +91,7 @@ namespace Aaru.DiscImages } // Read up to 1MiB at a time for verification - const int VERIFY_SIZE = 1024 * 1024; + const int verifySize = 1024 * 1024; foreach(IndexEntry entry in vrIndex) { @@ -114,9 +114,9 @@ namespace Aaru.DiscImages "Verifying data block type {0} at position {1}", entry.dataType, entry.offset); - while(readBytes + VERIFY_SIZE < blockHeader.cmpLength) + while(readBytes + verifySize < blockHeader.cmpLength) { - verifyBytes = new byte[VERIFY_SIZE]; + verifyBytes = new byte[verifySize]; _imageStream.Read(verifyBytes, 0, verifyBytes.Length); crcVerify.Update(verifyBytes); readBytes += (ulong)verifyBytes.LongLength; @@ -150,7 +150,7 @@ namespace Aaru.DiscImages "Verifying deduplication table type {0} at position {1}", entry.dataType, entry.offset); - while(readBytes + VERIFY_SIZE < ddtHeader.cmpLength) + while(readBytes + verifySize < ddtHeader.cmpLength) { verifyBytes = new byte[readBytes]; _imageStream.Read(verifyBytes, 0, verifyBytes.Length); @@ -221,7 +221,7 @@ namespace Aaru.DiscImages failingLbas = new List(); unknownLbas = new List(); - // Right now only CompactDisc sectors are verifyable + // Right now only CompactDisc sectors are verifiable if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { for(ulong i = sectorAddress; i < sectorAddress + length; i++) @@ -263,7 +263,7 @@ namespace Aaru.DiscImages public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List failingLbas, out List unknownLbas) { - // Right now only CompactDisc sectors are verifyable + // Right now only CompactDisc sectors are verifiable if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { failingLbas = new List(); diff --git a/Aaru.Images/Alcohol120/Alcohol120.cs b/Aaru.Images/Alcohol120/Alcohol120.cs index 35419b781..ff9477d13 100644 --- a/Aaru.Images/Alcohol120/Alcohol120.cs +++ b/Aaru.Images/Alcohol120/Alcohol120.cs @@ -40,24 +40,24 @@ namespace Aaru.DiscImages { public sealed partial class Alcohol120 : IWritableOpticalImage { - AlcoholFooter _alcFooter; - IFilter _alcImage; - Dictionary _alcSessions; - Dictionary> _alcToc; - Dictionary _alcTrackExtras; - Dictionary _alcTracks; - byte[] _bca; - FileStream _descriptorStream; - byte[] _dmi; - byte[] _fullToc; - AlcoholHeader _header; - ImageInfo _imageInfo; - Stream _imageStream; - bool _isDvd; - Dictionary _offsetmap; - byte[] _pfi; - Dictionary _trackFlags; - List _writingTracks; + Footer _alcFooter; + IFilter _alcImage; + Dictionary _alcSessions; + Dictionary> _alcToc; + Dictionary _alcTrackExtras; + Dictionary _alcTracks; + byte[] _bca; + FileStream _descriptorStream; + byte[] _dmi; + byte[] _fullToc; + Header _header; + ImageInfo _imageInfo; + Stream _imageStream; + bool _isDvd; + Dictionary _offsetMap; + byte[] _pfi; + Dictionary _trackFlags; + List _writingTracks; public Alcohol120() => _imageInfo = new ImageInfo { diff --git a/Aaru.Images/Alcohol120/Enums.cs b/Aaru.Images/Alcohol120/Enums.cs index 727177a43..41886324a 100644 --- a/Aaru.Images/Alcohol120/Enums.cs +++ b/Aaru.Images/Alcohol120/Enums.cs @@ -37,21 +37,21 @@ namespace Aaru.DiscImages public sealed partial class Alcohol120 { [SuppressMessage("ReSharper", "InconsistentNaming")] - enum AlcoholMediumType : ushort + enum MediumType : ushort { CD = 0x00, CDR = 0x01, CDRW = 0x02, DVD = 0x10, DVDR = 0x12 } [SuppressMessage("ReSharper", "InconsistentNaming")] - enum AlcoholTrackMode : byte + enum TrackMode : byte { NoData = 0x00, DVD = 0x02, Audio = 0xA9, Mode1 = 0xAA, Mode2 = 0xAB, Mode2F1 = 0xEC, Mode2F2 = 0xED, Mode2F1Alt = 0xAC, Mode2F2Alt = 0xAD } - enum AlcoholSubchannelMode : byte + enum SubchannelMode : byte { None = 0x00, Interleaved = 0x08 } diff --git a/Aaru.Images/Alcohol120/Helpers.cs b/Aaru.Images/Alcohol120/Helpers.cs index 5120af47e..5f6515c30 100644 --- a/Aaru.Images/Alcohol120/Helpers.cs +++ b/Aaru.Images/Alcohol120/Helpers.cs @@ -37,51 +37,51 @@ namespace Aaru.DiscImages { public sealed partial class Alcohol120 { - static ushort AlcoholTrackModeToCookedBytesPerSector(AlcoholTrackMode trackMode) + static ushort TrackModeToCookedBytesPerSector(TrackMode trackMode) { switch(trackMode) { - case AlcoholTrackMode.Mode1: - case AlcoholTrackMode.Mode2F1: - case AlcoholTrackMode.Mode2F1Alt: return 2048; - case AlcoholTrackMode.Mode2F2: - case AlcoholTrackMode.Mode2F2Alt: return 2324; - case AlcoholTrackMode.Mode2: return 2336; - case AlcoholTrackMode.Audio: return 2352; - case AlcoholTrackMode.DVD: return 2048; - default: return 0; + case TrackMode.Mode1: + case TrackMode.Mode2F1: + case TrackMode.Mode2F1Alt: return 2048; + case TrackMode.Mode2F2: + case TrackMode.Mode2F2Alt: return 2324; + case TrackMode.Mode2: return 2336; + case TrackMode.Audio: return 2352; + case TrackMode.DVD: return 2048; + default: return 0; } } - static TrackType AlcoholTrackTypeToTrackType(AlcoholTrackMode trackType) + static TrackType TrackModeToTrackType(TrackMode trackType) { switch(trackType) { - case AlcoholTrackMode.Mode1: return TrackType.CdMode1; - case AlcoholTrackMode.Mode2F1: - case AlcoholTrackMode.Mode2F1Alt: return TrackType.CdMode2Form1; - case AlcoholTrackMode.Mode2F2: - case AlcoholTrackMode.Mode2F2Alt: return TrackType.CdMode2Form2; - case AlcoholTrackMode.Mode2: return TrackType.CdMode2Formless; - case AlcoholTrackMode.Audio: return TrackType.Audio; - default: return TrackType.Data; + case TrackMode.Mode1: return TrackType.CdMode1; + case TrackMode.Mode2F1: + case TrackMode.Mode2F1Alt: return TrackType.CdMode2Form1; + case TrackMode.Mode2F2: + case TrackMode.Mode2F2Alt: return TrackType.CdMode2Form2; + case TrackMode.Mode2: return TrackType.CdMode2Formless; + case TrackMode.Audio: return TrackType.Audio; + default: return TrackType.Data; } } - static MediaType AlcoholMediumTypeToMediaType(AlcoholMediumType discType) + static MediaType MediumTypeToMediaType(MediumType discType) { switch(discType) { - case AlcoholMediumType.CD: return MediaType.CD; - case AlcoholMediumType.CDR: return MediaType.CDR; - case AlcoholMediumType.CDRW: return MediaType.CDRW; - case AlcoholMediumType.DVD: return MediaType.DVDROM; - case AlcoholMediumType.DVDR: return MediaType.DVDR; - default: return MediaType.Unknown; + case MediumType.CD: return MediaType.CD; + case MediumType.CDR: return MediaType.CDR; + case MediumType.CDRW: return MediaType.CDRW; + case MediumType.DVD: return MediaType.DVDROM; + case MediumType.DVDR: return MediaType.DVDR; + default: return MediaType.Unknown; } } - static AlcoholMediumType MediaTypeToAlcohol(MediaType type) + static MediumType MediaTypeToMediumType(MediaType type) { switch(type) { @@ -118,31 +118,31 @@ namespace Aaru.DiscImages case MediaType.VideoNow: case MediaType.VideoNowColor: case MediaType.VideoNowXp: - case MediaType.CVD: return AlcoholMediumType.CD; - case MediaType.CDR: return AlcoholMediumType.CDR; + case MediaType.CVD: return MediumType.CD; + case MediaType.CDR: return MediumType.CDR; case MediaType.CDRW: - case MediaType.CDMRW: return AlcoholMediumType.CDRW; + case MediaType.CDMRW: return MediumType.CDRW; case MediaType.DVDR: case MediaType.DVDRW: case MediaType.DVDPR: case MediaType.DVDRDL: case MediaType.DVDRWDL: case MediaType.DVDPRDL: - case MediaType.DVDPRWDL: return AlcoholMediumType.DVDR; - default: return AlcoholMediumType.DVD; + case MediaType.DVDPRWDL: return MediumType.DVDR; + default: return MediumType.DVD; } } - static AlcoholTrackMode TrackTypeToAlcohol(TrackType type) + static TrackMode TrackTypeToTrackMode(TrackType type) { switch(type) { - case TrackType.Audio: return AlcoholTrackMode.Audio; - case TrackType.CdMode1: return AlcoholTrackMode.Mode1; - case TrackType.CdMode2Formless: return AlcoholTrackMode.Mode2; - case TrackType.CdMode2Form1: return AlcoholTrackMode.Mode2F1; - case TrackType.CdMode2Form2: return AlcoholTrackMode.Mode2F2; - default: return AlcoholTrackMode.DVD; + case TrackType.Audio: return TrackMode.Audio; + case TrackType.CdMode1: return TrackMode.Mode1; + case TrackType.CdMode2Formless: return TrackMode.Mode2; + case TrackType.CdMode2Form1: return TrackMode.Mode2F1; + case TrackType.CdMode2Form2: return TrackMode.Mode2F2; + default: return TrackMode.DVD; } } diff --git a/Aaru.Images/Alcohol120/Identify.cs b/Aaru.Images/Alcohol120/Identify.cs index 3067ee2e5..95f02deea 100644 --- a/Aaru.Images/Alcohol120/Identify.cs +++ b/Aaru.Images/Alcohol120/Identify.cs @@ -49,7 +49,7 @@ namespace Aaru.DiscImages byte[] hdr = new byte[88]; stream.Read(hdr, 0, 88); - AlcoholHeader header = Marshal.ByteArrayToStructureLittleEndian(hdr); + Header header = Marshal.ByteArrayToStructureLittleEndian
(hdr); return header.signature.SequenceEqual(_alcoholSignature) && header.version[0] <= _maximumSupportedVersion; } diff --git a/Aaru.Images/Alcohol120/Properties.cs b/Aaru.Images/Alcohol120/Properties.cs index 8ea5db66b..8e75a728d 100644 --- a/Aaru.Images/Alcohol120/Properties.cs +++ b/Aaru.Images/Alcohol120/Properties.cs @@ -61,36 +61,36 @@ namespace Aaru.DiscImages public List Partitions { get; private set; } - public List Tracks + public List Tracks { get { - List tracks = new List(); + List tracks = new List(); - foreach(AlcoholTrack alcTrack in _alcTracks.Values) + foreach(Track alcTrack in _alcTracks.Values) { ushort sessionNo = (from session in Sessions where alcTrack.point >= session.StartTrack || alcTrack.point <= session.EndTrack select session.SessionSequence).FirstOrDefault(); - if(!_alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra)) + if(!_alcTrackExtras.TryGetValue(alcTrack.point, out TrackExtra alcExtra)) continue; - var aaruTrack = new Track + var aaruTrack = new CommonTypes.Structs.Track { TrackStartSector = alcTrack.startLba, TrackEndSector = (alcTrack.startLba + alcExtra.sectors) - 1, TrackPregap = alcExtra.pregap, TrackSession = sessionNo, TrackSequence = alcTrack.point, - TrackType = AlcoholTrackTypeToTrackType(alcTrack.mode), + TrackType = TrackModeToTrackType(alcTrack.mode), TrackFilter = _alcImage, TrackFile = _alcImage.GetFilename(), TrackFileOffset = alcTrack.startOffset, TrackFileType = "BINARY", TrackRawBytesPerSector = alcTrack.sectorSize, - TrackBytesPerSector = AlcoholTrackModeToCookedBytesPerSector(alcTrack.mode) + TrackBytesPerSector = TrackModeToCookedBytesPerSector(alcTrack.mode) }; if(alcExtra.pregap > 0) @@ -100,22 +100,22 @@ namespace Aaru.DiscImages switch(alcTrack.subMode) { - case AlcoholSubchannelMode.Interleaved: + case SubchannelMode.Interleaved: aaruTrack.TrackSubchannelFilter = _alcImage; aaruTrack.TrackSubchannelFile = _alcImage.GetFilename(); aaruTrack.TrackSubchannelOffset = alcTrack.startOffset; aaruTrack.TrackSubchannelType = TrackSubchannelType.RawInterleaved; break; - case AlcoholSubchannelMode.None: + case SubchannelMode.None: aaruTrack.TrackSubchannelType = TrackSubchannelType.None; break; } - if(_header.type != AlcoholMediumType.CD && - _header.type != AlcoholMediumType.CDR && - _header.type != AlcoholMediumType.CDRW) + if(_header.type != MediumType.CD && + _header.type != MediumType.CDR && + _header.type != MediumType.CDRW) { aaruTrack.TrackPregap = 0; aaruTrack.Indexes?.Clear(); @@ -128,7 +128,7 @@ namespace Aaru.DiscImages } } - public List Sessions { get; private set; } + public List Sessions { get; private set; } public List DumpHardware => null; public CICMMetadataType CicmMetadata => null; diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index 111b14aa3..91b655b22 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -39,13 +39,11 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Exceptions; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Decoders.CD; using Aaru.Decoders.DVD; using Aaru.Helpers; using DMI = Aaru.Decoders.Xbox.DMI; -using Session = Aaru.CommonTypes.Structs.Session; namespace Aaru.DiscImages { @@ -62,7 +60,7 @@ namespace Aaru.DiscImages _isDvd = false; byte[] hdr = new byte[88]; stream.Read(hdr, 0, 88); - _header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian
(hdr); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.signature = {0}", Encoding.ASCII.GetString(_header.signature)); @@ -103,13 +101,13 @@ namespace Aaru.DiscImages return false; stream.Seek(_header.sessionOffset, SeekOrigin.Begin); - _alcSessions = new Dictionary(); + _alcSessions = new Dictionary(); for(int i = 0; i < _header.sessions; i++) { byte[] sesHdr = new byte[24]; stream.Read(sesHdr, 0, 24); - AlcoholSession session = Marshal.SpanToStructureLittleEndian(sesHdr); + Session session = Marshal.SpanToStructureLittleEndian(sesHdr); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].sessionStart = {0}", session.sessionStart, i); @@ -142,22 +140,22 @@ namespace Aaru.DiscImages long footerOff = 0; bool oldIncorrectImage = false; - _alcTracks = new Dictionary(); - _alcToc = new Dictionary>(); + _alcTracks = new Dictionary(); + _alcToc = new Dictionary>(); - foreach(AlcoholSession session in _alcSessions.Values) + foreach(Session session in _alcSessions.Values) { stream.Seek(session.trackOffset, SeekOrigin.Begin); - Dictionary sesToc = new Dictionary(); + Dictionary sesToc = new Dictionary(); for(int i = 0; i < session.allBlocks; i++) { byte[] trkHdr = new byte[80]; stream.Read(trkHdr, 0, 80); - AlcoholTrack track = Marshal.ByteArrayToStructureLittleEndian(trkHdr); + Track track = Marshal.ByteArrayToStructureLittleEndian(trkHdr); - if(track.mode == AlcoholTrackMode.Mode2F1Alt || - track.mode == AlcoholTrackMode.Mode2F1Alt) + if(track.mode == TrackMode.Mode2F1Alt || + track.mode == TrackMode.Mode2F1Alt) oldIncorrectImage = true; // Solve our own mistake here, sorry, but anyway seems Alcohol doesn't support DDCD @@ -229,7 +227,7 @@ namespace Aaru.DiscImages //for(int j = 0; j < track.unknown2.Length; j++) // AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{2}].track[{1}].unknown2[{2}] = {0}", track.unknown2[j], i, j, session.sessionSequence); - if(track.subMode == AlcoholSubchannelMode.Interleaved) + if(track.subMode == SubchannelMode.Interleaved) track.sectorSize -= 96; if(!sesToc.ContainsKey(track.point)) @@ -241,22 +239,22 @@ namespace Aaru.DiscImages if(footerOff == 0) footerOff = track.footerOffset; - _isDvd |= track.mode == AlcoholTrackMode.DVD; + _isDvd |= track.mode == TrackMode.DVD; } _alcToc.Add(session.sessionSequence, sesToc); } - _alcTrackExtras = new Dictionary(); + _alcTrackExtras = new Dictionary(); - foreach(AlcoholTrack track in _alcTracks.Values) + foreach(Track track in _alcTracks.Values) if(track.extraOffset > 0 && !_isDvd) { byte[] extHdr = new byte[8]; stream.Seek(track.extraOffset, SeekOrigin.Begin); stream.Read(extHdr, 0, 8); - AlcoholTrackExtra extra = Marshal.SpanToStructureLittleEndian(extHdr); + TrackExtra extra = Marshal.SpanToStructureLittleEndian(extHdr); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "track[{1}].extra.pregap = {0}", extra.pregap, track.point); @@ -268,7 +266,7 @@ namespace Aaru.DiscImages } else if(_isDvd) { - var extra = new AlcoholTrackExtra + var extra = new TrackExtra { sectors = track.extraOffset }; @@ -281,7 +279,7 @@ namespace Aaru.DiscImages byte[] footer = new byte[16]; stream.Seek(footerOff, SeekOrigin.Begin); stream.Read(footer, 0, 16); - _alcFooter = Marshal.SpanToStructureLittleEndian(footer); + _alcFooter = Marshal.SpanToStructureLittleEndian