2017-08-08 13:40:32 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : OpticalDisc.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-08-08 13:40:32 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Core algorithms.
|
2017-08-08 13:40:32 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Contains logic to create sidecar from an optical media dump.
|
2017-08-08 13:40:32 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-08-08 13:40:32 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using System;
|
2017-12-19 03:50:57 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
2018-02-07 17:10:21 +00:00
|
|
|
|
using System.Linq;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
using System.Text;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DiscImageChef.Decoders.CD;
|
|
|
|
|
|
using DiscImageChef.Decoders.DVD;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
using DiscImageChef.DiscImages;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DiscImageChef.Filesystems;
|
2018-01-30 21:28:23 +00:00
|
|
|
|
using DiscImageChef.Metadata;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
using Schemas;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
2018-01-30 21:28:23 +00:00
|
|
|
|
using MediaType = DiscImageChef.CommonTypes.MediaType;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Session = DiscImageChef.DiscImages.Session;
|
|
|
|
|
|
using TrackType = Schemas.TrackType;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
public static partial class Sidecar
|
|
|
|
|
|
{
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// <summary>
|
2017-12-23 17:41:23 +00:00
|
|
|
|
/// Creates a metadata sidecar for an optical disc (e.g. CD, DVD, GD, BD, XGD, GOD)
|
2017-12-23 01:46:08 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="image">Image</param>
|
|
|
|
|
|
/// <param name="filterId">Filter uuid</param>
|
|
|
|
|
|
/// <param name="imagePath">Image path</param>
|
|
|
|
|
|
/// <param name="fi">Image file information</param>
|
|
|
|
|
|
/// <param name="plugins">Image plugins</param>
|
|
|
|
|
|
/// <param name="imgChecksums">List of image checksums</param>
|
|
|
|
|
|
/// <param name="sidecar">Metadata sidecar</param>
|
2018-01-28 20:29:46 +00:00
|
|
|
|
static void OpticalDisc(IMediaImage image, Guid filterId, string imagePath,
|
|
|
|
|
|
FileInfo fi, PluginBase plugins,
|
2017-12-26 06:05:12 +00:00
|
|
|
|
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc = new[]
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
new OpticalDiscType
|
|
|
|
|
|
{
|
|
|
|
|
|
Checksums = imgChecksums.ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Image = new ImageType
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
format = image.Format,
|
|
|
|
|
|
offset = 0,
|
2017-12-19 20:33:03 +00:00
|
|
|
|
offsetSpecified = true,
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Value = Path.GetFileName(imagePath)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
},
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = fi.Length,
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Sequence = new SequenceType {MediaTitle = image.Info.MediaTitle}
|
2017-08-08 14:18:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Sequence.MediaSequence = image.Info.MediaSequence;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Sequence.TotalMedia = image.Info.LastMediaSequence;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sidecar.OpticalDisc[0].Sequence.MediaSequence = 1;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Sequence.TotalMedia = 1;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
MediaType dskType = image.Info.MediaType;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
foreach(MediaTagType tagType in image.Info.ReadableMediaTags)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
switch(tagType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case MediaTagType.CD_ATIP:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].ATIP = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.CD_ATIP)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.CD_ATIP).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-12-23 17:41:23 +00:00
|
|
|
|
ATIP.CDATIP? atip = ATIP.Decode(image.ReadDiskTag(MediaTagType.CD_ATIP));
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(atip.HasValue)
|
2018-01-28 20:29:46 +00:00
|
|
|
|
if(atip.Value.DDCD)
|
|
|
|
|
|
dskType = atip.Value.DiscType ? MediaType.DDCDRW : MediaType.DDCDR;
|
|
|
|
|
|
else
|
|
|
|
|
|
dskType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_BCA:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].BCA = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.DVD_BCA)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.DVD_BCA).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.BD_BCA:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].BCA = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.BD_BCA)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.BD_BCA).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_CMI:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].CMI = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.DVD_CMI)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.DVD_CMI).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-12-21 14:30:38 +00:00
|
|
|
|
CSS_CPRM.LeadInCopyright? cmi =
|
|
|
|
|
|
CSS_CPRM.DecodeLeadInCopyright(image.ReadDiskTag(MediaTagType.DVD_CMI));
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(cmi.HasValue)
|
|
|
|
|
|
switch(cmi.Value.CopyrightType)
|
|
|
|
|
|
{
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case CopyrightType.AACS:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
sidecar.OpticalDisc[0].CopyProtection = "AACS";
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case CopyrightType.CSS:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
sidecar.OpticalDisc[0].CopyProtection = "CSS";
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case CopyrightType.CPRM:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
sidecar.OpticalDisc[0].CopyProtection = "CPRM";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_DMI:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].DMI = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.DVD_DMI)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.DVD_DMI).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-12-21 14:30:38 +00:00
|
|
|
|
if(DMI.IsXbox(image.ReadDiskTag(MediaTagType.DVD_DMI)))
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
dskType = MediaType.XGD;
|
2018-01-30 21:47:37 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions = new DimensionsType {Diameter = 120, Thickness = 1.2};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2017-12-21 14:30:38 +00:00
|
|
|
|
else if(DMI.IsXbox360(image.ReadDiskTag(MediaTagType.DVD_DMI)))
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
dskType = MediaType.XGD2;
|
2018-01-30 21:47:37 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions = new DimensionsType {Diameter = 120, Thickness = 1.2};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_PFI:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].PFI = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.DVD_PFI)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.DVD_PFI).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-12-23 17:41:23 +00:00
|
|
|
|
PFI.PhysicalFormatInformation? pfi = PFI.Decode(image.ReadDiskTag(MediaTagType.DVD_PFI));
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(pfi.HasValue)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(dskType != MediaType.XGD && dskType != MediaType.XGD2 && dskType != MediaType.XGD3)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
switch(pfi.Value.DiskCategory)
|
|
|
|
|
|
{
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDPR:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDPR;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDPRDL:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDPRDL;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDPRW:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDPRW;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDPRWDL:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDPRWDL;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDR:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDR;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDRAM:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDRAM;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDROM:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDROM;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.DVDRW:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.DVDRW;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.HDDVDR:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.HDDVDR;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.HDDVDRAM:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.HDDVDRAM;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.HDDVDROM:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.HDDVDROM;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.HDDVDRW:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.HDDVDRW;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.Nintendo:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.GOD;
|
|
|
|
|
|
break;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
case DiskCategory.UMD:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.UMD;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
if(dskType == MediaType.DVDR && pfi.Value.PartVersion == 6) dskType = MediaType.DVDRDL;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(dskType == MediaType.DVDRW && pfi.Value.PartVersion == 3)
|
|
|
|
|
|
dskType = MediaType.DVDRWDL;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
if(dskType == MediaType.GOD && pfi.Value.DiscSize == DVDSize.OneTwenty)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.WOD;
|
|
|
|
|
|
|
2018-02-01 23:06:51 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions = new DimensionsType();
|
2018-01-30 21:47:37 +00:00
|
|
|
|
if(dskType == MediaType.UMD)
|
|
|
|
|
|
{
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Height = 64;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.HeightSpecified = true;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Width = 63;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.WidthSpecified = true;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Thickness = 4;
|
|
|
|
|
|
}
|
2017-12-23 17:41:23 +00:00
|
|
|
|
else
|
|
|
|
|
|
switch(pfi.Value.DiscSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DVDSize.Eighty:
|
2018-02-01 23:06:51 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Diameter = 80;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.DiameterSpecified = true;
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Thickness = 1.2;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case DVDSize.OneTwenty:
|
2018-02-01 23:06:51 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Diameter = 120;
|
2018-01-30 23:31:08 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.DiameterSpecified = true;
|
2018-02-01 23:06:51 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Dimensions.Thickness = 1.2;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.CD_PMA:
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].PMA = new DumpType
|
|
|
|
|
|
{
|
2018-02-01 23:06:51 +00:00
|
|
|
|
Image = Path.GetFileName(imagePath),
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.CD_PMA)).ToArray(),
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.CD_PMA).Length
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
2018-02-01 23:06:51 +00:00
|
|
|
|
case MediaTagType.CD_FullTOC:
|
|
|
|
|
|
sidecar.OpticalDisc[0].TOC = new DumpType
|
|
|
|
|
|
{
|
|
|
|
|
|
Image = Path.GetFileName(imagePath),
|
|
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.CD_FullTOC)).ToArray(),
|
|
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.CD_FullTOC).Length
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.CD_LeadIn:
|
|
|
|
|
|
sidecar.OpticalDisc[0].LeadIn = new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new BorderType
|
|
|
|
|
|
{
|
|
|
|
|
|
Image = Path.GetFileName(imagePath),
|
|
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.CD_LeadIn)).ToArray(),
|
|
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.CD_LeadIn).Length
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.Xbox_SecuritySector:
|
|
|
|
|
|
if(sidecar.OpticalDisc[0].Xbox == null) sidecar.OpticalDisc[0].Xbox = new XboxType();
|
|
|
|
|
|
|
|
|
|
|
|
sidecar.OpticalDisc[0].Xbox.SecuritySectors = new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new XboxSecuritySectorsType
|
|
|
|
|
|
{
|
|
|
|
|
|
RequestNumber = 0,
|
|
|
|
|
|
RequestVersion = 1,
|
|
|
|
|
|
SecuritySectors = new DumpType
|
|
|
|
|
|
{
|
|
|
|
|
|
Image = Path.GetFileName(imagePath),
|
|
|
|
|
|
Checksums =
|
|
|
|
|
|
Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.Xbox_SecuritySector))
|
|
|
|
|
|
.ToArray(),
|
|
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.Xbox_SecuritySector).Length
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.Xbox_PFI:
|
|
|
|
|
|
if(sidecar.OpticalDisc[0].Xbox == null) sidecar.OpticalDisc[0].Xbox = new XboxType();
|
|
|
|
|
|
|
|
|
|
|
|
sidecar.OpticalDisc[0].Xbox.PFI = new DumpType
|
|
|
|
|
|
{
|
|
|
|
|
|
Image = Path.GetFileName(imagePath),
|
|
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.Xbox_PFI)).ToArray(),
|
|
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.Xbox_PFI).Length
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.Xbox_DMI:
|
|
|
|
|
|
if(sidecar.OpticalDisc[0].Xbox == null) sidecar.OpticalDisc[0].Xbox = new XboxType();
|
|
|
|
|
|
|
|
|
|
|
|
sidecar.OpticalDisc[0].Xbox.DMI = new DumpType
|
|
|
|
|
|
{
|
|
|
|
|
|
Image = Path.GetFileName(imagePath),
|
|
|
|
|
|
Checksums = Checksum.GetChecksums(image.ReadDiskTag(MediaTagType.Xbox_DMI)).ToArray(),
|
|
|
|
|
|
Size = image.ReadDiskTag(MediaTagType.Xbox_DMI).Length
|
|
|
|
|
|
};
|
|
|
|
|
|
break;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
List<Session> sessions = image.Sessions;
|
2017-12-21 23:00:30 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Sessions = sessions?.Count ?? 1;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
catch { sidecar.OpticalDisc[0].Sessions = 1; }
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
List<Track> tracks = image.Tracks;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
List<TrackType> trksLst = null;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(tracks != null)
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Tracks = new int[1];
|
2017-08-08 13:40:32 +01:00
|
|
|
|
sidecar.OpticalDisc[0].Tracks[0] = tracks.Count;
|
2018-01-28 20:29:46 +00:00
|
|
|
|
trksLst = new List<TrackType>();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 21:28:23 +00:00
|
|
|
|
if(sidecar.OpticalDisc[0].Dimensions == null && image.Info.MediaType != MediaType.Unknown)
|
|
|
|
|
|
sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
|
2018-02-01 23:06:51 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
InitProgress();
|
2018-02-07 17:10:21 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateStatus("Checking filesystems");
|
|
|
|
|
|
List<Partition> partitions = Partitions.GetAll(image);
|
|
|
|
|
|
Partitions.AddSchemesToStats(partitions);
|
|
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
foreach(Track trk in tracks)
|
|
|
|
|
|
{
|
2017-12-21 14:30:38 +00:00
|
|
|
|
TrackType xmlTrk = new TrackType();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
switch(trk.TrackType)
|
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.Audio:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.audio;
|
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.CdMode2Form2:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.m2f2;
|
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.CdMode2Formless:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.mode2;
|
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.CdMode2Form1:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.m2f1;
|
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.CdMode1:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.mode1;
|
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
case DiscImages.TrackType.Data:
|
2017-08-08 13:40:32 +01:00
|
|
|
|
switch(sidecar.OpticalDisc[0].DiscType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "BD":
|
|
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.bluray;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "DDCD":
|
|
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.ddcd;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "DVD":
|
|
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.dvd;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "HD DVD":
|
|
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.hddvd;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
xmlTrk.TrackType1 = TrackTypeTrackType.mode1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.Sequence =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
new TrackSequenceType {Session = trk.TrackSession, TrackNumber = (int)trk.TrackSequence};
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.StartSector = (long)trk.TrackStartSector;
|
|
|
|
|
|
xmlTrk.EndSector = (long)trk.TrackEndSector;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2017-12-23 17:41:23 +00:00
|
|
|
|
if(trk.Indexes != null && trk.Indexes.ContainsKey(0))
|
2018-01-28 20:29:46 +00:00
|
|
|
|
if(trk.Indexes.TryGetValue(0, out ulong idx0))
|
|
|
|
|
|
xmlTrk.StartSector = (long)idx0;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2017-12-23 17:41:23 +00:00
|
|
|
|
switch(sidecar.OpticalDisc[0].DiscType)
|
|
|
|
|
|
{
|
2017-12-21 04:43:29 +00:00
|
|
|
|
case "CD":
|
|
|
|
|
|
case "GD":
|
|
|
|
|
|
xmlTrk.StartMSF = LbaToMsf(xmlTrk.StartSector);
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.EndMSF = LbaToMsf(xmlTrk.EndSector);
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case "DDCD":
|
|
|
|
|
|
xmlTrk.StartMSF = DdcdLbaToMsf(xmlTrk.StartSector);
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.EndMSF = DdcdLbaToMsf(xmlTrk.EndSector);
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
xmlTrk.Image = new ImageType {Value = Path.GetFileName(trk.TrackFile), format = trk.TrackFileType};
|
2017-08-08 14:18:31 +01:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
if(trk.TrackFileOffset > 0)
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.Image.offset = (long)trk.TrackFileOffset;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.Image.offsetSpecified = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * trk.TrackRawBytesPerSector;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.BytesPerSector = trk.TrackBytesPerSector;
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
uint sectorsToRead = 512;
|
|
|
|
|
|
ulong sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
|
|
|
|
|
ulong doneSectors = 0;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
|
|
|
|
|
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
|
2017-08-08 13:40:32 +01:00
|
|
|
|
// Only if filter is none...
|
2017-12-21 14:30:38 +00:00
|
|
|
|
(filterId == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") ||
|
2017-08-08 13:40:32 +01:00
|
|
|
|
// ...or AppleDouble
|
2017-12-23 17:41:23 +00:00
|
|
|
|
filterId == new Guid("1b2165ee-c9df-4b21-bbbb-9e5892b2df4d")))
|
|
|
|
|
|
xmlTrk.Checksums = sidecar.OpticalDisc[0].Checksums;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateProgress("Track {0} of {1}", trk.TrackSequence, tracks.Count);
|
|
|
|
|
|
|
|
|
|
|
|
// For fast debugging, skip checksum
|
|
|
|
|
|
//goto skipChecksum;
|
|
|
|
|
|
|
|
|
|
|
|
Checksum trkChkWorker = new Checksum();
|
|
|
|
|
|
|
|
|
|
|
|
InitProgress2();
|
|
|
|
|
|
while(doneSectors < sectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] sector;
|
|
|
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(sectors - doneSectors >= sectorsToRead)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sector = image.ReadSectorsLong(doneSectors, sectorsToRead,
|
|
|
|
|
|
(uint)xmlTrk.Sequence.TrackNumber);
|
|
|
|
|
|
UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors,
|
|
|
|
|
|
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
2017-08-08 13:40:32 +01:00
|
|
|
|
doneSectors += sectorsToRead;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sector = image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors),
|
|
|
|
|
|
(uint)xmlTrk.Sequence.TrackNumber);
|
|
|
|
|
|
UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors,
|
|
|
|
|
|
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
2018-01-28 20:29:46 +00:00
|
|
|
|
doneSectors += sectors - doneSectors;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trkChkWorker.Update(sector);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ChecksumType> trkChecksums = trkChkWorker.End();
|
|
|
|
|
|
|
|
|
|
|
|
xmlTrk.Checksums = trkChecksums.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
EndProgress2();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(trk.TrackSubchannelType != TrackSubchannelType.None)
|
|
|
|
|
|
{
|
2017-08-08 14:18:31 +01:00
|
|
|
|
xmlTrk.SubChannel = new SubChannelType
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
Image = new ImageType {Value = trk.TrackSubchannelFile},
|
2017-08-08 14:18:31 +01:00
|
|
|
|
// TODO: Packed subchannel has different size?
|
|
|
|
|
|
Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * 96
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
switch(trk.TrackSubchannelType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TrackSubchannelType.Packed:
|
|
|
|
|
|
case TrackSubchannelType.PackedInterleaved:
|
|
|
|
|
|
xmlTrk.SubChannel.Image.format = "rw";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TrackSubchannelType.Raw:
|
|
|
|
|
|
case TrackSubchannelType.RawInterleaved:
|
|
|
|
|
|
xmlTrk.SubChannel.Image.format = "rw_raw";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TrackSubchannelType.Q16:
|
|
|
|
|
|
case TrackSubchannelType.Q16Interleaved:
|
|
|
|
|
|
xmlTrk.SubChannel.Image.format = "q16";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(trk.TrackFileOffset > 0)
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
xmlTrk.SubChannel.Image.offset = (long)trk.TrackSubchannelOffset;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.SubChannel.Image.offsetSpecified = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Checksum subChkWorker = new Checksum();
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
doneSectors = 0;
|
|
|
|
|
|
|
|
|
|
|
|
InitProgress2();
|
|
|
|
|
|
while(doneSectors < sectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] sector;
|
|
|
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(sectors - doneSectors >= sectorsToRead)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sector = image.ReadSectorsTag(doneSectors, sectorsToRead, (uint)xmlTrk.Sequence.TrackNumber,
|
2017-12-20 17:15:26 +00:00
|
|
|
|
SectorTagType.CdSectorSubchannel);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors,
|
|
|
|
|
|
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
2017-08-08 13:40:32 +01:00
|
|
|
|
doneSectors += sectorsToRead;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sector = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors),
|
|
|
|
|
|
(uint)xmlTrk.Sequence.TrackNumber,
|
2017-12-20 17:15:26 +00:00
|
|
|
|
SectorTagType.CdSectorSubchannel);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors,
|
|
|
|
|
|
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
2018-01-28 20:29:46 +00:00
|
|
|
|
doneSectors += sectors - doneSectors;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
subChkWorker.Update(sector);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ChecksumType> subChecksums = subChkWorker.End();
|
|
|
|
|
|
|
|
|
|
|
|
xmlTrk.SubChannel.Checksums = subChecksums.ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
EndProgress2();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// For fast debugging, skip checksum
|
|
|
|
|
|
//skipChecksum:
|
|
|
|
|
|
|
2018-02-07 17:10:21 +00:00
|
|
|
|
List<Partition> trkPartitions =
|
|
|
|
|
|
partitions.Where(p => p.Start >= trk.TrackStartSector && p.End <= trk.TrackEndSector).ToList();
|
|
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
xmlTrk.FileSystemInformation = new PartitionType[1];
|
2018-02-07 17:10:21 +00:00
|
|
|
|
if(trkPartitions.Count > 0)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2018-02-07 17:10:21 +00:00
|
|
|
|
xmlTrk.FileSystemInformation = new PartitionType[trkPartitions.Count];
|
|
|
|
|
|
for(int i = 0; i < trkPartitions.Count; i++)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2017-08-08 14:18:31 +01:00
|
|
|
|
xmlTrk.FileSystemInformation[i] = new PartitionType
|
|
|
|
|
|
{
|
2018-02-07 17:10:21 +00:00
|
|
|
|
Description = trkPartitions[i].Description,
|
|
|
|
|
|
EndSector = (int)trkPartitions[i].End,
|
|
|
|
|
|
Name = trkPartitions[i].Name,
|
|
|
|
|
|
Sequence = (int)trkPartitions[i].Sequence,
|
|
|
|
|
|
StartSector = (int)trkPartitions[i].Start,
|
|
|
|
|
|
Type = trkPartitions[i].Type
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
List<FileSystemType> lstFs = new List<FileSystemType>();
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
foreach(IFilesystem plugin in plugins.PluginsList.Values)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2018-02-07 17:10:21 +00:00
|
|
|
|
if(!plugin.Identify(image, trkPartitions[i])) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2018-02-07 17:10:21 +00:00
|
|
|
|
plugin.GetInformation(image, trkPartitions[i], out _, encoding);
|
2017-12-26 06:05:12 +00:00
|
|
|
|
lstFs.Add(plugin.XmlFsType);
|
|
|
|
|
|
Statistics.AddFilesystem(plugin.XmlFsType.Type);
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
switch(plugin.XmlFsType.Type)
|
2017-12-23 17:41:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
case "Opera":
|
|
|
|
|
|
dskType = MediaType.ThreeDO;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "PC Engine filesystem":
|
|
|
|
|
|
dskType = MediaType.SuperCDROM2;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "Nintendo Wii filesystem":
|
|
|
|
|
|
dskType = MediaType.WOD;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "Nintendo Gamecube filesystem":
|
|
|
|
|
|
dskType = MediaType.GOD;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2017-08-08 13:40:32 +01:00
|
|
|
|
catch
|
2018-01-28 20:29:46 +00:00
|
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
//DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(lstFs.Count > 0) xmlTrk.FileSystemInformation[i].FileSystems = lstFs.ToArray();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-08-08 14:18:31 +01:00
|
|
|
|
xmlTrk.FileSystemInformation[0] = new PartitionType
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
EndSector = (int)xmlTrk.EndSector,
|
2017-08-08 14:18:31 +01:00
|
|
|
|
StartSector = (int)xmlTrk.StartSector
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
List<FileSystemType> lstFs = new List<FileSystemType>();
|
|
|
|
|
|
|
|
|
|
|
|
Partition xmlPart = new Partition
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Start = (ulong)xmlTrk.StartSector,
|
|
|
|
|
|
Length = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1),
|
|
|
|
|
|
Type = xmlTrk.TrackType1.ToString(),
|
|
|
|
|
|
Size = (ulong)xmlTrk.Size,
|
2017-08-08 13:40:32 +01:00
|
|
|
|
Sequence = (ulong)xmlTrk.Sequence.TrackNumber
|
|
|
|
|
|
};
|
2017-12-26 06:05:12 +00:00
|
|
|
|
foreach(IFilesystem plugin in plugins.PluginsList.Values)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
|
if(!plugin.Identify(image, xmlPart)) continue;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
plugin.GetInformation(image, xmlPart, out _, encoding);
|
|
|
|
|
|
lstFs.Add(plugin.XmlFsType);
|
|
|
|
|
|
Statistics.AddFilesystem(plugin.XmlFsType.Type);
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
switch(plugin.XmlFsType.Type)
|
2017-12-23 17:41:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
case "Opera":
|
|
|
|
|
|
dskType = MediaType.ThreeDO;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "PC Engine filesystem":
|
|
|
|
|
|
dskType = MediaType.SuperCDROM2;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "Nintendo Wii filesystem":
|
|
|
|
|
|
dskType = MediaType.WOD;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-12-23 17:41:23 +00:00
|
|
|
|
case "Nintendo Gamecube filesystem":
|
|
|
|
|
|
dskType = MediaType.GOD;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
break;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2017-08-08 13:40:32 +01:00
|
|
|
|
catch
|
2018-01-28 20:29:46 +00:00
|
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
//DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(lstFs.Count > 0) xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trksLst.Add(xmlTrk);
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-08-08 13:40:32 +01:00
|
|
|
|
EndProgress();
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(trksLst != null) sidecar.OpticalDisc[0].Track = trksLst.ToArray();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
|
|
|
|
|
// All XGD3 all have the same number of blocks
|
|
|
|
|
|
if(dskType == MediaType.XGD2 && sidecar.OpticalDisc[0].Track.Length == 1)
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
ulong blocks = (ulong)(sidecar.OpticalDisc[0].Track[0].EndSector -
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sidecar.OpticalDisc[0].Track[0].StartSector + 1);
|
2018-01-28 20:29:46 +00:00
|
|
|
|
if(blocks == 25063 || // Locked (or non compatible drive)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
blocks == 4229664 || // Xtreme unlock
|
2018-01-28 20:29:46 +00:00
|
|
|
|
blocks == 4246304) // Wxripper unlock
|
2017-08-08 13:40:32 +01:00
|
|
|
|
dskType = MediaType.XGD3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-08 14:18:31 +01:00
|
|
|
|
Metadata.MediaType.MediaTypeToString(dskType, out string dscType, out string dscSubType);
|
2018-01-28 20:29:46 +00:00
|
|
|
|
sidecar.OpticalDisc[0].DiscType = dscType;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
sidecar.OpticalDisc[0].DiscSubType = dscSubType;
|
|
|
|
|
|
Statistics.AddMedia(dskType, false);
|
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
|
if(image.DumpHardware != null) sidecar.OpticalDisc[0].DumpHardwareArray = image.DumpHardware.ToArray();
|
|
|
|
|
|
else if(!string.IsNullOrEmpty(image.Info.DriveManufacturer) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveModel) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveFirmwareRevision) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveSerialNumber))
|
2017-08-08 14:18:31 +01:00
|
|
|
|
sidecar.OpticalDisc[0].DumpHardwareArray = new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new DumpHardwareType
|
|
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Extents = new[] {new ExtentType {Start = 0, End = image.Info.Sectors}},
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Manufacturer = image.Info.DriveManufacturer,
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Model = image.Info.DriveModel,
|
|
|
|
|
|
Firmware = image.Info.DriveFirmwareRevision,
|
|
|
|
|
|
Serial = image.Info.DriveSerialNumber,
|
|
|
|
|
|
Software = new SoftwareType
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
|
Name = image.Info.Application,
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Version = image.Info.ApplicationVersion
|
2017-08-08 14:18:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|