diff --git a/Aaru.CommonTypes/Interfaces/IWritableImage.cs b/Aaru.CommonTypes/Interfaces/IWritableImage.cs index 853051470..7314fa484 100644 --- a/Aaru.CommonTypes/Interfaces/IWritableImage.cs +++ b/Aaru.CommonTypes/Interfaces/IWritableImage.cs @@ -65,28 +65,32 @@ public interface IWritableImage : IMediaImage, IBaseWritableImage /// Writes a sector to the image /// Sector data /// Sector address + /// /// true if operating completed successfully, false otherwise - bool WriteSector(byte[] data, ulong sectorAddress); + bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus); /// Writes a sector to the image with main channel tags attached /// Sector data with its main channel tags attached /// Sector address + /// /// true if operating completed successfully, false otherwise - bool WriteSectorLong(byte[] data, ulong sectorAddress); + bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus); /// Writes several sectors to the image /// Sectors data /// Sector starting address /// How many sectors to write + /// /// true if operating completed successfully, false otherwise - bool WriteSectors(byte[] data, ulong sectorAddress, uint length); + bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus); /// Writes several sectors to the image /// Sector data with their main channel tags attached /// Sector starting address /// How many sectors to write + /// /// true if operating completed successfully, false otherwise - bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length); + bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus); /// Writes parallel or subchannel sector tag for several sector /// Tag data to write diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index defe8eb85..59ec8f409 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -197,7 +197,7 @@ public partial class Dump IbgLog ibgLog; double duration; - bool ret = true; + var ret = true; if(_dev.IsUsb && _dev.UsbDescriptors != null && @@ -294,7 +294,7 @@ public partial class Dump _mediaGraph?.PaintSectorsBad(_resume.BadBlocks); } - bool newTrim = false; + var newTrim = false; _dumpStopwatch.Restart(); _speedStopwatch.Reset(); @@ -336,7 +336,13 @@ public partial class Dump { mhddLog.Write(i, duration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); - outputFormat.WriteSectors(cmdBuf, i, blocksToRead); + + outputFormat.WriteSectors(cmdBuf, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -350,7 +356,13 @@ public partial class Dump mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip); ibgLog.Write(i, 0); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead) + .ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; UpdateProgress?.Invoke(Localization.Core.Skipping_0_blocks_from_errored_block_1, @@ -436,7 +448,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector); + outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -453,8 +465,8 @@ public partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; InitProgress?.Invoke(); repeatRetryLba: @@ -504,7 +516,7 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector); + outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core @@ -512,7 +524,7 @@ public partial class Dump badSector, pass)); } - else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector); + else if(_persistent) outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -613,7 +625,9 @@ public partial class Dump mhddLog.Write(currentBlock, duration); ibgLog.Write(currentBlock, currentSpeed * 1024); - outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1))); + outputFormat.WriteSector(cmdBuf, + (ulong)((cy * heads + hd) * sectors + (sc - 1)), + SectorStatus.Dumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(currentBlock); @@ -627,7 +641,8 @@ public partial class Dump ibgLog.Write(currentBlock, 0); outputFormat.WriteSector(new byte[blockSize], - (ulong)((cy * heads + hd) * sectors + (sc - 1))); + (ulong)((cy * heads + hd) * sectors + (sc - 1)), + SectorStatus.Errored); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index 39cc6543f..c5d73b3e4 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.Core.Logging; @@ -60,7 +61,7 @@ partial class Dump byte[] syncMark = [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00]; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; Array.Copy(sector, 0, testMark, 0, 12); return syncMark.SequenceEqual(testMark) && (sector[0xF] == 0 || sector[0xF] == 1 || sector[0xF] == 2); @@ -79,9 +80,9 @@ partial class Dump byte[] syncMark = [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00]; - byte[] testMark = new byte[12]; + var testMark = new byte[12]; - for(int i = 0; i <= 2336; i++) + for(var i = 0; i <= 2336; i++) { Array.Copy(sector, i, testMark, 0, 12); @@ -179,7 +180,7 @@ partial class Dump break; } - uint firstSectorToRead = (uint)i; + var firstSectorToRead = (uint)i; blocksToRead = _maximumReadable; @@ -288,8 +289,8 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); @@ -297,7 +298,10 @@ partial class Dump if(cdiReadyReadAsAudio) data = Sector.Scramble(data); - outputOptical.WriteSectorsLong(data, i + r, 1); + outputOptical.WriteSectorsLong(data, + i + r, + 1, + Enumerable.Repeat(SectorStatus.Dumped, 1).ToArray()); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -329,7 +333,7 @@ partial class Dump } } else - outputOptical.WriteSectorsLong(cmdBuf, i + r, 1); + outputOptical.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; @@ -386,11 +390,11 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * blocksToRead]; - byte[] sub = new byte[subSize * blocksToRead]; - byte[] tmpData = new byte[sectorSize]; + var data = new byte[sectorSize * blocksToRead]; + var sub = new byte[subSize * blocksToRead]; + var tmpData = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { if(cdiReadyReadAsAudio) { @@ -404,7 +408,10 @@ partial class Dump Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } - outputOptical.WriteSectorsLong(data, i, blocksToRead); + outputOptical.WriteSectorsLong(data, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -447,20 +454,28 @@ partial class Dump { if(cdiReadyReadAsAudio) { - byte[] tmpData = new byte[sectorSize]; - byte[] data = new byte[sectorSize * blocksToRead]; + var tmpData = new byte[sectorSize]; + var data = new byte[sectorSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), tmpData, 0, sectorSize); tmpData = Sector.Scramble(tmpData); Array.Copy(tmpData, 0, data, sectorSize * b, sectorSize); } - outputOptical.WriteSectorsLong(data, i, blocksToRead); + outputOptical.WriteSectorsLong(data, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); } else - outputOptical.WriteSectorsLong(cmdBuf, i, blocksToRead); + outputOptical.WriteSectorsLong(cmdBuf, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); } imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 7a836c9f7..3613979a0 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -103,7 +103,7 @@ partial class Dump { ulong sectorSpeedStart = 0; // Used to calculate correct speed uint blocksToRead; // How many sectors to read at once - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer ReadOnlySpan senseBuf = null; // Sense buffer double cmdDuration = 0; // Command execution time @@ -122,10 +122,10 @@ partial class Dump InitProgress?.Invoke(); - int currentReadSpeed = _speed; - bool crossingLeadOut = false; - bool failedCrossingLeadOut = false; - bool skippingLead = false; + int currentReadSpeed = _speed; + var crossingLeadOut = false; + var failedCrossingLeadOut = false; + var skippingLead = false; for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead) { @@ -145,7 +145,7 @@ partial class Dump if((long)i > lastSector) break; - uint firstSectorToRead = (uint)i; + var firstSectorToRead = (uint)i; Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => i >= t.StartSector); @@ -310,10 +310,10 @@ partial class Dump // Try to workaround firmware if(decSense?.ASC == 0x64) { - bool goBackTrackTypeChange = false; + var goBackTrackTypeChange = false; // Go one for one as the drive does not tell us which one failed - for(int bi = 0; bi < blocksToRead; bi++) + for(var bi = 0; bi < blocksToRead; bi++) { _speedStopwatch.Start(); @@ -584,7 +584,7 @@ partial class Dump if(_supportsPlextorD8) { - int adjustment = 0; + var adjustment = 0; if(offsetBytes < 0) adjustment = -sectorsForOffset; @@ -604,7 +604,7 @@ partial class Dump if(!sense) { - uint sectorsForFix = (uint)(1 + sectorsForOffset); + var sectorsForFix = (uint)(1 + sectorsForOffset); FixOffsetData(offsetBytes, sectorSize, @@ -630,7 +630,7 @@ partial class Dump { case 0: - for(int c = 16; c < 2352; c++) + for(var c = 16; c < 2352; c++) { if(cmdBuf[c] == 0x00) continue; @@ -768,28 +768,36 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputFormat.WriteSectorsLong(data, i + r, 1); + outputFormat.WriteSectorsLong(data, + i + r, + 1, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } - outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead); + outputFormat.WriteSectors(cooked.ToArray(), + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); } bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, @@ -836,20 +844,24 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(cmdBuf, i + r, 1); + outputFormat.WriteSectorsLong(cmdBuf, i + r, 1, [SectorStatus.Dumped]); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } - outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead); + outputFormat.WriteSectors(cooked.ToArray(), + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); } } @@ -866,7 +878,7 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputFormat.WriteSectorsLong(new byte[sectorSize], i + r, 1); + outputFormat.WriteSectorsLong(new byte[sectorSize], i + r, 1, [SectorStatus.Errored]); if(desiredSubchannel != MmcSubchannel.None) { @@ -879,13 +891,16 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1); + outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1, [SectorStatus.Errored]); else { if(cmdBuf.Length % sectorSize == 0) - outputFormat.WriteSectors(new byte[2048], i + r, 1); + outputFormat.WriteSectors(new byte[2048], i + r, 1, [SectorStatus.Errored]); else - outputFormat.WriteSectorsLong(new byte[blockSize], i + r, 1); + outputFormat.WriteSectorsLong(new byte[blockSize], + i + r, + 1, + [SectorStatus.Errored]); } } @@ -926,7 +941,7 @@ partial class Dump { if(crossingLeadOut && failedCrossingLeadOut) { - byte[] tmp = new byte[cmdBuf.Length + blockSize]; + var tmp = new byte[cmdBuf.Length + blockSize]; Array.Copy(cmdBuf, 0, tmp, 0, cmdBuf.Length); } @@ -951,10 +966,10 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * blocksToRead]; - byte[] sub = new byte[subSize * blocksToRead]; + var data = new byte[sectorSize * blocksToRead]; + var sub = new byte[subSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); @@ -962,20 +977,27 @@ partial class Dump } if(supportsLongSectors) - outputFormat.WriteSectorsLong(data, i, blocksToRead); + outputFormat.WriteSectorsLong(data, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } - outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead); + outputFormat.WriteSectors(cooked.ToArray(), + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); } bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, @@ -1021,20 +1043,27 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(cmdBuf, i, blocksToRead); + outputFormat.WriteSectorsLong(cmdBuf, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead) + .ToArray()); else { - var cooked = new MemoryStream(); - byte[] sector = new byte[sectorSize]; + var cooked = new MemoryStream(); + var sector = new byte[sectorSize]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize); byte[] cookedSector = Sector.GetUserData(sector); cooked.Write(cookedSector, 0, cookedSector.Length); } - outputFormat.WriteSectors(cooked.ToArray(), i, blocksToRead); + outputFormat.WriteSectors(cooked.ToArray(), + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); } } @@ -1066,7 +1095,10 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputFormat.WriteSectorsLong(new byte[sectorSize * _skip], i, _skip); + outputFormat.WriteSectorsLong(new byte[sectorSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); if(desiredSubchannel != MmcSubchannel.None) { @@ -1079,13 +1111,23 @@ partial class Dump else { if(supportsLongSectors) - outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip); + outputFormat.WriteSectorsLong(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); else { if(cmdBuf.Length % sectorSize == 0) - outputFormat.WriteSectors(new byte[2048 * _skip], i, _skip); + outputFormat.WriteSectors(new byte[2048 * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); else - outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip); + outputFormat.WriteSectorsLong(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip) + .ToArray()); } } diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index dddf745a0..d0b830dc9 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using System.Linq; using Aaru.Checksums; using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs.Devices.SCSI; @@ -80,7 +81,7 @@ partial class Dump ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack, bool supportsLongSectors) { - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration; // Command execution time const uint sectorSize = 2352; // Full sector size @@ -98,9 +99,9 @@ partial class Dump if(_resume.BadBlocks.Count <= 0 || _aborted || _retryPasses <= 0) return; - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -217,7 +218,7 @@ partial class Dump ulong[] tmpArray = _resume.BadBlocks.ToArray(); List sectorsNotEvenPartial = []; - for(int i = 0; i < tmpArray.Length; i++) + for(var i = 0; i < tmpArray.Length; i++) { ulong badSector = tmpArray[i]; @@ -255,7 +256,7 @@ partial class Dump Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); byte sectorsToReRead = 1; - uint badSectorToReRead = (uint)badSector; + var badSectorToReRead = (uint)badSector; if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0) { @@ -421,7 +422,7 @@ partial class Dump { case 0: - for(int c = 16; c < 2352; c++) + for(var c = 16; c < 2352; c++) { if(cmdBuf[c] == 0x00) continue; @@ -465,8 +466,9 @@ partial class Dump // MEDIUM ERROR, retry with ignore error below if(decSense is { ASC: 0x11 }) - if(!sectorsNotEvenPartial.Contains(badSector)) - sectorsNotEvenPartial.Add(badSector); + { + if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector); + } } // Because one block has been partially used to fix the offset @@ -502,15 +504,15 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector); + outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -541,9 +543,9 @@ partial class Dump else { if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector); + outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped); } } @@ -605,7 +607,7 @@ partial class Dump InitProgress?.Invoke(); - for(int i = 0; i < sectorsNotEvenPartial.Count; i++) + for(var i = 0; i < sectorsNotEvenPartial.Count; i++) { ulong badSector = sectorsNotEvenPartial[i]; @@ -655,15 +657,15 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector); + outputOptical.WriteSectorLong(data, badSector, SectorStatus.Errored); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Errored); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -694,9 +696,9 @@ partial class Dump else { if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector); + outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Errored); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Errored); } } @@ -741,7 +743,7 @@ partial class Dump Dictionary isrcs, ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) { - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration; // Command execution time ReadOnlySpan senseBuf = null; // Sense buffer @@ -760,8 +762,8 @@ partial class Dump if(_aborted) return; - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; InitProgress?.Invoke(); @@ -777,7 +779,7 @@ partial class Dump foreach(int bs in tmpArray) { - uint badSector = (uint)bs; + var badSector = (uint)bs; Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index f8fc7bf2d..6df702f36 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -92,7 +92,7 @@ partial class Dump { byte[] cmdBuf = null; // Data buffer const uint sectorSize = 2352; // Full sector size - bool sense = true; // Sense indicator + var sense = true; // Sense indicator ReadOnlySpan senseBuf = null; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -205,17 +205,21 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * _maximumReadable]; - byte[] sub = new byte[subSize * _maximumReadable]; + var data = new byte[sectorSize * _maximumReadable]; + var sub = new byte[subSize * _maximumReadable]; - for(int b = 0; b < _maximumReadable; b++) + for(var b = 0; b < _maximumReadable; b++) { Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } - outputOptical.WriteSectorsLong(data, i, _maximumReadable); + outputOptical.WriteSectorsLong(data, + i, + _maximumReadable, + Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) + .ToArray()); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -247,7 +251,11 @@ partial class Dump } } else - outputOptical.WriteSectors(cmdBuf, i, _maximumReadable); + outputOptical.WriteSectors(cmdBuf, + i, + _maximumReadable, + Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) + .ToArray()); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; } @@ -263,7 +271,7 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1); + outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]); outputOptical.WriteSectorsTag(new byte[subSize * _skip], i, @@ -271,7 +279,7 @@ partial class Dump SectorTagType.CdSectorSubchannel); } else - outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1); + outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; @@ -331,7 +339,7 @@ partial class Dump { byte[] cmdBuf = null; // Data buffer const uint sectorSize = 2352; // Full sector size - bool sense = true; // Sense indicator + var sense = true; // Sense indicator ReadOnlySpan senseBuf = null; var outputOptical = _outputPlugin as IWritableOpticalImage; @@ -444,17 +452,21 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize * _maximumReadable]; - byte[] sub = new byte[subSize * _maximumReadable]; + var data = new byte[sectorSize * _maximumReadable]; + var sub = new byte[subSize * _maximumReadable]; - for(int b = 0; b < _maximumReadable; b++) + for(var b = 0; b < _maximumReadable; b++) { Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize); Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize); } - outputOptical.WriteSectorsLong(data, i, _maximumReadable); + outputOptical.WriteSectorsLong(data, + i, + _maximumReadable, + Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) + .ToArray()); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, desiredSubchannel, @@ -486,7 +498,11 @@ partial class Dump } } else - outputOptical.WriteSectors(cmdBuf, i, _maximumReadable); + outputOptical.WriteSectors(cmdBuf, + i, + _maximumReadable, + Enumerable.Repeat(SectorStatus.Dumped, (int)_maximumReadable) + .ToArray()); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; } @@ -502,7 +518,7 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1); + outputOptical.WriteSectorsLong(new byte[sectorSize * _skip], i, 1, new SectorStatus[1]); if(desiredSubchannel != MmcSubchannel.None) { @@ -513,7 +529,7 @@ partial class Dump } } else - outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1); + outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1, new SectorStatus[1]); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs index 2bec64b82..2cee811be 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Recordable.cs @@ -72,7 +72,7 @@ partial class Dump if(track is null) continue; - byte[] sector = new byte[2352]; + var sector = new byte[2352]; switch(track.Type) { @@ -102,9 +102,9 @@ partial class Dump } if(supportsLongSectors) - outputOptical.WriteSectorLong(sector, s); + outputOptical.WriteSectorLong(sector, s, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(sector), s); + outputOptical.WriteSector(Sector.GetUserData(sector), s, SectorStatus.Dumped); _resume.BadBlocks.Remove(s); extents.Add(s); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index 57ff5e8b2..c68f44133 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using System.Linq; using Aaru.Checksums; using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.Core.Logging; @@ -84,7 +85,7 @@ partial class Dump Dictionary isrcs, ref string mcn, HashSet subchannelExtents, Dictionary smallestPregapLbaPerTrack) { - bool sense = true; // Sense indicator + var sense = true; // Sense indicator byte[] cmdBuf = null; // Data buffer double cmdDuration = 0; // Command execution time const uint sectorSize = 2352; // Full sector size @@ -109,7 +110,7 @@ partial class Dump trimStart: ulong[] tmpArray = _resume.BadBlocks.ToArray(); - for(int b = 0; b < tmpArray.Length; b++) + for(var b = 0; b < tmpArray.Length; b++) { ulong badSector = tmpArray[b]; @@ -126,7 +127,7 @@ partial class Dump Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => badSector >= t.StartSector); byte sectorsToTrim = 1; - uint badSectorToRead = (uint)badSector; + var badSectorToRead = (uint)badSector; if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0) { @@ -290,7 +291,7 @@ partial class Dump { case 0: - for(int c = 16; c < 2352; c++) + for(var c = 16; c < 2352; c++) { if(cmdBuf[c] == 0x00) continue; @@ -417,15 +418,15 @@ partial class Dump if(supportedSubchannel != MmcSubchannel.None) { - byte[] data = new byte[sectorSize]; - byte[] sub = new byte[subSize]; + var data = new byte[sectorSize]; + var sub = new byte[subSize]; Array.Copy(cmdBuf, 0, data, 0, sectorSize); Array.Copy(cmdBuf, sectorSize, sub, 0, subSize); if(supportsLongSectors) - outputOptical.WriteSectorLong(data, badSector); + outputOptical.WriteSectorLong(data, badSector, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(data), badSector); + outputOptical.WriteSector(Sector.GetUserData(data), badSector, SectorStatus.Dumped); ulong trkStartBefore = track.StartSector; @@ -467,9 +468,9 @@ partial class Dump } if(supportsLongSectors) - outputOptical.WriteSectorLong(cmdBuf, badSector); + outputOptical.WriteSectorLong(cmdBuf, badSector, SectorStatus.Dumped); else - outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector); + outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector, SectorStatus.Dumped); } _trimStopwatch.Stop(); diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 4ebd66ebd..4c0473fe6 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -230,7 +230,7 @@ partial class Dump if(decMode?.Pages != null) { - bool setGeometry = false; + var setGeometry = false; foreach(Modes.ModePage page in decMode.Value.Pages) { @@ -327,7 +327,7 @@ partial class Dump _mediaGraph?.PaintSectorsBad(_resume.BadBlocks); } - bool newTrim = false; + var newTrim = false; _speedStopwatch.Reset(); ulong sectorSpeedStart = 0; InitProgress?.Invoke(); @@ -374,7 +374,12 @@ partial class Dump mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(readBuffer, i, blocksToRead); + + outputFormat.WriteSectors(readBuffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -388,7 +393,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); @@ -470,7 +480,7 @@ partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -487,9 +497,9 @@ partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -637,14 +647,14 @@ partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index a82bdcc70..96e811ee8 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -86,7 +86,7 @@ public partial class Dump return; } - uint blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); + var blocks = (uint)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); blocks++; @@ -191,7 +191,7 @@ public partial class Dump _mediaGraph?.PaintSectorsBad(_resume.BadBlocks); } - bool newTrim = false; + var newTrim = false; _speedStopwatch.Restart(); ulong sectorSpeedStart = 0; @@ -246,7 +246,12 @@ public partial class Dump mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(readBuffer, i, blocksToRead); + + outputFormat.WriteSectors(readBuffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -262,7 +267,12 @@ public partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); @@ -363,7 +373,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -380,9 +390,9 @@ public partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -562,14 +572,14 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 57c24c612..9521d4370 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -96,11 +96,11 @@ public partial class Dump return; } - ushort fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]); - ushort sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]); - ushort rootStart = (ushort)(sectorsPerFat * 2 + fatStart); - ushort rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512); - ushort umdStart = (ushort)(rootStart + rootSize); + var fatStart = (ushort)((readBuffer[0x0F] << 8) + readBuffer[0x0E]); + var sectorsPerFat = (ushort)((readBuffer[0x17] << 8) + readBuffer[0x16]); + var rootStart = (ushort)(sectorsPerFat * 2 + fatStart); + var rootSize = (ushort)(((readBuffer[0x12] << 8) + readBuffer[0x11]) * 32 / 512); + var umdStart = (ushort)(rootStart + rootSize); UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_root_directory_in_sector_0, rootStart)); @@ -126,7 +126,7 @@ public partial class Dump return; } - uint umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C); + var umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C); ulong blocks = umdSizeInBytes / blockSize; string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim(); @@ -229,7 +229,7 @@ public partial class Dump _mediaGraph?.PaintSectorsBad(_resume.BadBlocks); } - bool newTrim = false; + var newTrim = false; _speedStopwatch.Reset(); ulong sectorSpeedStart = 0; @@ -285,7 +285,12 @@ public partial class Dump { mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); - outputOptical.WriteSectors(readBuffer, i, blocksToRead); + + outputOptical.WriteSectors(readBuffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -300,7 +305,11 @@ public partial class Dump if(i + _skip > blocks) _skip = (uint)(blocks - i); // Write empty data - outputOptical.WriteSectors(new byte[blockSize * _skip], i, _skip); + outputOptical.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); @@ -400,7 +409,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputOptical.WriteSector(readBuffer, badSector); + outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -417,9 +426,9 @@ public partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; Modes.ModePage? currentModePage = null; byte[] md6; @@ -576,14 +585,14 @@ public partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputOptical.WriteSector(readBuffer, badSector); + outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputOptical.WriteSector(readBuffer, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 207a80fc1..a083697b2 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -285,9 +285,8 @@ partial class Dump Modes.DecodedMode? decMode = null; if(!sense && !_dev.Error) - { - if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); - } + if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) + decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); @@ -315,9 +314,8 @@ partial class Dump if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(!sense && !_dev.Error) - { - if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); - } + if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) + decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); // TODO: Check partitions page if(decMode.HasValue) @@ -361,12 +359,12 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Media_identified_as_0, dskType.Humanize())); - bool endOfMedia = false; + var endOfMedia = false; ulong currentBlock = 0; uint currentFile = 0; byte currentPartition = 0; byte totalPartitions = 1; // TODO: Handle partitions. - bool fixedLen = false; + var fixedLen = false; uint transferLen = blockSize; firstRead: @@ -601,8 +599,8 @@ partial class Dump return; } - bool canLocateLong = false; - bool canLocate = false; + var canLocateLong = false; + var canLocate = false; UpdateStatus?.Invoke(Localization.Core.Positioning_tape_to_block_1); @@ -1092,7 +1090,7 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputTape.WriteSector(new byte[blockSize], currentBlock); + outputTape.WriteSector(new byte[blockSize], currentBlock, SectorStatus.NotDumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration); @@ -1104,7 +1102,7 @@ partial class Dump mhddLog.Write(currentBlock, duration); ibgLog.Write(currentBlock, currentSpeed * 1024); _writeStopwatch.Restart(); - outputTape.WriteSector(cmdBuf, currentBlock); + outputTape.WriteSector(cmdBuf, currentBlock, SectorStatus.Dumped); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(currentBlock, 1, true); } @@ -1167,8 +1165,8 @@ partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0 && (canLocate || canLocateLong)) { - int pass = 1; - bool forward = false; + var pass = 1; + var forward = false; const bool runningPersistent = false; Modes.ModePage? currentModePage; @@ -1299,13 +1297,13 @@ partial class Dump { _resume.BadBlocks.Remove(badBlock); extents.Add(badBlock); - outputTape.WriteSector(cmdBuf, badBlock); + outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Dumped); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock, pass)); } - else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock); + else if(runningPersistent) outputTape.WriteSector(cmdBuf, badBlock, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs index ade825f8d..30c41cc54 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Cache.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Cache.cs @@ -118,7 +118,7 @@ partial class Dump _writeStopwatch.Restart(); byte[] tmpBuf; - byte[] cmi = new byte[blocksToRead]; + var cmi = new byte[blocksToRead]; for(uint j = 0; j < blocksToRead; j++) { @@ -160,7 +160,10 @@ partial class Dump buffer = CSS.DecryptSectorLong(buffer, titleKey, cmi, blocksToRead); } - outputFormat.WriteSectorsLong(buffer, i, blocksToRead); + outputFormat.WriteSectorsLong(buffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); @@ -175,7 +178,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectorsLong(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index eb2f1327e..a20fd402c 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -189,7 +189,12 @@ partial class Dump mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(buffer, i, blocksToRead); + + outputFormat.WriteSectors(buffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -217,7 +222,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Error.cs b/Aaru.Core/Devices/Dumping/Sbc/Error.cs index d700f43a7..c222f26a0 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Error.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Error.cs @@ -57,9 +57,9 @@ partial class Dump void RetrySbcData(Reader scsiReader, DumpHardware currentTry, ExtentsULong extents, ref double totalDuration, ExtentsULong blankExtents, byte[] discKey) { - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; bool sense; byte[] buffer; bool recoveredError; @@ -67,7 +67,7 @@ partial class Dump byte[] md6; byte[] md10; bool blankCheck; - bool newBlank = false; + var newBlank = false; var outputFormat = _outputPlugin as IWritableImage; if(_persistent) @@ -310,7 +310,7 @@ partial class Dump if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw) { - byte[] cmi = new byte[1]; + var cmi = new byte[1]; byte[] key = buffer.Skip(7).Take(5).ToArray(); @@ -348,10 +348,10 @@ partial class Dump } _resume.BadBlocks.Remove(badSector); - outputFormat.WriteSectorLong(buffer, badSector); + outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped); } else - outputFormat.WriteSector(buffer, badSector); + outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); @@ -359,7 +359,7 @@ partial class Dump badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(buffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) @@ -397,8 +397,8 @@ partial class Dump void RetryTitleKeys(DVDDecryption dvdDecrypt, byte[] discKey, ref double totalDuration) { - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; bool sense; byte[] buffer; diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 115b8e0f4..427b14bea 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using Aaru.CommonTypes.AaruMetadata; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Extents; using Aaru.CommonTypes.Interfaces; using Aaru.Core.Logging; @@ -52,7 +53,7 @@ partial class Dump bool sense; byte[] buffer; ulong sectorSpeedStart = 0; - bool canMediumScan = true; + var canMediumScan = true; var outputFormat = _outputPlugin as IWritableImage; InitProgress?.Invoke(); @@ -179,9 +180,8 @@ partial class Dump writtenExtents.Add(0, blocks - 1); foreach(Tuple blank in blankExtents.ToArray()) - { - for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b); - } + for(ulong b = blank.Item1; b <= blank.Item2; b++) + writtenExtents.Remove(b); } if(writtenExtents.Count == 0) @@ -236,7 +236,12 @@ partial class Dump mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(buffer, i, blocksToRead); + + outputFormat.WriteSectors(buffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); } @@ -249,7 +254,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs index 656ce5692..6b2c5c8eb 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Trim.cs @@ -52,7 +52,7 @@ partial class Dump bool recoveredError; bool blankCheck; byte[] buffer; - bool newBlank = false; + var newBlank = false; if(_outputPlugin is not IWritableImage outputFormat) { @@ -101,7 +101,7 @@ partial class Dump if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw) { - byte[] cmi = new byte[1]; + var cmi = new byte[1]; byte[] key = buffer.Skip(7).Take(5).ToArray(); @@ -138,10 +138,10 @@ partial class Dump } _resume.BadBlocks.Remove(badSector); - outputFormat.WriteSectorLong(buffer, badSector); + outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped); } else - outputFormat.WriteSector(buffer, badSector); + outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 22dee497d..5499543e5 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -87,9 +87,9 @@ public partial class Dump byte[] ecsd = null; byte[] scr = null; uint physicalBlockSize = 0; - bool byteAddressed = true; + var byteAddressed = true; uint[] response; - bool supportsCmd23 = false; + var supportsCmd23 = false; var outputFormat = _outputPlugin as IWritableImage; Dictionary mediaTags = new(); @@ -412,7 +412,7 @@ public partial class Dump return; } - bool ret = true; + var ret = true; foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag))) { @@ -592,7 +592,7 @@ public partial class Dump _dumpStopwatch.Restart(); _speedStopwatch.Reset(); double imageWriteDuration = 0; - bool newTrim = false; + var newTrim = false; ulong sectorSpeedStart = 0; InitProgress?.Invoke(); @@ -664,7 +664,12 @@ public partial class Dump mhddLog.Write(i, duration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(cmdBuf, i, blocksToRead); + + outputFormat.WriteSectors(cmdBuf, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -681,7 +686,12 @@ public partial class Dump ibgLog.Write(i, 0); _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; AaruLogging.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i); i += _skip - blocksToRead; @@ -771,7 +781,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector); + outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -788,8 +798,8 @@ public partial class Dump if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0) { - int pass = 1; - bool forward = true; + var pass = 1; + var forward = true; InitProgress?.Invoke(); repeatRetryLba: @@ -832,7 +842,7 @@ public partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(cmdBuf, badSector); + outputFormat.WriteSector(cmdBuf, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index cea481dbc..bcc77dec4 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -150,7 +150,7 @@ partial class Dump return; } - byte[] tmpBuf = new byte[ssBuf.Length - 4]; + var tmpBuf = new byte[ssBuf.Length - 4]; Array.Copy(ssBuf, 4, tmpBuf, 0, ssBuf.Length - 4); mediaTags.Add(MediaTagType.Xbox_SecuritySector, tmpBuf); @@ -475,7 +475,7 @@ partial class Dump if(_skip < blocksToRead) _skip = blocksToRead; - bool ret = true; + var ret = true; foreach(MediaTagType tag in mediaTags.Keys.Where(tag => !outputFormat.SupportedMediaTags.Contains(tag))) { @@ -579,14 +579,14 @@ partial class Dump if(_resume.NextBlock > 0) UpdateStatus?.Invoke(string.Format(Localization.Core.Resuming_from_block_0, _resume.NextBlock)); - bool newTrim = false; + var newTrim = false; UpdateStatus?.Invoke(Localization.Core.Reading_game_partition); _speedStopwatch.Reset(); ulong sectorSpeedStart = 0; InitProgress?.Invoke(); - for(int e = 0; e <= 16; e++) + for(var e = 0; e <= 16; e++) { if(_aborted) { @@ -683,7 +683,12 @@ partial class Dump mhddLog.Write(i, cmdDuration, blocksToRead); ibgLog.Write(i, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(readBuffer, i, blocksToRead); + + outputFormat.WriteSectors(readBuffer, + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(i, blocksToRead, true); _mediaGraph?.PaintSectorsGood(i, blocksToRead); @@ -699,7 +704,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + i, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b); @@ -757,7 +767,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * blocksToRead], i, blocksToRead); + + outputFormat.WriteSectors(new byte[blockSize * blocksToRead], + i, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; blocksToRead = saveBlocksToRead; extents.Add(i, blocksToRead, true); @@ -802,7 +817,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, blocksToRead); + + outputFormat.WriteSectors(new byte[blockSize * blocksToRead], + middle + currentSector, + blocksToRead, + Enumerable.Repeat(SectorStatus.NotDumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(currentSector, blocksToRead, true); _writeStopwatch.Stop(); @@ -887,7 +907,12 @@ partial class Dump mhddLog.Write(currentSector, cmdDuration, blocksToRead); ibgLog.Write(currentSector, currentSpeed * 1024); _writeStopwatch.Restart(); - outputFormat.WriteSectors(readBuffer, currentSector, blocksToRead); + + outputFormat.WriteSectors(readBuffer, + currentSector, + blocksToRead, + Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; extents.Add(currentSector, blocksToRead, true); _mediaGraph?.PaintSectorsGood(currentSector, blocksToRead); @@ -901,7 +926,12 @@ partial class Dump // Write empty data _writeStopwatch.Restart(); - outputFormat.WriteSectors(new byte[blockSize * _skip], currentSector, _skip); + + outputFormat.WriteSectors(new byte[blockSize * _skip], + currentSector, + _skip, + Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray()); + imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds; // TODO: Handle errors in video partition @@ -1030,7 +1060,7 @@ partial class Dump _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); } @@ -1050,14 +1080,15 @@ partial class Dump List tmpList = []; foreach(ulong ur in _resume.BadBlocks) - for(ulong i = ur; i < ur + blocksToRead; i++) - tmpList.Add(i); + { + for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); + } tmpList.Sort(); - int pass = 1; - bool forward = true; - bool runningPersistent = false; + var pass = 1; + var forward = true; + var runningPersistent = false; _resume.BadBlocks = tmpList; Modes.ModePage? currentModePage = null; @@ -1230,14 +1261,14 @@ partial class Dump { _resume.BadBlocks.Remove(badSector); extents.Add(badSector); - outputFormat.WriteSector(readBuffer, badSector); + outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Dumped); _mediaGraph?.PaintSectorGood(badSector); UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass)); } - else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector); + else if(runningPersistent) outputFormat.WriteSector(readBuffer, badSector, SectorStatus.Errored); } if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0) diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index 9a542cbcb..1fba5acb2 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -741,19 +741,27 @@ public sealed partial class ImageConvertViewModel : ViewModelBase Progress2Value = (int)(sectors / SectorsValue); }); - bool result; + bool result; + SectorStatus sectorStatus = SectorStatus.NotDumped; + var sectorStatusArray = new SectorStatus[1]; if(useLong) { errno = sectorsToDo == 1 - ? _inputFormat.ReadSectorLong(doneSectors, out sector, out _) - : _inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector, out _); + ? _inputFormat.ReadSectorLong(doneSectors, out sector, out sectorStatus) + : _inputFormat.ReadSectorsLong(doneSectors, + sectorsToDo, + out sector, + out sectorStatusArray); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSectorLong(sector, doneSectors) - : outputFormat.WriteSectorsLong(sector, doneSectors, sectorsToDo); + ? outputFormat.WriteSectorLong(sector, doneSectors, sectorStatus) + : outputFormat.WriteSectorsLong(sector, + doneSectors, + sectorsToDo, + sectorStatusArray); } else { @@ -786,14 +794,14 @@ public sealed partial class ImageConvertViewModel : ViewModelBase else { errno = sectorsToDo == 1 - ? _inputFormat.ReadSector(doneSectors, out sector, out _) - : _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector, out _); + ? _inputFormat.ReadSector(doneSectors, out sector, out sectorStatus) + : _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector, out sectorStatusArray); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSector(sector, doneSectors) - : outputFormat.WriteSectors(sector, doneSectors, sectorsToDo); + ? outputFormat.WriteSector(sector, doneSectors, sectorStatus) + : outputFormat.WriteSectors(sector, doneSectors, sectorsToDo, sectorStatusArray); } else { @@ -1200,24 +1208,31 @@ public sealed partial class ImageConvertViewModel : ViewModelBase Progress2Value = (int)(sectors / SectorsValue); }); - bool result; + bool result; + SectorStatus sectorStatus = SectorStatus.NotDumped; + var sectorStatusArray = new SectorStatus[1]; if(useLong) { errno = sectorsToDo == 1 - ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, out sector, out _) + ? _inputFormat.ReadSectorLong(doneSectors + track.StartSector, + out sector, + out sectorStatus) : _inputFormat.ReadSectorsLong(doneSectors + track.StartSector, sectorsToDo, out sector, - out _); + out sectorStatusArray); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSectorLong(sector, doneSectors + track.StartSector) + ? outputFormat.WriteSectorLong(sector, + doneSectors + track.StartSector, + sectorStatus) : outputFormat.WriteSectorsLong(sector, doneSectors + track.StartSector, - sectorsToDo); + sectorsToDo, + sectorStatusArray); } else { @@ -1248,19 +1263,24 @@ public sealed partial class ImageConvertViewModel : ViewModelBase else { errno = sectorsToDo == 1 - ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector, out _) + ? _inputFormat.ReadSector(doneSectors + track.StartSector, + out sector, + out sectorStatus) : _inputFormat.ReadSectors(doneSectors + track.StartSector, sectorsToDo, out sector, - out _); + out sectorStatusArray); if(errno == ErrorNumber.NoError) { result = sectorsToDo == 1 - ? outputFormat.WriteSector(sector, doneSectors + track.StartSector) + ? outputFormat.WriteSector(sector, + doneSectors + track.StartSector, + sectorStatus) : outputFormat.WriteSectors(sector, doneSectors + track.StartSector, - sectorsToDo); + sectorsToDo, + sectorStatusArray); } else { diff --git a/Aaru.Images/A2R/Write.cs b/Aaru.Images/A2R/Write.cs index 73641a9e3..9b3f7e2b7 100644 --- a/Aaru.Images/A2R/Write.cs +++ b/Aaru.Images/A2R/Write.cs @@ -241,16 +241,20 @@ public sealed partial class A2R public bool WriteMediaTag(byte[] data, MediaTagType tag) => false; /// - public bool WriteSector(byte[] data, ulong sectorAddress) => throw new NotImplementedException(); + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => + throw new NotImplementedException(); /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) => throw new NotImplementedException(); + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => + throw new NotImplementedException(); /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) => + throw new NotImplementedException(); /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) => + throw new NotImplementedException(); #endregion diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index cd714fce6..2ce63feff 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -66,9 +66,9 @@ public sealed partial class AaruFormat #region IWritableOpticalImage Members /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { - Status res = aaruf_write_sector(_context, sectorAddress, false, data, SectorStatus.Dumped, (uint)data.Length); + Status res = aaruf_write_sector(_context, sectorAddress, false, data, sectorStatus, (uint)data.Length); if(res == Status.Ok) return true; @@ -78,10 +78,9 @@ public sealed partial class AaruFormat } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { - Status res = - aaruf_write_sector_long(_context, sectorAddress, false, data, SectorStatus.Dumped, (uint)data.Length); + Status res = aaruf_write_sector_long(_context, sectorAddress, false, data, sectorStatus, (uint)data.Length); if(res == Status.Ok) return true; @@ -137,7 +136,7 @@ public sealed partial class AaruFormat } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { var sectorSize = (uint)(data.Length / length); @@ -146,14 +145,14 @@ public sealed partial class AaruFormat var sectorData = new byte[sectorSize]; Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize); - if(!WriteSector(sectorData, sectorAddress + i)) return false; + if(!WriteSector(sectorData, sectorAddress + i, sectorStatus[i])) return false; } return true; } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { var sectorSize = (uint)(data.Length / length); @@ -162,7 +161,7 @@ public sealed partial class AaruFormat var sectorData = new byte[sectorSize]; Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize); - if(!WriteSectorLong(sectorData, sectorAddress + i)) return false; + if(!WriteSectorLong(sectorData, sectorAddress + i, sectorStatus[i])) return false; } return true; @@ -288,9 +287,8 @@ public sealed partial class AaruFormat // Convert array of booleans to List of enums for(nuint i = 0; i < sizet_length; i++) - { - if(sectorTagsBuffer[i] != 0) _imageInfo.ReadableSectorTags.Add((SectorTagType)i); - } + if(sectorTagsBuffer[i] != 0) + _imageInfo.ReadableSectorTags.Add((SectorTagType)i); sizet_length = 0; ret = aaruf_get_readable_media_tags(_context, null, ref sizet_length); @@ -314,9 +312,8 @@ public sealed partial class AaruFormat // Convert array of booleans to List of enums for(nuint i = 0; i < sizet_length; i++) - { - if(mediaTagsBuffer[i] != 0) _imageInfo.ReadableMediaTags.Add((MediaTagType)i); - } + if(mediaTagsBuffer[i] != 0) + _imageInfo.ReadableMediaTags.Add((MediaTagType)i); ret = aaruf_get_media_sequence(_context, out int sequence, out int lastSequence); diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index f911b7135..ad12fe4a9 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -211,7 +211,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -261,7 +261,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -343,7 +343,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -369,7 +369,7 @@ public sealed partial class Alcohol120 return false; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); _imageStream.Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * @@ -382,7 +382,7 @@ public sealed partial class Alcohol120 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -415,7 +415,7 @@ public sealed partial class Alcohol120 return false; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); for(uint i = 0; i < length; i++) { @@ -441,7 +441,7 @@ public sealed partial class Alcohol120 { CommonTypes.Structs.Track[] tmpTracks = tracks.OrderBy(t => t.Sequence).ToArray(); - for(int i = 1; i < tmpTracks.Length; i++) + for(var i = 1; i < tmpTracks.Length; i++) { CommonTypes.Structs.Track firstTrackInSession = tracks.FirstOrDefault(t => t.Session == tmpTracks[i].Session); @@ -548,9 +548,9 @@ public sealed partial class Alcohol120 FullTOC.CDFullTOC? decodedToc = FullTOC.Decode(tmpToc); long currentExtraOffset = currentTrackOffset; - int extraCount = 0; + var extraCount = 0; - for(int i = 1; i <= sessions; i++) + for(var i = 1; i <= sessions; i++) { if(decodedToc.HasValue) { @@ -619,7 +619,7 @@ public sealed partial class Alcohol120 } else { - for(int i = 1; i <= sessions; i++) + for(var i = 1; i <= sessions; i++) { CommonTypes.Structs.Track firstTrack = _writingTracks.First(t => t.Session == i); CommonTypes.Structs.Track lastTrack = _writingTracks.Last(t => t.Session == i); @@ -915,8 +915,8 @@ public sealed partial class Alcohol120 // Write header _descriptorStream.Seek(0, SeekOrigin.Begin); - byte[] block = new byte[Marshal.SizeOf
()]; - nint blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); + var block = new byte[Marshal.SizeOf
()]; + nint blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(blockPtr); diff --git a/Aaru.Images/Anex86/Write.cs b/Aaru.Images/Anex86/Write.cs index 98971b785..32ace3a07 100644 --- a/Aaru.Images/Anex86/Write.cs +++ b/Aaru.Images/Anex86/Write.cs @@ -113,7 +113,7 @@ public sealed partial class Anex86 } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -145,7 +145,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -177,7 +177,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -185,7 +185,7 @@ public sealed partial class Anex86 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -233,7 +233,7 @@ public sealed partial class Anex86 } } - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; MemoryMarshal.Write(hdr, in _header); _writingStream.Seek(0, SeekOrigin.Begin); diff --git a/Aaru.Images/Apple2MG/Write.cs b/Aaru.Images/Apple2MG/Write.cs index 0df61b0bd..066b5c593 100644 --- a/Aaru.Images/Apple2MG/Write.cs +++ b/Aaru.Images/Apple2MG/Write.cs @@ -109,7 +109,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -141,7 +141,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -173,7 +173,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -181,7 +181,7 @@ public sealed partial class Apple2Mg } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -199,7 +199,7 @@ public sealed partial class Apple2Mg } _writingStream.Seek(0x40 + 17 * 16 * 256, SeekOrigin.Begin); - byte[] tmp = new byte[256]; + var tmp = new byte[256]; _writingStream.EnsureRead(tmp, 0, tmp.Length); bool isDos = tmp[0x01] == 17 && @@ -235,8 +235,8 @@ public sealed partial class Apple2Mg _writingStream.WriteByte(0); } - byte[] hdr = new byte[Marshal.SizeOf
()]; - nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); + var hdr = new byte[Marshal.SizeOf
()]; + nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf
()); System.Runtime.InteropServices.Marshal.StructureToPtr(_imageHeader, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); diff --git a/Aaru.Images/AppleDOS/Write.cs b/Aaru.Images/AppleDOS/Write.cs index 94e7f3ddd..ed9b7cb88 100644 --- a/Aaru.Images/AppleDOS/Write.cs +++ b/Aaru.Images/AppleDOS/Write.cs @@ -114,10 +114,11 @@ public sealed partial class AppleDos } /// - public bool WriteSector(byte[] data, ulong sectorAddress) => WriteSectors(data, sectorAddress, 1); + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) => + WriteSectors(data, sectorAddress, 1, [SectorStatus.Dumped]); /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -148,7 +149,7 @@ public sealed partial class AppleDos } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -156,7 +157,7 @@ public sealed partial class AppleDos } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -195,9 +196,9 @@ public sealed partial class AppleDos ? _interleave : _deinterleave; - for(int t = 0; t < 35; t++) + for(var t = 0; t < 35; t++) { - for(int s = 0; s < 16; s++) + for(var s = 0; s < 16; s++) Array.Copy(_deinterleaved, t * 16 * 256 + offsets[s] * 256, tmp, t * 16 * 256 + s * 256, 256); } } diff --git a/Aaru.Images/Apridisk/Write.cs b/Aaru.Images/Apridisk/Write.cs index 6038630b5..f53f15f14 100644 --- a/Aaru.Images/Apridisk/Write.cs +++ b/Aaru.Images/Apridisk/Write.cs @@ -93,7 +93,7 @@ public sealed partial class Apridisk } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); @@ -124,7 +124,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { for(uint i = 0; i < length; i++) { @@ -158,7 +158,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -166,7 +166,7 @@ public sealed partial class Apridisk } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -180,7 +180,7 @@ public sealed partial class Apridisk _writingStream.Seek(0, SeekOrigin.Begin); _writingStream.Write(_signature, 0, _signature.Length); - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; for(ushort c = 0; c < _imageInfo.Cylinders; c++) { diff --git a/Aaru.Images/BLU/Write.cs b/Aaru.Images/BLU/Write.cs index 4422bd0d2..e38c8d760 100644 --- a/Aaru.Images/BLU/Write.cs +++ b/Aaru.Images/BLU/Write.cs @@ -111,7 +111,7 @@ public sealed partial class Blu } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; @@ -145,7 +145,7 @@ public sealed partial class Blu } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; @@ -179,7 +179,7 @@ public sealed partial class Blu } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -269,7 +269,7 @@ public sealed partial class Blu } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -387,7 +387,7 @@ public sealed partial class Blu byte[] markerTag = Encoding.UTF8.GetBytes("Aaru " + Version.GetVersion()); byte[] driveName; - byte[] driveType = new byte[3]; + var driveType = new byte[3]; byte[] driveBlocks = BigEndianBitConverter.GetBytes((uint)_imageInfo.Sectors); int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; byte[] blockSize = BigEndianBitConverter.GetBytes((ushort)longSectorSize); diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 4337a1b5d..2c7668350 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -143,7 +143,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -188,7 +188,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -209,7 +209,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -261,7 +261,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -307,7 +307,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -345,7 +345,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -356,7 +356,7 @@ public sealed partial class Cdrdao data = swapped; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); trackStream.Seek((long)(track.FileOffset + (sectorAddress - track.StartSector) * @@ -369,7 +369,7 @@ public sealed partial class Cdrdao } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -414,7 +414,7 @@ public sealed partial class Cdrdao // cdrdao audio tracks are endian swapped corresponding to Aaru if(track.Type == TrackType.Audio) { - byte[] swapped = new byte[data.Length]; + var swapped = new byte[data.Length]; for(long i = 0; i < swapped.Length; i += 2) { @@ -425,7 +425,7 @@ public sealed partial class Cdrdao data = swapped; } - uint subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); + var subchannelSize = (uint)(track.SubchannelType != TrackSubchannelType.None ? 96 : 0); for(uint i = 0; i < length; i++) { @@ -458,9 +458,8 @@ public sealed partial class Cdrdao } if(_writingTracks != null && _writingStreams != null) - { - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); - } + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) + oldTrack.Close(); ulong currentOffset = 0; _writingTracks = []; diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index 28239a038..5cfee870d 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -110,7 +110,7 @@ public sealed partial class CdrWin Tracks = [] }; - int mediaTypeAsInt = (int)_discImage.MediaType; + var mediaTypeAsInt = (int)_discImage.MediaType; _isCd = mediaTypeAsInt is >= 10 and <= 39 or 112 @@ -168,7 +168,7 @@ public sealed partial class CdrWin } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -220,7 +220,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -279,7 +279,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -324,7 +324,7 @@ public sealed partial class CdrWin } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -393,9 +393,8 @@ public sealed partial class CdrWin } if(_writingTracks != null && _writingStreams != null) - { - foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); - } + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) + oldTrack.Close(); _writingTracks = []; @@ -459,7 +458,7 @@ public sealed partial class CdrWin _writingStreams.First().Value.Close(); } - int currentSession = 0; + var currentSession = 0; if(!string.IsNullOrWhiteSpace(_discImage.Comment)) { diff --git a/Aaru.Images/CisCopy/Write.cs b/Aaru.Images/CisCopy/Write.cs index 01569f444..509da93ee 100644 --- a/Aaru.Images/CisCopy/Write.cs +++ b/Aaru.Images/CisCopy/Write.cs @@ -128,11 +128,11 @@ public sealed partial class CisCopy DiskType.MF2DD or DiskType.MD2HD or DiskType.MF2HD => 160 }; - int headStep = 1; + var headStep = 1; if(diskType is DiskType.MD1DD or DiskType.MD1DD8) headStep = 2; - for(int i = 0; i < tracks; i += headStep) + for(var i = 0; i < tracks; i += headStep) { _writingStream.WriteByte((byte)TrackType.Copied); @@ -157,7 +157,7 @@ public sealed partial class CisCopy } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -189,7 +189,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -221,7 +221,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -229,7 +229,7 @@ public sealed partial class CisCopy } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; diff --git a/Aaru.Images/CloneCD/Write.cs b/Aaru.Images/CloneCD/Write.cs index f23f51b8d..2677b9fae 100644 --- a/Aaru.Images/CloneCD/Write.cs +++ b/Aaru.Images/CloneCD/Write.cs @@ -126,7 +126,7 @@ public sealed partial class CloneCd } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -142,7 +142,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -158,7 +158,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -193,7 +193,7 @@ public sealed partial class CloneCd } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -310,7 +310,7 @@ public sealed partial class CloneCd // Easy, just decode the real toc if(_fullToc != null) { - byte[] tmp = new byte[_fullToc.Length + 2]; + var tmp = new byte[_fullToc.Length + 2]; Array.Copy(BigEndianBitConverter.GetBytes((ushort)_fullToc.Length), 0, tmp, 0, 2); Array.Copy(_fullToc, 0, tmp, 2, _fullToc.Length); nullableToc = FullTOC.Decode(tmp); @@ -329,7 +329,7 @@ public sealed partial class CloneCd if(!string.IsNullOrEmpty(_catalog)) _descriptorStream.WriteLine("CATALOG={0}", _catalog); - for(int i = 1; i <= toc.LastCompleteSession; i++) + for(var i = 1; i <= toc.LastCompleteSession; i++) { _descriptorStream.WriteLine("[Session {0}]", i); @@ -365,7 +365,7 @@ public sealed partial class CloneCd _descriptorStream.WriteLine("PreGapSubC=0"); } - for(int i = 0; i < toc.TrackDescriptors.Length; i++) + for(var i = 0; i < toc.TrackDescriptors.Length; i++) { long alba = MsfToLba((toc.TrackDescriptors[i].Min, toc.TrackDescriptors[i].Sec, toc.TrackDescriptors[i].Frame)); @@ -484,7 +484,8 @@ public sealed partial class CloneCd ErrorMessage = string.Format(Localization.Could_not_create_subchannel_file_exception_0, ex.Message); - AaruLogging.Exception(ex,Localization.Could_not_create_subchannel_file_exception_0, + AaruLogging.Exception(ex, + Localization.Could_not_create_subchannel_file_exception_0, ex.Message); return false; @@ -561,7 +562,8 @@ public sealed partial class CloneCd ErrorMessage = string.Format(Localization.Could_not_create_subchannel_file_exception_0, ex.Message); - AaruLogging.Exception(ex,Localization.Could_not_create_subchannel_file_exception_0, + AaruLogging.Exception(ex, + Localization.Could_not_create_subchannel_file_exception_0, ex.Message); return false; diff --git a/Aaru.Images/CopyTape/Write.cs b/Aaru.Images/CopyTape/Write.cs index dbb973d17..aacc7c899 100644 --- a/Aaru.Images/CopyTape/Write.cs +++ b/Aaru.Images/CopyTape/Write.cs @@ -102,7 +102,7 @@ public sealed partial class CopyTape } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!_writtenBlockPositions.TryGetValue(sectorAddress, out ulong position)) { @@ -138,11 +138,11 @@ public sealed partial class CopyTape } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { for(uint i = 0; i < length; i++) { - bool ret = WriteSector(data, sectorAddress + i); + bool ret = WriteSector(data, sectorAddress + i, sectorStatus[i]); if(!ret) return false; } @@ -151,7 +151,7 @@ public sealed partial class CopyTape } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Unsupported_feature; @@ -159,7 +159,7 @@ public sealed partial class CopyTape } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Unsupported_feature; diff --git a/Aaru.Images/DiskCopy42/Write.cs b/Aaru.Images/DiskCopy42/Write.cs index b45f3bf34..923da274d 100644 --- a/Aaru.Images/DiskCopy42/Write.cs +++ b/Aaru.Images/DiskCopy42/Write.cs @@ -51,8 +51,8 @@ public sealed partial class DiskCopy42 uint sectorSize) { header = new Header(); - bool tags = false; - bool macosx = false; + var tags = false; + var macosx = false; if(options != null && options.TryGetValue("macosx", out string tmpOption)) bool.TryParse(tmpOption, out macosx); @@ -223,7 +223,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -255,7 +255,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -287,7 +287,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -328,7 +328,7 @@ public sealed partial class DiskCopy42 } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -387,7 +387,7 @@ public sealed partial class DiskCopy42 if(writingStream.Length == 0x54 + header.DataSize) header.TagSize = 0; writingStream.Seek(0x54, SeekOrigin.Begin); - byte[] data = new byte[header.DataSize]; + var data = new byte[header.DataSize]; writingStream.EnsureRead(data, 0, (int)header.DataSize); header.DataChecksum = CheckSum(data); writingStream.Seek(0x54 + header.DataSize, SeekOrigin.Begin); diff --git a/Aaru.Images/DriDiskCopy/Write.cs b/Aaru.Images/DriDiskCopy/Write.cs index 39e0dec10..cec08432f 100644 --- a/Aaru.Images/DriDiskCopy/Write.cs +++ b/Aaru.Images/DriDiskCopy/Write.cs @@ -131,7 +131,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSector(byte[] data, ulong sectorAddress) + public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { if(!IsWriting) { @@ -163,7 +163,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { if(!IsWriting) { @@ -195,7 +195,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectorLong(byte[] data, ulong sectorAddress) + public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -203,7 +203,7 @@ public sealed partial class DriDiskCopy } /// - public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) + public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus) { ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported; @@ -220,8 +220,8 @@ public sealed partial class DriDiskCopy return false; } - byte[] hdr = new byte[Marshal.SizeOf