[AaruFormat] Implement WriteSectorsTag.

This commit is contained in:
2025-10-12 11:56:59 +01:00
parent 9f78a3ff34
commit 32bbf045cd
2 changed files with 16 additions and 8 deletions

View File

@@ -25,19 +25,12 @@ public sealed partial class AaruFormat
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
uint sectorSize) => throw new NotImplementedException();
/// <inheritdoc />
public bool SetDumpHardware(List<DumpHardware> dumpHardware) => throw new NotImplementedException();
/// <inheritdoc />
public bool SetImageInfo(ImageInfo imageInfo) => throw new NotImplementedException();
/// <inheritdoc />
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) =>
throw new NotImplementedException();
/// <inheritdoc />
public bool? VerifySector(ulong sectorAddress) => throw new NotImplementedException();
@@ -45,7 +38,6 @@ public sealed partial class AaruFormat
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
out List<ulong> unknownLbas) => throw new NotImplementedException();
/// <inheritdoc />
public ErrorNumber ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag, out byte[] buffer) =>
throw new NotImplementedException();

View File

@@ -90,6 +90,22 @@ public sealed partial class AaruFormat
return true;
}
/// <inheritdoc />
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag)
{
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(!WriteSectorTag(sectorData, sectorAddress + i, tag)) return false;
}
return true;
}
#endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative,