diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs
index d4b425f5..2119adc7 100644
--- a/SabreTools.Library/Tools/Utilities.cs
+++ b/SabreTools.Library/Tools/Utilities.cs
@@ -1217,11 +1217,24 @@ namespace SabreTools.Library.Tools
}
}
+ ///
+ /// Get if file has a known CHD header
+ ///
+ /// Filename of possible CHD
+ /// True if the file has a valid CHD header, false otherwise
+ public static bool HasCHDHeader(string input)
+ {
+ FileStream fs = TryOpenRead(input);
+ bool output = HasCHDHeader(fs);
+ fs.Dispose();
+ return output;
+ }
+
///
/// Get if file is a valid CHD
///
/// Filename of possible CHD
- /// True if a the file is a valid CHD, false otherwise
+ /// True if the file is a valid CHD, false otherwise
public static bool IsValidCHD(string input)
{
DatItem datItem = GetCHDInfo(input);
@@ -1703,7 +1716,7 @@ namespace SabreTools.Library.Tools
long offset = 0, bool keepReadOpen = false, bool chdsAsFiles = true)
{
// We first check to see if it's a CHD
- if (chdsAsFiles == false && IsValidCHD(input))
+ if (chdsAsFiles == false && HasCHDHeader(input))
{
// Seek to the starting position, if one is set
try
@@ -1930,11 +1943,27 @@ namespace SabreTools.Library.Tools
return datItem;
}
+ ///
+ /// Get if stream has a known CHD header
+ ///
+ /// Stream of possible CHD
+ /// True if the stream has a valid CHD header, false otherwise
+ public static bool HasCHDHeader(Stream input)
+ {
+ // Get a CHD object to store the data
+ CHDFile chd = new CHDFile(input);
+
+ // Now try to get the header version
+ uint? version = chd.ValidateHeaderVersion();
+
+ return version != null;
+ }
+
///
/// Get if stream is a valid CHD
///
/// Stream of possible CHD
- /// True if a the file is a valid CHD, false otherwise
+ /// True if the stream is a valid CHD, false otherwise
public static bool IsValidCHD(Stream input)
{
DatItem datItem = GetCHDInfo(input);
@@ -2347,7 +2376,7 @@ namespace SabreTools.Library.Tools
}
///
- /// Get if the given path has a valid archive extension
+ /// Get if the given path has a valid DAT extension
///
/// Path to check
/// True if the extension is valid, false otherwise