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);
|
BaseArchive? archive = FileTypeTool.CreateArchiveType(file);
|
||||||
|
|
||||||
// Now get all extracted items from the archive
|
// Now get all extracted items from the archive
|
||||||
|
HashType[] hashTypes = quickScan ? [HashType.CRC32] : [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
||||||
if (archive != null)
|
if (archive != null)
|
||||||
{
|
{
|
||||||
archive.SetHashTypes(quickScan ? [HashType.CRC32] : [HashType.CRC32, HashType.MD5, HashType.SHA1]);
|
archive.SetHashTypes(hashTypes);
|
||||||
entries = archive.GetChildren();
|
entries = archive.GetChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the entries list is null, we encountered an error or have a file and should scan externally
|
// 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))
|
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
|
// Create the correct DatItem
|
||||||
DatItem? internalDatItem;
|
DatItem? internalDatItem;
|
||||||
|
|||||||
@@ -15,6 +15,25 @@ namespace SabreTools.FileTypes
|
|||||||
{
|
{
|
||||||
#region File Info
|
#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>
|
/// <summary>
|
||||||
/// Retrieve file information for a single file
|
/// Retrieve file information for a single file
|
||||||
/// </summary>
|
/// </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="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="hashes">Hashes to include in the information</param>
|
||||||
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
||||||
/// <returns>Populated BaseFile object if success, empty one on error</returns>
|
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||||
public static BaseFile? GetInfo(string input, string? header = null, HashType[]? hashes = null, TreatAsFile asFiles = 0x00)
|
public static BaseFile? GetInfo(string input, string? header, HashType[] hashes, TreatAsFile asFiles)
|
||||||
{
|
{
|
||||||
// Add safeguard if file doesn't exist
|
// Add safeguard if file doesn't exist
|
||||||
if (!File.Exists(input))
|
if (!File.Exists(input))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// If no hashes are set, use the standard array
|
|
||||||
hashes ??= [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
|
||||||
|
|
||||||
// Get input information
|
// Get input information
|
||||||
var fileType = GetFileType(input);
|
var fileType = GetFileType(input);
|
||||||
Stream inputStream = File.OpenRead(input);
|
Stream inputStream = File.OpenRead(input);
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ namespace SabreTools.FileTypes
|
|||||||
foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BaseFile? nf = FileTypeTool.GetInfo(file, hashes: _hashTypes);
|
BaseFile? nf = FileTypeTool.GetInfo(file, _hashTypes);
|
||||||
if (nf != null)
|
if (nf != null)
|
||||||
_children.Add(nf);
|
_children.Add(nf);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user