[SabreTools, DatFile] Allow updating names AND/OR hashes

This commit is contained in:
Matt Nadareski
2017-12-14 13:38:04 -08:00
parent e8d59e6970
commit aa62531c9d
5 changed files with 69 additions and 38 deletions

View File

@@ -1581,9 +1581,10 @@ namespace SabreTools.Library.DatFiles
/// <param name="descAsName">True to allow SL DATs to have game names used instead of descriptions, false otherwise (default)</param>
/// <param name="filter">Filter object to be passed to the DatItem level</param>
/// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param>
/// <param name="updateHashes">True if hashes should be updated along with names, false otherwise [Only for base replacement]</param>
/// <param name="updateNames">True if names should be updated, false otherwise [only for base replacement]</param>
/// <param name="updateHashes">True if hashes should be updated, false otherwise [only for base replacement]</param>
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 updateHashes)
bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, bool updateNames, bool updateHashes)
{
// Ensure we only have files in the inputs
List<string> inputFileNames = Utilities.GetOnlyFilesFromInputs(inputPaths, appendparent: true);
@@ -1637,7 +1638,7 @@ namespace SabreTools.Library.DatFiles
else if ((updateMode & UpdateMode.BaseReplace) != 0
|| (updateMode & UpdateMode.ReverseBaseReplace) != 0)
{
BaseReplace(inputFileNames, baseFileNames, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, updateHashes);
BaseReplace(inputFileNames, baseFileNames, outDir, inplace, clean, remUnicode, descAsName, filter, splitType, updateNames, updateHashes);
}
return;
@@ -1705,7 +1706,7 @@ namespace SabreTools.Library.DatFiles
}
/// <summary>
/// Replace item names from on a base set
/// Replace item values from the base set
/// </summary>
/// <param name="inputFileNames">Names of the input files</param>
/// <param name="baseFileNames">Names of base files</param>
@@ -1719,9 +1720,10 @@ 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>
/// <param name="updateHashes">True if hashes should be updated along with names, false otherwise</param>
/// <param name="updateNames">True if names should be updated, false otherwise</param>
/// <param name="updateHashes">True if hashes should be updated, false otherwise</param>
public void BaseReplace(List<string> inputFileNames, List<string> baseFileNames, string outDir, bool inplace, bool clean, bool remUnicode,
bool descAsName, Filter filter, SplitType splitType, bool updateHashes)
bool descAsName, Filter filter, SplitType splitType, bool updateNames, bool updateHashes)
{
// First we want to parse all of the base DATs into the input
InternalStopwatch watch = new InternalStopwatch("Populating base DAT for replacement...");
@@ -1770,9 +1772,13 @@ namespace SabreTools.Library.DatFiles
if (dupes.Count > 0)
{
newDatItem.Name = dupes[0].Name;
// If we're updating names, replace using the first found name
if (updateNames)
{
newDatItem.Name = dupes[0].Name;
}
// If we're updating hashes too, only replace if the current item doesn't have them
// If we're updating hashes, only replace if the current item doesn't have them
if (updateHashes)
{
if (newDatItem.Type == ItemType.Rom)