Create and use ParentablePath

This commit is contained in:
Matt Nadareski
2020-07-26 23:39:33 -07:00
parent 3edd40b238
commit 5838c6f5c3
8 changed files with 135 additions and 90 deletions

View File

@@ -5,7 +5,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using NaturalSort;
using SabreTools.Library.Data;
using SabreTools.Library.DatItems;
using SabreTools.Library.Tools;
@@ -97,8 +97,16 @@ namespace SabreTools.Library.DatFiles
/// </summary>
private FilterItem<string> RebuildTo = new FilterItem<string>();
// TODO: Machine.Devices - List<string>
// TODO: Machine.SlotOptions - List<string>
/// <summary>
/// Include or exclude machine devices
/// </summary>
private FilterItem<string> Devices = new FilterItem<string>();
/// <summary>
/// Include or exclude machine slotoptions
/// </summary>
private FilterItem<string> SlotOptions = new FilterItem<string>();
// TODO: Machine.Infos - List<KeyValuePair<string, string>>
/// <summary>
@@ -463,6 +471,20 @@ namespace SabreTools.Library.DatFiles
RebuildTo.PositiveSet.Add(value);
break;
case Field.Devices:
if (negate)
Devices.NegativeSet.Add(value);
else
Devices.PositiveSet.Add(value);
break;
case Field.SlotOptions:
if (negate)
SlotOptions.NegativeSet.Add(value);
else
SlotOptions.PositiveSet.Add(value);
break;
case Field.MachineType:
if (negate)
MachineTypes.Negative |= value.AsMachineType();
@@ -1085,6 +1107,30 @@ namespace SabreTools.Library.DatFiles
if (this.RebuildTo.MatchesNegativeSet(item.RebuildTo) == true)
return false;
// Filter on devices
bool anyPositiveDevice = false;
bool anyNegativeDevice = false;
foreach (string device in item.Devices)
{
anyPositiveDevice |= this.Devices.MatchesPositiveSet(device) == true;
anyNegativeDevice |= this.Devices.MatchesNegativeSet(device) == false;
}
if (!anyPositiveDevice || anyNegativeDevice)
return false;
// Filter on slot options
bool anyPositiveSlotOption = false;
bool anyNegativeSlotOption = false;
foreach (string device in item.SlotOptions)
{
anyPositiveSlotOption |= this.SlotOptions.MatchesPositiveSet(device) == true;
anyNegativeSlotOption |= this.SlotOptions.MatchesNegativeSet(device) == false;
}
if (!anyPositiveSlotOption || anyNegativeSlotOption)
return false;
// Filter on machine type
if (this.MachineTypes.MatchesPositive(MachineType.NULL, item.MachineType) == false)
return false;