[AaruFormat] Implement WriteMediaTag.

This commit is contained in:
2025-10-12 11:42:42 +01:00
parent 2859153a51
commit 6eed7d5492
2 changed files with 20 additions and 4 deletions

View File

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

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Enums;
namespace Aaru.Images; namespace Aaru.Images;
@@ -33,6 +34,18 @@ public sealed partial class AaruFormat
return false; return false;
} }
/// <inheritdoc />
public bool WriteMediaTag(byte[] data, MediaTagType tag)
{
Status res = aaruf_write_media_tag(_context, data, tag, (uint)data.Length);
if(res == Status.Ok) return true;
ErrorMessage = StatusToErrorMessage(res);
return false;
}
#endregion #endregion
// AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative, // AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative,
@@ -50,4 +63,11 @@ public sealed partial class AaruFormat
private static partial Status aaruf_write_sector_long(IntPtr context, ulong sectorAddress, private static partial Status aaruf_write_sector_long(IntPtr context, ulong sectorAddress,
[MarshalAs(UnmanagedType.I4)] bool negative, [In] byte[] data, [MarshalAs(UnmanagedType.I4)] bool negative, [In] byte[] data,
SectorStatus sectorStatus, uint length); SectorStatus sectorStatus, uint length);
// AARU_EXPORT int32_t AARU_CALL aaruf_write_media_tag(void *context, const uint8_t *data, const int32_t type,
// const uint32_t length)
[LibraryImport("libaaruformat", EntryPoint = "aaruf_write_media_tag", SetLastError = true)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static partial Status aaruf_write_media_tag(IntPtr context, [In] byte[] data, MediaTagType type,
uint length);
} }