[AaruFormat] Implement WriteSectors.

This commit is contained in:
2025-10-12 11:53:51 +01:00
parent 3d519a6ee7
commit 2791eb6f7a
2 changed files with 16 additions and 3 deletions

View File

@@ -33,9 +33,6 @@ public sealed partial class AaruFormat
public bool SetImageInfo(ImageInfo imageInfo) => throw new NotImplementedException();
/// <inheritdoc />
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException();
/// <inheritdoc />
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException();

View File

@@ -58,6 +58,22 @@ public sealed partial class AaruFormat
return false;
}
/// <inheritdoc />
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length)
{
var sectorSize = (uint)(data.Length / length);
for(uint i = 0; i < length; i++)
{
var sectorData = new byte[sectorSize];
Array.Copy(data, i * sectorSize, sectorData, 0, sectorSize);
if(!WriteSector(sectorData, sectorAddress + i)) return false;
}
return true;
}
#endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative,