diff --git a/SabreTools.Library/Tools/FileTools.cs b/SabreTools.Library/Tools/FileTools.cs
index 561a4482..6d26a971 100644
--- a/SabreTools.Library/Tools/FileTools.cs
+++ b/SabreTools.Library/Tools/FileTools.cs
@@ -212,12 +212,10 @@ namespace SabreTools.Library.Tools
/// Set a >0 number for getting hash for part of the file, 0 otherwise (default)
/// True if the file Date should be included, false otherwise (default)
/// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise
+ /// True if CHDs should be treated like regular files, false otherwise
/// Populated DatItem object if success, empty one on error
- ///
- /// TODO: Add CHD parsing logic here to get internal hash data
- ///
public static DatItem GetFileInfo(string input, Hash omitFromScan = 0x0,
- long offset = 0, bool date = false, string header = null)
+ long offset = 0, bool date = false, string header = null, bool ignorechd = true)
{
// Add safeguard if file doesn't exist
if (!File.Exists(input))
@@ -226,7 +224,7 @@ namespace SabreTools.Library.Tools
}
// Get the information from the file stream
- Rom rom = new Rom();
+ DatItem datItem = new Rom();
if (header != null)
{
SkipperRule rule = Skipper.GetMatchingRule(input, Path.GetFileNameWithoutExtension(header));
@@ -240,7 +238,7 @@ namespace SabreTools.Library.Tools
// Transform the stream and get the information from it
rule.TransformStream(inputStream, outputStream, keepReadOpen: false, keepWriteOpen: true);
- rom = (Rom)GetStreamInfo(outputStream, outputStream.Length, omitFromScan: omitFromScan, keepReadOpen: false);
+ datItem = GetStreamInfo(outputStream, outputStream.Length, omitFromScan: omitFromScan, keepReadOpen: false, ignorechd: ignorechd);
// Dispose of the streams
outputStream.Dispose();
@@ -250,20 +248,23 @@ namespace SabreTools.Library.Tools
else
{
long length = new FileInfo(input).Length;
- rom = (Rom)GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, false);
+ datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, ignorechd: ignorechd);
}
}
else
{
long length = new FileInfo(input).Length;
- rom = (Rom)GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, false);
+ datItem = GetStreamInfo(TryOpenRead(input), length, omitFromScan, offset, keepReadOpen: false, ignorechd: ignorechd);
}
// Add unique data from the file
- rom.Name = Path.GetFileName(input);
- rom.Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : "");
+ datItem.Name = Path.GetFileName(input);
+ if (datItem.Type == ItemType.Rom)
+ {
+ ((Rom)datItem).Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : "");
+ }
- return rom;
+ return datItem;
}
///
@@ -732,6 +733,7 @@ namespace SabreTools.Library.Tools
/// Hash flag saying what hashes should not be calculated (defaults to none)
/// Set a >0 number for getting hash for part of the file, 0 otherwise (default)
/// True if the underlying read stream should be kept open, false otherwise
+ /// True if CHDs should be treated like regular files, false otherwise
/// Populated DatItem object if success, empty one on error
public static DatItem GetStreamInfo(Stream input, long size, Hash omitFromScan = 0x0,
long offset = 0, bool keepReadOpen = false, bool ignorechd = true)