[AaruFormat] Implement ReadSectorLong

This commit is contained in:
2025-10-11 21:54:09 +01:00
parent 58458b10e0
commit ecd83d056c
2 changed files with 26 additions and 4 deletions

View File

@@ -62,6 +62,23 @@ public sealed partial class AaruFormat
return StatusToErrorNumber(res);
}
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer)
{
buffer = null;
uint length = 0;
Status res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
if(res != Status.BufferTooSmall) return StatusToErrorNumber(res);
buffer = new byte[length];
res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
return StatusToErrorNumber(res);
}
#endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, uint32_t *length)
@@ -76,10 +93,18 @@ public sealed partial class AaruFormat
private static partial Status aaruf_read_sector(IntPtr context, ulong sectorAddress,
[MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
ref uint length, out byte sectorStatus);
// AARU_EXPORT int32_t AARU_CALL aaruf_read_track_sector(void *context, uint8_t *data, const uint64_t sector_address,
// uint32_t *length, const uint8_t track, uint8_t *sector_status)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_track_sector", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_read_track_sector(IntPtr context, byte[] data, ulong sectorAddress,
ref uint length, byte track, out byte sectorStatus);
// AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64_t sector_address, bool negative,
// uint8_t *data, uint32_t *length, uint8_t *sector_status)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_long", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_read_sector_long(IntPtr context, ulong sectorAddress,
[MarshalAs(UnmanagedType.I4)] bool negative, byte[] data,
ref uint length, out byte sectorStatus);
}

View File

@@ -21,9 +21,6 @@ public sealed partial class AaruFormat
#region IWritableOpticalImage Members
/// <inheritdoc />
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer) => throw new NotImplementedException();
/// <inheritdoc />
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer) =>
throw new NotImplementedException();