mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RomTools] Add ability to remove from input
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
@@ -187,8 +188,9 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="lastrom">Rom to use as a base</param>
|
/// <param name="lastrom">Rom to use as a base</param>
|
||||||
/// <param name="datdata">DAT to match against</param>
|
/// <param name="datdata">DAT to match against</param>
|
||||||
|
/// <param name="remove">True to remove matched roms from the input, false otherwise (default)</param>
|
||||||
/// <returns>List of matched RomData objects</returns>
|
/// <returns>List of matched RomData objects</returns>
|
||||||
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata)
|
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata, bool remove = false)
|
||||||
{
|
{
|
||||||
List<Rom> output = new List<Rom>();
|
List<Rom> output = new List<Rom>();
|
||||||
|
|
||||||
@@ -199,14 +201,27 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find duplicates
|
// Try to find duplicates
|
||||||
foreach (List<Rom> roms in datdata.Roms.Values)
|
List<string> keys = datdata.Roms.Keys.ToList();
|
||||||
|
foreach (string key in keys)
|
||||||
{
|
{
|
||||||
|
List<Rom> roms = datdata.Roms[key];
|
||||||
|
List<Rom> left = new List<Rom>();
|
||||||
foreach (Rom rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
if (IsDuplicate(rom, lastrom))
|
if (IsDuplicate(rom, lastrom))
|
||||||
{
|
{
|
||||||
output.Add(rom);
|
output.Add(rom);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
left.Add(rom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're in removal mode, replace the list with the new one
|
||||||
|
if (remove)
|
||||||
|
{
|
||||||
|
datdata.Roms[key] = left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user