diff --git a/SabreTools.Library/README.1ST b/SabreTools.Library/README.1ST index 3a0139bb..4dfe4e7a 100644 --- a/SabreTools.Library/README.1ST +++ b/SabreTools.Library/README.1ST @@ -405,6 +405,11 @@ Options: 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. + -nsh, --no-store-header Don't store the extracted header + By default, all headers that are removed from files are backed up in + the database. This flag allows users to skip that step entirely, + avoiding caching the headers at all. + -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 each file within. The order of preference for the diff --git a/SabreTools.Library/Tools/FileTools.cs b/SabreTools.Library/Tools/FileTools.cs index e7e37437..0340356d 100644 --- a/SabreTools.Library/Tools/FileTools.cs +++ b/SabreTools.Library/Tools/FileTools.cs @@ -394,8 +394,9 @@ namespace SabreTools.Library.Tools /// /// Name of the file to be parsed /// Output directory to write the file to, empty means the same directory as the input file + /// True if headers should not be stored in the database, false otherwise /// True if the output file was created, false otherwise - public static bool DetectSkipperAndTransform(string file, string outDir) + public static bool DetectSkipperAndTransform(string file, string outDir, bool nostore) { // Create the output directory if it doesn't exist if (outDir != "" && !Directory.Exists(outDir)) @@ -439,8 +440,11 @@ namespace SabreTools.Library.Tools } // Now add the information to the database if it's not already there - Rom rom = (Rom)GetFileInfo(newfile, chdsAsFiles: true); - DatabaseTools.AddHeaderToDatabase(hstr, rom.SHA1, rule.SourceFile); + if (!nostore) + { + Rom rom = (Rom)GetFileInfo(newfile, chdsAsFiles: true); + DatabaseTools.AddHeaderToDatabase(hstr, rom.SHA1, rule.SourceFile); + } return true; } diff --git a/SabreTools/SabreTools.Help.cs b/SabreTools/SabreTools.Help.cs index d6c85760..de7fd5ab 100644 --- a/SabreTools/SabreTools.Help.cs +++ b/SabreTools/SabreTools.Help.cs @@ -312,6 +312,11 @@ namespace SabreTools "Output directory", FeatureType.String, null)); + extract.AddFeature("no-store-header", new Feature( + new List() { "-nsh", "--no-store-header" }, + "Don't store the extracted header", + FeatureType.Flag, + null)); // Create the Extension Split feature Feature extSplit = new Feature( diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs index 27c84c5e..01b38cc4 100644 --- a/SabreTools/SabreTools.Inits.cs +++ b/SabreTools/SabreTools.Inits.cs @@ -160,19 +160,20 @@ namespace SabreTools /// /// 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) + /// True if headers should not be stored in the database, false otherwise + private static void InitExtractRemoveHeader(List inputs, string outDir, bool nostore) { foreach (string input in inputs) { if (File.Exists(input)) { - FileTools.DetectSkipperAndTransform(input, outDir); + FileTools.DetectSkipperAndTransform(input, outDir, nostore); } else if (Directory.Exists(input)) { foreach (string sub in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories)) { - FileTools.DetectSkipperAndTransform(sub, outDir); + FileTools.DetectSkipperAndTransform(sub, outDir, nostore); } } } diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index e852a407..0f8b9860 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -103,6 +103,7 @@ namespace SabreTools inplace = true, inverse = false, merge = false, + nostore = false, oneGameOneRegion = false, quickScan = false, quotes = false, @@ -436,6 +437,10 @@ namespace SabreTools case "--noSHA512": omitFromScan &= ~Hash.SHA512; // This needs to be inverted later break; + case "-nsh": + case "--no-store-header": + nostore = true; + break; case "-oa": case "--output-all": datFormat |= DatFormat.ALL; @@ -1261,7 +1266,7 @@ namespace SabreTools // If we're in header extract and remove mode else if (extract) { - InitExtractRemoveHeader(inputs, outDir); + InitExtractRemoveHeader(inputs, outDir, nostore); } // If we're in header restore mode