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
{
@@ -44,9 +45,9 @@ namespace Aaru.DiscImages
if(!_rawCompactDisc)
return null;
byte[] buffer = ReadSectorLong(sectorAddress);
ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer);
return CdChecksums.CheckCdSector(buffer);
return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer);
}
/// <inheritdoc />
@@ -64,11 +65,15 @@ namespace Aaru.DiscImages
return null;
}
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++)
{