mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, DatItem] Add better removal logic
This commit is contained in:
@@ -2534,6 +2534,29 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all items marked for removal from the DAT
|
||||
/// </summary>
|
||||
private void RemoveMarkedItems()
|
||||
{
|
||||
List<string> keys = Keys;
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<DatItem> items = this[key];
|
||||
List<DatItem> newItems = new List<DatItem>();
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
if (!item.Remove)
|
||||
{
|
||||
newItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
Remove(key);
|
||||
AddRange(key, newItems);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strip the given hash types from the DAT
|
||||
/// </summary>
|
||||
@@ -4031,6 +4054,7 @@ namespace SabreTools.Library.DatFiles
|
||||
FileName = "fixDAT_" + FileName;
|
||||
Name = "fixDAT_" + Name;
|
||||
Description = "fixDAT_" + Description;
|
||||
RemoveMarkedItems();
|
||||
WriteToFile(outDir);
|
||||
}
|
||||
|
||||
@@ -4178,6 +4202,7 @@ namespace SabreTools.Library.DatFiles
|
||||
FileName = "fixDAT_" + FileName;
|
||||
Name = "fixDAT_" + Name;
|
||||
Description = "fixDAT_" + Description;
|
||||
RemoveMarkedItems();
|
||||
WriteToFile(outDir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user