mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Separate GetInfo signatures for clarity
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -15,6 +15,25 @@ namespace SabreTools.FileTypes
|
||||
{
|
||||
#region File Info
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single file
|
||||
/// </summary>
|
||||
/// <param name="input">Filename to get information from</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
public static BaseFile? GetInfo(string input, HashType[] hashes)
|
||||
=> GetInfo(input, header: null, hashes, asFiles: 0x00);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single file
|
||||
/// </summary>
|
||||
/// <param name="input">Filename to get information from</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
public static BaseFile? GetInfo(string input, HashType[] hashes, TreatAsFile asFiles)
|
||||
=> GetInfo(input, header: null, hashes, asFiles);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single file
|
||||
/// </summary>
|
||||
@@ -22,16 +41,13 @@ namespace SabreTools.FileTypes
|
||||
/// <param name="header">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
||||
/// <returns>Populated BaseFile object if success, empty one on error</returns>
|
||||
public static BaseFile? GetInfo(string input, string? header = null, HashType[]? hashes = null, TreatAsFile asFiles = 0x00)
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user