Refactor sector writing methods to include SectorStatus parameter and update related logic

This commit is contained in:
2025-10-22 20:25:23 +01:00
parent 0ac2a48fb6
commit ce0e0dff22
55 changed files with 927 additions and 676 deletions

View File

@@ -100,7 +100,7 @@ public sealed partial class Nhdr0
}
/// <inheritdoc />
public bool WriteSector(byte[] data, ulong sectorAddress)
public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus)
{
if(!IsWriting)
{
@@ -134,7 +134,7 @@ public sealed partial class Nhdr0
}
/// <inheritdoc />
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length)
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus)
{
if(!IsWriting)
{
@@ -168,7 +168,7 @@ public sealed partial class Nhdr0
}
/// <inheritdoc />
public bool WriteSectorLong(byte[] data, ulong sectorAddress)
public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus)
{
ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported;
@@ -176,7 +176,7 @@ public sealed partial class Nhdr0
}
/// <inheritdoc />
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length)
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus)
{
ErrorMessage = Localization.Writing_sectors_with_tags_is_not_supported;
@@ -239,8 +239,8 @@ public sealed partial class Nhdr0
commentBytes.Length >= 0x100 ? 0x100 : commentBytes.Length);
}
byte[] hdr = new byte[Marshal.SizeOf<Header>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Header>());
var hdr = new byte[Marshal.SizeOf<Header>()];
nint hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf<Header>());
System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true);
System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr);