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;
|
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>
|
/// <summary>
|
||||||
/// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa
|
/// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -462,6 +462,8 @@ namespace SabreTools
|
|||||||
_logger.User("Stats of the matched ROMs:");
|
_logger.User("Stats of the matched ROMs:");
|
||||||
Stats.OutputStats(_matched, _logger, true);
|
Stats.OutputStats(_matched, _logger, true);
|
||||||
|
|
||||||
|
// Diff the matched with the input DAT(s) and output if flag is set
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,33 +486,8 @@ namespace SabreTools
|
|||||||
_logger.Log(statement, _cursorTop, 0);
|
_logger.Log(statement, _cursorTop, 0);
|
||||||
|
|
||||||
// Get if the file should be scanned internally and externally
|
// Get if the file should be scanned internally and externally
|
||||||
bool shouldExternalScan = true;
|
bool shouldExternalScan, shouldInternalScan;
|
||||||
bool shouldInternalScan = true;
|
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalScan, out shouldInternalScan);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash and match the external files
|
// Hash and match the external files
|
||||||
if (shouldExternalScan)
|
if (shouldExternalScan)
|
||||||
|
|||||||
@@ -271,33 +271,8 @@ namespace SabreTools
|
|||||||
_logger.User("Examining file " + input);
|
_logger.User("Examining file " + input);
|
||||||
|
|
||||||
// Get if the file should be scanned internally and externally
|
// Get if the file should be scanned internally and externally
|
||||||
bool shouldExternalProcess = true;
|
bool shouldExternalProcess, shouldInternalProcess;
|
||||||
bool shouldInternalProcess = true;
|
ArchiveTools.GetInternalExternalProcess(input, _7z, _gz, _rar, _zip, _logger, out shouldExternalProcess, out shouldInternalProcess);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do an external scan of the file, if necessary
|
// Do an external scan of the file, if necessary
|
||||||
if (shouldExternalProcess)
|
if (shouldExternalProcess)
|
||||||
|
|||||||
Reference in New Issue
Block a user