diff --git a/SabreTools.DatTools/Rebuilder.cs b/SabreTools.DatTools/Rebuilder.cs index 693bcc68..209f229b 100644 --- a/SabreTools.DatTools/Rebuilder.cs +++ b/SabreTools.DatTools/Rebuilder.cs @@ -314,16 +314,17 @@ namespace SabreTools.DatTools BaseArchive? archive = FileTypeTool.CreateArchiveType(file); // Now get all extracted items from the archive + HashType[] hashTypes = quickScan ? [HashType.CRC32] : [HashType.CRC32, HashType.MD5, HashType.SHA1]; if (archive != null) { - archive.SetHashTypes(quickScan ? [HashType.CRC32] : [HashType.CRC32, HashType.MD5, HashType.SHA1]); + archive.SetHashTypes(hashTypes); entries = archive.GetChildren(); } // If the entries list is null, we encountered an error or have a file and should scan externally if (entries == null && System.IO.File.Exists(file)) { - BaseFile? internalFileInfo = FileTypeTool.GetInfo(file, asFiles: asFiles); + BaseFile? internalFileInfo = FileTypeTool.GetInfo(file, hashTypes, asFiles); // Create the correct DatItem DatItem? internalDatItem; diff --git a/SabreTools.FileTypes/FileTypeTool.cs b/SabreTools.FileTypes/FileTypeTool.cs index ee3658e5..d85b7bd4 100644 --- a/SabreTools.FileTypes/FileTypeTool.cs +++ b/SabreTools.FileTypes/FileTypeTool.cs @@ -15,6 +15,25 @@ namespace SabreTools.FileTypes { #region File Info + /// + /// Retrieve file information for a single file + /// + /// Filename to get information from + /// Hashes to include in the information + /// Populated BaseFile object if success, null on error + public static BaseFile? GetInfo(string input, HashType[] hashes) + => GetInfo(input, header: null, hashes, asFiles: 0x00); + + /// + /// Retrieve file information for a single file + /// + /// Filename to get information from + /// Hashes to include in the information + /// TreatAsFiles representing special format scanning + /// Populated BaseFile object if success, null on error + public static BaseFile? GetInfo(string input, HashType[] hashes, TreatAsFile asFiles) + => GetInfo(input, header: null, hashes, asFiles); + /// /// Retrieve file information for a single file /// @@ -22,16 +41,13 @@ namespace SabreTools.FileTypes /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise /// Hashes to include in the information /// TreatAsFiles representing special format scanning - /// Populated BaseFile object if success, empty one on error - public static BaseFile? GetInfo(string input, string? header = null, HashType[]? hashes = null, TreatAsFile asFiles = 0x00) + /// Populated BaseFile object if success, null on error + public static BaseFile? GetInfo(string input, string? header, HashType[] hashes, TreatAsFile asFiles) { // Add safeguard if file doesn't exist if (!File.Exists(input)) return null; - // If no hashes are set, use the standard array - hashes ??= [HashType.CRC32, HashType.MD5, HashType.SHA1]; - // Get input information var fileType = GetFileType(input); Stream inputStream = File.OpenRead(input); diff --git a/SabreTools.FileTypes/Folder.cs b/SabreTools.FileTypes/Folder.cs index dc861398..85090fb2 100644 --- a/SabreTools.FileTypes/Folder.cs +++ b/SabreTools.FileTypes/Folder.cs @@ -255,7 +255,7 @@ namespace SabreTools.FileTypes foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly)) #endif { - BaseFile? nf = FileTypeTool.GetInfo(file, hashes: _hashTypes); + BaseFile? nf = FileTypeTool.GetInfo(file, _hashTypes); if (nf != null) _children.Add(nf); }