diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs
index 4ba75c14..ed17581b 100644
--- a/SabreTools.Helper/Data/Build.cs
+++ b/SabreTools.Helper/Data/Build.cs
@@ -192,9 +192,8 @@ namespace SabreTools.Helper.Data
helptext.Add(" -extb= Second set of extensions (comma-separated)");
helptext.Add(" -out= Output directory");
- // Headerer
- helptext.Add(" -he, --headerer Extract and remove copier headers");
- helptext.Add(" -r, --restore Restore header to file based on SHA-1 instead");
+ // Extract and Remove Headers
+ helptext.Add(" -ex, --extract Extract and remove copier headers");
helptext.Add(" -out= Output directory");
// Hash Split
@@ -203,9 +202,13 @@ namespace SabreTools.Helper.Data
// Level/SuperDAT Split
helptext.Add(" -ls, --lvl-split Split a SuperDAT or folder by internal path");
- helptext.Add(" -out= Output directory");
- helptext.Add(" -s, --short Use short output names");
- helptext.Add(" -ba, --base Use source DAT as base name for outputs");
+ helptext.Add(" -out= Output directory");
+ helptext.Add(" -s, --short Use short output names");
+ helptext.Add(" -ba, --base Use source DAT as base name for outputs");
+
+ // Restore Headers
+ helptext.Add(" -re, --restore Restore header to file based on SHA-1");
+ helptext.Add(" -out= Output directory");
// Sort
helptext.Add(" -ss, --sort Sort input files by a set of DATs");
@@ -263,7 +266,7 @@ namespace SabreTools.Helper.Data
helptext.Add(" -post=, --postfix= Set postfix for all lines");
helptext.Add(" -q, --quotes Put double-quotes around each item");
helptext.Add(" -ae=, --add-ext= Add an extension to each item");
- helptext.Add(" -re=, --rep-ext= Replace all extensions with specified");
+ helptext.Add(" -rep=, --rep-ext= Replace all extensions with specified");
helptext.Add(" -rme, --rem-ext Remove all extensions from each item");
helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)");
helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format");
diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST
index 17951985..ea3bf636 100644
--- a/SabreTools.Helper/README.1ST
+++ b/SabreTools.Helper/README.1ST
@@ -296,17 +296,13 @@ Options:
-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.
-
- -hd, --headerer Backup or restore copier headers from a variety of file types
- Headerer 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
+
+ -ex, --extract Backup and remove copier headers from a variety of file types
+ 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
@@ -317,12 +313,6 @@ Options:
- 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.
-
-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.
@@ -359,6 +349,26 @@ Options:
since the names would be the same. With this flag, the original DAT name is used in
the output name, in the format of "Original Name (Dir - Name)". This can be used in
conjunction with --short to output in the format of "Original Name (Name)" instead.
+
+ -re, --restore Restore copier headers from a variety of file types
+ This will make use of stored copier headers and 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.
+
+ 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
+
+ -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.
-ss, --sort Sort input files by a set of DATs
This feature allows the user to quickly rebuild based on a supplied DAT file(s). By
@@ -1247,6 +1257,36 @@ Below are originally from SabreTools / DATabase -
DAT outputs. If this flag is enabled, a clrmamepro DAT will be created instead.
-old, --romvault Produce a DAT in RV format
+
+ -hd, --headerer Backup or restore copier headers from a variety of file types
+ Headerer 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.
+
+ -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.
-i, -import Start tool in import mode
This starts the tool in DATabase import mode. This will allow for hashing of new
diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs
index c215b768..ddbc971a 100644
--- a/SabreTools/Partials/SabreTools_Inits.cs
+++ b/SabreTools/Partials/SabreTools_Inits.cs
@@ -137,6 +137,29 @@ namespace SabreTools
}
}
+ ///
+ /// Wrap extracting headers
+ ///
+ /// Input file or folder names
+ /// Output directory to write new files to, blank defaults to rom folder
+ private static void InitExtractRemoveHeader(List inputs, string outDir)
+ {
+ foreach (string input in inputs)
+ {
+ if (File.Exists(input))
+ {
+ FileTools.DetectSkipperAndTransform(input, outDir, _logger);
+ }
+ else if (Directory.Exists(input))
+ {
+ foreach (string sub in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
+ {
+ FileTools.DetectSkipperAndTransform(sub, outDir, _logger);
+ }
+ }
+ }
+ }
+
///
/// Wrap splitting a DAT by 2 extensions
///
@@ -214,38 +237,23 @@ namespace SabreTools
}
///
- /// Wrap extracting and replacing headers
+ /// Wrap replacing headers
///
/// Input file or folder names
- /// False if we're extracting headers (default), true if we're restoring them
/// Output directory to write new files to, blank defaults to rom folder
- private static void InitHeaderer(List inputs, bool restore, string outDir)
+ private static void InitReplaceHeader(List inputs, string outDir)
{
foreach (string input in inputs)
{
if (File.Exists(input))
{
- if (restore)
- {
- FileTools.RestoreHeader(input, outDir, _logger);
- }
- else
- {
- FileTools.DetectSkipperAndTransform(input, outDir, _logger);
- }
+ FileTools.RestoreHeader(input, outDir, _logger);
}
else if (Directory.Exists(input))
{
foreach (string sub in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
- if (restore)
- {
- FileTools.RestoreHeader(sub, outDir, _logger);
- }
- else
- {
- FileTools.DetectSkipperAndTransform(sub, outDir, _logger);
- }
+ FileTools.RestoreHeader(sub, outDir, _logger);
}
}
}
diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs
index c581cb2f..14e60aa7 100644
--- a/SabreTools/SabreTools.cs
+++ b/SabreTools/SabreTools.cs
@@ -56,7 +56,8 @@ namespace SabreTools
// Feature flags
bool help = false,
datFromDir = false,
- headerer = false,
+ extract = false,
+ restore = false,
sort = false, // SimpleSort
splitByExt = false,
splitByHash = false,
@@ -87,7 +88,6 @@ namespace SabreTools
quotes = false,
remext = false,
removeDateFromAutomaticName = false,
- restore = false,
romba = false,
showBaddumpColumn = false,
showNodumpColumn = false,
@@ -168,9 +168,9 @@ namespace SabreTools
case "--ext-split":
splitByExt = true;
break;
- case "-hd":
- case "--headerer":
- headerer = true;
+ case "-ex":
+ case "--extract":
+ extract = true;
break;
case "-hs":
case "--hash-split":
@@ -180,6 +180,10 @@ namespace SabreTools
case "--lvl-split":
splitByLevel = true;
break;
+ case "-re":
+ case "--restore":
+ restore = true;
+ break;
case "-ss":
case "--sort":
sort = true;
@@ -374,10 +378,6 @@ namespace SabreTools
case "--rev-cascade":
diffMode |= DiffMode.ReverseCascade;
break;
- case "-re":
- case "--restore":
- restore = true;
- break;
case "-rme":
case "--rem-ext":
remext = true;
@@ -833,7 +833,7 @@ namespace SabreTools
case "--root-dir":
root = split[1];
break;
- case "-re":
+ case "-rep":
case "--rep-ext":
repext = split[1];
break;
@@ -926,7 +926,7 @@ namespace SabreTools
}
// If more than one switch is enabled, show the help screen
- if (!(datFromDir ^ headerer ^ sort ^ splitByExt ^ splitByHash ^ splitByLevel ^ splitByType ^ stats ^ update ^ verify))
+ if (!(datFromDir ^ extract ^ restore ^ sort ^ splitByExt ^ splitByHash ^ splitByLevel ^ splitByType ^ stats ^ update ^ verify))
{
_logger.Error("Only one feature switch is allowed at a time");
Build.Help("SabreTools");
@@ -936,7 +936,7 @@ namespace SabreTools
// If a switch that requires a filename is set and no file is, show the help screen
if (inputs.Count == 0
- && (datFromDir || headerer || splitByExt || splitByHash || splitByLevel || splitByType || stats || update))
+ && (datFromDir || extract || restore || splitByExt || splitByHash || splitByLevel || splitByType || stats || update))
{
_logger.Error("This feature requires at least one input");
Build.Help("SabreTools");
@@ -975,10 +975,16 @@ namespace SabreTools
maxParallelism);
}
- // If we're in headerer mode
- else if (headerer)
+ // If we're in header extract and remove mode
+ else if (extract)
{
- InitHeaderer(inputs, restore, outDir);
+ InitExtractRemoveHeader(inputs, outDir);
+ }
+
+ // If we're in header restore mode
+ else if (restore)
+ {
+ InitReplaceHeader(inputs, outDir);
}
// If we're using the sorter