REFACTOR: Final cleanup of DiscImageChef.DiscImages.

This commit is contained in:
2017-12-24 00:12:31 +00:00
parent 536888507f
commit 736552f6d8
52 changed files with 5203 additions and 5359 deletions

View File

@@ -39,35 +39,45 @@ using DiscImageChef.Filters;
namespace DiscImageChef.DiscImages
{
/// <summary>
/// Abstract class to implement disk image reading plugins.
/// Abstract class to implement disk image reading plugins.
/// </summary>
public abstract class ImagePlugin
{
// CD flags bitmask
/// <summary>Track is quadraphonic.</summary>
public const byte CdFlagsFourChannel = 0x20;
/// <summary>Track is non-audio (data).</summary>
public const byte CdFlagsDataTrack = 0x10;
/// <summary>Track is copy protected.</summary>
public const byte CdFlagsCopyPrevent = 0x08;
/// <summary>Track has pre-emphasis.</summary>
public const byte CdFlagsPreEmphasis = 0x04;
/// <summary>Image information</summary>
public ImageInfo ImageInfo;
/// <summary>Plugin name.</summary>
public string Name;
/// <summary>Plugin UUID.</summary>
public Guid PluginUuid;
/// <summary>Image information</summary>
public ImageInfo ImageInfo;
// Basic image handling functions
/// <summary>
/// Identifies the image.
/// Identifies the image.
/// </summary>
/// <returns><c>true</c>, if image was identified, <c>false</c> otherwise.</returns>
/// <param name="imageFilter">Image filter.</param>
public abstract bool IdentifyImage(Filter imageFilter);
/// <summary>
/// Opens the image.
/// Opens the image.
/// </summary>
/// <returns><c>true</c>, if image was opened, <c>false</c> otherwise.</returns>
/// <param name="imageFilter">Image filter.</param>
public abstract bool OpenImage(Filter imageFilter);
/// <summary>
/// Asks the disk image plugin if the image contains partitions
/// Asks the disk image plugin if the image contains partitions
/// </summary>
/// <returns><c>true</c>, if the image contains partitions, <c>false</c> otherwise.</returns>
public abstract bool ImageHasPartitions();
@@ -75,19 +85,19 @@ namespace DiscImageChef.DiscImages
// Image size functions
/// <summary>
/// Gets the size of the image, without headers.
/// Gets the size of the image, without headers.
/// </summary>
/// <returns>The image size.</returns>
public abstract ulong GetImageSize();
/// <summary>
/// Gets the number of sectors in the image.
/// Gets the number of sectors in the image.
/// </summary>
/// <returns>Sectors in image.</returns>
public abstract ulong GetSectors();
/// <summary>
/// Returns the size of the biggest sector, counting user data only.
/// Returns the size of the biggest sector, counting user data only.
/// </summary>
/// <returns>Biggest sector size (user data only).</returns>
public abstract uint GetSectorSize();
@@ -95,21 +105,21 @@ namespace DiscImageChef.DiscImages
// Image reading functions
/// <summary>
/// Reads a disk tag.
/// Reads a disk tag.
/// </summary>
/// <returns>Disk tag</returns>
/// <param name="tag">Tag type to read.</param>
public abstract byte[] ReadDiskTag(MediaTagType tag);
/// <summary>
/// Reads a sector's user data.
/// Reads a sector's user data.
/// </summary>
/// <returns>The sector's user data.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
public abstract byte[] ReadSector(ulong sectorAddress);
/// <summary>
/// Reads a sector's tag.
/// Reads a sector's tag.
/// </summary>
/// <returns>The sector's tag.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
@@ -117,7 +127,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag);
/// <summary>
/// Reads a sector's user data, relative to track.
/// 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>
@@ -125,7 +135,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSector(ulong sectorAddress, uint track);
/// <summary>
/// Reads a sector's tag, relative to track.
/// Reads a sector's tag, relative to track.
/// </summary>
/// <returns>The sector's tag.</returns>
/// <param name="sectorAddress">Sector address (relative LBA).</param>
@@ -134,7 +144,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag);
/// <summary>
/// Reads user data from several sectors.
/// Reads user data from several sectors.
/// </summary>
/// <returns>The sectors user data.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
@@ -142,7 +152,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectors(ulong sectorAddress, uint length);
/// <summary>
/// Reads tag from several sectors.
/// Reads tag from several sectors.
/// </summary>
/// <returns>The sectors tag.</returns>
/// <param name="sectorAddress">Starting sector address (LBA).</param>
@@ -151,7 +161,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag);
/// <summary>
/// Reads user data from several sectors, relative to track.
/// 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>
@@ -160,7 +170,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectors(ulong sectorAddress, uint length, uint track);
/// <summary>
/// Reads tag from several sectors, relative to track.
/// Reads tag from several sectors, relative to track.
/// </summary>
/// <returns>The sectors tag.</returns>
/// <param name="sectorAddress">Starting sector address (relative LBA).</param>
@@ -170,14 +180,14 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag);
/// <summary>
/// Reads a complete sector (user data + all tags).
/// 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>
public abstract byte[] ReadSectorLong(ulong sectorAddress);
/// <summary>
/// Reads a complete sector (user data + all tags), relative to track.
/// 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>
@@ -185,7 +195,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorLong(ulong sectorAddress, uint track);
/// <summary>
/// Reads several complete sector (user data + all tags).
/// 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>
@@ -193,7 +203,7 @@ namespace DiscImageChef.DiscImages
public abstract byte[] ReadSectorsLong(ulong sectorAddress, uint length);
/// <summary>
/// Reads several complete sector (user data + all tags), relative to track.
/// 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>
@@ -204,55 +214,55 @@ namespace DiscImageChef.DiscImages
// Image information functions
/// <summary>
/// Gets the image format.
/// Gets the image format.
/// </summary>
/// <returns>The image format.</returns>
public abstract string GetImageFormat();
/// <summary>
/// Gets the image version.
/// Gets the image version.
/// </summary>
/// <returns>The image version.</returns>
public abstract string GetImageVersion();
/// <summary>
/// Gets the application that created the image.
/// Gets the application that created the image.
/// </summary>
/// <returns>The application that created the image.</returns>
public abstract string GetImageApplication();
/// <summary>
/// Gets the version of the application that created the image.
/// Gets the version of the application that created the image.
/// </summary>
/// <returns>The version of the application that created the image.</returns>
public abstract string GetImageApplicationVersion();
/// <summary>
/// Gets the image creator.
/// Gets the image creator.
/// </summary>
/// <returns>Who created the image.</returns>
public abstract string GetImageCreator();
/// <summary>
/// Gets the image creation time.
/// Gets the image creation time.
/// </summary>
/// <returns>The image creation time.</returns>
public abstract DateTime GetImageCreationTime();
/// <summary>
/// Gets the image last modification time.
/// Gets the image last modification time.
/// </summary>
/// <returns>The image last modification time.</returns>
public abstract DateTime GetImageLastModificationTime();
/// <summary>
/// Gets the name of the image.
/// Gets the name of the image.
/// </summary>
/// <returns>The image name.</returns>
public abstract string GetImageName();
/// <summary>
/// Gets the image comments.
/// Gets the image comments.
/// </summary>
/// <returns>The image comments.</returns>
public abstract string GetImageComments();
@@ -260,49 +270,49 @@ namespace DiscImageChef.DiscImages
// Functions to get information from disk represented by image
/// <summary>
/// Gets the media manufacturer.
/// Gets the media manufacturer.
/// </summary>
/// <returns>The media manufacturer.</returns>
public abstract string GetMediaManufacturer();
/// <summary>
/// Gets the media model.
/// Gets the media model.
/// </summary>
/// <returns>The media model.</returns>
public abstract string GetMediaModel();
/// <summary>
/// Gets the media serial number.
/// Gets the media serial number.
/// </summary>
/// <returns>The media serial number.</returns>
public abstract string GetMediaSerialNumber();
/// <summary>
/// Gets the media (or product) barcode.
/// Gets the media (or product) barcode.
/// </summary>
/// <returns>The media barcode.</returns>
public abstract string GetMediaBarcode();
/// <summary>
/// Gets the media part number.
/// Gets the media part number.
/// </summary>
/// <returns>The media part number.</returns>
public abstract string GetMediaPartNumber();
/// <summary>
/// Gets the type of the media.
/// Gets the type of the media.
/// </summary>
/// <returns>The media type.</returns>
public abstract MediaType GetMediaType();
/// <summary>
/// Gets the media sequence.
/// Gets the media sequence.
/// </summary>
/// <returns>The media sequence, starting at 1.</returns>
public abstract int GetMediaSequence();
/// <summary>
/// Gets the last media in the sequence.
/// Gets the last media in the sequence.
/// </summary>
/// <returns>The last media in the sequence.</returns>
public abstract int GetLastDiskSequence();
@@ -310,19 +320,19 @@ namespace DiscImageChef.DiscImages
// Functions to get information from drive used to create image
/// <summary>
/// Gets the manufacturer of the drive used to create the image.
/// Gets the manufacturer of the drive used to create the image.
/// </summary>
/// <returns>The drive manufacturer.</returns>
public abstract string GetDriveManufacturer();
/// <summary>
/// Gets the model of the drive used to create the image.
/// Gets the model of the drive used to create the image.
/// </summary>
/// <returns>The drive model.</returns>
public abstract string GetDriveModel();
/// <summary>
/// Gets the serial number of the drive used to create the image.
/// Gets the serial number of the drive used to create the image.
/// </summary>
/// <returns>The drive serial number.</returns>
public abstract string GetDriveSerialNumber();
@@ -330,48 +340,48 @@ namespace DiscImageChef.DiscImages
// Partitioning functions
/// <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.
/// 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>
/// <returns>The partitions.</returns>
public abstract List<Partition> GetPartitions();
/// <summary>
/// Gets the disc track extents (start, length).
/// Gets the disc track extents (start, length).
/// </summary>
/// <returns>The track extents.</returns>
public abstract List<Track> GetTracks();
/// <summary>
/// Gets the disc track extents for a specified session.
/// Gets the disc track extents for a specified session.
/// </summary>
/// <returns>The track exents for that session.</returns>
/// <param name="session">Session.</param>
public abstract List<Track> GetSessionTracks(Session session);
/// <summary>
/// Gets the disc track extents for a specified session.
/// Gets the disc track extents for a specified session.
/// </summary>
/// <returns>The track exents for that session.</returns>
/// <param name="session">Session.</param>
public abstract List<Track> GetSessionTracks(ushort session);
/// <summary>
/// Gets the sessions (optical discs only).
/// Gets the sessions (optical discs only).
/// </summary>
/// <returns>The sessions.</returns>
public abstract List<Session> GetSessions();
/// <summary>
/// Verifies a sector.
/// Verifies a sector.
/// </summary>
/// <returns>True if correct, false if incorrect, null if uncheckable.</returns>
/// <param name="sectorAddress">Sector address (LBA).</param>
public abstract bool? VerifySector(ulong sectorAddress);
/// <summary>
/// Verifies a sector, relative to track.
/// 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>
@@ -379,7 +389,7 @@ namespace DiscImageChef.DiscImages
public abstract bool? VerifySector(ulong sectorAddress, uint track);
/// <summary>
/// Verifies several sectors.
/// 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>
@@ -390,7 +400,7 @@ namespace DiscImageChef.DiscImages
out List<ulong> unknownLbas);
/// <summary>
/// Verifies several sectors, relative to track.
/// 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>
@@ -402,25 +412,14 @@ namespace DiscImageChef.DiscImages
out List<ulong> unknownLbas);
/// <summary>
/// Verifies media image internal checksum.
/// Verifies media image internal checksum.
/// </summary>
/// <returns>True if correct, false if incorrect, null if there is no internal checksum available</returns>
public abstract bool? VerifyMediaImage();
// CD flags bitmask
/// <summary>Track is quadraphonic.</summary>
public const byte CdFlagsFourChannel = 0x20;
/// <summary>Track is non-audio (data).</summary>
public const byte CdFlagsDataTrack = 0x10;
/// <summary>Track is copy protected.</summary>
public const byte CdFlagsCopyPrevent = 0x08;
/// <summary>Track has pre-emphasis.</summary>
public const byte CdFlagsPreEmphasis = 0x04;
}
/// <summary>
/// Track (as partitioning element) types.
/// Track (as partitioning element) types.
/// </summary>
public enum TrackType
{
@@ -439,7 +438,7 @@ namespace DiscImageChef.DiscImages
}
/// <summary>
/// Track defining structure.
/// Track defining structure.
/// </summary>
public struct Track
{
@@ -482,42 +481,42 @@ namespace DiscImageChef.DiscImages
}
/// <summary>
/// Type of subchannel in track
/// Type of subchannel in track
/// </summary>
public enum TrackSubchannelType
{
/// <summary>
/// Track does not has subchannel dumped, or it's not a CD
/// Track does not has subchannel dumped, or it's not a CD
/// </summary>
None,
/// <summary>
/// Subchannel is packed and error corrected
/// Subchannel is packed and error corrected
/// </summary>
Packed,
/// <summary>
/// Subchannel is interleaved
/// Subchannel is interleaved
/// </summary>
Raw,
/// <summary>
/// Subchannel is packed and comes interleaved with main channel in same file
/// Subchannel is packed and comes interleaved with main channel in same file
/// </summary>
PackedInterleaved,
/// <summary>
/// Subchannel is interleaved and comes interleaved with main channel in same file
/// Subchannel is interleaved and comes interleaved with main channel in same file
/// </summary>
RawInterleaved,
/// <summary>
/// Only Q subchannel is stored as 16 bytes
/// Only Q subchannel is stored as 16 bytes
/// </summary>
Q16,
/// <summary>
/// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file
/// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file
/// </summary>
Q16Interleaved
}
/// <summary>
/// Session defining structure.
/// Session defining structure.
/// </summary>
public struct Session
{
@@ -534,7 +533,7 @@ namespace DiscImageChef.DiscImages
}
/// <summary>
/// Metadata present for each sector (aka, "tag").
/// Metadata present for each sector (aka, "tag").
/// </summary>
public enum SectorTagType
{
@@ -569,7 +568,7 @@ namespace DiscImageChef.DiscImages
}
/// <summary>
/// Metadata present for each media.
/// Metadata present for each media.
/// </summary>
public enum MediaTagType
{
@@ -691,41 +690,44 @@ namespace DiscImageChef.DiscImages
MMC_ExtendedCSD,
/// <summary>Xbox Security Sector</summary>
Xbox_SecuritySector,
/// <summary>On floppy disks, data in last cylinder usually in a different format that contains duplication or manufacturing information</summary>
/// <summary>
/// On floppy disks, data in last cylinder usually in a different format that contains duplication or
/// manufacturing information
/// </summary>
Floppy_LeadOut
}
/// <summary>
/// Enumeration of media types defined in CICM metadata
/// Enumeration of media types defined in CICM metadata
/// </summary>
public enum XmlMediaType
{
/// <summary>
/// Purely optical discs
/// Purely optical discs
/// </summary>
OpticalDisc,
/// <summary>
/// Media that is physically block-based or abstracted like that
/// Media that is physically block-based or abstracted like that
/// </summary>
BlockMedia,
/// <summary>
/// Media that can be accessed by-byte or by-bit, like chips
/// Media that can be accessed by-byte or by-bit, like chips
/// </summary>
LinearMedia,
/// <summary>
/// Media that can only store data when it is modulated to audio
/// Media that can only store data when it is modulated to audio
/// </summary>
AudioMedia
}
/// <summary>
/// Feature is supported by image but not implemented yet.
/// Feature is supported by image but not implemented yet.
/// </summary>
[Serializable]
public class FeatureSupportedButNotImplementedImageException : Exception
{
/// <summary>
/// Feature is supported by image but not implemented yet.
/// Feature is supported by image but not implemented yet.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="inner">Inner.</param>
@@ -733,142 +735,137 @@ namespace DiscImageChef.DiscImages
base(message, inner) { }
/// <summary>
/// Feature is supported by image but not implemented yet.
/// Feature is supported by image but not implemented yet.
/// </summary>
/// <param name="message">Message.</param>
public FeatureSupportedButNotImplementedImageException(string message) : base(message) { }
/// <summary>
/// Feature is supported by image but not implemented yet.
/// Feature is supported by image but not implemented yet.
/// </summary>
/// <param name="info">Info.</param>
/// <param name="context">Context.</param>
protected FeatureSupportedButNotImplementedImageException(SerializationInfo info,
StreamingContext context)
protected FeatureSupportedButNotImplementedImageException(SerializationInfo info, StreamingContext context)
{
if(info == null) throw new ArgumentNullException(nameof(info));
}
}
/// <summary>
/// Feature is not supported by image.
/// Feature is not supported by image.
/// </summary>
[Serializable]
public class FeatureUnsupportedImageException : Exception
{
/// <summary>
/// Feature is not supported by image.
/// Feature is not supported by image.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="inner">Inner.</param>
public FeatureUnsupportedImageException(string message, Exception inner) : base(message, inner) { }
/// <summary>
/// Feature is not supported by image.
/// Feature is not supported by image.
/// </summary>
/// <param name="message">Message.</param>
public FeatureUnsupportedImageException(string message) : base(message) { }
/// <summary>
/// Feature is not supported by image.
/// Feature is not supported by image.
/// </summary>
/// <param name="info">Info.</param>
/// <param name="context">Context.</param>
protected FeatureUnsupportedImageException(SerializationInfo info,
StreamingContext context)
protected FeatureUnsupportedImageException(SerializationInfo info, StreamingContext context)
{
if(info == null) throw new ArgumentNullException(nameof(info));
}
}
/// <summary>
/// Feature is supported by image but not present on it.
/// Feature is supported by image but not present on it.
/// </summary>
[Serializable]
public class FeatureNotPresentImageException : Exception
{
/// <summary>
/// Feature is supported by image but not present on it.
/// Feature is supported by image but not present on it.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="inner">Inner.</param>
public FeatureNotPresentImageException(string message, Exception inner) : base(message, inner) { }
/// <summary>
/// Feature is supported by image but not present on it.
/// Feature is supported by image but not present on it.
/// </summary>
/// <param name="message">Message.</param>
public FeatureNotPresentImageException(string message) : base(message) { }
/// <summary>
/// Feature is supported by image but not present on it.
/// Feature is supported by image but not present on it.
/// </summary>
/// <param name="info">Info.</param>
/// <param name="context">Context.</param>
protected FeatureNotPresentImageException(SerializationInfo info,
StreamingContext context)
protected FeatureNotPresentImageException(SerializationInfo info, StreamingContext context)
{
if(info == null) throw new ArgumentNullException(nameof(info));
}
}
/// <summary>
/// Feature is supported by image but not by the disc it represents.
/// Feature is supported by image but not by the disc it represents.
/// </summary>
[Serializable]
public class FeaturedNotSupportedByDiscImageException : Exception
{
/// <summary>
/// Feature is supported by image but not by the disc it represents.
/// Feature is supported by image but not by the disc it represents.
/// </summary>
/// <param name="message">Message.</param>
/// <param name="inner">Inner.</param>
public FeaturedNotSupportedByDiscImageException(string message, Exception inner) : base(message, inner) { }
/// <summary>
/// Feature is supported by image but not by the disc it represents.
/// Feature is supported by image but not by the disc it represents.
/// </summary>
/// <param name="message">Message.</param>
public FeaturedNotSupportedByDiscImageException(string message) : base(message) { }
/// <summary>
/// Feature is supported by image but not by the disc it represents.
/// Feature is supported by image but not by the disc it represents.
/// </summary>
/// <param name="info">Info.</param>
/// <param name="context">Context.</param>
protected FeaturedNotSupportedByDiscImageException(SerializationInfo info,
StreamingContext context)
protected FeaturedNotSupportedByDiscImageException(SerializationInfo info, StreamingContext context)
{
if(info == null) throw new ArgumentNullException(nameof(info));
}
}
/// <summary>
/// Corrupt, incorrect or unhandled feature found on image
/// Corrupt, incorrect or unhandled feature found on image
/// </summary>
[Serializable]
public class ImageNotSupportedException : Exception
{
/// <summary>
/// Corrupt, incorrect or unhandled feature found on image
/// Corrupt, incorrect or unhandled feature found on image
/// </summary>
/// <param name="message">Message.</param>
/// <param name="inner">Inner.</param>
public ImageNotSupportedException(string message, Exception inner) : base(message, inner) { }
/// <summary>
/// Corrupt, incorrect or unhandled feature found on image
/// Corrupt, incorrect or unhandled feature found on image
/// </summary>
/// <param name="message">Message.</param>
public ImageNotSupportedException(string message) : base(message) { }
/// <summary>
/// Corrupt, incorrect or unhandled feature found on image
/// Corrupt, incorrect or unhandled feature found on image
/// </summary>
/// <param name="info">Info.</param>
/// <param name="context">Context.</param>
protected ImageNotSupportedException(SerializationInfo info,
StreamingContext context)
protected ImageNotSupportedException(SerializationInfo info, StreamingContext context)
{
if(info == null) throw new ArgumentNullException(nameof(info));
}