Refactor image classes and split them to smaller files.

This commit is contained in:
2018-07-23 23:25:43 +01:00
parent 55ca2d23b6
commit ed88989642
445 changed files with 50086 additions and 34342 deletions

View File

@@ -0,0 +1,90 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : BlindWrite5.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disc image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Manages BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System.Collections.Generic;
using System.IO;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
namespace DiscImageChef.DiscImages
{
// TODO: Too many unknowns to make this writable
public partial class BlindWrite5 : IMediaImage
{
byte[] atip;
byte[] bca;
List<Bw5SessionDescriptor> bwSessions;
byte[] cdtext;
List<Bw5DataFile> dataFiles;
string dataPath;
byte[] discInformation;
byte[] dmi;
byte[] dpm;
List<DataFileCharacteristics> filePaths;
byte[] fullToc;
Bw5Header header;
ImageInfo imageInfo;
Stream imageStream;
byte[] mode2A;
Dictionary<uint, ulong> offsetmap;
byte[] pfi;
byte[] pma;
Dictionary<uint, byte> trackFlags;
byte[] unkBlock;
public BlindWrite5()
{
imageInfo = new ImageInfo
{
ReadableSectorTags = new List<SectorTagType>(),
ReadableMediaTags = new List<MediaTagType>(),
HasPartitions = true,
HasSessions = true,
Version = null,
ApplicationVersion = null,
MediaTitle = null,
Creator = null,
MediaManufacturer = null,
MediaModel = null,
MediaPartNumber = null,
MediaSequence = 0,
LastMediaSequence = 0,
DriveManufacturer = null,
DriveModel = null,
DriveSerialNumber = null,
DriveFirmwareRevision = null
};
}
}
}

View File

@@ -0,0 +1,44 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Constants.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains constants for BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
/// <summary>"BWT5 STREAM FOOT"</summary>
readonly byte[] bw5Footer =
{0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x46, 0x4F, 0x4F, 0x54};
/// <summary>"BWT5 STREAM SIGN"</summary>
readonly byte[] bw5Signature =
{0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x53, 0x49, 0x47, 0x4E};
}
}

View File

@@ -0,0 +1,55 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Enums.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains enumerations for BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
enum Bw5TrackType : byte
{
NotData = 0,
Audio = 1,
Mode1 = 2,
Mode2 = 3,
Mode2F1 = 4,
Mode2F2 = 5,
Dvd = 6
}
enum Bw5TrackSubchannel : byte
{
None = 0,
Q16 = 2,
Linear = 4
}
}
}

View File

@@ -0,0 +1,97 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Helpers.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains helpers for BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.Decoders.SCSI.MMC;
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
static TrackType BlindWriteTrackTypeToTrackType(Bw5TrackType trackType)
{
switch(trackType)
{
case Bw5TrackType.Mode1: return TrackType.CdMode1;
case Bw5TrackType.Mode2F1: return TrackType.CdMode2Form1;
case Bw5TrackType.Mode2F2: return TrackType.CdMode2Form2;
case Bw5TrackType.Mode2: return TrackType.CdMode2Formless;
case Bw5TrackType.Audio: return TrackType.Audio;
default: return TrackType.Data;
}
}
static MediaType BlindWriteProfileToMediaType(ProfileNumber profile)
{
switch(profile)
{
case ProfileNumber.BDRE: return MediaType.BDRE;
case ProfileNumber.BDROM: return MediaType.BDROM;
case ProfileNumber.BDRRdm:
case ProfileNumber.BDRSeq: return MediaType.BDR;
case ProfileNumber.CDR:
case ProfileNumber.HDBURNR: return MediaType.CDR;
case ProfileNumber.CDROM:
case ProfileNumber.HDBURNROM: return MediaType.CDROM;
case ProfileNumber.CDRW:
case ProfileNumber.HDBURNRW: return MediaType.CDRW;
case ProfileNumber.DDCDR: return MediaType.DDCDR;
case ProfileNumber.DDCDROM: return MediaType.DDCD;
case ProfileNumber.DDCDRW: return MediaType.DDCDRW;
case ProfileNumber.DVDDownload: return MediaType.DVDDownload;
case ProfileNumber.DVDRAM: return MediaType.DVDRAM;
case ProfileNumber.DVDRDLJump:
case ProfileNumber.DVDRDLSeq: return MediaType.DVDRDL;
case ProfileNumber.DVDRDLPlus: return MediaType.DVDPRDL;
case ProfileNumber.DVDROM: return MediaType.DVDROM;
case ProfileNumber.DVDRPlus: return MediaType.DVDPR;
case ProfileNumber.DVDRSeq: return MediaType.DVDR;
case ProfileNumber.DVDRWDL: return MediaType.DVDRWDL;
case ProfileNumber.DVDRWDLPlus: return MediaType.DVDPRWDL;
case ProfileNumber.DVDRWPlus: return MediaType.DVDPRW;
case ProfileNumber.DVDRWRes:
case ProfileNumber.DVDRWSeq: return MediaType.DVDRW;
case ProfileNumber.HDDVDR: return MediaType.HDDVDR;
case ProfileNumber.HDDVDRAM: return MediaType.HDDVDRAM;
case ProfileNumber.HDDVDRDL: return MediaType.HDDVDRDL;
case ProfileNumber.HDDVDROM: return MediaType.HDDVDROM;
case ProfileNumber.HDDVDRW: return MediaType.HDDVDRW;
case ProfileNumber.HDDVDRWDL: return MediaType.HDDVDRWDL;
case ProfileNumber.ASMO:
case ProfileNumber.MOErasable: return MediaType.UnknownMO;
case ProfileNumber.NonRemovable: return MediaType.GENERIC_HDD;
default: return MediaType.CD;
}
}
}
}

