mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools] Integrate Headerer
This commit is contained in:
@@ -70,6 +70,7 @@ namespace SabreTools
|
|||||||
extract = true;
|
extract = true;
|
||||||
break;
|
break;
|
||||||
case "-r":
|
case "-r":
|
||||||
|
case "-re":
|
||||||
case "--restore":
|
case "--restore":
|
||||||
extract = false;
|
extract = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -410,6 +410,32 @@ Options:
|
|||||||
As a holdover from only two output formats, this tool defaults to Logiqx XML
|
As a holdover from only two output formats, this tool defaults to Logiqx XML
|
||||||
DAT outputs. If this flag is enabled, a clrmamepro DAT will be created instead.
|
DAT outputs. If this flag is enabled, a clrmamepro DAT will be created instead.
|
||||||
|
|
||||||
|
-hd, --headerer Backup or restore copier headers from a variety of file types
|
||||||
|
Headerer is formerly a small program that is meant as an intermediary between header
|
||||||
|
skipper files (which, a bit apart from their name, do not just show how to skip
|
||||||
|
copier headers) and rom managers that do not use them.
|
||||||
|
|
||||||
|
By default, this will detect, store, and remove copier headers from a file or folder
|
||||||
|
of files. The headers are backed up and collated by the hash of the unheadered file.
|
||||||
|
Files are then output without the detected copier header alongside the originals with
|
||||||
|
the suffix .new. No input files are altered in the process.
|
||||||
|
|
||||||
|
The following systems have headers that this program can work with:
|
||||||
|
- Atari 7800
|
||||||
|
- Atari Lynx
|
||||||
|
- Commodore PSID Music
|
||||||
|
- NEC PC-Engine / TurboGrafx 16
|
||||||
|
- Nintendo Famicom / Nintendo Entertainment System
|
||||||
|
- Nintendo Famicom Disk System
|
||||||
|
- Nintendo Super Famicom / Super Nintendo Entertainment System
|
||||||
|
- Nintendo Super Famicom / Super Nintendo Entertainment System SPC Music
|
||||||
|
|
||||||
|
-re, --restore Restore headers to file(s)
|
||||||
|
Instead of the default extraction, this flag enables use of stored copier headers
|
||||||
|
to reapply them to files if they match the included hash. More than one header can
|
||||||
|
be applied to a file, so they will be output to new files, suffixed with .newX,
|
||||||
|
where X is a number. No input files are altered in the process.
|
||||||
|
|
||||||
-hs, --hash-split Split a DAT or folder by best-available hashes
|
-hs, --hash-split Split a DAT or folder by best-available hashes
|
||||||
For a DAT, or set of DATs, allow for splitting based on the best available hash for
|
For a DAT, or set of DATs, allow for splitting based on the best available hash for
|
||||||
each file within. The order of preference for the outputted DATs is as follows:
|
each file within. The order of preference for the outputted DATs is as follows:
|
||||||
|
|||||||
@@ -317,13 +317,16 @@ namespace SabreTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrap extracting and replacing headers
|
/// Wrap extracting and replacing headers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">Input file or folder name</param>
|
/// <param name="inputs">Input file or folder names</param>
|
||||||
/// <param name="extract">True if we're extracting headers (default), false if we're replacing them</param>
|
/// <param name="extract">True if we're extracting headers (default), false if we're replacing them</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 InitHeaderer(string input, bool extract, Logger logger)
|
private static void InitHeaderer(List<string> inputs, bool extract, Logger logger)
|
||||||
{
|
{
|
||||||
Headerer headerer = new Headerer(input, extract, logger);
|
foreach (string input in inputs)
|
||||||
headerer.Process();
|
{
|
||||||
|
Headerer headerer = new Headerer(input, extract, logger);
|
||||||
|
headerer.Process();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -93,11 +93,13 @@ namespace SabreTools
|
|||||||
datprefix = false,
|
datprefix = false,
|
||||||
dedup = false,
|
dedup = false,
|
||||||
enableGzip = false,
|
enableGzip = false,
|
||||||
|
extract = true,
|
||||||
extsplit = false,
|
extsplit = false,
|
||||||
forceunpack = false,
|
forceunpack = false,
|
||||||
generate = false,
|
generate = false,
|
||||||
genall = false,
|
genall = false,
|
||||||
hashsplit = false,
|
hashsplit = false,
|
||||||
|
headerer = false,
|
||||||
ignore = false,
|
ignore = false,
|
||||||
import = false,
|
import = false,
|
||||||
inplace = false,
|
inplace = false,
|
||||||
@@ -273,6 +275,10 @@ namespace SabreTools
|
|||||||
case "--gz-files":
|
case "--gz-files":
|
||||||
enableGzip = true;
|
enableGzip = true;
|
||||||
break;
|
break;
|
||||||
|
case "-hd":
|
||||||
|
case "--headerer":
|
||||||
|
headerer = true;
|
||||||
|
break;
|
||||||
case "-hs":
|
case "-hs":
|
||||||
case "--hash-split":
|
case "--hash-split":
|
||||||
hashsplit = true;
|
hashsplit = true;
|
||||||
@@ -369,6 +375,10 @@ namespace SabreTools
|
|||||||
case "--rev-cascade":
|
case "--rev-cascade":
|
||||||
cascade = false;
|
cascade = false;
|
||||||
break;
|
break;
|
||||||
|
case "-re":
|
||||||
|
case "--restore":
|
||||||
|
extract = false;
|
||||||
|
break;
|
||||||
case "-rm":
|
case "-rm":
|
||||||
case "--remove":
|
case "--remove":
|
||||||
rem = true;
|
rem = true;
|
||||||
@@ -622,8 +632,8 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If more than one switch is enabled, show the help screen
|
// If more than one switch is enabled, show the help screen
|
||||||
if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^
|
if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ headerer ^ import ^ listsrc ^
|
||||||
(merge || diffMode != 0 || update || outputFormat != 0 || tsv != null|| trim) ^ rem ^ stats ^ typesplit))
|
listsys ^ (merge || diffMode != 0 || update || outputFormat != 0 || tsv != null|| trim) ^ rem ^ stats ^ typesplit))
|
||||||
{
|
{
|
||||||
_logger.Error("Only one feature switch is allowed at a time");
|
_logger.Error("Only one feature switch is allowed at a time");
|
||||||
Build.Help();
|
Build.Help();
|
||||||
@@ -632,8 +642,8 @@ 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 && (update || outputFormat != 0 || tsv != null || extsplit || hashsplit || datfromdir
|
if (inputs.Count == 0 && (datfromdir || datfromdirparallel || extsplit || hashsplit || headerer
|
||||||
|| datfromdirparallel || (merge || diffMode != 0) || stats || trim || typesplit))
|
|| (merge || diffMode != 0 || update || outputFormat != 0 || tsv != null) || stats || trim || typesplit))
|
||||||
{
|
{
|
||||||
_logger.Error("This feature requires at least one input");
|
_logger.Error("This feature requires at least one input");
|
||||||
Build.Help();
|
Build.Help();
|
||||||
@@ -643,10 +653,48 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now take care of each mode in succesion
|
// Now take care of each mode in succesion
|
||||||
|
|
||||||
// Import a file or folder
|
// Add a source or system
|
||||||
if (import)
|
if (add)
|
||||||
|
{
|
||||||
|
if (manu != "" && systems != "")
|
||||||
|
{
|
||||||
|
InitAddSystem(manu, systems);
|
||||||
|
}
|
||||||
|
else if (sources != "" && url != "")
|
||||||
|
{
|
||||||
|
InitAddSource(manu, systems);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Build.Help();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a DAT from a directory or set of directories
|
||||||
|
else if (datfromdir)
|
||||||
|
{
|
||||||
|
InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
|
||||||
|
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a DAT from a directory or set of directories in parallel
|
||||||
|
else if (datfromdirparallel)
|
||||||
|
{
|
||||||
|
InitDatFromDirParallel(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
|
||||||
|
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir, maxParallelism);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split a DAT by extension
|
||||||
|
else if (extsplit)
|
||||||
|
{
|
||||||
|
InitExtSplit(inputs, exta, extb, outdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate all DATs
|
||||||
|
else if (genall)
|
||||||
{
|
{
|
||||||
InitImport(ignore);
|
InitImport(ignore);
|
||||||
|
InitGenerateAll(norename, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a DAT
|
// Generate a DAT
|
||||||
@@ -656,11 +704,22 @@ namespace SabreTools
|
|||||||
InitGenerate(systems, norename, old);
|
InitGenerate(systems, norename, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate all DATs
|
// Split a DAT by available hashes
|
||||||
else if (genall)
|
else if (hashsplit)
|
||||||
|
{
|
||||||
|
InitHashSplit(inputs, outdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're in headerer mode
|
||||||
|
else if (headerer)
|
||||||
|
{
|
||||||
|
InitHeaderer(inputs, extract, _logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import a file or folder
|
||||||
|
else if (import)
|
||||||
{
|
{
|
||||||
InitImport(ignore);
|
InitImport(ignore);
|
||||||
InitGenerateAll(norename, old);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List all available sources
|
// List all available sources
|
||||||
@@ -675,32 +734,6 @@ namespace SabreTools
|
|||||||
ListSystems();
|
ListSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert, update, merge, diff, and filter a DAT or folder of DATs
|
|
||||||
else if (update || tsv != null || outputFormat != 0 || merge || diffMode != 0)
|
|
||||||
{
|
|
||||||
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
|
|
||||||
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
|
|
||||||
postfix, quotes, repext, addext, remext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
|
|
||||||
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a source or system
|
|
||||||
else if (add)
|
|
||||||
{
|
|
||||||
if (manu != "" && systems != "")
|
|
||||||
{
|
|
||||||
InitAddSystem(manu, systems);
|
|
||||||
}
|
|
||||||
else if (sources != "" && url != "")
|
|
||||||
{
|
|
||||||
InitAddSource(manu, systems);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Build.Help();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove a source or system
|
// Remove a source or system
|
||||||
else if (rem)
|
else if (rem)
|
||||||
{
|
{
|
||||||
@@ -718,16 +751,10 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split a DAT by extension
|
// Get statistics on input files
|
||||||
else if (extsplit)
|
else if (stats)
|
||||||
{
|
{
|
||||||
InitExtSplit(inputs, exta, extb, outdir);
|
InitStats(inputs, single);
|
||||||
}
|
|
||||||
|
|
||||||
// Split a DAT by available hashes
|
|
||||||
else if (hashsplit)
|
|
||||||
{
|
|
||||||
InitHashSplit(inputs, outdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split a DAT by item type
|
// Split a DAT by item type
|
||||||
@@ -736,24 +763,13 @@ namespace SabreTools
|
|||||||
InitTypeSplit(inputs, outdir);
|
InitTypeSplit(inputs, outdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get statistics on input files
|
// Convert, update, merge, diff, and filter a DAT or folder of DATs
|
||||||
else if (stats)
|
else if (update || tsv != null || outputFormat != 0 || merge || diffMode != 0)
|
||||||
{
|
{
|
||||||
InitStats(inputs, single);
|
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
|
||||||
}
|
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
|
||||||
|
postfix, quotes, repext, addext, remext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
|
||||||
// Create a DAT from a directory or set of directories
|
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism);
|
||||||
else if (datfromdir)
|
|
||||||
{
|
|
||||||
InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
|
|
||||||
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a DAT from a directory or set of directories in parallel
|
|
||||||
else if (datfromdirparallel)
|
|
||||||
{
|
|
||||||
InitDatFromDirParallel(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
|
|
||||||
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempdir, maxParallelism);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If nothing is set, show the help
|
// If nothing is set, show the help
|
||||||
|
|||||||
Reference in New Issue
Block a user