mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Filter] Make filtering more object-oriented
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
|
|
||||||
@@ -15,56 +14,100 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
/// Represents the filtering operations that need to be performed on a set of items, usually a DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Filter
|
public partial class Filter
|
||||||
{
|
{
|
||||||
#region Pubically facing variables
|
#region Pubically facing variables
|
||||||
|
|
||||||
#region Positive
|
/// <summary>
|
||||||
|
/// Include or exclude machine names
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> MachineName { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
public List<string> MachineNames { get; set; } = new List<string>();
|
/// <summary>
|
||||||
public List<string> MachineDescriptions { get; set; } = new List<string>();
|
/// Include or exclude machine descriptions
|
||||||
public List<string> ItemNames { get; set; } = new List<string>();
|
/// </summary>
|
||||||
public List<string> ItemTypes { get; set; } = new List<string>();
|
public FilterItem<string> MachineDescription { get; set; } = new FilterItem<string>();
|
||||||
public List<string> CRCs { get; set; } = new List<string>();
|
|
||||||
public List<string> MD5s { get; set; } = new List<string>();
|
|
||||||
public List<string> SHA1s { get; set; } = new List<string>();
|
|
||||||
public List<string> SHA256s { get; set; } = new List<string>();
|
|
||||||
public List<string> SHA384s { get; set; } = new List<string>();
|
|
||||||
public List<string> SHA512s { get; set; } = new List<string>();
|
|
||||||
public ItemStatus ItemStatuses { get; set; } = ItemStatus.NULL;
|
|
||||||
public MachineType MachineTypes { get; set; } = MachineType.NULL;
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Include or exclude item names
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> ItemName { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
#region Negative
|
/// <summary>
|
||||||
|
/// Include or exclude item types
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> ItemTypes { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
public List<string> NotMachineNames { get; set; } = new List<string>();
|
/// <summary>
|
||||||
public List<string> NotMachineDescriptions { get; set; } = new List<string>();
|
/// Include or exclude CRC32 hashes
|
||||||
public List<string> NotItemNames { get; set; } = new List<string>();
|
/// </summary>
|
||||||
public List<string> NotItemTypes { get; set; } = new List<string>();
|
public FilterItem<string> CRC { get; set; } = new FilterItem<string>();
|
||||||
public List<string> NotCRCs { get; set; } = new List<string>();
|
|
||||||
public List<string> NotMD5s { get; set; } = new List<string>();
|
|
||||||
public List<string> NotSHA1s { get; set; } = new List<string>();
|
|
||||||
public List<string> NotSHA256s { get; set; } = new List<string>();
|
|
||||||
public List<string> NotSHA384s { get; set; } = new List<string>();
|
|
||||||
public List<string> NotSHA512s { get; set; } = new List<string>();
|
|
||||||
public ItemStatus NotItemStatuses { get; set; } = ItemStatus.NULL;
|
|
||||||
public MachineType NotMachineTypes { get; set; } = MachineType.NULL;
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Include or exclude MD5 hashes
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> MD5 { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
#region Neutral
|
/// <summary>
|
||||||
|
/// Include or exclude SHA-1 hashes
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> SHA1 { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
public long SizeGreaterThanOrEqual { get; set; } = -1;
|
/// <summary>
|
||||||
public long SizeLessThanOrEqual { get; set; } = -1;
|
/// Include or exclude SHA-256 hashes
|
||||||
public long SizeEqualTo { get; set; } = -1;
|
/// </summary>
|
||||||
public bool IncludeOfInGame { get; set; } = false;
|
public FilterItem<string> SHA256 { get; set; } = new FilterItem<string>();
|
||||||
public bool? Runnable { get; set; } = null;
|
|
||||||
public bool Single { get; set; } = false;
|
|
||||||
public bool Trim { get; set; } = false;
|
|
||||||
public string Root { get; set; } = null;
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Include or exclude SHA-384 hashes
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> SHA384 { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include or exclude SHA-512 hashes
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> SHA512 { get; set; } = new FilterItem<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include or exclude item statuses
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<ItemStatus> ItemStatuses { get; set; } = new FilterItem<ItemStatus>() { Positive = ItemStatus.NULL, Negative = ItemStatus.NULL };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include or exclude machine types
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<MachineType> MachineTypes { get; set; } = new FilterItem<MachineType>() { Positive = MachineType.NULL, Negative = MachineType.NULL };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include or exclude item sizes
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Positive means "Greater than or equal", Negative means "Less than or equal", Neutral means "Equal"</remarks>
|
||||||
|
public FilterItem<long> Size { get; set; } = new FilterItem<long>() { Positive = -1, Negative = -1, Neutral = -1 };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include romof and cloneof when filtering machine names
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<bool> IncludeOfInGame { get; set; } = new FilterItem<bool>() { Neutral = false };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include or exclude items with the "Runnable" tag
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<bool?> Runnable { get; set; } = new FilterItem<bool?>() { Neutral = null };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Change all machine names to "!"
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<bool> Single { get; set; } = new FilterItem<bool>() { Neutral = false };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trim total machine and item name to not exceed NTFS limits
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<bool> Trim { get; set; } = new FilterItem<bool>() { Neutral = false };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Include root directory when determing trim sizes
|
||||||
|
/// </summary>
|
||||||
|
public FilterItem<string> Root { get; set; } = new FilterItem<string>() { Neutral = null };
|
||||||
|
|
||||||
#endregion // Pubically facing variables
|
#endregion // Pubically facing variables
|
||||||
|
|
||||||
@@ -92,16 +135,14 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (ItemPasses(item))
|
if (ItemPasses(item))
|
||||||
{
|
{
|
||||||
// If we are in single game mode, rename all games
|
// If we are in single game mode, rename all games
|
||||||
if (this.Single)
|
if (this.Single.Neutral)
|
||||||
{
|
|
||||||
item.MachineName = "!";
|
item.MachineName = "!";
|
||||||
}
|
|
||||||
|
|
||||||
// If we are in NTFS trim mode, trim the game name
|
// If we are in NTFS trim mode, trim the game name
|
||||||
if (this.Trim)
|
if (this.Trim.Neutral)
|
||||||
{
|
{
|
||||||
// Windows max name length is 260
|
// Windows max name length is 260
|
||||||
int usableLength = 260 - item.MachineName.Length - this.Root.Length;
|
int usableLength = 260 - item.MachineName.Length - this.Root.Neutral.Length;
|
||||||
if (item.Name.Length > usableLength)
|
if (item.Name.Length > usableLength)
|
||||||
{
|
{
|
||||||
string ext = Path.GetExtension(item.Name);
|
string ext = Path.GetExtension(item.Name);
|
||||||
@@ -140,25 +181,17 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
// If the item is null, we automatically fail it
|
// If the item is null, we automatically fail it
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on machine type
|
// Filter on machine type
|
||||||
if (this.MachineTypes != MachineType.NULL && (item.MachineType & this.MachineTypes) == 0)
|
if (!this.MachineTypes.MatchesPositive(MachineType.NULL, item.MachineType))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.MachineTypes.MatchesNegative(MachineType.NULL, item.MachineType))
|
||||||
if (this.NotMachineTypes != MachineType.NULL && (item.MachineType & this.NotMachineTypes) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on machine runability
|
// Filter on machine runability
|
||||||
if (this.Runnable != null && item.Runnable != this.Runnable)
|
if (!this.Runnable.MatchesNeutral(null, item.Runnable))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Take care of Rom and Disk specific differences
|
// Take care of Rom and Disk specific differences
|
||||||
if (item.ItemType == ItemType.Rom)
|
if (item.ItemType == ItemType.Rom)
|
||||||
@@ -166,375 +199,139 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Rom rom = (Rom)item;
|
Rom rom = (Rom)item;
|
||||||
|
|
||||||
// Filter on status
|
// Filter on status
|
||||||
if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0)
|
if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus))
|
||||||
if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on rom size
|
// Filter on rom size
|
||||||
if (this.SizeEqualTo != -1 && rom.Size != this.SizeEqualTo)
|
if (!this.Size.MatchesNeutral(-1, rom.Size))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
else if (!this.Size.MatchesPositive(-1, rom.Size))
|
||||||
else
|
|
||||||
{
|
|
||||||
if (this.SizeGreaterThanOrEqual != -1 && rom.Size < this.SizeGreaterThanOrEqual)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
else if (!this.Size.MatchesNegative(-1, rom.Size))
|
||||||
if (this.SizeLessThanOrEqual != -1 && rom.Size > this.SizeLessThanOrEqual)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on CRC
|
// Filter on CRC
|
||||||
if (this.CRCs.Count > 0)
|
if (!this.CRC.MatchesPositiveSet(rom.CRC))
|
||||||
{
|
|
||||||
// If the CRC isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.CRCs, rom.CRC))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.CRC.MatchesNegativeSet(rom.CRC))
|
||||||
}
|
|
||||||
if (this.NotCRCs.Count > 0)
|
|
||||||
{
|
|
||||||
// If the CRC is in the list, return false
|
|
||||||
if (FindValueInList(this.NotCRCs, rom.CRC))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on MD5
|
// Filter on MD5
|
||||||
if (this.MD5s.Count > 0)
|
if (!this.MD5.MatchesPositiveSet(rom.MD5))
|
||||||
{
|
|
||||||
// If the MD5 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.MD5s, rom.MD5))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.MD5.MatchesNegativeSet(rom.MD5))
|
||||||
}
|
|
||||||
if (this.NotMD5s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the MD5 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotMD5s, rom.MD5))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-1
|
// Filter on SHA-1
|
||||||
if (this.SHA1s.Count > 0)
|
if (!this.SHA1.MatchesPositiveSet(rom.SHA1))
|
||||||
{
|
|
||||||
// If the SHA-1 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA1s, rom.SHA1))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA1.MatchesNegativeSet(rom.SHA1))
|
||||||
}
|
|
||||||
if (this.NotSHA1s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-1 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA1s, rom.SHA1))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-256
|
// Filter on SHA-256
|
||||||
if (this.SHA256s.Count > 0)
|
if (!this.SHA256.MatchesPositiveSet(rom.SHA256))
|
||||||
{
|
|
||||||
// If the SHA-256 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA256s, rom.SHA256))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA256.MatchesNegativeSet(rom.SHA256))
|
||||||
}
|
|
||||||
if (this.NotSHA256s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-256 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA256s, rom.SHA256))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-384
|
// Filter on SHA-384
|
||||||
if (this.SHA384s.Count > 0)
|
if (!this.SHA384.MatchesPositiveSet(rom.SHA384))
|
||||||
{
|
|
||||||
// If the SHA-384 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA384s, rom.SHA384))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA384.MatchesNegativeSet(rom.SHA384))
|
||||||
}
|
|
||||||
if (this.NotSHA384s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-384 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA384s, rom.SHA384))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-512
|
// Filter on SHA-512
|
||||||
if (this.SHA512s.Count > 0)
|
if (!this.SHA512.MatchesPositiveSet(rom.SHA512))
|
||||||
{
|
|
||||||
// If the SHA-512 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA512s, rom.SHA512))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA512.MatchesNegativeSet(rom.SHA512))
|
||||||
}
|
|
||||||
if (this.NotSHA512s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-512 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA512s, rom.SHA512))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (item.ItemType == ItemType.Disk)
|
else if (item.ItemType == ItemType.Disk)
|
||||||
{
|
{
|
||||||
Disk rom = (Disk)item;
|
Disk rom = (Disk)item;
|
||||||
|
|
||||||
// Filter on status
|
// Filter on status
|
||||||
if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0)
|
if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus))
|
||||||
if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on MD5
|
// Filter on MD5
|
||||||
if (this.MD5s.Count > 0)
|
if (!this.MD5.MatchesPositiveSet(rom.MD5))
|
||||||
{
|
|
||||||
// If the MD5 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.MD5s, rom.MD5))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.MD5.MatchesNegativeSet(rom.MD5))
|
||||||
}
|
|
||||||
if (this.NotMD5s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the MD5 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotMD5s, rom.MD5))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-1
|
// Filter on SHA-1
|
||||||
if (this.SHA1s.Count > 0)
|
if (!this.SHA1.MatchesPositiveSet(rom.SHA1))
|
||||||
{
|
|
||||||
// If the SHA-1 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA1s, rom.SHA1))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA1.MatchesNegativeSet(rom.SHA1))
|
||||||
}
|
|
||||||
if (this.NotSHA1s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-1 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA1s, rom.SHA1))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-256
|
// Filter on SHA-256
|
||||||
if (this.SHA256s.Count > 0)
|
if (!this.SHA256.MatchesPositiveSet(rom.SHA256))
|
||||||
{
|
|
||||||
// If the SHA-256 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA256s, rom.SHA256))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA256.MatchesNegativeSet(rom.SHA256))
|
||||||
}
|
|
||||||
if (this.NotSHA256s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-256 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA256s, rom.SHA256))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-384
|
// Filter on SHA-384
|
||||||
if (this.SHA384s.Count > 0)
|
if (!this.SHA384.MatchesPositiveSet(rom.SHA384))
|
||||||
{
|
|
||||||
// If the SHA-384 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA384s, rom.SHA384))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA384.MatchesNegativeSet(rom.SHA384))
|
||||||
}
|
|
||||||
if (this.NotSHA384s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-384 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA384s, rom.SHA384))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on SHA-512
|
// Filter on SHA-512
|
||||||
if (this.SHA512s.Count > 0)
|
if (!this.SHA512.MatchesPositiveSet(rom.SHA512))
|
||||||
{
|
|
||||||
// If the SHA-512 isn't in the list, return false
|
|
||||||
if (!FindValueInList(this.SHA512s, rom.SHA512))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.SHA512.MatchesNegativeSet(rom.SHA512))
|
||||||
}
|
|
||||||
if (this.NotSHA512s.Count > 0)
|
|
||||||
{
|
|
||||||
// If the SHA-512 is in the list, return false
|
|
||||||
if (FindValueInList(this.NotSHA512s, rom.SHA512))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on machine name
|
// Filter on machine name
|
||||||
if (this.MachineNames.Count > 0)
|
bool machineNameFound = this.MachineName.MatchesPositiveSet(item.MachineName);
|
||||||
|
if (this.IncludeOfInGame.Neutral)
|
||||||
{
|
{
|
||||||
bool found = FindValueInList(this.MachineNames, item.MachineName);
|
machineNameFound |= this.MachineName.MatchesPositiveSet(item.CloneOf);
|
||||||
|
machineNameFound |= this.MachineName.MatchesPositiveSet(item.RomOf);
|
||||||
// If we are checking CloneOf and RomOf, add them in as well
|
|
||||||
if (this.IncludeOfInGame)
|
|
||||||
{
|
|
||||||
found |= FindValueInList(this.MachineNames, item.CloneOf);
|
|
||||||
found |= FindValueInList(this.MachineNames, item.RomOf);
|
|
||||||
}
|
}
|
||||||
|
if (!machineNameFound)
|
||||||
// If the game name was not found in the list, return false
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.NotMachineNames.Count > 0)
|
|
||||||
{
|
|
||||||
bool found = FindValueInList(this.NotMachineNames, item.MachineName);
|
|
||||||
|
|
||||||
// If we are checking CloneOf and RomOf, add them in as well
|
machineNameFound = this.MachineName.MatchesNegativeSet(item.MachineName);
|
||||||
if (this.IncludeOfInGame)
|
if (this.IncludeOfInGame.Neutral)
|
||||||
{
|
{
|
||||||
found |= FindValueInList(this.NotMachineNames, item.CloneOf);
|
machineNameFound |= this.MachineName.MatchesNegativeSet(item.CloneOf);
|
||||||
found |= FindValueInList(this.NotMachineNames, item.RomOf);
|
machineNameFound |= this.MachineName.MatchesNegativeSet(item.RomOf);
|
||||||
}
|
}
|
||||||
|
if (machineNameFound)
|
||||||
// If the machine name was found in the list, return false
|
|
||||||
if (found)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on machine description
|
// Filter on machine description
|
||||||
if (this.MachineDescriptions.Count > 0)
|
if (!this.MachineDescription.MatchesPositiveSet(item.MachineDescription))
|
||||||
{
|
|
||||||
bool found = FindValueInList(this.MachineDescriptions, item.MachineDescription);
|
|
||||||
|
|
||||||
// If the machine description was not found in the list, return false
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.MachineDescription.MatchesNegativeSet(item.MachineDescription))
|
||||||
}
|
|
||||||
if (this.NotMachineDescriptions.Count > 0)
|
|
||||||
{
|
|
||||||
bool found = FindValueInList(this.NotMachineDescriptions, item.MachineDescription);
|
|
||||||
|
|
||||||
// If the machine description was found in the list, return false
|
|
||||||
if (found)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on item name
|
// Filter on item name
|
||||||
if (this.ItemNames.Count > 0)
|
if (!this.ItemName.MatchesPositiveSet(item.Name))
|
||||||
{
|
|
||||||
// If the item name was not found in the list, return false
|
|
||||||
if (!FindValueInList(this.ItemNames, item.Name))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.ItemName.MatchesNegativeSet(item.Name))
|
||||||
}
|
|
||||||
if (this.NotItemNames.Count > 0)
|
|
||||||
{
|
|
||||||
// If the item name was found in the list, return false
|
|
||||||
if (FindValueInList(this.NotItemNames, item.Name))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter on item type
|
// Filter on item type
|
||||||
if (this.ItemTypes.Count == 0 && this.NotItemTypes.Count == 0 && item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank)
|
if (this.ItemTypes.PositiveSet.Count == 0 && this.ItemTypes.NegativeSet.Count == 0
|
||||||
{
|
&& item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank)
|
||||||
return false;
|
return false;
|
||||||
}
|
if (!this.ItemTypes.MatchesPositiveSet(item.ItemType.ToString()))
|
||||||
if (this.ItemTypes.Count > 0)
|
|
||||||
{
|
|
||||||
// If the item type was not found in the list, return false
|
|
||||||
if (!FindValueInList(this.ItemTypes, item.ItemType.ToString()))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
if (this.ItemTypes.MatchesNegativeSet(item.ItemType.ToString()))
|
||||||
}
|
|
||||||
if (this.NotItemTypes.Count > 0)
|
|
||||||
{
|
|
||||||
// If the item type was found in the list, return false
|
|
||||||
if (FindValueInList(this.NotItemTypes, item.ItemType.ToString()))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generic code to check if a specific value is in the list given
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="haystack">List to search for the value in</param>
|
|
||||||
/// <param name="needle">Value to search the list for</param>
|
|
||||||
/// <returns>True if the value could be found, false otherwise</returns>
|
|
||||||
private bool FindValueInList(List<string> haystack, string needle)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
foreach (string straw in haystack)
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrWhiteSpace(straw))
|
|
||||||
{
|
|
||||||
string regexStraw = straw;
|
|
||||||
|
|
||||||
// If the straw has no special characters at all, treat it as an exact match
|
|
||||||
if (regexStraw == Regex.Escape(regexStraw))
|
|
||||||
{
|
|
||||||
regexStraw = "^" + regexStraw + "$";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if a match is found with the regex
|
|
||||||
found |= Regex.IsMatch(needle, regexStraw, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
181
SabreTools.Library/DatFiles/FilterItem.cs
Normal file
181
SabreTools.Library/DatFiles/FilterItem.cs
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace SabreTools.Library.DatFiles
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a single filter within the overall filter
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Generic type representing the filtered object</typeparam>
|
||||||
|
public class FilterItem<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Single positive value for this filter
|
||||||
|
/// </summary>
|
||||||
|
public T Positive { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of positive values for this filter
|
||||||
|
/// </summary>
|
||||||
|
public List<T> PositiveSet { get; set; } = new List<T>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Single negative value for this filter
|
||||||
|
/// </summary>
|
||||||
|
public T Negative { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of negative values for this filter
|
||||||
|
/// </summary>
|
||||||
|
public List<T> NegativeSet { get; set; } = new List<T>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Single neutral value for this filter
|
||||||
|
/// </summary>
|
||||||
|
public T Neutral { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of neutral values for this filter
|
||||||
|
/// </summary>
|
||||||
|
public List<T> NeutralSet { get; set; } = new List<T>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a value matches the positive filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="def">Default value to check filter value</param>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in the positive filter, false otherwise</returns>
|
||||||
|
public bool MatchesPositive(T def, T value)
|
||||||
|
{
|
||||||
|
return Matches(this.Positive, def, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a value matches the negative filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="def">Default value to check filter value</param>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in the negative filter, false otherwise</returns>
|
||||||
|
public bool MatchesNegative(T def, T value)
|
||||||
|
{
|
||||||
|
return Matches(this.Negative, def, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a value matches the neutral filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="def">Default value to check filter value</param>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in the neutral filter, false otherwise</returns>
|
||||||
|
public bool MatchesNeutral(T def, T value)
|
||||||
|
{
|
||||||
|
return Matches(this.Neutral, def, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the given value matches any of the positive filters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in a positive filter, false otherwise</returns>
|
||||||
|
public bool MatchesPositiveSet(T value)
|
||||||
|
{
|
||||||
|
return MatchesSet(this.PositiveSet, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the given value matches any of the negative filters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in a negative filter, false otherwise</returns>
|
||||||
|
public bool MatchesNegativeSet(T value)
|
||||||
|
{
|
||||||
|
return MatchesSet(this.NegativeSet, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the given value matches any of the neutral filters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in a neutral filter, false otherwise</returns>
|
||||||
|
public bool MatchesNeutralSet(T value)
|
||||||
|
{
|
||||||
|
return MatchesSet(this.NeutralSet, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a value matches the supplied filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="single">Value to check against</param>
|
||||||
|
/// <param name="def">Default value to check filter value</param>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in the supplied filter, false otherwise</returns>
|
||||||
|
private bool Matches(T single, T def, T value)
|
||||||
|
{
|
||||||
|
// If the filter is default, we ignore
|
||||||
|
if (single.Equals(def))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If we have a flag
|
||||||
|
if (typeof(T).IsEnum && (single as Enum).HasFlag(value as Enum))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return single.Equals(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a value matches the supplied filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="set">Set to check against</param>
|
||||||
|
/// <param name="value">Value to check</param>
|
||||||
|
/// <returns>True if the value was found in the supplied filter, false otherwise</returns>
|
||||||
|
private bool MatchesSet(List<T> set, T value)
|
||||||
|
{
|
||||||
|
if (set.Count > 0)
|
||||||
|
{
|
||||||
|
if (this.FindValueInList(set, value))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic code to check if a specific value is in the list given
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="haystack">List to search for the value in</param>
|
||||||
|
/// <param name="needle">Value to search the list for</param>
|
||||||
|
/// <returns>True if the value could be found, false otherwise</returns>
|
||||||
|
private bool FindValueInList(List<T> haystack, T needle)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
foreach (T straw in haystack)
|
||||||
|
{
|
||||||
|
if (straw is string)
|
||||||
|
{
|
||||||
|
string needleString = needle as string;
|
||||||
|
string strawString = straw as string;
|
||||||
|
if (!String.IsNullOrWhiteSpace(strawString))
|
||||||
|
{
|
||||||
|
string regexStraw = strawString;
|
||||||
|
|
||||||
|
// If the straw has no special characters at all, treat it as an exact match
|
||||||
|
if (regexStraw == Regex.Escape(regexStraw))
|
||||||
|
{
|
||||||
|
regexStraw = "^" + regexStraw + "$";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if a match is found with the regex
|
||||||
|
found |= Regex.IsMatch(needleString, regexStraw, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
found |= (needle.Equals(straw));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -93,6 +93,7 @@
|
|||||||
<Compile Include="DatFiles\DatStats.cs" />
|
<Compile Include="DatFiles\DatStats.cs" />
|
||||||
<Compile Include="DatFiles\DosCenter.cs" />
|
<Compile Include="DatFiles\DosCenter.cs" />
|
||||||
<Compile Include="DatFiles\Filter.cs" />
|
<Compile Include="DatFiles\Filter.cs" />
|
||||||
|
<Compile Include="DatFiles\FilterItem.cs" />
|
||||||
<Compile Include="DatFiles\Hashfile.cs" />
|
<Compile Include="DatFiles\Hashfile.cs" />
|
||||||
<Compile Include="DatFiles\Listrom.cs" />
|
<Compile Include="DatFiles\Listrom.cs" />
|
||||||
<Compile Include="DatFiles\Listxml.cs" />
|
<Compile Include="DatFiles\Listxml.cs" />
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ namespace SabreTools
|
|||||||
splittingMode |= SplittingMode.Level;
|
splittingMode |= SplittingMode.Level;
|
||||||
break;
|
break;
|
||||||
case "match-of-tags":
|
case "match-of-tags":
|
||||||
filter.IncludeOfInGame = true;
|
filter.IncludeOfInGame.Neutral = true;
|
||||||
break;
|
break;
|
||||||
case "merge":
|
case "merge":
|
||||||
updateMode |= UpdateMode.Merge;
|
updateMode |= UpdateMode.Merge;
|
||||||
@@ -345,7 +345,7 @@ namespace SabreTools
|
|||||||
showNodumpColumn = true;
|
showNodumpColumn = true;
|
||||||
break;
|
break;
|
||||||
case "not-runnable":
|
case "not-runnable":
|
||||||
filter.Runnable = false;
|
filter.Runnable.Neutral = false;
|
||||||
break;
|
break;
|
||||||
case "no-store-header":
|
case "no-store-header":
|
||||||
nostore = true;
|
nostore = true;
|
||||||
@@ -487,7 +487,7 @@ namespace SabreTools
|
|||||||
datHeader.UseRomName = true;
|
datHeader.UseRomName = true;
|
||||||
break;
|
break;
|
||||||
case "runnable":
|
case "runnable":
|
||||||
filter.Runnable = true;
|
filter.Runnable.Neutral = true;
|
||||||
break;
|
break;
|
||||||
case "scan-all":
|
case "scan-all":
|
||||||
sevenzip = 0;
|
sevenzip = 0;
|
||||||
@@ -529,7 +529,7 @@ namespace SabreTools
|
|||||||
omitFromScan &= ~Hash.SHA512; // This needs to be inverted later
|
omitFromScan &= ~Hash.SHA512; // This needs to be inverted later
|
||||||
break;
|
break;
|
||||||
case "single-set":
|
case "single-set":
|
||||||
filter.Single = true;
|
filter.Single.Neutral = true;
|
||||||
break;
|
break;
|
||||||
case "superdat":
|
case "superdat":
|
||||||
datHeader.Type = "SuperDAT";
|
datHeader.Type = "SuperDAT";
|
||||||
@@ -569,7 +569,7 @@ namespace SabreTools
|
|||||||
outputFormat = OutputFormat.TorrentZstd;
|
outputFormat = OutputFormat.TorrentZstd;
|
||||||
break;
|
break;
|
||||||
case "trim":
|
case "trim":
|
||||||
filter.Trim = true;
|
filter.Trim.Neutral = true;
|
||||||
break;
|
break;
|
||||||
case "tsv":
|
case "tsv":
|
||||||
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags));
|
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags));
|
||||||
@@ -643,7 +643,7 @@ namespace SabreTools
|
|||||||
basePaths.AddRange((List<string>)feat.Value.GetValue());
|
basePaths.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "crc":
|
case "crc":
|
||||||
filter.CRCs.AddRange((List<string>)feat.Value.GetValue());
|
filter.CRC.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "dat":
|
case "dat":
|
||||||
datfiles.AddRange((List<string>)feat.Value.GetValue());
|
datfiles.AddRange((List<string>)feat.Value.GetValue());
|
||||||
@@ -661,66 +661,66 @@ namespace SabreTools
|
|||||||
extb.AddRange((List<string>)feat.Value.GetValue());
|
extb.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "game-description":
|
case "game-description":
|
||||||
filter.MachineDescriptions.AddRange((List<string>)feat.Value.GetValue());
|
filter.MachineDescription.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "game-name":
|
case "game-name":
|
||||||
filter.MachineNames.AddRange((List<string>)feat.Value.GetValue());
|
filter.MachineName.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "game-type":
|
case "game-type":
|
||||||
foreach (string mach in (List<string>)feat.Value.GetValue())
|
foreach (string mach in (List<string>)feat.Value.GetValue())
|
||||||
{
|
{
|
||||||
filter.MachineTypes |= Utilities.GetMachineType(mach);
|
filter.MachineTypes.Positive |= Utilities.GetMachineType(mach);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "item-name":
|
case "item-name":
|
||||||
filter.ItemNames.AddRange((List<string>)feat.Value.GetValue());
|
filter.ItemName.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "item-type":
|
case "item-type":
|
||||||
filter.ItemTypes.AddRange((List<string>)feat.Value.GetValue());
|
filter.ItemTypes.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "md5":
|
case "md5":
|
||||||
filter.MD5s.AddRange((List<string>)feat.Value.GetValue());
|
filter.MD5.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-crc":
|
case "not-crc":
|
||||||
filter.NotCRCs.AddRange((List<string>)feat.Value.GetValue());
|
filter.CRC.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-game-description":
|
case "not-game-description":
|
||||||
filter.NotMachineDescriptions.AddRange((List<string>)feat.Value.GetValue());
|
filter.MachineDescription.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-game-name":
|
case "not-game-name":
|
||||||
filter.NotMachineNames.AddRange((List<string>)feat.Value.GetValue());
|
filter.MachineName.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-game-type":
|
case "not-game-type":
|
||||||
foreach (string nmach in (List<string>)feat.Value.GetValue())
|
foreach (string nmach in (List<string>)feat.Value.GetValue())
|
||||||
{
|
{
|
||||||
filter.NotMachineTypes |= Utilities.GetMachineType(nmach);
|
filter.MachineTypes.Negative |= Utilities.GetMachineType(nmach);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "not-item-name":
|
case "not-item-name":
|
||||||
filter.NotItemNames.AddRange((List<string>)feat.Value.GetValue());
|
filter.ItemName.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-item-type":
|
case "not-item-type":
|
||||||
filter.NotItemTypes.AddRange((List<string>)feat.Value.GetValue());
|
filter.ItemTypes.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-md5":
|
case "not-md5":
|
||||||
filter.NotMD5s.AddRange((List<string>)feat.Value.GetValue());
|
filter.MD5.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-sha1":
|
case "not-sha1":
|
||||||
filter.NotSHA1s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA1.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-sha256":
|
case "not-sha256":
|
||||||
filter.NotSHA256s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA256.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-sha384":
|
case "not-sha384":
|
||||||
filter.NotSHA384s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA384.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-sha512":
|
case "not-sha512":
|
||||||
filter.NotSHA512s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA512.NegativeSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "not-status":
|
case "not-status":
|
||||||
foreach (string nstat in (List<string>)feat.Value.GetValue())
|
foreach (string nstat in (List<string>)feat.Value.GetValue())
|
||||||
{
|
{
|
||||||
filter.NotItemStatuses |= Utilities.GetItemStatus(nstat);
|
filter.ItemStatuses.Negative |= Utilities.GetItemStatus(nstat);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "output-type":
|
case "output-type":
|
||||||
@@ -741,21 +741,21 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "sha1":
|
case "sha1":
|
||||||
filter.SHA1s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA1.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "sha256":
|
case "sha256":
|
||||||
filter.SHA256s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA256.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "sha384":
|
case "sha384":
|
||||||
filter.SHA384s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA384.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "sha512":
|
case "sha512":
|
||||||
filter.SHA512s.AddRange((List<string>)feat.Value.GetValue());
|
filter.SHA512.PositiveSet.AddRange((List<string>)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
foreach (string stat in (List<string>)feat.Value.GetValue())
|
foreach (string stat in (List<string>)feat.Value.GetValue())
|
||||||
{
|
{
|
||||||
filter.ItemStatuses |= Utilities.GetItemStatus(stat);
|
filter.ItemStatuses.Positive |= Utilities.GetItemStatus(stat);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "update-field": // TODO: Use this
|
case "update-field": // TODO: Use this
|
||||||
@@ -791,7 +791,7 @@ namespace SabreTools
|
|||||||
datHeader.Email = (string)feat.Value.GetValue();
|
datHeader.Email = (string)feat.Value.GetValue();
|
||||||
break;
|
break;
|
||||||
case "equal":
|
case "equal":
|
||||||
filter.SizeEqualTo = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
filter.Size.Neutral = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "filename":
|
case "filename":
|
||||||
datHeader.FileName = (string)feat.Value.GetValue();
|
datHeader.FileName = (string)feat.Value.GetValue();
|
||||||
@@ -806,7 +806,7 @@ namespace SabreTools
|
|||||||
datHeader.ForcePacking = Utilities.GetForcePacking((string)feat.Value.GetValue());
|
datHeader.ForcePacking = Utilities.GetForcePacking((string)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "greater":
|
case "greater":
|
||||||
filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
filter.Size.Positive = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "header":
|
case "header":
|
||||||
datHeader.Header = (string)feat.Value.GetValue();
|
datHeader.Header = (string)feat.Value.GetValue();
|
||||||
@@ -815,7 +815,7 @@ namespace SabreTools
|
|||||||
datHeader.Homepage = (string)feat.Value.GetValue();
|
datHeader.Homepage = (string)feat.Value.GetValue();
|
||||||
break;
|
break;
|
||||||
case "less":
|
case "less":
|
||||||
filter.SizeLessThanOrEqual = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
filter.Size.Negative = Utilities.GetSizeFromString((string)feat.Value.GetValue());
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
datHeader.Name = (string)feat.Value.GetValue();
|
datHeader.Name = (string)feat.Value.GetValue();
|
||||||
@@ -836,7 +836,7 @@ namespace SabreTools
|
|||||||
datHeader.RootDir = (string)feat.Value.GetValue();
|
datHeader.RootDir = (string)feat.Value.GetValue();
|
||||||
break;
|
break;
|
||||||
case "root-dir":
|
case "root-dir":
|
||||||
filter.Root = (string)feat.Value.GetValue();
|
filter.Root.Neutral = (string)feat.Value.GetValue();
|
||||||
break;
|
break;
|
||||||
case "temp":
|
case "temp":
|
||||||
tempDir = (string)feat.Value.GetValue();
|
tempDir = (string)feat.Value.GetValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user