View File

@@ -0,0 +1,57 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Identify.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System.IO;
using System.Linq;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
public bool Identify(IFilter imageFilter)
{
Stream stream = imageFilter.GetDataForkStream();
stream.Seek(0, SeekOrigin.Begin);
if(stream.Length < 276) return false;
byte[] signature = new byte[16];
stream.Read(signature, 0, 16);
byte[] footer = new byte[16];
stream.Seek(-16, SeekOrigin.End);
stream.Read(footer, 0, 16);
return bw5Signature.SequenceEqual(signature) && bw5Footer.SequenceEqual(footer);
}
}
}

View File

@@ -0,0 +1,59 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Properties.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains properties for BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Structs;
using Schemas;
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
public ImageInfo Info => imageInfo;
public string Name => "BlindWrite 5";
public Guid Id => new Guid("9CB7A381-0509-4F9F-B801-3F65434BC3EE");
public string Format => "BlindWrite 5 TOC file";
public List<Partition> Partitions { get; private set; }
public List<Track> Tracks { get; private set; }
public List<Session> Sessions { get; private set; }
public List<DumpHardwareType> DumpHardware => null;
public CICMMetadataType CicmMetadata => null;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,166 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains structures for BlindWrite 5 disc images.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System.Runtime.InteropServices;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Decoders.SCSI.MMC;
namespace DiscImageChef.DiscImages
{
public partial class BlindWrite5
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Bw5Header
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] signature;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public uint[] unknown1;
public ProfileNumber profile;
public ushort sessions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] unknown2;
[MarshalAs(UnmanagedType.U1, SizeConst = 3)]
public bool mcnIsValid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
public byte[] mcn;
public ushort unknown3;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] unknown4;
public ushort pmaLen;
public ushort atipLen;
public ushort cdtLen;
public ushort cdInfoLen;
public uint bcaLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] unknown5;
public uint dvdStrLen;
public uint dvdInfoLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] unknown6;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] manufacturer;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] product;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] revision;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] vendor;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] volumeId;
public uint mode2ALen;
public uint unkBlkLen;
public uint dataLen;
public uint sessionsLen;
public uint dpmLen;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Bw5DataFile
{
public uint Type;
public uint Length;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] Unknown1;
public uint Offset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint[] Unknown2;
public int StartLba;
public int Sectors;
public uint FilenameLen;
public byte[] FilenameBytes;
public uint Unknown3;
public string Filename;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Bw5TrackDescriptor
{
public Bw5TrackType type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] unknown1;
public uint unknown2;
public Bw5TrackSubchannel subchannel;
public byte unknown3;
public byte ctl;
public byte adr;
public byte point;
public byte tno;
public byte min;
public byte sec;
public byte frame;
public byte zero;
public byte pmin;
public byte psec;
public byte pframe;
public byte unknown5;
public uint pregap;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public uint[] unknown6;
public int startLba;
public int sectors;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint[] unknown7;
public uint session;
public ushort unknown8;
// Seems to be only on non DVD track descriptors
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public uint[] unknown9;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Bw5SessionDescriptor
{
public ushort Sequence;
public byte Entries;
public byte Unknown;
public int Start;
public int End;
public ushort FirstTrack;
public ushort LastTrack;
public Bw5TrackDescriptor[] Tracks;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DataFileCharacteristics
{
public IFilter FileFilter;
public string FilePath;
public TrackSubchannelType Subchannel;
public long SectorSize;
public int StartLba;
public int Sectors;
}
}
}