diff --git a/DiscImageChef.CommonTypes.csproj b/DiscImageChef.CommonTypes.csproj index a130725..f396d69 100644 --- a/DiscImageChef.CommonTypes.csproj +++ b/DiscImageChef.CommonTypes.csproj @@ -46,10 +46,46 @@ + + Metadata/cicm.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -60,6 +96,14 @@ + + + LICENSE.MIT + + + + + diff --git a/Enums/Images.cs b/Enums/Images.cs new file mode 100644 index 0000000..372ca59 --- /dev/null +++ b/Enums/Images.cs @@ -0,0 +1,356 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines enumerations to be used by disc image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; + +namespace DiscImageChef.CommonTypes.Enums +{ + /// + /// Track (as partitioning element) types. + /// + public enum TrackType : byte + { + /// Audio track + Audio = 0, + /// Data track (not any of the below defined ones) + Data = 1, + /// Data track, compact disc mode 1 + CdMode1 = 2, + /// Data track, compact disc mode 2, formless + CdMode2Formless = 3, + /// Data track, compact disc mode 2, form 1 + CdMode2Form1 = 4, + /// Data track, compact disc mode 2, form 2 + CdMode2Form2 = 5 + } + + /// + /// Type of subchannel in track + /// + public enum TrackSubchannelType + { + /// + /// Track does not has subchannel dumped, or it's not a CD + /// + None, + /// + /// Subchannel is packed and error corrected + /// + Packed, + /// + /// Subchannel is interleaved + /// + Raw, + /// + /// Subchannel is packed and comes interleaved with main channel in same file + /// + PackedInterleaved, + /// + /// Subchannel is interleaved and comes interleaved with main channel in same file + /// + RawInterleaved, + /// + /// Only Q subchannel is stored as 16 bytes + /// + Q16, + /// + /// Only Q subchannel is stored as 16 bytes and comes interleaved with main channel in same file + /// + Q16Interleaved + } + + /// + /// Metadata present for each sector (aka, "tag"). + /// + public enum SectorTagType + { + /// Apple's GCR sector tags, 12 bytes + AppleSectorTag, + /// Sync frame from CD sector, 12 bytes + CdSectorSync, + /// CD sector header, 4 bytes + CdSectorHeader, + /// CD mode 2 sector subheader + CdSectorSubHeader, + /// CD sector EDC, 4 bytes + CdSectorEdc, + /// CD sector ECC P, 172 bytes + CdSectorEccP, + /// CD sector ECC Q, 104 bytes + CdSectorEccQ, + /// CD sector ECC (P and Q), 276 bytes + CdSectorEcc, + /// CD sector subchannel, 96 bytes + CdSectorSubchannel, + /// CD track ISRC, string, 12 bytes + CdTrackIsrc, + /// CD track text, string, 13 bytes + CdTrackText, + /// CD track flags, 1 byte + CdTrackFlags, + /// DVD sector copyright information + DvdCmi, + /// Floppy address mark (contents depend on underlying floppy format) + FloppyAddressMark + } + + /// + /// Metadata present for each media. + /// + public enum MediaTagType + { + /// CD table of contents + CD_TOC, + /// CD session information + CD_SessionInfo, + /// CD full table of contents + CD_FullTOC, + /// CD PMA + CD_PMA, + /// CD Adress-Time-In-Pregroove + CD_ATIP, + /// CD-Text + CD_TEXT, + /// CD Media Catalogue Number + CD_MCN, + /// DVD/HD DVD Physical Format Information + DVD_PFI, + /// DVD Lead-in Copyright Management Information + DVD_CMI, + /// DVD disc key + DVD_DiscKey, + /// DVD/HD DVD Burst Cutting Area + DVD_BCA, + /// DVD/HD DVD Lead-in Disc Manufacturer Information + DVD_DMI, + /// Media identifier + DVD_MediaIdentifier, + /// Media key block + DVD_MKB, + /// DVD-RAM/HD DVD-RAM DDS information + DVDRAM_DDS, + /// DVD-RAM/HD DVD-RAM Medium status + DVDRAM_MediumStatus, + /// DVD-RAM/HD DVD-RAM Spare area information + DVDRAM_SpareArea, + /// DVD-R/-RW/HD DVD-R RMD in last border-out + DVDR_RMD, + /// Pre-recorded information from DVD-R/-RW lead-in + DVDR_PreRecordedInfo, + /// DVD-R/-RW/HD DVD-R media identifier + DVDR_MediaIdentifier, + /// DVD-R/-RW/HD DVD-R physical format information + DVDR_PFI, + /// ADIP information + DVD_ADIP, + /// HD DVD Lead-in copyright protection information + HDDVD_CPI, + /// HD DVD-R Medium Status + HDDVD_MediumStatus, + /// DVD+/-R DL Layer capacity + DVDDL_LayerCapacity, + /// DVD-R DL Middle Zone start address + DVDDL_MiddleZoneAddress, + /// DVD-R DL Jump Interval Size + DVDDL_JumpIntervalSize, + /// DVD-R DL Start LBA of the manual layer jump + DVDDL_ManualLayerJumpLBA, + /// Blu-ray Disc Information + BD_DI, + /// Blu-ray Burst Cutting Area + BD_BCA, + /// Blu-ray Disc Definition Structure + BD_DDS, + /// Blu-ray Cartridge Status + BD_CartridgeStatus, + /// Blu-ray Status of Spare Area + BD_SpareArea, + /// AACS volume identifier + AACS_VolumeIdentifier, + /// AACS pre-recorded media serial number + AACS_SerialNumber, + /// AACS media identifier + AACS_MediaIdentifier, + /// Lead-in AACS media key block + AACS_MKB, + /// AACS data keys + AACS_DataKeys, + /// LBA extents flagged for bus encryption by AACS + AACS_LBAExtents, + /// CPRM media key block in Lead-in + AACS_CPRM_MKB, + /// Recognized layer formats in hybrid discs + Hybrid_RecognizedLayers, + /// Disc write protection status + MMC_WriteProtection, + /// Disc standard information + MMC_DiscInformation, + /// Disc track resources information + MMC_TrackResourcesInformation, + /// BD-R Pseudo-overwrite information + MMC_POWResourcesInformation, + /// SCSI INQUIRY response + SCSI_INQUIRY, + /// SCSI MODE PAGE 2Ah + SCSI_MODEPAGE_2A, + /// ATA IDENTIFY DEVICE response + ATA_IDENTIFY, + /// ATA IDENTIFY PACKET DEVICE response + ATAPI_IDENTIFY, + /// PCMCIA/CardBus Card Information Structure + PCMCIA_CIS, + /// SecureDigital CID + SD_CID, + /// SecureDigital CSD + SD_CSD, + /// SecureDigital SCR + SD_SCR, + /// SecureDigital OCR + SD_OCR, + /// MultiMediaCard CID + MMC_CID, + /// MultiMediaCard CSD + MMC_CSD, + /// MultiMediaCard OCR + MMC_OCR, + /// MultiMediaCard Extended CSD + MMC_ExtendedCSD, + /// Xbox Security Sector + Xbox_SecuritySector, + /// + /// On floppy disks, data in last cylinder usually in a different format that contains duplication or + /// manufacturing information + /// + Floppy_LeadOut, + /// DVD Disc Control Blocks + DCB, + /// Compact Disc Lead-in + CD_LeadIn, + /// Compact Disc Lead-out + CD_LeadOut, + /// SCSI MODE SENSE (6) + SCSI_MODESENSE_6, + /// SCSI MODE SENSE (10) + SCSI_MODESENSE_10, + /// USB descriptors + USB_Descriptors, + /// XGD unlocked DMI + Xbox_DMI, + /// XDG unlocked PFI + Xbox_PFI + } + + /// + /// Enumeration of media types defined in CICM metadata + /// + public enum XmlMediaType + { + /// + /// Purely optical discs + /// + OpticalDisc, + /// + /// Media that is physically block-based or abstracted like that + /// + BlockMedia, + /// + /// Media that can be accessed by-byte or by-bit, like chips + /// + LinearMedia, + /// + /// Media that can only store data when it is modulated to audio + /// + AudioMedia + } + + /// CD flags bitmask + [Flags] + public enum CdFlags : byte + { + /// Track is quadraphonic. + FourChannel = 0x08, + /// Track is non-audio (data). + DataTrack = 0x04, + /// Track is copy protected. + CopyPermitted = 0x02, + /// Track has pre-emphasis. + PreEmphasis = 0x01 + } + + /// Status of a requested floppy sector + [Flags] + public enum FloppySectorStatus : byte + { + /// Both address mark and data checksums are correct. + Correct = 0x01, + /// Data checksum is incorrect. + DataError = 0x02, + /// Addres mark checksum is incorrect. + AddressMarkError = 0x04, + /// There is another sector in the same track/head with same sector id. + Duplicated = 0x08, + /// Sector data section is not magnetized. + Demagnetized = 0x10, + /// Sector data section has a physically visible hole. + Hole = 0x20, + /// There is no address mark containing the requested sector id in the track/head. + NotFound = 0x40 + } + + public enum FloppyTypes : byte + { + /// 8" floppy + Floppy, + /// 5.25" floppy + MiniFloppy, + /// 3.5" floppy + MicroFloppy, + /// 3" floppy + CompactFloppy, + /// 5.25" twiggy + FileWare, + /// 2.5" quickdisk + QuickDisk + } + + public enum FloppyDensities : byte + { + /// Standard coercitivity (about 300Oe as found in 8" and 5.25"-double-density disks). + Standard, + /// Double density coercitivity (about 600Oe as found in 5.25" HD and 3.5" DD disks). + Double, + /// High density coercitivity (about 700Oe as found in 3.5" HD disks). + High, + /// Extended density coercitivity (about 750Oe as found in 3.5" ED disks). + Extended + } +} \ No newline at end of file diff --git a/Exceptions/Images.cs b/Exceptions/Images.cs new file mode 100644 index 0000000..e724f90 --- /dev/null +++ b/Exceptions/Images.cs @@ -0,0 +1,188 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines exceptions to be thrown by disc image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.Serialization; + +namespace DiscImageChef.CommonTypes.Exceptions +{ + /// + /// Feature is supported by image but not implemented yet. + /// + [Serializable] + public class FeatureSupportedButNotImplementedImageException : Exception + { + /// + /// Feature is supported by image but not implemented yet. + /// + /// Message. + /// Inner. + public FeatureSupportedButNotImplementedImageException(string message, Exception inner) : + base(message, inner) { } + + /// + /// Feature is supported by image but not implemented yet. + /// + /// Message. + public FeatureSupportedButNotImplementedImageException(string message) : base(message) { } + + /// + /// Feature is supported by image but not implemented yet. + /// + /// Info. + /// Context. + protected FeatureSupportedButNotImplementedImageException(SerializationInfo info, StreamingContext context) + { + if(info == null) throw new ArgumentNullException(nameof(info)); + } + } + + /// + /// Feature is not supported by image. + /// + [Serializable] + public class FeatureUnsupportedImageException : Exception + { + /// + /// Feature is not supported by image. + /// + /// Message. + /// Inner. + public FeatureUnsupportedImageException(string message, Exception inner) : base(message, inner) { } + + /// + /// Feature is not supported by image. + /// + /// Message. + public FeatureUnsupportedImageException(string message) : base(message) { } + + /// + /// Feature is not supported by image. + /// + /// Info. + /// Context. + protected FeatureUnsupportedImageException(SerializationInfo info, StreamingContext context) + { + if(info == null) throw new ArgumentNullException(nameof(info)); + } + } + + /// + /// Feature is supported by image but not present on it. + /// + [Serializable] + public class FeatureNotPresentImageException : Exception + { + /// + /// Feature is supported by image but not present on it. + /// + /// Message. + /// Inner. + public FeatureNotPresentImageException(string message, Exception inner) : base(message, inner) { } + + /// + /// Feature is supported by image but not present on it. + /// + /// Message. + public FeatureNotPresentImageException(string message) : base(message) { } + + /// + /// Feature is supported by image but not present on it. + /// + /// Info. + /// Context. + protected FeatureNotPresentImageException(SerializationInfo info, StreamingContext context) + { + if(info == null) throw new ArgumentNullException(nameof(info)); + } + } + + /// + /// Feature is supported by image but not by the disc it represents. + /// + [Serializable] + public class FeaturedNotSupportedByDiscImageException : Exception + { + /// + /// Feature is supported by image but not by the disc it represents. + /// + /// Message. + /// Inner. + public FeaturedNotSupportedByDiscImageException(string message, Exception inner) : base(message, inner) { } + + /// + /// Feature is supported by image but not by the disc it represents. + /// + /// Message. + public FeaturedNotSupportedByDiscImageException(string message) : base(message) { } + + /// + /// Feature is supported by image but not by the disc it represents. + /// + /// Info. + /// Context. + protected FeaturedNotSupportedByDiscImageException(SerializationInfo info, StreamingContext context) + { + if(info == null) throw new ArgumentNullException(nameof(info)); + } + } + + /// + /// Corrupt, incorrect or unhandled feature found on image + /// + [Serializable] + public class ImageNotSupportedException : Exception + { + /// + /// Corrupt, incorrect or unhandled feature found on image + /// + /// Message. + /// Inner. + public ImageNotSupportedException(string message, Exception inner) : base(message, inner) { } + + /// + /// Corrupt, incorrect or unhandled feature found on image + /// + /// Message. + public ImageNotSupportedException(string message) : base(message) { } + + /// + /// Corrupt, incorrect or unhandled feature found on image + /// + /// Info. + /// Context. + protected ImageNotSupportedException(SerializationInfo info, StreamingContext context) + { + if(info == null) throw new ArgumentNullException(nameof(info)); + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsByte.cs b/Extents/ExtentsByte.cs new file mode 100644 index 0000000..e51e215 --- /dev/null +++ b/Extents/ExtentsByte.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsByte.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for byte types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsByte + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsByte() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsByte(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(byte item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(byte start, byte end, bool run = false) + { + byte realEnd; + if(run) realEnd = (byte)(start + end - 1); + else realEnd = end; + + // TODO: Optimize this + for(byte t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(byte item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(byte item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (byte)(item - 1)); + toAddTwo = new Tuple((byte)(item + 1), extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple((byte)(item + 1), extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (byte)(item - 1)); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(byte item, out byte start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsConverter.cs b/Extents/ExtentsConverter.cs new file mode 100644 index 0000000..1739b44 --- /dev/null +++ b/Extents/ExtentsConverter.cs @@ -0,0 +1,65 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsConverter.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Converts extents to/from XML. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; +using Schemas; + +namespace DiscImageChef.CommonTypes.Extents +{ + public static class ExtentsConverter + { + public static ExtentType[] ToMetadata(ExtentsULong extents) + { + if(extents == null) return null; + + Tuple[] 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}; + + return array; + } + + public static ExtentsULong FromMetadata(ExtentType[] extents) + { + if(extents == null) return null; + + List> tuples = + extents.Select(extent => new Tuple(extent.Start, extent.End)).ToList(); + + return new ExtentsULong(tuples); + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsInt.cs b/Extents/ExtentsInt.cs new file mode 100644 index 0000000..7f7e7d3 --- /dev/null +++ b/Extents/ExtentsInt.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsInt.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for int types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License aint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsInt + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsInt() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsInt(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(int item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(int start, int end, bool run = false) + { + int realEnd; + if(run) realEnd = start + end - 1; + else realEnd = end; + + // TODO: Optimize this + for(int t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(int item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(int item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + toAddTwo = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(int item, out int start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsLong.cs b/Extents/ExtentsLong.cs new file mode 100644 index 0000000..fa401de --- /dev/null +++ b/Extents/ExtentsLong.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsLong.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for long types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsLong + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsLong() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsLong(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(long item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(long start, long end, bool run = false) + { + long realEnd; + if(run) realEnd = start + end - 1; + else realEnd = end; + + // TODO: Optimize this + for(long t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(long item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(long item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + toAddTwo = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(long item, out long start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsSByte.cs b/Extents/ExtentsSByte.cs new file mode 100644 index 0000000..e740dbe --- /dev/null +++ b/Extents/ExtentsSByte.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsSByte.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for sbyte types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsSByte + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsSByte() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsSByte(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(sbyte item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(sbyte start, sbyte end, bool run = false) + { + sbyte realEnd; + if(run) realEnd = (sbyte)(start + end - 1); + else realEnd = end; + + // TODO: Optimize this + for(sbyte t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(sbyte item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(sbyte item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (sbyte)(item - 1)); + toAddTwo = new Tuple((sbyte)(item + 1), extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple((sbyte)(item + 1), extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (sbyte)(item - 1)); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(sbyte item, out sbyte start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsShort.cs b/Extents/ExtentsShort.cs new file mode 100644 index 0000000..bc677e2 --- /dev/null +++ b/Extents/ExtentsShort.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsShort.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for short types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License ashort with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsShort + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsShort() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsShort(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(short item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(short start, short end, bool run = false) + { + short realEnd; + if(run) realEnd = (short)(start + end - 1); + else realEnd = end; + + // TODO: Optimize this + for(short t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(short item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(short item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (short)(item - 1)); + toAddTwo = new Tuple((short)(item + 1), extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple((short)(item + 1), extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (short)(item - 1)); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(short item, out short start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsUInt.cs b/Extents/ExtentsUInt.cs new file mode 100644 index 0000000..7f092cb --- /dev/null +++ b/Extents/ExtentsUInt.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsUInt.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for uint types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License auint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsUInt + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsUInt() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsUInt(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(uint item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(uint start, uint end, bool run = false) + { + uint realEnd; + if(run) realEnd = start + end - 1; + else realEnd = end; + + // TODO: Optimize this + for(uint t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(uint item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(uint item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + toAddTwo = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(uint item, out uint start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsULong.cs b/Extents/ExtentsULong.cs new file mode 100644 index 0000000..c999dba --- /dev/null +++ b/Extents/ExtentsULong.cs @@ -0,0 +1,248 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsULong.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for ulong types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License aulong with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsULong + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsULong() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsULong(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(ulong item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(ulong start, ulong end, bool run = false) + { + ulong realEnd; + if(run) realEnd = start + end - 1; + else realEnd = end; + + // TODO: Optimize this + for(ulong t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(ulong item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(ulong item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + toAddTwo = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(item + 1, extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, item - 1); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(ulong item, out ulong start) + { + start = 0; + foreach(Tuple extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Extents/ExtentsUShort.cs b/Extents/ExtentsUShort.cs new file mode 100644 index 0000000..6ee6894 --- /dev/null +++ b/Extents/ExtentsUShort.cs @@ -0,0 +1,249 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ExtentsUShort.cs +// Author(s) : Natalia Portillo +// +// Component : Extent helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides extents for ushort types. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License aushort with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiscImageChef.CommonTypes.Extents +{ + /// + /// Implements extents for + /// + public class ExtentsUShort + { + List> backend; + + /// + /// Initialize an empty list of extents + /// + public ExtentsUShort() + { + backend = new List>(); + } + + /// + /// Initializes extents with an specific list + /// + /// List of extents as tuples "start, end" + public ExtentsUShort(IEnumerable> list) + { + backend = list.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Gets a count of how many extents are stored + /// + public int Count => backend.Count; + + /// + /// Adds the specified number to the corresponding extent, or creates a new one + /// + /// + public void Add(ushort item) + { + Tuple removeOne = null; + Tuple removeTwo = null; + Tuple itemToAdd = null; + + for(int i = 0; i < backend.Count; i++) + { + // Already contained in an extent + 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) + { + removeTwo = backend[i - 1]; + itemToAdd = new Tuple(backend[i - 1].Item1, backend[i].Item2); + } + else itemToAdd = new Tuple(item, backend[i].Item2); + + break; + } + + // Expands existing extent end + if(item != backend[i].Item2 + 1) continue; + + removeOne = backend[i]; + + if(i < backend.Count - 1 && item == backend[i + 1].Item1 - 1) + { + removeTwo = backend[i + 1]; + itemToAdd = new Tuple(backend[i].Item1, backend[i + 1].Item2); + } + else itemToAdd = new Tuple(backend[i].Item1, item); + + break; + } + + if(itemToAdd != null) + { + backend.Remove(removeOne); + backend.Remove(removeTwo); + backend.Add(itemToAdd); + } + else backend.Add(new Tuple(item, item)); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + } + + /// + /// Adds a new extent + /// + /// First element of the extent + /// + /// Last element of the extent or if is true how many elements the extent runs + /// for + /// + /// If set to true, indicates how many elements the extent runs for + public void Add(ushort start, ushort end, bool run = false) + { + ushort realEnd; + if(run) realEnd = (ushort)(start + end - 1); + else realEnd = end; + + // TODO: Optimize this + for(ushort t = start; t <= realEnd; t++) Add(t); + } + + /// + /// Checks if the specified item is contained by an extent on this instance + /// + /// Item to seach for + /// true if any of the extents on this instance contains the item + public bool Contains(ushort item) + { + return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2); + } + + /// + /// Removes all extents from this instance + /// + public void Clear() + { + backend.Clear(); + } + + /// + /// Removes an item from the extents in this instance + /// + /// Item to remove + /// true if the item was contained in a known extent and removed, false otherwise + public bool Remove(ushort item) + { + Tuple toRemove = null; + Tuple toAddOne = null; + Tuple toAddTwo = null; + + foreach(Tuple extent in backend) + { + // Extent is contained and not a border + if(item > extent.Item1 && item < extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (ushort)(item - 1)); + toAddTwo = new Tuple((ushort)(item + 1), extent.Item2); + break; + } + + // Extent is left border, but not only element + if(item == extent.Item1 && item != extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple((ushort)(item + 1), extent.Item2); + break; + } + + // Extent is right border, but not only element + if(item != extent.Item1 && item == extent.Item2) + { + toRemove = extent; + toAddOne = new Tuple(extent.Item1, (ushort)(item - 1)); + break; + } + + // Extent is only element + if(item != extent.Item1 || item != extent.Item2) continue; + + toRemove = extent; + break; + } + + // Item not found + if(toRemove == null) return false; + + backend.Remove(toRemove); + if(toAddOne != null) backend.Add(toAddOne); + if(toAddTwo != null) backend.Add(toAddTwo); + + // Sort + backend = backend.OrderBy(t => t.Item1).ToList(); + + return true; + } + + /// + /// Converts the list of extents to an array of where T1 is first element of the extent and T2 is + /// last element + /// + /// Array of + public Tuple[] ToArray() + { + return backend.ToArray(); + } + + /// + /// Gets the first element of the extent that contains the specified item + /// + /// Item + /// First element of extent + /// true if item was found in an extent, false otherwise + public bool GetStart(ushort item, out ushort start) + { + start = 0; + foreach(Tuple extent in + backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) + { + start = extent.Item1; + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Filters.cs b/Filters.cs new file mode 100644 index 0000000..67a530d --- /dev/null +++ b/Filters.cs @@ -0,0 +1,108 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Filters.cs +// Author(s) : Natalia Portillo +// +// Component : Filters. +// +// --[ Description ] ---------------------------------------------------------- +// +// Enumerates all filters and instantiates the correct one. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using DiscImageChef.CommonTypes.Interfaces; +using DiscImageChef.Console; + +namespace DiscImageChef.CommonTypes +{ + public class FiltersList + { + public SortedDictionary Filters; + + /// + /// Fills the list of all known filters + /// + public FiltersList() + { + Assembly assembly = Assembly.Load("DiscImageChef.Filters"); + Filters = new SortedDictionary(); + + 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())) + Filters.Add(filter.Name.ToLower(), filter); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + } + + /// + /// Gets the filter that allows to read the specified path + /// + /// Path + /// The filter that allows reading the specified path + public IFilter GetFilter(string path) + { + 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; + + IFilter foundFilter = + (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + + foundFilter?.Open(path); + + if(foundFilter?.IsOpened() == true) return foundFilter; + } + else + noFilter = filter; + + if(!noFilter?.Identify(path) == true) return noFilter; + + noFilter?.Open(path); + + return noFilter; + } + catch(IOException) { return null; } + } + + /// + /// Gets all known filters + /// + /// Known filters + public SortedDictionary GetFiltersList() + { + return Filters; + } + } +} \ No newline at end of file diff --git a/Interfaces/IChecksum.cs b/Interfaces/IChecksum.cs new file mode 100644 index 0000000..ac56506 --- /dev/null +++ b/Interfaces/IChecksum.cs @@ -0,0 +1,60 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IChecksum.cs +// Author(s) : Natalia Portillo +// +// Component : Checksums. +// +// --[ Description ] ---------------------------------------------------------- +// +// Provides an interface for implementing checksums and hashes. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +namespace DiscImageChef.CommonTypes.Interfaces +{ + public interface IChecksum + { + /// + /// Updates the hash with data. + /// + /// Data buffer. + /// Length of buffer to hash. + void Update(byte[] data, uint len); + + /// + /// Updates the hash with data. + /// + /// Data buffer. + void Update(byte[] data); + + /// + /// Returns a byte array of the hash value. + /// + byte[] Final(); + + /// + /// Returns a hexadecimal representation of the hash value. + /// + string End(); + } +} \ No newline at end of file diff --git a/Interfaces/IFilesystem.cs b/Interfaces/IFilesystem.cs new file mode 100644 index 0000000..132d335 --- /dev/null +++ b/Interfaces/IFilesystem.cs @@ -0,0 +1,72 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IFilesystem.cs +// Author(s) : Natalia Portillo +// +// Component : Filesystem plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Interface for filesystem plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Schemas; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// Interface to implement filesystem plugins. + /// + public interface IFilesystem + { + Encoding Encoding { get; } + /// Plugin name. + string Name { get; } + /// Plugin UUID. + Guid Id { get; } + /// + /// Information about the filesystem as expected by CICM Metadata XML + /// + /// Information about the filesystem as expected by CICM Metadata XML + FileSystemType XmlFsType { get; } + + /// + /// Identifies the filesystem in the specified LBA + /// + /// Disk image. + /// Partition. + /// true, if the filesystem is recognized, false otherwise. + bool Identify(IMediaImage imagePlugin, Partition partition); + + /// + /// Gets information about the identified filesystem. + /// + /// Disk image. + /// Partition. + /// Filesystem information. + /// Which encoding to use for this filesystem. + void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding); + } +} \ No newline at end of file diff --git a/Interfaces/IFilter.cs b/Interfaces/IFilter.cs new file mode 100644 index 0000000..9af7c2a --- /dev/null +++ b/Interfaces/IFilter.cs @@ -0,0 +1,172 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IFilter.cs +// Author(s) : Natalia Portillo +// +// Component : Filters. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines the interface for a Filter. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.IO; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + public interface IFilter + { + /// Descriptive name of the plugin + string Name { get; } + /// Unique UUID of the plugin + Guid Id { get; } + + /// + /// Closes all opened streams. + /// + void Close(); + + /// + /// Gets the path used to open this filter.
+ /// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip/path/to/file.bin
+ /// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip\path\to\file.bin + ///
+ /// Path used to open this filter. + string GetBasePath(); + + /// + /// Gets creation time of file referenced by this filter. + /// + /// The creation time. + DateTime GetCreationTime(); + + /// + /// Gets length of this filter's data fork. + /// + /// The data fork length. + long GetDataForkLength(); + + /// + /// Gets a stream to access the data fork contents. + /// + /// The data fork stream. + Stream GetDataForkStream(); + + /// + /// Gets the filename for the file referenced by this filter.
+ /// UNIX: /path/to/archive.zip/path/to/file.bin => file.bin
+ /// Windows: C:\path\to\archive.zip\path\to\file.bin => file.bin + ///
+ /// The filename. + string GetFilename(); + + /// + /// Gets last write time of file referenced by this filter. + /// + /// The last write time. + DateTime GetLastWriteTime(); + + /// + /// Gets length of file referenced by ths filter. + /// + /// The length. + long GetLength(); + + /// + /// Gets full path to file referenced by this filter. If it's an archive, it's the path inside the archive.
+ /// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/file.bin
+ /// Windows: C:\path\to\archive.zip\path\to\file.bin => \path\to\file.bin + ///
+ /// The path. + string GetPath(); + + /// + /// 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.
+ /// UNIX: /path/to/archive.zip/path/to/file.bin => /path/to/archive.zip
+ /// Windows: C:\path\to\archive.zip\path\to\file.bin => C:\path\to\archive.zip + ///
+ /// The parent folder. + string GetParentFolder(); + + /// + /// Gets length of this filter's resource fork. + /// + /// The resource fork length. + long GetResourceForkLength(); + + /// + /// Gets a stream to access the resource fork contents. + /// + /// The resource fork stream. + Stream GetResourceForkStream(); + + /// + /// Returns true if the file referenced by this filter has a resource fork + /// + bool HasResourceFork(); + + /// + /// Identifies if the specified path contains data recognizable by this filter instance + /// + /// Path. + bool Identify(string path); + + /// + /// Identifies if the specified stream contains data recognizable by this filter instance + /// + /// Stream. + bool Identify(Stream stream); + + /// + /// Identifies if the specified buffer contains data recognizable by this filter instance + /// + /// Buffer. + bool Identify(byte[] buffer); + + /// + /// Returns true if the filter has a file/stream/buffer currently opened and no + /// has been issued. + /// + bool IsOpened(); + + /// + /// Opens the specified path with this filter instance + /// + /// Path. + void Open(string path); + + /// + /// Opens the specified stream with this filter instance + /// + /// Stream. + void Open(Stream stream); + + /// + /// Opens the specified buffer with this filter instance + /// + /// Buffer. + void Open(byte[] buffer); + } +} \ No newline at end of file diff --git a/Interfaces/IFloppyImage.cs b/Interfaces/IFloppyImage.cs new file mode 100644 index 0000000..b392df3 --- /dev/null +++ b/Interfaces/IFloppyImage.cs @@ -0,0 +1,129 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IFloppyImage.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines interface to be implemented by floppy image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// 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 . + /// All data returned by these methods is already decoded from its corresponding bitstream. + /// + public interface IFloppyImage : IMediaImage + { + /// + /// Floppy info, contains information about physical characteristics of floppy, like size, bitrate, track density, + /// etc... + /// + FloppyInfo FloppyInfo { get; } + + /// + /// Reads a sector's user data. + /// + /// + /// If is one of the duplicates is returned + /// randomly. + /// If is or + /// random data is returned. + /// If is null is returned. + /// Otherwise, whatever is in the sector is returned. + /// + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of request. + byte[] ReadSector(ushort track, byte head, ushort sector, out FloppySectorStatus status); + + /// + /// Reads a sector's tag. + /// + /// + /// If is one of the duplicates is returned + /// randomly. + /// If is or + /// random data is returned. + /// If is null is returned. + /// Otherwise, whatever tag is in the sector is returned. + /// + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of request. + byte[] ReadSectorTag(ushort track, byte head, ushort sector, out FloppySectorStatus status, SectorTagType tag); + + /// + /// Reads a whole track. It includes all gaps, address marks, sectors data, etc. + /// + /// The track data. + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + byte[] ReadTrack(ushort track, byte head); + + /// + /// Reads a sector's data including all tags, address mark, and so, in a format dependent of represented media. + /// + /// + /// If is one of the duplicates is returned + /// randomly. + /// If is or + /// random data is returned. + /// If is null is returned. + /// Otherwise, whatever is in the sector is returned. + /// + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of request. + byte[] ReadSectorLong(ushort track, byte head, ushort sector, out FloppySectorStatus status); + + /// + /// Verifies a track. + /// + /// True if correct, false if incorrect, null if uncheckable. + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + bool? VerifyTrack(ushort track, byte head); + + /// + /// Verifies a sector, relative to track. + /// + /// True if correct, false if incorrect, null if uncheckable. + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of request. + bool? VerifySector(ushort track, byte head, ushort sector); + } +} \ No newline at end of file diff --git a/Interfaces/IMediaImage.cs b/Interfaces/IMediaImage.cs new file mode 100644 index 0000000..20ffa4e --- /dev/null +++ b/Interfaces/IMediaImage.cs @@ -0,0 +1,257 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IMediaImage.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines interface to be implemented by disc image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Structs; +using Schemas; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// Abstract class to implement disk image reading plugins. + /// + public interface IMediaImage + { + /// Image information + ImageInfo Info { get; } + /// Plugin name. + string Name { get; } + /// Plugin UUID. + Guid Id { get; } + /// + /// Gets the image format. + /// + /// The image format. + string Format { get; } + /// + /// 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. + /// + /// The partitions. + List Partitions { get; } + /// + /// Gets the disc track extents (start, length). + /// + /// The track extents. + List Tracks { get; } + /// + /// Gets the sessions (optical discs only). + /// + /// The sessions. + List Sessions { get; } + /// List of dump hardware used to create the image from real media + List DumpHardware { get; } + /// Gets the CICM XML metadata for the image + CICMMetadataType CicmMetadata { get; } + + /// + /// Identifies the image. + /// + /// true, if image was identified, false otherwise. + /// Image filter. + bool Identify(IFilter imageFilter); + + /// + /// Opens the image. + /// + /// true, if image was opened, false otherwise. + /// Image filter. + bool Open(IFilter imageFilter); + + /// + /// Reads a disk tag. + /// + /// Disk tag + /// Tag type to read. + byte[] ReadDiskTag(MediaTagType tag); + + /// + /// Reads a sector's user data. + /// + /// The sector's user data. + /// Sector address (LBA). + byte[] ReadSector(ulong sectorAddress); + + /// + /// Reads a sector's tag. + /// + /// The sector's tag. + /// Sector address (LBA). + /// Tag type. + byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag); + + /// + /// Reads a sector's user data, relative to track. + /// + /// The sector's user data. + /// Sector address (relative LBA). + /// Track. + byte[] ReadSector(ulong sectorAddress, uint track); + + /// + /// Reads a sector's tag, relative to track. + /// + /// The sector's tag. + /// Sector address (relative LBA). + /// Track. + /// Tag type. + byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag); + + /// + /// Reads user data from several sectors. + /// + /// The sectors user data. + /// Starting sector address (LBA). + /// How many sectors to read. + byte[] ReadSectors(ulong sectorAddress, uint length); + + /// + /// Reads tag from several sectors. + /// + /// The sectors tag. + /// Starting sector address (LBA). + /// How many sectors to read. + /// Tag type. + byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag); + + /// + /// Reads user data from several sectors, relative to track. + /// + /// The sectors user data. + /// Starting sector address (relative LBA). + /// How many sectors to read. + /// Track. + byte[] ReadSectors(ulong sectorAddress, uint length, uint track); + + /// + /// Reads tag from several sectors, relative to track. + /// + /// The sectors tag. + /// Starting sector address (relative LBA). + /// How many sectors to read. + /// Track. + /// Tag type. + byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag); + + /// + /// Reads a complete sector (user data + all tags). + /// + /// The complete sector. Format depends on disk type. + /// Sector address (LBA). + byte[] ReadSectorLong(ulong sectorAddress); + + /// + /// Reads a complete sector (user data + all tags), relative to track. + /// + /// The complete sector. Format depends on disk type. + /// Sector address (relative LBA). + /// Track. + byte[] ReadSectorLong(ulong sectorAddress, uint track); + + /// + /// Reads several complete sector (user data + all tags). + /// + /// The complete sectors. Format depends on disk type. + /// Starting sector address (LBA). + /// How many sectors to read. + byte[] ReadSectorsLong(ulong sectorAddress, uint length); + + /// + /// Reads several complete sector (user data + all tags), relative to track. + /// + /// The complete sectors. Format depends on disk type. + /// Starting sector address (relative LBA). + /// How many sectors to read. + /// Track. + byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track); + + /// + /// Gets the disc track extents for a specified session. + /// + /// The track exents for that session. + /// Session. + List GetSessionTracks(Session session); + + /// + /// Gets the disc track extents for a specified session. + /// + /// The track exents for that session. + /// Session. + List GetSessionTracks(ushort session); + + /// + /// Verifies a sector. + /// + /// True if correct, false if incorrect, null if uncheckable. + /// Sector address (LBA). + bool? VerifySector(ulong sectorAddress); + + /// + /// Verifies a sector, relative to track. + /// + /// True if correct, false if incorrect, null if uncheckable. + /// Sector address (relative LBA). + /// Track. + bool? VerifySector(ulong sectorAddress, uint track); + + /// + /// Verifies several sectors. + /// + /// True if all are correct, false if any is incorrect, null if any is uncheckable. + /// Starting sector address (LBA). + /// How many sectors to read. + /// List of incorrect sectors + /// List of uncheckable sectors + bool? VerifySectors(ulong sectorAddress, uint length, out List failingLbas, out List unknownLbas); + + /// + /// Verifies several sectors, relative to track. + /// + /// True if all are correct, false if any is incorrect, null if any is uncheckable. + /// Starting sector address (relative LBA). + /// How many sectors to read. + /// Track. + /// List of incorrect sectors + /// List of uncheckable sectors + bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List failingLbas, + out List unknownLbas); + + /// + /// Verifies media image internal checksum. + /// + /// True if correct, false if incorrect, null if there is no internal checksum available + bool? VerifyMediaImage(); + } +} \ No newline at end of file diff --git a/Interfaces/IPartition.cs b/Interfaces/IPartition.cs new file mode 100644 index 0000000..a19216b --- /dev/null +++ b/Interfaces/IPartition.cs @@ -0,0 +1,60 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IPartition.cs +// Author(s) : Natalia Portillo +// +// Component : Partitioning scheme plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines methods to be used by partitioning scheme plugins and several +// constants. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes; +using DiscImageChef.CommonTypes.Interfaces; + +namespace DiscImageChef.Partitions +{ + /// + /// Abstract class to implement partitioning schemes interpreting plugins. + /// + public interface IPartition + { + /// Plugin name. + string Name { get; } + /// Plugin UUID. + Guid Id { get; } + + /// + /// Interprets a partitioning scheme. + /// + /// true, if partitioning scheme is recognized, false otherwise. + /// Disk image. + /// Returns list of partitions. + /// At which sector to start searching for the partition scheme. + bool GetInformation(IMediaImage imagePlugin, out List partitions, ulong sectorOffset); + } +} \ No newline at end of file diff --git a/Interfaces/IReadOnlyFilesystem.cs b/Interfaces/IReadOnlyFilesystem.cs new file mode 100644 index 0000000..deeb4c1 --- /dev/null +++ b/Interfaces/IReadOnlyFilesystem.cs @@ -0,0 +1,138 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IReadOnlyFilesystem.cs +// Author(s) : Natalia Portillo +// +// Component : Filesystem plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Interface for filesystem plugins that offer read-only support of their +// contents. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Text; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// Interface to implement filesystem plugins. + /// + public interface IReadOnlyFilesystem : IFilesystem + { + /// + /// Retrieves a list of options supported by the filesystem, with name, type and description + /// + IEnumerable<(string name, Type type, string description)> SupportedOptions { get; } + + /// + /// Initializates whatever internal structures the filesystem plugin needs to be able to read files and directories + /// from the filesystem. + /// + /// + /// + /// Which encoding to use for this filesystem. + /// Dictionary of key=value pairs containing options to pass to the filesystem + Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options); + + /// + /// Frees all internal structures created by + /// + /// + Errno Unmount(); + + /// + /// Maps a filesystem block from a file to a block from the underlying device. + /// + /// Error number. + /// File path. + /// File block. + /// Device block. + Errno MapBlock(string path, long fileBlock, out long deviceBlock); + + /// + /// Gets the attributes of a file or directory + /// + /// Error number. + /// File path. + /// File attributes. + Errno GetAttributes(string path, out FileAttributes attributes); + + /// + /// Lists all extended attributes, alternate data streams and forks of the given file. + /// + /// Error number. + /// Path. + /// List of extended attributes, alternate data streams and forks. + Errno ListXAttr(string path, out List xattrs); + + /// + /// Reads an extended attribute, alternate data stream or fork from the given file. + /// + /// Error number. + /// File path. + /// Extendad attribute, alternate data stream or fork name. + /// Buffer. + Errno GetXattr(string path, string xattr, ref byte[] buf); + + /// + /// Reads data from a file (main/only data stream or data fork). + /// + /// File path. + /// Offset. + /// Bytes to read. + /// Buffer. + Errno Read(string path, long offset, long size, ref byte[] buf); + + /// + /// Lists contents from a directory. + /// + /// Directory path. + /// Directory contents. + Errno ReadDir(string path, out List contents); + + /// + /// Gets information about the mounted volume. + /// + /// Information about the mounted volume. + Errno StatFs(out FileSystemInfo stat); + + /// + /// Gets information about a file or directory. + /// + /// File path. + /// File information. + Errno Stat(string path, out FileEntryInfo stat); + + /// + /// Solves a symbolic link. + /// + /// Link path. + /// Link destination. + Errno ReadLink(string path, out string dest); + } +} \ No newline at end of file diff --git a/Interfaces/IWritableFloppyImage.cs b/Interfaces/IWritableFloppyImage.cs new file mode 100644 index 0000000..1dec8d5 --- /dev/null +++ b/Interfaces/IWritableFloppyImage.cs @@ -0,0 +1,98 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IFloppyImage.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines interface to be implemented by floppy image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// 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 . + /// All data expected by these methods is already decoded from its corresponding bitstream. + /// + public interface IWritableFloppyImage : IFloppyImage, IWritableImage + { + /// + /// Indicates the image plugin the floppy physical characteristics and must be called before following methods are + /// called. Once this is called, LBA-based methods should not be used. + /// + /// + /// Floppy info, contains information about physical characteristics of floppy, like size, bitrate, + /// track density, etc... + /// + /// true if operating completed successfully, false otherwise + bool SetFloppyCharacteristics(FloppyInfo info); + + /// + /// Writes a sector's user data. + /// + /// + /// If is one of the duplicates. + /// If is , , + /// it will be ignored. + /// Otherwise, whatever data should be in the sector. + /// + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of sector. + /// true if operating completed successfully, false otherwise + bool WriteSector(byte[] data, ushort track, byte head, ushort sector, FloppySectorStatus status); + + /// + /// Writes a whole track, including all gaps, address marks, sectors data, etc. + /// + /// The track data. + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// true if operating completed successfully, false otherwise + bool WriteTrack(byte[] data, ushort track, byte head); + + /// + /// Writes a sector's data including all tags, address mark, and so, in a format dependent of represented media. + /// + /// + /// If is one of the duplicates. + /// If is , , + /// it will be ignored. + /// Otherwise, whatever data should be in the sector. + /// + /// Physical track (position of the heads over the floppy media, 0-based). + /// Physical head (0-based). + /// Logical sector ID. + /// Status of request. + /// true if operating completed successfully, false otherwise + bool WriteSectorLong(byte[] data, ushort track, byte head, ushort sector, out FloppySectorStatus status); + } +} \ No newline at end of file diff --git a/Interfaces/IWritableImage.cs b/Interfaces/IWritableImage.cs new file mode 100644 index 0000000..8dadc92 --- /dev/null +++ b/Interfaces/IWritableImage.cs @@ -0,0 +1,186 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IWritableImage.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines interface to be implemented by writable image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Structs; +using Schemas; + +namespace DiscImageChef.CommonTypes.Interfaces +{ + /// + /// Abstract class to implement disk image writing plugins. + /// TODO: This interface is subject to change until notice. + /// + public interface IWritableImage : IMediaImage + { + /// + /// Gets a list of that are supported by the media image format + /// + IEnumerable SupportedMediaTags { get; } + /// + /// Gets a list of that are supported by the media image format + /// + IEnumerable SupportedSectorTags { get; } + /// + /// Gets a list of that are supported by the media image format + /// + IEnumerable SupportedMediaTypes { get; } + /// + /// Retrieves a list of options supported by the filesystem, with name, type and description + /// + IEnumerable<(string name, Type type, string description)> SupportedOptions { get; } + /// + /// Gets a list of known extensions for format auto-chosing + /// + IEnumerable KnownExtensions { get; } + + bool IsWriting { get; } + string ErrorMessage { get; } + + /// + /// Creates a new image in the specified path, for the specified , with the + /// specified options to hold a media with the specified number of sectors + /// + /// Path to the new image, with extension + /// that will be written in the image + /// Options to be used when creating new image + /// How many sectors the media has. + /// + /// true if operating completed successfully, false otherwise + bool Create(string path, MediaType mediaType, Dictionary options, ulong sectors, + uint sectorSize); + + /// + /// Writes a media tag to the image + /// + /// Media tag + /// + /// + /// + /// true if operating completed successfully, false otherwise + bool WriteMediaTag(byte[] data, MediaTagType tag); + + /// + /// Writes a sector to the image + /// + /// Sector data + /// Sector address + /// true if operating completed successfully, false otherwise + bool WriteSector(byte[] data, ulong sectorAddress); + + /// + /// Writes several sectors to the image + /// + /// Sectors data + /// Sector starting address + /// How many sectors to write + /// true if operating completed successfully, false otherwise + bool WriteSectors(byte[] data, ulong sectorAddress, uint length); + + /// + /// Writes a sector to the image with main channel tags attached + /// + /// Sector data with its main channel tags attached + /// Sector address + /// true if operating completed successfully, false otherwise + bool WriteSectorLong(byte[] data, ulong sectorAddress); + + /// + /// Writes several sectors to the image + /// + /// Sector data with their main channel tags attached + /// Sector starting address + /// How many sectors to write + /// true if operating completed successfully, false otherwise + bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length); + + /// + /// Sets tracks for optical media + /// + /// List of tracks + /// true if operating completed successfully, false otherwise + bool SetTracks(List tracks); + + /// + /// Closes and flushes to disk the image + /// + /// true if operating completed successfully, false otherwise + bool Close(); + + /// + /// Sets image metadata + /// + /// containing image metadata + /// true if operating completed successfully, false otherwise + bool SetMetadata(ImageInfo metadata); + + /// + /// Sets media geometry + /// + /// Cylinders + /// Heads + /// Sectors per track + /// true if operating completed successfully, false otherwise + bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack); + + /// + /// Writes parallel or subchannel sector tag for one sector + /// + /// Tag data to write + /// Sector address + /// Tag type + /// true if operating completed successfully, false otherwise + bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag); + + /// + /// Writes parallel or subchannel sector tag for several sector + /// + /// Tag data to write + /// Starting sector address + /// How many sectors to write + /// Tag type + /// true if operating completed successfully, false otherwise + bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag); + + /// + /// Sets the list of dump hardware used to create the image from real media + /// + bool SetDumpHardware(List dumpHardware); + + /// + /// Sets the CICM XML metadata for the image + /// + bool SetCicmMetadata(CICMMetadataType metadata); + } +} \ No newline at end of file diff --git a/Interop/DetectOS.cs b/Interop/DetectOS.cs new file mode 100644 index 0000000..af2b86c --- /dev/null +++ b/Interop/DetectOS.cs @@ -0,0 +1,306 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : DetectOS.cs +// Author(s) : Natalia Portillo +// +// Component : Interop services. +// +// --[ Description ] ---------------------------------------------------------- +// +// Detects underlying operating system. +// +// --[ License ] -------------------------------------------------------------- +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +namespace DiscImageChef.CommonTypes.Interop +{ + public static class DetectOS + { + public static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; + + /// + /// Checks if the underlying runtime runs in 64-bit mode + /// + public static readonly bool Is64Bit = IntPtr.Size == 8; + + /// + /// Checks if the underlying runtime runs in 32-bit mode + /// + public static readonly bool Is32Bit = IntPtr.Size == 4; + + [DllImport("libc", SetLastError = true)] + static extern int uname(out utsname name); + + [DllImport("libc", SetLastError = true, EntryPoint = "sysctlbyname", CharSet = CharSet.Ansi)] + static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen); + + /// + /// Gets the real platform ID, not the incomplete .NET framework one + /// + /// Platform ID + /// Unhandled exception + public static PlatformID GetRealPlatformID() + { + 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()}"); + + switch(unixname.sysname) + { + // TODO: Differentiate Linux, Android, Tizen + case "Linux": + { + #if __ANDROID__ + return PlatformID.Android; + #else + return PlatformID.Linux; + #endif + } + 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); + + throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}"); + } + + 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); + Marshal.FreeHGlobal(pLen); + + throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}"); + } + + string machine = Marshal.PtrToStringAnsi(pStr); + + Marshal.FreeHGlobal(pStr); + Marshal.FreeHGlobal(pLen); + + 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; + default: + { + 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; + + return PlatformID.Unknown; + } + } + } + + /// + /// Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying) + /// + /// Current operating system version + public static string GetVersion() + { + string environ = Environment.OSVersion.Version.ToString(); + + switch(GetRealPlatformID()) + { + case PlatformID.MacOSX: + if(Environment.OSVersion.Version.Major != 1) + 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"; + } + + goto default; + case PlatformID.Win32NT: + // 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), + "KERNEL32.DLL")).ProductVersion; + + return environ; + default: return environ; + } + } + + /// + /// From a platform ID and version returns a human-readable version + /// + /// Platform ID + /// Version number + /// Operating system name + public static string GetPlatformName(PlatformID id, string version = null) + { + 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.Linux: return "Linux"; + case PlatformID.MacOSX: + 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"; + + 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(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"; + + 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"; + + 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(); + } + } + + /// + /// POSIX uname structure, size from OSX, big enough to handle extra fields + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + struct utsname + { + /// + /// System name + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string sysname; + /// + /// Node name + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string nodename; + /// + /// Release level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string release; + /// + /// Version level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string version; + /// + /// Hardware level + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string machine; + } + } +} \ No newline at end of file diff --git a/Interop/PlatformID.cs b/Interop/PlatformID.cs new file mode 100644 index 0000000..d3bcb88 --- /dev/null +++ b/Interop/PlatformID.cs @@ -0,0 +1,192 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : PlatformID.cs +// Author(s) : Natalia Portillo +// +// Component : Interop services. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains an enhanced PlatformID enumeration. +// +// --[ License ] -------------------------------------------------------------- +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +namespace DiscImageChef.CommonTypes.Interop +{ + /// + /// Contains an arbitrary list of OSes, even if .NET does not run on them + /// + public enum PlatformID + { + /// + /// Win32s + /// + Win32S = 0, + /// + /// Win32 (Windows 9x) + /// + Win32Windows = 1, + /// + /// Windows NT + /// + Win32NT = 2, + /// + /// Windows Mobile + /// + WinCE = 3, + /// + /// UNIX (do not use, too generic) + /// + Unix = 4, + /// + /// Xbox 360 + /// + Xbox = 5, + /// + /// OS X + /// + MacOSX = 6, + /// + /// iOS is not OS X + /// + iOS = 7, + /// + /// Linux + /// + Linux = 8, + /// + /// Sun Solaris + /// + Solaris = 9, + /// + /// NetBSD + /// + NetBSD = 10, + /// + /// OpenBSD + /// + OpenBSD = 11, + /// + /// FreeBSD + /// + FreeBSD = 12, + /// + /// DragonFly BSD + /// + DragonFly = 13, + /// + /// Nintendo Wii + /// + Wii = 14, + /// + /// Nintendo Wii U + /// + WiiU = 15, + /// + /// Sony PlayStation 3 + /// + PlayStation3 = 16, + /// + /// Sony Playstation 4 + /// + PlayStation4 = 17, + /// + /// Google Android + /// + Android = 18, + /// + /// Samsung Tizen + /// + Tizen = 19, + /// + /// Windows Phone + /// + WindowsPhone = 20, + /// + /// GNU/Hurd + /// + Hurd = 21, + /// + /// Haiku + /// + Haiku = 22, + /// + /// HP-UX + /// + HPUX = 23, + /// + /// AIX + /// + AIX = 24, + /// + /// OS/400 + /// + OS400 = 25, + /// + /// IRIX + /// + IRIX = 26, + /// + /// Minix + /// + Minix = 27, + /// + /// NonStop + /// + NonStop = 28, + /// + /// QNX + /// + QNX = 29, + /// + /// SINIX + /// + SINIX = 30, + /// + /// Tru64 UNIX + /// + Tru64 = 31, + /// + /// Ultrix + /// + Ultrix = 32, + /// + /// SCO OpenServer / SCO UNIX + /// + OpenServer = 33, + /// + /// SCO UnixWare + /// + UnixWare = 34, + /// + /// IBM z/OS + /// + zOS = 35, + Unknown = -1 + } +} \ No newline at end of file diff --git a/Interop/Version.cs b/Interop/Version.cs new file mode 100644 index 0000000..58d6b20 --- /dev/null +++ b/Interop/Version.cs @@ -0,0 +1,79 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Version.cs +// Author(s) : Natalia Portillo +// +// Component : Interop services. +// +// --[ Description ] ---------------------------------------------------------- +// +// Returns DiscImageChef version. +// +// --[ License ] -------------------------------------------------------------- +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Reflection; +using System.Runtime; + +namespace DiscImageChef.CommonTypes.Interop +{ + public static class Version + { + /// + /// Gets version string + /// + /// Version + public static string GetVersion() + { + return typeof(Version).Assembly.GetName().Version.ToString(); + } + + public static string GetNetCoreVersion() + { + Assembly assembly = typeof(GCSettings).Assembly; + string[] assemblyPath = + assembly.CodeBase.Split(new[] {'/', '\\'}, StringSplitOptions.RemoveEmptyEntries); + int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); + if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) + return assemblyPath[netCoreAppIndex + 1]; + + return null; + } + + public static string GetMonoVersion() + { + 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); + + return null; + } + } +} \ No newline at end of file diff --git a/Metadata/DeviceReport.cs b/Metadata/DeviceReport.cs new file mode 100644 index 0000000..a104106 --- /dev/null +++ b/Metadata/DeviceReport.cs @@ -0,0 +1,1051 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : DeviceReport.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains classes for an XML device report. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Xml.Serialization; +using DiscImageChef.Decoders.ATA; +using DiscImageChef.Decoders.SCSI; +using DiscImageChef.Decoders.SCSI.MMC; + +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedAutoPropertyAccessor.Global + +namespace DiscImageChef.CommonTypes.Metadata +{ + [Serializable] + [XmlRoot("DicDeviceReport", Namespace = "", IsNullable = false)] + public class DeviceReport + { + public usbType USB { get; set; } + public firewireType FireWire { get; set; } + public pcmciaType PCMCIA { get; set; } + public bool CompactFlash { get; set; } + public ataType ATA { get; set; } + public ataType ATAPI { get; set; } + public scsiType SCSI { get; set; } + public mmcsdType MultiMediaCard { get; set; } + public mmcsdType SecureDigital { get; set; } + + [XmlIgnore] + public bool CompactFlashSpecified { get; set; } + } + + public class usbType + { + public ushort VendorID { get; set; } + public ushort ProductID { get; set; } + public string Manufacturer { get; set; } + public string Product { get; set; } + public bool RemovableMedia { get; set; } + public byte[] Descriptors { get; set; } + } + + public class firewireType + { + public uint VendorID { get; set; } + public uint ProductID { get; set; } + public string Manufacturer { get; set; } + public string Product { get; set; } + public bool RemovableMedia { get; set; } + } + + public class ataType + { + public string AdditionalPID { get; set; } + public Identify.TransferMode APIOSupported { get; set; } + public ushort ATAPIByteCount { get; set; } + public ushort BufferType { get; set; } + public ushort BufferSize { get; set; } + public Identify.CapabilitiesBit Capabilities { get; set; } + public Identify.CapabilitiesBit2 Capabilities2 { get; set; } + public Identify.CapabilitiesBit3 Capabilities3 { get; set; } + public ushort CFAPowerMode { get; set; } + public Identify.CommandSetBit CommandSet { get; set; } + public Identify.CommandSetBit2 CommandSet2 { get; set; } + public Identify.CommandSetBit3 CommandSet3 { get; set; } + public Identify.CommandSetBit4 CommandSet4 { get; set; } + public Identify.CommandSetBit5 CommandSet5 { get; set; } + public byte CurrentAAM { get; set; } + public ushort CurrentAPM { get; set; } + public Identify.DataSetMgmtBit DataSetMgmt { get; set; } + public ushort DataSetMgmtSize { get; set; } + public Identify.DeviceFormFactorEnum DeviceFormFactor { get; set; } + public Identify.TransferMode DMAActive { get; set; } + public Identify.TransferMode DMASupported { get; set; } + public byte DMATransferTimingMode { get; set; } + public ushort EnhancedSecurityEraseTime { get; set; } + public Identify.CommandSetBit EnabledCommandSet { get; set; } + public Identify.CommandSetBit2 EnabledCommandSet2 { get; set; } + public Identify.CommandSetBit3 EnabledCommandSet3 { get; set; } + public Identify.CommandSetBit4 EnabledCommandSet4 { get; set; } + public Identify.SATAFeaturesBit EnabledSATAFeatures { get; set; } + public ulong ExtendedUserSectors { get; set; } + public byte FreeFallSensitivity { get; set; } + public string FirmwareRevision { get; set; } + public Identify.GeneralConfigurationBit GeneralConfiguration { get; set; } + public ushort HardwareResetResult { get; set; } + public ushort InterseekDelay { get; set; } + public Identify.MajorVersionBit MajorVersion { get; set; } + public ushort MasterPasswordRevisionCode { get; set; } + public ushort MaxDownloadMicroMode3 { get; set; } + public ushort MaxQueueDepth { get; set; } + public Identify.TransferMode MDMAActive { get; set; } + public Identify.TransferMode MDMASupported { get; set; } + public ushort MinDownloadMicroMode3 { get; set; } + public ushort MinMDMACycleTime { get; set; } + public ushort MinorVersion { get; set; } + public ushort MinPIOCycleTimeNoFlow { get; set; } + public ushort MinPIOCycleTimeFlow { get; set; } + public string Model { get; set; } + public byte MultipleMaxSectors { get; set; } + public byte MultipleSectorNumber { get; set; } + public ushort NVCacheCaps { get; set; } + public uint NVCacheSize { get; set; } + public ushort NVCacheWriteSpeed { get; set; } + public byte NVEstimatedSpinUp { get; set; } + public ushort PacketBusRelease { get; set; } + public byte PIOTransferTimingMode { get; set; } + public byte RecommendedAAM { get; set; } + public ushort RecommendedMDMACycleTime { get; set; } + public ushort RemovableStatusSet { get; set; } + public Identify.SATACapabilitiesBit SATACapabilities { get; set; } + public Identify.SATACapabilitiesBit2 SATACapabilities2 { get; set; } + public Identify.SATAFeaturesBit SATAFeatures { get; set; } + public Identify.SCTCommandTransportBit SCTCommandTransport { get; set; } + public uint SectorsPerCard { get; set; } + public ushort SecurityEraseTime { get; set; } + public Identify.SecurityStatusBit SecurityStatus { get; set; } + public ushort ServiceBusyClear { get; set; } + public Identify.SpecificConfigurationEnum SpecificConfiguration { get; set; } + public ushort StreamAccessLatency { get; set; } + public ushort StreamMinReqSize { get; set; } + public uint StreamPerformanceGranularity { get; set; } + public ushort StreamTransferTimeDMA { get; set; } + public ushort StreamTransferTimePIO { get; set; } + public ushort TransportMajorVersion { get; set; } + public ushort TransportMinorVersion { get; set; } + public Identify.TrustedComputingBit TrustedComputing { get; set; } + public Identify.TransferMode UDMAActive { get; set; } + public Identify.TransferMode UDMASupported { get; set; } + public byte WRVMode { get; set; } + public uint WRVSectorCountMode3 { get; set; } + public uint WRVSectorCountMode2 { get; set; } + + public byte[] Identify { get; set; } + + public testedMediaType ReadCapabilities { get; set; } + public testedMediaType[] RemovableMedias { get; set; } + + [XmlIgnore] + public bool AdditionalPIDSpecified { get; set; } + [XmlIgnore] + public bool APIOSupportedSpecified { get; set; } + [XmlIgnore] + public bool ATAPIByteCountSpecified { get; set; } + [XmlIgnore] + public bool BufferTypeSpecified { get; set; } + [XmlIgnore] + public bool BufferSizeSpecified { get; set; } + [XmlIgnore] + public bool CapabilitiesSpecified { get; set; } + [XmlIgnore] + public bool Capabilities2Specified { get; set; } + [XmlIgnore] + public bool Capabilities3Specified { get; set; } + [XmlIgnore] + public bool CFAPowerModeSpecified { get; set; } + [XmlIgnore] + public bool CommandSetSpecified { get; set; } + [XmlIgnore] + public bool CommandSet2Specified { get; set; } + [XmlIgnore] + public bool CommandSet3Specified { get; set; } + [XmlIgnore] + public bool CommandSet4Specified { get; set; } + [XmlIgnore] + public bool CommandSet5Specified { get; set; } + [XmlIgnore] + public bool CurrentAAMSpecified { get; set; } + [XmlIgnore] + public bool CurrentAPMSpecified { get; set; } + [XmlIgnore] + public bool DataSetMgmtSpecified { get; set; } + [XmlIgnore] + public bool DataSetMgmtSizeSpecified { get; set; } + [XmlIgnore] + public bool DeviceFormFactorSpecified { get; set; } + [XmlIgnore] + public bool DMAActiveSpecified { get; set; } + [XmlIgnore] + public bool DMASupportedSpecified { get; set; } + [XmlIgnore] + public bool DMATransferTimingModeSpecified { get; set; } + [XmlIgnore] + public bool EnhancedSecurityEraseTimeSpecified { get; set; } + [XmlIgnore] + public bool EnabledCommandSetSpecified { get; set; } + [XmlIgnore] + public bool EnabledCommandSet2Specified { get; set; } + [XmlIgnore] + public bool EnabledCommandSet3Specified { get; set; } + [XmlIgnore] + public bool EnabledCommandSet4Specified { get; set; } + [XmlIgnore] + public bool EnabledSATAFeaturesSpecified { get; set; } + [XmlIgnore] + public bool ExtendedIdentifySpecified { get; set; } + [XmlIgnore] + public bool ExtendedUserSectorsSpecified { get; set; } + [XmlIgnore] + public bool FreeFallSensitivitySpecified { get; set; } + [XmlIgnore] + public bool FirmwareRevisionSpecified { get; set; } + [XmlIgnore] + public bool GeneralConfigurationSpecified { get; set; } + [XmlIgnore] + public bool HardwareResetResultSpecified { get; set; } + [XmlIgnore] + public bool InterseekDelaySpecified { get; set; } + [XmlIgnore] + public bool MajorVersionSpecified { get; set; } + [XmlIgnore] + public bool MasterPasswordRevisionCodeSpecified { get; set; } + [XmlIgnore] + public bool MaxDownloadMicroMode3Specified { get; set; } + [XmlIgnore] + public bool MaxQueueDepthSpecified { get; set; } + [XmlIgnore] + public bool MDMAActiveSpecified { get; set; } + [XmlIgnore] + public bool MDMASupportedSpecified { get; set; } + [XmlIgnore] + public bool MinDownloadMicroMode3Specified { get; set; } + [XmlIgnore] + public bool MinMDMACycleTimeSpecified { get; set; } + [XmlIgnore] + public bool MinorVersionSpecified { get; set; } + [XmlIgnore] + public bool MinPIOCycleTimeNoFlowSpecified { get; set; } + [XmlIgnore] + public bool MinPIOCycleTimeFlowSpecified { get; set; } + [XmlIgnore] + public bool ModelSpecified { get; set; } + [XmlIgnore] + public bool MultipleMaxSectorsSpecified { get; set; } + [XmlIgnore] + public bool MultipleSectorNumberSpecified { get; set; } + [XmlIgnore] + public bool NVCacheCapsSpecified { get; set; } + [XmlIgnore] + public bool NVCacheSizeSpecified { get; set; } + [XmlIgnore] + public bool NVCacheWriteSpeedSpecified { get; set; } + [XmlIgnore] + public bool NVEstimatedSpinUpSpecified { get; set; } + [XmlIgnore] + public bool PacketBusReleaseSpecified { get; set; } + [XmlIgnore] + public bool PIOTransferTimingModeSpecified { get; set; } + [XmlIgnore] + public bool RecommendedAAMSpecified { get; set; } + [XmlIgnore] + public bool RecommendedMDMACycleTimeSpecified { get; set; } + [XmlIgnore] + public bool RemovableStatusSetSpecified { get; set; } + [XmlIgnore] + public bool SATACapabilitiesSpecified { get; set; } + [XmlIgnore] + public bool SATACapabilities2Specified { get; set; } + [XmlIgnore] + public bool SATAFeaturesSpecified { get; set; } + [XmlIgnore] + public bool SCTCommandTransportSpecified { get; set; } + [XmlIgnore] + public bool SectorsPerCardSpecified { get; set; } + [XmlIgnore] + public bool SecurityEraseTimeSpecified { get; set; } + [XmlIgnore] + public bool SecurityStatusSpecified { get; set; } + [XmlIgnore] + public bool ServiceBusyClearSpecified { get; set; } + [XmlIgnore] + public bool SpecificConfigurationSpecified { get; set; } + [XmlIgnore] + public bool StreamAccessLatencySpecified { get; set; } + [XmlIgnore] + public bool StreamMinReqSizeSpecified { get; set; } + [XmlIgnore] + public bool StreamPerformanceGranularitySpecified { get; set; } + [XmlIgnore] + public bool StreamTransferTimeDMASpecified { get; set; } + [XmlIgnore] + public bool StreamTransferTimePIOSpecified { get; set; } + [XmlIgnore] + public bool TransportMajorVersionSpecified { get; set; } + [XmlIgnore] + public bool TransportMinorVersionSpecified { get; set; } + [XmlIgnore] + public bool TrustedComputingSpecified { get; set; } + [XmlIgnore] + public bool UDMAActiveSpecified { get; set; } + [XmlIgnore] + public bool UDMASupportedSpecified { get; set; } + [XmlIgnore] + public bool WRVModeSpecified { get; set; } + [XmlIgnore] + public bool WRVSectorCountMode3Specified { get; set; } + [XmlIgnore] + public bool WRVSectorCountMode2Specified { get; set; } + } + + public class chsType + { + public ushort Cylinders { get; set; } + public ushort Heads { get; set; } + public ushort Sectors { get; set; } + } + + public class scsiType + { + public scsiInquiryType Inquiry { get; set; } + public pageType[] EVPDPages { get; set; } + public bool SupportsModeSense6 { get; set; } + public bool SupportsModeSense10 { get; set; } + public bool SupportsModeSubpages { get; set; } + public modeType ModeSense { get; set; } + public mmcType MultiMediaDevice { get; set; } + public testedMediaType ReadCapabilities { get; set; } + public testedMediaType[] RemovableMedias { get; set; } + public sscType SequentialDevice { get; set; } + public byte[] ModeSense6Data { get; set; } + public byte[] ModeSense10Data { get; set; } + + [XmlIgnore] + public bool ReadCapabilitiesSpecified { get; set; } + } + + public class scsiInquiryType + { + public bool AccessControlCoordinator { get; set; } + public bool ACKRequests { get; set; } + public bool AERCSupported { get; set; } + public bool Address16 { get; set; } + public bool Address32 { get; set; } + public byte ANSIVersion { get; set; } + public TGPSValues AsymmetricalLUNAccess { get; set; } + public bool BasicQueueing { get; set; } + public byte DeviceTypeModifier { get; set; } + public byte ECMAVersion { get; set; } + public bool EnclosureServices { get; set; } + public bool HierarchicalLUN { get; set; } + public bool IUS { get; set; } + public byte ISOVersion { get; set; } + public bool LinkedCommands { get; set; } + public bool MediumChanger { get; set; } + public bool MultiPortDevice { get; set; } + public bool NormalACA { get; set; } + public PeripheralDeviceTypes PeripheralDeviceType { get; set; } + public PeripheralQualifiers PeripheralQualifier { get; set; } + public string ProductIdentification { get; set; } + public string ProductRevisionLevel { get; set; } + public bool Protection { get; set; } + public bool QAS { get; set; } + public bool RelativeAddressing { get; set; } + public bool Removable { get; set; } + public byte ResponseDataFormat { get; set; } + public bool TaggedCommandQueue { get; set; } + public bool TerminateTaskSupported { get; set; } + public bool ThirdPartyCopy { get; set; } + public bool TranferDisable { get; set; } + public bool SoftReset { get; set; } + public SPIClocking SPIClocking { get; set; } + public bool StorageArrayController { get; set; } + public bool SyncTransfer { get; set; } + public string VendorIdentification { get; set; } + public ushort[] VersionDescriptors { get; set; } + public bool WideBus16 { get; set; } + public bool WideBus32 { get; set; } + public byte[] Data { get; set; } + + [XmlIgnore] + public bool ANSIVersionSpecified { get; set; } + [XmlIgnore] + public bool ECMAVersionSpecified { get; set; } + [XmlIgnore] + public bool DeviceTypeModifierSpecified { get; set; } + [XmlIgnore] + public bool ISOVersionSpecified { get; set; } + [XmlIgnore] + public bool ProductIdentificationSpecified { get; set; } + [XmlIgnore] + public bool ProductRevisionLevelSpecified { get; set; } + [XmlIgnore] + public bool ResponseDataFormatSpecified { get; set; } + [XmlIgnore] + public bool VendorIdentificationSpecified { get; set; } + } + + [Serializable] + public class pageType + { + [XmlAttribute] + public byte page { get; set; } + + [XmlText] + public byte[] value { get; set; } + } + + public class modeType + { + public byte MediumType { get; set; } + public bool WriteProtected { get; set; } + public blockDescriptorType[] BlockDescriptors { get; set; } + public byte Speed { get; set; } + public byte BufferedMode { get; set; } + public bool BlankCheckEnabled { get; set; } + public bool DPOandFUA { get; set; } + public modePageType[] ModePages { get; set; } + + [XmlIgnore] + public bool MediumTypeSpecified { get; set; } + [XmlIgnore] + public bool SpeedSpecified { get; set; } + [XmlIgnore] + public bool BufferedModeSpecified { get; set; } + } + + public class blockDescriptorType + { + public byte Density { get; set; } + public ulong Blocks { get; set; } + public uint BlockLength { get; set; } + + [XmlIgnore] + public bool BlocksSpecified { get; set; } + [XmlIgnore] + public bool BlockLengthSpecified { get; set; } + } + + [Serializable] + public class modePageType + { + [XmlAttribute] + public byte page { get; set; } + + [XmlAttribute] + public byte subpage { get; set; } + + [XmlText] + public byte[] value { get; set; } + } + + public class mmcType + { + public mmcModeType ModeSense2A { get; set; } + public mmcFeaturesType Features { get; set; } + public testedMediaType[] TestedMedia { get; set; } + } + + public class mmcModeType + { + public bool AccurateCDDA { get; set; } + public bool BCK { get; set; } + public ushort BufferSize { get; set; } + public bool BufferUnderRunProtection { get; set; } + public bool CanEject { get; set; } + public bool CanLockMedia { get; set; } + public bool CDDACommand { get; set; } + public bool CompositeAudioVideo { get; set; } + public bool CSSandCPPMSupported { get; set; } + public ushort CurrentSpeed { get; set; } + public ushort CurrentWriteSpeed { get; set; } + public ushort CurrentWriteSpeedSelected { get; set; } + public bool DeterministicSlotChanger { get; set; } + public bool DigitalPort1 { get; set; } + public bool DigitalPort2 { get; set; } + public bool LeadInPW { get; set; } + public byte LoadingMechanismType { get; set; } + public bool LockStatus { get; set; } + public bool LSBF { get; set; } + public ushort MaximumSpeed { get; set; } + public ushort MaximumWriteSpeed { get; set; } + public bool PlaysAudio { get; set; } + public bool PreventJumperStatus { get; set; } + public bool RCK { get; set; } + public bool ReadsBarcode { get; set; } + public bool ReadsBothSides { get; set; } + public bool ReadsCDR { get; set; } + public bool ReadsCDRW { get; set; } + public bool ReadsDeinterlavedSubchannel { get; set; } + public bool ReadsDVDR { get; set; } + public bool ReadsDVDRAM { get; set; } + public bool ReadsDVDROM { get; set; } + public bool ReadsISRC { get; set; } + public bool ReadsMode2Form2 { get; set; } + public bool ReadsMode2Form1 { get; set; } + public bool ReadsPacketCDR { get; set; } + public bool ReadsSubchannel { get; set; } + public bool ReadsUPC { get; set; } + public bool ReturnsC2Pointers { get; set; } + public byte RotationControlSelected { get; set; } + public bool SeparateChannelMute { get; set; } + public bool SeparateChannelVolume { get; set; } + public bool SSS { get; set; } + public bool SupportsMultiSession { get; set; } + public ushort SupportedVolumeLevels { get; set; } + public bool TestWrite { get; set; } + public bool WritesCDR { get; set; } + public bool WritesCDRW { get; set; } + public bool WritesDVDR { get; set; } + public bool WritesDVDRAM { get; set; } + public Modes.ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors { get; set; } + + [XmlIgnore] + public bool MaximumSpeedSpecified { get; set; } + [XmlIgnore] + public bool SupportedVolumeLevelsSpecified { get; set; } + [XmlIgnore] + public bool BufferSizeSpecified { get; set; } + [XmlIgnore] + public bool CurrentSpeedSpecified { get; set; } + [XmlIgnore] + public bool MaximumWriteSpeedSpecified { get; set; } + [XmlIgnore] + public bool CurrentWriteSpeedSpecified { get; set; } + [XmlIgnore] + public bool RotationControlSelectedSpecified { get; set; } + [XmlIgnore] + public bool CurrentWriteSpeedSelectedSpecified { get; set; } + } + + public class mmcFeaturesType + { + public byte AACSVersion { get; set; } + public byte AGIDs { get; set; } + public byte BindingNonceBlocks { get; set; } + public ushort BlocksPerReadableUnit { get; set; } + public bool BufferUnderrunFreeInDVD { get; set; } + public bool BufferUnderrunFreeInSAO { get; set; } + public bool BufferUnderrunFreeInTAO { get; set; } + public bool CanAudioScan { get; set; } + public bool CanEject { get; set; } + public bool CanEraseSector { get; set; } + public bool CanExpandBDRESpareArea { get; set; } + public bool CanFormat { get; set; } + public bool CanFormatBDREWithoutSpare { get; set; } + public bool CanFormatCert { get; set; } + public bool CanFormatFRF { get; set; } + public bool CanFormatQCert { get; set; } + public bool CanFormatRRM { get; set; } + public bool CanGenerateBindingNonce { get; set; } + public bool CanLoad { get; set; } + public bool CanMuteSeparateChannels { get; set; } + public bool CanOverwriteSAOTrack { get; set; } + public bool CanOverwriteTAOTrack { get; set; } + public bool CanPlayCDAudio { get; set; } + public bool CanPseudoOverwriteBDR { get; set; } + public bool CanReadAllDualR { get; set; } + public bool CanReadAllDualRW { get; set; } + public bool CanReadBD { get; set; } + public bool CanReadBDR { get; set; } + public bool CanReadBDRE1 { get; set; } + public bool CanReadBDRE2 { get; set; } + public bool CanReadBDROM { get; set; } + public bool CanReadBluBCA { get; set; } + public bool CanReadCD { get; set; } + public bool CanReadCDMRW { get; set; } + public bool CanReadCPRM_MKB { get; set; } + public bool CanReadDDCD { get; set; } + public bool CanReadDVD { get; set; } + public bool CanReadDVDPlusMRW { get; set; } + public bool CanReadDVDPlusR { get; set; } + public bool CanReadDVDPlusRDL { get; set; } + public bool CanReadDVDPlusRW { get; set; } + public bool CanReadDVDPlusRWDL { get; set; } + public bool CanReadDriveAACSCertificate { get; set; } + public bool CanReadHDDVD { get; set; } + public bool CanReadHDDVDR { get; set; } + public bool CanReadHDDVDRAM { get; set; } + public bool CanReadLeadInCDText { get; set; } + public bool CanReadOldBDR { get; set; } + public bool CanReadOldBDRE { get; set; } + public bool CanReadOldBDROM { get; set; } + public bool CanReadSpareAreaInformation { get; set; } + public bool CanReportDriveSerial { get; set; } + public bool CanReportMediaSerial { get; set; } + public bool CanTestWriteDDCDR { get; set; } + public bool CanTestWriteDVD { get; set; } + public bool CanTestWriteInSAO { get; set; } + public bool CanTestWriteInTAO { get; set; } + public bool CanUpgradeFirmware { get; set; } + public bool CanWriteBD { get; set; } + public bool CanWriteBDR { get; set; } + public bool CanWriteBDRE1 { get; set; } + public bool CanWriteBDRE2 { get; set; } + public bool CanWriteBusEncryptedBlocks { get; set; } + public bool CanWriteCDMRW { get; set; } + public bool CanWriteCDRW { get; set; } + public bool CanWriteCDRWCAV { get; set; } + public bool CanWriteCDSAO { get; set; } + public bool CanWriteCDTAO { get; set; } + public bool CanWriteCSSManagedDVD { get; set; } + public bool CanWriteDDCDR { get; set; } + public bool CanWriteDDCDRW { get; set; } + public bool CanWriteDVDPlusMRW { get; set; } + public bool CanWriteDVDPlusR { get; set; } + public bool CanWriteDVDPlusRDL { get; set; } + public bool CanWriteDVDPlusRW { get; set; } + public bool CanWriteDVDPlusRWDL { get; set; } + public bool CanWriteDVDR { get; set; } + public bool CanWriteDVDRDL { get; set; } + public bool CanWriteDVDRW { get; set; } + public bool CanWriteHDDVDR { get; set; } + public bool CanWriteHDDVDRAM { get; set; } + public bool CanWriteOldBDR { get; set; } + public bool CanWriteOldBDRE { get; set; } + public bool CanWritePackedSubchannelInTAO { get; set; } + public bool CanWriteRWSubchannelInSAO { get; set; } + public bool CanWriteRWSubchannelInTAO { get; set; } + public bool CanWriteRaw { get; set; } + public bool CanWriteRawMultiSession { get; set; } + public bool CanWriteRawSubchannelInTAO { get; set; } + public bool ChangerIsSideChangeCapable { get; set; } + public byte ChangerSlots { get; set; } + public bool ChangerSupportsDiscPresent { get; set; } + public byte CPRMVersion { get; set; } + public byte CSSVersion { get; set; } + public bool DBML { get; set; } + public bool DVDMultiRead { get; set; } + public bool EmbeddedChanger { get; set; } + public bool ErrorRecoveryPage { get; set; } + [XmlElement(DataType = "date")] + public DateTime FirmwareDate { get; set; } + public byte LoadingMechanismType { get; set; } + public bool Locked { get; set; } + public uint LogicalBlockSize { get; set; } + public bool MultiRead { get; set; } + public PhysicalInterfaces PhysicalInterfaceStandard { get; set; } + public uint PhysicalInterfaceStandardNumber { get; set; } + public bool PreventJumper { get; set; } + public bool SupportsAACS { get; set; } + public bool SupportsBusEncryption { get; set; } + public bool SupportsC2 { get; set; } + public bool SupportsCPRM { get; set; } + public bool SupportsCSS { get; set; } + public bool SupportsDAP { get; set; } + public bool SupportsDeviceBusyEvent { get; set; } + public bool SupportsHybridDiscs { get; set; } + public bool SupportsModePage1Ch { get; set; } + public bool SupportsOSSC { get; set; } + public bool SupportsPWP { get; set; } + public bool SupportsSWPP { get; set; } + public bool SupportsSecurDisc { get; set; } + public bool SupportsSeparateVolume { get; set; } + public bool SupportsVCPS { get; set; } + public bool SupportsWriteInhibitDCB { get; set; } + public bool SupportsWriteProtectPAC { get; set; } + public ushort VolumeLevels { get; set; } + + [XmlIgnore] + public bool PhysicalInterfaceStandardSpecified { get; set; } + [XmlIgnore] + public bool PhysicalInterfaceStandardNumberSpecified { get; set; } + [XmlIgnore] + public bool AACSVersionSpecified { get; set; } + [XmlIgnore] + public bool AGIDsSpecified { get; set; } + [XmlIgnore] + public bool BindingNonceBlocksSpecified { get; set; } + [XmlIgnore] + public bool CPRMVersionSpecified { get; set; } + [XmlIgnore] + public bool CSSVersionSpecified { get; set; } + [XmlIgnore] + public bool ChangerHighestSlotNumberSpecified { get; set; } + [XmlIgnore] + public bool LoadingMechanismTypeSpecified { get; set; } + [XmlIgnore] + public bool LogicalBlockSizeSpecified { get; set; } + [XmlIgnore] + public bool BlocksPerReadableUnitSpecified { get; set; } + [XmlIgnore] + public bool FirmwareDateSpecified { get; set; } + [XmlIgnore] + public bool VolumeLevelsSpecified { get; set; } + } + + public class testedMediaType + { + public ulong Blocks { get; set; } + public uint BlockSize { get; set; } + public bool CanReadAACS { get; set; } + public bool CanReadADIP { get; set; } + public bool CanReadATIP { get; set; } + public bool CanReadBCA { get; set; } + public bool CanReadC2Pointers { get; set; } + public bool CanReadCMI { get; set; } + public bool CanReadCorrectedSubchannel { get; set; } + public bool CanReadCorrectedSubchannelWithC2 { get; set; } + public bool CanReadDCB { get; set; } + public bool CanReadDDS { get; set; } + public bool CanReadDMI { get; set; } + public bool CanReadDiscInformation { get; set; } + public bool CanReadFullTOC { get; set; } + public bool CanReadHDCMI { get; set; } + public bool CanReadLayerCapacity { get; set; } + public bool CanReadLeadIn { get; set; } + public bool CanReadLeadOut { get; set; } + public bool CanReadMediaID { get; set; } + public bool CanReadMediaSerial { get; set; } + public bool CanReadPAC { get; set; } + public bool CanReadPFI { get; set; } + public bool CanReadPMA { get; set; } + public bool CanReadPQSubchannel { get; set; } + public bool CanReadPQSubchannelWithC2 { get; set; } + public bool CanReadPRI { get; set; } + public bool CanReadRWSubchannel { get; set; } + public bool CanReadRWSubchannelWithC2 { get; set; } + public bool CanReadRecordablePFI { get; set; } + public bool CanReadSpareAreaInformation { get; set; } + public bool CanReadTOC { get; set; } + public byte Density { get; set; } + public uint LongBlockSize { get; set; } + public string Manufacturer { get; set; } + public bool MediaIsRecognized { get; set; } + public byte MediumType { get; set; } + public string MediumTypeName { get; set; } + public string Model { get; set; } + public bool SupportsHLDTSTReadRawDVD { get; set; } + public bool SupportsNECReadCDDA { get; set; } + public bool SupportsPioneerReadCDDA { get; set; } + public bool SupportsPioneerReadCDDAMSF { get; set; } + public bool SupportsPlextorReadCDDA { get; set; } + public bool SupportsPlextorReadRawDVD { get; set; } + public bool SupportsRead10 { get; set; } + public bool SupportsRead12 { get; set; } + public bool SupportsRead16 { get; set; } + public bool SupportsRead { get; set; } + public bool SupportsReadCapacity16 { get; set; } + public bool SupportsReadCapacity { get; set; } + public bool SupportsReadCd { get; set; } + public bool SupportsReadCdMsf { get; set; } + public bool SupportsReadCdRaw { get; set; } + public bool SupportsReadCdMsfRaw { get; set; } + public bool SupportsReadLong16 { get; set; } + public bool SupportsReadLong { get; set; } + + public byte[] ModeSense6Data { get; set; } + public byte[] ModeSense10Data { get; set; } + + [XmlIgnore] + public bool BlocksSpecified { get; set; } + [XmlIgnore] + public bool BlockSizeSpecified { get; set; } + [XmlIgnore] + public bool CanReadAACSSpecified { get; set; } + [XmlIgnore] + public bool CanReadADIPSpecified { get; set; } + [XmlIgnore] + public bool CanReadATIPSpecified { get; set; } + [XmlIgnore] + public bool CanReadBCASpecified { get; set; } + [XmlIgnore] + public bool CanReadC2PointersSpecified { get; set; } + [XmlIgnore] + public bool CanReadCMISpecified { get; set; } + [XmlIgnore] + public bool CanReadCorrectedSubchannelSpecified { get; set; } + [XmlIgnore] + public bool CanReadCorrectedSubchannelWithC2Specified { get; set; } + [XmlIgnore] + public bool CanReadDCBSpecified { get; set; } + [XmlIgnore] + public bool CanReadDDSSpecified { get; set; } + [XmlIgnore] + public bool CanReadDMISpecified { get; set; } + [XmlIgnore] + public bool CanReadDiscInformationSpecified { get; set; } + [XmlIgnore] + public bool CanReadFullTOCSpecified { get; set; } + [XmlIgnore] + public bool CanReadHDCMISpecified { get; set; } + [XmlIgnore] + public bool CanReadLayerCapacitySpecified { get; set; } + [XmlIgnore] + public bool CanReadLeadInSpecified { get; set; } + [XmlIgnore] + public bool CanReadLeadOutSpecified { get; set; } + [XmlIgnore] + public bool CanReadMediaIDSpecified { get; set; } + [XmlIgnore] + public bool CanReadMediaSerialSpecified { get; set; } + [XmlIgnore] + public bool CanReadPACSpecified { get; set; } + [XmlIgnore] + public bool CanReadPFISpecified { get; set; } + [XmlIgnore] + public bool CanReadPMASpecified { get; set; } + [XmlIgnore] + public bool CanReadPQSubchannelSpecified { get; set; } + [XmlIgnore] + public bool CanReadPQSubchannelWithC2Specified { get; set; } + [XmlIgnore] + public bool CanReadPRISpecified { get; set; } + [XmlIgnore] + public bool CanReadRWSubchannelSpecified { get; set; } + [XmlIgnore] + public bool CanReadRWSubchannelWithC2Specified { get; set; } + [XmlIgnore] + public bool CanReadRecordablePFISpecified { get; set; } + [XmlIgnore] + public bool CanReadSpareAreaInformationSpecified { get; set; } + [XmlIgnore] + public bool CanReadTOCSpecified { get; set; } + [XmlIgnore] + public bool DensitySpecified { get; set; } + [XmlIgnore] + public bool LongBlockSizeSpecified { get; set; } + [XmlIgnore] + public bool ManufacturerSpecified { get; set; } + [XmlIgnore] + public bool MediumTypeSpecified { get; set; } + [XmlIgnore] + public bool ModelSpecified { get; set; } + [XmlIgnore] + public bool SupportsHLDTSTReadRawDVDSpecified { get; set; } + [XmlIgnore] + public bool SupportsNECReadCDDASpecified { get; set; } + [XmlIgnore] + public bool SupportsPioneerReadCDDASpecified { get; set; } + [XmlIgnore] + public bool SupportsPioneerReadCDDAMSFSpecified { get; set; } + [XmlIgnore] + public bool SupportsPlextorReadCDDASpecified { get; set; } + [XmlIgnore] + public bool SupportsPlextorReadRawDVDSpecified { get; set; } + [XmlIgnore] + public bool SupportsRead10Specified { get; set; } + [XmlIgnore] + public bool SupportsRead12Specified { get; set; } + [XmlIgnore] + public bool SupportsRead16Specified { get; set; } + [XmlIgnore] + public bool SupportsReadSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadCapacity16Specified { get; set; } + [XmlIgnore] + public bool SupportsReadCapacitySpecified { get; set; } + [XmlIgnore] + public bool SupportsReadCdSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadCdMsfSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadCdRawSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadCdMsfRawSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadLong16Specified { get; set; } + [XmlIgnore] + public bool SupportsReadLongSpecified { get; set; } + + public chsType CHS { get; set; } + public chsType CurrentCHS { get; set; } + public uint LBASectors { get; set; } + public ulong LBA48Sectors { get; set; } + public ushort LogicalAlignment { get; set; } + public ushort NominalRotationRate { get; set; } + public uint PhysicalBlockSize { get; set; } + public bool SolidStateDevice { get; set; } + public ushort UnformattedBPT { get; set; } + public ushort UnformattedBPS { get; set; } + + [XmlIgnore] + public bool LBASectorsSpecified { get; set; } + [XmlIgnore] + public bool LBA48SectorsSpecified { get; set; } + [XmlIgnore] + public bool LogicalAlignmentSpecified { get; set; } + [XmlIgnore] + public bool NominalRotationRateSpecified { get; set; } + [XmlIgnore] + public bool PhysicalBlockSizeSpecified { get; set; } + [XmlIgnore] + public bool SolidStateDeviceSpecified { get; set; } + [XmlIgnore] + public bool UnformattedBPTSpecified { get; set; } + [XmlIgnore] + public bool UnformattedBPSSpecified { get; set; } + + public bool SupportsReadDmaLba { get; set; } + public bool SupportsReadDmaRetryLba { get; set; } + public bool SupportsReadLba { get; set; } + public bool SupportsReadRetryLba { get; set; } + public bool SupportsReadLongLba { get; set; } + public bool SupportsReadLongRetryLba { get; set; } + public bool SupportsSeekLba { get; set; } + + public bool SupportsReadDmaLba48 { get; set; } + public bool SupportsReadLba48 { get; set; } + + public bool SupportsReadDma { get; set; } + public bool SupportsReadDmaRetry { get; set; } + public bool SupportsReadRetry { get; set; } + public bool SupportsReadLongRetry { get; set; } + public bool SupportsSeek { get; set; } + + [XmlIgnore] + public bool SupportsReadDmaLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadDmaRetryLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadRetryLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadLongLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadLongRetryLbaSpecified { get; set; } + [XmlIgnore] + public bool SupportsSeekLbaSpecified { get; set; } + + [XmlIgnore] + public bool SupportsReadDmaLba48Specified { get; set; } + [XmlIgnore] + public bool SupportsReadLba48Specified { get; set; } + + [XmlIgnore] + public bool SupportsReadDmaSpecified { get; set; } + [XmlIgnore] + public bool SupportsReadDmaRetrySpecified { get; set; } + [XmlIgnore] + public bool SupportsReadRetrySpecified { get; set; } + [XmlIgnore] + public bool SupportsReadLongRetrySpecified { get; set; } + [XmlIgnore] + public bool SupportsSeekSpecified { get; set; } + } + + public class sscType + { + public byte BlockSizeGranularity { get; set; } + public uint MaxBlockLength { get; set; } + public uint MinBlockLength { get; set; } + + public SupportedDensity[] SupportedDensities { get; set; } + public SupportedMedia[] SupportedMediaTypes { get; set; } + public SequentialMedia[] TestedMedia { get; set; } + + [XmlIgnore] + public bool BlockSizeGranularitySpecified { get; set; } + [XmlIgnore] + public bool MaxBlockLengthSpecified { get; set; } + [XmlIgnore] + public bool MinBlockLengthSpecified { get; set; } + } + + public struct SupportedDensity + { + public byte PrimaryCode { get; set; } + public byte SecondaryCode { get; set; } + public bool Writable { get; set; } + public bool Duplicate { get; set; } + public bool DefaultDensity { get; set; } + public uint BitsPerMm { get; set; } + public ushort Width { get; set; } + public ushort Tracks { get; set; } + public uint Capacity { get; set; } + public string Organization { get; set; } + public string Name { get; set; } + public string Description { get; set; } + } + + public struct SupportedMedia + { + public byte MediumType { get; set; } + public int[] DensityCodes { get; set; } + public ushort Width { get; set; } + public ushort Length { get; set; } + public string Organization { get; set; } + public string Name { get; set; } + public string Description { get; set; } + } + + public struct SequentialMedia + { + public bool CanReadMediaSerial { get; set; } + public byte Density { get; set; } + public string Manufacturer { get; set; } + public bool MediaIsRecognized { get; set; } + public byte MediumType { get; set; } + public string MediumTypeName { get; set; } + public string Model { get; set; } + public SupportedDensity[] SupportedDensities { get; set; } + public SupportedMedia[] SupportedMediaTypes { get; set; } + + public byte[] ModeSense6Data { get; set; } + public byte[] ModeSense10Data { get; set; } + + [XmlIgnore] + public bool CanReadMediaSerialSpecified { get; set; } + [XmlIgnore] + public bool DensitySpecified { get; set; } + [XmlIgnore] + public bool MediumTypeSpecified { get; set; } + } + + [Serializable] + public class pcmciaType + { + public byte[] CIS { get; set; } + public string Compliance { get; set; } + public ushort ManufacturerCode { get; set; } + public ushort CardCode { get; set; } + public string Manufacturer { get; set; } + public string ProductName { get; set; } + public string[] AdditionalInformation { get; set; } + + [XmlIgnore] + public bool ManufacturerCodeSpecified { get; set; } + [XmlIgnore] + public bool CardCodeSpecified { get; set; } + } + + [Serializable] + public class mmcsdType + { + public byte[] CID { get; set; } + public byte[] CSD { get; set; } + public byte[] OCR { get; set; } + public byte[] SCR { get; set; } + public byte[] ExtendedCSD { get; set; } + } +} \ No newline at end of file diff --git a/Metadata/Dimensions.cs b/Metadata/Dimensions.cs new file mode 100644 index 0000000..2598876 --- /dev/null +++ b/Metadata/Dimensions.cs @@ -0,0 +1,922 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Dimensions.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Gets physical dimensions of a device/media based on its media type. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using Schemas; + +namespace DiscImageChef.CommonTypes.Metadata +{ + public static class Dimensions + { + public static DimensionsType DimensionsFromMediaType(CommonTypes.MediaType dskType) + { + DimensionsType dmns = new DimensionsType(); + + switch(dskType) + { + #region 5.25" floppy disk + case CommonTypes.MediaType.Apple32SS: + case CommonTypes.MediaType.Apple32DS: + case CommonTypes.MediaType.Apple33SS: + case CommonTypes.MediaType.Apple33DS: + case CommonTypes.MediaType.AppleFileWare: + case CommonTypes.MediaType.DOS_525_SS_DD_8: + case CommonTypes.MediaType.DOS_525_SS_DD_9: + case CommonTypes.MediaType.DOS_525_DS_DD_8: + case CommonTypes.MediaType.DOS_525_DS_DD_9: + case CommonTypes.MediaType.DOS_525_HD: + case CommonTypes.MediaType.XDF_525: + case CommonTypes.MediaType.ACORN_525_SS_SD_40: + case CommonTypes.MediaType.ACORN_525_SS_SD_80: + case CommonTypes.MediaType.ACORN_525_SS_DD_40: + case CommonTypes.MediaType.ACORN_525_SS_DD_80: + case CommonTypes.MediaType.ACORN_525_DS_DD: + case CommonTypes.MediaType.ATARI_525_SD: + case CommonTypes.MediaType.ATARI_525_ED: + case CommonTypes.MediaType.ATARI_525_DD: + case CommonTypes.MediaType.CBM_1540: + case CommonTypes.MediaType.CBM_1540_Ext: + case CommonTypes.MediaType.CBM_1571: + case CommonTypes.MediaType.ECMA_66: + case CommonTypes.MediaType.ECMA_70: + case CommonTypes.MediaType.NEC_525_HD: + case CommonTypes.MediaType.ECMA_78: + case CommonTypes.MediaType.ECMA_78_2: + case CommonTypes.MediaType.ECMA_99_8: + case CommonTypes.MediaType.ECMA_99_15: + case CommonTypes.MediaType.ECMA_99_26: + case CommonTypes.MediaType.FDFORMAT_525_DD: + case CommonTypes.MediaType.FDFORMAT_525_HD: + // According to ECMA-99 et al + dmns.Height = 133.3; + dmns.HeightSpecified = true; + dmns.Width = 133.3; + dmns.WidthSpecified = true; + dmns.Thickness = 1.65; + return dmns; + #endregion 5.25" floppy disk + + #region 3.5" floppy disk + case CommonTypes.MediaType.AppleSonySS: + case CommonTypes.MediaType.AppleSonyDS: + case CommonTypes.MediaType.DOS_35_SS_DD_8: + case CommonTypes.MediaType.DOS_35_SS_DD_9: + case CommonTypes.MediaType.DOS_35_DS_DD_8: + case CommonTypes.MediaType.DOS_35_DS_DD_9: + case CommonTypes.MediaType.DOS_35_HD: + case CommonTypes.MediaType.DOS_35_ED: + case CommonTypes.MediaType.DMF: + case CommonTypes.MediaType.DMF_82: + case CommonTypes.MediaType.XDF_35: + case CommonTypes.MediaType.ACORN_35_DS_DD: + case CommonTypes.MediaType.CBM_35_DD: + case CommonTypes.MediaType.CBM_AMIGA_35_DD: + case CommonTypes.MediaType.CBM_AMIGA_35_HD: + case CommonTypes.MediaType.FDFORMAT_35_DD: + case CommonTypes.MediaType.FDFORMAT_35_HD: + case CommonTypes.MediaType.NEC_35_HD_8: + case CommonTypes.MediaType.NEC_35_HD_15: + case CommonTypes.MediaType.Floptical: + case CommonTypes.MediaType.HiFD: + case CommonTypes.MediaType.UHD144: + case CommonTypes.MediaType.Apricot_35: + case CommonTypes.MediaType.FD32MB: + // According to ECMA-100 et al + dmns.Height = 94; + dmns.HeightSpecified = true; + dmns.Width = 90; + dmns.WidthSpecified = true; + dmns.Thickness = 3.3; + return dmns; + #endregion 3.5" floppy disk + + #region 8" floppy disk + case CommonTypes.MediaType.IBM23FD: + case CommonTypes.MediaType.IBM33FD_128: + case CommonTypes.MediaType.IBM33FD_256: + case CommonTypes.MediaType.IBM33FD_512: + case CommonTypes.MediaType.IBM43FD_128: + case CommonTypes.MediaType.IBM43FD_256: + case CommonTypes.MediaType.IBM53FD_256: + case CommonTypes.MediaType.IBM53FD_512: + case CommonTypes.MediaType.IBM53FD_1024: + case CommonTypes.MediaType.RX01: + case CommonTypes.MediaType.RX02: + case CommonTypes.MediaType.NEC_8_SD: + case CommonTypes.MediaType.NEC_8_DD: + case CommonTypes.MediaType.ECMA_54: + case CommonTypes.MediaType.ECMA_59: + case CommonTypes.MediaType.ECMA_69_8: + case CommonTypes.MediaType.ECMA_69_15: + case CommonTypes.MediaType.ECMA_69_26: + // According to ECMA-59 et al + dmns.Height = 203.2; + dmns.HeightSpecified = true; + dmns.Width = 203.2; + dmns.WidthSpecified = true; + dmns.Thickness = 1.65; + return dmns; + #endregion 8" floppy disk + + #region 356mm magneto optical + case CommonTypes.MediaType.ECMA_260: + case CommonTypes.MediaType.ECMA_260_Double: + // According to ECMA-260 et al + dmns.Height = 421.84; + dmns.HeightSpecified = true; + dmns.Width = 443.76; + dmns.WidthSpecified = true; + dmns.Thickness = 25.4; + return dmns; + #endregion 356mm magneto optical + + #region 300mm magneto optical + case CommonTypes.MediaType.ECMA_189: + case CommonTypes.MediaType.ECMA_190: + case CommonTypes.MediaType.ECMA_317: + // According to ECMA-317 et al + dmns.Height = 340; + dmns.HeightSpecified = true; + dmns.Width = 320; + dmns.WidthSpecified = true; + dmns.Thickness = 17; + return dmns; + #endregion 300mm magneto optical + + #region 5.25" magneto optical + case CommonTypes.MediaType.ECMA_153: + case CommonTypes.MediaType.ECMA_153_512: + case CommonTypes.MediaType.ECMA_183_512: + case CommonTypes.MediaType.ECMA_183: + case CommonTypes.MediaType.ECMA_184_512: + case CommonTypes.MediaType.ECMA_184: + case CommonTypes.MediaType.ECMA_195: + case CommonTypes.MediaType.ECMA_195_512: + case CommonTypes.MediaType.ECMA_238: + case CommonTypes.MediaType.ECMA_280: + case CommonTypes.MediaType.ECMA_322: + case CommonTypes.MediaType.ECMA_322_2k: + case CommonTypes.MediaType.UDO: + case CommonTypes.MediaType.UDO2: + case CommonTypes.MediaType.UDO2_WORM: + // According to ECMA-183 et al + dmns.Height = 153; + dmns.HeightSpecified = true; + dmns.Width = 135; + dmns.WidthSpecified = true; + dmns.Thickness = 11; + return dmns; + #endregion 5.25" magneto optical + + #region 3.5" magneto optical + case CommonTypes.MediaType.ECMA_154: + case CommonTypes.MediaType.ECMA_201: + case CommonTypes.MediaType.ECMA_201_ROM: + case CommonTypes.MediaType.ECMA_223: + case CommonTypes.MediaType.ECMA_223_512: + case CommonTypes.MediaType.GigaMo: + case CommonTypes.MediaType.GigaMo2: + // According to ECMA-154 et al + dmns.Height = 94; + dmns.HeightSpecified = true; + dmns.Width = 90; + dmns.WidthSpecified = true; + dmns.Thickness = 6; + return dmns; + #endregion 3.5" magneto optical + + case CommonTypes.MediaType.PD650: + case CommonTypes.MediaType.PD650_WORM: + dmns.Height = 135; + dmns.HeightSpecified = true; + dmns.Width = 124; + dmns.WidthSpecified = true; + dmns.Thickness = 7.8; + return dmns; + case CommonTypes.MediaType.ECMA_239: + dmns.Height = 97; + dmns.HeightSpecified = true; + dmns.Width = 92; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.MMCmicro: + dmns.Height = 14; + dmns.HeightSpecified = true; + dmns.Width = 12; + dmns.WidthSpecified = true; + dmns.Thickness = 1.1; + return dmns; + case CommonTypes.MediaType.MemoryStickMicro: + dmns.Height = 15; + dmns.HeightSpecified = true; + dmns.Width = 12.5; + dmns.WidthSpecified = true; + dmns.Thickness = 1.2; + return dmns; + case CommonTypes.MediaType.microSD: + dmns.Height = 11; + dmns.HeightSpecified = true; + dmns.Width = 15; + dmns.WidthSpecified = true; + dmns.Thickness = 1; + return dmns; + case CommonTypes.MediaType.miniSD: + dmns.Height = 21.5; + dmns.HeightSpecified = true; + dmns.Width = 20; + dmns.WidthSpecified = true; + dmns.Thickness = 1.4; + return dmns; + case CommonTypes.MediaType.QIC3010: + case CommonTypes.MediaType.QIC3020: + case CommonTypes.MediaType.QIC3080: + case CommonTypes.MediaType.QIC3095: + case CommonTypes.MediaType.QIC320: + case CommonTypes.MediaType.QIC40: + case CommonTypes.MediaType.QIC80: + dmns.Height = 20; + dmns.HeightSpecified = true; + dmns.Width = 21.5; + dmns.WidthSpecified = true; + dmns.Thickness = 1.6; + return dmns; + case CommonTypes.MediaType.RSMMC: + dmns.Height = 18; + dmns.HeightSpecified = true; + dmns.Width = 24; + dmns.WidthSpecified = true; + dmns.Thickness = 1.4; + return dmns; + case CommonTypes.MediaType.MMC: + dmns.Height = 32; + dmns.HeightSpecified = true; + dmns.Width = 24; + dmns.WidthSpecified = true; + dmns.Thickness = 1.4; + return dmns; + case CommonTypes.MediaType.SecureDigital: + dmns.Height = 32; + dmns.HeightSpecified = true; + dmns.Width = 24; + dmns.WidthSpecified = true; + dmns.Thickness = 2.1; + return dmns; + case CommonTypes.MediaType.xD: + dmns.Height = 20; + dmns.HeightSpecified = true; + dmns.Width = 25; + dmns.WidthSpecified = true; + dmns.Thickness = 1.78; + return dmns; + case CommonTypes.MediaType.XQD: + dmns.Height = 38.5; + dmns.HeightSpecified = true; + dmns.Width = 29.8; + dmns.WidthSpecified = true; + dmns.Thickness = 3.8; + return dmns; + case CommonTypes.MediaType.MemoryStickDuo: + case CommonTypes.MediaType.MemoryStickProDuo: + dmns.Height = 20; + dmns.HeightSpecified = true; + dmns.Width = 31; + dmns.WidthSpecified = true; + dmns.Thickness = 1.6; + return dmns; + case CommonTypes.MediaType.Nintendo3DSGameCard: + case CommonTypes.MediaType.NintendoDSGameCard: + case CommonTypes.MediaType.NintendoDSiGameCard: + dmns.Height = 35; + dmns.HeightSpecified = true; + dmns.Width = 33; + dmns.WidthSpecified = true; + dmns.Thickness = 3.8; + return dmns; + case CommonTypes.MediaType.DataPlay: + dmns.Height = 42; + dmns.HeightSpecified = true; + dmns.Width = 33.5; + dmns.WidthSpecified = true; + dmns.Thickness = 3; + return dmns; + case CommonTypes.MediaType.Microdrive: + dmns.Height = 44; + dmns.HeightSpecified = true; + dmns.Width = 34; + dmns.WidthSpecified = true; + dmns.Thickness = 8; + return dmns; + case CommonTypes.MediaType.ExpressCard34: + dmns.Height = 75; + dmns.HeightSpecified = true; + dmns.Width = 34; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.SmartMedia: + dmns.Height = 45; + dmns.HeightSpecified = true; + dmns.Width = 37; + dmns.WidthSpecified = true; + dmns.Thickness = 0.76; + return dmns; + case CommonTypes.MediaType.MiniCard: + dmns.Height = 45; + dmns.HeightSpecified = true; + dmns.Width = 37; + dmns.WidthSpecified = true; + dmns.Thickness = 3.5; + return dmns; + case CommonTypes.MediaType.PlayStationMemoryCard: + case CommonTypes.MediaType.PlayStationMemoryCard2: + dmns.Height = 55.7; + dmns.HeightSpecified = true; + dmns.Width = 41.5; + dmns.WidthSpecified = true; + dmns.Thickness = 7; + return dmns; + case CommonTypes.MediaType.CFast: + case CommonTypes.MediaType.CompactFlash: + dmns.Height = 36; + dmns.HeightSpecified = true; + dmns.Width = 43; + dmns.WidthSpecified = true; + dmns.Thickness = 3.3; + return dmns; + case CommonTypes.MediaType.CompactFlashType2: + dmns.Height = 36; + dmns.HeightSpecified = true; + dmns.Width = 43; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.ZXMicrodrive: + dmns.Height = 36; + dmns.HeightSpecified = true; + dmns.Width = 43; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.MemoryStick: + case CommonTypes.MediaType.MemoryStickPro: + dmns.Height = 21; + dmns.HeightSpecified = true; + dmns.Width = 50; + dmns.WidthSpecified = true; + dmns.Thickness = 2.6; + return dmns; + case CommonTypes.MediaType.PocketZip: + dmns.Height = 54.5; + dmns.HeightSpecified = true; + dmns.Width = 50; + dmns.WidthSpecified = true; + dmns.Thickness = 2; + return dmns; + case CommonTypes.MediaType.ExpressCard54: + dmns.Height = 75; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.PCCardTypeI: + dmns.Height = 85.6; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 3.3; + return dmns; + case CommonTypes.MediaType.PCCardTypeII: + dmns.Height = 85.6; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.PCCardTypeIII: + dmns.Height = 85.6; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 10.5; + return dmns; + case CommonTypes.MediaType.PCCardTypeIV: + dmns.Height = 85.6; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 16; + return dmns; + case CommonTypes.MediaType.DataStore: + dmns.Height = 86.5; + dmns.HeightSpecified = true; + dmns.Width = 54; + dmns.WidthSpecified = true; + dmns.Thickness = 2.5; + return dmns; + case CommonTypes.MediaType.VideoFloppy: + dmns.Height = 54; + dmns.HeightSpecified = true; + dmns.Width = 60; + dmns.WidthSpecified = true; + dmns.Thickness = 3.5; + return dmns; + case CommonTypes.MediaType.VXA1: + case CommonTypes.MediaType.VXA2: + case CommonTypes.MediaType.VXA3: + dmns.Height = 95; + dmns.HeightSpecified = true; + dmns.Width = 62.5; + dmns.WidthSpecified = true; + dmns.Thickness = 15; + return dmns; + case CommonTypes.MediaType.MiniDV: + dmns.Height = 47.5; + dmns.HeightSpecified = true; + dmns.Width = 66; + dmns.WidthSpecified = true; + dmns.Thickness = 12; + return dmns; + case CommonTypes.MediaType.Wafer: + dmns.Height = 46.8; + dmns.HeightSpecified = true; + dmns.Width = 67.1; + dmns.WidthSpecified = true; + dmns.Thickness = 7.9; + return dmns; + case CommonTypes.MediaType.NintendoDiskCard: + dmns.Height = 76.2; + dmns.HeightSpecified = true; + dmns.Width = 71.12; + dmns.WidthSpecified = true; + dmns.Thickness = 0; + return dmns; + case CommonTypes.MediaType.HiMD: + case CommonTypes.MediaType.MD: + case CommonTypes.MediaType.MDData: + case CommonTypes.MediaType.MDData2: + dmns.Height = 68; + dmns.HeightSpecified = true; + dmns.Width = 71.5; + dmns.WidthSpecified = true; + dmns.Thickness = 4.8; + return dmns; + case CommonTypes.MediaType.DAT160: + case CommonTypes.MediaType.DAT320: + case CommonTypes.MediaType.DAT72: + case CommonTypes.MediaType.DDS1: + case CommonTypes.MediaType.DDS2: + case CommonTypes.MediaType.DDS3: + case CommonTypes.MediaType.DDS4: + case CommonTypes.MediaType.DigitalAudioTape: + dmns.Height = 54; + dmns.HeightSpecified = true; + dmns.Width = 73; + dmns.WidthSpecified = true; + dmns.Thickness = 10.5; + return dmns; + case CommonTypes.MediaType.CompactFloppy: + dmns.Height = 100; + dmns.HeightSpecified = true; + dmns.Width = 80; + dmns.WidthSpecified = true; + dmns.Thickness = 5; + return dmns; + case CommonTypes.MediaType.DECtapeII: + dmns.Height = 60; + dmns.HeightSpecified = true; + dmns.Width = 81; + dmns.WidthSpecified = true; + dmns.Thickness = 13; + return dmns; + case CommonTypes.MediaType.Ditto: + dmns.Height = 60; + dmns.HeightSpecified = true; + dmns.Width = 81; + dmns.WidthSpecified = true; + dmns.Thickness = 14; + return dmns; + case CommonTypes.MediaType.DittoMax: + dmns.Height = 126; + dmns.HeightSpecified = true; + dmns.Width = 81; + dmns.WidthSpecified = true; + dmns.Thickness = 14; + return dmns; + case CommonTypes.MediaType.RDX: + case CommonTypes.MediaType.RDX320: + dmns.Height = 119; + dmns.HeightSpecified = true; + dmns.Width = 87; + dmns.WidthSpecified = true; + dmns.Thickness = 23; + return dmns; + case CommonTypes.MediaType.LS120: + case CommonTypes.MediaType.LS240: + dmns.Height = 94; + dmns.HeightSpecified = true; + dmns.Width = 90; + dmns.WidthSpecified = true; + dmns.Thickness = 3.5; + return dmns; + case CommonTypes.MediaType.Travan: + case CommonTypes.MediaType.Travan3: + case CommonTypes.MediaType.Travan4: + case CommonTypes.MediaType.Travan5: + case CommonTypes.MediaType.Travan7: + dmns.Height = 72; + dmns.HeightSpecified = true; + dmns.Width = 92; + dmns.WidthSpecified = true; + dmns.Thickness = 15; + return dmns; + case CommonTypes.MediaType.Travan1Ex: + dmns.Height = 0; + dmns.HeightSpecified = true; + dmns.Width = 92; + dmns.WidthSpecified = true; + dmns.Thickness = 15; + return dmns; + case CommonTypes.MediaType.Travan3Ex: + dmns.Height = 0; + dmns.HeightSpecified = true; + dmns.Width = 92; + dmns.WidthSpecified = true; + dmns.Thickness = 15; + return dmns; + case CommonTypes.MediaType.ADR2120: + case CommonTypes.MediaType.ADR260: + case CommonTypes.MediaType.ADR30: + case CommonTypes.MediaType.ADR50: + dmns.Height = 129; + dmns.HeightSpecified = true; + dmns.Width = 93; + dmns.WidthSpecified = true; + dmns.Thickness = 14.5; + return dmns; + case CommonTypes.MediaType.Data8: + case CommonTypes.MediaType.AIT1: + case CommonTypes.MediaType.AIT1Turbo: + case CommonTypes.MediaType.AIT2: + case CommonTypes.MediaType.AIT2Turbo: + case CommonTypes.MediaType.AIT3: + case CommonTypes.MediaType.AIT3Ex: + case CommonTypes.MediaType.AIT3Turbo: + case CommonTypes.MediaType.AIT4: + case CommonTypes.MediaType.AIT5: + case CommonTypes.MediaType.AITETurbo: + case CommonTypes.MediaType.Exatape106m: + case CommonTypes.MediaType.Exatape160mXL: + case CommonTypes.MediaType.Exatape112m: + case CommonTypes.MediaType.Exatape125m: + case CommonTypes.MediaType.Exatape150m: + case CommonTypes.MediaType.Exatape15m: + case CommonTypes.MediaType.Exatape170m: + case CommonTypes.MediaType.Exatape225m: + case CommonTypes.MediaType.Exatape22m: + case CommonTypes.MediaType.Exatape22mAME: + case CommonTypes.MediaType.Exatape28m: + case CommonTypes.MediaType.Exatape40m: + case CommonTypes.MediaType.Exatape45m: + case CommonTypes.MediaType.Exatape54m: + case CommonTypes.MediaType.Exatape75m: + case CommonTypes.MediaType.Exatape76m: + case CommonTypes.MediaType.Exatape80m: + dmns.Height = 62.5; + dmns.HeightSpecified = true; + dmns.Width = 95; + dmns.WidthSpecified = true; + dmns.Thickness = 15; + return dmns; + case CommonTypes.MediaType.EZ135: + case CommonTypes.MediaType.EZ230: + dmns.Height = 97; + dmns.HeightSpecified = true; + dmns.Width = 98; + dmns.WidthSpecified = true; + dmns.Thickness = 9.5; + return dmns; + case CommonTypes.MediaType.ZIP100: + case CommonTypes.MediaType.ZIP250: + case CommonTypes.MediaType.ZIP750: + dmns.Height = 98.5; + dmns.HeightSpecified = true; + dmns.Width = 98; + dmns.WidthSpecified = true; + dmns.Thickness = 6.5; + return dmns; + case CommonTypes.MediaType.Jaz: + case CommonTypes.MediaType.Jaz2: + dmns.Height = 102; + dmns.HeightSpecified = true; + dmns.Width = 98; + dmns.WidthSpecified = true; + dmns.Thickness = 12; + return dmns; + case CommonTypes.MediaType.Orb: + case CommonTypes.MediaType.Orb5: + dmns.Height = 104; + dmns.HeightSpecified = true; + dmns.Width = 98; + dmns.WidthSpecified = true; + dmns.Thickness = 8; + return dmns; + case CommonTypes.MediaType.SparQ: + dmns.Height = 98; + dmns.HeightSpecified = true; + dmns.Width = 100; + dmns.WidthSpecified = true; + dmns.Thickness = 9.7; + return dmns; + case CommonTypes.MediaType.SLR1: + case CommonTypes.MediaType.SLR2: + case CommonTypes.MediaType.SLR3: + case CommonTypes.MediaType.SLR32: + case CommonTypes.MediaType.SLR32SL: + case CommonTypes.MediaType.SLR4: + case CommonTypes.MediaType.SLR5: + case CommonTypes.MediaType.SLR5SL: + case CommonTypes.MediaType.SLR6: + case CommonTypes.MediaType.SLRtape100: + case CommonTypes.MediaType.SLRtape140: + case CommonTypes.MediaType.SLRtape24: + case CommonTypes.MediaType.SLRtape24SL: + case CommonTypes.MediaType.SLRtape40: + case CommonTypes.MediaType.SLRtape50: + case CommonTypes.MediaType.SLRtape60: + case CommonTypes.MediaType.SLRtape7: + case CommonTypes.MediaType.SLRtape75: + case CommonTypes.MediaType.SLRtape7SL: + dmns.Height = 150; + dmns.HeightSpecified = true; + dmns.Width = 100; + dmns.WidthSpecified = true; + dmns.Thickness = 18; + return dmns; + case CommonTypes.MediaType.N64DD: + dmns.Height = 103.124; + dmns.HeightSpecified = true; + dmns.Width = 101.092; + dmns.WidthSpecified = true; + dmns.Thickness = 10.16; + return dmns; + case CommonTypes.MediaType.CompactTapeI: + case CommonTypes.MediaType.CompactTapeII: + case CommonTypes.MediaType.DLTtapeIII: + case CommonTypes.MediaType.DLTtapeIIIxt: + case CommonTypes.MediaType.DLTtapeIV: + case CommonTypes.MediaType.DLTtapeS4: + case CommonTypes.MediaType.SDLT1: + case CommonTypes.MediaType.SDLT2: + case CommonTypes.MediaType.VStapeI: + dmns.Height = 105; + dmns.HeightSpecified = true; + dmns.Width = 105; + dmns.WidthSpecified = true; + dmns.Thickness = 25; + return dmns; + case CommonTypes.MediaType.LTO: + case CommonTypes.MediaType.LTO2: + case CommonTypes.MediaType.LTO3: + case CommonTypes.MediaType.LTO3WORM: + case CommonTypes.MediaType.LTO4: + case CommonTypes.MediaType.LTO4WORM: + case CommonTypes.MediaType.LTO5: + case CommonTypes.MediaType.LTO5WORM: + case CommonTypes.MediaType.LTO6: + case CommonTypes.MediaType.LTO6WORM: + case CommonTypes.MediaType.LTO7: + case CommonTypes.MediaType.LTO7WORM: + dmns.Height = 101.6; + dmns.HeightSpecified = true; + dmns.Width = 105.41; + dmns.WidthSpecified = true; + dmns.Thickness = 21.59; + return dmns; + case CommonTypes.MediaType.IBM3480: + case CommonTypes.MediaType.IBM3490: + case CommonTypes.MediaType.IBM3490E: + case CommonTypes.MediaType.IBM3592: + dmns.Height = 125.73; + dmns.HeightSpecified = true; + dmns.Width = 107.95; + dmns.WidthSpecified = true; + dmns.Thickness = 25.4; + return dmns; + case CommonTypes.MediaType.T9840A: + case CommonTypes.MediaType.T9840B: + case CommonTypes.MediaType.T9840C: + case CommonTypes.MediaType.T9840D: + case CommonTypes.MediaType.T9940A: + case CommonTypes.MediaType.T9940B: + dmns.Height = 124.46; + dmns.HeightSpecified = true; + dmns.Width = 109.22; + dmns.WidthSpecified = true; + dmns.Thickness = 25.4; + return dmns; + case CommonTypes.MediaType.CompactCassette: + case CommonTypes.MediaType.Dcas25: + case CommonTypes.MediaType.Dcas85: + case CommonTypes.MediaType.Dcas103: + dmns.Height = 63.5; + dmns.HeightSpecified = true; + dmns.Width = 128; + dmns.WidthSpecified = true; + dmns.Thickness = 12; + return dmns; + case CommonTypes.MediaType.IBM3470: + dmns.Height = 58.42; + dmns.HeightSpecified = true; + dmns.Width = 137.16; + dmns.WidthSpecified = true; + dmns.Thickness = 16.51; + return dmns; + case CommonTypes.MediaType.Bernoulli2: + dmns.Height = 136; + dmns.HeightSpecified = true; + dmns.Width = 140; + dmns.WidthSpecified = true; + dmns.Thickness = 9; + return dmns; + case CommonTypes.MediaType.MLR1: + case CommonTypes.MediaType.MLR3: + case CommonTypes.MediaType.MLR1SL: + dmns.Height = 101.6; + dmns.HeightSpecified = true; + dmns.Width = 152.4; + dmns.WidthSpecified = true; + dmns.Thickness = 15.24; + return dmns; + case CommonTypes.MediaType.QIC11: + case CommonTypes.MediaType.QIC120: + case CommonTypes.MediaType.QIC1350: + case CommonTypes.MediaType.QIC150: + case CommonTypes.MediaType.QIC24: + case CommonTypes.MediaType.QIC525: + dmns.Height = 101.6; + dmns.HeightSpecified = true; + dmns.Width = 154.2; + dmns.WidthSpecified = true; + dmns.Thickness = 16.6; + return dmns; + case CommonTypes.MediaType.Bernoulli: + dmns.Height = 275; + dmns.HeightSpecified = true; + dmns.Width = 210; + dmns.WidthSpecified = true; + dmns.Thickness = 0; + return dmns; + case CommonTypes.MediaType.DTF: + case CommonTypes.MediaType.DTF2: + dmns.Height = 144.78; + dmns.HeightSpecified = true; + dmns.Width = 254; + dmns.WidthSpecified = true; + dmns.Thickness = 25.4; + return dmns; + case CommonTypes.MediaType.LD: + case CommonTypes.MediaType.LDROM: + case CommonTypes.MediaType.LDROM2: + case CommonTypes.MediaType.MegaLD: + case CommonTypes.MediaType.LVROM: + dmns.Diameter = 300; + dmns.DiameterSpecified = true; + dmns.Thickness = 2.5; + return dmns; + + #region CD/DVD/BD + case CommonTypes.MediaType.CDDA: + case CommonTypes.MediaType.CDG: + case CommonTypes.MediaType.CDEG: + case CommonTypes.MediaType.CDI: + case CommonTypes.MediaType.CDROM: + case CommonTypes.MediaType.CDROMXA: + case CommonTypes.MediaType.CDPLUS: + case CommonTypes.MediaType.CDMO: + case CommonTypes.MediaType.CDR: + case CommonTypes.MediaType.CDRW: + case CommonTypes.MediaType.CDMRW: + case CommonTypes.MediaType.VCD: + case CommonTypes.MediaType.SVCD: + case CommonTypes.MediaType.PCD: + case CommonTypes.MediaType.SACD: + case CommonTypes.MediaType.DDCD: + case CommonTypes.MediaType.DDCDR: + case CommonTypes.MediaType.DDCDRW: + case CommonTypes.MediaType.DTSCD: + case CommonTypes.MediaType.CDMIDI: + case CommonTypes.MediaType.CDV: + case CommonTypes.MediaType.CD: + case CommonTypes.MediaType.DVDROM: + case CommonTypes.MediaType.DVDR: + case CommonTypes.MediaType.DVDRW: + case CommonTypes.MediaType.DVDPR: + case CommonTypes.MediaType.DVDPRW: + case CommonTypes.MediaType.DVDPRWDL: + case CommonTypes.MediaType.DVDRDL: + case CommonTypes.MediaType.DVDPRDL: + case CommonTypes.MediaType.DVDRAM: + case CommonTypes.MediaType.DVDRWDL: + case CommonTypes.MediaType.DVDDownload: + case CommonTypes.MediaType.HDDVDROM: + case CommonTypes.MediaType.HDDVDRAM: + case CommonTypes.MediaType.HDDVDR: + case CommonTypes.MediaType.HDDVDRW: + case CommonTypes.MediaType.HDDVDRDL: + case CommonTypes.MediaType.HDDVDRWDL: + case CommonTypes.MediaType.BDROM: + case CommonTypes.MediaType.BDR: + case CommonTypes.MediaType.BDRE: + case CommonTypes.MediaType.BDRXL: + case CommonTypes.MediaType.BDREXL: + case CommonTypes.MediaType.PS1CD: + case CommonTypes.MediaType.PS2CD: + case CommonTypes.MediaType.PS2DVD: + case CommonTypes.MediaType.PS3DVD: + case CommonTypes.MediaType.PS3BD: + case CommonTypes.MediaType.PS4BD: + case CommonTypes.MediaType.XGD: + case CommonTypes.MediaType.XGD2: + case CommonTypes.MediaType.XGD3: + case CommonTypes.MediaType.XGD4: + case CommonTypes.MediaType.MEGACD: + case CommonTypes.MediaType.SATURNCD: + case CommonTypes.MediaType.GDROM: + case CommonTypes.MediaType.GDR: + case CommonTypes.MediaType.SuperCDROM2: + case CommonTypes.MediaType.JaguarCD: + case CommonTypes.MediaType.ThreeDO: + case CommonTypes.MediaType.WOD: + case CommonTypes.MediaType.WUOD: + case CommonTypes.MediaType.PCFX: + 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; + #endregion CD/DVD/BD + + #region Apple Hard Disks + // TODO: Find Apple Widget size + case CommonTypes.MediaType.AppleProfile: + dmns.Height = 223.8; + dmns.HeightSpecified = true; + dmns.Width = 438.9; + dmns.WidthSpecified = true; + dmns.Thickness = 111.5; + return dmns; + case CommonTypes.MediaType.AppleHD20: + dmns.Height = 246.4; + dmns.HeightSpecified = true; + dmns.Width = 266.7; + dmns.WidthSpecified = true; + dmns.Thickness = 78.7; + return dmns; + #endregion Apple Hard Disks + + case CommonTypes.MediaType.UMD: + dmns.Height = 64; + dmns.HeightSpecified = true; + dmns.Width = 63; + dmns.WidthSpecified = true; + dmns.Thickness = 4; + return dmns; + default: return null; + } + } + } +} \ No newline at end of file diff --git a/Metadata/MediaType.cs b/Metadata/MediaType.cs new file mode 100644 index 0000000..2cf3051 --- /dev/null +++ b/Metadata/MediaType.cs @@ -0,0 +1,1829 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : MediaType.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Converts a common media type to the XML equivalent. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +namespace DiscImageChef.CommonTypes.Metadata +{ + public static class MediaType + { + public static void MediaTypeToString(CommonTypes.MediaType dskType, out string discType, out string discSubType) + { + switch(dskType) + { + case CommonTypes.MediaType.BDR: + discType = "Blu-ray"; + discSubType = "BD-R"; + break; + case CommonTypes.MediaType.BDRE: + discType = "Blu-ray"; + discSubType = "BD-RE"; + break; + case CommonTypes.MediaType.BDREXL: + discType = "Blu-ray"; + discSubType = "BD-RE XL"; + break; + case CommonTypes.MediaType.BDROM: + discType = "Blu-ray"; + discSubType = "BD-ROM"; + break; + case CommonTypes.MediaType.BDRXL: + discType = "Blu-ray"; + discSubType = "BD-R XL"; + break; + case CommonTypes.MediaType.CBHD: + discType = "Blu-ray"; + discSubType = "CBHD"; + break; + case CommonTypes.MediaType.CD: + discType = "Compact Disc"; + discSubType = "CD"; + break; + case CommonTypes.MediaType.CDDA: + discType = "Compact Disc"; + discSubType = "CD Digital Audio"; + break; + case CommonTypes.MediaType.CDEG: + discType = "Compact Disc"; + discSubType = "CD+EG"; + break; + case CommonTypes.MediaType.CDG: + discType = "Compact Disc"; + discSubType = "CD+G"; + break; + case CommonTypes.MediaType.CDI: + discType = "Compact Disc"; + discSubType = "CD-i"; + break; + case CommonTypes.MediaType.CDMIDI: + discType = "Compact Disc"; + discSubType = "CD+MIDI"; + break; + case CommonTypes.MediaType.CDMO: + discType = "Compact Disc"; + discSubType = "CD-MO"; + break; + case CommonTypes.MediaType.CDMRW: + discType = "Compact Disc"; + discSubType = "CD-MRW"; + break; + case CommonTypes.MediaType.CDPLUS: + discType = "Compact Disc"; + discSubType = "CD+"; + break; + case CommonTypes.MediaType.CDR: + discType = "Compact Disc"; + discSubType = "CD-R"; + break; + case CommonTypes.MediaType.CDROM: + discType = "Compact Disc"; + discSubType = "CD-ROM"; + break; + case CommonTypes.MediaType.CDROMXA: + discType = "Compact Disc"; + discSubType = "CD-ROM XA"; + break; + case CommonTypes.MediaType.CDRW: + discType = "Compact Disc"; + discSubType = "CD-RW"; + break; + case CommonTypes.MediaType.CDV: + discType = "Compact Disc"; + discSubType = "CD-Video"; + break; + case CommonTypes.MediaType.DDCD: + discType = "DDCD"; + discSubType = "DDCD"; + break; + case CommonTypes.MediaType.DDCDR: + discType = "DDCD"; + discSubType = "DDCD-R"; + break; + case CommonTypes.MediaType.DDCDRW: + discType = "DDCD"; + discSubType = "DDCD-RW"; + break; + case CommonTypes.MediaType.DTSCD: + discType = "Compact Disc"; + discSubType = "DTS CD"; + break; + case CommonTypes.MediaType.DVDDownload: + discType = "DVD"; + discSubType = "DVD-Download"; + break; + case CommonTypes.MediaType.DVDPR: + discType = "DVD"; + discSubType = "DVD+R"; + break; + case CommonTypes.MediaType.DVDPRDL: + discType = "DVD"; + discSubType = "DVD+R DL"; + break; + case CommonTypes.MediaType.DVDPRW: + discType = "DVD"; + discSubType = "DVD+RW"; + break; + case CommonTypes.MediaType.DVDPRWDL: + discType = "DVD"; + discSubType = "DVD+RW DL"; + break; + case CommonTypes.MediaType.DVDR: + discType = "DVD"; + discSubType = "DVD-R"; + break; + case CommonTypes.MediaType.DVDRAM: + discType = "DVD"; + discSubType = "DVD-RAM"; + break; + case CommonTypes.MediaType.DVDRDL: + discType = "DVD"; + discSubType = "DVD-R DL"; + break; + case CommonTypes.MediaType.DVDROM: + discType = "DVD"; + discSubType = "DVD-ROM"; + break; + case CommonTypes.MediaType.DVDRW: + discType = "DVD"; + discSubType = "DVD-RW"; + break; + case CommonTypes.MediaType.DVDRWDL: + discType = "DVD"; + discSubType = "DVD-RW DL"; + break; + case CommonTypes.MediaType.EVD: + discType = "EVD"; + discSubType = "EVD"; + break; + case CommonTypes.MediaType.FDDVD: + discType = "FDDVD"; + discSubType = "FDDVD"; + break; + case CommonTypes.MediaType.FVD: + discType = "FVD"; + discSubType = "FVD"; + break; + case CommonTypes.MediaType.GDR: + discType = "GD"; + discSubType = "GD-R"; + break; + case CommonTypes.MediaType.GDROM: + discType = "GD"; + discSubType = "GD-ROM"; + break; + case CommonTypes.MediaType.GOD: + discType = "DVD"; + discSubType = "GameCube Game Disc"; + break; + case CommonTypes.MediaType.WOD: + discType = "DVD"; + discSubType = "Wii Optical Disc"; + break; + case CommonTypes.MediaType.WUOD: + discType = "Blu-ray"; + discSubType = "Wii U Optical Disc"; + break; + case CommonTypes.MediaType.HDDVDR: + discType = "HD DVD"; + discSubType = "HD DVD-R"; + break; + case CommonTypes.MediaType.HDDVDRAM: + discType = "HD DVD"; + discSubType = "HD DVD-RAM"; + break; + case CommonTypes.MediaType.HDDVDRDL: + discType = "HD DVD"; + discSubType = "HD DVD-R DL"; + break; + case CommonTypes.MediaType.HDDVDROM: + discType = "HD DVD"; + discSubType = "HD DVD-ROM"; + break; + case CommonTypes.MediaType.HDDVDRW: + discType = "HD DVD"; + discSubType = "HD DVD-RW"; + break; + case CommonTypes.MediaType.HDDVDRWDL: + discType = "HD DVD"; + discSubType = "HD DVD-RW DL"; + break; + case CommonTypes.MediaType.HDVMD: + discType = "HD VMD"; + discSubType = "HD VMD"; + break; + case CommonTypes.MediaType.HiMD: + discType = "MiniDisc"; + discSubType = "HiMD"; + break; + case CommonTypes.MediaType.HVD: + discType = "HVD"; + discSubType = "HVD"; + break; + case CommonTypes.MediaType.LD: + discType = "LaserDisc"; + discSubType = "LaserDisc"; + break; + case CommonTypes.MediaType.LDROM: + discType = "LaserDisc"; + discSubType = "LD-ROM"; + break; + case CommonTypes.MediaType.LVROM: + discType = "LaserDisc"; + discSubType = "LV-ROM"; + break; + case CommonTypes.MediaType.MegaLD: + discType = "LaserDisc"; + discSubType = "MegaLD"; + break; + case CommonTypes.MediaType.MD: + discType = "MiniDisc"; + discSubType = "MiniDisc"; + break; + case CommonTypes.MediaType.MEGACD: + discType = "Compact Disc"; + discSubType = "Sega Mega CD"; + break; + case CommonTypes.MediaType.PCD: + discType = "Compact Disc"; + discSubType = "Photo CD"; + break; + case CommonTypes.MediaType.PlayStationMemoryCard: + discType = "PlayStation Memory Card"; + discSubType = "PlayStation Memory Card"; + break; + case CommonTypes.MediaType.PlayStationMemoryCard2: + discType = "PlayStation Memory Card"; + discSubType = "PlayStation 2 Memory Card"; + break; + case CommonTypes.MediaType.PS1CD: + discType = "Compact Disc"; + discSubType = "PlayStation Game Disc"; + break; + case CommonTypes.MediaType.PS2CD: + discType = "Compact Disc"; + discSubType = "PlayStation 2 Game Disc"; + break; + case CommonTypes.MediaType.PS2DVD: + discType = "DVD"; + discSubType = "PlayStation 2 Game Disc"; + break; + case CommonTypes.MediaType.PS3BD: + discType = "Blu-ray"; + discSubType = "PlayStation 3 Game Disc"; + break; + case CommonTypes.MediaType.PS3DVD: + discType = "DVD"; + discSubType = "PlayStation 3 Game Disc"; + break; + case CommonTypes.MediaType.PS4BD: + discType = "Blu-ray"; + discSubType = "PlayStation 4 Game Disc"; + break; + case CommonTypes.MediaType.SACD: + discType = "SACD"; + discSubType = "Super Audio CD"; + break; + case CommonTypes.MediaType.SegaCard: + discType = "Sega Card"; + discSubType = "Sega Card"; + break; + case CommonTypes.MediaType.SATURNCD: + discType = "Compact Disc"; + discSubType = "Sega Saturn CD"; + break; + case CommonTypes.MediaType.SVCD: + discType = "Compact Disc"; + discSubType = "Super Video CD"; + break; + case CommonTypes.MediaType.SVOD: + discType = "SVOD"; + discSubType = "SVOD"; + break; + case CommonTypes.MediaType.UDO: + discType = "UDO"; + discSubType = "UDO"; + break; + case CommonTypes.MediaType.UMD: + discType = "UMD"; + discSubType = "Universal Media Disc"; + break; + case CommonTypes.MediaType.VCD: + discType = "Compact Disc"; + discSubType = "Video CD"; + break; + case CommonTypes.MediaType.XGD: + discType = "DVD"; + discSubType = "Xbox Game Disc (XGD)"; + break; + case CommonTypes.MediaType.XGD2: + discType = "DVD"; + discSubType = "Xbox 360 Game Disc (XGD2)"; + break; + case CommonTypes.MediaType.XGD3: + discType = "DVD"; + discSubType = "Xbox 360 Game Disc (XGD3)"; + break; + case CommonTypes.MediaType.XGD4: + discType = "Blu-ray"; + discSubType = "Xbox One Game Disc (XGD4)"; + break; + case CommonTypes.MediaType.Apple32SS: + discType = "5.25\" floppy"; + discSubType = "Apple DOS 3.2"; + break; + case CommonTypes.MediaType.Apple32DS: + discType = "5.25\" floppy"; + discSubType = "Apple DOS 3.2 (double-sided)"; + break; + case CommonTypes.MediaType.Apple33SS: + discType = "5.25\" floppy"; + discSubType = "Apple DOS 3.3"; + break; + case CommonTypes.MediaType.Apple33DS: + discType = "5.25\" floppy"; + discSubType = "Apple DOS 3.3 (double-sided)"; + break; + case CommonTypes.MediaType.AppleSonySS: + discType = "3.5\" floppy"; + discSubType = "Apple 400K"; + break; + case CommonTypes.MediaType.AppleSonyDS: + discType = "3.5\" floppy"; + discSubType = "Apple 800K"; + break; + case CommonTypes.MediaType.AppleFileWare: + discType = "5.25\" floppy"; + discSubType = "Apple FileWare"; + break; + case CommonTypes.MediaType.RX50: + discType = "5.25\" floppy"; + discSubType = "DEC RX50"; + break; + case CommonTypes.MediaType.DOS_525_SS_DD_8: + discType = "5.25\" floppy"; + discSubType = "IBM double-density, single-sided, 8 sectors"; + break; + case CommonTypes.MediaType.DOS_525_SS_DD_9: + discType = "5.25\" floppy"; + discSubType = "IBM double-density, single-sided, 9 sectors"; + break; + case CommonTypes.MediaType.DOS_525_DS_DD_8: + discType = "5.25\" floppy"; + discSubType = "IBM double-density, double-sided, 8 sectors"; + break; + case CommonTypes.MediaType.DOS_525_DS_DD_9: + discType = "5.25\" floppy"; + discSubType = "IBM double-density, double-sided, 9 sectors"; + break; + case CommonTypes.MediaType.DOS_525_HD: + discType = "5.25\" floppy"; + discSubType = "IBM high-density"; + break; + case CommonTypes.MediaType.DOS_35_SS_DD_8: + discType = "3.5\" floppy"; + discSubType = "IBM double-density, single-sided, 8 sectors"; + break; + case CommonTypes.MediaType.DOS_35_SS_DD_9: + discType = "3.5\" floppy"; + discSubType = "IBM double-density, single-sided, 9 sectors"; + break; + case CommonTypes.MediaType.DOS_35_DS_DD_8: + discType = "3.5\" floppy"; + discSubType = "IBM double-density, double-sided, 8 sectors"; + break; + case CommonTypes.MediaType.DOS_35_DS_DD_9: + discType = "3.5\" floppy"; + discSubType = "IBM double-density, double-sided, 9 sectors"; + break; + case CommonTypes.MediaType.DOS_35_HD: + discType = "3.5\" floppy"; + discSubType = "IBM high-density"; + break; + case CommonTypes.MediaType.DOS_35_ED: + discType = "3.5\" floppy"; + discSubType = "IBM extra-density"; + break; + case CommonTypes.MediaType.Apricot_35: + discType = "3.5\" floppy"; + discSubType = "Apricot double-density, single-sided, 70 tracks"; + break; + case CommonTypes.MediaType.DMF: + discType = "3.5\" floppy"; + discSubType = "Microsoft DMF"; + break; + case CommonTypes.MediaType.DMF_82: + discType = "3.5\" floppy"; + discSubType = "Microsoft DMF (82-track)"; + break; + case CommonTypes.MediaType.XDF_35: + discType = "3.5\" floppy"; + discSubType = "IBM XDF"; + break; + case CommonTypes.MediaType.XDF_525: + discType = "5.25\" floppy"; + discSubType = "IBM XDF"; + break; + case CommonTypes.MediaType.IBM23FD: + discType = "8\" floppy"; + discSubType = "IBM 23FD"; + break; + case CommonTypes.MediaType.IBM33FD_128: + discType = "8\" floppy"; + discSubType = "IBM 33FD (128 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM33FD_256: + discType = "8\" floppy"; + discSubType = "IBM 33FD (256 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM33FD_512: + discType = "8\" floppy"; + discSubType = "IBM 33FD (512 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM43FD_128: + discType = "8\" floppy"; + discSubType = "IBM 43FD (128 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM43FD_256: + discType = "8\" floppy"; + discSubType = "IBM 43FD (256 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM53FD_256: + discType = "8\" floppy"; + discSubType = "IBM 53FD (256 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM53FD_512: + discType = "8\" floppy"; + discSubType = "IBM 53FD (512 bytes/sector)"; + break; + case CommonTypes.MediaType.IBM53FD_1024: + discType = "8\" floppy"; + discSubType = "IBM 53FD (1024 bytes/sector)"; + break; + case CommonTypes.MediaType.RX01: + discType = "8\" floppy"; + discSubType = "DEC RX-01"; + break; + case CommonTypes.MediaType.RX02: + discType = "8\" floppy"; + discSubType = "DEC RX-02"; + break; + case CommonTypes.MediaType.RX03: + discType = "8\" floppy"; + discSubType = "DEC RX-03"; + break; + case CommonTypes.MediaType.ACORN_525_SS_SD_40: + discType = "5.25\" floppy"; + discSubType = "BBC Micro 100K"; + break; + case CommonTypes.MediaType.ACORN_525_SS_SD_80: + discType = "5.25\" floppy"; + discSubType = "BBC Micro 200K"; + break; + case CommonTypes.MediaType.ACORN_525_SS_DD_40: + discType = "5.25\" floppy"; + discSubType = "Acorn S"; + break; + case CommonTypes.MediaType.ACORN_525_SS_DD_80: + discType = "5.25\" floppy"; + discSubType = "Acorn M"; + break; + case CommonTypes.MediaType.ACORN_525_DS_DD: + discType = "5.25\" floppy"; + discSubType = "Acorn L"; + break; + case CommonTypes.MediaType.ACORN_35_DS_DD: + discType = "3.5\" floppy"; + discSubType = "Acorn Archimedes"; + break; + case CommonTypes.MediaType.ACORN_35_DS_HD: + discType = "3.5\" floppy"; + discSubType = "Acorn Archimedes high-density"; + break; + case CommonTypes.MediaType.ATARI_525_SD: + discType = "5.25\" floppy"; + discSubType = "Atari single-density"; + break; + case CommonTypes.MediaType.ATARI_525_ED: + discType = "5.25\" floppy"; + discSubType = "Atari enhanced-density"; + break; + case CommonTypes.MediaType.ATARI_525_DD: + discType = "5.25\" floppy"; + discSubType = "Atari double-density"; + break; + case CommonTypes.MediaType.ATARI_35_SS_DD: + discType = "3.5\" floppy"; + discSubType = "Atari ST double-density, single-sided, 10 sectors"; + break; + case CommonTypes.MediaType.ATARI_35_DS_DD: + discType = "3.5\" floppy"; + discSubType = "Atari ST double-density, double-sided, 10 sectors"; + break; + case CommonTypes.MediaType.ATARI_35_SS_DD_11: + discType = "3.5\" floppy"; + discSubType = "Atari ST double-density, single-sided, 11 sectors"; + break; + case CommonTypes.MediaType.ATARI_35_DS_DD_11: + discType = "3.5\" floppy"; + discSubType = "Atari ST double-density, double-sided, 11 sectors"; + break; + case CommonTypes.MediaType.CBM_1540: + case CommonTypes.MediaType.CBM_1540_Ext: + discType = "5.25\" floppy"; + discSubType = "Commodore 1540/1541"; + break; + case CommonTypes.MediaType.CBM_1571: + discType = "5.25\" floppy"; + discSubType = "Commodore 1571"; + break; + case CommonTypes.MediaType.CBM_35_DD: + discType = "3.5\" floppy"; + discSubType = "Commodore 1581"; + break; + case CommonTypes.MediaType.CBM_AMIGA_35_DD: + discType = "3.5\" floppy"; + discSubType = "Amiga double-density"; + break; + case CommonTypes.MediaType.CBM_AMIGA_35_HD: + discType = "3.5\" floppy"; + discSubType = "Amiga high-density"; + break; + case CommonTypes.MediaType.NEC_8_SD: + discType = "8\" floppy"; + discSubType = "NEC single-sided"; + break; + case CommonTypes.MediaType.NEC_8_DD: + discType = "8\" floppy"; + discSubType = "NEC double-sided"; + break; + case CommonTypes.MediaType.NEC_525_SS: + discType = "5.25\" floppy"; + discSubType = "NEC single-sided"; + break; + case CommonTypes.MediaType.NEC_525_HD: + discType = "5.25\" floppy"; + discSubType = "NEC high-density"; + break; + case CommonTypes.MediaType.NEC_35_HD_8: + discType = "3.5\" floppy"; + discSubType = "NEC high-density"; + break; + case CommonTypes.MediaType.NEC_35_HD_15: + discType = "3.5\" floppy"; + discSubType = "NEC high-density"; + break; + case CommonTypes.MediaType.NEC_35_TD: + discType = "3.5\" floppy"; + discSubType = "NEC triple-density"; + break; + case CommonTypes.MediaType.SHARP_525_9: + discType = "5.25\" floppy"; + discSubType = "Sharp (9 sectors per track)"; + break; + case CommonTypes.MediaType.SHARP_35_9: + discType = "3.5\" floppy"; + discSubType = "Sharp (9 sectors per track)"; + break; + case CommonTypes.MediaType.ECMA_54: + discType = "8\" floppy"; + discSubType = "ECMA-54"; + break; + case CommonTypes.MediaType.ECMA_59: + discType = "8\" floppy"; + discSubType = "ECMA-59"; + break; + case CommonTypes.MediaType.ECMA_69_8: + case CommonTypes.MediaType.ECMA_69_15: + case CommonTypes.MediaType.ECMA_69_26: + discType = "8\" floppy"; + discSubType = "ECMA-69"; + break; + case CommonTypes.MediaType.ECMA_66: + discType = "5.25\" floppy"; + discSubType = "ECMA-66"; + break; + case CommonTypes.MediaType.ECMA_70: + discType = "5.25\" floppy"; + discSubType = "ECMA-70"; + break; + case CommonTypes.MediaType.ECMA_78: + case CommonTypes.MediaType.ECMA_78_2: + discType = "5.25\" floppy"; + discSubType = "ECMA-78"; + break; + case CommonTypes.MediaType.ECMA_99_8: + case CommonTypes.MediaType.ECMA_99_15: + case CommonTypes.MediaType.ECMA_99_26: + discType = "5.25\" floppy"; + discSubType = "ECMA-99"; + break; + case CommonTypes.MediaType.FDFORMAT_525_DD: + discType = "5.25\" floppy"; + discSubType = "FDFORMAT double-density"; + break; + case CommonTypes.MediaType.FDFORMAT_525_HD: + discType = "5.25\" floppy"; + discSubType = "FDFORMAT high-density"; + break; + case CommonTypes.MediaType.FDFORMAT_35_DD: + discType = "3.5\" floppy"; + discSubType = "FDFORMAT double-density"; + break; + case CommonTypes.MediaType.FDFORMAT_35_HD: + discType = "3.5\" floppy"; + discSubType = "FDFORMAT high-density"; + break; + case CommonTypes.MediaType.ECMA_260: + case CommonTypes.MediaType.ECMA_260_Double: + discType = "356mm magneto-optical"; + discSubType = "ECMA-260 / ISO 15898"; + break; + case CommonTypes.MediaType.ECMA_183_512: + case CommonTypes.MediaType.ECMA_183: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-183"; + break; + case CommonTypes.MediaType.ECMA_184_512: + case CommonTypes.MediaType.ECMA_184: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-184"; + break; + case CommonTypes.MediaType.ECMA_154: + discType = "3.5\" magneto-optical"; + discSubType = "ECMA-154"; + break; + case CommonTypes.MediaType.ECMA_201: + case CommonTypes.MediaType.ECMA_201_ROM: + discType = "3.5\" magneto-optical"; + discSubType = "ECMA-201"; + break; + case CommonTypes.MediaType.FlashDrive: + discType = "USB flash drive"; + discSubType = "USB flash drive"; + break; + case CommonTypes.MediaType.SuperCDROM2: + discType = "Compact Disc"; + discSubType = "Super CD-ROM²"; + break; + case CommonTypes.MediaType.LDROM2: + discType = "LaserDisc"; + discSubType = "LD-ROM²"; + break; + case CommonTypes.MediaType.JaguarCD: + discType = "Compact Disc"; + discSubType = "Atari Jaguar CD"; + break; + case CommonTypes.MediaType.ThreeDO: + discType = "Compact Disc"; + discSubType = "3DO"; + break; + case CommonTypes.MediaType.PCFX: + discType = "Compact Disc"; + discSubType = "PC-FX"; + break; + case CommonTypes.MediaType.NeoGeoCD: + discType = "Compact Disc"; + discSubType = "NEO-GEO CD"; + break; + case CommonTypes.MediaType.ZIP100: + discType = "Iomega ZIP"; + discSubType = "Iomega ZIP100"; + break; + case CommonTypes.MediaType.ZIP250: + discType = "Iomega ZIP"; + discSubType = "Iomega ZIP250"; + break; + case CommonTypes.MediaType.ZIP750: + discType = "Iomega ZIP"; + discSubType = "Iomega ZIP750"; + break; + case CommonTypes.MediaType.AppleProfile: + discType = "Hard Disk Drive"; + discSubType = "Apple Profile"; + break; + case CommonTypes.MediaType.AppleWidget: + discType = "Hard Disk Drive"; + discSubType = "Apple Widget"; + break; + case CommonTypes.MediaType.AppleHD20: + discType = "Hard Disk Drive"; + discSubType = "Apple HD20"; + break; + case CommonTypes.MediaType.PriamDataTower: + discType = "Hard Disk Drive"; + discSubType = "Priam DataTower"; + break; + case CommonTypes.MediaType.DDS1: + discType = "Digital Data Storage"; + discSubType = "DDS"; + break; + case CommonTypes.MediaType.DDS2: + discType = "Digital Data Storage"; + discSubType = "DDS-2"; + break; + case CommonTypes.MediaType.DDS3: + discType = "Digital Data Storage"; + discSubType = "DDS-3"; + break; + case CommonTypes.MediaType.DDS4: + discType = "Digital Data Storage"; + discSubType = "DDS-4"; + break; + case CommonTypes.MediaType.PocketZip: + discType = "Iomega PocketZip"; + discSubType = "Iomega PocketZip"; + break; + case CommonTypes.MediaType.CompactFloppy: + discType = "3\" floppy"; + discSubType = "Compact Floppy"; + break; + case CommonTypes.MediaType.GENERIC_HDD: + discType = "Hard Disk Drive"; + discSubType = "Unknown"; + break; + case CommonTypes.MediaType.MDData: + discType = "MiniDisc"; + discSubType = "MD-DATA"; + break; + case CommonTypes.MediaType.MDData2: + discType = "MiniDisc"; + discSubType = "MD-DATA2"; + break; + case CommonTypes.MediaType.UDO2: + discType = "UDO"; + discSubType = "UDO2"; + break; + case CommonTypes.MediaType.UDO2_WORM: + discType = "UDO"; + discSubType = "UDO2 (WORM)"; + break; + case CommonTypes.MediaType.ADR30: + discType = "Advanced Digital Recording"; + discSubType = "ADR 30"; + break; + case CommonTypes.MediaType.ADR50: + discType = "Advanced Digital Recording"; + discSubType = "ADR 50"; + break; + case CommonTypes.MediaType.ADR260: + discType = "Advanced Digital Recording"; + discSubType = "ADR 2.60"; + break; + case CommonTypes.MediaType.ADR2120: + discType = "Advanced Digital Recording"; + discSubType = "ADR 2.120"; + break; + case CommonTypes.MediaType.AIT1: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-1"; + break; + case CommonTypes.MediaType.AIT1Turbo: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-1 Turbo"; + break; + case CommonTypes.MediaType.AIT2: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-2"; + break; + case CommonTypes.MediaType.AIT2Turbo: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-2 Turbo"; + break; + case CommonTypes.MediaType.AIT3: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-3"; + break; + case CommonTypes.MediaType.AIT3Ex: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-3Ex"; + break; + case CommonTypes.MediaType.AIT3Turbo: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-3 Turbo"; + break; + case CommonTypes.MediaType.AIT4: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-4"; + break; + case CommonTypes.MediaType.AIT5: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-5"; + break; + case CommonTypes.MediaType.AITETurbo: + discType = "Advanced Intelligent Tape"; + discSubType = "AIT-E Turbo"; + break; + case CommonTypes.MediaType.SAIT1: + discType = "Super Advanced Intelligent Tape"; + discSubType = "SAIT-1"; + break; + case CommonTypes.MediaType.SAIT2: + discType = "Super Advanced Intelligent Tape"; + discSubType = "SAIT-2"; + break; + case CommonTypes.MediaType.Bernoulli: + discType = "Iomega Bernoulli"; + discSubType = "Iomega Bernoulli"; + break; + case CommonTypes.MediaType.Bernoulli2: + discType = "Iomega Bernoulli"; + discSubType = "Iomega Bernoulli 2"; + break; + case CommonTypes.MediaType.Ditto: + discType = "Iomega Ditto"; + discSubType = "Iomega Ditto"; + break; + case CommonTypes.MediaType.DittoMax: + discType = "Iomega Ditto"; + discSubType = "Iomega Ditto Max"; + break; + case CommonTypes.MediaType.Jaz: + discType = "Iomega Jaz"; + discSubType = "Iomega Jaz 1GB"; + break; + case CommonTypes.MediaType.Jaz2: + discType = "Iomega Jaz"; + discSubType = "Iomega Jaz 2GB"; + break; + case CommonTypes.MediaType.REV35: + discType = "Iomega REV"; + discSubType = "Iomega REV-35"; + break; + case CommonTypes.MediaType.REV70: + discType = "Iomega REV"; + discSubType = "Iomega REV-70"; + break; + case CommonTypes.MediaType.REV120: + discType = "Iomega REV"; + discSubType = "Iomega REV-120"; + break; + case CommonTypes.MediaType.CompactFlash: + discType = "Compact Flash"; + discSubType = "Compact Flash"; + break; + case CommonTypes.MediaType.CompactFlashType2: + discType = "Compact Flash"; + discSubType = "Compact Flash Type 2"; + break; + case CommonTypes.MediaType.CFast: + discType = "Compact Flash"; + discSubType = "CFast"; + break; + case CommonTypes.MediaType.DigitalAudioTape: + discType = "Digital Audio Tape"; + discSubType = "Digital Audio Tape"; + break; + case CommonTypes.MediaType.DAT72: + discType = "Digital Data Storage"; + discSubType = "DAT-72"; + break; + case CommonTypes.MediaType.DAT160: + discType = "Digital Data Storage"; + discSubType = "DAT-160"; + break; + case CommonTypes.MediaType.DAT320: + discType = "Digital Data Storage"; + discSubType = "DAT-320"; + break; + case CommonTypes.MediaType.DECtapeII: + discType = "DECtape"; + discSubType = "DECtape II"; + break; + case CommonTypes.MediaType.CompactTapeI: + discType = "CompacTape"; + discSubType = "CompacTape"; + break; + case CommonTypes.MediaType.CompactTapeII: + discType = "CompacTape"; + discSubType = "CompacTape II"; + break; + case CommonTypes.MediaType.DLTtapeIII: + discType = "Digital Linear Tape"; + discSubType = "DLTtape III"; + break; + case CommonTypes.MediaType.DLTtapeIIIxt: + discType = "Digital Linear Tape"; + discSubType = "DLTtape IIIXT"; + break; + case CommonTypes.MediaType.DLTtapeIV: + discType = "Digital Linear Tape"; + discSubType = "DLTtape IV"; + break; + case CommonTypes.MediaType.DLTtapeS4: + discType = "Digital Linear Tape"; + discSubType = "DLTtape S4"; + break; + case CommonTypes.MediaType.SDLT1: + discType = "Super Digital Linear Tape"; + discSubType = "SDLTtape I"; + break; + case CommonTypes.MediaType.SDLT2: + discType = "Super Digital Linear Tape"; + discSubType = "SDLTtape II"; + break; + case CommonTypes.MediaType.VStapeI: + discType = "Digital Linear Tape"; + discSubType = "DLTtape VS1"; + break; + case CommonTypes.MediaType.Data8: + discType = "Data8"; + discSubType = "Data8"; + break; + case CommonTypes.MediaType.MiniDV: + discType = "DV tape"; + discSubType = "MiniDV"; + break; + case CommonTypes.MediaType.Exatape15m: + discType = "Exatape"; + discSubType = "Exatape (15m)"; + break; + case CommonTypes.MediaType.Exatape22m: + discType = "Exatape"; + discSubType = "Exatape (22m)"; + break; + case CommonTypes.MediaType.Exatape22mAME: + discType = "Exatape"; + discSubType = "Exatape (22m AME)"; + break; + case CommonTypes.MediaType.Exatape28m: + discType = "Exatape"; + discSubType = "Exatape (28m)"; + break; + case CommonTypes.MediaType.Exatape40m: + discType = "Exatape"; + discSubType = "Exatape (40m)"; + break; + case CommonTypes.MediaType.Exatape45m: + discType = "Exatape"; + discSubType = "Exatape (45m)"; + break; + case CommonTypes.MediaType.Exatape54m: + discType = "Exatape"; + discSubType = "Exatape (54m)"; + break; + case CommonTypes.MediaType.Exatape75m: + discType = "Exatape"; + discSubType = "Exatape (75m)"; + break; + case CommonTypes.MediaType.Exatape76m: + discType = "Exatape"; + discSubType = "Exatape (76m)"; + break; + case CommonTypes.MediaType.Exatape80m: + discType = "Exatape"; + discSubType = "Exatape (80m)"; + break; + case CommonTypes.MediaType.Exatape106m: + discType = "Exatape"; + discSubType = "Exatape (106m)"; + break; + case CommonTypes.MediaType.Exatape112m: + discType = "Exatape"; + discSubType = "Exatape (112m)"; + break; + case CommonTypes.MediaType.Exatape125m: + discType = "Exatape"; + discSubType = "Exatape (125m)"; + break; + case CommonTypes.MediaType.Exatape150m: + discType = "Exatape"; + discSubType = "Exatape (150m)"; + break; + case CommonTypes.MediaType.Exatape160mXL: + discType = "Exatape"; + discSubType = "Exatape XL (160m)"; + break; + case CommonTypes.MediaType.Exatape170m: + discType = "Exatape"; + discSubType = "Exatape (170m)"; + break; + case CommonTypes.MediaType.Exatape225m: + discType = "Exatape"; + discSubType = "Exatape (225m)"; + break; + case CommonTypes.MediaType.EZ135: + discType = "3.5\" SyQuest cartridge"; + discSubType = "EZ135"; + break; + case CommonTypes.MediaType.EZ230: + discType = "3.5\" SyQuest cartridge"; + discSubType = "EZ230"; + break; + case CommonTypes.MediaType.Quest: + discType = "3.5\" SyQuest cartridge"; + discSubType = "Quest"; + break; + case CommonTypes.MediaType.SparQ: + discType = "3.5\" SyQuest cartridge"; + discSubType = "SparQ"; + break; + case CommonTypes.MediaType.SQ100: + discType = "3.9\" SyQuest cartridge"; + discSubType = "SQ100"; + break; + case CommonTypes.MediaType.SQ200: + discType = "3.9\" SyQuest cartridge"; + discSubType = "SQ200"; + break; + case CommonTypes.MediaType.SQ300: + discType = "3.9\" SyQuest cartridge"; + discSubType = "SQ300"; + break; + case CommonTypes.MediaType.SQ310: + discType = "3.5\" SyQuest cartridge"; + discSubType = "SQ310"; + break; + case CommonTypes.MediaType.SQ327: + discType = "3.5\" SyQuest cartridge"; + discSubType = "SQ327"; + break; + case CommonTypes.MediaType.SQ400: + discType = "5.25\" SyQuest cartridge"; + discSubType = "SQ400"; + break; + case CommonTypes.MediaType.SQ800: + discType = "5.25\" SyQuest cartridge"; + discSubType = "SQ800"; + break; + case CommonTypes.MediaType.SQ1500: + discType = "3.5\" SyQuest cartridge"; + discSubType = "SQ1500"; + break; + case CommonTypes.MediaType.SQ2000: + discType = "5.25\" SyQuest cartridge"; + discSubType = "SQ2000"; + break; + case CommonTypes.MediaType.SyJet: + discType = "3.5\" SyQuest cartridge"; + discSubType = "SyJet"; + break; + case CommonTypes.MediaType.LTO: + discType = "Linear Tape-Open"; + discSubType = "LTO"; + break; + case CommonTypes.MediaType.LTO2: + discType = "Linear Tape-Open"; + discSubType = "LTO-2"; + break; + case CommonTypes.MediaType.LTO3: + discType = "Linear Tape-Open"; + discSubType = "LTO-3"; + break; + case CommonTypes.MediaType.LTO3WORM: + discType = "Linear Tape-Open"; + discSubType = "LTO-3 (WORM)"; + break; + case CommonTypes.MediaType.LTO4: + discType = "Linear Tape-Open"; + discSubType = "LTO-4"; + break; + case CommonTypes.MediaType.LTO4WORM: + discType = "Linear Tape-Open"; + discSubType = "LTO-4 (WORM)"; + break; + case CommonTypes.MediaType.LTO5: + discType = "Linear Tape-Open"; + discSubType = "LTO-5"; + break; + case CommonTypes.MediaType.LTO5WORM: + discType = "Linear Tape-Open"; + discSubType = "LTO-5 (WORM)"; + break; + case CommonTypes.MediaType.LTO6: + discType = "Linear Tape-Open"; + discSubType = "LTO-6"; + break; + case CommonTypes.MediaType.LTO6WORM: + discType = "Linear Tape-Open"; + discSubType = "LTO-6 (WORM)"; + break; + case CommonTypes.MediaType.LTO7: + discType = "Linear Tape-Open"; + discSubType = "LTO-7"; + break; + case CommonTypes.MediaType.LTO7WORM: + discType = "Linear Tape-Open"; + discSubType = "LTO-7 (WORM)"; + break; + case CommonTypes.MediaType.MemoryStick: + discType = "Memory Stick"; + discSubType = "Memory Stick"; + break; + case CommonTypes.MediaType.MemoryStickDuo: + discType = "Memory Stick"; + discSubType = "Memory Stick Duo"; + break; + case CommonTypes.MediaType.MemoryStickMicro: + discType = "Memory Stick"; + discSubType = "Memory Stick Micro"; + break; + case CommonTypes.MediaType.MemoryStickPro: + discType = "Memory Stick"; + discSubType = "Memory Stick Pro"; + break; + case CommonTypes.MediaType.MemoryStickProDuo: + discType = "Memory Stick"; + discSubType = "Memory Stick PRO Duo"; + break; + case CommonTypes.MediaType.SecureDigital: + discType = "Secure Digital"; + discSubType = "Secure Digital"; + break; + case CommonTypes.MediaType.miniSD: + discType = "Secure Digital"; + discSubType = "miniSD"; + break; + case CommonTypes.MediaType.microSD: + discType = "Secure Digital"; + discSubType = "microSD"; + break; + case CommonTypes.MediaType.MMC: + discType = "MultiMediaCard"; + discSubType = "MultiMediaCard"; + break; + case CommonTypes.MediaType.MMCmicro: + discType = "MultiMediaCard"; + discSubType = "MMCmicro"; + break; + case CommonTypes.MediaType.RSMMC: + discType = "MultiMediaCard"; + discSubType = "Reduced-Size MultiMediaCard"; + break; + case CommonTypes.MediaType.MMCplus: + discType = "MultiMediaCard"; + discSubType = "MMCplus"; + break; + case CommonTypes.MediaType.MMCmobile: + discType = "MultiMediaCard"; + discSubType = "MMCmobile"; + break; + case CommonTypes.MediaType.MLR1: + discType = "Scalable Linear Recording"; + discSubType = "MLR1"; + break; + case CommonTypes.MediaType.MLR1SL: + discType = "Scalable Linear Recording"; + discSubType = "MLR1 SL"; + break; + case CommonTypes.MediaType.MLR3: + discType = "Scalable Linear Recording"; + discSubType = "MLR3"; + break; + case CommonTypes.MediaType.SLR1: + discType = "Scalable Linear Recording"; + discSubType = "SLR1"; + break; + case CommonTypes.MediaType.SLR2: + discType = "Scalable Linear Recording"; + discSubType = "SLR2"; + break; + case CommonTypes.MediaType.SLR3: + discType = "Scalable Linear Recording"; + discSubType = "SLR3"; + break; + case CommonTypes.MediaType.SLR32: + discType = "Scalable Linear Recording"; + discSubType = "SLR32"; + break; + case CommonTypes.MediaType.SLR32SL: + discType = "Scalable Linear Recording"; + discSubType = "SLR32 SL"; + break; + case CommonTypes.MediaType.SLR4: + discType = "Scalable Linear Recording"; + discSubType = "SLR4"; + break; + case CommonTypes.MediaType.SLR5: + discType = "Scalable Linear Recording"; + discSubType = "SLR5"; + break; + case CommonTypes.MediaType.SLR5SL: + discType = "Scalable Linear Recording"; + discSubType = "SLR5 SL"; + break; + case CommonTypes.MediaType.SLR6: + discType = "Scalable Linear Recording"; + discSubType = "SLR6"; + break; + case CommonTypes.MediaType.SLRtape7: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape7"; + break; + case CommonTypes.MediaType.SLRtape7SL: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape7 SL"; + break; + case CommonTypes.MediaType.SLRtape24: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape24"; + break; + case CommonTypes.MediaType.SLRtape24SL: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape24 SL"; + break; + case CommonTypes.MediaType.SLRtape40: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape40"; + break; + case CommonTypes.MediaType.SLRtape50: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape50"; + break; + case CommonTypes.MediaType.SLRtape60: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape60"; + break; + case CommonTypes.MediaType.SLRtape75: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape75"; + break; + case CommonTypes.MediaType.SLRtape100: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape100"; + break; + case CommonTypes.MediaType.SLRtape140: + discType = "Scalable Linear Recording"; + discSubType = "SLRtape140"; + break; + case CommonTypes.MediaType.QIC11: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-11"; + break; + case CommonTypes.MediaType.QIC24: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-24"; + break; + case CommonTypes.MediaType.QIC40: + discType = "Quarter-inch mini cartridge"; + discSubType = "QIC-40"; + break; + case CommonTypes.MediaType.QIC80: + discType = "Quarter-inch mini cartridge"; + discSubType = "QIC-80"; + break; + case CommonTypes.MediaType.QIC120: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-120"; + break; + case CommonTypes.MediaType.QIC150: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-150"; + break; + case CommonTypes.MediaType.QIC320: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-320"; + break; + case CommonTypes.MediaType.QIC525: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-525"; + break; + case CommonTypes.MediaType.QIC1350: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-1350"; + break; + case CommonTypes.MediaType.QIC3010: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-3010"; + break; + case CommonTypes.MediaType.QIC3020: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-3020"; + break; + case CommonTypes.MediaType.QIC3080: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-3080"; + break; + case CommonTypes.MediaType.QIC3095: + discType = "Quarter-inch cartridge"; + discSubType = "QIC-3095"; + break; + case CommonTypes.MediaType.Travan: + discType = "Travan"; + discSubType = "TR-1"; + break; + case CommonTypes.MediaType.Travan1Ex: + discType = "Travan"; + discSubType = "TR-1 Ex"; + break; + case CommonTypes.MediaType.Travan3: + discType = "Travan"; + discSubType = "TR-3"; + break; + case CommonTypes.MediaType.Travan3Ex: + discType = "Travan"; + discSubType = "TR-3 Ex"; + break; + case CommonTypes.MediaType.Travan4: + discType = "Travan"; + discSubType = "TR-4"; + break; + case CommonTypes.MediaType.Travan5: + discType = "Travan"; + discSubType = "TR-5"; + break; + case CommonTypes.MediaType.Travan7: + discType = "Travan"; + discSubType = "TR-7"; + break; + case CommonTypes.MediaType.VXA1: + discType = "VXA"; + discSubType = "VXA-1"; + break; + case CommonTypes.MediaType.VXA2: + discType = "VXA"; + discSubType = "VXA-2"; + break; + case CommonTypes.MediaType.VXA3: + discType = "VXA"; + discSubType = "VXA-3"; + break; + case CommonTypes.MediaType.ECMA_153: + case CommonTypes.MediaType.ECMA_153_512: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-153"; + break; + case CommonTypes.MediaType.ECMA_189: + discType = "300mm magneto optical"; + discSubType = "ECMA-189"; + break; + case CommonTypes.MediaType.ECMA_190: + discType = "300mm magneto optical"; + discSubType = "ECMA-190"; + break; + case CommonTypes.MediaType.ECMA_195: + case CommonTypes.MediaType.ECMA_195_512: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-195"; + break; + case CommonTypes.MediaType.ECMA_223: + case CommonTypes.MediaType.ECMA_223_512: + discType = "3.5\" magneto-optical"; + discSubType = "ECMA-223"; + break; + case CommonTypes.MediaType.ECMA_238: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-238"; + break; + case CommonTypes.MediaType.ECMA_239: + discType = "3.5\" magneto-optical"; + discSubType = "ECMA-239"; + break; + case CommonTypes.MediaType.ECMA_280: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-280"; + break; + case CommonTypes.MediaType.ECMA_317: + discType = "300mm magneto optical"; + discSubType = "ECMA-317"; + break; + case CommonTypes.MediaType.ECMA_322: + case CommonTypes.MediaType.ECMA_322_2k: + discType = "5.25\" magneto-optical"; + discSubType = "ECMA-322"; + break; + case CommonTypes.MediaType.GigaMo: + discType = "3.5\" magneto-optical"; + discSubType = "GIGAMO"; + break; + case CommonTypes.MediaType.GigaMo2: + discType = "3.5\" magneto-optical"; + discSubType = "2.3GB GIGAMO"; + break; + case CommonTypes.MediaType.UnknownMO: + discType = "Magneto-optical"; + discSubType = "Unknown"; + break; + case CommonTypes.MediaType.Floptical: + discType = "Floptical"; + discSubType = "Floptical"; + break; + case CommonTypes.MediaType.HiFD: + discType = "HiFD"; + discSubType = "HiFD"; + break; + case CommonTypes.MediaType.LS120: + discType = "SuperDisk"; + discSubType = "LS-120"; + break; + case CommonTypes.MediaType.LS240: + discType = "SuperDisk"; + discSubType = "LS-240"; + break; + case CommonTypes.MediaType.FD32MB: + discType = "3.5\" floppy"; + discSubType = "FD32MB"; + break; + case CommonTypes.MediaType.UHD144: + discType = "UHD144"; + discSubType = "UHD144"; + break; + case CommonTypes.MediaType.VCDHD: + discType = "VCDHD"; + discSubType = "VCDHD"; + break; + case CommonTypes.MediaType.HuCard: + discType = "HuCard"; + discSubType = "HuCard"; + break; + case CommonTypes.MediaType.CompactCassette: + discType = "Compact Cassette"; + discSubType = "Compact Cassette"; + break; + case CommonTypes.MediaType.Dcas25: + discType = "Compact Cassette"; + discSubType = "D/CAS-25"; + break; + case CommonTypes.MediaType.Dcas85: + discType = "Compact Cassette"; + discSubType = "D/CAS-85"; + break; + case CommonTypes.MediaType.Dcas103: + discType = "Compact Cassette"; + discSubType = "D/CAS-103"; + break; + case CommonTypes.MediaType.PCCardTypeI: + discType = "PCMCIA Card"; + discSubType = "PC-Card Type I"; + break; + case CommonTypes.MediaType.PCCardTypeII: + discType = "PCMCIA Card"; + discSubType = "PC-Card Type II"; + break; + case CommonTypes.MediaType.PCCardTypeIII: + discType = "PCMCIA Card"; + discSubType = "PC-Card Type III"; + break; + case CommonTypes.MediaType.PCCardTypeIV: + discType = "PCMCIA Card"; + discSubType = "PC-Card Type IV"; + break; + case CommonTypes.MediaType.ExpressCard34: + discType = "Express Card"; + discSubType = "Express Card (34mm)"; + break; + case CommonTypes.MediaType.ExpressCard54: + discType = "Express Card"; + discSubType = "Express Card (54mm)"; + break; + case CommonTypes.MediaType.FamicomGamePak: + discType = "Nintendo Famicom Game Pak"; + discSubType = "Nintendo Famicom Game Pak"; + break; + case CommonTypes.MediaType.GameBoyAdvanceGamePak: + discType = "Nintendo Game Boy Advance Game Pak"; + discSubType = "Nintendo Game Boy Advance Game Pak"; + break; + case CommonTypes.MediaType.GameBoyGamePak: + discType = "Nintendo Game Boy Game Pak"; + discSubType = "Nintendo Game Boy Game Pak"; + break; + case CommonTypes.MediaType.N64DD: + discType = "Nintendo 64 Disk"; + discSubType = "Nintendo 64 Disk"; + break; + case CommonTypes.MediaType.N64GamePak: + discType = "Nintendo 64 Game Pak"; + discSubType = "Nintendo 64 Game Pak"; + break; + case CommonTypes.MediaType.NESGamePak: + discType = "Nintendo Entertainment System Game Pak"; + discSubType = "Nintendo Entertainment System Game Pak"; + break; + case CommonTypes.MediaType.Nintendo3DSGameCard: + discType = "Nintendo 3DS Game Card"; + discSubType = "Nintendo 3DS Game Card"; + break; + case CommonTypes.MediaType.NintendoDiskCard: + discType = "Nintendo Disk Card"; + discSubType = "Nintendo Disk Card"; + break; + case CommonTypes.MediaType.NintendoDSGameCard: + discType = "Nintendo DS Game Card"; + discSubType = "Nintendo DS Game Card"; + break; + case CommonTypes.MediaType.NintendoDSiGameCard: + discType = "Nintendo DSi Game Card"; + discSubType = "Nintendo DSi Game Card"; + break; + case CommonTypes.MediaType.SNESGamePak: + discType = "Super Nintendo Game Pak"; + discSubType = "Super Nintendo Game Pak"; + break; + case CommonTypes.MediaType.SNESGamePakUS: + discType = "Super Nintendo Game Pak (US)"; + discSubType = "Super Nintendo Game Pak (US)"; + break; + case CommonTypes.MediaType.IBM3470: + discType = "IBM 3470"; + discSubType = "IBM 3470"; + break; + case CommonTypes.MediaType.IBM3480: + discType = "IBM 3480"; + discSubType = "IBM 3480"; + break; + case CommonTypes.MediaType.IBM3490: + discType = "IBM 3490"; + discSubType = "IBM 3490"; + break; + case CommonTypes.MediaType.IBM3490E: + discType = "IBM 3490E"; + discSubType = "IBM 3490E"; + break; + case CommonTypes.MediaType.IBM3592: + discType = "IBM 3592"; + discSubType = "IBM 3592"; + break; + case CommonTypes.MediaType.STK4480: + discType = "STK 4480"; + discSubType = "STK 4480"; + break; + case CommonTypes.MediaType.STK4490: + discType = "STK 4490"; + discSubType = "STK 4490"; + break; + case CommonTypes.MediaType.STK9490: + discType = "STK 9490"; + discSubType = "STK 9490"; + break; + case CommonTypes.MediaType.T9840A: + discType = "STK T-9840"; + discSubType = "STK T-9840A"; + break; + case CommonTypes.MediaType.T9840B: + discType = "STK T-9840"; + discSubType = "STK T-9840B"; + break; + case CommonTypes.MediaType.T9840C: + discType = "STK T-9840"; + discSubType = "STK T-9840C"; + break; + case CommonTypes.MediaType.T9840D: + discType = "STK T-9840"; + discSubType = "STK T-9840D"; + break; + case CommonTypes.MediaType.T9940A: + discType = "STK T-9940"; + discSubType = "STK T-9940A"; + break; + case CommonTypes.MediaType.T9940B: + discType = "STK T-9840"; + discSubType = "STK T-9840B"; + break; + case CommonTypes.MediaType.T10000A: + discType = "STK T-10000"; + discSubType = "STK T-10000A"; + break; + case CommonTypes.MediaType.T10000B: + discType = "STK T-10000"; + discSubType = "STK T-10000B"; + break; + case CommonTypes.MediaType.T10000C: + discType = "STK T-10000"; + discSubType = "STK T-10000C"; + break; + case CommonTypes.MediaType.T10000D: + discType = "STK T-10000"; + discSubType = "STK T-10000D"; + break; + case CommonTypes.MediaType.DemiDiskette: + discType = "DemiDiskette"; + discSubType = "DemiDiskette"; + break; + case CommonTypes.MediaType.QuickDisk: + discType = "QuickDisk"; + discSubType = "QuickDisk"; + break; + case CommonTypes.MediaType.VideoFloppy: + discType = "VideoFloppy"; + discSubType = "VideoFloppy"; + break; + case CommonTypes.MediaType.Wafer: + discType = "Wafer"; + discSubType = "Wafer"; + break; + case CommonTypes.MediaType.ZXMicrodrive: + discType = "ZX Microdrive"; + discSubType = "ZX Microdrive"; + break; + case CommonTypes.MediaType.BeeCard: + discType = "BeeCard"; + discSubType = "BeeCard"; + break; + case CommonTypes.MediaType.Borsu: + discType = "Borsu"; + discSubType = "Borsu"; + break; + case CommonTypes.MediaType.DataStore: + discType = "DataStore"; + discSubType = "DataStore"; + break; + case CommonTypes.MediaType.DIR: + discType = "DIR"; + discSubType = "DIR"; + break; + case CommonTypes.MediaType.DST: + discType = "DST"; + discSubType = "DST"; + break; + case CommonTypes.MediaType.DTF: + discType = "DTF"; + discSubType = "DTF"; + break; + case CommonTypes.MediaType.DTF2: + discType = "DTF2"; + discSubType = "DTF2"; + break; + case CommonTypes.MediaType.Flextra3020: + discType = "Flextra"; + discSubType = "Flextra 3020"; + break; + case CommonTypes.MediaType.Flextra3225: + discType = "Flextra"; + discSubType = "Flextra 3225"; + break; + case CommonTypes.MediaType.HiTC1: + discType = "HiTC"; + discSubType = "HiTC1"; + break; + case CommonTypes.MediaType.HiTC2: + discType = "HiTC"; + discSubType = "HiTC2"; + break; + case CommonTypes.MediaType.LT1: + discType = "LT1"; + discSubType = "LT1"; + break; + case CommonTypes.MediaType.MiniCard: + discType = "MiniCard"; + discSubType = "MiniCard"; + break; + case CommonTypes.MediaType.Orb: + discType = "Orb"; + discSubType = "Orb"; + break; + case CommonTypes.MediaType.Orb5: + discType = "Orb"; + discSubType = "Orb5"; + break; + case CommonTypes.MediaType.SmartMedia: + discType = "SmartMedia"; + discSubType = "SmartMedia"; + break; + case CommonTypes.MediaType.xD: + discType = "xD"; + discSubType = "xD"; + break; + case CommonTypes.MediaType.XQD: + discType = "XQD"; + discSubType = "XQD"; + break; + case CommonTypes.MediaType.DataPlay: + discType = "DataPlay"; + discSubType = "DataPlay"; + break; + case CommonTypes.MediaType.PD650: + discType = "PD650"; + discSubType = "PD650"; + break; + case CommonTypes.MediaType.PD650_WORM: + discType = "PD650"; + discSubType = "PD650 (WORM)"; + break; + case CommonTypes.MediaType.RA60: + discType = "Hard Disk Drive"; + discSubType = "DEC RA-60"; + break; + case CommonTypes.MediaType.RA80: + discType = "Hard Disk Drive"; + discSubType = "DEC RA-80"; + break; + case CommonTypes.MediaType.RA81: + discType = "Hard Disk Drive"; + discSubType = "DEC RA-81"; + break; + case CommonTypes.MediaType.RC25: + discType = "Hard Disk Drive"; + discSubType = "DEC RC-25"; + break; + case CommonTypes.MediaType.RD31: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-31"; + break; + case CommonTypes.MediaType.RD32: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-32"; + break; + case CommonTypes.MediaType.RD51: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-51"; + break; + case CommonTypes.MediaType.RD52: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-52"; + break; + case CommonTypes.MediaType.RD53: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-53"; + break; + case CommonTypes.MediaType.RD54: + discType = "Hard Disk Drive"; + discSubType = "DEC RD-54"; + break; + case CommonTypes.MediaType.RK06: + case CommonTypes.MediaType.RK06_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RK-06"; + break; + case CommonTypes.MediaType.RK07: + case CommonTypes.MediaType.RK07_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RK-07"; + break; + case CommonTypes.MediaType.RM02: + discType = "Hard Disk Drive"; + discSubType = "DEC RM-02"; + break; + case CommonTypes.MediaType.RM03: + discType = "Hard Disk Drive"; + discSubType = "DEC RM-03"; + break; + case CommonTypes.MediaType.RM05: + discType = "Hard Disk Drive"; + discSubType = "DEC RM-05"; + break; + case CommonTypes.MediaType.RP02: + case CommonTypes.MediaType.RP02_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RP-02"; + break; + case CommonTypes.MediaType.RP03: + case CommonTypes.MediaType.RP03_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RP-03"; + break; + case CommonTypes.MediaType.RP04: + case CommonTypes.MediaType.RP04_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RP-04"; + break; + case CommonTypes.MediaType.RP05: + case CommonTypes.MediaType.RP05_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RP-05"; + break; + case CommonTypes.MediaType.RP06: + case CommonTypes.MediaType.RP06_18: + discType = "Hard Disk Drive"; + discSubType = "DEC RP-06"; + break; + case CommonTypes.MediaType.RDX: + discType = "RDX"; + discSubType = "RDX"; + break; + case CommonTypes.MediaType.RDX320: + discType = "RDX"; + discSubType = "RDX 320"; + break; + case CommonTypes.MediaType.Zone_HDD: + discType = "Zoned Hard Disk Drive"; + discSubType = "Unknown"; + break; + case CommonTypes.MediaType.Microdrive: + discType = "Hard Disk Drive"; + discSubType = "Microdrive"; + break; + default: + discType = "Unknown"; + discSubType = "Unknown"; + break; + } + } + } +} \ No newline at end of file diff --git a/Metadata/Resume.cs b/Metadata/Resume.cs new file mode 100644 index 0000000..5338358 --- /dev/null +++ b/Metadata/Resume.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Resume.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines XML format of a dump resume file. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using Schemas; + +namespace DiscImageChef.CommonTypes.Metadata +{ + [Serializable] + [XmlRoot("DicResume", Namespace = "", IsNullable = false)] + public class Resume + { + [XmlElement(DataType = "dateTime")] public DateTime CreationDate; + [XmlElement(DataType = "dateTime")] public DateTime LastWriteDate; + public bool Removable; + public ulong LastBlock; + public ulong NextBlock; + + [XmlArrayItem("DumpTry")] public List Tries; + [XmlArrayItem("Block")] public List BadBlocks; + } +} \ No newline at end of file diff --git a/Metadata/Statistics.cs b/Metadata/Statistics.cs new file mode 100644 index 0000000..593a3b2 --- /dev/null +++ b/Metadata/Statistics.cs @@ -0,0 +1,173 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Statistics.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Define XML for statistics. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace DiscImageChef.CommonTypes.Metadata +{ + [XmlRoot("DicStats", Namespace = "", IsNullable = false)] + public class Stats + { + public CommandsStats Commands; + [XmlArrayItem("OperatingSystem")] + public List OperatingSystems { get; set; } + [XmlArrayItem("Version")] + public List Versions { get; set; } + [XmlArrayItem("Filesystem")] + public List Filesystems { get; set; } + [XmlArrayItem("Scheme")] + public List Partitions { get; set; } + [XmlArrayItem("Format")] + public List MediaImages { get; set; } + [XmlArrayItem("Filter", IsNullable = true)] + public List Filters { get; set; } + [XmlArrayItem("Device", IsNullable = true)] + public List Devices { get; set; } + [XmlArrayItem("Media")] + public List Medias { get; set; } + public BenchmarkStats Benchmark { get; set; } + public MediaScanStats MediaScan { get; set; } + public VerifyStats Verify { get; set; } + } + + public class CommandsStats + { + public long Analyze; + public long Benchmark; + public long Checksum; + public long Compare; + public long ConvertImage; + public long CreateSidecar; + public long Decode; + public long DeviceInfo; + public long DeviceReport; + public long DumpMedia; + public long Entropy; + public long ExtractFiles; + public long Formats; + public long ImageInfo; + public long ListDevices; + public long ListEncodings; + public long Ls; + public long MediaInfo; + public long MediaScan; + public long PrintHex; + public long Verify; + } + + public class VerifiedItems + { + public long Correct; + public long Failed; + } + + public class VerifyStats + { + public VerifiedItems MediaImages; + public ScannedSectors Sectors; + } + + public class ScannedSectors + { + public long Correct; + public long Error; + public long Total; + public long Unverifiable; + } + + public class TimeStats + { + public long LessThan10ms; + public long LessThan150ms; + public long LessThan3ms; + public long LessThan500ms; + public long LessThan50ms; + public long MoreThan500ms; + } + + public class MediaScanStats + { + public ScannedSectors Sectors; + public TimeStats Times; + } + + public class ChecksumStats + { + [XmlAttribute] public string algorithm; + [XmlText] public double Value; + } + + public class BenchmarkStats + { + public double All; + [XmlElement("Checksum")] public List Checksum; + public double Entropy; + public long MaxMemory; + public long MinMemory; + public double Sequential; + } + + public class MediaStats + { + [XmlAttribute] public bool real; + [XmlAttribute] public string type; + [XmlText] public long Value; + } + + public class DeviceStats + { + [XmlIgnore] public bool ManufacturerSpecified; + public string Manufacturer { get; set; } + public string Model { get; set; } + public string Revision { get; set; } + public string Bus { get; set; } + } + + public class NameValueStats + { + [XmlAttribute] + public string name { get; set; } + [XmlText] + public long Value { get; set; } + } + + public class OsStats + { + [XmlAttribute] + public string name { get; set; } + [XmlAttribute] + public string version { get; set; } + [XmlText] + public long Value { get; set; } + } +} \ No newline at end of file diff --git a/Metadata/Version.cs b/Metadata/Version.cs new file mode 100644 index 0000000..82c487e --- /dev/null +++ b/Metadata/Version.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Statistics.cs +// Author(s) : Natalia Portillo +// +// Component : XML metadata. +// +// --[ Description ] ---------------------------------------------------------- +// +// Returns DiscImageChef version in XML software type format. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using DiscImageChef.CommonTypes.Interop; +using Schemas; + +namespace DiscImageChef.CommonTypes.Metadata +{ + public static class Version + { + /// + /// Gets XML software type for the running version + /// + /// XML software type + public static SoftwareType GetSoftwareType() + { + return new SoftwareType + { + Name = "DiscImageChef", + OperatingSystem = DetectOS.GetRealPlatformID().ToString(), + Version = typeof(Version).Assembly.GetName().Version.ToString() + }; + } + } +} \ No newline at end of file diff --git a/PluginBase.cs b/PluginBase.cs new file mode 100644 index 0000000..499d71a --- /dev/null +++ b/PluginBase.cs @@ -0,0 +1,168 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : PluginBase.cs +// Author(s) : Natalia Portillo +// +// Component : Core algorithms. +// +// --[ Description ] ---------------------------------------------------------- +// +// Class to hold all installed plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using DiscImageChef.CommonTypes.Interfaces; +using DiscImageChef.Console; +using DiscImageChef.Partitions; + +namespace DiscImageChef.CommonTypes +{ + /// + /// Contain all plugins (filesystem, partition and image) + /// + public class PluginBase + { + /// + /// List of all media image plugins + /// + public readonly SortedDictionary ImagePluginsList; + /// + /// List of all partition plugins + /// + public readonly SortedDictionary PartPluginsList; + /// + /// List of all filesystem plugins + /// + public readonly SortedDictionary PluginsList; + /// + /// List of read-only filesystem plugins + /// + public readonly SortedDictionary ReadOnlyFilesystems; + /// + /// List of writable media image plugins + /// + public readonly SortedDictionary WritableImages; + + /// + /// Initializes the plugins lists + /// + public PluginBase() + { + PluginsList = new SortedDictionary(); + ReadOnlyFilesystems = new SortedDictionary(); + PartPluginsList = new SortedDictionary(); + ImagePluginsList = new SortedDictionary(); + WritableImages = new SortedDictionary(); + + // We need to manually load assemblies :( + AppDomain.CurrentDomain.Load("DiscImageChef.DiscImages"); + AppDomain.CurrentDomain.Load("DiscImageChef.Filesystems"); + AppDomain.CurrentDomain.Load("DiscImageChef.Partitions"); + + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach(Assembly assembly in assemblies) + { + foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IMediaImage))) + .Where(t => t.IsClass)) + try + { + IMediaImage plugin = + (IMediaImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + RegisterImagePlugin(plugin); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + + foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition))) + .Where(t => t.IsClass)) + try + { + IPartition plugin = (IPartition)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + RegisterPartPlugin(plugin); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + + foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))) + .Where(t => t.IsClass)) + try + { + IFilesystem plugin = + (IFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + RegisterPlugin(plugin); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + + foreach(Type type in assembly + .GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IReadOnlyFilesystem))) + .Where(t => t.IsClass)) + try + { + IReadOnlyFilesystem plugin = + (IReadOnlyFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + RegisterReadOnlyFilesystem(plugin); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + + foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IWritableImage))) + .Where(t => t.IsClass)) + try + { + IWritableImage plugin = + (IWritableImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }); + RegisterWritableMedia(plugin); + } + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } + } + } + + void RegisterImagePlugin(IMediaImage plugin) + { + if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower())) + ImagePluginsList.Add(plugin.Name.ToLower(), plugin); + } + + void RegisterPlugin(IFilesystem plugin) + { + if(!PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin); + } + + void RegisterReadOnlyFilesystem(IReadOnlyFilesystem plugin) + { + if(!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower())) + ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin); + } + + void RegisterWritableMedia(IWritableImage plugin) + { + if(!WritableImages.ContainsKey(plugin.Name.ToLower())) WritableImages.Add(plugin.Name.ToLower(), plugin); + } + + void RegisterPartPlugin(IPartition partplugin) + { + if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower())) + PartPluginsList.Add(partplugin.Name.ToLower(), partplugin); + } + } +} \ No newline at end of file diff --git a/Structs/Filesystems.cs b/Structs/Filesystems.cs new file mode 100644 index 0000000..060430a --- /dev/null +++ b/Structs/Filesystems.cs @@ -0,0 +1,321 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : DiscImageChef filesystem plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains enumerations and structures of common usage by filesystem +// plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace DiscImageChef.CommonTypes.Structs +{ + /// + /// File attributes. + /// + [Flags] + public enum FileAttributes : ulong + { + /// File is an alias (Mac OS) + Alias = 0x01, + /// Indicates that the file can only be writable appended + AppendOnly = 0x02, + /// File is candidate for archival/backup + Archive = 0x04, + /// File is a block device + BlockDevice = 0x08, + /// File is stored on filesystem block units instead of device sectors + BlockUnits = 0x10, + /// Directory is a bundle or file contains a BNDL resource + Bundle = 0x20, + /// File is a char device + CharDevice = 0x40, + /// File is compressed + Compressed = 0x80, + /// File is compressed and should not be uncompressed on read + CompressedRaw = 0x100, + /// File has compression errors + CompressionError = 0x200, + /// Compressed file is dirty + CompressionDirty = 0x400, + /// File is a device + Device = 0x800, + /// File is a directory + Directory = 0x1000, + /// File is encrypted + Encrypted = 0x2000, + /// File is stored on disk using extents + Extents = 0x4000, + /// File is a FIFO + FIFO = 0x8000, + /// File is a normal file + File = 0x10000, + /// File is a Mac OS file containing desktop databases that has already been added to the desktop database + HasBeenInited = 0x20000, + /// File contains an icon resource / EA + HasCustomIcon = 0x40000, + /// File is a Mac OS extension or control panel lacking INIT resources + HasNoINITs = 0x80000, + /// File is hidden/invisible + Hidden = 0x100000, + /// File cannot be written, deleted, modified or linked to + Immutable = 0x200000, + /// Directory is indexed using hashed trees + IndexedDirectory = 0x400000, + /// File contents are stored alongside its inode (or equivalent) + Inline = 0x800000, + /// File contains integrity checks + IntegrityStream = 0x1000000, + /// File is on desktop + IsOnDesk = 0x2000000, + /// File changes are written to filesystem journal before being written to file itself + Journaled = 0x4000000, + /// Access time will not be modified + NoAccessTime = 0x8000000, + /// File will not be subject to copy-on-write + NoCopyOnWrite = 0x10000000, + /// File will not be backed up + NoDump = 0x20000000, + /// File contents should not be scrubbed + NoScrub = 0x40000000, + /// File contents should not be indexed + NotIndexed = 0x80000000, + /// File is offline + Offline = 0x100000000, + /// File is password protected, but contents are not encrypted on disk + Password = 0x200000000, + /// File is read-only + ReadOnly = 0x400000000, + /// File is a reparse point + ReparsePoint = 0x800000000, + /// When file is removed its content will be overwritten with zeroes + Secured = 0x1000000000, + /// File contents are sparse + Sparse = 0x2000000000, + /// File is a shadow (OS/2) + Shadow = 0x4000000000, + /// File is shared + Shared = 0x8000000000, + /// File is a stationery + Stationery = 0x10000000000, + /// File is a symbolic link + Symlink = 0x20000000000, + /// File writes are synchronously written to disk + Sync = 0x40000000000, + /// File belongs to the operating system + System = 0x80000000000, + /// If file end is a partial block its content will be merged with other files + TailMerged = 0x100000000000, + /// File is temporary + Temporary = 0x200000000000, + /// Subdirectories inside of this directory are not related and should be allocated elsewhere + TopDirectory = 0x400000000000, + /// If file is deleted, contents should be stored, for a possible future undeletion + Undeletable = 0x800000000000, + /// File is a pipe + Pipe = 0x1000000000000 + } + + /// + /// Information about a file entry + /// + public class FileEntryInfo + { + /// File attributes + public FileAttributes Attributes; + /// File length in blocks + public long Blocks; + /// File block size in bytes + public long BlockSize; + /// If file points to a device, device number + public ulong DeviceNo; + /// POSIX group ID + public ulong GID; + + /// inode number for this file + public ulong Inode; + /// File length in bytes + public long Length; + /// Number of hard links pointing to this file + public ulong Links; + /// POSIX permissions/mode for this file + public uint Mode; + /// POSIX owner ID + public ulong UID; + + /// File creation date in UTC + public DateTime CreationTimeUtc { get; set; } + /// File last access date in UTC + public DateTime AccessTimeUtc { get; set; } + /// File attributes change date in UTC + public DateTime StatusChangeTimeUtc { get; set; } + /// File last backup date in UTC + public DateTime BackupTimeUtc { get; set; } + /// File last modification date in UTC + public DateTime LastWriteTimeUtc { get; set; } + + /// File creation date + public DateTime CreationTime + { + get => CreationTimeUtc.ToLocalTime(); + set => CreationTimeUtc = value.ToUniversalTime(); + } + /// File last access date + public DateTime AccessTime + { + get => AccessTimeUtc.ToLocalTime(); + set => AccessTimeUtc = value.ToUniversalTime(); + } + /// File attributes change date + public DateTime StatusChangeTime + { + get => StatusChangeTimeUtc.ToLocalTime(); + set => StatusChangeTimeUtc = value.ToUniversalTime(); + } + /// File last backup date + public DateTime BackupTime + { + get => BackupTimeUtc.ToLocalTime(); + set => BackupTimeUtc = value.ToUniversalTime(); + } + /// File last modification date + public DateTime LastWriteTime + { + get => LastWriteTimeUtc.ToLocalTime(); + set => LastWriteTimeUtc = value.ToUniversalTime(); + } + } + + public class FileSystemInfo + { + /// Blocks for this filesystem + public long Blocks; + /// Maximum length of filenames on this filesystem + public ushort FilenameLength; + /// Files on this filesystem + public ulong Files; + /// Blocks free on this filesystem + public long FreeBlocks; + /// Free inodes on this filesystem + public ulong FreeFiles; + /// Filesystem ID + public FileSystemId Id; + /// ID of plugin for this file + public Guid PluginId; + + /// Filesystem type + public string Type; + + public FileSystemInfo() + { + Id = new FileSystemId(); + } + } + + [StructLayout(LayoutKind.Explicit)] + public struct FileSystemId + { + [FieldOffset(0)] public bool IsInt; + [FieldOffset(1)] public bool IsLong; + [FieldOffset(2)] public bool IsGuid; + + [FieldOffset(3)] public uint Serial32; + [FieldOffset(3)] public ulong Serial64; + [FieldOffset(3)] public Guid uuid; + } + + /// + /// Errors + /// + public enum Errno + { + /// No error happened + NoError = 0, + /// Access denied + AccessDenied = -13, + /// Busy, cannot complete + Busy = -16, + /// File is too large + FileTooLarge = -27, + /// Invalid argument + InvalidArgument = -22, + /// I/O error + InOutError = -5, + /// Is a directory (e.g.: trying to Read() a dir) + IsDirectory = -21, + /// Name is too long + NameTooLong = -36, + /// There is no data available + NoData = 61, + /// There is no such attribute + NoSuchExtendedAttribute = NoData, + /// No such device + NoSuchDevice = -19, + /// No such file or directory + NoSuchFile = -2, + /// Is not a directory (e.g.: trying to ReadDir() a file) + NotDirectory = -20, + /// Not implemented + NotImplemented = -38, + /// Not supported + NotSupported = -252, + /// Link is severed + SeveredLink = -67, + /// Access denied + EACCES = AccessDenied, + /// Busy, cannot complete + EBUSY = Busy, + /// File is too large + EFBIG = FileTooLarge, + /// Invalid argument + EINVAL = InvalidArgument, + /// I/O error + EIO = InOutError, + /// Is a directory (e.g.: trying to Read() a dir) + EISDIR = IsDirectory, + /// Name is too long + ENAMETOOLONG = NameTooLong, + /// There is no such attribute + ENOATTR = NoSuchExtendedAttribute, + /// There is no data available + ENODATA = NoData, + /// No such device + ENODEV = NoSuchDevice, + /// No such file or directory + ENOENT = NoSuchFile, + /// Link is severed + ENOLINK = SeveredLink, + /// Not implemented + ENOSYS = NotImplemented, + /// Is not a directory (e.g.: trying to ReadDir() a file) + ENOTDIR = NotDirectory, + /// Not supported + ENOTSUP = NotSupported + } +} \ No newline at end of file diff --git a/Structs/Images.cs b/Structs/Images.cs new file mode 100644 index 0000000..8a22ffd --- /dev/null +++ b/Structs/Images.cs @@ -0,0 +1,188 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : IMediaImage.cs +// Author(s) : Natalia Portillo +// +// Component : Disc image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Defines structures to be used by disc image plugins. +// +// --[ License ] -------------------------------------------------------------- +// +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 2.1 of the +// License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2018 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Interfaces; + +namespace DiscImageChef.CommonTypes.Structs +{ + /// + /// Contains information about a dump image and its contents + /// + public struct ImageInfo + { + /// Image contains partitions (or tracks for optical media) + public bool HasPartitions; + /// Image contains sessions (optical media only) + public bool HasSessions; + /// Size of the image without headers + public ulong ImageSize; + /// Sectors contained in the image + public ulong Sectors; + /// Size of sectors contained in the image + public uint SectorSize; + /// Media tags contained by the image + public List ReadableMediaTags; + /// Sector tags contained by the image + public List ReadableSectorTags; + /// Image version + public string Version; + /// Application that created the image + public string Application; + /// Version of the application that created the image + public string ApplicationVersion; + /// Who (person) created the image? + public string Creator; + /// Image creation time + public DateTime CreationTime; + /// Image last modification time + public DateTime LastModificationTime; + /// Title of the media represented by the image + public string MediaTitle; + /// Image comments + public string Comments; + /// Manufacturer of the media represented by the image + public string MediaManufacturer; + /// Model of the media represented by the image + public string MediaModel; + /// Serial number of the media represented by the image + public string MediaSerialNumber; + /// Barcode of the media represented by the image + public string MediaBarcode; + /// Part number of the media represented by the image + public string MediaPartNumber; + /// Media type represented by the image + public MediaType MediaType; + /// Number in sequence for the media represented by the image + public int MediaSequence; + /// Last media of the sequence the media represented by the image corresponds to + public int LastMediaSequence; + /// Manufacturer of the drive used to read the media represented by the image + public string DriveManufacturer; + /// Model of the drive used to read the media represented by the image + public string DriveModel; + /// Serial number of the drive used to read the media represented by the image + public string DriveSerialNumber; + /// Firmware revision of the drive used to read the media represented by the image + public string DriveFirmwareRevision; + /// Type of the media represented by the image to use in XML sidecars + public XmlMediaType XmlMediaType; + // CHS geometry... + /// Cylinders of the media represented by the image + public uint Cylinders; + /// Heads of the media represented by the image + public uint Heads; + /// Sectors per track of the media represented by the image (for variable image, the smallest) + public uint SectorsPerTrack; + } + + /// + /// Session defining structure. + /// + public struct Session + { + /// Session number, 1-started + public ushort SessionSequence; + /// First track present on this session + public uint StartTrack; + /// Last track present on this session + public uint EndTrack; + /// First sector present on this session + public ulong StartSector; + /// Last sector present on this session + public ulong EndSector; + } + + /// + /// Track defining structure. + /// + public struct Track + { + /// Track number, 1-started + public uint TrackSequence; + /// Partition type + public TrackType TrackType; + /// Track starting sector + public ulong TrackStartSector; + /// Track ending sector + public ulong TrackEndSector; + /// Track pre-gap + public ulong TrackPregap; + /// Session this track belongs to + public ushort TrackSession; + /// Information that does not find space in this struct + public string TrackDescription; + /// Indexes, 00 to 99 and sector offset + public Dictionary Indexes; + /// Which filter stores this track + public IFilter TrackFilter; + /// Which file stores this track + public string TrackFile; + /// Starting at which byte is this track stored + public ulong TrackFileOffset; + /// What kind of file is storing this track + public string TrackFileType; + /// How many main channel / user data bytes are per sector in this track + public int TrackBytesPerSector; + /// How many main channel bytes per sector are in the file with this track + public int TrackRawBytesPerSector; + /// Which filter stores this track's subchannel + public IFilter TrackSubchannelFilter; + /// Which file stores this track's subchannel + public string TrackSubchannelFile; + /// Starting at which byte are this track's subchannel stored + public ulong TrackSubchannelOffset; + /// Type of subchannel stored for this track + public TrackSubchannelType TrackSubchannelType; + } + + /// + /// Floppy physical characteristics structure. + /// + public struct FloppyInfo + { + /// Physical floppy type. + public FloppyTypes Type; + /// Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable. + public uint Bitrate; + /// Physical magnetic density (coercitivity) of floppy medium. + public FloppyDensities Coercitivity; + /// How many physical tracks are actually written in the floppy image. + public ushort Tracks; + /// How many physical heads are actually written in the floppy image. + public byte Heads; + /// How many tracks per inch are actually written in the floppy image. + public ushort TrackDensity; + } +} \ No newline at end of file