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="inputPaths">Names of the input files and/or folders</param>
|
||||||
/// <param name="basePaths">Names of base 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="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="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="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>
|
/// <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="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="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>
|
/// <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)
|
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 we're in standard update mode, run through all of the inputs
|
||||||
if (merge || (updateMode != UpdateMode.None
|
if (updateMode == UpdateMode.None)
|
||||||
&& (updateMode & UpdateMode.DiffAgainst) == 0)
|
{
|
||||||
&& (updateMode & UpdateMode.BaseReplace) == 0
|
Update(inputPaths, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||||
&& (updateMode & UpdateMode.ReverseBaseReplace) == 0)
|
}
|
||||||
|
// Otherwise, we're in one of the special modes
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Make sure there are no folders in inputs
|
// Make sure there are no folders in inputs
|
||||||
List<string> newInputFileNames = Utilities.GetOnlyFilesFromInputs(inputPaths, appendparent: true);
|
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)
|
if ((updateMode & UpdateMode.DiffReverseCascade) != 0)
|
||||||
{
|
{
|
||||||
newInputFileNames.Reverse();
|
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,
|
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 we're in merging mode
|
||||||
if (updateMode != 0 && updateMode < UpdateMode.DiffCascade)
|
if ((updateMode & UpdateMode.Merge) != 0)
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
MergeNoDiff(outDir, newInputFileNames, datHeaders);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,8 @@ namespace SabreTools.Library.Data
|
|||||||
DiffAgainst = DiffReverseCascade << 1,
|
DiffAgainst = DiffReverseCascade << 1,
|
||||||
|
|
||||||
// Special update modes
|
// Special update modes
|
||||||
BaseReplace = DiffAgainst << 1,
|
Merge = DiffAgainst << 1,
|
||||||
|
BaseReplace = Merge << 1,
|
||||||
ReverseBaseReplace = BaseReplace << 1,
|
ReverseBaseReplace = BaseReplace << 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,8 +300,7 @@ namespace SabreTools
|
|||||||
/// <param name="datprefix">Add the dat name as a directory prefix</param>
|
/// <param name="datprefix">Add the dat name as a directory prefix</param>
|
||||||
/// <param name="romba">Output files in romba format</param>
|
/// <param name="romba">Output files in romba format</param>
|
||||||
/// /* Merging and Diffing info */
|
/// /* Merging and Diffing info */
|
||||||
/// <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="diffMode">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="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="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>
|
/// <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,
|
bool romba,
|
||||||
|
|
||||||
/* Merging and Diffing info */
|
/* Merging and Diffing info */
|
||||||
bool merge,
|
UpdateMode updateMode,
|
||||||
UpdateMode diffMode,
|
|
||||||
bool inplace,
|
bool inplace,
|
||||||
bool skip,
|
bool skip,
|
||||||
bool bare,
|
bool bare,
|
||||||
@@ -389,8 +387,8 @@ namespace SabreTools
|
|||||||
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
|
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
|
||||||
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
|
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
|
||||||
|
|
||||||
// If we're in merge or diff mode and the names aren't set, set defaults
|
// If we're in a special update mode and the names aren't set, set defaults
|
||||||
if (merge || diffMode != 0)
|
if (updateMode != 0)
|
||||||
{
|
{
|
||||||
// Get the values that will be used
|
// Get the values that will be used
|
||||||
if (date == "")
|
if (date == "")
|
||||||
@@ -399,17 +397,17 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
if (name == "")
|
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 == "")
|
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)
|
if (!bare)
|
||||||
{
|
{
|
||||||
description += " (" + date + ")";
|
description += " (" + date + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (category == "" && diffMode != 0)
|
if (category == "" && updateMode != 0)
|
||||||
{
|
{
|
||||||
category = "DiffDAT";
|
category = "DiffDAT";
|
||||||
}
|
}
|
||||||
@@ -456,7 +454,7 @@ namespace SabreTools
|
|||||||
Romba = romba,
|
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);
|
remUnicode, descAsName, filter, splitType, trim, single, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ namespace SabreTools
|
|||||||
hashOnly = false,
|
hashOnly = false,
|
||||||
inplace = false,
|
inplace = false,
|
||||||
inverse = false,
|
inverse = false,
|
||||||
merge = false,
|
|
||||||
nostore = false,
|
nostore = false,
|
||||||
quickScan = false,
|
quickScan = false,
|
||||||
quotes = false,
|
quotes = false,
|
||||||
@@ -398,7 +397,7 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
case "-m":
|
case "-m":
|
||||||
case "--merge":
|
case "--merge":
|
||||||
merge = true;
|
updateMode |= UpdateMode.Merge;
|
||||||
break;
|
break;
|
||||||
case "-nc":
|
case "-nc":
|
||||||
case "--nodump-col":
|
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,
|
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,
|
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);
|
cleanGameNames, removeUnicode, descAsName, dedup, stripHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user