mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SimpleSort] Add TGZ and Romba output support
This commit is contained in:
@@ -236,6 +236,8 @@ Options:
|
|||||||
-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
|
-v, --verify Enable verification of output directory
|
||||||
|
-tgz, --tgz Enable TorrentGZ output
|
||||||
|
-r, --romba Enable Romba depot dir output
|
||||||
-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
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace SabreTools
|
|||||||
private bool _quickScan;
|
private bool _quickScan;
|
||||||
private bool _toFolder;
|
private bool _toFolder;
|
||||||
private bool _verify;
|
private bool _verify;
|
||||||
|
private bool _tgz;
|
||||||
|
private bool _romba;
|
||||||
private ArchiveScanLevel _7z;
|
private ArchiveScanLevel _7z;
|
||||||
private ArchiveScanLevel _gz;
|
private ArchiveScanLevel _gz;
|
||||||
private ArchiveScanLevel _rar;
|
private ArchiveScanLevel _rar;
|
||||||
@@ -37,13 +39,16 @@ 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="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="verify">True if output directory should be checked instead of rebuilt to, false otherwise</param>
|
||||||
|
/// <param name="tgz">True if files should be output in TorrentGZ format, false for standard zip</param>
|
||||||
|
/// <param name="romba">True if files should be output in Romba depot folders, 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, bool verify, int sevenzip, int gz, int rar, int zip, Logger logger)
|
bool quickScan, bool toFolder, bool verify, bool tgz, bool romba, int sevenzip,
|
||||||
|
int gz, int rar, int zip, Logger logger)
|
||||||
{
|
{
|
||||||
_datdata = datdata;
|
_datdata = datdata;
|
||||||
_inputs = inputs;
|
_inputs = inputs;
|
||||||
@@ -52,6 +57,8 @@ namespace SabreTools
|
|||||||
_quickScan = quickScan;
|
_quickScan = quickScan;
|
||||||
_toFolder = toFolder;
|
_toFolder = toFolder;
|
||||||
_verify = verify;
|
_verify = verify;
|
||||||
|
_tgz = tgz;
|
||||||
|
_romba = romba;
|
||||||
_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);
|
||||||
@@ -103,7 +110,9 @@ namespace SabreTools
|
|||||||
// Set all default values
|
// Set all default values
|
||||||
bool help = false,
|
bool help = false,
|
||||||
quickScan = false,
|
quickScan = false,
|
||||||
|
romba = false,
|
||||||
simpleSort = true,
|
simpleSort = true,
|
||||||
|
tgz = false,
|
||||||
toFolder = false,
|
toFolder = false,
|
||||||
verify = false;
|
verify = false;
|
||||||
int sevenzip = 0,
|
int sevenzip = 0,
|
||||||
@@ -133,6 +142,14 @@ namespace SabreTools
|
|||||||
case "--quick":
|
case "--quick":
|
||||||
quickScan = true;
|
quickScan = true;
|
||||||
break;
|
break;
|
||||||
|
case "-r":
|
||||||
|
case "--romba":
|
||||||
|
romba = true;
|
||||||
|
break;
|
||||||
|
case "-tgz":
|
||||||
|
case "--tgz":
|
||||||
|
tgz = true;
|
||||||
|
break;
|
||||||
case "-v":
|
case "-v":
|
||||||
case "--verify":
|
case "--verify":
|
||||||
verify = true;
|
verify = true;
|
||||||
@@ -227,7 +244,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
if (datfiles.Count > 0)
|
if (datfiles.Count > 0)
|
||||||
{
|
{
|
||||||
InitSimpleSort(datfiles, inputs, outdir, tempdir, quickScan, toFolder, verify, sevenzip, gz, rar, zip, logger);
|
InitSimpleSort(datfiles, inputs, outdir, tempdir, quickScan, toFolder, verify, tgz, romba, sevenzip, gz, rar, zip, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -259,12 +276,14 @@ namespace SabreTools
|
|||||||
/// <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="verify">True if output directory should be checked instead of rebuilt to, false otherwise</param>
|
||||||
|
/// <param name="tgz">True if files should be output in TorrentGZ format, false for standard zip</param>
|
||||||
|
/// <param name="romba">True if files should be output in Romba depot folders, 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, bool verify, int sevenzip, int gz, int rar, int zip, Logger logger)
|
bool quickScan, bool toFolder, bool verify, bool tgz, bool romba, 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();
|
||||||
@@ -273,7 +292,7 @@ namespace SabreTools
|
|||||||
datdata = DatTools.Parse(datfile, 99, 99, datdata, logger);
|
datdata = DatTools.Parse(datfile, 99, 99, datdata, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, verify, sevenzip, gz, rar, zip, logger);
|
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, verify, tgz, romba, sevenzip, gz, rar, zip, logger);
|
||||||
ss.StartProcessing();
|
ss.StartProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,7 +550,7 @@ namespace SabreTools
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -540,7 +559,14 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ArchiveTools.WriteToManagedArchive(input, _outdir, found);
|
if (_tgz)
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteToManagedArchive(input, _outdir, found);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,7 +617,7 @@ namespace SabreTools
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -600,7 +626,14 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ArchiveTools.WriteToManagedArchive(newinput, _outdir, found);
|
if (_tgz)
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteTorrentGZ(newinput, _outdir, _romba, _logger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteToManagedArchive(newinput, _outdir, found);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then output the headered rom (renamed)
|
// Then output the headered rom (renamed)
|
||||||
@@ -639,7 +672,14 @@ namespace SabreTools
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log("Matched name: " + newfound.Name);
|
_logger.Log("Matched name: " + newfound.Name);
|
||||||
ArchiveTools.WriteToManagedArchive(input, _outdir, newfound);
|
if (_tgz)
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteToManagedArchive(input, _outdir, newfound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,14 +751,21 @@ namespace SabreTools
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy file between archives
|
// Copy file between archives
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_tgz ? found.SHA1 : found.Name) + "'");
|
||||||
|
|
||||||
if (Build.MonoEnvironment)
|
if (Build.MonoEnvironment || _tgz)
|
||||||
{
|
{
|
||||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||||
if (File.Exists(outfile))
|
if (File.Exists(outfile))
|
||||||
{
|
{
|
||||||
ArchiveTools.WriteToManagedArchive(outfile, _outdir, found);
|
if (_tgz)
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteTorrentGZ(outfile, _outdir, _romba, _logger);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ArchiveTools.WriteToManagedArchive(outfile, _outdir, found);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -740,7 +787,7 @@ namespace SabreTools
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Now, if the file is a supported archive type, also run on all files within
|
// Now, if the file is a supported archive type, also run on all files within
|
||||||
bool encounteredErrors = !ArchiveTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
bool encounteredErrors = ArchiveTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
|
||||||
|
|
||||||
// Remove the current file if we are in recursion so it's not picked up in the next step
|
// Remove the current file if we are in recursion so it's not picked up in the next step
|
||||||
if (recurse)
|
if (recurse)
|
||||||
|
|||||||
Reference in New Issue
Block a user