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

This commit is contained in:
2021-09-19 21:16:47 +01:00
parent fbccfb2ca9
commit f51d414abd
187 changed files with 4036 additions and 2081 deletions

View File

@@ -35,6 +35,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
using Schemas;
@@ -63,7 +64,7 @@ namespace Aaru.Filesystems
/// <inheritdoc />
public string Name => "F2FS Plugin";
/// <inheritdoc />
public Guid Id => new Guid("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5");
public Guid Id => new("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5");
/// <inheritdoc />
public string Author => "Natalia Portillo";
@@ -87,7 +88,10 @@ namespace Aaru.Filesystems
if(partition.Start + sbAddr + sbSize >= partition.End)
return false;
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
if(errno != ErrorNumber.NoError)
return false;
if(sector.Length < Marshal.SizeOf<Superblock>())
return false;
@@ -118,7 +122,10 @@ namespace Aaru.Filesystems
if(Marshal.SizeOf<Superblock>() % imagePlugin.Info.SectorSize != 0)
sbSize++;
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize, out byte[] sector);
if(errno != ErrorNumber.NoError)
return;
if(sector.Length < Marshal.SizeOf<Superblock>())
return;