Make duplicate suffix inherent

This commit is contained in:
Matt Nadareski
2025-01-09 05:52:33 -05:00
parent bea947f7c2
commit 24387491ae
6 changed files with 13 additions and 44 deletions

View File

@@ -811,11 +811,9 @@ namespace SabreTools.DatFiles
{ {
_logger.Verbose($"Name duplicate found for '{datItemName}'"); _logger.Verbose($"Name duplicate found for '{datItemName}'");
if (datItem is Disk || datItem is DatItems.Formats.File || datItem is Media || datItem is Rom) // Get the duplicate suffix
{ datItemName += datItem.GetDuplicateSuffix();
datItemName += GetDuplicateSuffix(datItem); lastrenamed ??= datItemName;
lastrenamed ??= datItemName;
}
// If we have a conflict with the last renamed item, do the right thing // If we have a conflict with the last renamed item, do the right thing
if (datItemName == lastrenamed) if (datItemName == lastrenamed)
@@ -906,11 +904,9 @@ namespace SabreTools.DatFiles
{ {
_logger.Verbose($"Name duplicate found for '{datItemName}'"); _logger.Verbose($"Name duplicate found for '{datItemName}'");
if (datItem.Value is Disk || datItem.Value is DatItems.Formats.File || datItem.Value is Media || datItem.Value is Rom) // Get the duplicate suffix
{ datItemName += datItem.Value.GetDuplicateSuffix();
datItemName += GetDuplicateSuffix(datItem.Value); lastrenamed ??= datItemName;
lastrenamed ??= datItemName;
}
// If we have a conflict with the last renamed item, do the right thing // If we have a conflict with the last renamed item, do the right thing
if (datItemName == lastrenamed) if (datItemName == lastrenamed)
@@ -1017,21 +1013,6 @@ namespace SabreTools.DatFiles
return false; return false;
} }
/// <summary>
/// Get duplicate suffix based on the item type
/// </summary>
private static string GetDuplicateSuffix(DatItem datItem)
{
return datItem switch
{
Disk disk => disk.GetDuplicateSuffix(),
DatItems.Formats.File file => file.GetDuplicateSuffix(),
Media media => media.GetDuplicateSuffix(),
Rom rom => rom.GetDuplicateSuffix(),
_ => "_1",
};
}
#endregion #endregion
} }
} }

View File

@@ -356,6 +356,12 @@ namespace SabreTools.DatItems
#region Sorting and Merging #region Sorting and Merging
/// <summary>
/// Get unique duplicate suffix on name collision
/// </summary>
/// <returns>String representing the suffix</returns>
public virtual string GetDuplicateSuffix() => _internal.GetDuplicateSuffix();
/// <summary> /// <summary>
/// Get the dictionary key that should be used for a given item and bucketing type /// Get the dictionary key that should be used for a given item and bucketing type
/// </summary> /// </summary>

View File

@@ -114,12 +114,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Disk other) public void FillMissingInformation(Disk other)
=> _internal.FillMissingHashes(other._internal); => _internal.FillMissingHashes(other._internal);
/// <summary>
/// Get unique duplicate suffix on name collision
/// </summary>
/// <returns>String representing the suffix</returns>
public string GetDuplicateSuffix() => _internal.GetDuplicateSuffix();
/// <summary> /// <summary>
/// Returns if the Rom contains any hashes /// Returns if the Rom contains any hashes
/// </summary> /// </summary>

View File

@@ -216,7 +216,7 @@ namespace SabreTools.DatItems.Formats
/// Get unique duplicate suffix on name collision /// Get unique duplicate suffix on name collision
/// </summary> /// </summary>
/// <returns>String representing the suffix</returns> /// <returns>String representing the suffix</returns>
public string GetDuplicateSuffix() public override string GetDuplicateSuffix()
{ {
if (!_crc.IsNullOrEmpty()) if (!_crc.IsNullOrEmpty())
return $"_{CRC}"; return $"_{CRC}";

View File

@@ -63,12 +63,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Media other) public void FillMissingInformation(Media other)
=> _internal.FillMissingHashes(other._internal); => _internal.FillMissingHashes(other._internal);
/// <summary>
/// Get unique duplicate suffix on name collision
/// </summary>
/// <returns>String representing the suffix</returns>
public string GetDuplicateSuffix() => _internal.GetDuplicateSuffix();
/// <summary> /// <summary>
/// Returns if the Rom contains any hashes /// Returns if the Rom contains any hashes
/// </summary> /// </summary>

View File

@@ -105,12 +105,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Rom other) public void FillMissingInformation(Rom other)
=> _internal.FillMissingHashes(other._internal); => _internal.FillMissingHashes(other._internal);
/// <summary>
/// Get unique duplicate suffix on name collision
/// </summary>
/// <returns>String representing the suffix</returns>
public string GetDuplicateSuffix() => _internal.GetDuplicateSuffix();
/// <summary> /// <summary>
/// Returns if the Rom contains any hashes /// Returns if the Rom contains any hashes
/// </summary> /// </summary>