diff --git a/Aaru.Images/AaruFormat/Unimplemented.cs b/Aaru.Images/AaruFormat/Unimplemented.cs index 4a9819a01..8c98e0cc0 100644 --- a/Aaru.Images/AaruFormat/Unimplemented.cs +++ b/Aaru.Images/AaruFormat/Unimplemented.cs @@ -43,9 +43,6 @@ public sealed partial class AaruFormat public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag) => throw new NotImplementedException(); - /// - public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) => - throw new NotImplementedException(); /// public bool? VerifySector(ulong sectorAddress) => throw new NotImplementedException(); diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index 9ca1d988a..8b0294fcd 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -46,6 +46,18 @@ public sealed partial class AaruFormat return false; } + /// + public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag) + { + Status res = aaruf_write_sector_tag(_context, sectorAddress, false, data, (ulong)data.Length, tag); + + if(res == Status.Ok) return true; + + ErrorMessage = StatusToErrorMessage(res); + + return false; + } + #endregion // AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative, @@ -70,4 +82,12 @@ public sealed partial class AaruFormat [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] private static partial Status aaruf_write_media_tag(IntPtr context, [In] byte[] data, MediaTagType type, uint length); + + // AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_tag(void *context, const uint64_t sector_address, const bool negative, + // const uint8_t *data, const size_t length, const int32_t tag) + [LibraryImport("libaaruformat", EntryPoint = "aaruf_write_sector_tag", SetLastError = true)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] + private static partial Status aaruf_write_sector_tag(IntPtr context, ulong sectorAddress, + [MarshalAs(UnmanagedType.I4)] bool negative, [In] byte[] data, + ulong length, SectorTagType tag); } \ No newline at end of file