2016-07-28 18:13:49 +01:00
|
|
|
// /***************************************************************************
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : CDRWin.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Disc image plugins.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Manages CDRWin cuesheets (cue/bin).
|
|
|
|
|
//
|
|
|
|
|
// --[ 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
2013-12-14 23:02:04 +00:00
|
|
|
using System;
|
2017-12-19 19:33:46 +00:00
|
|
|
using System.Collections.Generic;
|
2013-12-14 23:02:04 +00:00
|
|
|
using System.IO;
|
2017-12-21 07:08:26 +00:00
|
|
|
using System.Linq;
|
2013-12-14 23:02:04 +00:00
|
|
|
using System.Text;
|
2013-12-16 01:04:17 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2017-12-21 14:30:38 +00:00
|
|
|
using DiscImageChef.Checksums;
|
2015-11-23 21:44:58 +00:00
|
|
|
using DiscImageChef.CommonTypes;
|
2017-12-19 19:33:46 +00:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2013-12-14 23:02:04 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.DiscImages
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
// TODO: Implement track flags
|
2017-12-20 17:15:26 +00:00
|
|
|
public class CdrWin : ImagePlugin
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
// Type for FILE entity
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Data as-is in little-endian</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_LITTLE_ENDIAN = "BINARY";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Data as-is in big-endian</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BIG_ENDIAN = "MOTOROLA";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Audio in Apple AIF file</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_AIFF = "AIFF";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Audio in Microsoft WAV file</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_RIFF = "WAVE";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Audio in MP3 file</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_MP3 = "MP3";
|
2015-12-06 07:37:20 +00:00
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
// Type for TRACK entity
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Audio track, 2352 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_AUDIO = "AUDIO";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>CD+G track, 2448 bytes/sector (audio+subchannel)</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_CDG = "CDG";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 1 track, cooked, 2048 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE1 = "MODE1/2048";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 1 track, raw, 2352 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE1_RAW = "MODE1/2352";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 2 form 1 track, cooked, 2048 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE2_FORM1 = "MODE2/2048";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 2 form 2 track, cooked, 2324 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE2_FORM2 = "MODE2/2324";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 2 formless track, cooked, 2336 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE2_FORMLESS = "MODE2/2336";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Mode 2 track, raw, 2352 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_MODE2_RAW = "MODE2/2352";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>CD-i track, cooked, 2336 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_CDI = "CDI/2336";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>CD-i track, raw, 2352 bytes/sector</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_TRACK_TYPE_CDI_RAW = "CDI/2352";
|
2015-12-06 07:37:20 +00:00
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
// Type for REM ORIGINAL MEDIA-TYPE entity
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.CD</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_CD = "CD";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.CDRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_CDRW = "CD-RW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.CDMRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_CDMRW = "CD-MRW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.CDMRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_CDMRW2 = "CD-(MRW)";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDROM</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVD = "DVD";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPMRW = "DVD+MRW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPMRW2 = "DVD+(MRW)";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRWDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPMRWDL = "DVD+MRW DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRWDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPMRWDL2 = "DVD+(MRW) DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPR = "DVD+R";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPRDL = "DVD+R DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPRW = "DVD+RW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPRWDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPRWDL = "DVD+RW DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDPR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDPVR = "DVD+VR";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDRAM</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDRAM = "DVD-RAM";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDR = "DVD-R";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDRDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDRDL = "DVD-R DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDRW = "DVD-RW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDRWDL</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDRWDL = "DVD-RW DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDVR = "DVD-VR";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.DVDRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_DVDRW2 = "DVDRW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDROM</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVD = "HD DVD";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDRAM</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVDRAM = "HD DVD-RAM";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVDR = "HD DVD-R";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVDRDL = "HD DVD-R DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVDRW = "HD DVD-RW";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.HDDVDRW</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_HDDVDRWDL = "HD DVD-RW DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.BDROM</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BD = "BD";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.BDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BDR = "BD-R";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.BDRE</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BDRE = "BD-RE";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.BDR</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BDRDL = "BD-R DL";
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>DiskType.BDRE</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const string CDRWIN_DISK_TYPE_BDREDL = "BD-RE DL";
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-24 20:26:23 +00:00
|
|
|
const string REGEX_SESSION = @"\bREM\s+SESSION\s+(?<number>\d+).*$";
|
|
|
|
|
const string REGEX_MEDIA_TYPE = @"\bREM\s+ORIGINAL MEDIA-TYPE:\s+(?<mediatype>.+)$";
|
|
|
|
|
const string REGEX_LEAD_OUT = @"\bREM\s+LEAD-OUT\s+(?<msf>[\d]+:[\d]+:[\d]+)$";
|
2017-12-24 00:12:31 +00:00
|
|
|
// Not checked
|
2017-12-24 20:26:23 +00:00
|
|
|
const string REGEX_LBA = @"\bREM MSF:\s+(?<msf>[\d]+:[\d]+:[\d]+)\s+=\s+LBA:\s+(?<lba>[\d]+)$";
|
|
|
|
|
const string REGEX_DISC_ID = @"\bDISC_ID\s+(?<diskid>[\da-f]{8})$";
|
|
|
|
|
const string REGEX_BARCODE = @"\bUPC_EAN\s+(?<barcode>[\d]{12,13})$";
|
|
|
|
|
const string REGEX_COMMENT = @"\bREM\s+(?<comment>.+)$";
|
|
|
|
|
const string REGEX_CDTEXT = @"\bCDTEXTFILE\s+(?<filename>.+)$";
|
|
|
|
|
const string REGEX_MCN = @"\bCATALOG\s+(?<catalog>\d{13})$";
|
|
|
|
|
const string REGEX_TITLE = @"\bTITLE\s+(?<title>.+)$";
|
|
|
|
|
const string REGEX_GENRE = @"\bGENRE\s+(?<genre>.+)$";
|
|
|
|
|
const string REGEX_ARRANGER = @"\bARRANGER\s+(?<arranger>.+)$";
|
|
|
|
|
const string REGEX_COMPOSER = @"\bCOMPOSER\s+(?<composer>.+)$";
|
|
|
|
|
const string REGEX_PERFORMER = @"\bPERFORMER\s+(?<performer>.+)$";
|
|
|
|
|
const string REGEX_SONGWRITER = @"\bSONGWRITER\s+(?<songwriter>.+)$";
|
|
|
|
|
const string REGEX_FILE = @"\bFILE\s+(?<filename>.+)\s+(?<type>\S+)$";
|
|
|
|
|
const string REGEX_TRACK = @"\bTRACK\s+(?<number>\d+)\s+(?<type>\S+)$";
|
|
|
|
|
const string REGEX_ISRC = @"\bISRC\s+(?<isrc>\w{12})$";
|
|
|
|
|
const string REGEX_INDEX = @"\bINDEX\s+(?<index>\d+)\s+(?<msf>[\d]+:[\d]+:[\d]+)$";
|
|
|
|
|
const string REGEX_PREGAP = @"\bPREGAP\s+(?<msf>[\d]+:[\d]+:[\d]+)$";
|
|
|
|
|
const string REGEX_POSTGAP = @"\bPOSTGAP\s+(?<msf>[\d]+:[\d]+:[\d]+)$";
|
|
|
|
|
const string REGEX_FLAGS = @"\bFLAGS\s+(((?<dcp>DCP)|(?<quad>4CH)|(?<pre>PRE)|(?<scms>SCMS))\s*)+$";
|
2017-12-24 00:12:31 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
Filter cdrwinFilter;
|
2014-04-14 01:14:20 +00:00
|
|
|
StreamReader cueStream;
|
2017-12-24 00:12:31 +00:00
|
|
|
CdrWinDisc discimage;
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream imageStream;
|
2015-12-06 07:37:20 +00:00
|
|
|
/// <summary>Dictionary, index is track #, value is TrackFile</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
Dictionary<uint, ulong> offsetmap;
|
|
|
|
|
List<Partition> partitions;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public CdrWin()
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2014-06-07 17:32:14 +01:00
|
|
|
Name = "CDRWin cuesheet";
|
2017-12-20 17:15:26 +00:00
|
|
|
PluginUuid = new Guid("664568B2-15D4-4E64-8A7A-20BDA8B8386F");
|
2017-12-22 06:55:04 +00:00
|
|
|
ImageInfo = new ImageInfo
|
|
|
|
|
{
|
|
|
|
|
ReadableSectorTags = new List<SectorTagType>(),
|
|
|
|
|
ReadableMediaTags = new List<MediaTagType>(),
|
2017-12-26 02:51:10 +00:00
|
|
|
HasPartitions = true,
|
|
|
|
|
HasSessions = true,
|
|
|
|
|
Version = null,
|
|
|
|
|
ApplicationVersion = null,
|
|
|
|
|
MediaTitle = null,
|
|
|
|
|
Creator = null,
|
2017-12-22 06:55:04 +00:00
|
|
|
MediaManufacturer = null,
|
|
|
|
|
MediaModel = null,
|
|
|
|
|
MediaPartNumber = null,
|
|
|
|
|
MediaSequence = 0,
|
|
|
|
|
LastMediaSequence = 0,
|
|
|
|
|
DriveManufacturer = null,
|
|
|
|
|
DriveModel = null,
|
|
|
|
|
DriveSerialNumber = null,
|
|
|
|
|
DriveFirmwareRevision = null
|
|
|
|
|
};
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-26 02:51:10 +00:00
|
|
|
public override string ImageFormat => "CDRWin CUESheet";
|
|
|
|
|
|
|
|
|
|
public override List<Partition> Partitions => partitions;
|
|
|
|
|
|
|
|
|
|
public override List<Track> Tracks
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
List<Track> tracks = new List<Track>();
|
|
|
|
|
|
|
|
|
|
ulong previousStartSector = 0;
|
|
|
|
|
|
|
|
|
|
foreach(CdrWinTrack cdrTrack in discimage.Tracks)
|
|
|
|
|
{
|
|
|
|
|
Track dicTrack = new Track
|
|
|
|
|
{
|
|
|
|
|
Indexes = cdrTrack.Indexes,
|
|
|
|
|
TrackDescription = cdrTrack.Title,
|
|
|
|
|
TrackStartSector = previousStartSector,
|
|
|
|
|
TrackPregap = cdrTrack.Pregap,
|
|
|
|
|
TrackSession = cdrTrack.Session,
|
|
|
|
|
TrackSequence = cdrTrack.Sequence,
|
|
|
|
|
TrackType = CdrWinTrackTypeToTrackType(cdrTrack.Tracktype),
|
|
|
|
|
TrackFile = cdrTrack.Trackfile.Datafilter.GetFilename(),
|
|
|
|
|
TrackFilter = cdrTrack.Trackfile.Datafilter,
|
|
|
|
|
TrackFileOffset = cdrTrack.Trackfile.Offset,
|
|
|
|
|
TrackFileType = cdrTrack.Trackfile.Filetype,
|
|
|
|
|
TrackRawBytesPerSector = cdrTrack.Bps,
|
|
|
|
|
TrackBytesPerSector = CdrWinTrackTypeToCookedBytesPerSector(cdrTrack.Tracktype)
|
|
|
|
|
};
|
|
|
|
|
dicTrack.TrackEndSector = dicTrack.TrackStartSector + cdrTrack.Sectors - 1;
|
|
|
|
|
|
|
|
|
|
if(!cdrTrack.Indexes.TryGetValue(0, out dicTrack.TrackStartSector))
|
|
|
|
|
cdrTrack.Indexes.TryGetValue(1, out dicTrack.TrackStartSector);
|
|
|
|
|
if(cdrTrack.Bps == 2448)
|
|
|
|
|
{
|
|
|
|
|
dicTrack.TrackSubchannelFilter = cdrTrack.Trackfile.Datafilter;
|
|
|
|
|
dicTrack.TrackSubchannelFile = cdrTrack.Trackfile.Datafilter.GetFilename();
|
|
|
|
|
dicTrack.TrackSubchannelOffset = cdrTrack.Trackfile.Offset;
|
|
|
|
|
dicTrack.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
|
|
|
|
}
|
|
|
|
|
else dicTrack.TrackSubchannelType = TrackSubchannelType.None;
|
|
|
|
|
|
|
|
|
|
tracks.Add(dicTrack);
|
|
|
|
|
previousStartSector = dicTrack.TrackEndSector + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tracks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override List<Session> Sessions => discimage.Sessions;
|
|
|
|
|
|
2013-12-16 01:04:17 +00:00
|
|
|
// Due to .cue format, this method must parse whole file, ignoring errors (those will be thrown by OpenImage()).
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool IdentifyImage(Filter imageFilter)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
cdrwinFilter = imageFilter;
|
2013-12-14 23:02:04 +00:00
|
|
|
|
2013-12-16 01:04:17 +00:00
|
|
|
try
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
|
|
|
|
byte[] testArray = new byte[512];
|
|
|
|
|
imageFilter.GetDataForkStream().Read(testArray, 0, 512);
|
|
|
|
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
|
|
|
|
// Check for unexpected control characters that shouldn't be present in a text file and can crash this plugin
|
|
|
|
|
bool twoConsecutiveNulls = false;
|
|
|
|
|
for(int i = 0; i < 512; i++)
|
|
|
|
|
{
|
|
|
|
|
if(i >= imageFilter.GetDataForkStream().Length) break;
|
|
|
|
|
|
|
|
|
|
if(testArray[i] == 0)
|
|
|
|
|
{
|
|
|
|
|
if(twoConsecutiveNulls) return false;
|
|
|
|
|
|
|
|
|
|
twoConsecutiveNulls = true;
|
|
|
|
|
}
|
|
|
|
|
else twoConsecutiveNulls = false;
|
|
|
|
|
|
|
|
|
|
if(testArray[i] < 0x20 && testArray[i] != 0x0A && testArray[i] != 0x0D && testArray[i] != 0x00)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
cueStream = new StreamReader(cdrwinFilter.GetDataForkStream());
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
while(cueStream.Peek() >= 0)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
string line = cueStream.ReadLine();
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
Regex sr = new Regex(REGEX_SESSION);
|
|
|
|
|
Regex rr = new Regex(REGEX_COMMENT);
|
|
|
|
|
Regex cr = new Regex(REGEX_MCN);
|
|
|
|
|
Regex fr = new Regex(REGEX_FILE);
|
|
|
|
|
Regex tr = new Regex(REGEX_CDTEXT);
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2016-08-08 18:44:08 +01:00
|
|
|
// First line must be SESSION, REM, CATALOG, FILE or CDTEXTFILE.
|
2017-12-22 06:55:04 +00:00
|
|
|
Match sm = sr.Match(line ?? throw new InvalidOperationException());
|
|
|
|
|
Match rm = rr.Match(line);
|
|
|
|
|
Match cm = cr.Match(line);
|
|
|
|
|
Match fm = fr.Match(line);
|
|
|
|
|
Match tm = tr.Match(line);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
return sm.Success || rm.Success || cm.Success || fm.Success || tm.Success;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
catch(Exception ex)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.ErrorWriteLine("Exception trying to identify image file {0}", cdrwinFilter);
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.ErrorWriteLine("Exception: {0}", ex.Message);
|
|
|
|
|
DicConsole.ErrorWriteLine("Stack trace: {0}", ex.StackTrace);
|
2013-12-16 01:04:17 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
public override bool OpenImage(Filter imageFilter)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(imageFilter == null) return false;
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
cdrwinFilter = imageFilter;
|
2013-12-16 01:04:17 +00:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
|
|
|
|
cueStream = new StreamReader(imageFilter.GetDataForkStream());
|
2017-12-22 06:55:04 +00:00
|
|
|
int lineNumber = 0;
|
2013-12-16 01:04:17 +00:00
|
|
|
bool intrack = false;
|
|
|
|
|
byte currentsession = 1;
|
|
|
|
|
|
|
|
|
|
// Initialize all RegExs
|
2017-12-24 00:12:31 +00:00
|
|
|
Regex regexSession = new Regex(REGEX_SESSION);
|
|
|
|
|
Regex regexDiskType = new Regex(REGEX_MEDIA_TYPE);
|
|
|
|
|
Regex regexLeadOut = new Regex(REGEX_LEAD_OUT);
|
|
|
|
|
Regex regexLba = new Regex(REGEX_LBA);
|
|
|
|
|
Regex regexDiskId = new Regex(REGEX_DISC_ID);
|
|
|
|
|
Regex regexBarCode = new Regex(REGEX_BARCODE);
|
|
|
|
|
Regex regexComment = new Regex(REGEX_COMMENT);
|
|
|
|
|
Regex regexCdText = new Regex(REGEX_CDTEXT);
|
|
|
|
|
Regex regexMcn = new Regex(REGEX_MCN);
|
|
|
|
|
Regex regexTitle = new Regex(REGEX_TITLE);
|
|
|
|
|
Regex regexGenre = new Regex(REGEX_GENRE);
|
|
|
|
|
Regex regexArranger = new Regex(REGEX_ARRANGER);
|
|
|
|
|
Regex regexComposer = new Regex(REGEX_COMPOSER);
|
|
|
|
|
Regex regexPerformer = new Regex(REGEX_PERFORMER);
|
|
|
|
|
Regex regexSongWriter = new Regex(REGEX_SONGWRITER);
|
|
|
|
|
Regex regexFile = new Regex(REGEX_FILE);
|
|
|
|
|
Regex regexTrack = new Regex(REGEX_TRACK);
|
|
|
|
|
Regex regexIsrc = new Regex(REGEX_ISRC);
|
|
|
|
|
Regex regexIndex = new Regex(REGEX_INDEX);
|
|
|
|
|
Regex regexPregap = new Regex(REGEX_PREGAP);
|
|
|
|
|
Regex regexPostgap = new Regex(REGEX_POSTGAP);
|
|
|
|
|
Regex regexFlags = new Regex(REGEX_FLAGS);
|
2013-12-16 01:04:17 +00:00
|
|
|
|
|
|
|
|
// Initialize all RegEx matches
|
2017-12-20 17:15:26 +00:00
|
|
|
Match matchTrack;
|
2013-12-16 01:04:17 +00:00
|
|
|
|
|
|
|
|
// Initialize disc
|
2017-12-22 06:55:04 +00:00
|
|
|
discimage = new CdrWinDisc
|
|
|
|
|
{
|
|
|
|
|
Sessions = new List<Session>(),
|
|
|
|
|
Tracks = new List<CdrWinTrack>(),
|
|
|
|
|
Comment = ""
|
|
|
|
|
};
|
2017-12-20 17:15:26 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
CdrWinTrack currenttrack = new CdrWinTrack {Indexes = new Dictionary<int, ulong>()};
|
2017-12-20 17:15:26 +00:00
|
|
|
CdrWinTrackFile currentfile = new CdrWinTrackFile();
|
2014-04-14 01:14:20 +00:00
|
|
|
ulong currentfileoffsetsector = 0;
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
int trackCount = 0;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
while(cueStream.Peek() >= 0)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
lineNumber++;
|
|
|
|
|
string line = cueStream.ReadLine();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
matchTrack = regexTrack.Match(line);
|
2017-12-21 06:06:19 +00:00
|
|
|
if(!matchTrack.Success) continue;
|
|
|
|
|
|
|
|
|
|
uint trackSeq = uint.Parse(matchTrack.Groups[1].Value);
|
|
|
|
|
if(trackCount + 1 != trackSeq)
|
|
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found TRACK {trackSeq} out of order in line {lineNumber}");
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
trackCount++;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(trackCount == 0) throw new FeatureUnsupportedImageException("No tracks found");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
CdrWinTrack[] cuetracks = new CdrWinTrack[trackCount];
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
lineNumber = 0;
|
2016-09-05 17:37:31 +01:00
|
|
|
imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin);
|
|
|
|
|
cueStream = new StreamReader(imageFilter.GetDataForkStream());
|
2015-05-23 05:29:35 +01:00
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
FiltersList filtersList = new FiltersList();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
while(cueStream.Peek() >= 0)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
lineNumber++;
|
|
|
|
|
string line = cueStream.ReadLine();
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
Match matchSession = regexSession.Match(line);
|
|
|
|
|
Match matchDiskType = regexDiskType.Match(line);
|
|
|
|
|
Match matchComment = regexComment.Match(line);
|
|
|
|
|
Match matchLba = regexLba.Match(line);
|
|
|
|
|
Match matchLeadOut = regexLeadOut.Match(line);
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(matchDiskType.Success && !intrack)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM ORIGINAL MEDIA TYPE at line {0}",
|
|
|
|
|
lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Disktypestr = matchDiskType.Groups[1].Value;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchDiskType.Success && intrack)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found REM ORIGINAL MEDIA TYPE field after a track in line {lineNumber}");
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchSession.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM SESSION at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
currentsession = byte.Parse(matchSession.Groups[1].Value);
|
2013-12-16 01:04:17 +00:00
|
|
|
|
|
|
|
|
// What happens between sessions
|
|
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
else if(matchLba.Success)
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM MSF at line {0}", lineNumber);
|
|
|
|
|
else if(matchLeadOut.Success)
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM LEAD-OUT at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchComment.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found REM at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Comment == "") discimage.Comment = matchComment.Groups[1].Value; // First comment
|
2014-04-14 01:14:20 +00:00
|
|
|
else
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Comment +=
|
|
|
|
|
Environment.NewLine + matchComment.Groups[1].Value; // Append new comments as new lines
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
matchTrack = regexTrack.Match(line);
|
|
|
|
|
Match matchTitle = regexTitle.Match(line);
|
|
|
|
|
Match matchSongWriter = regexSongWriter.Match(line);
|
|
|
|
|
Match matchPregap = regexPregap.Match(line);
|
|
|
|
|
Match matchPostgap = regexPostgap.Match(line);
|
|
|
|
|
Match matchPerformer = regexPerformer.Match(line);
|
|
|
|
|
Match matchMcn = regexMcn.Match(line);
|
|
|
|
|
Match matchIsrc = regexIsrc.Match(line);
|
|
|
|
|
Match matchIndex = regexIndex.Match(line);
|
|
|
|
|
Match matchGenre = regexGenre.Match(line);
|
|
|
|
|
Match matchFlags = regexFlags.Match(line);
|
|
|
|
|
Match matchFile = regexFile.Match(line);
|
|
|
|
|
Match matchDiskId = regexDiskId.Match(line);
|
|
|
|
|
Match matchComposer = regexComposer.Match(line);
|
|
|
|
|
Match matchCdText = regexCdText.Match(line);
|
|
|
|
|
Match matchBarCode = regexBarCode.Match(line);
|
|
|
|
|
Match matchArranger = regexArranger.Match(line);
|
2017-12-20 17:15:26 +00:00
|
|
|
|
|
|
|
|
if(matchArranger.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found ARRANGER at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Arranger = matchArranger.Groups[1].Value;
|
|
|
|
|
else discimage.Arranger = matchArranger.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchBarCode.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found UPC_EAN at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!intrack) discimage.Barcode = matchBarCode.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found barcode field in incorrect place at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchCdText.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found CDTEXTFILE at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!intrack) discimage.Cdtextfile = matchCdText.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found CD-Text file field in incorrect place at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchComposer.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found COMPOSER at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Composer = matchComposer.Groups[1].Value;
|
|
|
|
|
else discimage.Composer = matchComposer.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchDiskId.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found DISC_ID at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!intrack) discimage.DiskId = matchDiskId.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found CDDB ID field in incorrect place at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchFile.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found FILE at line {0}", lineNumber);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currenttrack.Sequence != 0)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Sequence = currenttrack.Sequence;
|
|
|
|
|
currenttrack.Trackfile = currentfile;
|
|
|
|
|
currenttrack.Sectors =
|
|
|
|
|
((ulong)currentfile.Datafilter.GetLength() - currentfile.Offset) /
|
|
|
|
|
CdrWinTrackTypeToBytesPerSector(currenttrack.Tracktype);
|
|
|
|
|
cuetracks[currenttrack.Sequence - 1] = currenttrack;
|
2014-04-14 01:14:20 +00:00
|
|
|
intrack = false;
|
2017-12-20 17:15:26 +00:00
|
|
|
currenttrack = new CdrWinTrack();
|
|
|
|
|
currentfile = new CdrWinTrackFile();
|
2017-12-19 20:33:03 +00:00
|
|
|
filtersList = new FiltersList();
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
//currentfile = new CDRWinTrackFile();
|
2017-12-20 17:15:26 +00:00
|
|
|
string datafile = matchFile.Groups[1].Value;
|
|
|
|
|
currentfile.Filetype = matchFile.Groups[2].Value;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
// Check if file path is quoted
|
2017-12-24 00:12:31 +00:00
|
|
|
if(datafile[0] == '"' && datafile[datafile.Length - 1] == '"')
|
|
|
|
|
datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(datafile);
|
2016-09-05 17:37:31 +01:00
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
// Check if file exists
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2017-12-24 00:12:31 +00:00
|
|
|
if(datafile[0] == '/' || datafile[0] == '/' && datafile[1] == '.') // UNIX absolute path
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
|
|
|
|
Regex unixpath = new Regex("^(.+)/([^/]+)$");
|
2016-09-05 17:37:31 +01:00
|
|
|
Match unixpathmatch = unixpath.Match(datafile);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(unixpathmatch.Success)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(unixpathmatch.Groups[1].Value);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
string path = imageFilter.GetParentFolder() + Path.PathSeparator +
|
|
|
|
|
unixpathmatch.Groups[1].Value;
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(path);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"File \"{matchFile.Groups[1].Value}\" not found.");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"File \"{matchFile.Groups[1].Value}\" not found.");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-20 17:26:28 +00:00
|
|
|
else if(datafile[1] == ':' && datafile[2] == '\\' ||
|
|
|
|
|
datafile[0] == '\\' && datafile[1] == '\\' ||
|
|
|
|
|
datafile[0] == '.' && datafile[1] == '\\') // Windows absolute path
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
Regex winpath =
|
|
|
|
|
new
|
|
|
|
|
Regex("^(?:[a-zA-Z]\\:(\\\\|\\/)|file\\:\\/\\/|\\\\\\\\|\\.(\\/|\\\\))([^\\\\\\/\\:\\*\\?\\<\\>\\\"\\|]+(\\\\|\\/){0,1})+$");
|
2016-09-05 17:37:31 +01:00
|
|
|
Match winpathmatch = winpath.Match(datafile);
|
2016-04-19 02:11:47 +01:00
|
|
|
if(winpathmatch.Success)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(winpathmatch.Groups[1].Value);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
string path = imageFilter.GetParentFolder() + Path.PathSeparator +
|
|
|
|
|
winpathmatch.Groups[1].Value;
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(path);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"File \"{matchFile.Groups[1].Value}\" not found.");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"File \"{matchFile.Groups[1].Value}\" not found.");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
string path = imageFilter.GetParentFolder() + Path.PathSeparator + datafile;
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter = filtersList.GetFilter(path);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"File \"{matchFile.Groups[1].Value}\" not found.");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// File does exist, process it
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "File \"{0}\" found",
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Datafilter.GetFilename());
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
switch(currentfile.Filetype)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_DISK_TYPE_LITTLE_ENDIAN: break;
|
|
|
|
|
case CDRWIN_DISK_TYPE_BIG_ENDIAN:
|
|
|
|
|
case CDRWIN_DISK_TYPE_AIFF:
|
|
|
|
|
case CDRWIN_DISK_TYPE_RIFF:
|
|
|
|
|
case CDRWIN_DISK_TYPE_MP3:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureSupportedButNotImplementedImageException($"Unsupported file type {currentfile.Filetype}");
|
2014-04-14 01:14:20 +00:00
|
|
|
default:
|
2017-12-24 00:12:31 +00:00
|
|
|
throw new
|
|
|
|
|
FeatureUnsupportedImageException($"Unknown file type {currentfile.Filetype}");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Offset = 0;
|
|
|
|
|
currentfile.Sequence = 0;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchFlags.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found FLAGS at line {0}", lineNumber);
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!intrack)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found FLAGS field in incorrect place at line {lineNumber}");
|
2015-12-23 23:46:31 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
currenttrack.FlagDcp |= matchFile.Groups["dcp"].Value == "DCP";
|
|
|
|
|
currenttrack.Flag4ch |= matchFile.Groups["quad"].Value == "4CH";
|
|
|
|
|
currenttrack.FlagPre |= matchFile.Groups["pre"].Value == "PRE";
|
|
|
|
|
currenttrack.FlagScms |= matchFile.Groups["scms"].Value == "SCMS";
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchGenre.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found GENRE at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Genre = matchGenre.Groups[1].Value;
|
|
|
|
|
else discimage.Genre = matchGenre.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchIndex.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found INDEX at line {0}", lineNumber);
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!intrack)
|
2017-12-24 00:12:31 +00:00
|
|
|
throw new FeatureUnsupportedImageException($"Found INDEX before a track {lineNumber}");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-21 02:57:32 +00:00
|
|
|
int index = int.Parse(matchIndex.Groups[1].Value);
|
|
|
|
|
ulong offset = CdrWinMsftoLba(matchIndex.Groups[2].Value);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-21 02:57:32 +00:00
|
|
|
if(index != 0 && index != 1 && currenttrack.Indexes.Count == 0)
|
|
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
FeatureUnsupportedImageException($"Found INDEX {index} before INDEX 00 or INDEX 01");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-21 02:57:32 +00:00
|
|
|
if(index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0))
|
|
|
|
|
if((int)(currenttrack.Sequence - 2) >= 0 && offset > 1)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-21 02:57:32 +00:00
|
|
|
cuetracks[currenttrack.Sequence - 2].Sectors = offset - currentfileoffsetsector;
|
|
|
|
|
currentfile.Offset +=
|
|
|
|
|
cuetracks[currenttrack.Sequence - 2].Sectors *
|
|
|
|
|
cuetracks[currenttrack.Sequence - 2].Bps;
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin",
|
|
|
|
|
"Sets currentfile.offset to {0} at line 553",
|
|
|
|
|
currentfile.Offset);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin",
|
|
|
|
|
"cuetracks[currenttrack.sequence-2].sectors = {0}",
|
|
|
|
|
cuetracks[currenttrack.Sequence - 2].Sectors);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin",
|
2017-12-21 02:57:32 +00:00
|
|
|
"cuetracks[currenttrack.sequence-2].bps = {0}",
|
|
|
|
|
cuetracks[currenttrack.Sequence - 2].Bps);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
|
2017-12-21 02:57:32 +00:00
|
|
|
if((index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0)) &&
|
|
|
|
|
currenttrack.Sequence == 1)
|
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Sets currentfile.offset to {0} at line 559",
|
2017-12-21 02:57:32 +00:00
|
|
|
offset * currenttrack.Bps);
|
|
|
|
|
currentfile.Offset = offset * currenttrack.Bps;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-21 02:57:32 +00:00
|
|
|
|
|
|
|
|
currentfileoffsetsector = offset;
|
|
|
|
|
currenttrack.Indexes.Add(index, offset);
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchIsrc.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found ISRC at line {0}", lineNumber);
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!intrack)
|
2017-12-24 00:12:31 +00:00
|
|
|
throw new FeatureUnsupportedImageException($"Found ISRC before a track {lineNumber}");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
currenttrack.Isrc = matchIsrc.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchMcn.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found CATALOG at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!intrack) discimage.Mcn = matchMcn.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found CATALOG field in incorrect place at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchPerformer.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found PERFORMER at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Performer = matchPerformer.Groups[1].Value;
|
|
|
|
|
else discimage.Performer = matchPerformer.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchPostgap.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found POSTGAP at line {0}", lineNumber);
|
2017-12-20 23:07:46 +00:00
|
|
|
if(intrack) currenttrack.Postgap = CdrWinMsftoLba(matchPostgap.Groups[1].Value);
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found POSTGAP field before a track at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchPregap.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found PREGAP at line {0}", lineNumber);
|
2017-12-20 23:07:46 +00:00
|
|
|
if(intrack) currenttrack.Pregap = CdrWinMsftoLba(matchPregap.Groups[1].Value);
|
2013-12-16 01:04:17 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found PREGAP field before a track at line {lineNumber}");
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchSongWriter.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found SONGWRITER at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Songwriter = matchSongWriter.Groups[1].Value;
|
|
|
|
|
else discimage.Songwriter = matchSongWriter.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchTitle.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found TITLE at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(intrack) currenttrack.Title = matchTitle.Groups[1].Value;
|
|
|
|
|
else discimage.Title = matchTitle.Groups[1].Value;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(matchTrack.Success)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Found TRACK at line {0}", lineNumber);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currentfile.Datafilter == null)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found TRACK field before a file is defined at line {lineNumber}");
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(intrack)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
if(currenttrack.Indexes.ContainsKey(0) && currenttrack.Pregap == 0)
|
|
|
|
|
currenttrack.Indexes.TryGetValue(0, out currenttrack.Pregap);
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Sequence = currenttrack.Sequence;
|
|
|
|
|
currenttrack.Trackfile = currentfile;
|
|
|
|
|
cuetracks[currenttrack.Sequence - 1] = currenttrack;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
currenttrack = new CdrWinTrack
|
|
|
|
|
{
|
|
|
|
|
Indexes = new Dictionary<int, ulong>(),
|
|
|
|
|
Sequence = uint.Parse(matchTrack.Groups[1].Value)
|
|
|
|
|
};
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Setting currenttrack.sequence to {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
currenttrack.Sequence);
|
|
|
|
|
currentfile.Sequence = currenttrack.Sequence;
|
|
|
|
|
currenttrack.Bps = CdrWinTrackTypeToBytesPerSector(matchTrack.Groups[2].Value);
|
|
|
|
|
currenttrack.Tracktype = matchTrack.Groups[2].Value;
|
|
|
|
|
currenttrack.Session = currentsession;
|
2014-04-14 01:14:20 +00:00
|
|
|
intrack = true;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
else if(line == "") // Empty line, ignore it
|
2017-12-19 20:33:03 +00:00
|
|
|
{ }
|
2014-04-14 01:14:20 +00:00
|
|
|
else // Non-empty unknown field
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-22 06:55:04 +00:00
|
|
|
FeatureUnsupportedImageException($"Found unknown field defined at line {lineNumber}: \"{line}\"");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(currenttrack.Sequence != 0)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
currentfile.Sequence = currenttrack.Sequence;
|
|
|
|
|
currenttrack.Trackfile = currentfile;
|
|
|
|
|
currenttrack.Sectors = ((ulong)currentfile.Datafilter.GetLength() - currentfile.Offset) /
|
|
|
|
|
CdrWinTrackTypeToBytesPerSector(currenttrack.Tracktype);
|
|
|
|
|
cuetracks[currenttrack.Sequence - 1] = currenttrack;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Session[] sessions = new Session[currentsession];
|
|
|
|
|
for(int s = 1; s <= sessions.Length; s++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sessions[s - 1].SessionSequence = 1;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(s > 1) sessions[s - 1].StartSector = sessions[s - 2].EndSector + 1;
|
|
|
|
|
else sessions[s - 1].StartSector = 0;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong sessionSectors = 0;
|
|
|
|
|
int lastSessionTrack = 0;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < cuetracks.Length; i++)
|
2017-12-20 17:15:26 +00:00
|
|
|
if(cuetracks[i].Session == s)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sessionSectors += cuetracks[i].Sectors;
|
|
|
|
|
if(i > lastSessionTrack) lastSessionTrack = i;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
sessions[s - 1].EndTrack = cuetracks[lastSessionTrack].Sequence;
|
|
|
|
|
sessions[s - 1].EndSector = sessionSectors - 1;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int s = 1; s <= sessions.Length; s++) discimage.Sessions.Add(sessions[s - 1]);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int t = 1; t <= cuetracks.Length; t++) discimage.Tracks.Add(cuetracks[t - 1]);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Disktype = CdrWinIsoBusterDiscTypeToMediaType(discimage.Disktypestr);
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Disktype == MediaType.Unknown || discimage.Disktype == MediaType.CD)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
|
|
|
|
bool data = false;
|
|
|
|
|
bool cdg = false;
|
|
|
|
|
bool cdi = false;
|
|
|
|
|
bool mode2 = false;
|
|
|
|
|
bool firstaudio = false;
|
|
|
|
|
bool firstdata = false;
|
|
|
|
|
bool audio = false;
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int i = 0; i < discimage.Tracks.Count; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
|
|
|
|
// First track is audio
|
2017-12-20 17:15:26 +00:00
|
|
|
firstaudio |= i == 0 && discimage.Tracks[i].Tracktype == CDRWIN_TRACK_TYPE_AUDIO;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
// First track is data
|
2017-12-20 17:15:26 +00:00
|
|
|
firstdata |= i == 0 && discimage.Tracks[i].Tracktype != CDRWIN_TRACK_TYPE_AUDIO;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
// Any non first track is data
|
2017-12-20 17:15:26 +00:00
|
|
|
data |= i != 0 && discimage.Tracks[i].Tracktype != CDRWIN_TRACK_TYPE_AUDIO;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
// Any non first track is audio
|
2017-12-20 17:15:26 +00:00
|
|
|
audio |= i != 0 && discimage.Tracks[i].Tracktype == CDRWIN_TRACK_TYPE_AUDIO;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
switch(discimage.Tracks[i].Tracktype)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDG:
|
2014-04-14 01:14:20 +00:00
|
|
|
cdg = true;
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
2014-04-14 01:14:20 +00:00
|
|
|
cdi = true;
|
|
|
|
|
break;
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
2014-04-14 01:14:20 +00:00
|
|
|
mode2 = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!data && !firstdata) discimage.Disktype = MediaType.CDDA;
|
|
|
|
|
else if(cdg) discimage.Disktype = MediaType.CDG;
|
|
|
|
|
else if(cdi) discimage.Disktype = MediaType.CDI;
|
|
|
|
|
else if(firstaudio && data && discimage.Sessions.Count > 1 && mode2)
|
|
|
|
|
discimage.Disktype = MediaType.CDPLUS;
|
2017-12-20 17:26:28 +00:00
|
|
|
else if(firstdata && audio || mode2) discimage.Disktype = MediaType.CDROMXA;
|
2017-12-20 17:15:26 +00:00
|
|
|
else if(!audio) discimage.Disktype = MediaType.CDROM;
|
|
|
|
|
else discimage.Disktype = MediaType.CD;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
// DEBUG information
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Disc image parsing results");
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Disc CD-TEXT:");
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Arranger == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tArranger is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tArranger: {0}", discimage.Arranger);
|
|
|
|
|
if(discimage.Composer == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tComposer is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tComposer: {0}", discimage.Composer);
|
|
|
|
|
if(discimage.Genre == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tGenre is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tGenre: {0}", discimage.Genre);
|
|
|
|
|
if(discimage.Performer == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tPerformer is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tPerformer: {0}", discimage.Performer);
|
|
|
|
|
if(discimage.Songwriter == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tSongwriter is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tSongwriter: {0}", discimage.Songwriter);
|
|
|
|
|
if(discimage.Title == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tTitle is not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tTitle: {0}", discimage.Title);
|
|
|
|
|
if(discimage.Cdtextfile == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tCD-TEXT binary file not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tCD-TEXT binary file: {0}", discimage.Cdtextfile);
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Disc information:");
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Disktypestr == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tISOBuster disc type not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tISOBuster disc type: {0}", discimage.Disktypestr);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tGuessed disk type: {0}", discimage.Disktype);
|
|
|
|
|
if(discimage.Barcode == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tBarcode not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tBarcode: {0}", discimage.Barcode);
|
|
|
|
|
if(discimage.DiskId == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tDisc ID not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tDisc ID: {0}", discimage.DiskId);
|
|
|
|
|
if(discimage.Mcn == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tMCN not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tMCN: {0}", discimage.Mcn);
|
|
|
|
|
if(discimage.Comment == null) DicConsole.DebugWriteLine("CDRWin plugin", "\tComment not set.");
|
|
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\tComment: \"{0}\"", discimage.Comment);
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Session information:");
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tDisc contains {0} sessions", discimage.Sessions.Count);
|
|
|
|
|
for(int i = 0; i < discimage.Sessions.Count; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tSession {0} information:", i + 1);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tStarting track: {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Sessions[i].StartTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tStarting sector: {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Sessions[i].StartSector);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding track: {0}", discimage.Sessions[i].EndTrack);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tEnding sector: {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Sessions[i].EndSector);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Track information:");
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tDisc contains {0} tracks", discimage.Tracks.Count);
|
|
|
|
|
for(int i = 0; i < discimage.Tracks.Count; i++)
|
2015-10-18 22:04:03 +01:00
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tTrack {0} information:",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Tracks[i].Sequence);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\t{0} bytes per sector", discimage.Tracks[i].Bps);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tPregap: {0} sectors", discimage.Tracks[i].Pregap);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tData: {0} sectors", discimage.Tracks[i].Sectors);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tPostgap: {0} sectors", discimage.Tracks[i].Postgap);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].Flag4ch)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTrack is flagged as quadraphonic");
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].FlagDcp)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTrack allows digital copy");
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].FlagPre)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTrack has pre-emphasis applied");
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].FlagScms) DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTrack has SCMS");
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin",
|
|
|
|
|
"\t\tTrack resides in file {0}, type defined as {1}, starting at byte {2}",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Tracks[i].Trackfile.Datafilter.GetFilename(),
|
|
|
|
|
discimage.Tracks[i].Trackfile.Filetype,
|
|
|
|
|
discimage.Tracks[i].Trackfile.Offset);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tIndexes:");
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(KeyValuePair<int, ulong> kvp in discimage.Tracks[i].Indexes)
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\t\tIndex {0} starts at sector {1}", kvp.Key,
|
|
|
|
|
kvp.Value);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].Isrc == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tISRC is not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\t\tISRC: {0}", discimage.Tracks[i].Isrc);
|
2015-10-18 22:04:03 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].Arranger == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tArranger is not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\t\tArranger: {0}", discimage.Tracks[i].Arranger);
|
|
|
|
|
if(discimage.Tracks[i].Composer == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tComposer is not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\t\tComposer: {0}", discimage.Tracks[i].Composer);
|
|
|
|
|
if(discimage.Tracks[i].Genre == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tGenre is not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\t\tGenre: {0}", discimage.Tracks[i].Genre);
|
|
|
|
|
if(discimage.Tracks[i].Performer == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tPerformer is not set.");
|
2014-04-14 01:31:32 +00:00
|
|
|
else
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tPerformer: {0}", discimage.Tracks[i].Performer);
|
|
|
|
|
if(discimage.Tracks[i].Songwriter == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tSongwriter is not set.");
|
2014-04-14 01:31:32 +00:00
|
|
|
else
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tSongwriter: {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
discimage.Tracks[i].Songwriter);
|
|
|
|
|
if(discimage.Tracks[i].Title == null)
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTitle is not set.");
|
2017-12-20 17:15:26 +00:00
|
|
|
else DicConsole.DebugWriteLine("CDRWin plugin", "\t\tTitle: {0}", discimage.Tracks[i].Title);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Building offset map");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
partitions = new List<Partition>();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong byteOffset = 0;
|
|
|
|
|
ulong sectorOffset = 0;
|
2014-04-14 01:14:20 +00:00
|
|
|
ulong partitionSequence = 0;
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong indexZeroOffset = 0;
|
|
|
|
|
ulong indexOneOffset = 0;
|
|
|
|
|
bool indexZero = false;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
offsetmap = new Dictionary<uint, ulong>();
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
for(int i = 0; i < discimage.Tracks.Count; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong index0Len = 0;
|
2015-11-09 19:42:00 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Tracks[i].Sequence == 1 && i != 0)
|
2014-04-14 01:14:20 +00:00
|
|
|
throw new ImageNotSupportedException("Unordered tracks");
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
Partition partition = new Partition();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-08-08 18:44:08 +01:00
|
|
|
/*if(discimage.tracks[i].pregap > 0)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
partition.PartitionDescription = string.Format("Track {0} pregap.", discimage.tracks[i].sequence);
|
2014-04-14 01:14:20 +00:00
|
|
|
partition.PartitionName = discimage.tracks[i].title;
|
|
|
|
|
partition.PartitionStartSector = sector_offset;
|
|
|
|
|
partition.PartitionLength = discimage.tracks[i].pregap * discimage.tracks[i].bps;
|
|
|
|
|
partition.PartitionSectors = discimage.tracks[i].pregap;
|
|
|
|
|
partition.PartitionSequence = partitionSequence;
|
|
|
|
|
partition.PartitionStart = byte_offset;
|
|
|
|
|
partition.PartitionType = discimage.tracks[i].tracktype;
|
|
|
|
|
|
|
|
|
|
sector_offset += partition.PartitionSectors;
|
|
|
|
|
byte_offset += partition.PartitionLength;
|
|
|
|
|
partitionSequence++;
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!offsetmap.ContainsKey(discimage.tracks[i].sequence))
|
2014-04-14 01:14:20 +00:00
|
|
|
offsetmap.Add(discimage.tracks[i].sequence, partition.PartitionStartSector);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ulong old_start;
|
|
|
|
|
offsetmap.TryGetValue(discimage.tracks[i].sequence, out old_start);
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(partition.PartitionStartSector < old_start)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
|
|
|
|
offsetmap.Remove(discimage.tracks[i].sequence);
|
|
|
|
|
offsetmap.Add(discimage.tracks[i].sequence, partition.PartitionStartSector);
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
partitions.Add(partition);
|
2016-07-28 22:25:26 +01:00
|
|
|
partition = new Partition();
|
2016-08-08 18:44:08 +01:00
|
|
|
}*/
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
indexZero |= discimage.Tracks[i].Indexes.TryGetValue(0, out indexZeroOffset);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!discimage.Tracks[i].Indexes.TryGetValue(1, out indexOneOffset))
|
2017-12-21 17:58:51 +00:00
|
|
|
throw new ImageNotSupportedException($"Track {discimage.Tracks[i].Sequence} lacks index 01");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-08-08 18:44:08 +01:00
|
|
|
/*if(index_zero && index_one_offset > index_zero_offset)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
partition.PartitionDescription = string.Format("Track {0} index 00.", discimage.tracks[i].sequence);
|
2014-04-14 01:14:20 +00:00
|
|
|
partition.PartitionName = discimage.tracks[i].title;
|
|
|
|
|
partition.PartitionStartSector = sector_offset;
|
|
|
|
|
partition.PartitionLength = (index_one_offset - index_zero_offset) * discimage.tracks[i].bps;
|
|
|
|
|
partition.PartitionSectors = index_one_offset - index_zero_offset;
|
|
|
|
|
partition.PartitionSequence = partitionSequence;
|
|
|
|
|
partition.PartitionStart = byte_offset;
|
|
|
|
|
partition.PartitionType = discimage.tracks[i].tracktype;
|
|
|
|
|
|
|
|
|
|
sector_offset += partition.PartitionSectors;
|
|
|
|
|
byte_offset += partition.PartitionLength;
|
2015-11-09 19:42:00 +00:00
|
|
|
index0_len = partition.PartitionSectors;
|
2014-04-14 01:14:20 +00:00
|
|
|
partitionSequence++;
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(!offsetmap.ContainsKey(discimage.tracks[i].sequence))
|
2014-04-14 01:14:20 +00:00
|
|
|
offsetmap.Add(discimage.tracks[i].sequence, partition.PartitionStartSector);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ulong old_start;
|
|
|
|
|
offsetmap.TryGetValue(discimage.tracks[i].sequence, out old_start);
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
if(partition.PartitionStartSector < old_start)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
|
|
|
|
offsetmap.Remove(discimage.tracks[i].sequence);
|
|
|
|
|
offsetmap.Add(discimage.tracks[i].sequence, partition.PartitionStartSector);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partitions.Add(partition);
|
2016-07-28 22:25:26 +01:00
|
|
|
partition = new Partition();
|
2016-08-08 18:44:08 +01:00
|
|
|
}*/
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
// Index 01
|
2017-12-21 17:58:51 +00:00
|
|
|
partition.Description = $"Track {discimage.Tracks[i].Sequence}.";
|
2017-12-20 17:15:26 +00:00
|
|
|
partition.Name = discimage.Tracks[i].Title;
|
|
|
|
|
partition.Start = sectorOffset;
|
|
|
|
|
partition.Size = (discimage.Tracks[i].Sectors - index0Len) * discimage.Tracks[i].Bps;
|
2017-12-20 17:26:28 +00:00
|
|
|
partition.Length = discimage.Tracks[i].Sectors - index0Len;
|
2017-07-19 16:37:11 +01:00
|
|
|
partition.Sequence = partitionSequence;
|
2017-12-20 17:15:26 +00:00
|
|
|
partition.Offset = byteOffset;
|
|
|
|
|
partition.Type = discimage.Tracks[i].Tracktype;
|
2017-07-19 16:37:11 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset += partition.Length;
|
|
|
|
|
byteOffset += partition.Size;
|
2014-04-14 01:14:20 +00:00
|
|
|
partitionSequence++;
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!offsetmap.ContainsKey(discimage.Tracks[i].Sequence))
|
|
|
|
|
offsetmap.Add(discimage.Tracks[i].Sequence, partition.Start);
|
2014-04-14 01:14:20 +00:00
|
|
|
else
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
offsetmap.TryGetValue(discimage.Tracks[i].Sequence, out ulong oldStart);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(partition.Start < oldStart)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
offsetmap.Remove(discimage.Tracks[i].Sequence);
|
|
|
|
|
offsetmap.Add(discimage.Tracks[i].Sequence, partition.Start);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partitions.Add(partition);
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-14 01:31:32 +00:00
|
|
|
// Print offset map
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "printing partition map");
|
2016-07-28 22:25:26 +01:00
|
|
|
foreach(Partition partition in partitions)
|
2014-04-14 01:31:32 +00:00
|
|
|
{
|
2017-07-19 16:37:11 +01:00
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "Partition sequence: {0}", partition.Sequence);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition name: {0}", partition.Name);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition description: {0}", partition.Description);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition type: {0}", partition.Type);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition starting sector: {0}", partition.Start);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition sectors: {0}", partition.Length);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition starting offset: {0}", partition.Offset);
|
|
|
|
|
DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition size in bytes: {0}", partition.Size);
|
2014-04-14 01:31:32 +00:00
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(CdrWinTrack track in discimage.Tracks) ImageInfo.ImageSize += track.Bps * track.Sectors;
|
|
|
|
|
foreach(CdrWinTrack track in discimage.Tracks) ImageInfo.Sectors += track.Sectors;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Disktype == MediaType.CDG || discimage.Disktype == MediaType.CDEG ||
|
|
|
|
|
discimage.Disktype == MediaType.CDMIDI)
|
|
|
|
|
ImageInfo.SectorSize = 2448; // CD+G subchannels ARE user data, as CD+G are useless without them
|
|
|
|
|
else if(discimage.Disktype != MediaType.CDROMXA && discimage.Disktype != MediaType.CDDA &&
|
|
|
|
|
discimage.Disktype != MediaType.CDI &&
|
|
|
|
|
discimage.Disktype != MediaType.CDPLUS) ImageInfo.SectorSize = 2048; // Only data tracks
|
|
|
|
|
else ImageInfo.SectorSize = 2352; // All others
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Mcn != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN);
|
|
|
|
|
if(discimage.Cdtextfile != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT);
|
2014-08-24 17:46:29 +01:00
|
|
|
|
|
|
|
|
// Detect ISOBuster extensions
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Disktypestr != null || discimage.Comment.ToLower().Contains("isobuster") ||
|
2017-12-26 02:51:10 +00:00
|
|
|
discimage.Sessions.Count > 1) ImageInfo.Application = "ISOBuster";
|
|
|
|
|
else ImageInfo.Application = "CDRWin";
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-26 02:51:10 +00:00
|
|
|
ImageInfo.CreationTime = imageFilter.GetCreationTime();
|
|
|
|
|
ImageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-26 02:51:10 +00:00
|
|
|
ImageInfo.Comments = discimage.Comment;
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.MediaSerialNumber = discimage.Mcn;
|
|
|
|
|
ImageInfo.MediaBarcode = discimage.Barcode;
|
|
|
|
|
ImageInfo.MediaType = discimage.Disktype;
|
2014-08-24 17:46:29 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags);
|
2015-12-23 23:46:31 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(CdrWinTrack track in discimage.Tracks)
|
|
|
|
|
switch(track.Tracktype)
|
2014-08-24 17:46:29 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDG:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
|
|
|
|
|
if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
|
|
|
|
ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-08-24 17:46:29 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
ImageInfo.XmlMediaType = XmlMediaType.OpticalDisc;
|
2015-12-05 17:21:47 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
DicConsole.VerboseWriteLine("CDRWIN image describes a disc of type {0}", ImageInfo.MediaType);
|
2017-12-26 02:51:10 +00:00
|
|
|
if(!string.IsNullOrEmpty(ImageInfo.Comments))
|
|
|
|
|
DicConsole.VerboseWriteLine("CDRWIN comments: {0}", ImageInfo.Comments);
|
2016-08-21 17:35:35 +01:00
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
return true;
|
2013-12-16 01:04:17 +00:00
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
catch(Exception ex)
|
2013-12-16 01:04:17 +00:00
|
|
|
{
|
2016-09-05 21:22:04 +01:00
|
|
|
DicConsole.ErrorWriteLine("Exception trying to identify image file {0}", imageFilter.GetFilename());
|
2015-10-18 22:04:03 +01:00
|
|
|
DicConsole.ErrorWriteLine("Exception: {0}", ex.Message);
|
|
|
|
|
DicConsole.ErrorWriteLine("Stack trace: {0}", ex.StackTrace);
|
2013-12-16 01:04:17 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
2013-12-16 01:04:17 +00:00
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override byte[] ReadDiskTag(MediaTagType tag)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(tag)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-01-16 03:54:55 +00:00
|
|
|
case MediaTagType.CD_MCN:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 23:07:46 +00:00
|
|
|
if(discimage.Mcn != null) return Encoding.ASCII.GetBytes(discimage.Mcn);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
throw new FeatureNotPresentImageException("Image does not contain MCN information.");
|
|
|
|
|
}
|
2016-01-16 03:54:55 +00:00
|
|
|
case MediaTagType.CD_TEXT:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(discimage.Cdtextfile != null)
|
2017-12-19 20:33:03 +00:00
|
|
|
// TODO: Check that binary text file exists, open it, read it, send it to caller.
|
|
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
|
|
|
|
|
|
|
|
|
throw new FeatureNotPresentImageException("Image does not contain CD-TEXT information.");
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
default:
|
|
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSector(ulong sectorAddress)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectors(sectorAddress, 1);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectorsTag(sectorAddress, 1, tag);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSector(ulong sectorAddress, uint track)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectors(sectorAddress, 1, track);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectorsTag(sectorAddress, 1, track, tag);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectors(ulong sectorAddress, uint length)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from cdrwinTrack in discimage.Tracks
|
|
|
|
|
where cdrwinTrack.Sequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value < cdrwinTrack.Sectors
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from cdrwinTrack in discimage.Tracks
|
|
|
|
|
where cdrwinTrack.Sequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value < cdrwinTrack.Sectors
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
CdrWinTrack dicTrack = new CdrWinTrack {Sequence = 0};
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(CdrWinTrack cdrwinTrack in discimage.Tracks.Where(cdrwinTrack => cdrwinTrack.Sequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = cdrwinTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.Sequence == 0)
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
|
|
|
|
"Requested more sectors than present in track, won't cross tracks");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.Tracktype)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2324;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 288;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 16;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDG:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 96;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.Trackfile.Datafilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
CdrWinTrack dicTrack = new CdrWinTrack {Sequence = 0};
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(CdrWinTrack cdrwinTrack in discimage.Tracks.Where(cdrwinTrack => cdrwinTrack.Sequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = cdrwinTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.Sequence == 0)
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
|
|
|
|
"Requested more sectors than present in track, won't cross tracks");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(tag)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
|
|
|
|
case SectorTagType.CdSectorEdc:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
|
|
|
|
case SectorTagType.CdSectorSync: break;
|
|
|
|
|
case SectorTagType.CdTrackFlags:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
byte[] flags = new byte[1];
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.Tracktype != CDRWIN_TRACK_TYPE_AUDIO && dicTrack.Tracktype != CDRWIN_TRACK_TYPE_CDG)
|
2017-12-19 20:33:03 +00:00
|
|
|
flags[0] += 0x40;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.FlagDcp) flags[0] += 0x20;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.FlagPre) flags[0] += 0x10;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.Flag4ch) flags[0] += 0x80;
|
2015-12-23 23:46:31 +00:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
return flags;
|
|
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
case SectorTagType.CdTrackIsrc: return Encoding.UTF8.GetBytes(dicTrack.Isrc);
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdTrackText:
|
2014-04-14 01:14:20 +00:00
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
2017-12-19 20:33:03 +00:00
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.Tracktype)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2:
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentException("No tags in image for requested track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
|
|
|
|
case SectorTagType.CdSectorHeader:
|
|
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorEcc:
|
|
|
|
|
case SectorTagType.CdSectorEccP:
|
|
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 8;
|
|
|
|
|
sectorSkip = 2328;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2332;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
|
|
|
|
switch(tag)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSync:
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 12;
|
|
|
|
|
sectorSkip = 2340;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 12;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 2336;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorSubchannel:
|
|
|
|
|
case SectorTagType.CdSectorSubHeader:
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEcc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 276;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccP:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2076;
|
|
|
|
|
sectorSize = 172;
|
|
|
|
|
sectorSkip = 104;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEccQ:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2248;
|
|
|
|
|
sectorSize = 104;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case SectorTagType.CdSectorEdc:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2064;
|
|
|
|
|
sectorSize = 4;
|
|
|
|
|
sectorSkip = 284;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new ArgumentException("Unsupported tag requested", nameof(tag));
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW: // Requires reading sector
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
2014-04-14 01:14:20 +00:00
|
|
|
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDG:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
if(tag != SectorTagType.CdSectorSubchannel)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 2352;
|
|
|
|
|
sectorSize = 96;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.Trackfile.Datafilter.GetDataForkStream();
|
2016-09-05 17:37:31 +01:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2016-09-05 17:37:31 +01:00
|
|
|
else
|
|
|
|
|
for(int i = 0; i < length; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
|
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorLong(ulong sectorAddress)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectorsLong(sectorAddress, 1);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
return ReadSectorsLong(sectorAddress, 1, track);
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap
|
|
|
|
|
where sectorAddress >= kvp.Value
|
|
|
|
|
from cdrwinTrack in discimage.Tracks
|
|
|
|
|
where cdrwinTrack.Sequence == kvp.Key
|
|
|
|
|
where sectorAddress - kvp.Value < cdrwinTrack.Sectors
|
|
|
|
|
select kvp)
|
|
|
|
|
return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
CdrWinTrack dicTrack = new CdrWinTrack {Sequence = 0};
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
foreach(CdrWinTrack cdrwinTrack in discimage.Tracks.Where(cdrwinTrack => cdrwinTrack.Sequence == track))
|
|
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack = cdrwinTrack;
|
2017-12-21 07:08:26 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(dicTrack.Sequence == 0)
|
2016-07-28 22:25:26 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(length > dicTrack.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
|
|
|
|
"Requested more sectors than present in track, won't cross tracks");
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
uint sectorOffset;
|
|
|
|
|
uint sectorSize;
|
|
|
|
|
uint sectorSkip;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
switch(dicTrack.Tracktype)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2048;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2324;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2336;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2352;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_CDG:
|
2017-12-19 20:33:03 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorOffset = 0;
|
|
|
|
|
sectorSize = 2448;
|
|
|
|
|
sectorSkip = 0;
|
2017-12-19 20:33:03 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type");
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] buffer = new byte[sectorSize * length];
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
imageStream = dicTrack.Trackfile.Datafilter.GetDataForkStream();
|
2014-04-14 02:29:13 +00:00
|
|
|
BinaryReader br = new BinaryReader(imageStream);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
br.BaseStream
|
2017-12-22 06:55:04 +00:00
|
|
|
.Seek((long)dicTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)),
|
2017-12-19 20:33:03 +00:00
|
|
|
SeekOrigin.Begin);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length));
|
2014-04-14 01:14:20 +00:00
|
|
|
else
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorOffset, SeekOrigin.Current);
|
2017-12-22 06:55:04 +00:00
|
|
|
byte[] sector = br.ReadBytes((int)sectorSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
br.BaseStream.Seek(sectorSkip, SeekOrigin.Current);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer;
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
public override List<Track> GetSessionTracks(Session session)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2017-12-20 23:07:46 +00:00
|
|
|
if(discimage.Sessions.Contains(session)) return GetSessionTracks(session.SessionSequence);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
throw new ImageNotSupportedException("Session does not exist in disc image");
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override List<Track> GetSessionTracks(ushort session)
|
2013-12-14 23:02:04 +00:00
|
|
|
{
|
2014-04-14 01:14:20 +00:00
|
|
|
List<Track> tracks = new List<Track>();
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(CdrWinTrack cdrTrack in discimage.Tracks)
|
|
|
|
|
if(cdrTrack.Session == session)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
Track dicTrack = new Track
|
|
|
|
|
{
|
|
|
|
|
Indexes = cdrTrack.Indexes,
|
|
|
|
|
TrackDescription = cdrTrack.Title,
|
|
|
|
|
TrackPregap = cdrTrack.Pregap,
|
|
|
|
|
TrackSession = cdrTrack.Session,
|
|
|
|
|
TrackSequence = cdrTrack.Sequence,
|
|
|
|
|
TrackType = CdrWinTrackTypeToTrackType(cdrTrack.Tracktype),
|
|
|
|
|
TrackFile = cdrTrack.Trackfile.Datafilter.GetFilename(),
|
|
|
|
|
TrackFilter = cdrTrack.Trackfile.Datafilter,
|
|
|
|
|
TrackFileOffset = cdrTrack.Trackfile.Offset,
|
|
|
|
|
TrackFileType = cdrTrack.Trackfile.Filetype,
|
|
|
|
|
TrackRawBytesPerSector = cdrTrack.Bps,
|
|
|
|
|
TrackBytesPerSector = CdrWinTrackTypeToCookedBytesPerSector(cdrTrack.Tracktype)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(!cdrTrack.Indexes.TryGetValue(0, out dicTrack.TrackStartSector))
|
|
|
|
|
cdrTrack.Indexes.TryGetValue(1, out dicTrack.TrackStartSector);
|
|
|
|
|
dicTrack.TrackEndSector = dicTrack.TrackStartSector + cdrTrack.Sectors - 1;
|
2017-12-20 17:15:26 +00:00
|
|
|
if(cdrTrack.Bps == 2448)
|
2015-12-06 05:09:31 +00:00
|
|
|
{
|
2017-12-22 06:55:04 +00:00
|
|
|
dicTrack.TrackSubchannelFilter = cdrTrack.Trackfile.Datafilter;
|
|
|
|
|
dicTrack.TrackSubchannelFile = cdrTrack.Trackfile.Datafilter.GetFilename();
|
|
|
|
|
dicTrack.TrackSubchannelOffset = cdrTrack.Trackfile.Offset;
|
|
|
|
|
dicTrack.TrackSubchannelType = TrackSubchannelType.RawInterleaved;
|
2015-12-06 05:09:31 +00:00
|
|
|
}
|
2017-12-22 06:55:04 +00:00
|
|
|
else dicTrack.TrackSubchannelType = TrackSubchannelType.None;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
tracks.Add(dicTrack);
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tracks;
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override bool? VerifySector(ulong sectorAddress)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 22:25:26 +01:00
|
|
|
public override bool? VerifySector(ulong sectorAddress, uint track)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorLong(sectorAddress, track);
|
2017-12-21 14:30:38 +00:00
|
|
|
return CdChecksums.CheckCdSector(buffer);
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(sectorStatus)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
return failingLbas.Count <= 0;
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
|
|
|
|
|
int bps = (int)(buffer.Length / length);
|
|
|
|
|
byte[] sector = new byte[bps];
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
for(int i = 0; i < length; i++)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
Array.Copy(buffer, i * bps, sector, 0, bps);
|
2017-12-21 14:30:38 +00:00
|
|
|
bool? sectorStatus = CdChecksums.CheckCdSector(sector);
|
2014-08-25 05:00:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(sectorStatus)
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
case null:
|
2017-12-20 17:15:26 +00:00
|
|
|
unknownLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
case false:
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas.Add((ulong)i + sectorAddress);
|
2014-08-25 05:00:25 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(unknownLbas.Count > 0) return null;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
return failingLbas.Count <= 0;
|
2014-08-25 05:00:25 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-16 03:54:55 +00:00
|
|
|
public override bool? VerifyMediaImage()
|
2014-08-25 05:00:25 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static ulong CdrWinMsftoLba(string msf)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
ulong minute, second, frame, sectors;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
string[] msfElements = msf.Split(':');
|
2017-12-20 17:15:26 +00:00
|
|
|
minute = ulong.Parse(msfElements[0]);
|
|
|
|
|
second = ulong.Parse(msfElements[1]);
|
|
|
|
|
frame = ulong.Parse(msfElements[2]);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
sectors = minute * 60 * 75 + second * 75 + frame;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
|
|
|
return sectors;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static ushort CdrWinTrackTypeToBytesPerSector(string trackType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(trackType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1: return 2048;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2: return 2324;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI: return 2336;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW: return 2352;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDG: return 2448;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return 0;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static ushort CdrWinTrackTypeToCookedBytesPerSector(string trackType)
|
2015-12-06 05:09:31 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(trackType)
|
2015-12-06 05:09:31 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW: return 2048;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2: return 2324;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW: return 2336;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO: return 2352;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDG: return 2448;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return 0;
|
2015-12-06 05:09:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static TrackType CdrWinTrackTypeToTrackType(string trackType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(trackType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_TRACK_TYPE_MODE1:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE1_RAW: return TrackType.CdMode1;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM1: return TrackType.CdMode2Form1;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORM2: return TrackType.CdMode2Form2;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDI:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_RAW:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_MODE2_FORMLESS: return TrackType.CdMode2Formless;
|
|
|
|
|
case CDRWIN_TRACK_TYPE_AUDIO:
|
|
|
|
|
case CDRWIN_TRACK_TYPE_CDG: return TrackType.Audio;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return TrackType.Data;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
static MediaType CdrWinIsoBusterDiscTypeToMediaType(string discType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
switch(discType)
|
2014-04-14 01:14:20 +00:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
case CDRWIN_DISK_TYPE_CD: return MediaType.CD;
|
|
|
|
|
case CDRWIN_DISK_TYPE_CDRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_CDMRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_CDMRW2: return MediaType.CDRW;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVD: return MediaType.DVDROM;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPMRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPMRW2: return MediaType.DVDPRW;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPRWDL:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPMRWDL:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPMRWDL2: return MediaType.DVDPRWDL;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPR:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPVR: return MediaType.DVDPR;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDPRDL: return MediaType.DVDPRDL;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDRAM: return MediaType.DVDRAM;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDVR:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDR: return MediaType.DVDR;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDRDL: return MediaType.DVDRDL;
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDRWDL:
|
|
|
|
|
case CDRWIN_DISK_TYPE_DVDRW2: return MediaType.DVDRW;
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVD: return MediaType.HDDVDROM;
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVDRAM: return MediaType.HDDVDRAM;
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVDR:
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVDRDL: return MediaType.HDDVDR;
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVDRW:
|
|
|
|
|
case CDRWIN_DISK_TYPE_HDDVDRWDL: return MediaType.HDDVDRW;
|
|
|
|
|
case CDRWIN_DISK_TYPE_BD: return MediaType.BDROM;
|
|
|
|
|
case CDRWIN_DISK_TYPE_BDR:
|
|
|
|
|
case CDRWIN_DISK_TYPE_BDRDL: return MediaType.BDR;
|
|
|
|
|
case CDRWIN_DISK_TYPE_BDRE:
|
|
|
|
|
case CDRWIN_DISK_TYPE_BDREDL: return MediaType.BDRE;
|
2017-12-19 20:33:03 +00:00
|
|
|
default: return MediaType.Unknown;
|
2014-04-14 01:14:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
struct CdrWinTrackFile
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Track #</summary>
|
|
|
|
|
public uint Sequence;
|
|
|
|
|
/// <summary>Filter of file containing track</summary>
|
|
|
|
|
public Filter Datafilter;
|
|
|
|
|
/// <summary>Offset of track start in file</summary>
|
|
|
|
|
public ulong Offset;
|
|
|
|
|
/// <summary>Type of file</summary>
|
|
|
|
|
public string Filetype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CdrWinTrack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Track #</summary>
|
|
|
|
|
public uint Sequence;
|
|
|
|
|
/// <summary>Track title (from CD-Text)</summary>
|
|
|
|
|
public string Title;
|
|
|
|
|
/// <summary>Track genre (from CD-Text)</summary>
|
|
|
|
|
public string Genre;
|
|
|
|
|
/// <summary>Track arranger (from CD-Text)</summary>
|
|
|
|
|
public string Arranger;
|
|
|
|
|
/// <summary>Track composer (from CD-Text)</summary>
|
|
|
|
|
public string Composer;
|
|
|
|
|
/// <summary>Track performer (from CD-Text)</summary>
|
|
|
|
|
public string Performer;
|
|
|
|
|
/// <summary>Track song writer (from CD-Text)</summary>
|
|
|
|
|
public string Songwriter;
|
|
|
|
|
/// <summary>Track ISRC</summary>
|
|
|
|
|
public string Isrc;
|
|
|
|
|
/// <summary>File struct for this track</summary>
|
|
|
|
|
public CdrWinTrackFile Trackfile;
|
|
|
|
|
/// <summary>Indexes on this track</summary>
|
|
|
|
|
public Dictionary<int, ulong> Indexes;
|
|
|
|
|
/// <summary>Track pre-gap in sectors</summary>
|
|
|
|
|
public ulong Pregap;
|
|
|
|
|
/// <summary>Track post-gap in sectors</summary>
|
|
|
|
|
public ulong Postgap;
|
|
|
|
|
/// <summary>Digical Copy Permitted</summary>
|
|
|
|
|
public bool FlagDcp;
|
|
|
|
|
/// <summary>Track is quadraphonic</summary>
|
|
|
|
|
public bool Flag4ch;
|
|
|
|
|
/// <summary>Track has preemphasis</summary>
|
|
|
|
|
public bool FlagPre;
|
|
|
|
|
/// <summary>Track has SCMS</summary>
|
|
|
|
|
public bool FlagScms;
|
|
|
|
|
/// <summary>Bytes per sector</summary>
|
|
|
|
|
public ushort Bps;
|
|
|
|
|
/// <summary>Sectors in track</summary>
|
|
|
|
|
public ulong Sectors;
|
|
|
|
|
/// <summary>Track type</summary>
|
|
|
|
|
public string Tracktype;
|
|
|
|
|
/// <summary>Track session</summary>
|
|
|
|
|
public ushort Session;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CdrWinDisc
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Disk title (from CD-Text)</summary>
|
|
|
|
|
public string Title;
|
|
|
|
|
/// <summary>Disk genre (from CD-Text)</summary>
|
|
|
|
|
public string Genre;
|
|
|
|
|
/// <summary>Disk arranger (from CD-Text)</summary>
|
|
|
|
|
public string Arranger;
|
|
|
|
|
/// <summary>Disk composer (from CD-Text)</summary>
|
|
|
|
|
public string Composer;
|
|
|
|
|
/// <summary>Disk performer (from CD-Text)</summary>
|
|
|
|
|
public string Performer;
|
|
|
|
|
/// <summary>Disk song writer (from CD-Text)</summary>
|
|
|
|
|
public string Songwriter;
|
|
|
|
|
/// <summary>Media catalog number</summary>
|
|
|
|
|
public string Mcn;
|
|
|
|
|
/// <summary>Disk type</summary>
|
|
|
|
|
public MediaType Disktype;
|
|
|
|
|
/// <summary>Disk type string</summary>
|
|
|
|
|
public string Disktypestr;
|
|
|
|
|
/// <summary>Disk CDDB ID</summary>
|
|
|
|
|
public string DiskId;
|
|
|
|
|
/// <summary>Disk UPC/EAN</summary>
|
|
|
|
|
public string Barcode;
|
|
|
|
|
/// <summary>Sessions</summary>
|
|
|
|
|
public List<Session> Sessions;
|
|
|
|
|
/// <summary>Tracks</summary>
|
|
|
|
|
public List<CdrWinTrack> Tracks;
|
|
|
|
|
/// <summary>Disk comment</summary>
|
|
|
|
|
public string Comment;
|
|
|
|
|
/// <summary>File containing CD-Text</summary>
|
|
|
|
|
public string Cdtextfile;
|
|
|
|
|
}
|
2013-12-14 23:02:04 +00:00
|
|
|
}
|
2016-09-05 17:37:31 +01:00
|
|
|
}
|