// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : IByteAddressableImage.cs // Author(s) : Natalia Portillo // // Component : Disc image plugins. // // --[ Description ] ---------------------------------------------------------- // // Defines the interface to be implemented by byte-addressable image plugins. // // --[ License ] -------------------------------------------------------------- // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // ---------------------------------------------------------------------------- // Copyright © 2011-2024 Natalia Portillo // ****************************************************************************/ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; namespace Aaru.CommonTypes.Interfaces; /// /// Interface defining linear media (chips, game carts, etc) images [SuppressMessage("ReSharper", "UnusedParameter.Global")] [SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] [SuppressMessage("ReSharper", "UnusedMember.Global")] [SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")] [SuppressMessage("ReSharper", "OutParameterValueIsAlwaysDiscarded.Global")] public interface IByteAddressableImage : IBaseWritableImage { /// Gets or sets the current position long Position { get; set; } /// Creates a linear media image /// Path where to create the media image /// Media type /// Image options /// Maximum size in bytes /// Error number ErrorNumber Create(string path, MediaType mediaType, Dictionary options, long maximumSize); /// Gets the linear memory mappings, e.g. interleaving, starting address, etc. /// Format still not decided /// Error number ErrorNumber GetMappings(out LinearMemoryMap mappings); /// Reads a byte from the image /// The byte read /// Set to true to advance position, false otherwise. /// Error number ErrorNumber ReadByte(out byte b, bool advance = true); /// Reads a byte from the image at the specified position /// Position /// The byte read /// Set to true to advance position, false otherwise. /// Error number ErrorNumber ReadByteAt(long position, out byte b, bool advance = true); /// Reads several bytes from the image /// Buffer to store the data in /// Offset in buffer where to place the byte in /// How many bytes to read from image /// How many bytes were read /// Set to true to advance position, false otherwise. /// Error number ErrorNumber ReadBytes(byte[] buffer, int offset, int bytesToRead, out int bytesRead, bool advance = true); /// Reads several bytes from the image at the specified position /// Position /// Buffer to store the data in /// Offset in buffer where to place the byte in /// How many bytes to read from image /// How many bytes were read /// Set to true to advance position, false otherwise. /// Error number ErrorNumber ReadBytesAt(long position, byte[] buffer, int offset, int bytesToRead, out int bytesRead, bool advance = true); /// Sets the linear memory mappings, e.g. interleaving, starting address, etc. /// Format still not decided /// Error number ErrorNumber SetMappings(LinearMemoryMap mappings); /// Writes a byte to the image /// The byte to be written /// Set to true to advance position, false otherwise. /// Error number ErrorNumber WriteByte(byte b, bool advance = true); /// Writes a byte to the image at the specified position /// Position /// The byte read /// Set to true to advance position, false otherwise. /// Error number ErrorNumber WriteByteAt(long position, byte b, bool advance = true); /// Writes several bytes to the image /// Buffer to store the data in /// Offset in buffer where the bytes start in /// How many bytes to write to image /// How many bytes were written /// Set to true to advance position, false otherwise. /// Error number ErrorNumber WriteBytes(byte[] buffer, int offset, int bytesToWrite, out int bytesWritten, bool advance = true); /// Writes several bytes to the image at the specified position /// Position /// Buffer to store the data in /// Offset in buffer where the bytes start in /// How many bytes to write to image /// How many bytes were written /// Set to true to advance position, false otherwise. /// Error number ErrorNumber WriteBytesAt(long position, byte[] buffer, int offset, int bytesToWrite, out int bytesWritten, bool advance = true); }