mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add support for negative sectors to read and write sector calls in images.
This commit is contained in:
@@ -745,9 +745,8 @@ public sealed partial class BlindWrite4
|
||||
|
||||
// As long as subchannel is written for any track, it is present for all tracks
|
||||
if(Tracks.Any(t => t.SubchannelType == TrackSubchannelType.Packed))
|
||||
{
|
||||
foreach(Track track in Tracks) track.SubchannelType = TrackSubchannelType.Packed;
|
||||
}
|
||||
foreach(Track track in Tracks)
|
||||
track.SubchannelType = TrackSubchannelType.Packed;
|
||||
|
||||
_imageInfo.MediaType = MediaType.CD;
|
||||
|
||||
@@ -829,16 +828,16 @@ public sealed partial class BlindWrite4
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
{
|
||||
sectorStatus = SectorStatus.Dumped;
|
||||
|
||||
return ReadSectors(sectorAddress, 1, out buffer, out _);
|
||||
return ReadSectors(sectorAddress, false, 1, out buffer, out _);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
|
||||
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
|
||||
public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) =>
|
||||
ReadSectorsTag(sectorAddress, false, 1, tag, out buffer);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
@@ -853,11 +852,14 @@ public sealed partial class BlindWrite4
|
||||
ReadSectorsTag(sectorAddress, 1, track, tag, out buffer);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus)
|
||||
public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
|
||||
out SectorStatus[] sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
sectorStatus = null;
|
||||
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap
|
||||
where sectorAddress >= kvp.Value
|
||||
from track in Tracks
|
||||
@@ -871,10 +873,13 @@ public sealed partial class BlindWrite4
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
|
||||
public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag,
|
||||
out byte[] buffer)
|
||||
{
|
||||
buffer = null;
|
||||
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap
|
||||
where sectorAddress >= kvp.Value
|
||||
from track in Tracks
|
||||
@@ -1186,11 +1191,15 @@ public sealed partial class BlindWrite4
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer,
|
||||
out SectorStatus sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
sectorStatus = SectorStatus.Dumped;
|
||||
|
||||
return ReadSectorsLong(sectorAddress, 1, out buffer, out _);
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
return ReadSectorsLong(sectorAddress, false, 1, out buffer, out _);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1202,12 +1211,14 @@ public sealed partial class BlindWrite4
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer,
|
||||
public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
|
||||
out SectorStatus[] sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
sectorStatus = null;
|
||||
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap
|
||||
where sectorAddress >= kvp.Value
|
||||
from track in Tracks
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class BlindWrite4
|
||||
/// <inheritdoc />
|
||||
public bool? VerifySector(ulong sectorAddress)
|
||||
{
|
||||
ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _);
|
||||
ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _);
|
||||
|
||||
return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public sealed partial class BlindWrite4
|
||||
{
|
||||
failingLbas = [];
|
||||
unknownLbas = [];
|
||||
ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _);
|
||||
ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _);
|
||||
|
||||
if(errno != ErrorNumber.NoError) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user