mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[AaruFormat] Handle when a sector has not been dumped imitating V1 behavior.
This commit is contained in:
@@ -109,6 +109,11 @@ public sealed partial class AaruFormat
|
||||
/// </summary>
|
||||
Ok = 0,
|
||||
/// <summary>
|
||||
/// Sector has not been dumped.
|
||||
/// <remarks>AARUF_STATUS_SECTOR_NOT_DUMPED</remarks>
|
||||
/// </summary>
|
||||
SectorNotDumped = 1,
|
||||
/// <summary>
|
||||
/// Input file/stream failed magic or structural validation.
|
||||
/// <remarks>AARUF_ERROR_NOT_AARUFORMAT</remarks>
|
||||
/// </summary>
|
||||
|
||||
@@ -10,6 +10,43 @@ namespace Aaru.Images;
|
||||
|
||||
public sealed partial class AaruFormat
|
||||
{
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, uint32_t *length)
|
||||
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_media_tag", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static partial Status aaruf_read_media_tag(IntPtr context, byte[] data, MediaTagType tag, ref uint length);
|
||||
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(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", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
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);
|
||||
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, const uint64_t sector_address,
|
||||
// const bool negative, uint8_t *buffer, uint32_t *length,
|
||||
// const int32_t tag)
|
||||
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_tag", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static partial Status aaruf_read_sector_tag(IntPtr context, ulong sectorAddress,
|
||||
[MarshalAs(UnmanagedType.I4)] bool negative, byte[] buffer,
|
||||
ref uint length, SectorTagType tag);
|
||||
|
||||
#region IWritableOpticalImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -45,7 +82,12 @@ public sealed partial class AaruFormat
|
||||
|
||||
res = aaruf_read_sector(_context, sectorAddress, false, buffer, ref length, out _);
|
||||
|
||||
return StatusToErrorNumber(res);
|
||||
// Sector not dumped
|
||||
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
|
||||
|
||||
buffer = new byte[length];
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -62,7 +104,12 @@ public sealed partial class AaruFormat
|
||||
|
||||
res = aaruf_read_track_sector(_context, buffer, sectorAddress, ref length, (byte)track, out _);
|
||||
|
||||
return StatusToErrorNumber(res);
|
||||
// Sector not dumped
|
||||
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
|
||||
|
||||
buffer = new byte[length];
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -79,7 +126,12 @@ public sealed partial class AaruFormat
|
||||
|
||||
res = aaruf_read_sector_long(_context, sectorAddress, false, buffer, ref length, out _);
|
||||
|
||||
return StatusToErrorNumber(res);
|
||||
// Sector not dumped
|
||||
if(res != Status.SectorNotDumped || length <= 0) return StatusToErrorNumber(res);
|
||||
|
||||
buffer = new byte[length];
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -259,41 +311,4 @@ public sealed partial class AaruFormat
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, const int32_t tag, uint32_t *length)
|
||||
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_media_tag", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static partial Status aaruf_read_media_tag(IntPtr context, byte[] data, MediaTagType tag, ref uint length);
|
||||
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(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", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
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);
|
||||
|
||||
// AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, const uint64_t sector_address,
|
||||
// const bool negative, uint8_t *buffer, uint32_t *length,
|
||||
// const int32_t tag)
|
||||
[LibraryImport("libaaruformat", EntryPoint = "aaruf_read_sector_tag", SetLastError = true)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
|
||||
private static partial Status aaruf_read_sector_tag(IntPtr context, ulong sectorAddress,
|
||||
[MarshalAs(UnmanagedType.I4)] bool negative, byte[] buffer,
|
||||
ref uint length, SectorTagType tag);
|
||||
}
|
||||
Reference in New Issue
Block a user