// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : GDI.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using DiscImageChef.Console;
using DiscImageChef.CommonTypes;
namespace DiscImageChef.ImagePlugins
{
// TODO: There seems no be no clear definition on how to treat pregaps that are not included in the file, so this is just appending it to start of track
// TODO: This format doesn't support to specify pregaps that are included in the file (like Redump ones)
class GDI : ImagePlugin
{
#region Internal structures
struct GDITrack
{
/// Track #
public UInt32 sequence;
/// Track file
public string trackfile;
/// Track byte offset in file
public long offset;
/// Track flags
public byte flags;
/// Track starting sector
public ulong startSector;
/// Bytes per sector
public UInt16 bps;
/// Sectors in track
public UInt64 sectors;
/// Track type
public TrackType tracktype;
/// Track session
public bool highDensity;
/// Pregap sectors not stored in track file
public ulong pregap;
}
struct GDIDisc
{
/// Sessions
public List sessions;
/// Tracks
public List tracks;
/// Disk type
public MediaType disktype;
}
#endregion Internal structures
#region Internal variables
string imagePath;
StreamReader gdiStream;
FileStream imageStream;
/// Dictionary, index is track #, value is track number, or 0 if a TOC
Dictionary offsetmap;
GDIDisc discimage;
List partitions;
ulong densitySeparationSectors;
#endregion Internal variables
#region Parsing regexs
const string TrackRegEx = "\\s?(?