mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, FileTools, README.1ST] Add "don't add to db" flag
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -394,8 +394,9 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="file">Name of the file to be parsed</param>
|
||||
/// <param name="outDir">Output directory to write the file to, empty means the same directory as the input file</param>
|
||||
/// <param name="nostore">True if headers should not be stored in the database, false otherwise</param>
|
||||
/// <returns>True if the output file was created, false otherwise</returns>
|
||||
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
|
||||
if (!nostore)
|
||||
{
|
||||
Rom rom = (Rom)GetFileInfo(newfile, chdsAsFiles: true);
|
||||
DatabaseTools.AddHeaderToDatabase(hstr, rom.SHA1, rule.SourceFile);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,6 +312,11 @@ namespace SabreTools
|
||||
"Output directory",
|
||||
FeatureType.String,
|
||||
null));
|
||||
extract.AddFeature("no-store-header", new Feature(
|
||||
new List<string>() { "-nsh", "--no-store-header" },
|
||||
"Don't store the extracted header",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
|
||||
// Create the Extension Split feature
|
||||
Feature extSplit = new Feature(
|
||||
|
||||
@@ -160,19 +160,20 @@ namespace SabreTools
|
||||
/// </summary>
|
||||
/// <param name="inputs">Input file or folder names</param>
|
||||
/// <param name="outDir">Output directory to write new files to, blank defaults to rom folder</param>
|
||||
private static void InitExtractRemoveHeader(List<string> inputs, string outDir)
|
||||
/// <param name="nostore">True if headers should not be stored in the database, false otherwise</param>
|
||||
private static void InitExtractRemoveHeader(List<string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user