Refactor IMediaImage.ReadSector(s)Long to return error status instead of buffer.

This commit is contained in:
2021-09-20 14:22:22 +01:00
parent 88aeda7240
commit a6690aa121
77 changed files with 1048 additions and 555 deletions

View File

@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
using Aaru.Checksums;
using Aaru.CommonTypes.Enums;
namespace Aaru.DiscImages
{
@@ -41,20 +42,24 @@ namespace Aaru.DiscImages
/// <inheritdoc />
public bool? VerifySector(ulong sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer);
return CdChecksums.CheckCdSector(buffer);
return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer);
}
/// <inheritdoc />
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
out List<ulong> unknownLbas)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
failingLbas = new List<ulong>();
unknownLbas = new List<ulong>();
ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer);
if(errno != ErrorNumber.NoError)
return null;
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
for(int i = 0; i < length; i++)
{