2017-08-08 13:40:32 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-08-08 13:40:32 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 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;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Decoders.CD;
|
|
|
|
|
|
using Aaru.Decoders.DVD;
|
|
|
|
|
|
using DMI = Aaru.Decoders.Xbox.DMI;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Dump = Aaru.Core.Devices.Dumping.Dump;
|
|
|
|
|
|
using Partition = Aaru.CommonTypes.Partition;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Session = Aaru.CommonTypes.Structs.Session;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Track = Aaru.CommonTypes.Structs.Track;
|
|
|
|
|
|
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Core;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed partial class Sidecar
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>Creates a metadata sidecar for an optical disc (e.g. CD, DVD, GD, BD, XGD, GOD)</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>
|
|
|
|
|
|
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
2023-10-05 13:47:59 +01:00
|
|
|
|
void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins,
|
2022-12-15 22:21:07 +00:00
|
|
|
|
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_aborted)
|
|
|
|
|
|
return;
|
2019-04-20 19:21:00 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs = new List<OpticalDisc>
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
new()
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Checksums = imgChecksums,
|
|
|
|
|
|
Image = new Image
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Format = image.Format,
|
|
|
|
|
|
Offset = 0,
|
|
|
|
|
|
Value = Path.GetFileName(imagePath)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
},
|
|
|
|
|
|
Size = (ulong)fi.Length,
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Sequence = new Sequence
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Title = image.Info.MediaTitle
|
2017-08-08 14:18:31 +01:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Sequence.MediaSequence = 1;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Sequence.TotalMedia = 1;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
MediaType dskType = image.Info.MediaType;
|
|
|
|
|
|
ErrorNumber errno;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(Localization.Core.Hashing_media_tags);
|
2019-04-20 19:21:00 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(MediaTagType tagType in image.Info.ReadableMediaTags)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
|
|
|
|
|
return;
|
2021-09-18 15:01:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
errno = image.ReadMediaTag(tagType, out byte[] tag);
|
2021-06-04 18:17:53 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
continue;
|
2021-06-04 18:17:53 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Dump.AddMediaTagToSidecar(imagePath, tagType, tag, ref sidecar);
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(tagType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case MediaTagType.CD_ATIP:
|
|
|
|
|
|
ATIP.CDATIP atip = ATIP.Decode(tag);
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(atip != null)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(atip.DDCD)
|
|
|
|
|
|
dskType = atip.DiscType ? MediaType.DDCDRW : MediaType.DDCDR;
|
|
|
|
|
|
else
|
|
|
|
|
|
dskType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_DMI:
|
|
|
|
|
|
if(DMI.IsXbox(tag))
|
|
|
|
|
|
{
|
|
|
|
|
|
dskType = MediaType.XGD;
|
|
|
|
|
|
|
2022-12-17 20:59:12 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions = new Dimensions
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Diameter = 120,
|
|
|
|
|
|
Thickness = 1.2
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(DMI.IsXbox360(tag))
|
|
|
|
|
|
{
|
|
|
|
|
|
dskType = MediaType.XGD2;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-12-17 20:59:12 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions = new Dimensions
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Diameter = 120,
|
|
|
|
|
|
Thickness = 1.2
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaTagType.DVD_PFI:
|
|
|
|
|
|
PFI.PhysicalFormatInformation? pfi = PFI.Decode(tag, dskType);
|
|
|
|
|
|
|
|
|
|
|
|
if(pfi.HasValue)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(dskType != MediaType.XGD &&
|
|
|
|
|
|
dskType != MediaType.XGD2 &&
|
|
|
|
|
|
dskType != MediaType.XGD3 &&
|
|
|
|
|
|
dskType != MediaType.PS2DVD &&
|
|
|
|
|
|
dskType != MediaType.PS3DVD &&
|
|
|
|
|
|
dskType != MediaType.Nuon)
|
|
|
|
|
|
{
|
2022-11-13 19:59:24 +00:00
|
|
|
|
dskType = pfi.Value.DiskCategory switch
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
DiskCategory.DVDPR => MediaType.DVDPR,
|
|
|
|
|
|
DiskCategory.DVDPRDL => MediaType.DVDPRDL,
|
|
|
|
|
|
DiskCategory.DVDPRW => MediaType.DVDPRW,
|
|
|
|
|
|
DiskCategory.DVDPRWDL => MediaType.DVDPRWDL,
|
|
|
|
|
|
DiskCategory.DVDR => MediaType.DVDR,
|
|
|
|
|
|
DiskCategory.DVDRAM => MediaType.DVDRAM,
|
|
|
|
|
|
DiskCategory.DVDROM => MediaType.DVDROM,
|
|
|
|
|
|
DiskCategory.DVDRW => MediaType.DVDRW,
|
|
|
|
|
|
DiskCategory.HDDVDR => MediaType.HDDVDR,
|
|
|
|
|
|
DiskCategory.HDDVDRAM => MediaType.HDDVDRAM,
|
|
|
|
|
|
DiskCategory.HDDVDROM => MediaType.HDDVDROM,
|
|
|
|
|
|
DiskCategory.HDDVDRW => MediaType.HDDVDRW,
|
|
|
|
|
|
DiskCategory.Nintendo => MediaType.GOD,
|
|
|
|
|
|
DiskCategory.UMD => MediaType.UMD,
|
|
|
|
|
|
_ => dskType
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(dskType == MediaType.DVDR && pfi.Value.PartVersion >= 6)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
dskType = MediaType.DVDRDL;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(dskType == MediaType.DVDRW && pfi.Value.PartVersion >= 15)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
dskType = MediaType.DVDRWDL;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(dskType == MediaType.GOD && pfi.Value.DiscSize == DVDSize.OneTwenty)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
dskType = MediaType.WOD;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-17 20:59:12 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions = new Dimensions();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(dskType == MediaType.UMD)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Height = 64;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Width = 63;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Thickness = 4;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(pfi.Value.DiscSize)
|
2018-01-30 21:47:37 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
case DVDSize.Eighty:
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Diameter = 80;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Thickness = 1.2;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DVDSize.OneTwenty:
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Diameter = 120;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions.Thickness = 1.2;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
break;
|
2018-01-30 21:47:37 +00:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
2019-04-20 19:21:00 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
List<Session> sessions = image.Sessions;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Sessions = (uint)(sessions?.Count ?? 1);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Sessions = 1;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
List<Track> tracks = image.Tracks;
|
|
|
|
|
|
List<CommonTypes.AaruMetadata.Track> trksLst = null;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(tracks != null)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Tracks = new uint[1];
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Tracks[0] = (uint)tracks.Count;
|
|
|
|
|
|
trksLst = new List<CommonTypes.AaruMetadata.Track>();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(sidecar.OpticalDiscs[0].Dimensions == null && image.Info.MediaType != MediaType.Unknown)
|
2022-12-17 20:59:12 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Dimensions = Dimensions.FromMediaType(image.Info.MediaType);
|
2018-02-01 23:06:51 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_aborted)
|
|
|
|
|
|
return;
|
2019-04-20 19:21:00 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress();
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(Localization.Core.Checking_filesystems);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
List<Partition> partitions = Partitions.GetAll(image);
|
|
|
|
|
|
Partitions.AddSchemesToStats(partitions);
|
2018-02-07 17:10:21 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(Localization.Core.Hashing_tracks);
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(Track trk in tracks)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-04-20 19:21:00 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var xmlTrk = new CommonTypes.AaruMetadata.Track();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Type = trk.Type switch
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
TrackType.Audio => CommonTypes.AaruMetadata.TrackType.Audio,
|
|
|
|
|
|
TrackType.CdMode2Form2 => CommonTypes.AaruMetadata.TrackType.Mode2Form2,
|
|
|
|
|
|
TrackType.CdMode2Formless => CommonTypes.AaruMetadata.TrackType.Mode2,
|
|
|
|
|
|
TrackType.CdMode2Form1 => CommonTypes.AaruMetadata.TrackType.Mode2Form1,
|
|
|
|
|
|
TrackType.CdMode1 => CommonTypes.AaruMetadata.TrackType.Mode1,
|
|
|
|
|
|
TrackType.Data => sidecar.OpticalDiscs[0].DiscType switch
|
|
|
|
|
|
{
|
|
|
|
|
|
"BD" => CommonTypes.AaruMetadata.TrackType.Bluray,
|
|
|
|
|
|
"DDCD" => CommonTypes.AaruMetadata.TrackType.Ddcd,
|
|
|
|
|
|
"DVD" => CommonTypes.AaruMetadata.TrackType.Dvd,
|
|
|
|
|
|
"HD DVD" => CommonTypes.AaruMetadata.TrackType.HdDvd,
|
|
|
|
|
|
_ => CommonTypes.AaruMetadata.TrackType.Mode1
|
|
|
|
|
|
},
|
|
|
|
|
|
_ => xmlTrk.Type
|
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Sequence = new TrackSequence
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Session = trk.Session,
|
|
|
|
|
|
Number = trk.Sequence
|
2022-03-06 13:29:38 +00:00
|
|
|
|
};
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
xmlTrk.StartSector = trk.StartSector;
|
|
|
|
|
|
xmlTrk.EndSector = trk.EndSector;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(trk.Indexes?.TryGetValue(0, out int idx0) == true && idx0 >= 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
xmlTrk.StartSector = (ulong)idx0;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
switch(sidecar.OpticalDiscs[0].DiscType)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
case "CD":
|
|
|
|
|
|
case "GD":
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.StartMsf = LbaToMsf((long)xmlTrk.StartSector);
|
|
|
|
|
|
xmlTrk.EndMsf = LbaToMsf((long)xmlTrk.EndSector);
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case "DDCD":
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.StartMsf = DdcdLbaToMsf((long)xmlTrk.StartSector);
|
|
|
|
|
|
xmlTrk.EndMsf = DdcdLbaToMsf((long)xmlTrk.EndSector);
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Image = new Image
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Value = Path.GetFileName(trk.File),
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Format = trk.FileType
|
2022-03-06 13:29:38 +00:00
|
|
|
|
};
|
2017-08-08 14:18:31 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(trk.FileOffset > 0)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Image.Offset = trk.FileOffset;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
xmlTrk.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * (ulong)trk.RawBytesPerSector;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
xmlTrk.BytesPerSector = (uint)trk.BytesPerSector;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-11-13 20:08:10 +00:00
|
|
|
|
const uint sectorsToRead = 512;
|
|
|
|
|
|
ulong sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1;
|
|
|
|
|
|
ulong doneSectors = 0;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
|
|
|
|
|
|
if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Only if filter is none...
|
|
|
|
|
|
(filterId == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") ||
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// ...or AppleDouble
|
|
|
|
|
|
filterId == new Guid("1b2165ee-c9df-4b21-bbbb-9e5892b2df4d")))
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Checksums = sidecar.OpticalDiscs[0].Checksums;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress(Localization.Core.Track_0_of_1, trk.Sequence, tracks.Count);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// For fast debugging, skip checksum
|
|
|
|
|
|
//goto skipChecksum;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var trkChkWorker = new Checksum();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress2();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(doneSectors < sectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress();
|
|
|
|
|
|
EndProgress2();
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte[] sector;
|
|
|
|
|
|
|
|
|
|
|
|
if(sectors - doneSectors >= sectorsToRead)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
errno = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.Number, out sector);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(long)(trk.EndSector - trk.StartSector + 1));
|
|
|
|
|
|
|
|
|
|
|
|
if(errno != ErrorNumber.NoError)
|
2019-04-20 19:21:00 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(string.Format(Localization.Core.Error_0_reading_sector_1, errno, doneSectors));
|
2019-04-20 19:21:00 +01:00
|
|
|
|
EndProgress2();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2019-04-20 19:21:00 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
doneSectors += sectorsToRead;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
errno = image.ReadSectorsLong(doneSectors, (uint)(sectors - doneSectors),
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Sequence.Number, out sector);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress2(Localization.Core.Hashing_sector_0_of_1, (long)doneSectors,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(long)(trk.EndSector - trk.StartSector + 1));
|
|
|
|
|
|
|
|
|
|
|
|
if(errno != ErrorNumber.NoError)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(string.Format(Localization.Core.Error_0_reading_sector_1, errno, doneSectors));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress2();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
doneSectors += sectors - doneSectors;
|
|
|
|
|
|
}
|
2021-09-21 02:59:54 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
trkChkWorker.Update(sector);
|
|
|
|
|
|
}
|
2021-09-21 02:59:54 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Checksums = trkChkWorker.End();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress2();
|
|
|
|
|
|
}
|
2021-09-21 02:59:54 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(trk.SubchannelType != TrackSubchannelType.None)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel = new SubChannel
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Image = new Image
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Value = trk.SubchannelFile
|
|
|
|
|
|
},
|
2021-09-21 02:59:54 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Packed subchannel has different size?
|
|
|
|
|
|
Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * 96
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(trk.SubchannelType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TrackSubchannelType.Packed:
|
|
|
|
|
|
case TrackSubchannelType.PackedInterleaved:
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel.Image.Format = "rw";
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case TrackSubchannelType.Raw:
|
|
|
|
|
|
case TrackSubchannelType.RawInterleaved:
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel.Image.Format = "rw_raw";
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case TrackSubchannelType.Q16:
|
|
|
|
|
|
case TrackSubchannelType.Q16Interleaved:
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel.Image.Format = "q16";
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(trk.FileOffset > 0)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel.Image.Offset = trk.SubchannelOffset;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var subChkWorker = new Checksum();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1;
|
|
|
|
|
|
doneSectors = 0;
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress2();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(doneSectors < sectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress();
|
|
|
|
|
|
EndProgress2();
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
byte[] sector;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sectors - doneSectors >= sectorsToRead)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
errno = image.ReadSectorsTag(doneSectors, sectorsToRead, xmlTrk.Sequence.Number,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
SectorTagType.CdSectorSubchannel, out sector);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(long)(trk.EndSector - trk.StartSector + 1));
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
2019-04-20 19:21:00 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(string.Format(Localization.Core.Error_0_reading_sector_1, errno, doneSectors));
|
2019-04-20 19:21:00 +01:00
|
|
|
|
EndProgress2();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2019-04-20 19:21:00 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
doneSectors += sectorsToRead;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
errno = image.ReadSectorsTag(doneSectors, (uint)(sectors - doneSectors), xmlTrk.Sequence.Number,
|
|
|
|
|
|
SectorTagType.CdSectorSubchannel, out sector);
|
2021-09-21 03:42:15 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateProgress2(Localization.Core.Hashing_subchannel_sector_0_of_1, (long)doneSectors,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(long)(trk.EndSector - trk.StartSector + 1));
|
2021-09-21 03:42:15 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus(string.Format(Localization.Core.Error_0_reading_sector_1, errno, doneSectors));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress2();
|
2021-09-21 03:42:15 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
doneSectors += sectors - doneSectors;
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
subChkWorker.Update(sector);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.SubChannel.Checksums = subChkWorker.End();
|
2019-04-20 19:21:00 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress2();
|
|
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// For fast debugging, skip checksum
|
|
|
|
|
|
//skipChecksum:
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
var trkPartitions = partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.FileSystemInformation = new List<CommonTypes.AaruMetadata.Partition>();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(trkPartitions.Count > 0)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
foreach(Partition partition in trkPartitions)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var metadataPartition = new CommonTypes.AaruMetadata.Partition
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Description = partition.Description,
|
|
|
|
|
|
EndSector = partition.End,
|
|
|
|
|
|
Name = partition.Name,
|
|
|
|
|
|
Sequence = (uint)partition.Sequence,
|
|
|
|
|
|
StartSector = partition.Start,
|
|
|
|
|
|
Type = partition.Type
|
2017-08-08 14:18:31 +01:00
|
|
|
|
};
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
List<FileSystem> lstFs = new();
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
foreach(Type pluginType in plugins.Filesystems.Values)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2017-08-08 13:40:32 +01:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(_aborted)
|
2019-04-20 19:21:00 +01:00
|
|
|
|
{
|
|
|
|
|
|
EndProgress();
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2019-04-20 19:21:00 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
|
2019-11-18 20:59:16 +00:00
|
|
|
|
continue;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
if(!fs.Identify(image, partition))
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
fs.GetInformation(image, partition, encoding, out _, out FileSystem fsMetadata);
|
|
|
|
|
|
lstFs.Add(fsMetadata);
|
|
|
|
|
|
Statistics.AddFilesystem(fsMetadata.Type);
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
dskType = fsMetadata.Type switch
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
"Opera" => MediaType.ThreeDO,
|
|
|
|
|
|
"PC Engine filesystem" => MediaType.SuperCDROM2,
|
|
|
|
|
|
"Nintendo Wii filesystem" => MediaType.WOD,
|
|
|
|
|
|
"Nintendo Gamecube filesystem" => MediaType.GOD,
|
|
|
|
|
|
_ => dskType
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01: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
|
2023-10-03 22:57:50 +01: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
|
|
|
|
{
|
2023-10-03 17:17:16 +01:00
|
|
|
|
//AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2019-11-18 20:59:16 +00:00
|
|
|
|
if(lstFs.Count > 0)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
metadataPartition.FileSystems = lstFs;
|
|
|
|
|
|
|
|
|
|
|
|
xmlTrk.FileSystemInformation.Add(metadataPartition);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var metadataPartition = new CommonTypes.AaruMetadata.Partition
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
EndSector = xmlTrk.EndSector,
|
|
|
|
|
|
StartSector = xmlTrk.StartSector
|
|
|
|
|
|
};
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
List<FileSystem> lstFs = new();
|
2020-07-12 22:47:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var xmlPart = new Partition
|
2020-07-12 22:47:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Start = xmlTrk.StartSector,
|
|
|
|
|
|
Length = xmlTrk.EndSector - xmlTrk.StartSector + 1,
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Type = xmlTrk.Type.ToString(),
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Size = xmlTrk.Size,
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Sequence = xmlTrk.Sequence.Number
|
2022-03-06 13:29:38 +00:00
|
|
|
|
};
|
2020-07-12 22:47:32 +01:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
foreach(Type pluginType in plugins.Filesystems.Values)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
try
|
2020-07-12 22:47:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
|
|
|
|
|
EndProgress();
|
2020-07-12 22:47:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if(!fs.Identify(image, xmlPart))
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
fs.GetInformation(image, xmlPart, encoding, out _, out FileSystem fsMetadata);
|
|
|
|
|
|
lstFs.Add(fsMetadata);
|
|
|
|
|
|
Statistics.AddFilesystem(fsMetadata.Type);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
dskType = fsMetadata.Type switch
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
"Opera" => MediaType.ThreeDO,
|
|
|
|
|
|
"PC Engine filesystem" => MediaType.SuperCDROM2,
|
|
|
|
|
|
"Nintendo Wii filesystem" => MediaType.WOD,
|
|
|
|
|
|
"Nintendo Gamecube filesystem" => MediaType.GOD,
|
|
|
|
|
|
_ => dskType
|
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2022-03-06 13:29:38 +00:00
|
|
|
|
catch
|
2023-10-03 22:57:50 +01:00
|
|
|
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
2020-07-12 22:47:32 +01:00
|
|
|
|
{
|
2023-10-03 17:17:16 +01:00
|
|
|
|
//AaruConsole.DebugWriteLine(MODULE_NAME, "Plugin {0} crashed", _plugin.Name);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2020-07-12 22:47:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(lstFs.Count > 0)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
metadataPartition.FileSystems = lstFs;
|
|
|
|
|
|
|
|
|
|
|
|
xmlTrk.FileSystemInformation.Add(metadataPartition);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackIsrc, out byte[] isrcData);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno == ErrorNumber.NoError)
|
|
|
|
|
|
xmlTrk.ISRC = Encoding.UTF8.GetString(isrcData);
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
errno = image.ReadSectorTag(trk.Sequence, SectorTagType.CdTrackFlags, out byte[] flagsData);
|
|
|
|
|
|
|
|
|
|
|
|
if(errno == ErrorNumber.NoError)
|
2017-08-08 13:40:32 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var trackFlags = (CdFlags)flagsData[0];
|
|
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
xmlTrk.Flags = new TrackFlags
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
PreEmphasis = trackFlags.HasFlag(CdFlags.PreEmphasis),
|
|
|
|
|
|
CopyPermitted = trackFlags.HasFlag(CdFlags.CopyPermitted),
|
|
|
|
|
|
Data = trackFlags.HasFlag(CdFlags.DataTrack),
|
|
|
|
|
|
Quadraphonic = trackFlags.HasFlag(CdFlags.FourChannel)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2019-11-18 20:59:16 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(trk.Indexes?.Count > 0)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2023-10-04 17:34:40 +01:00
|
|
|
|
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).
|
|
|
|
|
|
Select(i => new TrackIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
Index = i.Key,
|
|
|
|
|
|
Value = i.Value
|
|
|
|
|
|
}).
|
|
|
|
|
|
ToList();
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
trksLst.Add(xmlTrk);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EndProgress();
|
|
|
|
|
|
|
|
|
|
|
|
if(trksLst != null)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].Track = trksLst;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
// All XGD3 all have the same number of blocks
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(dskType == MediaType.XGD2 && sidecar.OpticalDiscs[0].Track.Count == 1)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2023-10-04 17:34:40 +01:00
|
|
|
|
ulong blocks = sidecar.OpticalDiscs[0].Track[0].EndSector -
|
|
|
|
|
|
sidecar.OpticalDiscs[0].Track[0].StartSector +
|
2022-12-15 22:21:07 +00:00
|
|
|
|
1;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-03-16 11:47:00 +00:00
|
|
|
|
if(blocks is 25063 or 4229664 or 4246304) // Wxripper unlock
|
2022-03-06 13:29:38 +00:00
|
|
|
|
dskType = MediaType.XGD3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
(string type, string subType) discType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].DiscType = discType.type;
|
|
|
|
|
|
sidecar.OpticalDiscs[0].DiscSubType = discType.subType;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Statistics.AddMedia(dskType, false);
|
|
|
|
|
|
|
|
|
|
|
|
if(image.DumpHardware != null)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].DumpHardware = image.DumpHardware;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(!string.IsNullOrEmpty(image.Info.DriveManufacturer) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveModel) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveFirmwareRevision) ||
|
|
|
|
|
|
!string.IsNullOrEmpty(image.Info.DriveSerialNumber))
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.OpticalDiscs[0].DumpHardware = new List<DumpHardware>
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
new()
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Extents = new List<Extent>
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
new()
|
2017-08-08 14:18:31 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Start = 0,
|
|
|
|
|
|
End = image.Info.Sectors
|
2020-07-20 04:34:16 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
},
|
|
|
|
|
|
Manufacturer = image.Info.DriveManufacturer,
|
|
|
|
|
|
Model = image.Info.DriveModel,
|
|
|
|
|
|
Firmware = image.Info.DriveFirmwareRevision,
|
|
|
|
|
|
Serial = image.Info.DriveSerialNumber,
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Software = new Software
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Name = image.Info.Application,
|
|
|
|
|
|
Version = image.Info.ApplicationVersion
|
2017-08-08 14:18:31 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2017-08-08 13:40:32 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|