mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ArchiveTools] Abstract out getting scan level
This commit is contained in:
@@ -785,6 +785,49 @@ namespace SabreTools.Helper
|
||||
return outtype;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get if the current file should be scanned internally and externally
|
||||
/// </summary>
|
||||
/// <param name="input">Name of the input file to check</param>
|
||||
/// <param name="sevenzip">User-defined scan level for 7z archives</param>
|
||||
/// <param name="gzip">User-defined scan level for GZ archives</param>
|
||||
/// <param name="rar">User-defined scan level for RAR archives</param>
|
||||
/// <param name="zip">User-defined scan level for Zip archives</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <param name="shouldExternalProcess">Output parameter determining if file should be processed externally</param>
|
||||
/// <param name="shouldInternalProcess">Output parameter determining if file should be processed internally</param>
|
||||
public static void GetInternalExternalProcess(string input, ArchiveScanLevel sevenzip, ArchiveScanLevel gzip,
|
||||
ArchiveScanLevel rar, ArchiveScanLevel zip, Logger logger, out bool shouldExternalProcess, out bool shouldInternalProcess)
|
||||
{
|
||||
shouldExternalProcess = true;
|
||||
shouldInternalProcess = true;
|
||||
|
||||
ArchiveType? archiveType = ArchiveTools.GetCurrentArchiveType(input, logger);
|
||||
switch (archiveType)
|
||||
{
|
||||
case null:
|
||||
shouldExternalProcess = true;
|
||||
shouldInternalProcess = false;
|
||||
break;
|
||||
case ArchiveType.GZip:
|
||||
shouldExternalProcess = (gzip != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (gzip != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Rar:
|
||||
shouldExternalProcess = (rar != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (rar != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.SevenZip:
|
||||
shouldExternalProcess = (sevenzip != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (sevenzip != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Zip:
|
||||
shouldExternalProcess = (zip != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (zip != ArchiveScanLevel.External);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa
|
||||
/// </summary>
|
||||
|
||||
@@ -462,6 +462,8 @@ namespace SabreTools
|
||||
_logger.User("Stats of the matched ROMs:");
|
||||
Stats.OutputStats(_matched, _logger, true);
|
||||
|
||||
// Diff the matched with the input DAT(s) and output if flag is set
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -484,33 +486,8 @@ namespace SabreTools
|
||||
_logger.Log(statement, _cursorTop, 0);
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalScan = true;
|
||||
bool shouldInternalScan = true;
|
||||
|
||||
ArchiveType? archiveType = ArchiveTools.GetCurrentArchiveType(input, _logger);
|
||||
switch (archiveType)
|
||||
{
|
||||
case null:
|
||||
shouldExternalScan = true;
|
||||
shouldInternalScan = false;
|
||||
break;
|
||||
case ArchiveType.GZip:
|
||||
shouldExternalScan = (_gz != ArchiveScanLevel.Internal);
|
||||
shouldInternalScan = (_gz != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Rar:
|
||||
shouldExternalScan = (_rar != ArchiveScanLevel.Internal);
|
||||
shouldInternalScan = (_rar != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.SevenZip:
|
||||
shouldExternalScan = (_7z != ArchiveScanLevel.Internal);
|
||||
shouldInternalScan = (_7z != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Zip:
|
||||
shouldExternalScan = (_zip != ArchiveScanLevel.Internal);
|
||||
shouldInternalScan = (_zip != ArchiveScanLevel.External);
|
||||
break;
|
||||
}
|
||||
bool shouldExternalScan, shouldInternalScan;
|
||||
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalScan, out shouldInternalScan);
|
||||
|
||||
// Hash and match the external files
|
||||
if (shouldExternalScan)
|
||||
|
||||
@@ -271,33 +271,8 @@ namespace SabreTools
|
||||
_logger.User("Examining file " + input);
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalProcess = true;
|
||||
bool shouldInternalProcess = true;
|
||||
|
||||
ArchiveType? archiveType = ArchiveTools.GetCurrentArchiveType(input, _logger);
|
||||
switch (archiveType)
|
||||
{
|
||||
case null:
|
||||
shouldExternalProcess = true;
|
||||
shouldInternalProcess = false;
|
||||
break;
|
||||
case ArchiveType.GZip:
|
||||
shouldExternalProcess = (_gz != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_gz != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Rar:
|
||||
shouldExternalProcess = (_rar != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_rar != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.SevenZip:
|
||||
shouldExternalProcess = (_7z != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_7z != ArchiveScanLevel.External);
|
||||
break;
|
||||
case ArchiveType.Zip:
|
||||
shouldExternalProcess = (_zip != ArchiveScanLevel.Internal);
|
||||
shouldInternalProcess = (_zip != ArchiveScanLevel.External);
|
||||
break;
|
||||
}
|
||||
bool shouldExternalProcess, shouldInternalProcess;
|
||||
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalProcess, out shouldInternalProcess);
|
||||
|
||||
// Do an external scan of the file, if necessary
|
||||
if (shouldExternalProcess)
|
||||
|
||||
Reference in New Issue
Block a user