mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
Reformat.
This commit is contained in:
@@ -40,12 +40,8 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
{
|
||||
public enum DeviceType
|
||||
{
|
||||
Unknown = -1,
|
||||
ATA = 1,
|
||||
ATAPI = 2,
|
||||
SCSI = 3,
|
||||
SecureDigital = 4,
|
||||
MMC = 5,
|
||||
NVMe = 6
|
||||
Unknown = -1, ATA = 1, ATAPI = 2,
|
||||
SCSI = 3, SecureDigital = 4, MMC = 5,
|
||||
NVMe = 6
|
||||
}
|
||||
}
|
||||
@@ -38,78 +38,43 @@
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumerates error codes. Positive for warnings or informative codes, negative for errors.
|
||||
/// </summary>
|
||||
/// <summary>Enumerates error codes. Positive for warnings or informative codes, negative for errors.</summary>
|
||||
public enum ErrorNumber
|
||||
{
|
||||
/// <summary>No error</summary>
|
||||
NoError = 0,
|
||||
/// <summary>User requested help to be shown</summary>
|
||||
HelpRequested = 1,
|
||||
/// <summary>Command found nothing</summary>
|
||||
NothingFound = 2,
|
||||
/// <summary>Media has been already dumped completely</summary>
|
||||
AlreadyDumped = 3,
|
||||
/// <summary>Image and its sectors cannot be verified</summary>
|
||||
NotVerificable = 4,
|
||||
/// <summary>There are bad sectors and image cannot be verified</summary>
|
||||
BadSectorsImageNotVerified = 5,
|
||||
/// <summary>All sectors are good and image cannot be verified</summary>
|
||||
CorrectSectorsImageNotVerified = 6,
|
||||
/// <summary>Image is bad and sectors cannot be verified</summary>
|
||||
BadImageSectorsNotVerified = 7,
|
||||
/// <summary>Image is bad and there are bad sectors</summary>
|
||||
BadImageBadSectors = 8,
|
||||
/// <summary>All sectors are good and image is bad</summary>
|
||||
CorrectSectorsBadImage = 9,
|
||||
/// <summary>Image is good and sectors cannot be verified</summary>
|
||||
CorrectImageSectorsNotVerified = 10,
|
||||
/// <summary>Image is good and there are bad sectors</summary>
|
||||
CorrectImageBadSectors = 11,
|
||||
/// <summary>Exception has been raised</summary>
|
||||
UnexpectedException = -1,
|
||||
/// <summary>The number of arguments is not as expected</summary>
|
||||
UnexpectedArgumentCount = -2,
|
||||
/// <summary>A required argument is not present</summary>
|
||||
MissingArgument = -3,
|
||||
/// <summary>A specified argument contains an invalid value</summary>
|
||||
InvalidArgument = -4,
|
||||
/// <summary>The specified file cannot be found</summary>
|
||||
FileNotFound = -5,
|
||||
/// <summary>The specified file cannot be opened</summary>
|
||||
CannotOpenFile = -6,
|
||||
/// <summary>The specified encoding cannot be found</summary>
|
||||
EncodingUnknown = -7,
|
||||
/// <summary>The image format has not been recognized</summary>
|
||||
UnrecognizedFormat = -8,
|
||||
/// <summary>The image format failed to open</summary>
|
||||
CannotOpenFormat = -9,
|
||||
/// <summary>The specified metadata sidecar does not have the correct format</summary>
|
||||
InvalidSidecar = -10,
|
||||
/// <summary>The specified resume map does not have the correct format</summary>
|
||||
InvalidResume = -11,
|
||||
/// <summary>The specified destination file/folder already exists</summary>
|
||||
DestinationExists = -12,
|
||||
/// <summary>The specified image format cannot be found</summary>
|
||||
FormatNotFound = -13,
|
||||
/// <summary>More than one format found for the specified search criteria</summary>
|
||||
TooManyFormats = -14,
|
||||
/// <summary>The specified format does not support the specified media</summary>
|
||||
UnsupportedMedia = -15,
|
||||
/// <summary>Data will be lost writing the specified format</summary>
|
||||
DataWillBeLost = -16,
|
||||
/// <summary>Cannot create destination format</summary>
|
||||
CannotCreateFormat = -17,
|
||||
/// <summary>Error writing data</summary>
|
||||
WriteError = -18,
|
||||
/// <summary>Argument expected a directory, but found a file</summary>
|
||||
ExpectedDirectory = -19,
|
||||
/// <summary>Argument expected a file, but found a directory</summary>
|
||||
ExpectedFile = -20,
|
||||
/// <summary>Cannot open device</summary>
|
||||
CannotOpenDevice = -21,
|
||||
/// <summary>The specified operation requires administrative privileges</summary>
|
||||
NoError = 0, /// <summary>User requested help to be shown</summary>
|
||||
HelpRequested = 1, /// <summary>Command found nothing</summary>
|
||||
NothingFound = 2, /// <summary>Media has been already dumped completely</summary>
|
||||
AlreadyDumped = 3, /// <summary>Image and its sectors cannot be verified</summary>
|
||||
NotVerificable = 4, /// <summary>There are bad sectors and image cannot be verified</summary>
|
||||
BadSectorsImageNotVerified = 5, /// <summary>All sectors are good and image cannot be verified</summary>
|
||||
CorrectSectorsImageNotVerified = 6, /// <summary>Image is bad and sectors cannot be verified</summary>
|
||||
BadImageSectorsNotVerified = 7, /// <summary>Image is bad and there are bad sectors</summary>
|
||||
BadImageBadSectors = 8, /// <summary>All sectors are good and image is bad</summary>
|
||||
CorrectSectorsBadImage = 9, /// <summary>Image is good and sectors cannot be verified</summary>
|
||||
CorrectImageSectorsNotVerified = 10, /// <summary>Image is good and there are bad sectors</summary>
|
||||
CorrectImageBadSectors = 11, /// <summary>Exception has been raised</summary>
|
||||
UnexpectedException = -1, /// <summary>The number of arguments is not as expected</summary>
|
||||
UnexpectedArgumentCount = -2, /// <summary>A required argument is not present</summary>
|
||||
MissingArgument = -3, /// <summary>A specified argument contains an invalid value</summary>
|
||||
InvalidArgument = -4, /// <summary>The specified file cannot be found</summary>
|
||||
FileNotFound = -5, /// <summary>The specified file cannot be opened</summary>
|
||||
CannotOpenFile = -6, /// <summary>The specified encoding cannot be found</summary>
|
||||
EncodingUnknown = -7, /// <summary>The image format has not been recognized</summary>
|
||||
UnrecognizedFormat = -8, /// <summary>The image format failed to open</summary>
|
||||
CannotOpenFormat = -9, /// <summary>The specified metadata sidecar does not have the correct format</summary>
|
||||
InvalidSidecar = -10, /// <summary>The specified resume map does not have the correct format</summary>
|
||||
InvalidResume = -11, /// <summary>The specified destination file/folder already exists</summary>
|
||||
DestinationExists = -12, /// <summary>The specified image format cannot be found</summary>
|
||||
FormatNotFound = -13, /// <summary>More than one format found for the specified search criteria</summary>
|
||||
TooManyFormats = -14, /// <summary>The specified format does not support the specified media</summary>
|
||||
UnsupportedMedia = -15, /// <summary>Data will be lost writing the specified format</summary>
|
||||
DataWillBeLost = -16, /// <summary>Cannot create destination format</summary>
|
||||
CannotCreateFormat = -17, /// <summary>Error writing data</summary>
|
||||
WriteError = -18, /// <summary>Argument expected a directory, but found a file</summary>
|
||||
ExpectedDirectory = -19, /// <summary>Argument expected a file, but found a directory</summary>
|
||||
ExpectedFile = -20, /// <summary>Cannot open device</summary>
|
||||
CannotOpenDevice = -21, /// <summary>The specified operation requires administrative privileges</summary>
|
||||
NotEnoughPermissions = -22
|
||||
}
|
||||
}
|
||||
373
Enums/Images.cs
373
Enums/Images.cs
@@ -40,263 +40,136 @@ using System;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Track (as partitioning element) types.
|
||||
/// </summary>
|
||||
/// <summary>Track (as partitioning element) types.</summary>
|
||||
public enum TrackType : byte
|
||||
{
|
||||
/// <summary>Audio track</summary>
|
||||
Audio = 0,
|
||||
/// <summary>Data track (not any of the below defined ones)</summary>
|
||||
Data = 1,
|
||||
/// <summary>Data track, compact disc mode 1</summary>
|
||||
CdMode1 = 2,
|
||||
/// <summary>Data track, compact disc mode 2, formless</summary>
|
||||
CdMode2Formless = 3,
|
||||
/// <summary>Data track, compact disc mode 2, form 1</summary>
|
||||
CdMode2Form1 = 4,
|
||||
/// <summary>Data track, compact disc mode 2, form 2</summary>
|
||||
Audio = 0, /// <summary>Data track (not any of the below defined ones)</summary>
|
||||
Data = 1, /// <summary>Data track, compact disc mode 1</summary>
|
||||
CdMode1 = 2, /// <summary>Data track, compact disc mode 2, formless</summary>
|
||||
CdMode2Formless = 3, /// <summary>Data track, compact disc mode 2, form 1</summary>
|
||||
CdMode2Form1 = 4, /// <summary>Data track, compact disc mode 2, form 2</summary>
|
||||
CdMode2Form2 = 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type of subchannel in track
|
||||
/// </summary>
|
||||
/// <summary>Type of subchannel in track</summary>
|
||||
public enum TrackSubchannelType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Track does not has subchannel dumped, or it's not a CD
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Subchannel is packed and error corrected
|
||||
/// </summary>
|
||||
Packed = 1,
|
||||
/// <summary>
|
||||
/// Subchannel is interleaved
|
||||
/// </summary>
|
||||
Raw = 2,
|
||||
/// <summary>
|
||||
/// Subchannel is packed and comes interleaved with main channel in same file
|
||||
/// </summary>
|
||||
PackedInterleaved = 3,
|
||||
/// <summary>
|
||||
/// Subchannel is interleaved and comes interleaved with main channel in same file
|
||||
/// </summary>
|
||||
RawInterleaved = 4,
|
||||
/// <summary>
|
||||
/// Only Q subchannel is stored as 16 bytes
|
||||
/// </summary>
|
||||
Q16 = 5,
|
||||
/// <summary>
|
||||
/// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file
|
||||
/// </summary>
|
||||
/// <summary>Track does not has subchannel dumped, or it's not a CD</summary>
|
||||
None = 0, /// <summary>Subchannel is packed and error corrected</summary>
|
||||
Packed = 1, /// <summary>Subchannel is interleaved</summary>
|
||||
Raw = 2, /// <summary>Subchannel is packed and comes interleaved with main channel in same file</summary>
|
||||
PackedInterleaved = 3, /// <summary>Subchannel is interleaved and comes interleaved with main channel in same file</summary>
|
||||
RawInterleaved = 4, /// <summary>Only Q subchannel is stored as 16 bytes</summary>
|
||||
Q16 = 5, /// <summary>Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file</summary>
|
||||
Q16Interleaved = 6
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metadata present for each sector (aka, "tag").
|
||||
/// </summary>
|
||||
/// <summary>Metadata present for each sector (aka, "tag").</summary>
|
||||
public enum SectorTagType
|
||||
{
|
||||
/// <summary>Apple's GCR sector tags, 12 bytes</summary>
|
||||
AppleSectorTag = 0,
|
||||
/// <summary>Sync frame from CD sector, 12 bytes</summary>
|
||||
CdSectorSync = 1,
|
||||
/// <summary>CD sector header, 4 bytes</summary>
|
||||
CdSectorHeader = 2,
|
||||
/// <summary>CD mode 2 sector subheader</summary>
|
||||
CdSectorSubHeader = 3,
|
||||
/// <summary>CD sector EDC, 4 bytes</summary>
|
||||
CdSectorEdc = 4,
|
||||
/// <summary>CD sector ECC P, 172 bytes</summary>
|
||||
CdSectorEccP = 5,
|
||||
/// <summary>CD sector ECC Q, 104 bytes</summary>
|
||||
CdSectorEccQ = 6,
|
||||
/// <summary>CD sector ECC (P and Q), 276 bytes</summary>
|
||||
CdSectorEcc = 7,
|
||||
/// <summary>CD sector subchannel, 96 bytes</summary>
|
||||
CdSectorSubchannel = 8,
|
||||
/// <summary>CD track ISRC, string, 12 bytes</summary>
|
||||
CdTrackIsrc = 9,
|
||||
/// <summary>CD track text, string, 13 bytes</summary>
|
||||
CdTrackText = 10,
|
||||
/// <summary>CD track flags, 1 byte</summary>
|
||||
CdTrackFlags = 11,
|
||||
/// <summary>DVD sector copyright information</summary>
|
||||
DvdCmi = 12,
|
||||
/// <summary>Floppy address mark (contents depend on underlying floppy format)</summary>
|
||||
AppleSectorTag = 0, /// <summary>Sync frame from CD sector, 12 bytes</summary>
|
||||
CdSectorSync = 1, /// <summary>CD sector header, 4 bytes</summary>
|
||||
CdSectorHeader = 2, /// <summary>CD mode 2 sector subheader</summary>
|
||||
CdSectorSubHeader = 3, /// <summary>CD sector EDC, 4 bytes</summary>
|
||||
CdSectorEdc = 4, /// <summary>CD sector ECC P, 172 bytes</summary>
|
||||
CdSectorEccP = 5, /// <summary>CD sector ECC Q, 104 bytes</summary>
|
||||
CdSectorEccQ = 6, /// <summary>CD sector ECC (P and Q), 276 bytes</summary>
|
||||
CdSectorEcc = 7, /// <summary>CD sector subchannel, 96 bytes</summary>
|
||||
CdSectorSubchannel = 8, /// <summary>CD track ISRC, string, 12 bytes</summary>
|
||||
CdTrackIsrc = 9, /// <summary>CD track text, string, 13 bytes</summary>
|
||||
CdTrackText = 10, /// <summary>CD track flags, 1 byte</summary>
|
||||
CdTrackFlags = 11, /// <summary>DVD sector copyright information</summary>
|
||||
DvdCmi = 12, /// <summary>Floppy address mark (contents depend on underlying floppy format)</summary>
|
||||
FloppyAddressMark = 13
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metadata present for each media.
|
||||
/// </summary>
|
||||
/// <summary>Metadata present for each media.</summary>
|
||||
public enum MediaTagType
|
||||
{
|
||||
/// <summary>CD table of contents</summary>
|
||||
CD_TOC = 0,
|
||||
/// <summary>CD session information</summary>
|
||||
CD_SessionInfo = 1,
|
||||
/// <summary>CD full table of contents</summary>
|
||||
CD_FullTOC = 2,
|
||||
/// <summary>CD PMA</summary>
|
||||
CD_PMA = 3,
|
||||
/// <summary>CD Adress-Time-In-Pregroove</summary>
|
||||
CD_ATIP = 4,
|
||||
/// <summary>CD-Text</summary>
|
||||
CD_TEXT = 5,
|
||||
/// <summary>CD Media Catalogue Number</summary>
|
||||
CD_MCN = 6,
|
||||
/// <summary>DVD/HD DVD Physical Format Information</summary>
|
||||
DVD_PFI = 7,
|
||||
/// <summary>DVD Lead-in Copyright Management Information</summary>
|
||||
DVD_CMI = 8,
|
||||
/// <summary>DVD disc key</summary>
|
||||
DVD_DiscKey = 9,
|
||||
/// <summary>DVD/HD DVD Burst Cutting Area</summary>
|
||||
DVD_BCA = 10,
|
||||
/// <summary>DVD/HD DVD Lead-in Disc Manufacturer Information</summary>
|
||||
DVD_DMI = 11,
|
||||
/// <summary>Media identifier</summary>
|
||||
DVD_MediaIdentifier = 12,
|
||||
/// <summary>Media key block</summary>
|
||||
DVD_MKB = 13,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM DDS information</summary>
|
||||
DVDRAM_DDS = 14,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM Medium status</summary>
|
||||
DVDRAM_MediumStatus = 15,
|
||||
/// <summary>DVD-RAM/HD DVD-RAM Spare area information</summary>
|
||||
DVDRAM_SpareArea = 16,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R RMD in last border-out</summary>
|
||||
DVDR_RMD = 17,
|
||||
/// <summary>Pre-recorded information from DVD-R/-RW lead-in</summary>
|
||||
DVDR_PreRecordedInfo = 18,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R media identifier</summary>
|
||||
DVDR_MediaIdentifier = 19,
|
||||
/// <summary>DVD-R/-RW/HD DVD-R physical format information</summary>
|
||||
DVDR_PFI = 20,
|
||||
/// <summary>ADIP information</summary>
|
||||
DVD_ADIP = 21,
|
||||
/// <summary>HD DVD Lead-in copyright protection information</summary>
|
||||
HDDVD_CPI = 22,
|
||||
/// <summary>HD DVD-R Medium Status</summary>
|
||||
HDDVD_MediumStatus = 23,
|
||||
/// <summary>DVD+/-R DL Layer capacity</summary>
|
||||
DVDDL_LayerCapacity = 24,
|
||||
/// <summary>DVD-R DL Middle Zone start address</summary>
|
||||
DVDDL_MiddleZoneAddress = 25,
|
||||
/// <summary>DVD-R DL Jump Interval Size</summary>
|
||||
DVDDL_JumpIntervalSize = 26,
|
||||
/// <summary>DVD-R DL Start LBA of the manual layer jump</summary>
|
||||
DVDDL_ManualLayerJumpLBA = 27,
|
||||
/// <summary>Blu-ray Disc Information</summary>
|
||||
BD_DI = 28,
|
||||
/// <summary>Blu-ray Burst Cutting Area</summary>
|
||||
BD_BCA = 29,
|
||||
/// <summary>Blu-ray Disc Definition Structure</summary>
|
||||
BD_DDS = 30,
|
||||
/// <summary>Blu-ray Cartridge Status</summary>
|
||||
BD_CartridgeStatus = 31,
|
||||
/// <summary>Blu-ray Status of Spare Area</summary>
|
||||
BD_SpareArea = 32,
|
||||
/// <summary>AACS volume identifier</summary>
|
||||
AACS_VolumeIdentifier = 33,
|
||||
/// <summary>AACS pre-recorded media serial number</summary>
|
||||
AACS_SerialNumber = 34,
|
||||
/// <summary>AACS media identifier</summary>
|
||||
AACS_MediaIdentifier = 35,
|
||||
/// <summary>Lead-in AACS media key block</summary>
|
||||
AACS_MKB = 36,
|
||||
/// <summary>AACS data keys</summary>
|
||||
AACS_DataKeys = 37,
|
||||
/// <summary>LBA extents flagged for bus encryption by AACS</summary>
|
||||
AACS_LBAExtents = 38,
|
||||
/// <summary>CPRM media key block in Lead-in</summary>
|
||||
AACS_CPRM_MKB = 39,
|
||||
/// <summary>Recognized layer formats in hybrid discs</summary>
|
||||
Hybrid_RecognizedLayers = 40,
|
||||
/// <summary>Disc write protection status</summary>
|
||||
MMC_WriteProtection = 41,
|
||||
/// <summary>Disc standard information</summary>
|
||||
MMC_DiscInformation = 42,
|
||||
/// <summary>Disc track resources information</summary>
|
||||
MMC_TrackResourcesInformation = 43,
|
||||
/// <summary>BD-R Pseudo-overwrite information</summary>
|
||||
MMC_POWResourcesInformation = 44,
|
||||
/// <summary>SCSI INQUIRY response</summary>
|
||||
SCSI_INQUIRY = 45,
|
||||
/// <summary>SCSI MODE PAGE 2Ah</summary>
|
||||
SCSI_MODEPAGE_2A = 46,
|
||||
/// <summary>ATA IDENTIFY DEVICE response</summary>
|
||||
ATA_IDENTIFY = 47,
|
||||
/// <summary>ATA IDENTIFY PACKET DEVICE response</summary>
|
||||
ATAPI_IDENTIFY = 48,
|
||||
/// <summary>PCMCIA/CardBus Card Information Structure</summary>
|
||||
PCMCIA_CIS = 49,
|
||||
/// <summary>SecureDigital CID</summary>
|
||||
SD_CID = 50,
|
||||
/// <summary>SecureDigital CSD</summary>
|
||||
SD_CSD = 51,
|
||||
/// <summary>SecureDigital SCR</summary>
|
||||
SD_SCR = 52,
|
||||
/// <summary>SecureDigital OCR</summary>
|
||||
SD_OCR = 53,
|
||||
/// <summary>MultiMediaCard CID</summary>
|
||||
MMC_CID = 54,
|
||||
/// <summary>MultiMediaCard CSD</summary>
|
||||
MMC_CSD = 55,
|
||||
/// <summary>MultiMediaCard OCR</summary>
|
||||
MMC_OCR = 56,
|
||||
/// <summary>MultiMediaCard Extended CSD</summary>
|
||||
MMC_ExtendedCSD = 57,
|
||||
/// <summary>Xbox Security Sector</summary>
|
||||
Xbox_SecuritySector = 58,
|
||||
/// <summary>
|
||||
CD_TOC = 0, /// <summary>CD session information</summary>
|
||||
CD_SessionInfo = 1, /// <summary>CD full table of contents</summary>
|
||||
CD_FullTOC = 2, /// <summary>CD PMA</summary>
|
||||
CD_PMA = 3, /// <summary>CD Adress-Time-In-Pregroove</summary>
|
||||
CD_ATIP = 4, /// <summary>CD-Text</summary>
|
||||
CD_TEXT = 5, /// <summary>CD Media Catalogue Number</summary>
|
||||
CD_MCN = 6, /// <summary>DVD/HD DVD Physical Format Information</summary>
|
||||
DVD_PFI = 7, /// <summary>DVD Lead-in Copyright Management Information</summary>
|
||||
DVD_CMI = 8, /// <summary>DVD disc key</summary>
|
||||
DVD_DiscKey = 9, /// <summary>DVD/HD DVD Burst Cutting Area</summary>
|
||||
DVD_BCA = 10, /// <summary>DVD/HD DVD Lead-in Disc Manufacturer Information</summary>
|
||||
DVD_DMI = 11, /// <summary>Media identifier</summary>
|
||||
DVD_MediaIdentifier = 12, /// <summary>Media key block</summary>
|
||||
DVD_MKB = 13, /// <summary>DVD-RAM/HD DVD-RAM DDS information</summary>
|
||||
DVDRAM_DDS = 14, /// <summary>DVD-RAM/HD DVD-RAM Medium status</summary>
|
||||
DVDRAM_MediumStatus = 15, /// <summary>DVD-RAM/HD DVD-RAM Spare area information</summary>
|
||||
DVDRAM_SpareArea = 16, /// <summary>DVD-R/-RW/HD DVD-R RMD in last border-out</summary>
|
||||
DVDR_RMD = 17, /// <summary>Pre-recorded information from DVD-R/-RW lead-in</summary>
|
||||
DVDR_PreRecordedInfo = 18, /// <summary>DVD-R/-RW/HD DVD-R media identifier</summary>
|
||||
DVDR_MediaIdentifier = 19, /// <summary>DVD-R/-RW/HD DVD-R physical format information</summary>
|
||||
DVDR_PFI = 20, /// <summary>ADIP information</summary>
|
||||
DVD_ADIP = 21, /// <summary>HD DVD Lead-in copyright protection information</summary>
|
||||
HDDVD_CPI = 22, /// <summary>HD DVD-R Medium Status</summary>
|
||||
HDDVD_MediumStatus = 23, /// <summary>DVD+/-R DL Layer capacity</summary>
|
||||
DVDDL_LayerCapacity = 24, /// <summary>DVD-R DL Middle Zone start address</summary>
|
||||
DVDDL_MiddleZoneAddress = 25, /// <summary>DVD-R DL Jump Interval Size</summary>
|
||||
DVDDL_JumpIntervalSize = 26, /// <summary>DVD-R DL Start LBA of the manual layer jump</summary>
|
||||
DVDDL_ManualLayerJumpLBA = 27, /// <summary>Blu-ray Disc Information</summary>
|
||||
BD_DI = 28, /// <summary>Blu-ray Burst Cutting Area</summary>
|
||||
BD_BCA = 29, /// <summary>Blu-ray Disc Definition Structure</summary>
|
||||
BD_DDS = 30, /// <summary>Blu-ray Cartridge Status</summary>
|
||||
BD_CartridgeStatus = 31, /// <summary>Blu-ray Status of Spare Area</summary>
|
||||
BD_SpareArea = 32, /// <summary>AACS volume identifier</summary>
|
||||
AACS_VolumeIdentifier = 33, /// <summary>AACS pre-recorded media serial number</summary>
|
||||
AACS_SerialNumber = 34, /// <summary>AACS media identifier</summary>
|
||||
AACS_MediaIdentifier = 35, /// <summary>Lead-in AACS media key block</summary>
|
||||
AACS_MKB = 36, /// <summary>AACS data keys</summary>
|
||||
AACS_DataKeys = 37, /// <summary>LBA extents flagged for bus encryption by AACS</summary>
|
||||
AACS_LBAExtents = 38, /// <summary>CPRM media key block in Lead-in</summary>
|
||||
AACS_CPRM_MKB = 39, /// <summary>Recognized layer formats in hybrid discs</summary>
|
||||
Hybrid_RecognizedLayers = 40, /// <summary>Disc write protection status</summary>
|
||||
MMC_WriteProtection = 41, /// <summary>Disc standard information</summary>
|
||||
MMC_DiscInformation = 42, /// <summary>Disc track resources information</summary>
|
||||
MMC_TrackResourcesInformation = 43, /// <summary>BD-R Pseudo-overwrite information</summary>
|
||||
MMC_POWResourcesInformation = 44, /// <summary>SCSI INQUIRY response</summary>
|
||||
SCSI_INQUIRY = 45, /// <summary>SCSI MODE PAGE 2Ah</summary>
|
||||
SCSI_MODEPAGE_2A = 46, /// <summary>ATA IDENTIFY DEVICE response</summary>
|
||||
ATA_IDENTIFY = 47, /// <summary>ATA IDENTIFY PACKET DEVICE response</summary>
|
||||
ATAPI_IDENTIFY = 48, /// <summary>PCMCIA/CardBus Card Information Structure</summary>
|
||||
PCMCIA_CIS = 49, /// <summary>SecureDigital CID</summary>
|
||||
SD_CID = 50, /// <summary>SecureDigital CSD</summary>
|
||||
SD_CSD = 51, /// <summary>SecureDigital SCR</summary>
|
||||
SD_SCR = 52, /// <summary>SecureDigital OCR</summary>
|
||||
SD_OCR = 53, /// <summary>MultiMediaCard CID</summary>
|
||||
MMC_CID = 54, /// <summary>MultiMediaCard CSD</summary>
|
||||
MMC_CSD = 55, /// <summary>MultiMediaCard OCR</summary>
|
||||
MMC_OCR = 56, /// <summary>MultiMediaCard Extended CSD</summary>
|
||||
MMC_ExtendedCSD = 57, /// <summary>Xbox Security Sector</summary>
|
||||
Xbox_SecuritySector = 58, /// <summary>
|
||||
/// On floppy disks, data in last cylinder usually in a different format that contains duplication or
|
||||
/// manufacturing information
|
||||
/// </summary>
|
||||
Floppy_LeadOut = 59,
|
||||
/// <summary>DVD Disc Control Blocks</summary>
|
||||
DCB = 60,
|
||||
/// <summary>Compact Disc First Track Pregap</summary>
|
||||
CD_FirstTrackPregap = 61,
|
||||
/// <summary>Compact Disc Lead-out</summary>
|
||||
CD_LeadOut = 62,
|
||||
/// <summary>SCSI MODE SENSE (6)</summary>
|
||||
SCSI_MODESENSE_6 = 63,
|
||||
/// <summary>SCSI MODE SENSE (10)</summary>
|
||||
SCSI_MODESENSE_10 = 64,
|
||||
/// <summary>USB descriptors</summary>
|
||||
USB_Descriptors = 65,
|
||||
/// <summary>XGD unlocked DMI</summary>
|
||||
Xbox_DMI = 66,
|
||||
/// <summary>XDG unlocked PFI</summary>
|
||||
Xbox_PFI = 67,
|
||||
/// <summary>Compact Disc Lead-in</summary>
|
||||
Floppy_LeadOut = 59, /// <summary>DVD Disc Control Blocks</summary>
|
||||
DCB = 60, /// <summary>Compact Disc First Track Pregap</summary>
|
||||
CD_FirstTrackPregap = 61, /// <summary>Compact Disc Lead-out</summary>
|
||||
CD_LeadOut = 62, /// <summary>SCSI MODE SENSE (6)</summary>
|
||||
SCSI_MODESENSE_6 = 63, /// <summary>SCSI MODE SENSE (10)</summary>
|
||||
SCSI_MODESENSE_10 = 64, /// <summary>USB descriptors</summary>
|
||||
USB_Descriptors = 65, /// <summary>XGD unlocked DMI</summary>
|
||||
Xbox_DMI = 66, /// <summary>XDG unlocked PFI</summary>
|
||||
Xbox_PFI = 67, /// <summary>Compact Disc Lead-in</summary>
|
||||
CD_LeadIn = 68
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration of media types defined in CICM metadata
|
||||
/// </summary>
|
||||
/// <summary>Enumeration of media types defined in CICM metadata</summary>
|
||||
public enum XmlMediaType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Purely optical discs
|
||||
/// </summary>
|
||||
OpticalDisc = 0,
|
||||
/// <summary>
|
||||
/// Media that is physically block-based or abstracted like that
|
||||
/// </summary>
|
||||
BlockMedia = 1,
|
||||
/// <summary>
|
||||
/// Media that can be accessed by-byte or by-bit, like chips
|
||||
/// </summary>
|
||||
LinearMedia = 2,
|
||||
/// <summary>
|
||||
/// Media that can only store data when it is modulated to audio
|
||||
/// </summary>
|
||||
/// <summary>Purely optical discs</summary>
|
||||
OpticalDisc = 0, /// <summary>Media that is physically block-based or abstracted like that</summary>
|
||||
BlockMedia = 1, /// <summary>Media that can be accessed by-byte or by-bit, like chips</summary>
|
||||
LinearMedia = 2, /// <summary>Media that can only store data when it is modulated to audio</summary>
|
||||
AudioMedia = 3
|
||||
}
|
||||
|
||||
@@ -305,12 +178,9 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
public enum CdFlags : byte
|
||||
{
|
||||
/// <summary>Track is quadraphonic.</summary>
|
||||
FourChannel = 0x08,
|
||||
/// <summary>Track is non-audio (data).</summary>
|
||||
DataTrack = 0x04,
|
||||
/// <summary>Track is copy protected.</summary>
|
||||
CopyPermitted = 0x02,
|
||||
/// <summary>Track has pre-emphasis.</summary>
|
||||
FourChannel = 0x08, /// <summary>Track is non-audio (data).</summary>
|
||||
DataTrack = 0x04, /// <summary>Track is copy protected.</summary>
|
||||
CopyPermitted = 0x02, /// <summary>Track has pre-emphasis.</summary>
|
||||
PreEmphasis = 0x01
|
||||
}
|
||||
|
||||
@@ -319,16 +189,12 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
public enum FloppySectorStatus : byte
|
||||
{
|
||||
/// <summary>Both address mark and data checksums are correct.</summary>
|
||||
Correct = 0x01,
|
||||
/// <summary>Data checksum is incorrect.</summary>
|
||||
DataError = 0x02,
|
||||
/// <summary>Addres mark checksum is incorrect.</summary>
|
||||
Correct = 0x01, /// <summary>Data checksum is incorrect.</summary>
|
||||
DataError = 0x02, /// <summary>Addres mark checksum is incorrect.</summary>
|
||||
AddressMarkError = 0x04,
|
||||
/// <summary>There is another sector in the same track/head with same sector id.</summary>
|
||||
Duplicated = 0x08,
|
||||
/// <summary>Sector data section is not magnetized.</summary>
|
||||
Demagnetized = 0x10,
|
||||
/// <summary>Sector data section has a physically visible hole.</summary>
|
||||
Duplicated = 0x08, /// <summary>Sector data section is not magnetized.</summary>
|
||||
Demagnetized = 0x10, /// <summary>Sector data section has a physically visible hole.</summary>
|
||||
Hole = 0x20,
|
||||
/// <summary>There is no address mark containing the requested sector id in the track/head.</summary>
|
||||
NotFound = 0x40
|
||||
@@ -337,16 +203,11 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
public enum FloppyTypes : byte
|
||||
{
|
||||
/// <summary>8" floppy</summary>
|
||||
Floppy,
|
||||
/// <summary>5.25" floppy</summary>
|
||||
MiniFloppy,
|
||||
/// <summary>3.5" floppy</summary>
|
||||
MicroFloppy,
|
||||
/// <summary>3" floppy</summary>
|
||||
CompactFloppy,
|
||||
/// <summary>5.25" twiggy</summary>
|
||||
FileWare,
|
||||
/// <summary>2.5" quickdisk</summary>
|
||||
Floppy, /// <summary>5.25" floppy</summary>
|
||||
MiniFloppy, /// <summary>3.5" floppy</summary>
|
||||
MicroFloppy, /// <summary>3" floppy</summary>
|
||||
CompactFloppy, /// <summary>5.25" twiggy</summary>
|
||||
FileWare, /// <summary>2.5" quickdisk</summary>
|
||||
QuickDisk
|
||||
}
|
||||
|
||||
@@ -355,10 +216,8 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
/// <summary>Standard coercitivity (about 300Oe as found in 8" and 5.25"-double-density disks).</summary>
|
||||
Standard,
|
||||
/// <summary>Double density coercitivity (about 600Oe as found in 5.25" HD and 3.5" DD disks).</summary>
|
||||
Double,
|
||||
/// <summary>High density coercitivity (about 700Oe as found in 3.5" HD disks).</summary>
|
||||
High,
|
||||
/// <summary>Extended density coercitivity (about 750Oe as found in 3.5" ED disks).</summary>
|
||||
Double, /// <summary>High density coercitivity (about 700Oe as found in 3.5" HD disks).</summary>
|
||||
High, /// <summary>Extended density coercitivity (about 750Oe as found in 3.5" ED disks).</summary>
|
||||
Extended
|
||||
}
|
||||
}
|
||||
@@ -41,154 +41,119 @@ using System.Runtime.Serialization;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Feature is supported by image but not implemented yet.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>Feature is supported by image but not implemented yet.</summary>
|
||||
/// <param name="message">Message.</param>
|
||||
/// <param name="inner">Inner.</param>
|
||||
public FeatureSupportedButNotImplementedImageException(string message, Exception inner) :
|
||||
base(message, inner) { }
|
||||
|
||||
/// <summary>
|
||||
/// Feature is supported by image but not implemented yet.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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)
|
||||
{
|
||||
if(info == null) throw new ArgumentNullException(nameof(info));
|
||||
if(info == null)
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feature is not supported by image.
|
||||
/// </summary>
|
||||
/// <summary>Feature is not supported by image.</summary>
|
||||
[Serializable]
|
||||
public class FeatureUnsupportedImageException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Feature is not supported by image.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>Feature is not supported by image.</summary>
|
||||
/// <param name="info">Info.</param>
|
||||
/// <param name="context">Context.</param>
|
||||
protected FeatureUnsupportedImageException(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if(info == null) throw new ArgumentNullException(nameof(info));
|
||||
if(info == null)
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feature is supported by image but not present on it.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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)
|
||||
{
|
||||
if(info == null) throw new ArgumentNullException(nameof(info));
|
||||
if(info == null)
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feature is supported by image but not by the disc it represents.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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.
|
||||
/// </summary>
|
||||
/// <summary>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)
|
||||
{
|
||||
if(info == null) throw new ArgumentNullException(nameof(info));
|
||||
if(info == null)
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Corrupt, incorrect or unhandled feature found on image
|
||||
/// </summary>
|
||||
/// <summary>Corrupt, incorrect or unhandled feature found on image</summary>
|
||||
[Serializable]
|
||||
public class ImageNotSupportedException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Corrupt, incorrect or unhandled feature found on image
|
||||
/// </summary>
|
||||
/// <summary>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
|
||||
/// </summary>
|
||||
/// <summary>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
|
||||
/// </summary>
|
||||
/// <summary>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)
|
||||
{
|
||||
if(info == null) throw new ArgumentNullException(nameof(info));
|
||||
if(info == null)
|
||||
throw new ArgumentNullException(nameof(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="byte" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="byte" /></summary>
|
||||
public class ExtentsByte
|
||||
{
|
||||
List<Tuple<byte, byte>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsByte()
|
||||
{
|
||||
backend = new List<Tuple<byte, byte>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsByte() => backend = new List<Tuple<byte, byte>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(byte item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<byte, byte>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<byte, byte>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<byte, byte>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<byte, byte>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<byte, byte>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<byte, byte>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<byte, byte>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<byte, byte>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(byte start, byte end, bool run = false)
|
||||
{
|
||||
byte realEnd;
|
||||
if(run) realEnd = (byte)(start + end - 1);
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = (byte)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(byte t = start; t <= realEnd; t++) Add(t);
|
||||
for(byte t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(byte item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(byte item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(byte item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<byte, byte> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>(extent.Item1, (byte)(item - 1));
|
||||
toAddTwo = new Tuple<byte, byte>((byte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>((byte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<byte, byte>(extent.Item1, (byte)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<byte, byte>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(byte item, out byte start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<byte, byte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,20 +47,25 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
public static ExtentType[] ToMetadata(ExtentsULong extents)
|
||||
{
|
||||
if(extents == null) return null;
|
||||
if(extents == null)
|
||||
return null;
|
||||
|
||||
Tuple<ulong, ulong>[] tuples = extents.ToArray();
|
||||
ExtentType[] array = new ExtentType[tuples.Length];
|
||||
|
||||
for(ulong i = 0; i < (ulong)array.LongLength; i++)
|
||||
array[i] = new ExtentType {Start = tuples[i].Item1, End = tuples[i].Item2};
|
||||
array[i] = new ExtentType
|
||||
{
|
||||
Start = tuples[i].Item1, End = tuples[i].Item2
|
||||
};
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static ExtentsULong FromMetadata(ExtentType[] extents)
|
||||
{
|
||||
if(extents == null) return null;
|
||||
if(extents == null)
|
||||
return null;
|
||||
|
||||
List<Tuple<ulong, ulong>> tuples =
|
||||
extents.Select(extent => new Tuple<ulong, ulong>(extent.Start, extent.End)).ToList();
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="int" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="int" /></summary>
|
||||
public class ExtentsInt
|
||||
{
|
||||
List<Tuple<int, int>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsInt()
|
||||
{
|
||||
backend = new List<Tuple<int, int>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsInt() => backend = new List<Tuple<int, int>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsInt(IEnumerable<Tuple<int, int>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsInt(IEnumerable<Tuple<int, int>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(int item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<int, int>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<int, int>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<int, int>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<int, int>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<int, int>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<int, int>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<int, int>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<int, int>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(int start, int end, bool run = false)
|
||||
{
|
||||
int realEnd;
|
||||
if(run) realEnd = start + end - 1;
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(int t = start; t <= realEnd; t++) Add(t);
|
||||
for(int t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(int item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(int item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(int item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<int, int> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<int, int>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<int, int>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<int, int>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(int item, out int start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<int, int> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="long" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="long" /></summary>
|
||||
public class ExtentsLong
|
||||
{
|
||||
List<Tuple<long, long>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsLong()
|
||||
{
|
||||
backend = new List<Tuple<long, long>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsLong() => backend = new List<Tuple<long, long>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsLong(IEnumerable<Tuple<long, long>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsLong(IEnumerable<Tuple<long, long>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(long item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<long, long>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<long, long>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<long, long>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<long, long>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<long, long>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<long, long>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<long, long>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<long, long>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(long start, long end, bool run = false)
|
||||
{
|
||||
long realEnd;
|
||||
if(run) realEnd = start + end - 1;
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(long t = start; t <= realEnd; t++) Add(t);
|
||||
for(long t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(long item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(long item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(long item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<long, long> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<long, long>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<long, long>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<long, long>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(long item, out long start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<long, long> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="sbyte" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="sbyte" /></summary>
|
||||
public class ExtentsSByte
|
||||
{
|
||||
List<Tuple<sbyte, sbyte>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsSByte()
|
||||
{
|
||||
backend = new List<Tuple<sbyte, sbyte>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsSByte() => backend = new List<Tuple<sbyte, sbyte>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(sbyte item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<sbyte, sbyte>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<sbyte, sbyte>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<sbyte, sbyte>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<sbyte, sbyte>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<sbyte, sbyte>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(sbyte start, sbyte end, bool run = false)
|
||||
{
|
||||
sbyte realEnd;
|
||||
if(run) realEnd = (sbyte)(start + end - 1);
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = (sbyte)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(sbyte t = start; t <= realEnd; t++) Add(t);
|
||||
for(sbyte t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(sbyte item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(sbyte item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(sbyte item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<sbyte, sbyte> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>(extent.Item1, (sbyte)(item - 1));
|
||||
toAddTwo = new Tuple<sbyte, sbyte>((sbyte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>((sbyte)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<sbyte, sbyte>(extent.Item1, (sbyte)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<sbyte, sbyte>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(sbyte item, out sbyte start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<sbyte, sbyte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="short" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="short" /></summary>
|
||||
public class ExtentsShort
|
||||
{
|
||||
List<Tuple<short, short>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsShort()
|
||||
{
|
||||
backend = new List<Tuple<short, short>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsShort() => backend = new List<Tuple<short, short>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsShort(IEnumerable<Tuple<short, short>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsShort(IEnumerable<Tuple<short, short>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(short item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<short, short>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<short, short>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<short, short>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<short, short>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<short, short>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<short, short>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<short, short>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<short, short>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(short start, short end, bool run = false)
|
||||
{
|
||||
short realEnd;
|
||||
if(run) realEnd = (short)(start + end - 1);
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = (short)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(short t = start; t <= realEnd; t++) Add(t);
|
||||
for(short t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(short item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(short item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(short item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<short, short> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>(extent.Item1, (short)(item - 1));
|
||||
toAddTwo = new Tuple<short, short>((short)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>((short)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<short, short>(extent.Item1, (short)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<short, short>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(short item, out short start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<short, short> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="uint" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="uint" /></summary>
|
||||
public class ExtentsUInt
|
||||
{
|
||||
List<Tuple<uint, uint>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsUInt()
|
||||
{
|
||||
backend = new List<Tuple<uint, uint>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsUInt() => backend = new List<Tuple<uint, uint>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(uint item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<uint, uint>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<uint, uint>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<uint, uint>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<uint, uint>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<uint, uint>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<uint, uint>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<uint, uint>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<uint, uint>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(uint start, uint end, bool run = false)
|
||||
{
|
||||
uint realEnd;
|
||||
if(run) realEnd = start + end - 1;
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(uint t = start; t <= realEnd; t++) Add(t);
|
||||
for(uint t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(uint item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(uint item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(uint item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<uint, uint> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<uint, uint>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<uint, uint>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<uint, uint>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(uint item, out uint start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<uint, uint> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="ulong" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="ulong" /></summary>
|
||||
public class ExtentsULong
|
||||
{
|
||||
List<Tuple<ulong, ulong>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsULong()
|
||||
{
|
||||
backend = new List<Tuple<ulong, ulong>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsULong() => backend = new List<Tuple<ulong, ulong>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ulong item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<ulong, ulong>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<ulong, ulong>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<ulong, ulong>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<ulong, ulong>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<ulong, ulong>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<ulong, ulong>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<ulong, ulong>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<ulong, ulong>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(ulong start, ulong end, bool run = false)
|
||||
{
|
||||
ulong realEnd;
|
||||
if(run) realEnd = start + end - 1;
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = start + end - 1;
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(ulong t = start; t <= realEnd; t++) Add(t);
|
||||
for(ulong t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(ulong item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(ulong item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(ulong item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<ulong, ulong> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(extent.Item1, item - 1);
|
||||
toAddTwo = new Tuple<ulong, ulong>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(item + 1, extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ulong, ulong>(extent.Item1, item - 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,24 +220,24 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ulong, ulong>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(ulong item, out ulong start)
|
||||
{
|
||||
start = 0;
|
||||
|
||||
foreach(Tuple<ulong, ulong> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,38 +42,22 @@ using System.Linq;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="ushort" />
|
||||
/// </summary>
|
||||
/// <summary>Implements extents for <see cref="ushort" /></summary>
|
||||
public class ExtentsUShort
|
||||
{
|
||||
List<Tuple<ushort, ushort>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsUShort()
|
||||
{
|
||||
backend = new List<Tuple<ushort, ushort>>();
|
||||
}
|
||||
/// <summary>Initialize an empty list of extents</summary>
|
||||
public ExtentsUShort() => backend = new List<Tuple<ushort, ushort>>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <summary>Initializes extents with an specific list</summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list)
|
||||
{
|
||||
backend = list.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list) => backend = list.OrderBy(t => t.Item1).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <summary>Adds the specified number to the corresponding extent, or creates a new one</summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ushort item)
|
||||
{
|
||||
@@ -84,34 +68,41 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
for(int i = 0; i < backend.Count; i++)
|
||||
{
|
||||
// Already contained in an extent
|
||||
if(item >= backend[i].Item1 && item <= backend[i].Item2) return;
|
||||
if(item >= backend[i].Item1 &&
|
||||
item <= backend[i].Item2)
|
||||
return;
|
||||
|
||||
// Expands existing extent start
|
||||
if(item == backend[i].Item1 - 1)
|
||||
{
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i > 0 && item == backend[i - 1].Item2 + 1)
|
||||
if(i > 0 &&
|
||||
item == backend[i - 1].Item2 + 1)
|
||||
{
|
||||
removeTwo = backend[i - 1];
|
||||
itemToAdd = new Tuple<ushort, ushort>(backend[i - 1].Item1, backend[i].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<ushort, ushort>(item, backend[i].Item2);
|
||||
else
|
||||
itemToAdd = new Tuple<ushort, ushort>(item, backend[i].Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Expands existing extent end
|
||||
if(item != backend[i].Item2 + 1) continue;
|
||||
if(item != backend[i].Item2 + 1)
|
||||
continue;
|
||||
|
||||
removeOne = backend[i];
|
||||
|
||||
if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1)
|
||||
if(i < backend.Count - 1 &&
|
||||
item == backend[i + 1].Item1 - 1)
|
||||
{
|
||||
removeTwo = backend[i + 1];
|
||||
itemToAdd = new Tuple<ushort, ushort>(backend[i].Item1, backend[i + 1].Item2);
|
||||
}
|
||||
else itemToAdd = new Tuple<ushort, ushort>(backend[i].Item1, item);
|
||||
else
|
||||
itemToAdd = new Tuple<ushort, ushort>(backend[i].Item1, item);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -122,15 +113,14 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
backend.Remove(removeTwo);
|
||||
backend.Add(itemToAdd);
|
||||
}
|
||||
else backend.Add(new Tuple<ushort, ushort>(item, item));
|
||||
else
|
||||
backend.Add(new Tuple<ushort, ushort>(item, item));
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <summary>Adds a new extent</summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
@@ -140,34 +130,26 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
public void Add(ushort start, ushort end, bool run = false)
|
||||
{
|
||||
ushort realEnd;
|
||||
if(run) realEnd = (ushort)(start + end - 1);
|
||||
else realEnd = end;
|
||||
|
||||
if(run)
|
||||
realEnd = (ushort)(start + end - 1);
|
||||
else
|
||||
realEnd = end;
|
||||
|
||||
// TODO: Optimize this
|
||||
for(ushort t = start; t <= realEnd; t++) Add(t);
|
||||
for(ushort t = start; t <= realEnd; t++)
|
||||
Add(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <summary>Checks if the specified item is contained by an extent on this instance</summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
public bool Contains(ushort item)
|
||||
{
|
||||
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
}
|
||||
public bool Contains(ushort item) => backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
backend.Clear();
|
||||
}
|
||||
/// <summary>Removes all extents from this instance</summary>
|
||||
public void Clear() => backend.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <summary>Removes an item from the extents in this instance</summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
public bool Remove(ushort item)
|
||||
@@ -179,43 +161,57 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
foreach(Tuple<ushort, ushort> extent in backend)
|
||||
{
|
||||
// Extent is contained and not a border
|
||||
if(item > extent.Item1 && item < extent.Item2)
|
||||
if(item > extent.Item1 &&
|
||||
item < extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>(extent.Item1, (ushort)(item - 1));
|
||||
toAddTwo = new Tuple<ushort, ushort>((ushort)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is left border, but not only element
|
||||
if(item == extent.Item1 && item != extent.Item2)
|
||||
if(item == extent.Item1 &&
|
||||
item != extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>((ushort)(item + 1), extent.Item2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is right border, but not only element
|
||||
if(item != extent.Item1 && item == extent.Item2)
|
||||
if(item != extent.Item1 &&
|
||||
item == extent.Item2)
|
||||
{
|
||||
toRemove = extent;
|
||||
toAddOne = new Tuple<ushort, ushort>(extent.Item1, (ushort)(item - 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Extent is only element
|
||||
if(item != extent.Item1 || item != extent.Item2) continue;
|
||||
if(item != extent.Item1 ||
|
||||
item != extent.Item2)
|
||||
continue;
|
||||
|
||||
toRemove = extent;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Item not found
|
||||
if(toRemove == null) return false;
|
||||
if(toRemove == null)
|
||||
return false;
|
||||
|
||||
backend.Remove(toRemove);
|
||||
if(toAddOne != null) backend.Add(toAddOne);
|
||||
if(toAddTwo != null) backend.Add(toAddTwo);
|
||||
|
||||
if(toAddOne != null)
|
||||
backend.Add(toAddOne);
|
||||
|
||||
if(toAddTwo != null)
|
||||
backend.Add(toAddTwo);
|
||||
|
||||
// Sort
|
||||
backend = backend.OrderBy(t => t.Item1).ToList();
|
||||
@@ -224,25 +220,25 @@ namespace DiscImageChef.CommonTypes.Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and
|
||||
/// T2 is last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ushort, ushort>[] ToArray() => backend.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <summary>Gets the first element of the extent that contains the specified item</summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
|
||||
public bool GetStart(ushort item, out ushort start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<ushort, ushort> extent in
|
||||
backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
|
||||
foreach(Tuple<ushort, ushort> extent in backend.Where(extent =>
|
||||
item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
43
Filters.cs
43
Filters.cs
@@ -50,9 +50,7 @@ namespace DiscImageChef.CommonTypes
|
||||
{
|
||||
public SortedDictionary<string, IFilter> Filters;
|
||||
|
||||
/// <summary>
|
||||
/// Fills the list of all known filters
|
||||
/// </summary>
|
||||
/// <summary>Fills the list of all known filters</summary>
|
||||
public FiltersList()
|
||||
{
|
||||
Assembly assembly = Assembly.Load("DiscImageChef.Filters");
|
||||
@@ -61,16 +59,20 @@ namespace DiscImageChef.CommonTypes
|
||||
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter))))
|
||||
try
|
||||
{
|
||||
IFilter filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
if(filter != null && !Filters.ContainsKey(filter.Name.ToLower()))
|
||||
var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ });
|
||||
|
||||
if(filter != null &&
|
||||
!Filters.ContainsKey(filter.Name.ToLower()))
|
||||
Filters.Add(filter.Name.ToLower(), filter);
|
||||
}
|
||||
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
|
||||
catch(Exception exception)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Exception {0}", exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filter that allows to read the specified path
|
||||
/// </summary>
|
||||
/// <summary>Gets the filter that allows to read the specified path</summary>
|
||||
/// <param name="path">Path</param>
|
||||
/// <returns>The filter that allows reading the specified path</returns>
|
||||
public IFilter GetFilter(string path)
|
||||
@@ -78,33 +80,38 @@ namespace DiscImageChef.CommonTypes
|
||||
try
|
||||
{
|
||||
IFilter noFilter = null;
|
||||
|
||||
foreach(IFilter filter in Filters.Values)
|
||||
if(filter.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||
{
|
||||
if(!filter.Identify(path)) continue;
|
||||
if(!filter.Identify(path))
|
||||
continue;
|
||||
|
||||
IFilter foundFilter =
|
||||
(IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ });
|
||||
|
||||
foundFilter?.Open(path);
|
||||
|
||||
if(foundFilter?.IsOpened() == true) return foundFilter;
|
||||
if(foundFilter?.IsOpened() == true)
|
||||
return foundFilter;
|
||||
}
|
||||
else
|
||||
noFilter = filter;
|
||||
|
||||
if(!noFilter?.Identify(path) == true) return noFilter;
|
||||
if(!noFilter?.Identify(path) == true)
|
||||
return noFilter;
|
||||
|
||||
noFilter?.Open(path);
|
||||
|
||||
return noFilter;
|
||||
}
|
||||
catch(IOException) { return null; }
|
||||
catch(IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all known filters
|
||||
/// </summary>
|
||||
/// <summary>Gets all known filters</summary>
|
||||
/// <returns>Known filters</returns>
|
||||
public SortedDictionary<string, IFilter> GetFiltersList() => Filters;
|
||||
}
|
||||
|
||||
25
Geometry.cs
25
Geometry.cs
@@ -42,7 +42,7 @@ namespace DiscImageChef.CommonTypes
|
||||
{
|
||||
public static class Geometry
|
||||
{
|
||||
static readonly (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding
|
||||
static readonly(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding
|
||||
encoding, bool variableSectorsPerTrack, MediaType type)[] KnownGeometries =
|
||||
{
|
||||
(32, 1, 8, 319, MediaEncoding.FM, false, MediaType.IBM23FD),
|
||||
@@ -107,6 +107,7 @@ namespace DiscImageChef.CommonTypes
|
||||
(82, 2, 21, 512, MediaEncoding.MFM, false, MediaType.FDFORMAT_35_HD),
|
||||
(240, 2, 38, 512, MediaEncoding.MFM, false, MediaType.NEC_35_TD),
|
||||
(753, 2, 27, 512, MediaEncoding.MFM, false, MediaType.Floptical),
|
||||
|
||||
// Following ones are what the device itself report, not the physical geometry
|
||||
(154, 16, 32, 512, MediaEncoding.MFM, false, MediaType.PocketZip),
|
||||
(262, 32, 56, 512, MediaEncoding.MFM, false, MediaType.LS240),
|
||||
@@ -117,18 +118,18 @@ namespace DiscImageChef.CommonTypes
|
||||
|
||||
public static MediaType GetMediaType(
|
||||
(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool
|
||||
variableSectorsPerTrack) geometry) =>
|
||||
(from geom in KnownGeometries
|
||||
where geom.cylinders == geometry.cylinders &&
|
||||
geom.heads == geometry.heads &&
|
||||
geom.sectorsPerTrack == geometry.sectorsPerTrack &&
|
||||
geom.bytesPerSector == geometry.bytesPerSector &&
|
||||
geom.encoding == geometry.encoding &&
|
||||
geom.variableSectorsPerTrack == geometry.variableSectorsPerTrack
|
||||
select geom.type).FirstOrDefault();
|
||||
variableSectorsPerTrack) geometry) => (from geom in KnownGeometries
|
||||
where geom.cylinders == geometry.cylinders &&
|
||||
geom.heads == geometry.heads &&
|
||||
geom.sectorsPerTrack == geometry.sectorsPerTrack &&
|
||||
geom.bytesPerSector == geometry.bytesPerSector &&
|
||||
geom.encoding == geometry.encoding &&
|
||||
geom.variableSectorsPerTrack ==
|
||||
geometry.variableSectorsPerTrack select geom.type).
|
||||
FirstOrDefault();
|
||||
|
||||
public static (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding
|
||||
, bool variableSectorsPerTrack, MediaType type) GetGeometry(MediaType mediaType) =>
|
||||
public static(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding,
|
||||
bool variableSectorsPerTrack, MediaType type) GetGeometry(MediaType mediaType) =>
|
||||
(from geom in KnownGeometries where geom.type == mediaType select geom).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@@ -32,54 +32,34 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
[Flags]
|
||||
public enum ArchiveSupportedFeature : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// The archive supports filenames for its entries. If this flag is not set,
|
||||
/// files can only be accessed by number.
|
||||
/// <summary>The archive supports filenames for its entries. If this flag is not set, files can only be accessed by number.</summary>
|
||||
SupportsFilenames = 1 << 0, /// <summary>
|
||||
/// The archive supports compression. If this flag is not set, compressed and uncompressed lengths are always the
|
||||
/// same.
|
||||
/// </summary>
|
||||
SupportsFilenames = 1 << 0,
|
||||
SupportsCompression = 1 << 1, /// <summary>
|
||||
/// The archive supports subdirectories. If this flag is not set, all filenames are guaranteed to not contain any
|
||||
/// "/" character.
|
||||
/// </summary>
|
||||
SupportsSubdirectories = 1 << 2, /// <summary>
|
||||
/// The archive supports explicit entries for directories (like Zip, for example). If this flag is not set,
|
||||
/// directories are implicit by the relative name of the files.
|
||||
/// </summary>
|
||||
HasExplicitDirectories = 1 << 3, /// <summary>The archive stores a timestamp with each entry if this flag is set.</summary>
|
||||
HasEntryTimestamp = 1 << 4, /// <summary>If this flag is set, individual files or the whole archive might be encrypted or password-protected.</summary>
|
||||
SupportsProtection = 1 << 5, // TODO: not implemented yet
|
||||
|
||||
/// <summary>
|
||||
/// The archive supports compression. If this flag is not set, compressed and
|
||||
/// uncompressed lengths are always the same.
|
||||
/// </summary>
|
||||
SupportsCompression = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// The archive supports subdirectories. If this flag is not set, all filenames are
|
||||
/// guaranteed to not contain any "/" character.
|
||||
/// </summary>
|
||||
SupportsSubdirectories = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// The archive supports explicit entries for directories (like Zip, for example).
|
||||
/// If this flag is not set, directories are implicit by the relative name of the files.
|
||||
/// </summary>
|
||||
HasExplicitDirectories = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// The archive stores a timestamp with each entry if this flag is set.
|
||||
/// </summary>
|
||||
HasEntryTimestamp = 1 << 4,
|
||||
|
||||
/// <summary>
|
||||
/// If this flag is set, individual files or the whole archive might be encrypted or
|
||||
/// password-protected.
|
||||
/// </summary>
|
||||
SupportsProtection = 1 << 5, // TODO: not implemented yet
|
||||
|
||||
/// <summary>
|
||||
/// If this flag is set, the archive supports returning extended attributes (Xattrs) for each entry.
|
||||
/// </summary>
|
||||
SupportsXAttrs = 1 << 6,
|
||||
};
|
||||
/// <summary>If this flag is set, the archive supports returning extended attributes (Xattrs) for each entry.</summary>
|
||||
SupportsXAttrs = 1 << 6
|
||||
}
|
||||
|
||||
public interface IArchive
|
||||
{
|
||||
@@ -89,39 +69,27 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <summary>Unique UUID of the plugin</summary>
|
||||
Guid Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified path contains data recognizable by this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Identifies if the specified path contains data recognizable by this archive instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
bool Identify(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified stream contains data recognizable by this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Identifies if the specified stream contains data recognizable by this archive instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
bool Identify(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies if the specified buffer contains data recognizable by this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Identifies if the specified buffer contains data recognizable by this archive instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
bool Identify(byte[] buffer);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified path with this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Opens the specified path with this archive instance</summary>
|
||||
/// <param name="path">Path.</param>
|
||||
void Open(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified stream with this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Opens the specified stream with this archive instance</summary>
|
||||
/// <param name="stream">Stream.</param>
|
||||
void Open(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified buffer with this archive instance
|
||||
/// </summary>
|
||||
/// <summary>Opens the specified buffer with this archive instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
void Open(byte[] buffer);
|
||||
|
||||
@@ -131,123 +99,95 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// </summary>
|
||||
bool IsOpened();
|
||||
|
||||
/// <summary>
|
||||
/// Closes all opened streams.
|
||||
/// </summary>
|
||||
/// <summary>Closes all opened streams.</summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Return a bitfield indicating the features supported by this archive type.
|
||||
/// </summary>
|
||||
/// <summary>Return a bitfield indicating the features supported by this archive type.</summary>
|
||||
/// <returns>The <c>ArchiveSupportedFeature</c> bitfield.</returns>
|
||||
/// <remarks>
|
||||
/// This should be a constant, tied to the archive type, not to the particular
|
||||
/// features used by the currently-opened archive file.
|
||||
/// This should be a constant, tied to the archive type, not to the particular features used by the
|
||||
/// currently-opened archive file.
|
||||
/// </remarks>
|
||||
ArchiveSupportedFeature GetArchiveFeatures();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of entries (i.e. files) that are contained in this archive.
|
||||
/// </summary>
|
||||
/// <summary>Gets the number of entries (i.e. files) that are contained in this archive.</summary>
|
||||
/// <remarks>
|
||||
/// Entries in this context can also mean directories or volume labels, for some types of
|
||||
/// archives that store these explicitly. Do not rely on all entries being regular files!
|
||||
/// Entries in this context can also mean directories or volume labels, for some types of archives that store
|
||||
/// these explicitly. Do not rely on all entries being regular files!
|
||||
/// </remarks>
|
||||
/// <returns>The number of files.</returns>
|
||||
int GetNumberOfEntries();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file name (and path) of the given entry in the archive.
|
||||
/// </summary>
|
||||
/// <summary>Gets the file name (and path) of the given entry in the archive.</summary>
|
||||
/// <remarks>
|
||||
/// The path components are separated by a forward slash "/". <br />
|
||||
/// The path should not start with a leading slash (i.e. it should be relative, not absolute).
|
||||
/// The path components are separated by a forward slash "/". <br /> The path should not start with a leading
|
||||
/// slash (i.e. it should be relative, not absolute).
|
||||
/// </remarks>
|
||||
/// <seealso cref="Stat(int)"/>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <param name="entryNumber">The entry in the archive for which to return the file name.</param>
|
||||
/// <returns>The file name, with (relative) path</returns>
|
||||
string GetFilename(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entry number for a particular file path in the archive. <c>fileName</c> is
|
||||
/// the relative path of the file in the archive. If the file cannot be found, -1 is returned.
|
||||
/// Gets the entry number for a particular file path in the archive. <c>fileName</c> is the relative path of the
|
||||
/// file in the archive. If the file cannot be found, -1 is returned.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The path should be relative (no leading slash), using regular slashes as path separator, and be
|
||||
/// normalized, i.e. no "foo//bar" or "foo/../bar" path components.
|
||||
/// The path should be relative (no leading slash), using regular slashes as path separator, and be normalized,
|
||||
/// i.e. no "foo//bar" or "foo/../bar" path components.
|
||||
/// </remarks>
|
||||
/// <param name="fileName">The relative path for which to get the entry number.</param>
|
||||
/// <param name="caseInsensitiveMatch">If set, do a case insensitive matching and return the first file that matches.</param>
|
||||
/// <returns>The number of the entry corresponding to the given path, or -1 if the path does not exist.</returns>
|
||||
int GetEntryNumber(string fileName, bool caseInsensitiveMatch);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the (compressed) size of the given entry.
|
||||
/// </summary>
|
||||
/// <summary>Gets the (compressed) size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the compressed size.</param>
|
||||
/// <returns>The compressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <remarks>
|
||||
/// The return value is equal to the return value of <c>GetUncompressedSize()</c> if the file is not compressed.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetUncompressedSize(int)"/>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetUncompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetUncompressedSize(int)" />
|
||||
long GetCompressedSize(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the uncompressed size of the given entry.
|
||||
/// </summary>
|
||||
/// <summary>Gets the uncompressed size of the given entry.</summary>
|
||||
/// <param name="entryNumber">The entry for which to get the uncompressed size.</param>
|
||||
/// <returns>The uncompressed size of the entry, or 0 if the entry is not a regular file.</returns>
|
||||
/// <remarks>
|
||||
/// The return value is equal to the return value of <c>GetCompressedSize()</c> if the file is not compressed.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetCompressedSize(int)"/>
|
||||
/// <remarks>The return value is equal to the return value of <c>GetCompressedSize()</c> if the file is not compressed.</remarks>
|
||||
/// <seealso cref="GetCompressedSize(int)" />
|
||||
long GetUncompressedSize(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attributes of a file or directory.
|
||||
/// </summary>
|
||||
/// <seealso cref="Stat(int)"/>
|
||||
/// <summary>Gets the attributes of a file or directory.</summary>
|
||||
/// <seealso cref="Stat(int)" />
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retreive the attributes.</param>
|
||||
/// <returns>File attributes, or zero if the archive does not support attributes.</returns>
|
||||
FileAttributes GetAttributes(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all extended attributes, alternate data streams and forks of the given file.
|
||||
/// </summary>
|
||||
/// <summary>Lists all extended attributes, alternate data streams and forks of the given file.</summary>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retreive the list of attributes.</param>
|
||||
/// <returns>List of extended attributes, alternate data streams and forks.</returns>
|
||||
List<string> GetXAttrs(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Reads an extended attribute, alternate data stream or fork from the given file.
|
||||
/// </summary>
|
||||
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="entryNumber">The entry in the archive for which to retreive the XAttr.</param>
|
||||
/// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
|
||||
/// <returns>Buffer with the XAttr data.</returns>
|
||||
byte[] GetXattr(int entryNumber, string xattr);
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about an entry in the archive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that some of the data might be incomplete or not available at all, depending on the type of
|
||||
/// archive.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetAttributes(int)"/>
|
||||
/// <seealso cref="GetFilename(int)"/>
|
||||
/// <summary>Gets information about an entry in the archive.</summary>
|
||||
/// <remarks>Note that some of the data might be incomplete or not available at all, depending on the type of archive.</remarks>
|
||||
/// <seealso cref="GetAttributes(int)" />
|
||||
/// <seealso cref="GetFilename(int)" />
|
||||
/// <param name="entryNumber">The entry int he archive for which to get the information</param>
|
||||
/// <returns>The available information about the entry in the archive</returns>
|
||||
FileSystemInfo Stat(int entryNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Filter for the given entry. It will return <c>null</c> if the entry in question
|
||||
/// is not a regular file (i.e. directory, volume label, etc.)
|
||||
/// Returns the Filter for the given entry. It will return <c>null</c> if the entry in question is not a regular
|
||||
/// file (i.e. directory, volume label, etc.)
|
||||
/// </summary>
|
||||
/// <param name="entryNumber">The entry for which the Filter should be returned.</param>
|
||||
/// <returns>The Filter for the given entry.</returns>
|
||||
IFilter GetEntry(int entryNumber);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,27 +40,19 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IChecksum
|
||||
{
|
||||
/// <summary>
|
||||
/// Updates the hash with data.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <summary>Returns a byte array of the hash value.</summary>
|
||||
byte[] Final();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hexadecimal representation of the hash value.
|
||||
/// </summary>
|
||||
/// <summary>Returns a hexadecimal representation of the hash value.</summary>
|
||||
string End();
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,7 @@ using Schemas;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to implement filesystem plugins.
|
||||
/// </summary>
|
||||
/// <summary>Interface to implement filesystem plugins.</summary>
|
||||
public interface IFilesystem
|
||||
{
|
||||
Encoding Encoding { get; }
|
||||
@@ -52,25 +50,19 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
string Name { get; }
|
||||
/// <summary>Plugin UUID.</summary>
|
||||
Guid Id { get; }
|
||||
/// <summary>
|
||||
/// Information about the filesystem as expected by CICM Metadata XML
|
||||
/// </summary>
|
||||
/// <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>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the filesystem in the specified LBA
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
|
||||
@@ -50,106 +50,80 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Closes all opened streams.
|
||||
/// </summary>
|
||||
/// <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
|
||||
/// 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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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
|
||||
/// 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>
|
||||
/// <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>
|
||||
/// <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
|
||||
/// 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
|
||||
/// 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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <summary>Identifies if the specified buffer contains data recognizable by this filter instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
bool Identify(byte[] buffer);
|
||||
|
||||
@@ -159,21 +133,15 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// </summary>
|
||||
bool IsOpened();
|
||||
|
||||
/// <summary>
|
||||
/// Opens the specified path with this filter instance
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <summary>Opens the specified buffer with this filter instance</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
void Open(byte[] buffer);
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ 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.
|
||||
/// 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
|
||||
{
|
||||
@@ -55,16 +55,13 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// </summary>
|
||||
FloppyInfo FloppyInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's user data.
|
||||
/// </summary>
|
||||
/// <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.
|
||||
/// 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>
|
||||
@@ -72,16 +69,13 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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>
|
||||
/// <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.
|
||||
/// 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>
|
||||
@@ -89,24 +83,19 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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.
|
||||
/// 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>
|
||||
@@ -114,17 +103,13 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <param name="status">Status of request.</param>
|
||||
byte[] ReadSectorLong(ushort track, byte head, ushort sector, out FloppySectorStatus status);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a track.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
|
||||
@@ -45,9 +45,7 @@ using Schemas;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins.
|
||||
/// </summary>
|
||||
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
||||
public interface IMediaImage
|
||||
{
|
||||
/// <summary>Image information</summary>
|
||||
@@ -58,9 +56,7 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
Guid Id { get; }
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
/// <summary>
|
||||
/// Gets the image format.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
@@ -68,69 +64,51 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <summary>Gets the CICM XML metadata for the image</summary>
|
||||
CICMMetadataType CicmMetadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the image.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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 user data from several sectors.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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 a complete sector (user data + all tags).
|
||||
/// </summary>
|
||||
/// <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 several complete sector (user data + all tags).
|
||||
/// </summary>
|
||||
/// <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>
|
||||
|
||||
@@ -42,51 +42,37 @@ using DiscImageChef.CommonTypes.Structs;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image reading plugins.
|
||||
/// </summary>
|
||||
/// <summary>Abstract class to implement disk image reading plugins.</summary>
|
||||
public interface IOpticalMediaImage : IMediaImage, IPartitionableMediaImage, IVerifiableSectorsImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the disc track extents (start, length).
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <summary>Gets the sessions (optical discs only).</summary>
|
||||
/// <value>The sessions.</value>
|
||||
List<Session> Sessions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reads a sector's user data, relative to track.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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, relative to track.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
@@ -94,47 +80,37 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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), relative to track.
|
||||
/// </summary>
|
||||
/// <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), relative to track.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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 several sectors, relative to track.
|
||||
/// </summary>
|
||||
/// <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,
|
||||
bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
||||
out List<ulong> unknownLbas);
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,7 @@ using DiscImageChef.CommonTypes.Interfaces;
|
||||
|
||||
namespace DiscImageChef.Partitions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement partitioning schemes interpreting plugins.
|
||||
/// </summary>
|
||||
/// <summary>Abstract class to implement partitioning schemes interpreting plugins.</summary>
|
||||
public interface IPartition
|
||||
{
|
||||
/// <summary>Plugin name.</summary>
|
||||
@@ -56,9 +54,7 @@ namespace DiscImageChef.Partitions
|
||||
/// <summary>Plugin author</summary>
|
||||
string Author { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interprets a partitioning scheme.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
|
||||
@@ -44,9 +44,8 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
public interface IPartitionableMediaImage
|
||||
{
|
||||
/// <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>
|
||||
/// <value>The partitions.</value>
|
||||
List<Partition> Partitions { get; }
|
||||
|
||||
@@ -43,57 +43,39 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IPluginRegister
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all checksum plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all checksum plugins</summary>
|
||||
/// <returns>List of checksum plugins</returns>
|
||||
List<Type> GetAllChecksumPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all filesystem plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all filesystem plugins</summary>
|
||||
/// <returns>List of filesystem plugins</returns>
|
||||
List<Type> GetAllFilesystemPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all filter plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all filter plugins</summary>
|
||||
/// <returns>List of filter plugins</returns>
|
||||
List<Type> GetAllFilterPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all floppy image plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all floppy image plugins</summary>
|
||||
/// <returns>List of floppy image plugins</returns>
|
||||
List<Type> GetAllFloppyImagePlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all media image plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all media image plugins</summary>
|
||||
/// <returns>List of media image plugins</returns>
|
||||
List<Type> GetAllMediaImagePlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all partition plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all partition plugins</summary>
|
||||
/// <returns>List of partition plugins</returns>
|
||||
List<Type> GetAllPartitionPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all read-only filesystem plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all read-only filesystem plugins</summary>
|
||||
/// <returns>List of read-only filesystem plugins</returns>
|
||||
List<Type> GetAllReadOnlyFilesystemPlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all writable floppy image plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all writable floppy image plugins</summary>
|
||||
/// <returns>List of writable floppy image plugins</returns>
|
||||
List<Type> GetAllWritableFloppyImagePlugins();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all writable media image plugins
|
||||
/// </summary>
|
||||
/// <summary>Gets all writable media image plugins</summary>
|
||||
/// <returns>List of writable media image plugins</returns>
|
||||
List<Type> GetAllWritableImagePlugins();
|
||||
}
|
||||
|
||||
@@ -44,21 +44,17 @@ using DiscImageChef.CommonTypes.Structs;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to implement filesystem plugins.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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; }
|
||||
|
||||
Dictionary<string, string> Namespaces { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializates whatever internal structures the filesystem plugin needs to be able to read files and directories
|
||||
/// from the filesystem.
|
||||
/// 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>
|
||||
@@ -66,80 +62,59 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <param name="options">Dictionary of key=value pairs containing options to pass to the filesystem</param>
|
||||
/// <param name="namespace">Filename namespace</param>
|
||||
Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary<string, string> options,
|
||||
string @namespace);
|
||||
string @namespace);
|
||||
|
||||
/// <summary>
|
||||
/// Frees all internal structures created by
|
||||
/// <see cref="Mount" />
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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);
|
||||
|
||||
@@ -44,17 +44,11 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface ITapeImage : IMediaImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all the files registered in the image
|
||||
/// </summary>
|
||||
/// <summary>Gets a list of all the files registered in the image</summary>
|
||||
List<TapeFile> Files { get; }
|
||||
/// <summary>
|
||||
/// Gets a list of all the partitions registered in the image
|
||||
/// </summary>
|
||||
/// <summary>Gets a list of all the partitions registered in the image</summary>
|
||||
List<TapePartition> TapePartitions { get; }
|
||||
/// <summary>
|
||||
/// If the media is a really a tape, as some formats can store non-tapes
|
||||
/// </summary>
|
||||
/// <summary>If the media is a really a tape, as some formats can store non-tapes</summary>
|
||||
bool IsTape { get; }
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,7 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IVerifiableImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies media image internal checksum.
|
||||
/// </summary>
|
||||
/// <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();
|
||||
}
|
||||
|
||||
@@ -43,16 +43,12 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IVerifiableSectorsImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies a sector.
|
||||
/// </summary>
|
||||
/// <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 several sectors.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
|
||||
@@ -42,10 +42,10 @@ 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.
|
||||
/// 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
|
||||
{
|
||||
@@ -60,14 +60,11 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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>
|
||||
/// <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.
|
||||
/// 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>
|
||||
@@ -76,23 +73,18 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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.
|
||||
/// 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>
|
||||
|
||||
@@ -45,38 +45,28 @@ using Schemas;
|
||||
namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class to implement disk image writing plugins.
|
||||
/// TODO: This interface is subject to change until notice.
|
||||
/// 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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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-chosing
|
||||
/// </summary>
|
||||
/// <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
|
||||
/// 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>
|
||||
@@ -85,11 +75,9 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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);
|
||||
uint sectorSize);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a media tag to the image
|
||||
/// </summary>
|
||||
/// <summary>Writes a media tag to the image</summary>
|
||||
/// <param name="data">Media tag</param>
|
||||
/// <param name="tag">
|
||||
/// <see cref="MediaTagType" />
|
||||
@@ -97,74 +85,56 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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 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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// Closes and flushes to disk the image
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
@@ -172,14 +142,10 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <summary>Sets the CICM XML metadata for the image</summary>
|
||||
bool SetCicmMetadata(CICMMetadataType metadata);
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,7 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IWritableOpticalImage : IWritableImage, IOpticalMediaImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets tracks for optical media
|
||||
/// </summary>
|
||||
/// <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);
|
||||
|
||||
@@ -43,23 +43,19 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
{
|
||||
public interface IWritableTapeImage : ITapeImage, IWritableImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers a new file in the image
|
||||
/// </summary>
|
||||
/// <summary>Registers a new file in the image</summary>
|
||||
/// <param name="file">Tape file descriptor</param>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool AddFile(TapeFile file);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new partition
|
||||
/// </summary>
|
||||
/// <summary>Registers a new partition</summary>
|
||||
/// <param name="partition">Tape partition descriptor</param>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool AddPartition(TapePartition partition);
|
||||
|
||||
/// <summary>
|
||||
/// Tells the image plugin to set the internal structures to expect a tape (e.g. unknown block count and size).
|
||||
/// Must be called before <see cref="IWritableImage.Create"/>
|
||||
/// Tells the image plugin to set the internal structures to expect a tape (e.g. unknown block count and size).
|
||||
/// Must be called before <see cref="IWritableImage.Create" />
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if successful, <c>false</c> otherwise</returns>
|
||||
bool SetTape();
|
||||
|
||||
@@ -55,38 +55,47 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
public static readonly bool IsNetNative =
|
||||
RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the underlying runtime runs in 64-bit mode
|
||||
/// </summary>
|
||||
/// <summary>Checks if the underlying runtime runs in 64-bit mode</summary>
|
||||
public static readonly bool Is64Bit = IntPtr.Size == 8;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the underlying runtime runs in 32-bit mode
|
||||
/// </summary>
|
||||
/// <summary>Checks if the underlying runtime runs in 32-bit mode</summary>
|
||||
public static readonly bool Is32Bit = IntPtr.Size == 4;
|
||||
|
||||
public static bool IsWindows =>
|
||||
GetRealPlatformID() == PlatformID.Win32NT || GetRealPlatformID() == PlatformID.Win32S ||
|
||||
GetRealPlatformID() == PlatformID.Win32Windows || GetRealPlatformID() == PlatformID.WinCE ||
|
||||
GetRealPlatformID() == PlatformID.WindowsPhone || GetRealPlatformID() == PlatformID.Xbox;
|
||||
public static bool IsWindows => GetRealPlatformID() == PlatformID.Win32NT ||
|
||||
GetRealPlatformID() == PlatformID.Win32S ||
|
||||
GetRealPlatformID() == PlatformID.Win32Windows ||
|
||||
GetRealPlatformID() == PlatformID.WinCE ||
|
||||
GetRealPlatformID() == PlatformID.WindowsPhone ||
|
||||
GetRealPlatformID() == PlatformID.Xbox;
|
||||
|
||||
public static bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!IsWindows) return Environment.UserName == "root";
|
||||
if(!IsWindows)
|
||||
return Environment.UserName == "root";
|
||||
|
||||
bool isAdmin;
|
||||
WindowsIdentity user = null;
|
||||
|
||||
try
|
||||
{
|
||||
user = WindowsIdentity.GetCurrent();
|
||||
WindowsPrincipal principal = new WindowsPrincipal(user);
|
||||
var principal = new WindowsPrincipal(user);
|
||||
isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
catch(UnauthorizedAccessException ex) { isAdmin = false; }
|
||||
catch(Exception ex) { isAdmin = false; }
|
||||
finally { user?.Dispose(); }
|
||||
catch(UnauthorizedAccessException ex)
|
||||
{
|
||||
isAdmin = false;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
isAdmin = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
user?.Dispose();
|
||||
}
|
||||
|
||||
return isAdmin;
|
||||
}
|
||||
@@ -98,35 +107,37 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
[DllImport("libc", SetLastError = true, EntryPoint = "sysctlbyname", CharSet = CharSet.Ansi)]
|
||||
static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the real platform ID, not the incomplete .NET framework one
|
||||
/// </summary>
|
||||
/// <summary>Gets the real platform ID, not the incomplete .NET framework one</summary>
|
||||
/// <returns>Platform ID</returns>
|
||||
/// <exception cref="Exception">Unhandled exception</exception>
|
||||
public static PlatformID GetRealPlatformID()
|
||||
{
|
||||
if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5)
|
||||
return (PlatformID)(int)Environment.OSVersion.Platform;
|
||||
if((int)Environment.OSVersion.Platform < 4 ||
|
||||
(int)Environment.OSVersion.Platform == 5)
|
||||
return(PlatformID)(int)Environment.OSVersion.Platform;
|
||||
|
||||
int error = uname(out utsname unixname);
|
||||
if(error != 0) throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
|
||||
if(error != 0)
|
||||
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
|
||||
switch(unixname.sysname)
|
||||
{
|
||||
// TODO: Differentiate Linux, Android, Tizen
|
||||
case "Linux":
|
||||
case"Linux":
|
||||
{
|
||||
#if __ANDROID__
|
||||
#if __ANDROID__
|
||||
return PlatformID.Android;
|
||||
#else
|
||||
#else
|
||||
return PlatformID.Linux;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
case "Darwin":
|
||||
case"Darwin":
|
||||
{
|
||||
IntPtr pLen = Marshal.AllocHGlobal(sizeof(int));
|
||||
int osxError = OSX_sysctlbyname("hw.machine", IntPtr.Zero, pLen, IntPtr.Zero, 0);
|
||||
|
||||
if(osxError != 0)
|
||||
{
|
||||
Marshal.FreeHGlobal(pLen);
|
||||
@@ -137,6 +148,7 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
int length = Marshal.ReadInt32(pLen);
|
||||
IntPtr pStr = Marshal.AllocHGlobal(length);
|
||||
osxError = OSX_sysctlbyname("hw.machine", pStr, pLen, IntPtr.Zero, 0);
|
||||
|
||||
if(osxError != 0)
|
||||
{
|
||||
Marshal.FreeHGlobal(pStr);
|
||||
@@ -150,52 +162,52 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
Marshal.FreeHGlobal(pStr);
|
||||
Marshal.FreeHGlobal(pLen);
|
||||
|
||||
if(machine != null && (machine.StartsWith("iPad", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPod", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPhone", StringComparison.Ordinal)))
|
||||
if(machine != null &&
|
||||
(machine.StartsWith("iPad", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPod", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPhone", StringComparison.Ordinal)))
|
||||
return PlatformID.iOS;
|
||||
|
||||
return PlatformID.MacOSX;
|
||||
}
|
||||
|
||||
case "GNU": return PlatformID.Hurd;
|
||||
case "FreeBSD":
|
||||
case "GNU/kFreeBSD": return PlatformID.FreeBSD;
|
||||
case "DragonFly": return PlatformID.DragonFly;
|
||||
case "Haiku": return PlatformID.Haiku;
|
||||
case "HP-UX": return PlatformID.HPUX;
|
||||
case "AIX": return PlatformID.AIX;
|
||||
case "OS400": return PlatformID.OS400;
|
||||
case "IRIX":
|
||||
case "IRIX64": return PlatformID.IRIX;
|
||||
case "Minix": return PlatformID.Minix;
|
||||
case "NetBSD": return PlatformID.NetBSD;
|
||||
case "NONSTOP_KERNEL": return PlatformID.NonStop;
|
||||
case "OpenBSD": return PlatformID.OpenBSD;
|
||||
case "QNX": return PlatformID.QNX;
|
||||
case "SINIX-Y": return PlatformID.SINIX;
|
||||
case "SunOS": return PlatformID.Solaris;
|
||||
case "OSF1": return PlatformID.Tru64;
|
||||
case "ULTRIX": return PlatformID.Ultrix;
|
||||
case "SCO_SV": return PlatformID.OpenServer;
|
||||
case "UnixWare": return PlatformID.UnixWare;
|
||||
case "Interix":
|
||||
case "UWIN-W7": return PlatformID.Win32NT;
|
||||
case"GNU": return PlatformID.Hurd;
|
||||
case"FreeBSD":
|
||||
case"GNU/kFreeBSD": return PlatformID.FreeBSD;
|
||||
case"DragonFly": return PlatformID.DragonFly;
|
||||
case"Haiku": return PlatformID.Haiku;
|
||||
case"HP-UX": return PlatformID.HPUX;
|
||||
case"AIX": return PlatformID.AIX;
|
||||
case"OS400": return PlatformID.OS400;
|
||||
case"IRIX":
|
||||
case"IRIX64": return PlatformID.IRIX;
|
||||
case"Minix": return PlatformID.Minix;
|
||||
case"NetBSD": return PlatformID.NetBSD;
|
||||
case"NONSTOP_KERNEL": return PlatformID.NonStop;
|
||||
case"OpenBSD": return PlatformID.OpenBSD;
|
||||
case"QNX": return PlatformID.QNX;
|
||||
case"SINIX-Y": return PlatformID.SINIX;
|
||||
case"SunOS": return PlatformID.Solaris;
|
||||
case"OSF1": return PlatformID.Tru64;
|
||||
case"ULTRIX": return PlatformID.Ultrix;
|
||||
case"SCO_SV": return PlatformID.OpenServer;
|
||||
case"UnixWare": return PlatformID.UnixWare;
|
||||
case"Interix":
|
||||
case"UWIN-W7": return PlatformID.Win32NT;
|
||||
default:
|
||||
{
|
||||
if(unixname.sysname.StartsWith("CYGWIN_NT", StringComparison.Ordinal) ||
|
||||
if(unixname.sysname.StartsWith("CYGWIN_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("MINGW32_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("MSYS_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("UWIN", StringComparison.Ordinal)) return PlatformID.Win32NT;
|
||||
unixname.sysname.StartsWith("MSYS_NT", StringComparison.Ordinal) ||
|
||||
unixname.sysname.StartsWith("UWIN", StringComparison.Ordinal))
|
||||
return PlatformID.Win32NT;
|
||||
|
||||
return PlatformID.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)
|
||||
/// </summary>
|
||||
/// <summary>Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)</summary>
|
||||
/// <returns>Current operating system version</returns>
|
||||
public static string GetVersion()
|
||||
{
|
||||
@@ -205,12 +217,12 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
{
|
||||
case PlatformID.MacOSX:
|
||||
if(Environment.OSVersion.Version.Major != 1)
|
||||
return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}";
|
||||
return$"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}";
|
||||
|
||||
switch(Environment.OSVersion.Version.Minor)
|
||||
{
|
||||
case 3: return "10.0";
|
||||
case 4: return "10.1";
|
||||
case 3: return"10.0";
|
||||
case 4: return"10.1";
|
||||
}
|
||||
|
||||
goto default;
|
||||
@@ -218,8 +230,8 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
// From Windows 8.1 the reported version is simply falsified...
|
||||
if(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Major >= 2 ||
|
||||
Environment.OSVersion.Version.Major > 6)
|
||||
return FileVersionInfo
|
||||
.GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
|
||||
return FileVersionInfo.
|
||||
GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
|
||||
"KERNEL32.DLL")).ProductVersion;
|
||||
|
||||
return environ;
|
||||
@@ -227,9 +239,7 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From a platform ID and version returns a human-readable version
|
||||
/// </summary>
|
||||
/// <summary>From a platform ID and version returns a human-readable version</summary>
|
||||
/// <param name="id">Platform ID</param>
|
||||
/// <param name="version">Version number</param>
|
||||
/// <returns>Operating system name</returns>
|
||||
@@ -237,111 +247,135 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
case PlatformID.AIX: return "AIX";
|
||||
case PlatformID.Android: return "Android";
|
||||
case PlatformID.DragonFly: return "DragonFly BSD";
|
||||
case PlatformID.FreeBSD: return "FreeBSD";
|
||||
case PlatformID.Haiku: return "Haiku";
|
||||
case PlatformID.HPUX: return "HP/UX";
|
||||
case PlatformID.Hurd: return "Hurd";
|
||||
case PlatformID.iOS: return "iOS";
|
||||
case PlatformID.IRIX: return "IRIX";
|
||||
case PlatformID.AIX: return"AIX";
|
||||
case PlatformID.Android: return"Android";
|
||||
case PlatformID.DragonFly: return"DragonFly BSD";
|
||||
case PlatformID.FreeBSD: return"FreeBSD";
|
||||
case PlatformID.Haiku: return"Haiku";
|
||||
case PlatformID.HPUX: return"HP/UX";
|
||||
case PlatformID.Hurd: return"Hurd";
|
||||
case PlatformID.iOS: return"iOS";
|
||||
case PlatformID.IRIX: return"IRIX";
|
||||
case PlatformID.Linux:
|
||||
if(!File.Exists("/proc/version")) return "Linux";
|
||||
if(!File.Exists("/proc/version"))
|
||||
return"Linux";
|
||||
|
||||
string s = File.ReadAllText("/proc/version");
|
||||
|
||||
return s.Contains("Microsoft") || s.Contains("WSL") ? "Windows Subsystem for Linux" : "Linux";
|
||||
|
||||
case PlatformID.MacOSX:
|
||||
if(string.IsNullOrEmpty(version)) return "macOS";
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return"macOS";
|
||||
|
||||
string[] pieces = version.Split('.');
|
||||
if(pieces.Length < 2 || !int.TryParse(pieces[1], out int minor)) return "macOS";
|
||||
|
||||
if(minor >= 12) return "macOS";
|
||||
if(minor >= 8) return "OS X";
|
||||
if(pieces.Length < 2 ||
|
||||
!int.TryParse(pieces[1], out int minor))
|
||||
return"macOS";
|
||||
|
||||
return "Mac OS X";
|
||||
if(minor >= 12)
|
||||
return"macOS";
|
||||
|
||||
case PlatformID.Minix: return "MINIX";
|
||||
case PlatformID.NetBSD: return "NetBSD";
|
||||
case PlatformID.NonStop: return "NonStop OS";
|
||||
case PlatformID.OpenBSD: return "OpenBSD";
|
||||
case PlatformID.OpenServer: return "SCO OpenServer";
|
||||
case PlatformID.OS400: return "OS/400";
|
||||
case PlatformID.PlayStation3: return "Sony CellOS";
|
||||
case PlatformID.PlayStation4: return "Sony Orbis OS";
|
||||
case PlatformID.QNX: return "QNX";
|
||||
case PlatformID.SINIX: return "SINIX";
|
||||
case PlatformID.Solaris: return "Sun Solaris";
|
||||
case PlatformID.Tizen: return "Samsung Tizen";
|
||||
case PlatformID.Tru64: return "Tru64 UNIX";
|
||||
case PlatformID.Ultrix: return "Ultrix";
|
||||
case PlatformID.Unix: return "UNIX";
|
||||
case PlatformID.UnixWare: return "SCO UnixWare";
|
||||
case PlatformID.Wii: return "Nintendo Wii";
|
||||
case PlatformID.WiiU: return "Nintendo Wii U";
|
||||
if(minor >= 8)
|
||||
return"OS X";
|
||||
|
||||
return"Mac OS X";
|
||||
|
||||
case PlatformID.Minix: return"MINIX";
|
||||
case PlatformID.NetBSD: return"NetBSD";
|
||||
case PlatformID.NonStop: return"NonStop OS";
|
||||
case PlatformID.OpenBSD: return"OpenBSD";
|
||||
case PlatformID.OpenServer: return"SCO OpenServer";
|
||||
case PlatformID.OS400: return"OS/400";
|
||||
case PlatformID.PlayStation3: return"Sony CellOS";
|
||||
case PlatformID.PlayStation4: return"Sony Orbis OS";
|
||||
case PlatformID.QNX: return"QNX";
|
||||
case PlatformID.SINIX: return"SINIX";
|
||||
case PlatformID.Solaris: return"Sun Solaris";
|
||||
case PlatformID.Tizen: return"Samsung Tizen";
|
||||
case PlatformID.Tru64: return"Tru64 UNIX";
|
||||
case PlatformID.Ultrix: return"Ultrix";
|
||||
case PlatformID.Unix: return"UNIX";
|
||||
case PlatformID.UnixWare: return"SCO UnixWare";
|
||||
case PlatformID.Wii: return"Nintendo Wii";
|
||||
case PlatformID.WiiU: return"Nintendo Wii U";
|
||||
case PlatformID.Win32NT:
|
||||
if(string.IsNullOrEmpty(version)) return "Windows NT/2000/XP/Vista/7/10";
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return"Windows NT/2000/XP/Vista/7/10";
|
||||
|
||||
if(version.StartsWith("3.", StringComparison.Ordinal) ||
|
||||
version.StartsWith("4.", StringComparison.Ordinal)) return "Windows NT";
|
||||
if(version.StartsWith("5.0", StringComparison.Ordinal)) return "Windows 2000";
|
||||
if(version.StartsWith("5.1", StringComparison.Ordinal)) return "Windows XP";
|
||||
if(version.StartsWith("5.2", StringComparison.Ordinal)) return "Windows 2003";
|
||||
if(version.StartsWith("6.0", StringComparison.Ordinal)) return "Windows Vista";
|
||||
if(version.StartsWith("6.1", StringComparison.Ordinal)) return "Windows 7";
|
||||
if(version.StartsWith("6.2", StringComparison.Ordinal)) return "Windows 8";
|
||||
if(version.StartsWith("6.3", StringComparison.Ordinal)) return "Windows 8.1";
|
||||
if(version.StartsWith("10.0", StringComparison.Ordinal)) return "Windows 10";
|
||||
version.StartsWith("4.", StringComparison.Ordinal))
|
||||
return"Windows NT";
|
||||
|
||||
return "Windows NT/2000/XP/Vista/7/10";
|
||||
case PlatformID.Win32S: return "Windows 3.x with win32s";
|
||||
if(version.StartsWith("5.0", StringComparison.Ordinal))
|
||||
return"Windows 2000";
|
||||
|
||||
if(version.StartsWith("5.1", StringComparison.Ordinal))
|
||||
return"Windows XP";
|
||||
|
||||
if(version.StartsWith("5.2", StringComparison.Ordinal))
|
||||
return"Windows 2003";
|
||||
|
||||
if(version.StartsWith("6.0", StringComparison.Ordinal))
|
||||
return"Windows Vista";
|
||||
|
||||
if(version.StartsWith("6.1", StringComparison.Ordinal))
|
||||
return"Windows 7";
|
||||
|
||||
if(version.StartsWith("6.2", StringComparison.Ordinal))
|
||||
return"Windows 8";
|
||||
|
||||
if(version.StartsWith("6.3", StringComparison.Ordinal))
|
||||
return"Windows 8.1";
|
||||
|
||||
if(version.StartsWith("10.0", StringComparison.Ordinal))
|
||||
return"Windows 10";
|
||||
|
||||
return"Windows NT/2000/XP/Vista/7/10";
|
||||
case PlatformID.Win32S: return"Windows 3.x with win32s";
|
||||
case PlatformID.Win32Windows:
|
||||
if(string.IsNullOrEmpty(version)) return "Windows 9x/Me";
|
||||
if(version.StartsWith("4.0", StringComparison.Ordinal)) return "Windows 95";
|
||||
if(version.StartsWith("4.10.2222", StringComparison.Ordinal)) return "Windows 98 SE";
|
||||
if(version.StartsWith("4.1", StringComparison.Ordinal)) return "Windows 98";
|
||||
if(version.StartsWith("4.9", StringComparison.Ordinal)) return "Windows Me";
|
||||
if(string.IsNullOrEmpty(version))
|
||||
return"Windows 9x/Me";
|
||||
|
||||
return "Windows 9x/Me";
|
||||
case PlatformID.WinCE: return "Windows CE/Mobile";
|
||||
case PlatformID.WindowsPhone: return "Windows Phone";
|
||||
case PlatformID.Xbox: return "Xbox OS";
|
||||
case PlatformID.zOS: return "z/OS";
|
||||
if(version.StartsWith("4.0", StringComparison.Ordinal))
|
||||
return"Windows 95";
|
||||
|
||||
if(version.StartsWith("4.10.2222", StringComparison.Ordinal))
|
||||
return"Windows 98 SE";
|
||||
|
||||
if(version.StartsWith("4.1", StringComparison.Ordinal))
|
||||
return"Windows 98";
|
||||
|
||||
if(version.StartsWith("4.9", StringComparison.Ordinal))
|
||||
return"Windows Me";
|
||||
|
||||
return"Windows 9x/Me";
|
||||
case PlatformID.WinCE: return"Windows CE/Mobile";
|
||||
case PlatformID.WindowsPhone: return"Windows Phone";
|
||||
case PlatformID.Xbox: return"Xbox OS";
|
||||
case PlatformID.zOS: return"z/OS";
|
||||
default: return id.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// POSIX uname structure, size from OSX, big enough to handle extra fields
|
||||
/// </summary>
|
||||
/// <summary>POSIX uname structure, size from OSX, big enough to handle extra fields</summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct utsname
|
||||
{
|
||||
/// <summary>
|
||||
/// System name
|
||||
/// </summary>
|
||||
/// <summary>System name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string sysname;
|
||||
/// <summary>
|
||||
/// Node name
|
||||
/// </summary>
|
||||
/// <summary>Node name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string nodename;
|
||||
/// <summary>
|
||||
/// Release level
|
||||
/// </summary>
|
||||
/// <summary>Release level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string release;
|
||||
/// <summary>
|
||||
/// Version level
|
||||
/// </summary>
|
||||
/// <summary>Version level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string version;
|
||||
/// <summary>
|
||||
/// Hardware level
|
||||
/// </summary>
|
||||
/// <summary>Hardware level</summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public readonly string machine;
|
||||
}
|
||||
|
||||
@@ -38,155 +38,45 @@
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains an arbitrary list of OSes, even if .NET does not run on them
|
||||
/// </summary>
|
||||
/// <summary>Contains an arbitrary list of OSes, even if .NET does not run on them</summary>
|
||||
public enum PlatformID
|
||||
{
|
||||
/// <summary>
|
||||
/// Win32s
|
||||
/// </summary>
|
||||
Win32S = 0,
|
||||
/// <summary>
|
||||
/// Win32 (Windows 9x)
|
||||
/// </summary>
|
||||
Win32Windows = 1,
|
||||
/// <summary>
|
||||
/// Windows NT
|
||||
/// </summary>
|
||||
Win32NT = 2,
|
||||
/// <summary>
|
||||
/// Windows Mobile
|
||||
/// </summary>
|
||||
WinCE = 3,
|
||||
/// <summary>
|
||||
/// UNIX (do not use, too generic)
|
||||
/// </summary>
|
||||
Unix = 4,
|
||||
/// <summary>
|
||||
/// Xbox 360
|
||||
/// </summary>
|
||||
Xbox = 5,
|
||||
/// <summary>
|
||||
/// OS X
|
||||
/// </summary>
|
||||
MacOSX = 6,
|
||||
/// <summary>
|
||||
/// iOS is not OS X
|
||||
/// </summary>
|
||||
iOS = 7,
|
||||
/// <summary>
|
||||
/// Linux
|
||||
/// </summary>
|
||||
Linux = 8,
|
||||
/// <summary>
|
||||
/// Sun Solaris
|
||||
/// </summary>
|
||||
Solaris = 9,
|
||||
/// <summary>
|
||||
/// NetBSD
|
||||
/// </summary>
|
||||
NetBSD = 10,
|
||||
/// <summary>
|
||||
/// OpenBSD
|
||||
/// </summary>
|
||||
OpenBSD = 11,
|
||||
/// <summary>
|
||||
/// FreeBSD
|
||||
/// </summary>
|
||||
FreeBSD = 12,
|
||||
/// <summary>
|
||||
/// DragonFly BSD
|
||||
/// </summary>
|
||||
DragonFly = 13,
|
||||
/// <summary>
|
||||
/// Nintendo Wii
|
||||
/// </summary>
|
||||
Wii = 14,
|
||||
/// <summary>
|
||||
/// Nintendo Wii U
|
||||
/// </summary>
|
||||
WiiU = 15,
|
||||
/// <summary>
|
||||
/// Sony PlayStation 3
|
||||
/// </summary>
|
||||
PlayStation3 = 16,
|
||||
/// <summary>
|
||||
/// Sony Playstation 4
|
||||
/// </summary>
|
||||
PlayStation4 = 17,
|
||||
/// <summary>
|
||||
/// Google Android
|
||||
/// </summary>
|
||||
Android = 18,
|
||||
/// <summary>
|
||||
/// Samsung Tizen
|
||||
/// </summary>
|
||||
Tizen = 19,
|
||||
/// <summary>
|
||||
/// Windows Phone
|
||||
/// </summary>
|
||||
WindowsPhone = 20,
|
||||
/// <summary>
|
||||
/// GNU/Hurd
|
||||
/// </summary>
|
||||
Hurd = 21,
|
||||
/// <summary>
|
||||
/// Haiku
|
||||
/// </summary>
|
||||
Haiku = 22,
|
||||
/// <summary>
|
||||
/// HP-UX
|
||||
/// </summary>
|
||||
HPUX = 23,
|
||||
/// <summary>
|
||||
/// AIX
|
||||
/// </summary>
|
||||
AIX = 24,
|
||||
/// <summary>
|
||||
/// OS/400
|
||||
/// </summary>
|
||||
OS400 = 25,
|
||||
/// <summary>
|
||||
/// IRIX
|
||||
/// </summary>
|
||||
IRIX = 26,
|
||||
/// <summary>
|
||||
/// Minix
|
||||
/// </summary>
|
||||
Minix = 27,
|
||||
/// <summary>
|
||||
/// NonStop
|
||||
/// </summary>
|
||||
NonStop = 28,
|
||||
/// <summary>
|
||||
/// QNX
|
||||
/// </summary>
|
||||
QNX = 29,
|
||||
/// <summary>
|
||||
/// SINIX
|
||||
/// </summary>
|
||||
SINIX = 30,
|
||||
/// <summary>
|
||||
/// Tru64 UNIX
|
||||
/// </summary>
|
||||
Tru64 = 31,
|
||||
/// <summary>
|
||||
/// Ultrix
|
||||
/// </summary>
|
||||
Ultrix = 32,
|
||||
/// <summary>
|
||||
/// SCO OpenServer / SCO UNIX
|
||||
/// </summary>
|
||||
OpenServer = 33,
|
||||
/// <summary>
|
||||
/// SCO UnixWare
|
||||
/// </summary>
|
||||
UnixWare = 34,
|
||||
/// <summary>
|
||||
/// IBM z/OS
|
||||
/// </summary>
|
||||
zOS = 35,
|
||||
Unknown = -1
|
||||
/// <summary>Win32s</summary>
|
||||
Win32S = 0, /// <summary>Win32 (Windows 9x)</summary>
|
||||
Win32Windows = 1, /// <summary>Windows NT</summary>
|
||||
Win32NT = 2, /// <summary>Windows Mobile</summary>
|
||||
WinCE = 3, /// <summary>UNIX (do not use, too generic)</summary>
|
||||
Unix = 4, /// <summary>Xbox 360</summary>
|
||||
Xbox = 5, /// <summary>OS X</summary>
|
||||
MacOSX = 6, /// <summary>iOS is not OS X</summary>
|
||||
iOS = 7, /// <summary>Linux</summary>
|
||||
Linux = 8, /// <summary>Sun Solaris</summary>
|
||||
Solaris = 9, /// <summary>NetBSD</summary>
|
||||
NetBSD = 10, /// <summary>OpenBSD</summary>
|
||||
OpenBSD = 11, /// <summary>FreeBSD</summary>
|
||||
FreeBSD = 12, /// <summary>DragonFly BSD</summary>
|
||||
DragonFly = 13, /// <summary>Nintendo Wii</summary>
|
||||
Wii = 14, /// <summary>Nintendo Wii U</summary>
|
||||
WiiU = 15, /// <summary>Sony PlayStation 3</summary>
|
||||
PlayStation3 = 16, /// <summary>Sony Playstation 4</summary>
|
||||
PlayStation4 = 17, /// <summary>Google Android</summary>
|
||||
Android = 18, /// <summary>Samsung Tizen</summary>
|
||||
Tizen = 19, /// <summary>Windows Phone</summary>
|
||||
WindowsPhone = 20, /// <summary>GNU/Hurd</summary>
|
||||
Hurd = 21, /// <summary>Haiku</summary>
|
||||
Haiku = 22, /// <summary>HP-UX</summary>
|
||||
HPUX = 23, /// <summary>AIX</summary>
|
||||
AIX = 24, /// <summary>OS/400</summary>
|
||||
OS400 = 25, /// <summary>IRIX</summary>
|
||||
IRIX = 26, /// <summary>Minix</summary>
|
||||
Minix = 27, /// <summary>NonStop</summary>
|
||||
NonStop = 28, /// <summary>QNX</summary>
|
||||
QNX = 29, /// <summary>SINIX</summary>
|
||||
SINIX = 30, /// <summary>Tru64 UNIX</summary>
|
||||
Tru64 = 31, /// <summary>Ultrix</summary>
|
||||
Ultrix = 32, /// <summary>SCO OpenServer / SCO UNIX</summary>
|
||||
OpenServer = 33, /// <summary>SCO UnixWare</summary>
|
||||
UnixWare = 34, /// <summary>IBM z/OS</summary>
|
||||
zOS = 35, Unknown = -1
|
||||
}
|
||||
}
|
||||
@@ -44,19 +44,23 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
{
|
||||
public static class Version
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets version string
|
||||
/// </summary>
|
||||
/// <summary>Gets version string</summary>
|
||||
/// <returns>Version</returns>
|
||||
public static string GetVersion() => typeof(Version).Assembly.GetName().Version.ToString();
|
||||
|
||||
public static string GetNetCoreVersion()
|
||||
{
|
||||
Assembly assembly = typeof(GCSettings).Assembly;
|
||||
string[] assemblyPath =
|
||||
assembly.CodeBase.Split(new[] {'/', '\\'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string[] assemblyPath = assembly.CodeBase.Split(new[]
|
||||
{
|
||||
'/', '\\'
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
|
||||
if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
|
||||
|
||||
if(netCoreAppIndex > 0 &&
|
||||
netCoreAppIndex < assemblyPath.Length - 2)
|
||||
return assemblyPath[netCoreAppIndex + 1];
|
||||
|
||||
return null;
|
||||
@@ -64,11 +68,14 @@ namespace DiscImageChef.CommonTypes.Interop
|
||||
|
||||
public static string GetMonoVersion()
|
||||
{
|
||||
if(!DetectOS.IsMono) return null;
|
||||
if(!DetectOS.IsMono)
|
||||
return null;
|
||||
|
||||
MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")
|
||||
?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if(monoDisplayName != null) return (string)monoDisplayName.Invoke(null, null);
|
||||
MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")?.
|
||||
GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
if(monoDisplayName != null)
|
||||
return(string)monoDisplayName.Invoke(null, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
919
MediaType.cs
919
MediaType.cs
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -48,8 +48,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Metadata
|
||||
{
|
||||
[Serializable]
|
||||
[XmlRoot("DicDeviceReport", Namespace = "", IsNullable = false)]
|
||||
[Serializable, XmlRoot("DicDeviceReport", Namespace = "", IsNullable = false)]
|
||||
public class DeviceReport
|
||||
{
|
||||
public usbType USB { get; set; }
|
||||
@@ -981,8 +980,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
|
||||
public class SupportedDensity
|
||||
{
|
||||
[XmlIgnore]
|
||||
[JsonIgnore]
|
||||
[XmlIgnore, JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
public byte PrimaryCode { get; set; }
|
||||
public byte SecondaryCode { get; set; }
|
||||
@@ -1000,8 +998,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
|
||||
public class SupportedMedia
|
||||
{
|
||||
[XmlIgnore]
|
||||
[JsonIgnore]
|
||||
[XmlIgnore, JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
public byte MediumType { get; set; }
|
||||
public int[] DensityCodes { get; set; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,7 +44,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
{
|
||||
public static DimensionsType DimensionsFromMediaType(CommonTypes.MediaType dskType)
|
||||
{
|
||||
DimensionsType dmns = new DimensionsType();
|
||||
var dmns = new DimensionsType();
|
||||
|
||||
switch(dskType)
|
||||
{
|
||||
@@ -87,6 +87,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 133.3;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.65;
|
||||
|
||||
return dmns;
|
||||
#endregion 5.25" floppy disk
|
||||
|
||||
@@ -121,6 +122,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 90;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.3;
|
||||
|
||||
return dmns;
|
||||
#endregion 3.5" floppy disk
|
||||
|
||||
@@ -149,6 +151,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 203.2;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.65;
|
||||
|
||||
return dmns;
|
||||
#endregion 8" floppy disk
|
||||
|
||||
@@ -161,6 +164,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 443.76;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 25.4;
|
||||
|
||||
return dmns;
|
||||
#endregion 356mm magneto optical
|
||||
|
||||
@@ -174,6 +178,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 320;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 17;
|
||||
|
||||
return dmns;
|
||||
#endregion 300mm magneto optical
|
||||
|
||||
@@ -199,6 +204,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 135;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 11;
|
||||
|
||||
return dmns;
|
||||
#endregion 5.25" magneto optical
|
||||
|
||||
@@ -216,6 +222,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 90;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 6;
|
||||
|
||||
return dmns;
|
||||
#endregion 3.5" magneto optical
|
||||
|
||||
@@ -226,6 +233,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 124;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 7.8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ECMA_239:
|
||||
dmns.Height = 97;
|
||||
@@ -233,6 +241,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 92;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MMCmicro:
|
||||
dmns.Height = 14;
|
||||
@@ -240,6 +249,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 12;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.1;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MemoryStickMicro:
|
||||
dmns.Height = 15;
|
||||
@@ -247,6 +257,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 12.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.2;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.microSD:
|
||||
dmns.Height = 11;
|
||||
@@ -254,6 +265,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 15;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.miniSD:
|
||||
dmns.Height = 21.5;
|
||||
@@ -261,6 +273,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 20;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.QIC3010:
|
||||
case CommonTypes.MediaType.QIC3020:
|
||||
@@ -274,6 +287,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 21.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.6;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.RSMMC:
|
||||
dmns.Height = 18;
|
||||
@@ -281,6 +295,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 24;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MMC:
|
||||
dmns.Height = 32;
|
||||
@@ -288,6 +303,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 24;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.SecureDigital:
|
||||
dmns.Height = 32;
|
||||
@@ -295,6 +311,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 24;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 2.1;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.xD:
|
||||
dmns.Height = 20;
|
||||
@@ -302,6 +319,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 25;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.78;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.XQD:
|
||||
dmns.Height = 38.5;
|
||||
@@ -309,6 +327,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 29.8;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MemoryStickDuo:
|
||||
case CommonTypes.MediaType.MemoryStickProDuo:
|
||||
@@ -317,6 +336,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 31;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 1.6;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Nintendo3DSGameCard:
|
||||
case CommonTypes.MediaType.NintendoDSGameCard:
|
||||
@@ -326,6 +346,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 33;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DataPlay:
|
||||
dmns.Height = 42;
|
||||
@@ -333,6 +354,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 33.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Microdrive:
|
||||
dmns.Height = 44;
|
||||
@@ -340,6 +362,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 34;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ExpressCard34:
|
||||
dmns.Height = 75;
|
||||
@@ -347,6 +370,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 34;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.SmartMedia:
|
||||
dmns.Height = 45;
|
||||
@@ -354,6 +378,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 37;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 0.76;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MiniCard:
|
||||
dmns.Height = 45;
|
||||
@@ -361,6 +386,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 37;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PlayStationMemoryCard:
|
||||
case CommonTypes.MediaType.PlayStationMemoryCard2:
|
||||
@@ -369,6 +395,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 41.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 7;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.CFast:
|
||||
case CommonTypes.MediaType.CompactFlash:
|
||||
@@ -377,6 +404,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 43;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.3;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.CompactFlashType2:
|
||||
dmns.Height = 36;
|
||||
@@ -384,6 +412,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 43;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ZXMicrodrive:
|
||||
dmns.Height = 36;
|
||||
@@ -391,6 +420,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 43;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MemoryStick:
|
||||
case CommonTypes.MediaType.MemoryStickPro:
|
||||
@@ -399,6 +429,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 50;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 2.6;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PocketZip:
|
||||
dmns.Height = 54.5;
|
||||
@@ -406,6 +437,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 50;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 2;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ExpressCard54:
|
||||
dmns.Height = 75;
|
||||
@@ -413,6 +445,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PCCardTypeI:
|
||||
dmns.Height = 85.6;
|
||||
@@ -420,6 +453,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.3;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PCCardTypeII:
|
||||
dmns.Height = 85.6;
|
||||
@@ -427,6 +461,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PCCardTypeIII:
|
||||
dmns.Height = 85.6;
|
||||
@@ -434,6 +469,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 10.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.PCCardTypeIV:
|
||||
dmns.Height = 85.6;
|
||||
@@ -441,6 +477,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 16;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DataStore:
|
||||
dmns.Height = 86.5;
|
||||
@@ -448,6 +485,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 54;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 2.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.VideoFloppy:
|
||||
dmns.Height = 54;
|
||||
@@ -455,6 +493,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 60;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.VXA1:
|
||||
case CommonTypes.MediaType.VXA2:
|
||||
@@ -464,6 +503,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 62.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MiniDV:
|
||||
dmns.Height = 47.5;
|
||||
@@ -471,6 +511,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 66;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 12;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Wafer:
|
||||
dmns.Height = 46.8;
|
||||
@@ -478,6 +519,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 67.1;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 7.9;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.NintendoDiskCard:
|
||||
dmns.Height = 76.2;
|
||||
@@ -485,6 +527,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 71.12;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 0;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.HiMD:
|
||||
case CommonTypes.MediaType.MD:
|
||||
@@ -495,6 +538,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 71.5;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 4.8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DAT160:
|
||||
case CommonTypes.MediaType.DAT320:
|
||||
@@ -509,6 +553,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 73;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 10.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.CompactFloppy:
|
||||
dmns.Height = 100;
|
||||
@@ -516,6 +561,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 80;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DECtapeII:
|
||||
dmns.Height = 60;
|
||||
@@ -523,6 +569,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 81;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 13;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Ditto:
|
||||
dmns.Height = 60;
|
||||
@@ -530,6 +577,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 81;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 14;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DittoMax:
|
||||
dmns.Height = 126;
|
||||
@@ -537,6 +585,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 81;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 14;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.RDX:
|
||||
case CommonTypes.MediaType.RDX320:
|
||||
@@ -545,6 +594,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 87;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 23;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.LS120:
|
||||
case CommonTypes.MediaType.LS240:
|
||||
@@ -553,6 +603,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 90;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 3.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Travan:
|
||||
case CommonTypes.MediaType.Travan3:
|
||||
@@ -564,6 +615,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 92;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Travan1Ex:
|
||||
dmns.Height = 0;
|
||||
@@ -571,6 +623,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 92;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Travan3Ex:
|
||||
dmns.Height = 0;
|
||||
@@ -578,6 +631,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 92;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ADR2120:
|
||||
case CommonTypes.MediaType.ADR260:
|
||||
@@ -588,6 +642,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 93;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 14.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Data8:
|
||||
case CommonTypes.MediaType.AIT1:
|
||||
@@ -622,6 +677,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 95;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.EZ135:
|
||||
case CommonTypes.MediaType.EZ230:
|
||||
@@ -630,6 +686,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 98;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 9.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.ZIP100:
|
||||
case CommonTypes.MediaType.ZIP250:
|
||||
@@ -639,6 +696,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 98;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 6.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Jaz:
|
||||
case CommonTypes.MediaType.Jaz2:
|
||||
@@ -647,6 +705,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 98;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 12;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Orb:
|
||||
case CommonTypes.MediaType.Orb5:
|
||||
@@ -655,6 +714,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 98;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 8;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.SparQ:
|
||||
dmns.Height = 98;
|
||||
@@ -662,6 +722,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 100;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 9.7;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.SLR1:
|
||||
case CommonTypes.MediaType.SLR2:
|
||||
@@ -687,6 +748,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 100;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 18;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.N64DD:
|
||||
dmns.Height = 103.124;
|
||||
@@ -694,6 +756,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 101.092;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 10.16;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.CompactTapeI:
|
||||
case CommonTypes.MediaType.CompactTapeII:
|
||||
@@ -709,6 +772,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 105;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 25;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.LTO:
|
||||
case CommonTypes.MediaType.LTO2:
|
||||
@@ -727,6 +791,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 105.41;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 21.59;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.IBM3480:
|
||||
case CommonTypes.MediaType.IBM3490:
|
||||
@@ -737,6 +802,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 107.95;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 25.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.T9840A:
|
||||
case CommonTypes.MediaType.T9840B:
|
||||
@@ -749,6 +815,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 109.22;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 25.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.CompactCassette:
|
||||
case CommonTypes.MediaType.Dcas25:
|
||||
@@ -759,6 +826,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 128;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 12;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.IBM3470:
|
||||
dmns.Height = 58.42;
|
||||
@@ -766,6 +834,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 137.16;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 16.51;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Bernoulli2:
|
||||
dmns.Height = 136;
|
||||
@@ -773,6 +842,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 140;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 9;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.MLR1:
|
||||
case CommonTypes.MediaType.MLR3:
|
||||
@@ -782,6 +852,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 152.4;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 15.24;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.QIC11:
|
||||
case CommonTypes.MediaType.QIC120:
|
||||
@@ -794,6 +865,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 154.2;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 16.6;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.Bernoulli:
|
||||
dmns.Height = 275;
|
||||
@@ -801,6 +873,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 210;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 0;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.DTF:
|
||||
case CommonTypes.MediaType.DTF2:
|
||||
@@ -809,6 +882,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 254;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 25.4;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.LD:
|
||||
case CommonTypes.MediaType.LDROM:
|
||||
@@ -818,6 +892,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Diameter = 300;
|
||||
dmns.DiameterSpecified = true;
|
||||
dmns.Thickness = 2.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.REV35:
|
||||
case CommonTypes.MediaType.REV70:
|
||||
@@ -827,6 +902,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 76.8;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 10;
|
||||
|
||||
return dmns;
|
||||
|
||||
#region CD/DVD/BD
|
||||
@@ -905,22 +981,26 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Diameter = 120;
|
||||
dmns.DiameterSpecified = true;
|
||||
dmns.Thickness = 1.2;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.GOD:
|
||||
dmns.Diameter = 80;
|
||||
dmns.DiameterSpecified = true;
|
||||
dmns.Thickness = 1.2;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.VideoNow:
|
||||
dmns.Diameter = 85;
|
||||
dmns.DiameterSpecified = true;
|
||||
dmns.Thickness = 1.2;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.VideoNowColor:
|
||||
case CommonTypes.MediaType.VideoNowXp:
|
||||
dmns.Diameter = 108;
|
||||
dmns.DiameterSpecified = true;
|
||||
dmns.Thickness = 1.2;
|
||||
|
||||
return dmns;
|
||||
#endregion CD/DVD/BD
|
||||
|
||||
@@ -932,6 +1012,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 438.9;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 111.5;
|
||||
|
||||
return dmns;
|
||||
case CommonTypes.MediaType.AppleHD20:
|
||||
dmns.Height = 246.4;
|
||||
@@ -939,6 +1020,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 266.7;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 78.7;
|
||||
|
||||
return dmns;
|
||||
#endregion Apple Hard Disks
|
||||
|
||||
@@ -948,6 +1030,7 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
dmns.Width = 63;
|
||||
dmns.WidthSpecified = true;
|
||||
dmns.Thickness = 4;
|
||||
|
||||
return dmns;
|
||||
default: return null;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,8 +43,7 @@ using Schemas;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Metadata
|
||||
{
|
||||
[Serializable]
|
||||
[XmlRoot("DicResume", Namespace = "", IsNullable = false)]
|
||||
[Serializable, XmlRoot("DicResume", Namespace = "", IsNullable = false)]
|
||||
public class Resume
|
||||
{
|
||||
[XmlElement(DataType = "dateTime")]
|
||||
|
||||
@@ -43,16 +43,12 @@ namespace DiscImageChef.CommonTypes.Metadata
|
||||
{
|
||||
public static class Version
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets XML software type for the running version
|
||||
/// </summary>
|
||||
/// <summary>Gets XML software type for the running version</summary>
|
||||
/// <returns>XML software type</returns>
|
||||
public static SoftwareType GetSoftwareType() =>
|
||||
new SoftwareType
|
||||
{
|
||||
Name = "DiscImageChef",
|
||||
OperatingSystem = DetectOS.GetRealPlatformID().ToString(),
|
||||
Version = typeof(Version).Assembly.GetName().Version.ToString()
|
||||
};
|
||||
public static SoftwareType GetSoftwareType() => new SoftwareType
|
||||
{
|
||||
Name = "DiscImageChef", OperatingSystem = DetectOS.GetRealPlatformID().ToString(),
|
||||
Version = typeof(Version).Assembly.GetName().Version.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
22
Partition.cs
22
Partition.cs
@@ -40,9 +40,7 @@ using System;
|
||||
|
||||
namespace DiscImageChef.CommonTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Partition structure.
|
||||
/// </summary>
|
||||
/// <summary>Partition structure.</summary>
|
||||
public struct Partition : IEquatable<Partition>, IComparable<Partition>
|
||||
{
|
||||
/// <summary>Partition number, 0-started</summary>
|
||||
@@ -66,9 +64,7 @@ namespace DiscImageChef.CommonTypes
|
||||
/// <summary>Name of partition scheme that contains this partition</summary>
|
||||
public string Scheme;
|
||||
|
||||
/// <summary>
|
||||
/// Compares two partitions
|
||||
/// </summary>
|
||||
/// <summary>Compares two partitions</summary>
|
||||
/// <param name="other">Partition to compare with</param>
|
||||
/// <returns>0 if both partitions start and end at the same sector</returns>
|
||||
public bool Equals(Partition other) => Start == other.Start && Length == other.Length;
|
||||
@@ -78,18 +74,22 @@ namespace DiscImageChef.CommonTypes
|
||||
public override int GetHashCode() => Start.GetHashCode() + End.GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// Compares this partition with another and returns an integer that indicates whether the current partition precedes,
|
||||
/// follows, or is in the same place as the other partition.
|
||||
/// Compares this partition with another and returns an integer that indicates whether the current partition
|
||||
/// precedes, follows, or is in the same place as the other partition.
|
||||
/// </summary>
|
||||
/// <param name="other">Partition to compare with</param>
|
||||
/// <returns>A value that indicates the relative equality of the partitions being compared.</returns>
|
||||
public int CompareTo(Partition other)
|
||||
{
|
||||
if(Start == other.Start && End == other.End) return 0;
|
||||
if(Start == other.Start &&
|
||||
End == other.End)
|
||||
return 0;
|
||||
|
||||
if(Start > other.Start || End > other.End) return 1;
|
||||
if(Start > other.Start ||
|
||||
End > other.End)
|
||||
return 1;
|
||||
|
||||
return -1;
|
||||
return-1;
|
||||
}
|
||||
|
||||
// Define the equality operator.
|
||||
|
||||
@@ -44,51 +44,29 @@ using DiscImageChef.Partitions;
|
||||
|
||||
namespace DiscImageChef.CommonTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Contain all plugins (filesystem, partition and image)
|
||||
/// </summary>
|
||||
/// <summary>Contain all plugins (filesystem, partition and image)</summary>
|
||||
public class PluginBase
|
||||
{
|
||||
/// <summary>
|
||||
/// List of checksum plugins
|
||||
/// </summary>
|
||||
/// <summary>List of checksum plugins</summary>
|
||||
public readonly List<IChecksum> Checksums;
|
||||
/// <summary>
|
||||
/// List of filter plugins
|
||||
/// </summary>
|
||||
/// <summary>List of filter plugins</summary>
|
||||
public readonly SortedDictionary<string, IFilter> Filters;
|
||||
/// <summary>
|
||||
/// List of floppy image plugins
|
||||
/// </summary>
|
||||
/// <summary>List of floppy image plugins</summary>
|
||||
public readonly SortedDictionary<string, IFloppyImage> FloppyImages;
|
||||
/// <summary>
|
||||
/// List of all media image plugins
|
||||
/// </summary>
|
||||
/// <summary>List of all media image plugins</summary>
|
||||
public readonly SortedDictionary<string, IMediaImage> ImagePluginsList;
|
||||
/// <summary>
|
||||
/// List of all partition plugins
|
||||
/// </summary>
|
||||
/// <summary>List of all partition plugins</summary>
|
||||
public readonly SortedDictionary<string, IPartition> PartPluginsList;
|
||||
/// <summary>
|
||||
/// List of all filesystem plugins
|
||||
/// </summary>
|
||||
/// <summary>List of all filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, IFilesystem> PluginsList;
|
||||
/// <summary>
|
||||
/// List of read-only filesystem plugins
|
||||
/// </summary>
|
||||
/// <summary>List of read-only filesystem plugins</summary>
|
||||
public readonly SortedDictionary<string, IReadOnlyFilesystem> ReadOnlyFilesystems;
|
||||
/// <summary>
|
||||
/// List of writable floppy image plugins
|
||||
/// </summary>
|
||||
/// <summary>List of writable floppy image plugins</summary>
|
||||
public readonly SortedDictionary<string, IWritableFloppyImage> WritableFloppyImages;
|
||||
/// <summary>
|
||||
/// List of writable media image plugins
|
||||
/// </summary>
|
||||
/// <summary>List of writable media image plugins</summary>
|
||||
public readonly SortedDictionary<string, IWritableImage> WritableImages;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the plugins lists
|
||||
/// </summary>
|
||||
/// <summary>Initializes the plugins lists</summary>
|
||||
public PluginBase()
|
||||
{
|
||||
PluginsList = new SortedDictionary<string, IFilesystem>();
|
||||
@@ -105,46 +83,55 @@ namespace DiscImageChef.CommonTypes
|
||||
public void AddPlugins(IPluginRegister pluginRegister)
|
||||
{
|
||||
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IChecksum plugin)
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IChecksum plugin)
|
||||
Checksums.Add(plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFilesystem plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IFilesystem plugin &&
|
||||
!PluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
PluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFilter plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IFilter plugin &&
|
||||
!Filters.ContainsKey(plugin.Name.ToLower()))
|
||||
Filters.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFloppyImage plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IFloppyImage plugin &&
|
||||
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
FloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IMediaImage plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IMediaImage plugin &&
|
||||
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IPartition plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IPartition plugin &&
|
||||
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IReadOnlyFilesystem plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IReadOnlyFilesystem plugin &&
|
||||
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IWritableFloppyImage plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IWritableFloppyImage plugin &&
|
||||
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||
|
||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IWritableImage plugin &&
|
||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
||||
{ }) is IWritableImage plugin &&
|
||||
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
||||
WritableImages.Add(plugin.Name.ToLower(), plugin);
|
||||
}
|
||||
|
||||
@@ -42,119 +42,72 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// File attributes.
|
||||
/// </summary>
|
||||
/// <summary>File attributes.</summary>
|
||||
[Flags]
|
||||
public enum FileAttributes : ulong
|
||||
{
|
||||
/// <summary>File has no attributes</summary>
|
||||
None = 0,
|
||||
/// <summary>File is an alias (Mac OS)</summary>
|
||||
Alias = 0x01,
|
||||
/// <summary>Indicates that the file can only be writable appended</summary>
|
||||
AppendOnly = 0x02,
|
||||
/// <summary>File is candidate for archival/backup</summary>
|
||||
Archive = 0x04,
|
||||
/// <summary>File is a block device</summary>
|
||||
BlockDevice = 0x08,
|
||||
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
|
||||
BlockUnits = 0x10,
|
||||
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
|
||||
Bundle = 0x20,
|
||||
/// <summary>File is a char device</summary>
|
||||
CharDevice = 0x40,
|
||||
/// <summary>File is compressed</summary>
|
||||
Compressed = 0x80,
|
||||
/// <summary>File is compressed and should not be uncompressed on read</summary>
|
||||
CompressedRaw = 0x100,
|
||||
/// <summary>File has compression errors</summary>
|
||||
CompressionError = 0x200,
|
||||
/// <summary>Compressed file is dirty</summary>
|
||||
CompressionDirty = 0x400,
|
||||
/// <summary>File is a device</summary>
|
||||
Device = 0x800,
|
||||
/// <summary>File is a directory</summary>
|
||||
Directory = 0x1000,
|
||||
/// <summary>File is encrypted</summary>
|
||||
Encrypted = 0x2000,
|
||||
/// <summary>File is stored on disk using extents</summary>
|
||||
Extents = 0x4000,
|
||||
/// <summary>File is a FIFO</summary>
|
||||
FIFO = 0x8000,
|
||||
/// <summary>File is a normal file</summary>
|
||||
None = 0, /// <summary>File is an alias (Mac OS)</summary>
|
||||
Alias = 0x01, /// <summary>Indicates that the file can only be writable appended</summary>
|
||||
AppendOnly = 0x02, /// <summary>File is candidate for archival/backup</summary>
|
||||
Archive = 0x04, /// <summary>File is a block device</summary>
|
||||
BlockDevice = 0x08, /// <summary>File is stored on filesystem block units instead of device sectors</summary>
|
||||
BlockUnits = 0x10, /// <summary>Directory is a bundle or file contains a BNDL resource</summary>
|
||||
Bundle = 0x20, /// <summary>File is a char device</summary>
|
||||
CharDevice = 0x40, /// <summary>File is compressed</summary>
|
||||
Compressed = 0x80, /// <summary>File is compressed and should not be uncompressed on read</summary>
|
||||
CompressedRaw = 0x100, /// <summary>File has compression errors</summary>
|
||||
CompressionError = 0x200, /// <summary>Compressed file is dirty</summary>
|
||||
CompressionDirty = 0x400, /// <summary>File is a device</summary>
|
||||
Device = 0x800, /// <summary>File is a directory</summary>
|
||||
Directory = 0x1000, /// <summary>File is encrypted</summary>
|
||||
Encrypted = 0x2000, /// <summary>File is stored on disk using extents</summary>
|
||||
Extents = 0x4000, /// <summary>File is a FIFO</summary>
|
||||
FIFO = 0x8000, /// <summary>File is a normal file</summary>
|
||||
File = 0x10000,
|
||||
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
|
||||
HasBeenInited = 0x20000,
|
||||
/// <summary>File contains an icon resource / EA</summary>
|
||||
HasBeenInited = 0x20000, /// <summary>File contains an icon resource / EA</summary>
|
||||
HasCustomIcon = 0x40000,
|
||||
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
|
||||
HasNoINITs = 0x80000,
|
||||
/// <summary>File is hidden/invisible</summary>
|
||||
Hidden = 0x100000,
|
||||
/// <summary>File cannot be written, deleted, modified or linked to</summary>
|
||||
Immutable = 0x200000,
|
||||
/// <summary>Directory is indexed using hashed trees</summary>
|
||||
IndexedDirectory = 0x400000,
|
||||
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
|
||||
Inline = 0x800000,
|
||||
/// <summary>File contains integrity checks</summary>
|
||||
IntegrityStream = 0x1000000,
|
||||
/// <summary>File is on desktop</summary>
|
||||
HasNoINITs = 0x80000, /// <summary>File is hidden/invisible</summary>
|
||||
Hidden = 0x100000, /// <summary>File cannot be written, deleted, modified or linked to</summary>
|
||||
Immutable = 0x200000, /// <summary>Directory is indexed using hashed trees</summary>
|
||||
IndexedDirectory = 0x400000, /// <summary>File contents are stored alongside its inode (or equivalent)</summary>
|
||||
Inline = 0x800000, /// <summary>File contains integrity checks</summary>
|
||||
IntegrityStream = 0x1000000, /// <summary>File is on desktop</summary>
|
||||
IsOnDesk = 0x2000000,
|
||||
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
|
||||
Journaled = 0x4000000,
|
||||
/// <summary>Access time will not be modified</summary>
|
||||
NoAccessTime = 0x8000000,
|
||||
/// <summary>File will not be subject to copy-on-write</summary>
|
||||
NoCopyOnWrite = 0x10000000,
|
||||
/// <summary>File will not be backed up</summary>
|
||||
NoDump = 0x20000000,
|
||||
/// <summary>File contents should not be scrubbed</summary>
|
||||
NoScrub = 0x40000000,
|
||||
/// <summary>File contents should not be indexed</summary>
|
||||
NotIndexed = 0x80000000,
|
||||
/// <summary>File is offline</summary>
|
||||
Offline = 0x100000000,
|
||||
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
|
||||
Password = 0x200000000,
|
||||
/// <summary>File is read-only</summary>
|
||||
ReadOnly = 0x400000000,
|
||||
/// <summary>File is a reparse point</summary>
|
||||
Journaled = 0x4000000, /// <summary>Access time will not be modified</summary>
|
||||
NoAccessTime = 0x8000000, /// <summary>File will not be subject to copy-on-write</summary>
|
||||
NoCopyOnWrite = 0x10000000, /// <summary>File will not be backed up</summary>
|
||||
NoDump = 0x20000000, /// <summary>File contents should not be scrubbed</summary>
|
||||
NoScrub = 0x40000000, /// <summary>File contents should not be indexed</summary>
|
||||
NotIndexed = 0x80000000, /// <summary>File is offline</summary>
|
||||
Offline = 0x100000000, /// <summary>File is password protected, but contents are not encrypted on disk</summary>
|
||||
Password = 0x200000000, /// <summary>File is read-only</summary>
|
||||
ReadOnly = 0x400000000, /// <summary>File is a reparse point</summary>
|
||||
ReparsePoint = 0x800000000,
|
||||
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
|
||||
Secured = 0x1000000000,
|
||||
/// <summary>File contents are sparse</summary>
|
||||
Sparse = 0x2000000000,
|
||||
/// <summary>File is a shadow (OS/2)</summary>
|
||||
Shadow = 0x4000000000,
|
||||
/// <summary>File is shared</summary>
|
||||
Shared = 0x8000000000,
|
||||
/// <summary>File is a stationery</summary>
|
||||
Stationery = 0x10000000000,
|
||||
/// <summary>File is a symbolic link</summary>
|
||||
Symlink = 0x20000000000,
|
||||
/// <summary>File writes are synchronously written to disk</summary>
|
||||
Sync = 0x40000000000,
|
||||
/// <summary>File belongs to the operating system</summary>
|
||||
Secured = 0x1000000000, /// <summary>File contents are sparse</summary>
|
||||
Sparse = 0x2000000000, /// <summary>File is a shadow (OS/2)</summary>
|
||||
Shadow = 0x4000000000, /// <summary>File is shared</summary>
|
||||
Shared = 0x8000000000, /// <summary>File is a stationery</summary>
|
||||
Stationery = 0x10000000000, /// <summary>File is a symbolic link</summary>
|
||||
Symlink = 0x20000000000, /// <summary>File writes are synchronously written to disk</summary>
|
||||
Sync = 0x40000000000, /// <summary>File belongs to the operating system</summary>
|
||||
System = 0x80000000000,
|
||||
/// <summary>If file end is a partial block its content will be merged with other files</summary>
|
||||
TailMerged = 0x100000000000,
|
||||
/// <summary>File is temporary</summary>
|
||||
TailMerged = 0x100000000000, /// <summary>File is temporary</summary>
|
||||
Temporary = 0x200000000000,
|
||||
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
|
||||
TopDirectory = 0x400000000000,
|
||||
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
|
||||
Undeletable = 0x800000000000,
|
||||
/// <summary>File is a pipe</summary>
|
||||
Pipe = 0x1000000000000,
|
||||
/// <summary>File is a socket</summary>
|
||||
Undeletable = 0x800000000000, /// <summary>File is a pipe</summary>
|
||||
Pipe = 0x1000000000000, /// <summary>File is a socket</summary>
|
||||
Socket = 0x2000000000000
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Information about a file entry
|
||||
/// </summary>
|
||||
/// <summary>Information about a file entry</summary>
|
||||
public class FileEntryInfo
|
||||
{
|
||||
/// <summary>File attributes</summary>
|
||||
@@ -194,24 +147,28 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
get => CreationTimeUtc?.ToLocalTime();
|
||||
set => CreationTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last access date. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? AccessTime
|
||||
{
|
||||
get => AccessTimeUtc?.ToLocalTime();
|
||||
set => AccessTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File attributes change date. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? StatusChangeTime
|
||||
{
|
||||
get => StatusChangeTimeUtc?.ToLocalTime();
|
||||
set => StatusChangeTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last backup date. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? BackupTime
|
||||
{
|
||||
get => BackupTimeUtc?.ToLocalTime();
|
||||
set => BackupTimeUtc = value?.ToUniversalTime();
|
||||
}
|
||||
|
||||
/// <summary>File last modification date. Null if the underlying filesystem does not support them.</summary>
|
||||
public DateTime? LastWriteTime
|
||||
{
|
||||
@@ -239,10 +196,7 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
/// <summary>Filesystem type</summary>
|
||||
public string Type;
|
||||
|
||||
public FileSystemInfo()
|
||||
{
|
||||
Id = new FileSystemId();
|
||||
}
|
||||
public FileSystemInfo() => Id = new FileSystemId();
|
||||
|
||||
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
|
||||
}
|
||||
@@ -265,72 +219,40 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
public Guid uuid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Errors
|
||||
/// </summary>
|
||||
/// <summary>Errors</summary>
|
||||
public enum Errno
|
||||
{
|
||||
/// <summary>No error happened</summary>
|
||||
NoError = 0,
|
||||
/// <summary>Access denied</summary>
|
||||
AccessDenied = -13,
|
||||
/// <summary>Busy, cannot complete</summary>
|
||||
Busy = -16,
|
||||
/// <summary>File is too large</summary>
|
||||
FileTooLarge = -27,
|
||||
/// <summary>Invalid argument</summary>
|
||||
InvalidArgument = -22,
|
||||
/// <summary>I/O error</summary>
|
||||
InOutError = -5,
|
||||
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
IsDirectory = -21,
|
||||
/// <summary>Name is too long</summary>
|
||||
NameTooLong = -36,
|
||||
/// <summary>There is no data available</summary>
|
||||
NoData = 61,
|
||||
/// <summary>There is no such attribute</summary>
|
||||
NoSuchExtendedAttribute = NoData,
|
||||
/// <summary>No such device</summary>
|
||||
NoSuchDevice = -19,
|
||||
/// <summary>No such file or directory</summary>
|
||||
NoSuchFile = -2,
|
||||
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
NotDirectory = -20,
|
||||
/// <summary>Not implemented</summary>
|
||||
NotImplemented = -38,
|
||||
/// <summary>Not supported</summary>
|
||||
NotSupported = -252,
|
||||
/// <summary>Link is severed</summary>
|
||||
SeveredLink = -67,
|
||||
/// <summary>Access denied</summary>
|
||||
EACCES = AccessDenied,
|
||||
/// <summary>Busy, cannot complete</summary>
|
||||
EBUSY = Busy,
|
||||
/// <summary>File is too large</summary>
|
||||
EFBIG = FileTooLarge,
|
||||
/// <summary>Invalid argument</summary>
|
||||
EINVAL = InvalidArgument,
|
||||
/// <summary>I/O error</summary>
|
||||
EIO = InOutError,
|
||||
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
EISDIR = IsDirectory,
|
||||
/// <summary>Name is too long</summary>
|
||||
ENAMETOOLONG = NameTooLong,
|
||||
/// <summary>There is no such attribute</summary>
|
||||
ENOATTR = NoSuchExtendedAttribute,
|
||||
/// <summary>There is no data available</summary>
|
||||
ENODATA = NoData,
|
||||
/// <summary>No such device</summary>
|
||||
ENODEV = NoSuchDevice,
|
||||
/// <summary>No such file or directory</summary>
|
||||
ENOENT = NoSuchFile,
|
||||
/// <summary>Link is severed</summary>
|
||||
ENOLINK = SeveredLink,
|
||||
/// <summary>Not implemented</summary>
|
||||
ENOSYS = NotImplemented,
|
||||
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
ENOTDIR = NotDirectory,
|
||||
/// <summary>Not supported</summary>
|
||||
NoError = 0, /// <summary>Access denied</summary>
|
||||
AccessDenied = -13, /// <summary>Busy, cannot complete</summary>
|
||||
Busy = -16, /// <summary>File is too large</summary>
|
||||
FileTooLarge = -27, /// <summary>Invalid argument</summary>
|
||||
InvalidArgument = -22, /// <summary>I/O error</summary>
|
||||
InOutError = -5, /// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
IsDirectory = -21, /// <summary>Name is too long</summary>
|
||||
NameTooLong = -36, /// <summary>There is no data available</summary>
|
||||
NoData = 61, /// <summary>There is no such attribute</summary>
|
||||
NoSuchExtendedAttribute = NoData, /// <summary>No such device</summary>
|
||||
NoSuchDevice = -19, /// <summary>No such file or directory</summary>
|
||||
NoSuchFile = -2, /// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
NotDirectory = -20, /// <summary>Not implemented</summary>
|
||||
NotImplemented = -38, /// <summary>Not supported</summary>
|
||||
NotSupported = -252, /// <summary>Link is severed</summary>
|
||||
SeveredLink = -67, /// <summary>Access denied</summary>
|
||||
EACCES = AccessDenied, /// <summary>Busy, cannot complete</summary>
|
||||
EBUSY = Busy, /// <summary>File is too large</summary>
|
||||
EFBIG = FileTooLarge, /// <summary>Invalid argument</summary>
|
||||
EINVAL = InvalidArgument, /// <summary>I/O error</summary>
|
||||
EIO = InOutError, /// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
|
||||
EISDIR = IsDirectory, /// <summary>Name is too long</summary>
|
||||
ENAMETOOLONG = NameTooLong, /// <summary>There is no such attribute</summary>
|
||||
ENOATTR = NoSuchExtendedAttribute, /// <summary>There is no data available</summary>
|
||||
ENODATA = NoData, /// <summary>No such device</summary>
|
||||
ENODEV = NoSuchDevice, /// <summary>No such file or directory</summary>
|
||||
ENOENT = NoSuchFile, /// <summary>Link is severed</summary>
|
||||
ENOLINK = SeveredLink, /// <summary>Not implemented</summary>
|
||||
ENOSYS = NotImplemented, /// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
|
||||
ENOTDIR = NotDirectory, /// <summary>Not supported</summary>
|
||||
ENOTSUP = NotSupported
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,7 @@ using DiscImageChef.CommonTypes.Interfaces;
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a dump image and its contents
|
||||
/// </summary>
|
||||
/// <summary>Contains information about a dump image and its contents</summary>
|
||||
public struct ImageInfo
|
||||
{
|
||||
/// <summary>Image contains partitions (or tracks for optical media)</summary>
|
||||
@@ -104,6 +102,7 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
public string DriveFirmwareRevision;
|
||||
/// <summary>Type of the media represented by the image to use in XML sidecars</summary>
|
||||
public XmlMediaType XmlMediaType;
|
||||
|
||||
// CHS geometry...
|
||||
/// <summary>Cylinders of the media represented by the image</summary>
|
||||
public uint Cylinders;
|
||||
@@ -113,9 +112,7 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
public uint SectorsPerTrack;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Session defining structure.
|
||||
/// </summary>
|
||||
/// <summary>Session defining structure.</summary>
|
||||
public struct Session
|
||||
{
|
||||
/// <summary>Session number, 1-started</summary>
|
||||
@@ -130,9 +127,7 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
public ulong EndSector;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Track defining structure.
|
||||
/// </summary>
|
||||
/// <summary>Track defining structure.</summary>
|
||||
public struct Track
|
||||
{
|
||||
/// <summary>Track number, 1-started</summary>
|
||||
@@ -173,9 +168,7 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
public TrackSubchannelType TrackSubchannelType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floppy physical characteristics structure.
|
||||
/// </summary>
|
||||
/// <summary>Floppy physical characteristics structure.</summary>
|
||||
public struct FloppyInfo
|
||||
{
|
||||
/// <summary>Physical floppy type.</summary>
|
||||
|
||||
@@ -35,25 +35,18 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.CommonTypes.Structs
|
||||
{
|
||||
public struct TapeFile
|
||||
{
|
||||
/// <summary>
|
||||
/// File number
|
||||
/// </summary>
|
||||
/// <summary>File number</summary>
|
||||
public uint File;
|
||||
/// <summary>
|
||||
/// Partition number
|
||||
/// </summary>
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Partition;
|
||||
/// <summary>
|
||||
/// First block, inclusive, of the file
|
||||
/// </summary>
|
||||
/// <summary>First block, inclusive, of the file</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>
|
||||
/// Last block, inclusive, of the file
|
||||
/// </summary>
|
||||
/// <summary>Last block, inclusive, of the file</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
}
|
||||
@@ -40,17 +40,11 @@ namespace DiscImageChef.CommonTypes.Structs
|
||||
{
|
||||
public struct TapePartition
|
||||
{
|
||||
/// <summary>
|
||||
/// Partition number
|
||||
/// </summary>
|
||||
/// <summary>Partition number</summary>
|
||||
public byte Number;
|
||||
/// <summary>
|
||||
/// First block, inclusive, of the partition
|
||||
/// </summary>
|
||||
/// <summary>First block, inclusive, of the partition</summary>
|
||||
public ulong FirstBlock;
|
||||
/// <summary>
|
||||
/// Last block, inclusive, of the partition
|
||||
/// </summary>
|
||||
/// <summary>Last block, inclusive, of the partition</summary>
|
||||
public ulong LastBlock;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user