mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add interface for byte addressable images.
This commit is contained in:
@@ -76,6 +76,9 @@
|
|||||||
<Compile Include="Extents\ExtentsUShort.cs" />
|
<Compile Include="Extents\ExtentsUShort.cs" />
|
||||||
<Compile Include="Filters.cs" />
|
<Compile Include="Filters.cs" />
|
||||||
<Compile Include="Geometry.cs" />
|
<Compile Include="Geometry.cs" />
|
||||||
|
<Compile Include="Interfaces\IBaseImage.cs" />
|
||||||
|
<Compile Include="Interfaces\IBaseWritableImage.cs" />
|
||||||
|
<Compile Include="Interfaces\IByteAddressableImage.cs" />
|
||||||
<Compile Include="Interfaces\IChecksum.cs" />
|
<Compile Include="Interfaces\IChecksum.cs" />
|
||||||
<Compile Include="Interfaces\IFilesystem.cs" />
|
<Compile Include="Interfaces\IFilesystem.cs" />
|
||||||
<Compile Include="Interfaces\IArchive.cs" />
|
<Compile Include="Interfaces\IArchive.cs" />
|
||||||
|
|||||||
75
Interfaces/IBaseImage.cs
Normal file
75
Interfaces/IBaseImage.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// Aaru Data Preservation Suite
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : IBaseImage.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Disc image plugins.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Defines the interface to be implemented by 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-2021 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Aaru.CommonTypes.Enums;
|
||||||
|
using Aaru.CommonTypes.Structs;
|
||||||
|
using Schemas;
|
||||||
|
|
||||||
|
namespace Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>Base interface for all images</summary>
|
||||||
|
public interface IBaseImage
|
||||||
|
{
|
||||||
|
/// <summary>Plugin author</summary>
|
||||||
|
string Author { get; }
|
||||||
|
/// <summary>Gets the CICM XML metadata for the image</summary>
|
||||||
|
CICMMetadataType CicmMetadata { get; }
|
||||||
|
/// <summary>List of dump hardware used to create the image from real media</summary>
|
||||||
|
List<DumpHardwareType> DumpHardware { get; }
|
||||||
|
/// <summary>Gets the image format.</summary>
|
||||||
|
/// <value>The image format.</value>
|
||||||
|
string Format { get; }
|
||||||
|
/// <summary>Plugin UUID.</summary>
|
||||||
|
Guid Id { get; }
|
||||||
|
/// <summary>Image information</summary>
|
||||||
|
ImageInfo Info { get; }
|
||||||
|
/// <summary>Plugin name.</summary>
|
||||||
|
string Name { get; }
|
||||||
|
|
||||||
|
/// <summary>Identifies the image.</summary>
|
||||||
|
/// <returns><c>true</c>, if image was identified, <c>false</c> otherwise.</returns>
|
||||||
|
/// <param name="imageFilter">Image filter.</param>
|
||||||
|
bool Identify(IFilter imageFilter);
|
||||||
|
|
||||||
|
/// <summary>Opens the image.</summary>
|
||||||
|
/// <returns><c>true</c>, if image was opened, <c>false</c> otherwise.</returns>
|
||||||
|
/// <param name="imageFilter">Image filter.</param>
|
||||||
|
ErrorNumber Open(IFilter imageFilter);
|
||||||
|
}
|
||||||
91
Interfaces/IBaseWritableImage.cs
Normal file
91
Interfaces/IBaseWritableImage.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// Aaru Data Preservation Suite
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : IBaseWritableImage.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Disc image plugins.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Defines the base interface to be implemented by writable 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-2021 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Aaru.CommonTypes.Enums;
|
||||||
|
using Aaru.CommonTypes.Structs;
|
||||||
|
using Schemas;
|
||||||
|
|
||||||
|
namespace Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>Base interface for all writable images</summary>
|
||||||
|
public interface IBaseWritableImage : IBaseImage
|
||||||
|
{
|
||||||
|
/// <summary>Contains a description of the last error</summary>
|
||||||
|
string ErrorMessage { get; }
|
||||||
|
/// <summary>If set to <c>true</c> means the image is opened for writing</summary>
|
||||||
|
bool IsWriting { get; }
|
||||||
|
/// <summary>Gets a list of known extensions for format auto-choosing</summary>
|
||||||
|
IEnumerable<string> KnownExtensions { get; }
|
||||||
|
/// <summary>Gets a list of <see cref="MediaTagType" /> that are supported by the media image format</summary>
|
||||||
|
IEnumerable<MediaTagType> SupportedMediaTags { get; }
|
||||||
|
/// <summary>Gets a list of <see cref="MediaType" /> that are supported by the media image format</summary>
|
||||||
|
IEnumerable<MediaType> SupportedMediaTypes { get; }
|
||||||
|
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
|
||||||
|
IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions { get; }
|
||||||
|
/// <summary>Gets a list of <see cref="SectorTagType" /> that are supported by the media image format</summary>
|
||||||
|
IEnumerable<SectorTagType> SupportedSectorTags { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new image in the specified path, for the specified <see cref="MediaType" />, with the specified
|
||||||
|
/// options to hold a media with the specified number of sectors
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to the new image, with extension</param>
|
||||||
|
/// <param name="mediaType"><see cref="MediaType" /> that will be written in the image</param>
|
||||||
|
/// <param name="options">Options to be used when creating new image</param>
|
||||||
|
/// <param name="sectors">How many sectors the media has.</param>
|
||||||
|
/// <param name="sectorSize"></param>
|
||||||
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors, uint sectorSize);
|
||||||
|
|
||||||
|
/// <summary>Closes the image and flushes all data to disk</summary>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
bool Close();
|
||||||
|
|
||||||
|
/// <summary>Sets the CICM XML metadata for the image</summary>
|
||||||
|
bool SetCicmMetadata(CICMMetadataType metadata);
|
||||||
|
|
||||||
|
/// <summary>Sets the list of dump hardware used to create the image from real media</summary>
|
||||||
|
bool SetDumpHardware(List<DumpHardwareType> dumpHardware);
|
||||||
|
|
||||||
|
/// <summary>Sets image metadata</summary>
|
||||||
|
/// <param name="metadata"><see cref="ImageInfo" /> containing image metadata</param>
|
||||||
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool SetMetadata(ImageInfo metadata);
|
||||||
|
}
|
||||||
143
Interfaces/IByteAddressableImage.cs
Normal file
143
Interfaces/IByteAddressableImage.cs
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// Aaru Data Preservation Suite
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : IByteAddressableImage.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// 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-2021 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Aaru.CommonTypes.Enums;
|
||||||
|
|
||||||
|
namespace Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>Interface defining linear media (chips, game carts, etc) images</summary>
|
||||||
|
public interface IByteAddressableImage : IBaseImage
|
||||||
|
{
|
||||||
|
/// <summary>Gets or sets the current position</summary>
|
||||||
|
long Position { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Creates a linear media image</summary>
|
||||||
|
/// <param name="path">Path where to create the media image</param>
|
||||||
|
/// <param name="mediaType">Media type</param>
|
||||||
|
/// <param name="options">Image options</param>
|
||||||
|
/// <param name="maximumSize">Maximum size in bytes</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber Create(string path, MediaType mediaType, Dictionary<string, string> options, long maximumSize);
|
||||||
|
|
||||||
|
/// <summary>Gets the media image header (really needed?)</summary>
|
||||||
|
/// <param name="header">Header, interchange format still undecided</param>
|
||||||
|
/// <returns>Error message</returns>
|
||||||
|
ErrorNumber GetHeader(out byte[] header);
|
||||||
|
|
||||||
|
/// <summary>Gets the linear memory mappings, e.g. interleaving, starting address, etc.</summary>
|
||||||
|
/// <param name="mappings">Format still not decided</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber GetMappings(out object mappings);
|
||||||
|
|
||||||
|
/// <summary>Reads a byte from the image</summary>
|
||||||
|
/// <param name="b">The byte read</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber ReadByte(out byte b, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Reads a byte from the image at the specified position</summary>
|
||||||
|
/// <param name="position">Position</param>
|
||||||
|
/// <param name="b">The byte read</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber ReadByteAt(long position, out byte b, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Reads several bytes from the image</summary>
|
||||||
|
/// <param name="buffer">Buffer to store the data in</param>
|
||||||
|
/// <param name="offset">Offset in buffer where to place the byte in</param>
|
||||||
|
/// <param name="bytesToRead">How many bytes to read from image</param>
|
||||||
|
/// <param name="bytesRead">How many bytes were read</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber ReadBytes(byte[] buffer, int offset, int bytesToRead, out int bytesRead, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Reads several bytes from the image at the specified position</summary>
|
||||||
|
/// <param name="position">Position</param>
|
||||||
|
/// <param name="buffer">Buffer to store the data in</param>
|
||||||
|
/// <param name="offset">Offset in buffer where to place the byte in</param>
|
||||||
|
/// <param name="bytesToRead">How many bytes to read from image</param>
|
||||||
|
/// <param name="bytesRead">How many bytes were read</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber ReadBytesAt(long position, byte[] buffer, int offset, int bytesToRead, out int bytesRead,
|
||||||
|
bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Sets the media image header (really needed?)</summary>
|
||||||
|
/// <param name="header">Header, interchange format still undecided</param>
|
||||||
|
/// <returns>Error message</returns>
|
||||||
|
ErrorNumber SetHeader(byte[] header);
|
||||||
|
|
||||||
|
/// <summary>Sets the linear memory mappings, e.g. interleaving, starting address, etc.</summary>
|
||||||
|
/// <param name="mappings">Format still not decided</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber SetMappings(object mappings);
|
||||||
|
|
||||||
|
/// <summary>Writes a byte to the image</summary>
|
||||||
|
/// <param name="b">The byte to be written</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber WriteByte(byte b, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Writes a byte to the image at the specified position</summary>
|
||||||
|
/// <param name="position">Position</param>
|
||||||
|
/// <param name="b">The byte read</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber WriteByteAt(long position, byte b, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Writes several bytes to the image</summary>
|
||||||
|
/// <param name="buffer">Buffer to store the data in</param>
|
||||||
|
/// <param name="offset">Offset in buffer where the bytes start in</param>
|
||||||
|
/// <param name="bytesToWrite">How many bytes to write to image</param>
|
||||||
|
/// <param name="bytesWritten">How many bytes were written</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber WriteBytes(byte[] buffer, int offset, int bytesToWrite, out int bytesWritten, bool advance = true);
|
||||||
|
|
||||||
|
/// <summary>Writes several bytes to the image at the specified position</summary>
|
||||||
|
/// <param name="position">Position</param>
|
||||||
|
/// <param name="buffer">Buffer to store the data in</param>
|
||||||
|
/// <param name="offset">Offset in buffer where the bytes start in</param>
|
||||||
|
/// <param name="bytesToWrite">How many bytes to write to image</param>
|
||||||
|
/// <param name="bytesWritten">How many bytes were written</param>
|
||||||
|
/// <param name="advance">Set to <c>true</c> to advance position, <c>false</c> otherwise.</param>
|
||||||
|
/// <returns>Error number</returns>
|
||||||
|
ErrorNumber WriteBytesAt(long position, byte[] buffer, int offset, int bytesToWrite, out int bytesWritten,
|
||||||
|
bool advance = true);
|
||||||
|
}
|
||||||
@@ -37,88 +37,57 @@
|
|||||||
// Copyright © 2011-2021 Natalia Portillo
|
// Copyright © 2011-2021 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Structs;
|
|
||||||
using Schemas;
|
|
||||||
|
|
||||||
namespace Aaru.CommonTypes.Interfaces
|
namespace Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
||||||
|
public interface IMediaImage : IBaseImage
|
||||||
{
|
{
|
||||||
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
/// <summary>Reads a disk tag.</summary>
|
||||||
public interface IMediaImage
|
/// <returns></returns>
|
||||||
{
|
/// <param name="tag">Tag type to read.</param>
|
||||||
/// <summary>Image information</summary>
|
/// <param name="buffer">Disk tag</param>
|
||||||
ImageInfo Info { get; }
|
ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer);
|
||||||
/// <summary>Plugin name.</summary>
|
|
||||||
string Name { get; }
|
|
||||||
/// <summary>Plugin UUID.</summary>
|
|
||||||
Guid Id { get; }
|
|
||||||
/// <summary>Plugin author</summary>
|
|
||||||
string Author { get; }
|
|
||||||
/// <summary>Gets the image format.</summary>
|
|
||||||
/// <value>The image format.</value>
|
|
||||||
string Format { get; }
|
|
||||||
/// <summary>List of dump hardware used to create the image from real media</summary>
|
|
||||||
List<DumpHardwareType> DumpHardware { get; }
|
|
||||||
/// <summary>Gets the CICM XML metadata for the image</summary>
|
|
||||||
CICMMetadataType CicmMetadata { get; }
|
|
||||||
|
|
||||||
/// <summary>Identifies the image.</summary>
|
/// <summary>Reads a sector's user data.</summary>
|
||||||
/// <returns><c>true</c>, if image was identified, <c>false</c> otherwise.</returns>
|
/// <returns>The sector's user data.</returns>
|
||||||
/// <param name="imageFilter">Image filter.</param>
|
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||||
bool Identify(IFilter imageFilter);
|
/// <param name="buffer"></param>
|
||||||
|
ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Opens the image.</summary>
|
/// <summary>Reads a complete sector (user data + all tags).</summary>
|
||||||
/// <returns><c>true</c>, if image was opened, <c>false</c> otherwise.</returns>
|
/// <returns>The complete sector. Format depends on disk type.</returns>
|
||||||
/// <param name="imageFilter">Image filter.</param>
|
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||||
ErrorNumber Open(IFilter imageFilter);
|
/// <param name="buffer"></param>
|
||||||
|
ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Reads a disk tag.</summary>
|
/// <summary>Reads user data from several sectors.</summary>
|
||||||
/// <returns></returns>
|
/// <returns>The sectors user data.</returns>
|
||||||
/// <param name="tag">Tag type to read.</param>
|
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||||
/// <param name="buffer">Disk tag</param>
|
/// <param name="length">How many sectors to read.</param>
|
||||||
ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer);
|
/// <param name="buffer"></param>
|
||||||
|
ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Reads a sector's user data.</summary>
|
/// <summary>Reads several complete sector (user data + all tags).</summary>
|
||||||
/// <returns>The sector's user data.</returns>
|
/// <returns>The complete sectors. Format depends on disk type.</returns>
|
||||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||||
/// <param name="buffer"></param>
|
/// <param name="length">How many sectors to read.</param>
|
||||||
ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer);
|
/// <param name="buffer"></param>
|
||||||
|
ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Reads a sector's tag.</summary>
|
/// <summary>Reads tag from several sectors.</summary>
|
||||||
/// <returns>The sector's tag.</returns>
|
/// <returns>The sectors tag.</returns>
|
||||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||||
/// <param name="tag">Tag type.</param>
|
/// <param name="length">How many sectors to read.</param>
|
||||||
/// <param name="buffer"></param>
|
/// <param name="tag">Tag type.</param>
|
||||||
ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer);
|
/// <param name="buffer"></param>
|
||||||
|
ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Reads user data from several sectors.</summary>
|
/// <summary>Reads a sector's tag.</summary>
|
||||||
/// <returns>The sectors user data.</returns>
|
/// <returns>The sector's tag.</returns>
|
||||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||||
/// <param name="length">How many sectors to read.</param>
|
/// <param name="tag">Tag type.</param>
|
||||||
/// <param name="buffer"></param>
|
/// <param name="buffer"></param>
|
||||||
ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer);
|
ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer);
|
||||||
|
|
||||||
/// <summary>Reads tag from several sectors.</summary>
|
|
||||||
/// <returns>The sectors tag.</returns>
|
|
||||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
|
||||||
/// <param name="length">How many sectors to read.</param>
|
|
||||||
/// <param name="tag">Tag type.</param>
|
|
||||||
/// <param name="buffer"></param>
|
|
||||||
ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer);
|
|
||||||
|
|
||||||
/// <summary>Reads a complete sector (user data + all tags).</summary>
|
|
||||||
/// <returns>The complete sector. Format depends on disk type.</returns>
|
|
||||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
|
||||||
/// <param name="buffer"></param>
|
|
||||||
ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer);
|
|
||||||
|
|
||||||
/// <summary>Reads several complete sector (user data + all tags).</summary>
|
|
||||||
/// <returns>The complete sectors. Format depends on disk type.</returns>
|
|
||||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
|
||||||
/// <param name="length">How many sectors to read.</param>
|
|
||||||
/// <param name="buffer"></param>
|
|
||||||
ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
//
|
//
|
||||||
// --[ Description ] ----------------------------------------------------------
|
// --[ Description ] ----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Defines the interface to be implemented by writable image plugins.
|
// Defines the interface to be implemented by writable block addressable image plugins.
|
||||||
//
|
//
|
||||||
// --[ License ] --------------------------------------------------------------
|
// --[ License ] --------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -36,119 +36,69 @@
|
|||||||
// Copyright © 2011-2021 Natalia Portillo
|
// Copyright © 2011-2021 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Structs;
|
|
||||||
using Schemas;
|
|
||||||
|
|
||||||
namespace Aaru.CommonTypes.Interfaces
|
namespace Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abstract class to implement disk image writing plugins. TODO: This interface is subject to change until
|
||||||
|
/// notice.
|
||||||
|
/// </summary>
|
||||||
|
public interface IWritableImage : IMediaImage, IBaseWritableImage
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <summary>Sets media geometry</summary>
|
||||||
/// <summary>
|
/// <param name="cylinders">Cylinders</param>
|
||||||
/// Abstract class to implement disk image writing plugins. TODO: This interface is subject to change until
|
/// <param name="heads">Heads</param>
|
||||||
/// notice.
|
/// <param name="sectorsPerTrack">Sectors per track</param>
|
||||||
/// </summary>
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
public interface IWritableImage : IMediaImage
|
bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack);
|
||||||
{
|
|
||||||
/// <summary>Gets a list of <see cref="MediaTagType" /> that are supported by the media image format</summary>
|
|
||||||
IEnumerable<MediaTagType> SupportedMediaTags { get; }
|
|
||||||
/// <summary>Gets a list of <see cref="SectorTagType" /> that are supported by the media image format</summary>
|
|
||||||
IEnumerable<SectorTagType> SupportedSectorTags { get; }
|
|
||||||
/// <summary>Gets a list of <see cref="MediaType" /> that are supported by the media image format</summary>
|
|
||||||
IEnumerable<MediaType> SupportedMediaTypes { get; }
|
|
||||||
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
|
|
||||||
IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions { get; }
|
|
||||||
/// <summary>Gets a list of known extensions for format auto-choosing</summary>
|
|
||||||
IEnumerable<string> KnownExtensions { get; }
|
|
||||||
|
|
||||||
/// <summary>If set to <c>true</c> means the image is opened for writing</summary>
|
/// <summary>Writes a media tag to the image</summary>
|
||||||
bool IsWriting { get; }
|
/// <param name="data">Media tag</param>
|
||||||
/// <summary>Contains a description of the last error</summary>
|
/// <param name="tag">
|
||||||
string ErrorMessage { get; }
|
/// <see cref="MediaTagType" />
|
||||||
|
/// </param>
|
||||||
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool WriteMediaTag(byte[] data, MediaTagType tag);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Writes a sector to the image</summary>
|
||||||
/// Creates a new image in the specified path, for the specified <see cref="MediaType" />, with the specified
|
/// <param name="data">Sector data</param>
|
||||||
/// options to hold a media with the specified number of sectors
|
/// <param name="sectorAddress">Sector address</param>
|
||||||
/// </summary>
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
/// <param name="path">Path to the new image, with extension</param>
|
bool WriteSector(byte[] data, ulong sectorAddress);
|
||||||
/// <param name="mediaType"><see cref="MediaType" /> that will be written in the image</param>
|
|
||||||
/// <param name="options">Options to be used when creating new image</param>
|
|
||||||
/// <param name="sectors">How many sectors the media has.</param>
|
|
||||||
/// <param name="sectorSize"></param>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
|
||||||
uint sectorSize);
|
|
||||||
|
|
||||||
/// <summary>Writes a media tag to the image</summary>
|
/// <summary>Writes a sector to the image with main channel tags attached</summary>
|
||||||
/// <param name="data">Media tag</param>
|
/// <param name="data">Sector data with its main channel tags attached</param>
|
||||||
/// <param name="tag">
|
/// <param name="sectorAddress">Sector address</param>
|
||||||
/// <see cref="MediaTagType" />
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
/// </param>
|
bool WriteSectorLong(byte[] data, ulong sectorAddress);
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool WriteMediaTag(byte[] data, MediaTagType tag);
|
|
||||||
|
|
||||||
/// <summary>Writes a sector to the image</summary>
|
/// <summary>Writes several sectors to the image</summary>
|
||||||
/// <param name="data">Sector data</param>
|
/// <param name="data">Sectors data</param>
|
||||||
/// <param name="sectorAddress">Sector address</param>
|
/// <param name="sectorAddress">Sector starting address</param>
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
/// <param name="length">How many sectors to write</param>
|
||||||
bool WriteSector(byte[] data, ulong sectorAddress);
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool WriteSectors(byte[] data, ulong sectorAddress, uint length);
|
||||||
|
|
||||||
/// <summary>Writes several sectors to the image</summary>
|
/// <summary>Writes several sectors to the image</summary>
|
||||||
/// <param name="data">Sectors data</param>
|
/// <param name="data">Sector data with their main channel tags attached</param>
|
||||||
/// <param name="sectorAddress">Sector starting address</param>
|
/// <param name="sectorAddress">Sector starting address</param>
|
||||||
/// <param name="length">How many sectors to write</param>
|
/// <param name="length">How many sectors to write</param>
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
bool WriteSectors(byte[] data, ulong sectorAddress, uint length);
|
bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length);
|
||||||
|
|
||||||
/// <summary>Writes a sector to the image with main channel tags attached</summary>
|
/// <summary>Writes parallel or subchannel sector tag for several sector</summary>
|
||||||
/// <param name="data">Sector data with its main channel tags attached</param>
|
/// <param name="data">Tag data to write</param>
|
||||||
/// <param name="sectorAddress">Sector address</param>
|
/// <param name="sectorAddress">Starting sector address</param>
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
/// <param name="length">How many sectors to write</param>
|
||||||
bool WriteSectorLong(byte[] data, ulong sectorAddress);
|
/// <param name="tag">Tag type</param>
|
||||||
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag);
|
||||||
|
|
||||||
/// <summary>Writes several sectors to the image</summary>
|
/// <summary>Writes parallel or subchannel sector tag for one sector</summary>
|
||||||
/// <param name="data">Sector data with their main channel tags attached</param>
|
/// <param name="data">Tag data to write</param>
|
||||||
/// <param name="sectorAddress">Sector starting address</param>
|
/// <param name="sectorAddress">Sector address</param>
|
||||||
/// <param name="length">How many sectors to write</param>
|
/// <param name="tag">Tag type</param>
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length);
|
bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag);
|
||||||
|
|
||||||
/// <summary>Closes and flushes to disk the image</summary>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool Close();
|
|
||||||
|
|
||||||
/// <summary>Sets image metadata</summary>
|
|
||||||
/// <param name="metadata"><see cref="ImageInfo" /> containing image metadata</param>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool SetMetadata(ImageInfo metadata);
|
|
||||||
|
|
||||||
/// <summary>Sets media geometry</summary>
|
|
||||||
/// <param name="cylinders">Cylinders</param>
|
|
||||||
/// <param name="heads">Heads</param>
|
|
||||||
/// <param name="sectorsPerTrack">Sectors per track</param>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack);
|
|
||||||
|
|
||||||
/// <summary>Writes parallel or subchannel sector tag for one sector</summary>
|
|
||||||
/// <param name="data">Tag data to write</param>
|
|
||||||
/// <param name="sectorAddress">Sector address</param>
|
|
||||||
/// <param name="tag">Tag type</param>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag);
|
|
||||||
|
|
||||||
/// <summary>Writes parallel or subchannel sector tag for several sector</summary>
|
|
||||||
/// <param name="data">Tag data to write</param>
|
|
||||||
/// <param name="sectorAddress">Starting sector address</param>
|
|
||||||
/// <param name="length">How many sectors to write</param>
|
|
||||||
/// <param name="tag">Tag type</param>
|
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
|
||||||
bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag);
|
|
||||||
|
|
||||||
/// <summary>Sets the list of dump hardware used to create the image from real media</summary>
|
|
||||||
bool SetDumpHardware(List<DumpHardwareType> dumpHardware);
|
|
||||||
|
|
||||||
/// <summary>Sets the CICM XML metadata for the image</summary>
|
|
||||||
bool SetCicmMetadata(CICMMetadataType metadata);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user