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}'");
if (datItem is Disk || datItem is DatItems.Formats.File || datItem is Media || datItem is Rom)
{
datItemName += GetDuplicateSuffix(datItem);
// Get the duplicate suffix
datItemName += datItem.GetDuplicateSuffix();
lastrenamed ??= datItemName;
}
// If we have a conflict with the last renamed item, do the right thing
if (datItemName == lastrenamed)
@@ -906,11 +904,9 @@ namespace SabreTools.DatFiles
{
_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)
{
datItemName += GetDuplicateSuffix(datItem.Value);
// Get the duplicate suffix
datItemName += datItem.Value.GetDuplicateSuffix();
lastrenamed ??= datItemName;
}
// If we have a conflict with the last renamed item, do the right thing
if (datItemName == lastrenamed)
@@ -1017,21 +1013,6 @@ namespace SabreTools.DatFiles
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
}
}

View File

@@ -356,6 +356,12 @@ namespace SabreTools.DatItems
#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>
/// Get the dictionary key that should be used for a given item and bucketing type
/// </summary>

View File

@@ -114,12 +114,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Disk other)
=> _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>
/// Returns if the Rom contains any hashes
/// </summary>

View File

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

View File

@@ -63,12 +63,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Media other)
=> _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>
/// Returns if the Rom contains any hashes
/// </summary>

View File

@@ -105,12 +105,6 @@ namespace SabreTools.DatItems.Formats
public void FillMissingInformation(Rom other)
=> _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>
/// Returns if the Rom contains any hashes
/// </summary>