mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Formerly roll Convert into Sort by adding --inverse flag
This commit is contained in:
@@ -188,7 +188,7 @@ namespace SabreTools
|
||||
|
||||
// Create the sorting object to use and rebuild the needed files
|
||||
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers((onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1), (onlyNeeded ? 0 : 1));
|
||||
need.RebuildToOutput(onlyDirs, _depots.Keys.ToList()[0], _tmpdir, false, false, false, OutputFormat.TorrentGzip, true, asl, false, null, 4, _logger);
|
||||
need.RebuildToOutput(onlyDirs, _depots.Keys.ToList()[0], _tmpdir, false, false, false, false /*inverse*/, OutputFormat.TorrentGzip, true, asl, false, null, 4, _logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,7 +226,7 @@ namespace SabreTools
|
||||
|
||||
// Now scan all of those depots and rebuild
|
||||
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1);
|
||||
datFile.RebuildToOutput(onlineDepots, outputFolder, _tmpdir, true, false, false, (copy ? OutputFormat.TorrentGzip : OutputFormat.TorrentZip), copy, asl, false, null, 4, _logger);
|
||||
datFile.RebuildToOutput(onlineDepots, outputFolder, _tmpdir, true, false, false, false /*inverse*/, (copy ? OutputFormat.TorrentGzip : OutputFormat.TorrentZip), copy, asl, false, null, 4, _logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,25 +147,6 @@ namespace SabreTools.Helper.Data
|
||||
helptext.Add("Options:");
|
||||
helptext.Add(" -?, -h, --help Show this help");
|
||||
|
||||
// Convert
|
||||
helptext.Add(" -cv, --convert Enable conversion of input files to folder");
|
||||
helptext.Add(" -dat= DAT to be used as a filter for conversion");
|
||||
helptext.Add(" -out= Output directory");
|
||||
helptext.Add(" -t=, --temp= Set the temporary directory to use");
|
||||
helptext.Add(" -del, --delete Delete input files [DO NOT USE]");
|
||||
//helptext.Add(" -t7z Enable Torrent7z output");
|
||||
//helptext.Add(" -tar Enable TAR output");
|
||||
helptext.Add(" -tgz Enable TorrentGZ output");
|
||||
helptext.Add(" -r, --romba Enable Romba depot dir output");
|
||||
//helptext.Add(" -tlrz Enable TorrentLRZ output");
|
||||
//helptext.Add(" -trar Enable TorrentRAR output");
|
||||
//helptext.Add(" -txz Enable TorrentXZ output");
|
||||
helptext.Add(" -tzip Enable TorrentZip output");
|
||||
helptext.Add(" -7z={0} Set scanning level for 7z archives");
|
||||
helptext.Add(" -gz={2} Set scanning level for GZip archives");
|
||||
helptext.Add(" -rar={2} Set scanning level for RAR archives");
|
||||
helptext.Add(" -zip={0} Set scanning level for ZIP archives");
|
||||
|
||||
// DATFromDir
|
||||
helptext.Add(" -d, --dfd Create a DAT from an input directory");
|
||||
helptext.Add(" -nm, --noMD5 Don't include MD5 in output");
|
||||
@@ -225,6 +206,7 @@ namespace SabreTools.Helper.Data
|
||||
helptext.Add(" -out= Output directory");
|
||||
helptext.Add(" -t=, --temp= Set the temporary directory to use");
|
||||
helptext.Add(" -del, --delete Delete input files [DO NOT USE]");
|
||||
helptext.Add(" -in, --inverse Rebuild only files not in DAT");
|
||||
helptext.Add(" -qs, --quick Enable quick scanning of archives");
|
||||
helptext.Add(" -ad, --add-date Add original dates from DAT, if possible");
|
||||
//helptext.Add(" -t7z Enable Torrent7z output");
|
||||
|
||||
@@ -4273,188 +4273,6 @@ namespace SabreTools.Helper.Dats
|
||||
|
||||
#region Rebuilding and Verifying
|
||||
|
||||
/// <summary>
|
||||
/// Process inputs and convert to TorrentZip or TorrentGZ, optionally converting to Romba format
|
||||
/// </summary>
|
||||
/// <param name="inputs">List of inputs to convert over to TorrentZip or TorrentGZ</param>
|
||||
/// <param name="outDir">Output folder to rebuild to, blank is the current directory</param>
|
||||
/// <param name="tempDir">Temporary directory to use in file extraction</param>
|
||||
/// <param name="outputFormat">Output format that files should be written to</param>
|
||||
/// <param name="romba">True if TorrentGZ files should be output in romba depot format, false otherwise</param>
|
||||
/// <param name="delete">True if input files should be deleted, false otherwise</param>
|
||||
/// <param name="archiveScanLevel">ArchiveScanLevel representing how files should be treated</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if processing was a success, false otherwise</returns>
|
||||
public bool ConvertFiles(List<string> inputs, string outDir, string tempDir, OutputFormat outputFormat,
|
||||
bool romba, bool delete, ArchiveScanLevel archiveScanLevel, Logger logger)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
// Check to see that there's an output directory and a temp directory defined
|
||||
if (String.IsNullOrEmpty(outDir))
|
||||
{
|
||||
outDir = "output";
|
||||
}
|
||||
if (String.IsNullOrEmpty(tempDir))
|
||||
{
|
||||
tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
}
|
||||
|
||||
// First, check that the output directory exists
|
||||
if (!Directory.Exists(outDir))
|
||||
{
|
||||
Directory.CreateDirectory(outDir);
|
||||
outDir = Path.GetFullPath(outDir);
|
||||
}
|
||||
|
||||
// Then create or clean the temp directory
|
||||
if (!Directory.Exists(tempDir))
|
||||
{
|
||||
Directory.CreateDirectory(tempDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileTools.CleanDirectory(tempDir);
|
||||
}
|
||||
|
||||
// Now process all of the inputs
|
||||
foreach (string input in inputs)
|
||||
{
|
||||
logger.User("Examining file " + input);
|
||||
|
||||
// Get if the file should be scanned internally and externally
|
||||
bool shouldExternalProcess, shouldInternalProcess;
|
||||
ArchiveTools.GetInternalExternalProcess(input, archiveScanLevel, logger, out shouldExternalProcess, out shouldInternalProcess);
|
||||
|
||||
// Do an external scan of the file, if necessary
|
||||
if (shouldExternalProcess)
|
||||
{
|
||||
// If a DAT is defined, we want to make sure that this file is not in there
|
||||
Rom rom = FileTools.GetFileInfo(input, logger);
|
||||
rom.Machine = new Machine { Name = Path.GetFileNameWithoutExtension(rom.Name) };
|
||||
if (this != null && Files.Count > 0)
|
||||
{
|
||||
if (rom.HasDuplicates(this, logger))
|
||||
{
|
||||
logger.User("File '" + input + "' existed in the DAT, skipping...");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
logger.User("Processing file " + input);
|
||||
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormat.TorrentGzip:
|
||||
success &= ArchiveTools.WriteTorrentGZ(input, outDir, romba, logger);
|
||||
break;
|
||||
case OutputFormat.TorrentZip:
|
||||
success &= ArchiveTools.WriteTorrentZip(input, outDir, rom, logger);
|
||||
break;
|
||||
case OutputFormat.Folder:
|
||||
try
|
||||
{
|
||||
string outfile = Path.Combine(outDir, rom.Machine.Name, rom.Name);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
|
||||
File.Copy(input, outfile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Process the file as an archive, if necessary
|
||||
if (shouldInternalProcess)
|
||||
{
|
||||
// Now, if the file is a supported archive type, also run on all files within
|
||||
bool encounteredErrors = ArchiveTools.ExtractArchive(input, tempDir, archiveScanLevel, logger);
|
||||
|
||||
// If no errors were encountered, we loop through the temp directory
|
||||
if (!encounteredErrors)
|
||||
{
|
||||
logger.Verbose("Archive found! Successfully extracted");
|
||||
foreach (string file in Directory.EnumerateFiles(tempDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
// If a DAT is defined, we want to make sure that this file is not in there
|
||||
Rom rom = FileTools.GetFileInfo(file, logger);
|
||||
rom.Machine = new Machine { Name = Path.GetFileNameWithoutExtension(input) };
|
||||
if (this != null && Files.Count > 0)
|
||||
{
|
||||
if (rom.HasDuplicates(this, logger))
|
||||
{
|
||||
logger.User("File '" + file + "' existed in the DAT, skipping...");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
logger.User("Processing file " + file);
|
||||
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormat.TorrentGzip:
|
||||
success &= ArchiveTools.WriteTorrentGZ(file, outDir, romba, logger);
|
||||
break;
|
||||
case OutputFormat.TorrentZip:
|
||||
success &= ArchiveTools.WriteTorrentZip(file, outDir, rom, logger);
|
||||
break;
|
||||
case OutputFormat.Folder:
|
||||
try
|
||||
{
|
||||
string outfile = Path.Combine(outDir, rom.Machine.Name, rom.Name);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
|
||||
File.Copy(file, outfile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileTools.CleanDirectory(tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the source file if we're supposed to
|
||||
if (delete)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.User("Attempting to delete " + input);
|
||||
File.Delete(input);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.ToString());
|
||||
success &= false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now one final delete of the temp directory
|
||||
while (Directory.Exists(tempDir))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the DAT and find all matches in input files and folders
|
||||
/// </summary>
|
||||
@@ -4464,6 +4282,7 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
|
||||
/// <param name="delete">True if input files should be deleted, false otherwise</param>
|
||||
/// <param name="inverse">True if the DAT should be used as a filter instead of a template, false otherwise</param>
|
||||
/// <param name="outputFormat">Output format that files should be written to</param>
|
||||
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
|
||||
/// <param name="archiveScanLevel">ArchiveScanLevel representing the archive handling levels</param>
|
||||
@@ -4472,8 +4291,8 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if rebuilding was a success, false otherwise</returns>
|
||||
public bool RebuildToOutput(List<string> inputs, string outDir, string tempDir, bool quickScan, bool date,
|
||||
bool delete, OutputFormat outputFormat, bool romba, ArchiveScanLevel archiveScanLevel, bool updateDat, string headerToCheckAgainst,
|
||||
int maxDegreeOfParallelism, Logger logger)
|
||||
bool delete, bool inverse, OutputFormat outputFormat, bool romba, ArchiveScanLevel archiveScanLevel, bool updateDat,
|
||||
string headerToCheckAgainst, int maxDegreeOfParallelism, Logger logger)
|
||||
{
|
||||
#region Perform setup
|
||||
|
||||
@@ -4746,28 +4565,75 @@ namespace SabreTools.Helper.Dats
|
||||
new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism },
|
||||
key =>
|
||||
{
|
||||
// If the input DAT doesn't have the key, then nothing from the current DAT are there
|
||||
if (!Files.ContainsKey(key))
|
||||
// If we are using the DAT as a filter, treat the files one way
|
||||
if (inverse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we try to find duplicates
|
||||
List<DatItem> datItems = current.Files[key];
|
||||
foreach (Rom rom in datItems)
|
||||
{
|
||||
List<DatItem> found = rom.GetDuplicates(this, logger, false);
|
||||
|
||||
// Now add all of the duplicates mapped to the current file
|
||||
foreach (Rom mid in found)
|
||||
// Check for duplicates
|
||||
List<DatItem> datItems = current.Files[key];
|
||||
foreach (Rom rom in datItems)
|
||||
{
|
||||
// If the rom has duplicates, we skip it
|
||||
if (rom.HasDuplicates(this, logger))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, map the file to itself
|
||||
try
|
||||
{
|
||||
toFromMap.Add(mid, rom);
|
||||
Rom newrom = new Rom
|
||||
{
|
||||
Name = rom.Name.Remove(0, Path.GetDirectoryName(rom.Name).Length),
|
||||
Size = rom.Size,
|
||||
CRC = rom.CRC,
|
||||
MD5 = rom.MD5,
|
||||
SHA1 = rom.SHA1,
|
||||
|
||||
Machine = new Machine
|
||||
{
|
||||
Name = Path.GetFileNameWithoutExtension(rom.Machine.Name),
|
||||
},
|
||||
};
|
||||
newrom.Name = newrom.Name.Remove(0, (newrom.Name.StartsWith("\\") || newrom.Name.StartsWith("/") ? 1 : 0));
|
||||
|
||||
lock (toFromMap)
|
||||
{
|
||||
toFromMap.Add(newrom, rom);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, treat it like a standard rebuild
|
||||
else
|
||||
{
|
||||
// If the input DAT doesn't have the key, then nothing from the current DAT are there
|
||||
if (!Files.ContainsKey(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we try to find duplicates
|
||||
List<DatItem> datItems = current.Files[key];
|
||||
foreach (Rom rom in datItems)
|
||||
{
|
||||
List<DatItem> found = rom.GetDuplicates(this, logger, false);
|
||||
|
||||
// Now add all of the duplicates mapped to the current file
|
||||
foreach (Rom mid in found)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (toFromMap)
|
||||
{
|
||||
toFromMap.Add(mid, rom);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
logger.User("Determining complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
@@ -141,85 +141,6 @@ Options:
|
||||
-?, -h, --help Show the built-in help text
|
||||
Built-in to most of the programs is a basic help text
|
||||
|
||||
-cv, --convert Enable conversion of input files to unarchived folders
|
||||
Using a folder or set of folders, rebuild to another folder.
|
||||
|
||||
-dat= Name of the DAT to be used as a filter
|
||||
A supplied DAT file to be used as a filter in conversion. If a file is found in the
|
||||
DAT, it will be skipped on output. This allows convert to act like an anti-sort,
|
||||
useful for finding useless files in an input folder.
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used when the files are created. If a path
|
||||
is not defined, the application directory is used instead.
|
||||
|
||||
-t=, --temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations
|
||||
that require an archive to be extracted.
|
||||
|
||||
-del, --delete Delete input files
|
||||
This is a WIP flag that allows for deletion of input files once they have been
|
||||
rebuilt. It is not recommended for normal use because it does not discriminate
|
||||
whether or not the input files were rebuilt or not before deletion
|
||||
|
||||
-t7z Enable Torrent 7zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent7Zip (T7Z)
|
||||
files. This format is based on the LZMA container format 7zip, but with custom header
|
||||
information. This is currently unused by any major application.
|
||||
|
||||
-tar Enable Tape ARchive output [NOT IMPLEMENTED]
|
||||
Instead of outputting the fiels to folder, files will be rebuilt to Tape ARchive (TAR)
|
||||
files. This format is a standardized storage archive without any compression, usually
|
||||
used with other compression formats around it. It is widely used in backup applications
|
||||
and source code archives.
|
||||
|
||||
-tgz Enable Torrent GZ output
|
||||
Instead of outputting the files to folder, files will be rebuilt to TorrentGZ (TGZ)
|
||||
files. This format is based on the GZip archive format, but with custom header
|
||||
information and a file name replaced by the SHA-1 of the file inside. This is
|
||||
primarily used by external tool Romba (https://github.com/uwedeportivo/romba), but
|
||||
may be used more widely in the future.
|
||||
|
||||
-r, --romba Enable Romba depot directory output
|
||||
As an extension of the parent flag, this outputs the TGZ files into directories
|
||||
based on the structure used by Romba. This uses nested folders using the first
|
||||
4 bytes of the SHA-1, 1 byte for each layer of the directory name. It also
|
||||
includes two auxilary files, .romba_size and .romba_size.backup, that have the
|
||||
compressed size of the folder inside for use with Romba.
|
||||
|
||||
-tlrz Enable Torrent Long-Range Zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent Long-Range
|
||||
Zip (TLRZ) files. This format is based on the LRZip file format as defined at
|
||||
https://github.com/ckolivas/lrzip but with custom header information. This is currently
|
||||
unused by any major application.
|
||||
|
||||
-trar Enable Torrent RAR output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR)
|
||||
files. This format is based on the RAR propietary format but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-txz Enable Torrent XZ output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent XZ (TXZ) files.
|
||||
This format is based on the LZMA container format XZ, but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-tzip Enable Torrent Zip output
|
||||
Instead of ouputting files to folder, files will be rebuilt to TorrentZip (TZ) files.
|
||||
This format is based on the ZIP archive format, but with custom header information.
|
||||
This is primarily used by external tool RomVault (http://www.romvault.com/) and is
|
||||
already widely used.
|
||||
|
||||
-7z={0} Set scanning level for 7z archives
|
||||
-gz={2} Set scanning level for GZip archives
|
||||
-rar={2} Set scanning level for RAR archives
|
||||
-zip={0} Set scanning level for ZIP archives
|
||||
For each of the major archive types recognized by the libraries used by this
|
||||
program, scan the archive in one of the following ways:
|
||||
0 Hash both archive and its contents
|
||||
1 Only hash contents of the archive
|
||||
2 Only hash archive itself (treat like a regular file)
|
||||
|
||||
-d, --dfd Create a DAT from each input directory
|
||||
Create a DAT file from an input directory or set of files. By default, this will
|
||||
output a DAT named based on the input directory and the current date. It will also
|
||||
@@ -436,11 +357,16 @@ Options:
|
||||
(inside the running folder) is not preferred. This is used for any operations that
|
||||
require an archive to be extracted.
|
||||
|
||||
-d, --delete Enable deletion of the input files
|
||||
-d, --delete Enable deletion of the input files [DO NOT USE]
|
||||
Optionally, the input files, once processed, can be deleted. This can be useful
|
||||
when the original file structure is no longer needed or if there is limited space
|
||||
on the source drive.
|
||||
|
||||
-in, --inverse Match files not in the DAT
|
||||
Instead of the normal behavior of rebuilding using a DAT, this flag allows the user
|
||||
to use the DAT as a filter instead. All files that are found in the DAT will be
|
||||
skipped and everything else will be output in the selected format.
|
||||
|
||||
-qs, --quick Enable quick scanning of archives
|
||||
For all archives, if this flag is enabled, it will only use the header information
|
||||
to get the archive entries' file information. The upside to this is that it is much
|
||||
@@ -1048,6 +974,86 @@ Below are originally from SabreTools / DATabase -
|
||||
-clean Clean game names according to WoD standards
|
||||
-out= Output directory
|
||||
out= Output directory
|
||||
|
||||
-cv, --convert Enable conversion of input files to unarchived folders
|
||||
Using a folder or set of folders, rebuild to another folder.
|
||||
|
||||
-dat= Name of the DAT to be used as a filter
|
||||
A supplied DAT file to be used as a filter in conversion. If a file is found in the
|
||||
DAT, it will be skipped on output. This allows convert to act like an anti-sort,
|
||||
useful for finding useless files in an input folder.
|
||||
|
||||
-out= Set the name of the output directory
|
||||
This sets an output folder to be used when the files are created. If a path
|
||||
is not defined, the application directory is used instead.
|
||||
|
||||
-t=, --temp= Set the name of the temporary directory
|
||||
Optionally, a temp folder can be supplied in the case the default temp directory
|
||||
(inside the running folder) is not preferred. This is used for any operations
|
||||
that require an archive to be extracted.
|
||||
|
||||
-del, --delete Delete input files
|
||||
This is a WIP flag that allows for deletion of input files once they have been
|
||||
rebuilt. It is not recommended for normal use because it does not discriminate
|
||||
whether or not the input files were rebuilt or not before deletion
|
||||
|
||||
-t7z Enable Torrent 7zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent7Zip (T7Z)
|
||||
files. This format is based on the LZMA container format 7zip, but with custom header
|
||||
information. This is currently unused by any major application.
|
||||
|
||||
-tar Enable Tape ARchive output [NOT IMPLEMENTED]
|
||||
Instead of outputting the fiels to folder, files will be rebuilt to Tape ARchive (TAR)
|
||||
files. This format is a standardized storage archive without any compression, usually
|
||||
used with other compression formats around it. It is widely used in backup applications
|
||||
and source code archives.
|
||||
|
||||
-tgz Enable Torrent GZ output
|
||||
Instead of outputting the files to folder, files will be rebuilt to TorrentGZ (TGZ)
|
||||
files. This format is based on the GZip archive format, but with custom header
|
||||
information and a file name replaced by the SHA-1 of the file inside. This is
|
||||
primarily used by external tool Romba (https://github.com/uwedeportivo/romba), but
|
||||
may be used more widely in the future.
|
||||
|
||||
-r, --romba Enable Romba depot directory output
|
||||
As an extension of the parent flag, this outputs the TGZ files into directories
|
||||
based on the structure used by Romba. This uses nested folders using the first
|
||||
4 bytes of the SHA-1, 1 byte for each layer of the directory name. It also
|
||||
includes two auxilary files, .romba_size and .romba_size.backup, that have the
|
||||
compressed size of the folder inside for use with Romba.
|
||||
|
||||
-tlrz Enable Torrent Long-Range Zip output [NOT IMPLEMENTED]
|
||||
Instead of ouputting the files to folder, files will be rebuilt to Torrent Long-Range
|
||||
Zip (TLRZ) files. This format is based on the LRZip file format as defined at
|
||||
https://github.com/ckolivas/lrzip but with custom header information. This is currently
|
||||
unused by any major application.
|
||||
|
||||
-trar Enable Torrent RAR output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent RAR (TRAR)
|
||||
files. This format is based on the RAR propietary format but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-txz Enable Torrent XZ output [NOT IMPLEMENTED]
|
||||
Instead of outputting files to folder, files will be rebuilt to Torrent XZ (TXZ) files.
|
||||
This format is based on the LZMA container format XZ, but with custom header
|
||||
information. This is currently unused by any major application;
|
||||
|
||||
-tzip Enable Torrent Zip output
|
||||
Instead of ouputting files to folder, files will be rebuilt to TorrentZip (TZ) files.
|
||||
This format is based on the ZIP archive format, but with custom header information.
|
||||
This is primarily used by external tool RomVault (http://www.romvault.com/) and is
|
||||
already widely used.
|
||||
|
||||
-7z={0} Set scanning level for 7z archives
|
||||
-gz={2} Set scanning level for GZip archives
|
||||
-rar={2} Set scanning level for RAR archives
|
||||
-zip={0} Set scanning level for ZIP archives
|
||||
For each of the major archive types recognized by the libraries used by this
|
||||
program, scan the archive in one of the following ways:
|
||||
0 Hash both archive and its contents
|
||||
1 Only hash contents of the archive
|
||||
2 Only hash archive itself (treat like a regular file)
|
||||
|
||||
-cm, --convert-miss Convert from DAT to miss
|
||||
-r, --roms Output roms to miss instead of sets
|
||||
-gp, --game-prefix Add game name as a prefix to each item
|
||||
|
||||
@@ -13,60 +13,6 @@ namespace SabreTools
|
||||
{
|
||||
#region Init Methods
|
||||
|
||||
/// <summary>
|
||||
/// Wrap converting a folder to TorrentZip or TorrentGZ, optionally filtering by an input DAT(s)
|
||||
/// </summary>
|
||||
/// <param name="datfiles">Names of the DATs to compare against</param>
|
||||
/// <param name="inputs">List of all inputted files and folders</param>
|
||||
/// <param name="outDir">Output directory (empty for default directory)</param>
|
||||
/// <param name="tempDir">Temporary directory for archive extraction</param>
|
||||
/// <param name="delete">True if input files should be deleted, false otherwise</param>
|
||||
/// <param name="outputFormat">Output format that files should be written to</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="gz">Integer representing the archive handling level for GZip</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>
|
||||
public static bool InitConvertFolder(List<string> datfiles, List<string> inputs, string outDir, string tempDir, bool delete,
|
||||
OutputFormat outputFormat, bool romba, int sevenzip, int gz, int rar, int zip)
|
||||
{
|
||||
// Get the archive scanning level
|
||||
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(sevenzip, gz, rar, zip);
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
_logger.User("Populating internal DAT...");
|
||||
|
||||
// Add all of the input DATs into one huge internal DAT
|
||||
DatFile datdata = new DatFile();
|
||||
foreach (string datfile in datfiles)
|
||||
{
|
||||
datdata.Parse(datfile, 99, 99, _logger, keep: true, softlist: true);
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
// Get all individual files from the inputs
|
||||
start = DateTime.Now;
|
||||
_logger.User("Organizing input files...");
|
||||
List<string> newinputs = new List<string>();
|
||||
foreach (string input in inputs)
|
||||
{
|
||||
if (File.Exists(input))
|
||||
{
|
||||
newinputs.Add(Path.GetFullPath(input));
|
||||
}
|
||||
else if (Directory.Exists(input))
|
||||
{
|
||||
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
newinputs.Add(Path.GetFullPath(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
_logger.User("Organizing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
return datdata.ConvertFiles(newinputs, outDir, tempDir, outputFormat, romba, delete, asl, _logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrap creating a DAT file from files or a directory in parallel
|
||||
/// </summary>
|
||||
@@ -308,6 +254,7 @@ namespace SabreTools
|
||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||
/// <param name="date">True if the date from the DAT should be used if available, false otherwise</param>
|
||||
/// <param name="delete">True if input files should be deleted, false otherwise</param>
|
||||
/// <param name="inverse">True if the DAT should be used as a filter instead of a template, false otherwise</param>
|
||||
/// <param name="outputFormat">Output format that files should be written to</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>
|
||||
@@ -318,7 +265,7 @@ namespace SabreTools
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
private static void InitSort(List<string> datfiles, List<string> inputs, string outDir, string tempDir, bool quickScan, bool date, bool delete,
|
||||
OutputFormat outputFormat, bool romba, int sevenzip, int gz, int rar, int zip, bool updateDat, string headerToCheckAgainst,
|
||||
bool inverse, OutputFormat outputFormat, bool romba, int sevenzip, int gz, int rar, int zip, bool updateDat, string headerToCheckAgainst,
|
||||
int maxDegreeOfParallelism)
|
||||
{
|
||||
// Get the archive scanning level
|
||||
@@ -335,7 +282,7 @@ namespace SabreTools
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
datdata.RebuildToOutput(inputs, outDir, tempDir, quickScan, date, delete, outputFormat, romba, asl,
|
||||
datdata.RebuildToOutput(inputs, outDir, tempDir, quickScan, date, delete, inverse, outputFormat, romba, asl,
|
||||
updateDat, headerToCheckAgainst, maxDegreeOfParallelism, _logger);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ namespace SabreTools
|
||||
|
||||
// Feature flags
|
||||
bool help = false,
|
||||
convert = false, // SimpleSort
|
||||
datFromDir = false,
|
||||
headerer = false,
|
||||
sort = false, // SimpleSort
|
||||
@@ -73,6 +72,7 @@ namespace SabreTools
|
||||
enableGzip = false,
|
||||
excludeOf = false,
|
||||
inplace = false,
|
||||
inverse = false, // SimpleSort
|
||||
merge = false,
|
||||
noMD5 = false,
|
||||
noSHA1 = false,
|
||||
@@ -152,10 +152,6 @@ namespace SabreTools
|
||||
case "--help":
|
||||
help = true;
|
||||
break;
|
||||
case "-cv":
|
||||
case "--convert":
|
||||
convert = true;
|
||||
break;
|
||||
case "-d":
|
||||
case "--d2d":
|
||||
case "--dfd":
|
||||
@@ -263,6 +259,10 @@ namespace SabreTools
|
||||
case "--html":
|
||||
statDatFormat = StatDatFormat.HTML;
|
||||
break;
|
||||
case "-in":
|
||||
case "--inverse":
|
||||
inverse = true;
|
||||
break;
|
||||
case "-ip":
|
||||
case "--inplace":
|
||||
inplace = true;
|
||||
@@ -903,7 +903,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// If more than one switch is enabled, show the help screen
|
||||
if (!(convert ^ datFromDir ^ headerer ^ sort ^ splitByExt ^ splitByHash ^ splitByType ^ stats ^ update ^ verify))
|
||||
if (!(datFromDir ^ headerer ^ sort ^ splitByExt ^ splitByHash ^ splitByType ^ stats ^ update ^ verify))
|
||||
{
|
||||
_logger.Error("Only one feature switch is allowed at a time");
|
||||
Build.Help("SabreTools");
|
||||
@@ -923,14 +923,8 @@ namespace SabreTools
|
||||
|
||||
// Now take care of each mode in succesion
|
||||
|
||||
// Convert a folder to TGZ or TorrentZip
|
||||
if (convert)
|
||||
{
|
||||
InitConvertFolder(datfiles, inputs, outDir, tempDir, delete, outputFormat, romba, sevenzip, gz, rar, zip);
|
||||
}
|
||||
|
||||
// Create a DAT from a directory or set of directories
|
||||
else if (datFromDir)
|
||||
if (datFromDir)
|
||||
{
|
||||
InitDatFromDir(inputs,
|
||||
filename,
|
||||
@@ -967,8 +961,8 @@ namespace SabreTools
|
||||
// If we're using the sorter
|
||||
else if (sort)
|
||||
{
|
||||
InitSort(datfiles, inputs, outDir, tempDir, quickScan, addFileDates, delete, outputFormat,
|
||||
romba, sevenzip, gz, rar, zip, updateDat, header, maxParallelism);
|
||||
InitSort(datfiles, inputs, outDir, tempDir, quickScan, addFileDates, delete, inverse,
|
||||
outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, maxParallelism);
|
||||
}
|
||||
|
||||
// Split a DAT by extension
|
||||
|
||||
Reference in New Issue
Block a user