mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SimpleSort] Add verify flag
This is the flag that will be used eventually to verify a set in a folder. This will be a test to see if I can verify a folder to a DAT properly...
This commit is contained in:
@@ -231,6 +231,7 @@ Options:
|
|||||||
-out= Output directory
|
-out= Output directory
|
||||||
-t=, --temp= Set the temporary directory to use
|
-t=, --temp= Set the temporary directory to use
|
||||||
-qs, --quick Enable quick scanning of archives
|
-qs, --quick Enable quick scanning of archives
|
||||||
|
-v, --verify Enable verification of output directory
|
||||||
-do, --directory Output files as uncompressed
|
-do, --directory Output files as uncompressed
|
||||||
-7z={0} Set scanning level for 7z archives
|
-7z={0} Set scanning level for 7z archives
|
||||||
-gz={2} Set scanning level for GZip archives
|
-gz={2} Set scanning level for GZip archives
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace SabreTools
|
|||||||
private string _tempdir;
|
private string _tempdir;
|
||||||
private bool _quickScan;
|
private bool _quickScan;
|
||||||
private bool _toFolder;
|
private bool _toFolder;
|
||||||
|
private bool _verify;
|
||||||
private ArchiveScanLevel _7z;
|
private ArchiveScanLevel _7z;
|
||||||
private ArchiveScanLevel _gz;
|
private ArchiveScanLevel _gz;
|
||||||
private ArchiveScanLevel _rar;
|
private ArchiveScanLevel _rar;
|
||||||
@@ -35,13 +36,14 @@ namespace SabreTools
|
|||||||
/// <param name="tempdir">Temporary directory for archive extraction</param>
|
/// <param name="tempdir">Temporary directory for archive extraction</param>
|
||||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||||
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
|
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
|
||||||
|
/// <param name="verify">True if output directory should be checked instead of rebuilt to, false otherwise</param>
|
||||||
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
|
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
|
||||||
/// <param name="gz">Integer representing the archive handling level for GZip</param>
|
/// <param name="gz">Integer representing the archive handling level for GZip</param>
|
||||||
/// <param name="rar">Integer representing the archive handling level for RAR</param>
|
/// <param name="rar">Integer representing the archive handling level for RAR</param>
|
||||||
/// <param name="zip">Integer representing the archive handling level for Zip</param>
|
/// <param name="zip">Integer representing the archive handling level for Zip</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
public SimpleSort(Dat datdata, List<string> inputs, string outdir, string tempdir,
|
public SimpleSort(Dat datdata, List<string> inputs, string outdir, string tempdir,
|
||||||
bool quickScan, bool toFolder, int sevenzip, int gz, int rar, int zip, Logger logger)
|
bool quickScan, bool toFolder, bool verify, int sevenzip, int gz, int rar, int zip, Logger logger)
|
||||||
{
|
{
|
||||||
_datdata = datdata;
|
_datdata = datdata;
|
||||||
_inputs = inputs;
|
_inputs = inputs;
|
||||||
@@ -49,6 +51,7 @@ namespace SabreTools
|
|||||||
_tempdir = (tempdir == "" ? "__TEMP__" : tempdir);
|
_tempdir = (tempdir == "" ? "__TEMP__" : tempdir);
|
||||||
_quickScan = quickScan;
|
_quickScan = quickScan;
|
||||||
_toFolder = toFolder;
|
_toFolder = toFolder;
|
||||||
|
_verify = verify;
|
||||||
_7z = (ArchiveScanLevel)(sevenzip < 0 || sevenzip > 2 ? 0 : sevenzip);
|
_7z = (ArchiveScanLevel)(sevenzip < 0 || sevenzip > 2 ? 0 : sevenzip);
|
||||||
_gz = (ArchiveScanLevel)(gz < 0 || gz > 2 ? 0 : gz);
|
_gz = (ArchiveScanLevel)(gz < 0 || gz > 2 ? 0 : gz);
|
||||||
_rar = (ArchiveScanLevel)(rar < 0 || rar > 2 ? 0 : rar);
|
_rar = (ArchiveScanLevel)(rar < 0 || rar > 2 ? 0 : rar);
|
||||||
@@ -101,7 +104,8 @@ namespace SabreTools
|
|||||||
bool help = false,
|
bool help = false,
|
||||||
quickScan = false,
|
quickScan = false,
|
||||||
simpleSort = true,
|
simpleSort = true,
|
||||||
toFolder = false;
|
toFolder = false,
|
||||||
|
verify = false;
|
||||||
int sevenzip = 0,
|
int sevenzip = 0,
|
||||||
gz = 2,
|
gz = 2,
|
||||||
rar = 2,
|
rar = 2,
|
||||||
@@ -129,6 +133,10 @@ namespace SabreTools
|
|||||||
case "--quick":
|
case "--quick":
|
||||||
quickScan = true;
|
quickScan = true;
|
||||||
break;
|
break;
|
||||||
|
case "-v":
|
||||||
|
case "--verify":
|
||||||
|
verify = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
string temparg = arg.Replace("\"", "").Replace("file://", "");
|
string temparg = arg.Replace("\"", "").Replace("file://", "");
|
||||||
|
|
||||||
@@ -206,7 +214,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a switch that requires a filename is set and no file is, show the help screen
|
// If a switch that requires a filename is set and no file is, show the help screen
|
||||||
if (inputs.Count == 0 && (simpleSort))
|
if (inputs.Count == 0 && (simpleSort && !verify))
|
||||||
{
|
{
|
||||||
logger.Error("This feature requires at least one input");
|
logger.Error("This feature requires at least one input");
|
||||||
Build.Help();
|
Build.Help();
|
||||||
@@ -219,7 +227,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
if (datfiles.Count > 0)
|
if (datfiles.Count > 0)
|
||||||
{
|
{
|
||||||
InitSimpleSort(datfiles, inputs, outdir, tempdir, quickScan, toFolder, sevenzip, gz, rar, zip, logger);
|
InitSimpleSort(datfiles, inputs, outdir, tempdir, quickScan, toFolder, verify, sevenzip, gz, rar, zip, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -250,12 +258,13 @@ namespace SabreTools
|
|||||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||||
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
|
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
|
||||||
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
|
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
|
||||||
|
/// <param name="verify">True if output directory should be checked instead of rebuilt to, false otherwise</param>
|
||||||
/// <param name="gz">Integer representing the archive handling level for GZip</param>
|
/// <param name="gz">Integer representing the archive handling level for GZip</param>
|
||||||
/// <param name="rar">Integer representing the archive handling level for RAR</param>
|
/// <param name="rar">Integer representing the archive handling level for RAR</param>
|
||||||
/// <param name="zip">Integer representing the archive handling level for Zip</param>
|
/// <param name="zip">Integer representing the archive handling level for Zip</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
private static void InitSimpleSort(List<string> datfiles, List<string> inputs, string outdir, string tempdir,
|
private static void InitSimpleSort(List<string> datfiles, List<string> inputs, string outdir, string tempdir,
|
||||||
bool quickScan, bool toFolder, int sevenzip, int gz, int rar, int zip, Logger logger)
|
bool quickScan, bool toFolder, bool verify, int sevenzip, int gz, int rar, int zip, Logger logger)
|
||||||
{
|
{
|
||||||
// Add all of the input DATs into one huge internal DAT
|
// Add all of the input DATs into one huge internal DAT
|
||||||
Dat datdata = new Dat();
|
Dat datdata = new Dat();
|
||||||
@@ -264,7 +273,7 @@ namespace SabreTools
|
|||||||
datdata = DatTools.Parse(datfile, 0, 0, datdata, logger);
|
datdata = DatTools.Parse(datfile, 0, 0, datdata, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, sevenzip, gz, rar, zip, logger);
|
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, verify, sevenzip, gz, rar, zip, logger);
|
||||||
ss.RebuildToOutput();
|
ss.RebuildToOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +302,21 @@ namespace SabreTools
|
|||||||
Output.CleanDirectory(_tempdir);
|
Output.CleanDirectory(_tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're in verification mode, only check the output directory
|
||||||
|
if (_verify)
|
||||||
|
{
|
||||||
|
// Create a list of files from the output directory
|
||||||
|
List<string> files = new List<string>();
|
||||||
|
foreach (string file in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
_logger.Log("File found: '" + file + "'");
|
||||||
|
files.Add(Path.GetFullPath(file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, run the rebuilder
|
||||||
|
else
|
||||||
|
{
|
||||||
// Create a list of just files from inputs
|
// Create a list of just files from inputs
|
||||||
List<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
foreach (string input in _inputs)
|
foreach (string input in _inputs)
|
||||||
@@ -344,6 +368,7 @@ namespace SabreTools
|
|||||||
Console.SetCursorPosition(0, Constants.HeaderHeight + 1);
|
Console.SetCursorPosition(0, Constants.HeaderHeight + 1);
|
||||||
_logger.User("Stats of the matched ROMs:");
|
_logger.User("Stats of the matched ROMs:");
|
||||||
Stats.OutputStats(_matched, _logger, true);
|
Stats.OutputStats(_matched, _logger, true);
|
||||||
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user