mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Flags, DatFile, SabreTools] Merge as an update flag; reorganize
This commit is contained in:
@@ -1563,7 +1563,6 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="inputPaths">Names of the input files and/or folders</param>
|
||||
/// <param name="basePaths">Names of base files and/or folders</param>
|
||||
/// <param name="outDir">Optional param for output directory</param>
|
||||
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
|
||||
/// <param name="updateMode">Non-zero flag for diffing mode, zero otherwise</param>
|
||||
/// <param name="inplace">True if the output files should overwrite their inputs, false otherwise</param>
|
||||
/// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
|
||||
@@ -1576,64 +1575,62 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="trim">True if we are supposed to trim names to NTFS length, false otherwise</param>
|
||||
/// <param name="single">True if all games should be replaced by '!', false otherwise</param>
|
||||
/// <param name="root">String representing root directory to compare against for length calculation</param>
|
||||
public void DetermineUpdateType(List<string> inputPaths, List<string> basePaths, string outDir, bool merge, UpdateMode updateMode, bool inplace, bool skip,
|
||||
public void DetermineUpdateType(List<string> inputPaths, List<string> basePaths, string outDir, UpdateMode updateMode, bool inplace, bool skip,
|
||||
bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, bool trim, bool single, string root)
|
||||
{
|
||||
// If we're in merging or diffing mode, use the full list of inputs
|
||||
if (merge || (updateMode != UpdateMode.None
|
||||
&& (updateMode & UpdateMode.DiffAgainst) == 0)
|
||||
&& (updateMode & UpdateMode.BaseReplace) == 0
|
||||
&& (updateMode & UpdateMode.ReverseBaseReplace) == 0)
|
||||
// If we're in standard update mode, run through all of the inputs
|
||||
if (updateMode == UpdateMode.None)
|
||||
{
|
||||
Update(inputPaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||
}
|
||||
// Otherwise, we're in one of the special modes
|
||||
else
|
||||
{
|
||||
// Make sure there are no folders in inputs
|
||||
List<string> newInputFileNames = Utilities.GetOnlyFilesFromInputs(inputPaths, appendparent: true);
|
||||
|
||||
// Reverse if we have to
|
||||
// Reverse if we're in a required mode
|
||||
if ((updateMode & UpdateMode.DiffReverseCascade) != 0)
|
||||
{
|
||||
newInputFileNames.Reverse();
|
||||
}
|
||||
|
||||
// Create a dictionary of all ROMs from the input DATs
|
||||
// Populate the combined data and get the headers
|
||||
List<DatFile> datHeaders = PopulateUserData(newInputFileNames, inplace, clean,
|
||||
remUnicode, descAsName, outDir, filter, splitType, trim, single, root);
|
||||
remUnicode, descAsName, outDir, filter, splitType, trim, single, root);
|
||||
|
||||
// Modify the Dictionary if necessary and output the results
|
||||
if (updateMode != 0 && updateMode < UpdateMode.DiffCascade)
|
||||
{
|
||||
DiffNoCascade(updateMode, outDir, newInputFileNames);
|
||||
}
|
||||
// If we're in cascade and diff, output only cascaded diffs
|
||||
else if (updateMode != 0 && updateMode >= UpdateMode.DiffCascade)
|
||||
{
|
||||
DiffCascade(outDir, inplace, newInputFileNames, datHeaders, skip);
|
||||
}
|
||||
// Output all entries with user-defined merge
|
||||
else
|
||||
// If we're in merging mode
|
||||
if ((updateMode & UpdateMode.Merge) != 0)
|
||||
{
|
||||
MergeNoDiff(outDir, newInputFileNames, datHeaders);
|
||||
}
|
||||
// If we have one of the standard diffing modes
|
||||
else if ((updateMode & UpdateMode.DiffDupesOnly) != 0
|
||||
|| (updateMode & UpdateMode.DiffNoDupesOnly) != 0
|
||||
|| (updateMode & UpdateMode.DiffIndividualsOnly) != 0)
|
||||
{
|
||||
DiffNoCascade(updateMode, outDir, newInputFileNames);
|
||||
}
|
||||
// If we have one of the cascaded diffing modes
|
||||
else if ((updateMode & UpdateMode.DiffCascade) != 0
|
||||
|| (updateMode & UpdateMode.DiffReverseCascade) != 0)
|
||||
{
|
||||
DiffCascade(outDir, inplace, newInputFileNames, datHeaders, skip);
|
||||
}
|
||||
// If we have diff against mode
|
||||
else if ((updateMode & UpdateMode.DiffAgainst) != 0)
|
||||
{
|
||||
DiffAgainst(inputPaths, basePaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||
}
|
||||
// If we have one of the base replacement modes
|
||||
else if ((updateMode & UpdateMode.BaseReplace) != 0
|
||||
|| (updateMode & UpdateMode.ReverseBaseReplace) != 0)
|
||||
{
|
||||
bool brrev = (updateMode & UpdateMode.ReverseBaseReplace) != 0;
|
||||
BaseReplace(inputPaths, basePaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root, brrev);
|
||||
}
|
||||
}
|
||||
// If we're in "diff against" mode, we treat the inputs differently
|
||||
else if ((updateMode & UpdateMode.DiffAgainst) != 0)
|
||||
{
|
||||
DiffAgainst(inputPaths, basePaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||
}
|
||||
// If we're in "base replacement" mode, we treat the inputs differently
|
||||
else if ((updateMode & UpdateMode.BaseReplace) != 0)
|
||||
{
|
||||
BaseReplace(inputPaths, basePaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root, false);
|
||||
}
|
||||
// If we're in "reverse base replacement" mode, we treat the inputs differently
|
||||
else if ((updateMode & UpdateMode.ReverseBaseReplace) != 0)
|
||||
{
|
||||
BaseReplace(inputPaths, basePaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root, true);
|
||||
}
|
||||
// Otherwise, loop through all of the inputs individually
|
||||
else
|
||||
{
|
||||
Update(inputPaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,8 @@ namespace SabreTools.Library.Data
|
||||
DiffAgainst = DiffReverseCascade << 1,
|
||||
|
||||
// Special update modes
|
||||
BaseReplace = DiffAgainst << 1,
|
||||
Merge = DiffAgainst << 1,
|
||||
BaseReplace = Merge << 1,
|
||||
ReverseBaseReplace = BaseReplace << 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -300,8 +300,7 @@ namespace SabreTools
|
||||
/// <param name="datprefix">Add the dat name as a directory prefix</param>
|
||||
/// <param name="romba">Output files in romba format</param>
|
||||
/// /* Merging and Diffing info */
|
||||
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
|
||||
/// <param name="diffMode">Non-zero flag for diffing mode, zero otherwise</param>
|
||||
/// <param name="updateMode">Non-zero flag for diffing mode, zero otherwise</param>
|
||||
/// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param>
|
||||
/// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
|
||||
/// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param>
|
||||
@@ -357,8 +356,7 @@ namespace SabreTools
|
||||
bool romba,
|
||||
|
||||
/* Merging and Diffing info */
|
||||
bool merge,
|
||||
UpdateMode diffMode,
|
||||
UpdateMode updateMode,
|
||||
bool inplace,
|
||||
bool skip,
|
||||
bool bare,
|
||||
@@ -389,8 +387,8 @@ namespace SabreTools
|
||||
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
|
||||
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
|
||||
|
||||
// If we're in merge or diff mode and the names aren't set, set defaults
|
||||
if (merge || diffMode != 0)
|
||||
// If we're in a special update mode and the names aren't set, set defaults
|
||||
if (updateMode != 0)
|
||||
{
|
||||
// Get the values that will be used
|
||||
if (date == "")
|
||||
@@ -399,17 +397,17 @@ namespace SabreTools
|
||||
}
|
||||
if (name == "")
|
||||
{
|
||||
name = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup != DedupeType.None ? "-deduped" : "");
|
||||
name = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup != DedupeType.None ? "-deduped" : "");
|
||||
}
|
||||
if (description == "")
|
||||
{
|
||||
description = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup != DedupeType.None ? " - deduped" : "");
|
||||
description = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup != DedupeType.None ? " - deduped" : "");
|
||||
if (!bare)
|
||||
{
|
||||
description += " (" + date + ")";
|
||||
}
|
||||
}
|
||||
if (category == "" && diffMode != 0)
|
||||
if (category == "" && updateMode != 0)
|
||||
{
|
||||
category = "DiffDAT";
|
||||
}
|
||||
@@ -456,7 +454,7 @@ namespace SabreTools
|
||||
Romba = romba,
|
||||
};
|
||||
|
||||
userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, merge, diffMode, inplace, skip, bare, clean,
|
||||
userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, updateMode, inplace, skip, bare, clean,
|
||||
remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ namespace SabreTools
|
||||
hashOnly = false,
|
||||
inplace = false,
|
||||
inverse = false,
|
||||
merge = false,
|
||||
nostore = false,
|
||||
quickScan = false,
|
||||
quotes = false,
|
||||
@@ -398,7 +397,7 @@ namespace SabreTools
|
||||
break;
|
||||
case "-m":
|
||||
case "--merge":
|
||||
merge = true;
|
||||
updateMode |= UpdateMode.Merge;
|
||||
break;
|
||||
case "-nc":
|
||||
case "--nodump-col":
|
||||
@@ -1302,7 +1301,7 @@ namespace SabreTools
|
||||
{
|
||||
InitUpdate(inputs, basePaths, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
|
||||
superdat, forcemerge, forcend, forcepack, excludeOf, sceneDateStrip, datFormat, usegame, prefix, postfix, quotes, repext, addext, remext,
|
||||
datPrefix, romba, merge, updateMode, inplace, skip, removeDateFromAutomaticName, filter, splitType, trim, single, root, outDir,
|
||||
datPrefix, romba, updateMode, inplace, skip, removeDateFromAutomaticName, filter, splitType, trim, single, root, outDir,
|
||||
cleanGameNames, removeUnicode, descAsName, dedup, stripHash);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user