mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[CHDFile, FileTools] Hook up CHDFile; create helper class
This commit is contained in:
315
SabreTools.Library/External/CHDFile.cs
vendored
315
SabreTools.Library/External/CHDFile.cs
vendored
@@ -66,21 +66,152 @@ namespace SabreTools.Library.External
|
|||||||
/// </remrks>
|
/// </remrks>
|
||||||
public class CHDFile
|
public class CHDFile
|
||||||
{
|
{
|
||||||
// Core parameters from the header
|
/// <summary>
|
||||||
private ulong m_signature; // signature
|
/// Information regarding the CHD, mostly unused
|
||||||
private uint m_headersize; // size of the header
|
/// </summary>
|
||||||
private uint m_version; // version of the header
|
private class CHD
|
||||||
private ulong m_logicalbytes; // logical size of the raw CHD data in bytes
|
{
|
||||||
private ulong m_mapoffset; // offset of map
|
// Core parameters from the header
|
||||||
private ulong m_metaoffset; // offset to first metadata bit
|
public ulong m_signature; // signature
|
||||||
private uint m_hunkbytes; // size of each raw hunk in bytes
|
public uint m_headersize; // size of the header
|
||||||
private ulong m_hunkcount; // number of hunks represented
|
public uint m_version; // version of the header
|
||||||
private uint m_unitbytes; // size of each unit in bytes
|
public ulong m_logicalbytes; // logical size of the raw CHD data in bytes
|
||||||
private ulong m_unitcount; // number of units represented
|
public ulong m_mapoffset; // offset of map
|
||||||
private CHDCodecType[] m_compression = new CHDCodecType[4]; // array of compression types used
|
public ulong m_metaoffset; // offset to first metadata bit
|
||||||
|
public uint m_hunkbytes; // size of each raw hunk in bytes
|
||||||
|
private ulong m_hunkcount; // number of hunks represented
|
||||||
|
public uint m_unitbytes; // size of each unit in bytes
|
||||||
|
public ulong m_unitcount; // number of units represented
|
||||||
|
public CHDCodecType[] m_compression = new CHDCodecType[4]; // array of compression types used
|
||||||
|
|
||||||
// map information
|
// map information
|
||||||
uint m_mapentrybytes; // length of each entry in a map
|
public uint m_mapentrybytes; // length of each entry in a map
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a CHD v3 header
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="br">Binary reader representing the input stream</param>
|
||||||
|
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
||||||
|
public byte[] ParseCHDv3Header(BinaryReader br)
|
||||||
|
{
|
||||||
|
// Set the blank SHA-1 hash
|
||||||
|
byte[] sha1 = new byte[20];
|
||||||
|
|
||||||
|
// Set offsets and defaults
|
||||||
|
m_mapoffset = 120;
|
||||||
|
m_mapentrybytes = 16;
|
||||||
|
|
||||||
|
// Read the CHD flags
|
||||||
|
uint flags = br.ReadUInt32();
|
||||||
|
|
||||||
|
// Determine compression
|
||||||
|
switch (br.ReadUInt32())
|
||||||
|
{
|
||||||
|
case 0: m_compression[0] = CHDCodecType.CHD_CODEC_NONE; break;
|
||||||
|
case 1: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
||||||
|
case 2: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
||||||
|
case 3: m_compression[0] = CHDCodecType.CHD_CODEC_AVHUFF; break;
|
||||||
|
default: /* throw CHDERR_UNKNOWN_COMPRESSION; */ return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_compression[1] = m_compression[2] = m_compression[3] = CHDCodecType.CHD_CODEC_NONE;
|
||||||
|
|
||||||
|
m_hunkcount = br.ReadUInt32();
|
||||||
|
m_logicalbytes = br.ReadUInt64();
|
||||||
|
m_metaoffset = br.ReadUInt64();
|
||||||
|
|
||||||
|
br.BaseStream.Seek(76, SeekOrigin.Begin);
|
||||||
|
m_hunkbytes = br.ReadUInt32();
|
||||||
|
|
||||||
|
br.BaseStream.Seek(Constants.CHDv3SHA1Offset, SeekOrigin.Begin);
|
||||||
|
sha1 = br.ReadBytes(20);
|
||||||
|
|
||||||
|
// guess at the units based on snooping the metadata
|
||||||
|
// m_unitbytes = guess_unitbytes();
|
||||||
|
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
||||||
|
|
||||||
|
return sha1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a CHD v4 header
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="br">Binary reader representing the input stream</param>
|
||||||
|
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
||||||
|
public byte[] ParseCHDv4Header(BinaryReader br)
|
||||||
|
{
|
||||||
|
// Set the blank SHA-1 hash
|
||||||
|
byte[] sha1 = new byte[20];
|
||||||
|
|
||||||
|
// Set offsets and defaults
|
||||||
|
m_mapoffset = 108;
|
||||||
|
m_mapentrybytes = 16;
|
||||||
|
|
||||||
|
// Read the CHD flags
|
||||||
|
uint flags = br.ReadUInt32();
|
||||||
|
|
||||||
|
// Determine compression
|
||||||
|
switch (br.ReadUInt32())
|
||||||
|
{
|
||||||
|
case 0: m_compression[0] = CHDCodecType.CHD_CODEC_NONE; break;
|
||||||
|
case 1: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
||||||
|
case 2: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
||||||
|
case 3: m_compression[0] = CHDCodecType.CHD_CODEC_AVHUFF; break;
|
||||||
|
default: /* throw CHDERR_UNKNOWN_COMPRESSION; */ return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_compression[1] = m_compression[2] = m_compression[3] = CHDCodecType.CHD_CODEC_NONE;
|
||||||
|
|
||||||
|
m_hunkcount = br.ReadUInt32();
|
||||||
|
m_logicalbytes = br.ReadUInt64();
|
||||||
|
m_metaoffset = br.ReadUInt64();
|
||||||
|
|
||||||
|
br.BaseStream.Seek(44, SeekOrigin.Begin);
|
||||||
|
m_hunkbytes = br.ReadUInt32();
|
||||||
|
|
||||||
|
br.BaseStream.Seek(Constants.CHDv4SHA1Offset, SeekOrigin.Begin);
|
||||||
|
sha1 = br.ReadBytes(20);
|
||||||
|
|
||||||
|
// guess at the units based on snooping the metadata
|
||||||
|
// m_unitbytes = guess_unitbytes();
|
||||||
|
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
||||||
|
return sha1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a CHD v5 header
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="br">Binary reader representing the input stream</param>
|
||||||
|
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
||||||
|
public byte[] ParseCHDv5Header(BinaryReader br)
|
||||||
|
{
|
||||||
|
// Set the blank SHA-1 hash
|
||||||
|
byte[] sha1 = new byte[20];
|
||||||
|
|
||||||
|
// Determine compression
|
||||||
|
m_compression[0] = (CHDCodecType)br.ReadUInt32();
|
||||||
|
m_compression[1] = (CHDCodecType)br.ReadUInt32();
|
||||||
|
m_compression[2] = (CHDCodecType)br.ReadUInt32();
|
||||||
|
m_compression[3] = (CHDCodecType)br.ReadUInt32();
|
||||||
|
|
||||||
|
m_logicalbytes = br.ReadUInt64();
|
||||||
|
m_mapoffset = br.ReadUInt64();
|
||||||
|
m_metaoffset = br.ReadUInt64();
|
||||||
|
m_hunkbytes = br.ReadUInt32();
|
||||||
|
m_hunkcount = (m_logicalbytes + m_hunkbytes - 1) / m_hunkbytes;
|
||||||
|
m_unitbytes = br.ReadUInt32();
|
||||||
|
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
||||||
|
|
||||||
|
// m_allow_writes = !compressed();
|
||||||
|
|
||||||
|
// determine properties of map entries
|
||||||
|
// m_mapentrybytes = compressed() ? 12 : 4;
|
||||||
|
|
||||||
|
br.BaseStream.Seek(Constants.CHDv5SHA1Offset, SeekOrigin.Begin);
|
||||||
|
sha1 = br.ReadBytes(20);
|
||||||
|
return sha1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get internal metadata from a CHD
|
/// Get internal metadata from a CHD
|
||||||
@@ -90,7 +221,7 @@ namespace SabreTools.Library.External
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Original code had a "writable" param. This is not required for metadata checking
|
/// Original code had a "writable" param. This is not required for metadata checking
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public DatItem GetCHDInfo(string filename)
|
public static DatItem GetCHDInfo(string filename)
|
||||||
{
|
{
|
||||||
FileStream fs = FileTools.TryOpenRead(filename);
|
FileStream fs = FileTools.TryOpenRead(filename);
|
||||||
DatItem datItem = GetCHDInfo(fs);
|
DatItem datItem = GetCHDInfo(fs);
|
||||||
@@ -106,43 +237,46 @@ namespace SabreTools.Library.External
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Original code had a "writable" param. This is not required for metadata checking
|
/// Original code had a "writable" param. This is not required for metadata checking
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public DatItem GetCHDInfo(Stream fs)
|
public static DatItem GetCHDInfo(Stream fs)
|
||||||
{
|
{
|
||||||
// Create a blank Disk to populate and return
|
// Create a blank Disk to populate and return
|
||||||
Disk datItem = new Disk();
|
Disk datItem = new Disk();
|
||||||
|
|
||||||
|
// Get a CHD object to store the data
|
||||||
|
CHD chd = new CHD();
|
||||||
|
|
||||||
// Get a binary reader to make life easier
|
// Get a binary reader to make life easier
|
||||||
BinaryReader br = new BinaryReader(fs);
|
BinaryReader br = new BinaryReader(fs);
|
||||||
|
|
||||||
// Read and verify the CHD signature
|
// Read and verify the CHD signature
|
||||||
m_signature = br.ReadUInt64();
|
chd.m_signature = br.ReadUInt64();
|
||||||
if (m_signature != Constants.CHDSignature)
|
if (chd.m_signature != Constants.CHDSignature)
|
||||||
{
|
{
|
||||||
// throw CHDERR_INVALID_FILE;
|
// throw CHDERR_INVALID_FILE;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the header size and version
|
// Get the header size and version
|
||||||
m_headersize = br.ReadUInt32();
|
chd.m_headersize = br.ReadUInt32();
|
||||||
m_version = br.ReadUInt32();
|
chd.m_version = br.ReadUInt32();
|
||||||
|
|
||||||
// Create a placeholder for the extracted SHA-1
|
// Create a placeholder for the extracted SHA-1
|
||||||
byte[] sha1 = new byte[20];
|
byte[] sha1 = new byte[20];
|
||||||
|
|
||||||
// If we have a CHD v3 file, parse it accordingly
|
// If we have a CHD v3 file, parse it accordingly
|
||||||
if (m_headersize == Constants.CHD_V3_HEADER_SIZE && m_version == 3)
|
if (chd.m_headersize == Constants.CHD_V3_HEADER_SIZE && chd.m_version == 3)
|
||||||
{
|
{
|
||||||
sha1 = ParseCHDv3Header(br);
|
sha1 = chd.ParseCHDv3Header(br);
|
||||||
}
|
}
|
||||||
// If we have a CHD v4 file, parse it accordingly
|
// If we have a CHD v4 file, parse it accordingly
|
||||||
else if (m_headersize == Constants.CHD_V4_HEADER_SIZE && m_version == 4)
|
else if (chd.m_headersize == Constants.CHD_V4_HEADER_SIZE && chd.m_version == 4)
|
||||||
{
|
{
|
||||||
sha1 = ParseCHDv4Header(br);
|
sha1 = chd.ParseCHDv4Header(br);
|
||||||
}
|
}
|
||||||
// If we have a CHD v5 file, parse it accordingly
|
// If we have a CHD v5 file, parse it accordingly
|
||||||
else if (m_headersize == Constants.CHD_V5_HEADER_SIZE && m_version == 5)
|
else if (chd.m_headersize == Constants.CHD_V5_HEADER_SIZE && chd.m_version == 5)
|
||||||
{
|
{
|
||||||
sha1 = ParseCHDv5Header(br);
|
sha1 = chd.ParseCHDv5Header(br);
|
||||||
}
|
}
|
||||||
// If we don't have a valid combination, return null
|
// If we don't have a valid combination, return null
|
||||||
else
|
else
|
||||||
@@ -163,7 +297,7 @@ namespace SabreTools.Library.External
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Filename of possible CHD</param>
|
/// <param name="filename">Filename of possible CHD</param>
|
||||||
/// <returns>True if a the file is a valid CHD, false otherwise</returns>
|
/// <returns>True if a the file is a valid CHD, false otherwise</returns>
|
||||||
public bool IsValidCHD(string filename)
|
public static bool IsValidCHD(string filename)
|
||||||
{
|
{
|
||||||
DatItem datItem = GetCHDInfo(filename);
|
DatItem datItem = GetCHDInfo(filename);
|
||||||
return datItem != null
|
return datItem != null
|
||||||
@@ -176,137 +310,12 @@ namespace SabreTools.Library.External
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fs">Stream of possible CHD</param>
|
/// <param name="fs">Stream of possible CHD</param>
|
||||||
/// <returns>True if a the file is a valid CHD, false otherwise</returns>
|
/// <returns>True if a the file is a valid CHD, false otherwise</returns>
|
||||||
public bool IsValidCHD(Stream fs)
|
public static bool IsValidCHD(Stream fs)
|
||||||
{
|
{
|
||||||
DatItem datItem = GetCHDInfo(fs);
|
DatItem datItem = GetCHDInfo(fs);
|
||||||
return datItem != null
|
return datItem != null
|
||||||
&& datItem.Type == ItemType.Disk
|
&& datItem.Type == ItemType.Disk
|
||||||
&& ((Disk)datItem).SHA1 != null;
|
&& ((Disk)datItem).SHA1 != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Parse a CHD v3 header
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="br">Binary reader representing the input stream</param>
|
|
||||||
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
|
||||||
private byte[] ParseCHDv3Header(BinaryReader br)
|
|
||||||
{
|
|
||||||
// Set the blank SHA-1 hash
|
|
||||||
byte[] sha1 = new byte[20];
|
|
||||||
|
|
||||||
// Set offsets and defaults
|
|
||||||
m_mapoffset = 120;
|
|
||||||
m_mapentrybytes = 16;
|
|
||||||
|
|
||||||
// Read the CHD flags
|
|
||||||
uint flags = br.ReadUInt32();
|
|
||||||
|
|
||||||
// Determine compression
|
|
||||||
switch (br.ReadUInt32())
|
|
||||||
{
|
|
||||||
case 0: m_compression[0] = CHDCodecType.CHD_CODEC_NONE; break;
|
|
||||||
case 1: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
|
||||||
case 2: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
|
||||||
case 3: m_compression[0] = CHDCodecType.CHD_CODEC_AVHUFF; break;
|
|
||||||
default: /* throw CHDERR_UNKNOWN_COMPRESSION; */ return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_compression[1] = m_compression[2] = m_compression[3] = CHDCodecType.CHD_CODEC_NONE;
|
|
||||||
|
|
||||||
m_hunkcount = br.ReadUInt32();
|
|
||||||
m_logicalbytes = br.ReadUInt64();
|
|
||||||
m_metaoffset = br.ReadUInt64();
|
|
||||||
|
|
||||||
br.BaseStream.Seek(76, SeekOrigin.Begin);
|
|
||||||
m_hunkbytes = br.ReadUInt32();
|
|
||||||
|
|
||||||
br.BaseStream.Seek(Constants.CHDv3SHA1Offset, SeekOrigin.Begin);
|
|
||||||
sha1 = br.ReadBytes(20);
|
|
||||||
|
|
||||||
// guess at the units based on snooping the metadata
|
|
||||||
// m_unitbytes = guess_unitbytes();
|
|
||||||
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
|
||||||
|
|
||||||
return sha1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Parse a CHD v4 header
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="br">Binary reader representing the input stream</param>
|
|
||||||
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
|
||||||
private byte[] ParseCHDv4Header(BinaryReader br)
|
|
||||||
{
|
|
||||||
// Set the blank SHA-1 hash
|
|
||||||
byte[] sha1 = new byte[20];
|
|
||||||
|
|
||||||
// Set offsets and defaults
|
|
||||||
m_mapoffset = 108;
|
|
||||||
m_mapentrybytes = 16;
|
|
||||||
|
|
||||||
// Read the CHD flags
|
|
||||||
uint flags = br.ReadUInt32();
|
|
||||||
|
|
||||||
// Determine compression
|
|
||||||
switch (br.ReadUInt32())
|
|
||||||
{
|
|
||||||
case 0: m_compression[0] = CHDCodecType.CHD_CODEC_NONE; break;
|
|
||||||
case 1: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
|
||||||
case 2: m_compression[0] = CHDCodecType.CHD_CODEC_ZLIB; break;
|
|
||||||
case 3: m_compression[0] = CHDCodecType.CHD_CODEC_AVHUFF; break;
|
|
||||||
default: /* throw CHDERR_UNKNOWN_COMPRESSION; */ return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_compression[1] = m_compression[2] = m_compression[3] = CHDCodecType.CHD_CODEC_NONE;
|
|
||||||
|
|
||||||
m_hunkcount = br.ReadUInt32();
|
|
||||||
m_logicalbytes = br.ReadUInt64();
|
|
||||||
m_metaoffset = br.ReadUInt64();
|
|
||||||
|
|
||||||
br.BaseStream.Seek(44, SeekOrigin.Begin);
|
|
||||||
m_hunkbytes = br.ReadUInt32();
|
|
||||||
|
|
||||||
br.BaseStream.Seek(Constants.CHDv4SHA1Offset, SeekOrigin.Begin);
|
|
||||||
sha1 = br.ReadBytes(20);
|
|
||||||
|
|
||||||
// guess at the units based on snooping the metadata
|
|
||||||
// m_unitbytes = guess_unitbytes();
|
|
||||||
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
|
||||||
return sha1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Parse a CHD v5 header
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="br">Binary reader representing the input stream</param>
|
|
||||||
/// <returns>The extracted SHA-1 on success, null otherwise</returns>
|
|
||||||
private byte[] ParseCHDv5Header(BinaryReader br)
|
|
||||||
{
|
|
||||||
// Set the blank SHA-1 hash
|
|
||||||
byte[] sha1 = new byte[20];
|
|
||||||
|
|
||||||
// Determine compression
|
|
||||||
m_compression[0] = (CHDCodecType)br.ReadUInt32();
|
|
||||||
m_compression[1] = (CHDCodecType)br.ReadUInt32();
|
|
||||||
m_compression[2] = (CHDCodecType)br.ReadUInt32();
|
|
||||||
m_compression[3] = (CHDCodecType)br.ReadUInt32();
|
|
||||||
|
|
||||||
m_logicalbytes = br.ReadUInt64();
|
|
||||||
m_mapoffset = br.ReadUInt64();
|
|
||||||
m_metaoffset = br.ReadUInt64();
|
|
||||||
m_hunkbytes = br.ReadUInt32();
|
|
||||||
m_hunkcount = (m_logicalbytes + m_hunkbytes - 1) / m_hunkbytes;
|
|
||||||
m_unitbytes = br.ReadUInt32();
|
|
||||||
m_unitcount = (m_logicalbytes + m_unitbytes - 1) / m_unitbytes;
|
|
||||||
|
|
||||||
// m_allow_writes = !compressed();
|
|
||||||
|
|
||||||
// determine properties of map entries
|
|
||||||
// m_mapentrybytes = compressed() ? 12 : 4;
|
|
||||||
|
|
||||||
br.BaseStream.Seek(Constants.CHDv5SHA1Offset, SeekOrigin.Begin);
|
|
||||||
sha1 = br.ReadBytes(20);
|
|
||||||
return sha1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -734,8 +734,55 @@ namespace SabreTools.Library.Tools
|
|||||||
/// <param name="keepReadOpen">True if the underlying read stream should be kept open, false otherwise</param>
|
/// <param name="keepReadOpen">True if the underlying read stream should be kept open, false otherwise</param>
|
||||||
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
/// <returns>Populated DatItem object if success, empty one on error</returns>
|
||||||
public static DatItem GetStreamInfo(Stream input, long size, Hash omitFromScan = 0x0,
|
public static DatItem GetStreamInfo(Stream input, long size, Hash omitFromScan = 0x0,
|
||||||
long offset = 0, bool keepReadOpen = false)
|
long offset = 0, bool keepReadOpen = false, bool ignorechd = true)
|
||||||
{
|
{
|
||||||
|
// We first check to see if it's a CHD
|
||||||
|
if (ignorechd == false && CHDFile.IsValidCHD(input))
|
||||||
|
{
|
||||||
|
// Seek to the starting position, if one is set
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (offset < 0)
|
||||||
|
{
|
||||||
|
input.Seek(offset, SeekOrigin.End);
|
||||||
|
}
|
||||||
|
else if (offset > 0)
|
||||||
|
{
|
||||||
|
input.Seek(offset, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
|
catch (NotImplementedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Warning("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the Disk from the information
|
||||||
|
DatItem disk = CHDFile.GetCHDInfo(input);
|
||||||
|
|
||||||
|
// Seek to the beginning of the stream if possible
|
||||||
|
try
|
||||||
|
{
|
||||||
|
input.Seek(0, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
|
catch (NotImplementedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keepReadOpen)
|
||||||
|
{
|
||||||
|
input.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
|
|||||||
Reference in New Issue
Block a user