diff --git a/Aaru.Images/AaruFormat/Unimplemented.cs b/Aaru.Images/AaruFormat/Unimplemented.cs index 8c98e0cc0..3730c316e 100644 --- a/Aaru.Images/AaruFormat/Unimplemented.cs +++ b/Aaru.Images/AaruFormat/Unimplemented.cs @@ -33,9 +33,6 @@ public sealed partial class AaruFormat public bool SetImageInfo(ImageInfo imageInfo) => throw new NotImplementedException(); - /// - public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); - /// public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length) => throw new NotImplementedException(); diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index 8b0294fcd..63eb1916c 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -58,6 +58,22 @@ public sealed partial class AaruFormat return false; } + /// + 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,