mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
Move all interfaces, extents, interop and metadata to DiscImageChef.CommonTypes.
This commit is contained in:
60
Interfaces/IChecksum.cs
Normal file
60
Interfaces/IChecksum.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IChecksum.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Checksums.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Provides an interface for implementing checksums and hashes.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IChecksum
|
||||
{
|
||||
/// <summary>
|
||||
/// Updates the hash with data.
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of buffer to hash.</param>
|
||||
void Update(byte[] data, uint len);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the hash with data.
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</param>
|
||||
void Update(byte[] data);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a byte array of the hash value.
|
||||
/// </summary>
|
||||
byte[] Final();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hexadecimal representation of the hash value.
|
||||
/// </summary>
|
||||
string End();
|
||||
}
|
||||
}
|
||||
72
Interfaces/IFilesystem.cs
Normal file
72
Interfaces/IFilesystem.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFilesystem.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filesystem plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Interface for filesystem plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Schemas;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to implement filesystem plugins.
|
||||
/// </summary>
|
||||
public interface IFilesystem
|
||||
{
|
||||
Encoding Encoding { get; }
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>
|
||||
/// Information about the filesystem as expected by CICM Metadata XML
|
||||
/// </summary>
|
||||
/// <value>Information about the filesystem as expected by CICM Metadata XML</value>
|
||||
FileSystemType XmlFsType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the filesystem in the specified LBA
|
||||
/// </summary>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partition">Partition.</param>
|
||||
/// <returns><c>true</c>, if the filesystem is recognized, <c>false</c> otherwise.</returns>
|
||||
bool Identify(IMediaImage imagePlugin, Partition partition);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the identified filesystem.
|
||||
/// </summary>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partition">Partition.</param>
|
||||
/// <param name="information">Filesystem information.</param>
|
||||
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
||||
void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding);
|
||||
}
|
||||
}
|
||||
172
Interfaces/IFilter.cs
Normal file
172
Interfaces/IFilter.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFilter.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filters.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines the interface for a Filter.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IFilter
|
||||
{
|
||||
/// <summary>Descriptive name of the plugin</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Unique UUID of the plugin</summary>
|
||||
Guid Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Closes all opened streams.
|
||||
/// </summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path used to open this filter.<br />
|
||||
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip/path/to/file.bin <br />
|
||||
/// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip\path\to\file.bin
|
||||
/// </summary>
|
||||
/// <returns>Path used to open this filter.</returns>
|
||||
string GetBasePath();
|
||||
|
||||
/// <summary>
|
||||
/// Gets creation time of file referenced by this filter.
|
||||
/// </summary>
|
||||
/// <returns>The creation time.</returns>
|
||||
DateTime GetCreationTime();
|
||||
|
||||
/// <summary>
|
||||
/// Gets length of this filter's data fork.
|
||||
/// </summary>
|
||||
/// <returns>The data fork length.</returns>
|
||||
long GetDataForkLength();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stream to access the data fork contents.
|
||||
/// </summary>
|
||||
/// <returns>The data fork stream.</returns>
|
||||
Stream GetDataForkStream();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filename for the file referenced by this filter.<br />
|
||||
/// UNIX: /path/to/archive.zip/path/to/file.bin => file.bin <br />
|
||||
/// Windows: C:\path\to\archive.zip\path\to\file.bin => file.bin
|
||||
/// </summary>
|
||||
/// <returns>The filename.</returns>
|
||||
string GetFilename();
|
||||
|
||||
/// <summary>
|
||||
/// Gets last write time of file referenced by this filter.
|
||||
/// </summary>
|
||||
/// <returns>The last write time.</returns>
|
||||
DateTime GetLastWriteTime();
|
||||
|
||||
/// <summary>
|
||||
/// Gets length of file referenced by ths filter.
|
||||
/// </summary>
|
||||
/// <returns>The length.</returns>
|
||||
long GetLength();
|
||||
|
||||
/// <summary>
|
||||
/// Gets full path to file referenced by this filter. If it's an archive, it's the path inside the archive.<br />
|
||||
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/file.bin <br />
|
||||
/// Windows: C:\path\to\archive.zip\path\to\file.bin => \path\to\file.bin
|
||||
/// </summary>
|
||||
/// <returns>The path.</returns>
|
||||
string GetPath();
|
||||
|
||||
/// <summary>
|
||||
/// Gets path to parent folder to the file referenced by this filter. If it's an archive, it's the full path to the
|
||||
/// archive itself.<br />
|
||||
/// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip <br />
|
||||
/// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip
|
||||
/// </summary>
|
||||
/// <returns>The parent folder.</returns>
|
||||
string GetParentFolder();
|
||||
|
||||
/// <summary>
|
||||
/// Gets length of this filter's resource fork.
|
||||
/// </summary>
|
||||
/// <returns>The resource fork length.</returns>
|
||||
long GetResourceForkLength();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a stream to access the resource fork contents.
|
||||
/// </summary>
|
||||
/// <returns>The resource fork stream.</returns>
|
||||
Stream GetResourceForkStream();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the file referenced by this filter has a resource fork
|
||||
/// </summary>
|
||||
bool HasResourceFork();
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified path contains data recognizable by this filter instance
|
||||
/// </summary>
|
||||
/// <param name="path">Path.</param>
|
||||
bool Identify(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified stream contains data recognizable by this filter instance
|
||||
/// </summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
bool Identify(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified buffer contains data recognizable by this filter instance
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
bool Identify(byte[] buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the filter has a file/stream/buffer currently opened and no
|
||||
/// <see cref="M:DiscImageChef.Filters.Filter.Close" /> has been issued.
|
||||
/// </summary>
|
||||
bool IsOpened();
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified path with this filter instance
|
||||
/// </summary>
|
||||
/// <param name="path">Path.</param>
|
||||
void Open(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified stream with this filter instance
|
||||
/// </summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
void Open(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified buffer with this filter instance
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
void Open(byte[] buffer);
|
||||
}
|
||||
}
|
||||
129
Interfaces/IFloppyImage.cs
Normal file
129
Interfaces/IFloppyImage.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFloppyImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by floppy image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins that can contain floppy images.
|
||||
/// This interface is needed because floppy formatting characteristics are not necesarily compatible with the whole.
|
||||
/// LBA-oriented interface is defined by <see cref="IMediaImage" />.
|
||||
/// All data returned by these methods is already decoded from its corresponding bitstream.
|
||||
/// </summary>
|
||||
public interface IFloppyImage : IMediaImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Floppy info, contains information about physical characteristics of floppy, like size, bitrate, track density,
|
||||
/// etc...
|
||||
/// </summary>
|
||||
FloppyInfo FloppyInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's user data.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned.
|
||||
/// Otherwise, whatever is in the sector is returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
byte[] ReadSector(ushort track, byte head, ushort sector, out FloppySectorStatus status);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's tag.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned.
|
||||
/// Otherwise, whatever tag is in the sector is returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
byte[] ReadSectorTag(ushort track, byte head, ushort sector, out FloppySectorStatus status, SectorTagType tag);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a whole track. It includes all gaps, address marks, sectors data, etc.
|
||||
/// </summary>
|
||||
/// <returns>The track data.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
byte[] ReadTrack(ushort track, byte head);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's data including all tags, address mark, and so, in a format dependent of represented media.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates is returned
|
||||
/// randomly.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" /> or
|
||||
/// <see cref="FloppySectorStatus.Hole" /> random data is returned.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.NotFound" /> <c>null</c> is returned.
|
||||
/// Otherwise, whatever is in the sector is returned.
|
||||
/// </returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
byte[] ReadSectorLong(ushort track, byte head, ushort sector, out FloppySectorStatus status);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a track.
|
||||
/// </summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
bool? VerifyTrack(ushort track, byte head);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a sector, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
bool? VerifySector(ushort track, byte head, ushort sector);
|
||||
}
|
||||
}
|
||||
257
Interfaces/IMediaImage.cs
Normal file
257
Interfaces/IMediaImage.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IMediaImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by disc image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins.
|
||||
/// </summary>
|
||||
public interface IMediaImage
|
||||
{
|
||||
/// <summary>Image information</summary>
|
||||
ImageInfo Info { get; }
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>
|
||||
/// Gets the image format.
|
||||
/// </summary>
|
||||
/// <value>The image format.</value>
|
||||
string Format { get; }
|
||||
/// <summary>
|
||||
/// Gets an array partitions. Typically only useful for optical disc
|
||||
/// images where each track and index means a different partition, as
|
||||
/// reads can be relative to them.
|
||||
/// </summary>
|
||||
/// <value>The partitions.</value>
|
||||
List<Partition> Partitions { get; }
|
||||
/// <summary>
|
||||
/// Gets the disc track extents (start, length).
|
||||
/// </summary>
|
||||
/// <value>The track extents.</value>
|
||||
List<Track> Tracks { get; }
|
||||
/// <summary>
|
||||
/// Gets the sessions (optical discs only).
|
||||
/// </summary>
|
||||
/// <value>The sessions.</value>
|
||||
List<Session> Sessions { 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>
|
||||
/// <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>
|
||||
bool Open(IFilter imageFilter);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a disk tag.
|
||||
/// </summary>
|
||||
/// <returns>Disk tag</returns>
|
||||
/// <param name="tag">Tag type to read.</param>
|
||||
byte[] ReadDiskTag(MediaTagType tag);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's user data.
|
||||
/// </summary>
|
||||
/// <returns>The sector's user data.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
byte[] ReadSector(ulong sectorAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's tag.
|
||||
/// </summary>
|
||||
/// <returns>The sector's tag.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's user data, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The sector's user data.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
byte[] ReadSector(ulong sectorAddress, uint track);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's tag, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The sector's tag.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag);
|
||||
|
||||
/// <summary>
|
||||
/// Reads user data from several sectors.
|
||||
/// </summary>
|
||||
/// <returns>The sectors user data.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
byte[] ReadSectors(ulong sectorAddress, uint length);
|
||||
|
||||
/// <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>
|
||||
byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag);
|
||||
|
||||
/// <summary>
|
||||
/// Reads user data from several sectors, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The sectors user data.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
byte[] ReadSectors(ulong sectorAddress, uint length, uint track);
|
||||
|
||||
/// <summary>
|
||||
/// Reads tag from several sectors, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The sectors tag.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="tag">Tag type.</param>
|
||||
byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag);
|
||||
|
||||
/// <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>
|
||||
byte[] ReadSectorLong(ulong sectorAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a complete sector (user data + all tags), relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The complete sector. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
byte[] ReadSectorLong(ulong sectorAddress, uint track);
|
||||
|
||||
/// <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>
|
||||
byte[] ReadSectorsLong(ulong sectorAddress, uint length);
|
||||
|
||||
/// <summary>
|
||||
/// Reads several complete sector (user data + all tags), relative to track.
|
||||
/// </summary>
|
||||
/// <returns>The complete sectors. Format depends on disk type.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the disc track extents for a specified session.
|
||||
/// </summary>
|
||||
/// <returns>The track exents for that session.</returns>
|
||||
/// <param name="session">Session.</param>
|
||||
List<Track> GetSessionTracks(Session session);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the disc track extents for a specified session.
|
||||
/// </summary>
|
||||
/// <returns>The track exents for that session.</returns>
|
||||
/// <param name="session">Session.</param>
|
||||
List<Track> GetSessionTracks(ushort session);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a sector.
|
||||
/// </summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Sector address (LBA).</param>
|
||||
bool? VerifySector(ulong sectorAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a sector, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Sector address (relative LBA).</param>
|
||||
/// <param name="track">Track.</param>
|
||||
bool? VerifySector(ulong sectorAddress, uint track);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies several sectors.
|
||||
/// </summary>
|
||||
/// <returns>True if all are correct, false if any is incorrect, null if any is uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="failingLbas">List of incorrect sectors</param>
|
||||
/// <param name="unknownLbas">List of uncheckable sectors</param>
|
||||
bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas, out List<ulong> unknownLbas);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies several sectors, relative to track.
|
||||
/// </summary>
|
||||
/// <returns>True if all are correct, false if any is incorrect, null if any is uncheckable.</returns>
|
||||
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
|
||||
/// <param name="length">How many sectors to read.</param>
|
||||
/// <param name="track">Track.</param>
|
||||
/// <param name="failingLbas">List of incorrect sectors</param>
|
||||
/// <param name="unknownLbas">List of uncheckable sectors</param>
|
||||
bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
||||
out List<ulong> unknownLbas);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies media image internal checksum.
|
||||
/// </summary>
|
||||
/// <returns>True if correct, false if incorrect, null if there is no internal checksum available</returns>
|
||||
bool? VerifyMediaImage();
|
||||
}
|
||||
}
|
||||
60
Interfaces/IPartition.cs
Normal file
60
Interfaces/IPartition.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IPartition.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Partitioning scheme plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines methods to be used by partitioning scheme plugins and several
|
||||
// constants.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement partitioning schemes interpreting plugins.
|
||||
/// </summary>
|
||||
public interface IPartition
|
||||
{
|
||||
/// <summary>Plugin name.</summary>
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interprets a partitioning scheme.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if partitioning scheme is recognized, <c>false</c> otherwise.</returns>
|
||||
/// <param name="imagePlugin">Disk image.</param>
|
||||
/// <param name="partitions">Returns list of partitions.</param>
|
||||
/// <param name="sectorOffset">At which sector to start searching for the partition scheme.</param>
|
||||
bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset);
|
||||
}
|
||||
}
|
||||
138
Interfaces/IReadOnlyFilesystem.cs
Normal file
138
Interfaces/IReadOnlyFilesystem.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IReadOnlyFilesystem.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Filesystem plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Interface for filesystem plugins that offer read-only support of their
|
||||
// contents.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to implement filesystem plugins.
|
||||
/// </summary>
|
||||
public interface IReadOnlyFilesystem : IFilesystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a list of options supported by the filesystem, with name, type and description
|
||||
/// </summary>
|
||||
IEnumerable<(string name, Type type, string description)> SupportedOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializates whatever internal structures the filesystem plugin needs to be able to read files and directories
|
||||
/// from the filesystem.
|
||||
/// </summary>
|
||||
/// <param name="imagePlugin"></param>
|
||||
/// <param name="partition"></param>
|
||||
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
||||
/// <param name="options">Dictionary of key=value pairs containing options to pass to the filesystem</param>
|
||||
Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options);
|
||||
|
||||
/// <summary>
|
||||
/// Frees all internal structures created by
|
||||
/// <see cref="Mount" />
|
||||
/// </summary>
|
||||
Errno Unmount();
|
||||
|
||||
/// <summary>
|
||||
/// Maps a filesystem block from a file to a block from the underlying device.
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="fileBlock">File block.</param>
|
||||
/// <param name="deviceBlock">Device block.</param>
|
||||
Errno MapBlock(string path, long fileBlock, out long deviceBlock);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attributes of a file or directory
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="attributes">File attributes.</param>
|
||||
Errno GetAttributes(string path, out FileAttributes attributes);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all extended attributes, alternate data streams and forks of the given file.
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">Path.</param>
|
||||
/// <param name="xattrs">List of extended attributes, alternate data streams and forks.</param>
|
||||
Errno ListXAttr(string path, out List<string> xattrs);
|
||||
|
||||
/// <summary>
|
||||
/// Reads an extended attribute, alternate data stream or fork from the given file.
|
||||
/// </summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="xattr">Extendad attribute, alternate data stream or fork name.</param>
|
||||
/// <param name="buf">Buffer.</param>
|
||||
Errno GetXattr(string path, string xattr, ref byte[] buf);
|
||||
|
||||
/// <summary>
|
||||
/// Reads data from a file (main/only data stream or data fork).
|
||||
/// </summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="offset">Offset.</param>
|
||||
/// <param name="size">Bytes to read.</param>
|
||||
/// <param name="buf">Buffer.</param>
|
||||
Errno Read(string path, long offset, long size, ref byte[] buf);
|
||||
|
||||
/// <summary>
|
||||
/// Lists contents from a directory.
|
||||
/// </summary>
|
||||
/// <param name="path">Directory path.</param>
|
||||
/// <param name="contents">Directory contents.</param>
|
||||
Errno ReadDir(string path, out List<string> contents);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the mounted volume.
|
||||
/// </summary>
|
||||
/// <param name="stat">Information about the mounted volume.</param>
|
||||
Errno StatFs(out FileSystemInfo stat);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about a file or directory.
|
||||
/// </summary>
|
||||
/// <param name="path">File path.</param>
|
||||
/// <param name="stat">File information.</param>
|
||||
Errno Stat(string path, out FileEntryInfo stat);
|
||||
|
||||
/// <summary>
|
||||
/// Solves a symbolic link.
|
||||
/// </summary>
|
||||
/// <param name="path">Link path.</param>
|
||||
/// <param name="dest">Link destination.</param>
|
||||
Errno ReadLink(string path, out string dest);
|
||||
}
|
||||
}
|
||||
98
Interfaces/IWritableFloppyImage.cs
Normal file
98
Interfaces/IWritableFloppyImage.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IFloppyImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by floppy image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins that can contain floppy images.
|
||||
/// This interface is needed because floppy formatting characteristics are not necesarily compatible with the whole
|
||||
/// LBA-oriented interface defined by <see cref="IMediaImage" />.
|
||||
/// All data expected by these methods is already decoded from its corresponding bitstream.
|
||||
/// </summary>
|
||||
public interface IWritableFloppyImage : IFloppyImage, IWritableImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the image plugin the floppy physical characteristics and must be called before following methods are
|
||||
/// called. Once this is called, LBA-based methods should not be used.
|
||||
/// </summary>
|
||||
/// <param name="info">
|
||||
/// Floppy info, contains information about physical characteristics of floppy, like size, bitrate,
|
||||
/// track density, etc...
|
||||
/// </param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetFloppyCharacteristics(FloppyInfo info);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sector's user data.
|
||||
/// </summary>
|
||||
/// <param name="data">
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" />, <see cref="FloppySectorStatus.Hole" />,
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> it will be ignored.
|
||||
/// Otherwise, whatever data should be in the sector.
|
||||
/// </param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of sector.</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSector(byte[] data, ushort track, byte head, ushort sector, FloppySectorStatus status);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a whole track, including all gaps, address marks, sectors data, etc.
|
||||
/// </summary>
|
||||
/// <param name="data">The track data.</param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteTrack(byte[] data, ushort track, byte head);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sector's data including all tags, address mark, and so, in a format dependent of represented media.
|
||||
/// </summary>
|
||||
/// <param name="data">
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Duplicated" /> one of the duplicates.
|
||||
/// If <see cref="status" /> is <see cref="FloppySectorStatus.Demagnetized" />, <see cref="FloppySectorStatus.Hole" />,
|
||||
/// <see cref="FloppySectorStatus.NotFound" /> it will be ignored.
|
||||
/// Otherwise, whatever data should be in the sector.
|
||||
/// </param>
|
||||
/// <param name="track">Physical track (position of the heads over the floppy media, 0-based).</param>
|
||||
/// <param name="head">Physical head (0-based).</param>
|
||||
/// <param name="sector">Logical sector ID.</param>
|
||||
/// <param name="status">Status of request.</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorLong(byte[] data, ushort track, byte head, ushort sector, out FloppySectorStatus status);
|
||||
}
|
||||
}
|
||||
186
Interfaces/IWritableImage.cs
Normal file
186
Interfaces/IWritableImage.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : IWritableImage.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Disc image plugins.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Defines interface to be implemented by writable image plugins.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using Schemas;
|
||||
|
||||
namespace DiscImageChef.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
|
||||
{
|
||||
/// <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)> SupportedOptions { get; }
|
||||
/// <summary>
|
||||
/// Gets a list of known extensions for format auto-chosing
|
||||
/// </summary>
|
||||
IEnumerable<string> KnownExtensions { get; }
|
||||
|
||||
bool IsWriting { get; }
|
||||
string ErrorMessage { 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>
|
||||
/// Writes a media tag to the image
|
||||
/// </summary>
|
||||
/// <param name="data">Media tag</param>
|
||||
/// <param name="tag">
|
||||
/// <see cref="MediaTagType" />
|
||||
/// </param>
|
||||
/// <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>
|
||||
/// <param name="data">Sector data</param>
|
||||
/// <param name="sectorAddress">Sector address</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSector(byte[] data, ulong sectorAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Writes several sectors to the image
|
||||
/// </summary>
|
||||
/// <param name="data">Sectors data</param>
|
||||
/// <param name="sectorAddress">Sector starting address</param>
|
||||
/// <param name="length">How many sectors to write</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectors(byte[] data, ulong sectorAddress, uint length);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sector to the image with main channel tags attached
|
||||
/// </summary>
|
||||
/// <param name="data">Sector data with its main channel tags attached</param>
|
||||
/// <param name="sectorAddress">Sector address</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorLong(byte[] data, ulong sectorAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Writes several sectors to the image
|
||||
/// </summary>
|
||||
/// <param name="data">Sector data with their main channel tags attached</param>
|
||||
/// <param name="sectorAddress">Sector starting address</param>
|
||||
/// <param name="length">How many sectors to write</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length);
|
||||
|
||||
/// <summary>
|
||||
/// Sets tracks for optical media
|
||||
/// </summary>
|
||||
/// <param name="tracks">List of tracks</param>
|
||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||
bool SetTracks(List<Track> tracks);
|
||||
|
||||
/// <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