diff --git a/Aaru.Checksums b/Aaru.Checksums index 695b9275e..a9af82e47 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit 695b9275ee69251c7ca66b5fafaff5de039263a9 +Subproject commit a9af82e47ff6d611789bb4f42e8b8b73c8bce6c0 diff --git a/Aaru.Compression/ADC.cs b/Aaru.Compression/ADC.cs index 42f0dabcd..071f03c58 100644 --- a/Aaru.Compression/ADC.cs +++ b/Aaru.Compression/ADC.cs @@ -90,17 +90,18 @@ public static class ADC return AARU_adc_decode_buffer(destination, destination.Length, source, source.Length); var inputPosition = 0; - int chunkSize; - int offset; - int chunkType; - var outPosition = 0; - Span temp = stackalloc byte[3]; + var outPosition = 0; + Span temp = stackalloc byte[3]; while(inputPosition < source.Length) { byte readByte = source[inputPosition++]; - chunkType = GetChunkType(readByte); + int chunkType = GetChunkType(readByte); + + int chunkSize; + + int offset; switch(chunkType) { diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 2660879df..74fab4275 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -57,8 +57,6 @@ public partial class Dump /// Dumps an ATA device void Ata() { - bool recoveredError; - if(_outputPlugin is not IWritableImage outputFormat) { StoppingErrorMessage?.Invoke("Image is not writable, aborting..."); @@ -248,6 +246,8 @@ public partial class Dump // Setting geometry outputFormat.SetGeometry(cylinders, heads, sectors); + bool recoveredError; + if(ataReader.IsLba) { UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time."); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index acf4d4e3e..ff3cf98c4 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -85,8 +85,7 @@ partial class Dump double currentSpeed = 0; double maxSpeed = double.MinValue; double minSpeed = double.MaxValue; - byte[] readBuffer; - Modes.DecodedMode? decMode = null; + Modes.DecodedMode? decMode = null; bool ret; ExtentsULong blankExtents = null; var outputFormat = _outputPlugin as IWritableImage; @@ -376,6 +375,8 @@ partial class Dump { if(outputFormat is IWritableOpticalImage opticalPlugin) { + byte[] readBuffer; + sense = _dev.ReadDiscInformation(out readBuffer, out _, MmcDiscInformationDataTypes.DiscInformation, _dev.Timeout, out _); diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index b7a04d0e6..bb6568fb0 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -200,7 +200,6 @@ public static class CompactDisc subLog.WriteRwFix(lba); } - byte smin, ssec, amin, asec, aframe; int aPos; // Fix Q @@ -258,20 +257,20 @@ public static class CompactDisc !rwOk) continue; - aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); if((q[0] & 0x3) == 1) { - amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); - asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); aPos = amin * 60 * 75 + asec * 75 + aframe - 150; } else { ulong expectedSectorAddress = sectorAddress + (ulong)(subPos / 96) + 150; - smin = (byte)(expectedSectorAddress / 60 / 75); + var smin = (byte)(expectedSectorAddress / 60 / 75); expectedSectorAddress -= (ulong)(smin * 60 * 75); - ssec = (byte)(expectedSectorAddress / 75); + var ssec = (byte)(expectedSectorAddress / 75); aPos = smin * 60 * 75 + ssec * 75 + aframe - 150; @@ -875,9 +874,8 @@ public static class CompactDisc out bool fixedIndex, out bool fixedRelPos, out bool fixedAbsPos, out bool fixedCrc, out bool fixedMcn, out bool fixedIsrc) { - byte amin, asec, aframe, pmin, psec, pframe; - byte rmin, rsec, rframe; - int aPos, rPos, pPos, dPos; + byte aframe; + byte rframe; controlFix = false; fixedZero = false; fixedTno = false; @@ -1049,18 +1047,26 @@ public static class CompactDisc 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; + var amin = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + var asec = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); + aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); + int 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; + var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + var pframe = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + int pPos = pmin * 60 * 75 + psec * 75 + pframe; // TODO: pregap // Not pregap + byte rmin; + + byte rsec; + + int rPos; + + int dPos; + if(q[2] > 0) { // Previous was not pregap either diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index b163b9475..2affc9ceb 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -48,8 +48,6 @@ public sealed partial class CPM /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - ErrorNumber errno; - // This will only continue on devices with a chance to have ever been used by CP/M while failing on all others // It's ugly, but will stop a lot of false positives switch(imagePlugin.Info.MediaType) @@ -172,6 +170,8 @@ public sealed partial class CPM _label = null; // Try Amstrad superblock + ErrorNumber errno; + if(!_cpmFound) { // Read CHS = {0,0,1} diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index 14599604e..04a40cbea 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -61,7 +61,6 @@ public sealed partial class FAT public ErrorNumber ReadDir(string path, out List contents) { contents = null; - ErrorNumber errno; if(!_mounted) return ErrorNumber.AccessDenied; @@ -139,8 +138,8 @@ public sealed partial class FAT for(var i = 0; i < clusters.Length; i++) { - errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, _sectorsPerCluster, - out byte[] buffer); + ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i] * _sectorsPerCluster, _sectorsPerCluster, + out byte[] buffer); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 2ffa8acbf..d9403e30e 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -91,8 +91,6 @@ public sealed partial class FAT /// public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { - ErrorNumber errno; - if(!_mounted) return ErrorNumber.AccessDenied; @@ -137,8 +135,8 @@ public sealed partial class FAT if(i + firstCluster >= clusters.Length) return ErrorNumber.InvalidArgument; - errno = _image.ReadSectors(_firstClusterSector + clusters[i + firstCluster] * _sectorsPerCluster, - _sectorsPerCluster, out byte[] buffer); + ErrorNumber errno = _image.ReadSectors(_firstClusterSector + clusters[i + firstCluster] * _sectorsPerCluster, + _sectorsPerCluster, out byte[] buffer); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index d01810e28..25eab31b5 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -542,7 +542,6 @@ public sealed partial class ISO9660 hasResourceFork = false; var continueSymlink = false; var continueSymlinkComponent = false; - AppleCommon.FInfo fInfo; while(systemAreaOff + 2 <= end) { @@ -551,6 +550,8 @@ public sealed partial class ISO9660 if(BigEndianBitConverter.ToUInt16(data, systemAreaOff + 6) == XA_MAGIC) systemAreaSignature = XA_MAGIC; + AppleCommon.FInfo fInfo; + switch(systemAreaSignature) { case APPLE_MAGIC: diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index da1498beb..cebd285a6 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -387,7 +387,6 @@ public sealed partial class LisaFS ErrorNumber ReadFile(short fileId, out byte[] buf, bool tags) { buf = null; - ErrorNumber errno; if(!_mounted) return ErrorNumber.AccessDenied; @@ -422,11 +421,11 @@ public sealed partial class LisaFS { byte[] sector; - errno = !tags ? _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, - (uint)file.extents[i].length, out sector) - : _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, - (uint)file.extents[i].length, SectorTagType.AppleSectorTag, - out sector); + ErrorNumber errno = !tags ? _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + (uint)file.extents[i].length, out sector) + : _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + (uint)file.extents[i].length, SectorTagType.AppleSectorTag, + out sector); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs index 50955a8eb..651f7b046 100644 --- a/Aaru.Filesystems/LisaFS/Info.cs +++ b/Aaru.Filesystems/LisaFS/Info.cs @@ -49,8 +49,6 @@ public sealed partial class LisaFS /// public bool Identify(IMediaImage imagePlugin, Partition partition) { - ErrorNumber errno; - if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) return false; @@ -63,7 +61,7 @@ public sealed partial class LisaFS // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(var i = 0; i < 100; i++) { - errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); + ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; @@ -137,7 +135,6 @@ public sealed partial class LisaFS Encoding = new LisaRoman(); information = ""; var sb = new StringBuilder(); - ErrorNumber errno; if(imagePlugin.Info.ReadableSectorTags?.Contains(SectorTagType.AppleSectorTag) != true) return; @@ -151,7 +148,7 @@ public sealed partial class LisaFS // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(var i = 0; i < 100; i++) { - errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); + ErrorNumber errno = imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag, out byte[] tag); if(errno != ErrorNumber.NoError) continue; diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index 4e91b22d2..0a367b697 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -119,8 +119,6 @@ public sealed class SubdirectoryViewModel if(SelectedEntries.Count == 0) return; - ButtonResult mboxResult; - var saveFilesFolderDialog = new OpenFolderDialog { Title = "Choose destination folder..." @@ -139,6 +137,8 @@ public sealed class SubdirectoryViewModel { string filename = file.Name; + ButtonResult mboxResult; + if(DetectOS.IsWindows) if(filename.Contains('<') || filename.Contains('>') || diff --git a/Aaru.Helpers b/Aaru.Helpers index 70e03d4ef..c1196f636 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit 70e03d4efbe416e87420aa22435f194295fe2cec +Subproject commit c1196f636d12431c3c3637cffa7a3b2585ed9a7a diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs index e92aa32c2..8e353647e 100644 --- a/Aaru.Images/AaruFormat/Read.cs +++ b/Aaru.Images/AaruFormat/Read.cs @@ -1955,7 +1955,6 @@ public sealed partial class AaruFormat /// public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) { - ErrorNumber errno; buffer = null; switch(_imageInfo.XmlMediaType) @@ -1976,7 +1975,7 @@ public sealed partial class AaruFormat return ReadSector(sectorAddress, out buffer); buffer = new byte[2352]; - errno = ReadSector(sectorAddress, out byte[] data); + ErrorNumber errno = ReadSector(sectorAddress, out byte[] data); if(errno != ErrorNumber.NoError) return errno; diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index ccdc58a5b..5bf851570 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -2584,15 +2584,14 @@ public sealed partial class AaruFormat var cmpBuffer = new byte[mediaTag.Value.Length + 262144]; - int cmpLen; byte[] lzmaProperties = null; var doNotCompress = false; switch(_compressionAlgorithm) { case CompressionType.Lzma: - cmpLen = LZMA.EncodeBuffer(mediaTag.Value, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, 0, - 2, 273); + int cmpLen = LZMA.EncodeBuffer(mediaTag.Value, cmpBuffer, out lzmaProperties, 9, _dictionarySize, 4, 0, + 2, 273); if(cmpLen + LZMA_PROPERTIES_LENGTH > mediaTag.Value.Length) doNotCompress = true; diff --git a/Aaru.Images/WCDiskImage/Read.cs b/Aaru.Images/WCDiskImage/Read.cs index 2032b7c4a..1ac40e371 100644 --- a/Aaru.Images/WCDiskImage/Read.cs +++ b/Aaru.Images/WCDiskImage/Read.cs @@ -241,10 +241,6 @@ public sealed partial class WCDiskImage /// The head number of the track being read. ErrorNumber ReadTrack(Stream stream, int cyl, int head) { - byte[] sectorData; - byte[] crc; - short calculatedCRC; - for(var sect = 1; sect < _imageInfo.SectorsPerTrack + 1; sect++) { /* read the sector header */ @@ -264,7 +260,7 @@ public sealed partial class WCDiskImage return ErrorNumber.InvalidArgument; } - sectorData = new byte[512]; + var sectorData = new byte[512]; /* read the sector data */ switch(sheader.flag) @@ -272,8 +268,9 @@ public sealed partial class WCDiskImage case SectorFlag.Normal: /* read a normal sector and store it in cache */ stream.Read(sectorData, 0, 512); _sectorCache[(cyl, head, sect)] = sectorData; + byte[] crc; CRC16IBMContext.Data(sectorData, 512, out crc); - calculatedCRC = (short)((256 * crc[0]) | crc[1]); + var calculatedCRC = (short)((256 * crc[0]) | crc[1]); /* AaruConsole.DebugWriteLine("d2f plugin", "CHS {0},{1},{2}: Regular sector, stored CRC=0x{3:x4}, calculated CRC=0x{4:x4}", cyl, head, sect, sheader.crc, 256 * crc[0] + crc[1]); diff --git a/Aaru.Tests/Issues/ImageReadIssueTest.cs b/Aaru.Tests/Issues/ImageReadIssueTest.cs index 50c5629a2..0f233623a 100644 --- a/Aaru.Tests/Issues/ImageReadIssueTest.cs +++ b/Aaru.Tests/Issues/ImageReadIssueTest.cs @@ -37,12 +37,13 @@ public abstract class ImageReadIssueTest ulong doneSectors = 0; var ctx = new Crc32Context(); - ErrorNumber errno; while(doneSectors < image.Info.Sectors) { byte[] sector; + ErrorNumber errno; + if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) { errno = image.ReadSectors(doneSectors, SECTORS_TO_READ, out sector); diff --git a/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs b/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs index e79444ed1..8d776b456 100644 --- a/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs +++ b/Aaru.Tests/Issues/OpticalImageReadIssueTest.cs @@ -46,7 +46,6 @@ public abstract class OpticalImageReadIssueTest ulong previousTrackEnd = 0; List inputTracks = opticalInput.Tracks; - ErrorNumber errno; foreach(Track currentTrack in inputTracks) { @@ -57,6 +56,8 @@ public abstract class OpticalImageReadIssueTest { byte[] sector; + ErrorNumber errno; + if(sectors - doneSectors >= SECTORS_TO_READ) { errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ, currentTrack.Sequence, out sector);