[FileTypes/] BaseFile for life

This commit is contained in:
Matt Nadareski
2018-02-15 23:38:55 -08:00
parent 3a45dcc1a5
commit 5740cecc0d
19 changed files with 295 additions and 218 deletions

View File

@@ -187,9 +187,9 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
/// <returns>List of DatItem objects representing the found data</returns>
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
public override List<Rom> GetArchiveFileInfo(Hash omitFromScan = Hash.DeepHashes, bool date = false)
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
{
List<Rom> found = new List<Rom>();
List<BaseFile> found = new List<BaseFile>();
string gamename = Path.GetFileNameWithoutExtension(_filename);
try
@@ -200,24 +200,23 @@ namespace SabreTools.Library.FileTypes
// If secure hashes are disabled, do a quickscan
if (omitFromScan == Hash.SecureHashes)
{
found.Add(new Rom
found.Add(new BaseFile
{
Type = ItemType.Rom,
Name = entry.Key,
Filename = entry.Key,
Size = entry.Size,
CRC = entry.Crc.ToString("X").ToLowerInvariant(),
CRC = BitConverter.GetBytes(entry.Crc),
Date = (date && entry.LastModifiedTime != null ? entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss") : null),
MachineName = gamename,
Parent = gamename,
});
}
// Otherwise, use the stream directly
else
{
Stream entryStream = entry.OpenEntryStream();
Rom rarEntryRom = (Rom)Utilities.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
rarEntryRom.Name = entry.Key;
rarEntryRom.MachineName = gamename;
BaseFile rarEntryRom = Utilities.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
rarEntryRom.Filename = entry.Key;
rarEntryRom.Parent = gamename;
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
found.Add(rarEntryRom);
entryStream.Dispose();