mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Refactor sector writing methods to include SectorStatus parameter and update related logic
This commit is contained in:
@@ -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<int> subchannelExtents,
|
||||
Dictionary<byte, int> 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<ulong> 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<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
|
||||
Dictionary<byte, int> smallestPregapLbaPerTrack)
|
||||
{
|
||||
bool sense = true; // Sense indicator
|
||||
var sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
double cmdDuration; // Command execution time
|
||||
ReadOnlySpan<byte> 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user