mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Filter] Make filter great again
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
|
||||
#if MONO
|
||||
using System.IO;
|
||||
@@ -8,9 +10,6 @@ using System.IO;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
#endif
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
/// <summary>
|
||||
@@ -18,284 +17,57 @@ namespace SabreTools.Library.DatFiles
|
||||
/// </summary>
|
||||
public class Filter
|
||||
{
|
||||
#region Private instance variables
|
||||
|
||||
#region Positive
|
||||
|
||||
private List<string> _gameNames;
|
||||
private List<string> _gameDescriptions;
|
||||
private List<string> _romNames;
|
||||
private List<string> _romTypes;
|
||||
private List<string> _crcs;
|
||||
private List<string> _md5s;
|
||||
private List<string> _sha1s;
|
||||
private List<string> _sha256s;
|
||||
private List<string> _sha384s;
|
||||
private List<string> _sha512s;
|
||||
private ItemStatus _itemStatuses;
|
||||
private MachineType _machineTypes;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Negative
|
||||
|
||||
private List<string> _notGameNames;
|
||||
private List<string> _notGameDescriptions;
|
||||
private List<string> _notRomNames;
|
||||
private List<string> _notRomTypes;
|
||||
private List<string> _notCrcs;
|
||||
private List<string> _notMd5s;
|
||||
private List<string> _notSha1s;
|
||||
private List<string> _notSha256s;
|
||||
private List<string> _notSha384s;
|
||||
private List<string> _notSha512s;
|
||||
private ItemStatus _itemNotStatuses;
|
||||
private MachineType _machineNotTypes;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Neutral
|
||||
|
||||
private long _sizeGreaterThanOrEqual;
|
||||
private long _sizeLessThanOrEqual;
|
||||
private long _sizeEqualTo;
|
||||
private bool _includeOfInGame;
|
||||
private bool? _runnable;
|
||||
private bool _single;
|
||||
private bool _trim;
|
||||
private string _root;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Private instance variables
|
||||
|
||||
#region Pubically facing variables
|
||||
|
||||
#region Positive
|
||||
|
||||
public List<string> MachineNames
|
||||
{
|
||||
get { return _gameNames; }
|
||||
set { _gameNames = value; }
|
||||
}
|
||||
public List<string> MachineDescriptions
|
||||
{
|
||||
get { return _gameDescriptions; }
|
||||
set { _gameDescriptions = value; }
|
||||
}
|
||||
public List<string> ItemNames
|
||||
{
|
||||
get { return _romNames; }
|
||||
set { _romNames = value; }
|
||||
}
|
||||
public List<string> ItemTypes
|
||||
{
|
||||
get { return _romTypes; }
|
||||
set { _romTypes = value; }
|
||||
}
|
||||
public List<string> CRCs
|
||||
{
|
||||
get { return _crcs; }
|
||||
set { _crcs = value; }
|
||||
}
|
||||
public List<string> MD5s
|
||||
{
|
||||
get { return _md5s; }
|
||||
set { _md5s = value; }
|
||||
}
|
||||
public List<string> SHA1s
|
||||
{
|
||||
get { return _sha1s; }
|
||||
set { _sha1s = value; }
|
||||
}
|
||||
public List<string> SHA256s
|
||||
{
|
||||
get { return _sha256s; }
|
||||
set { _sha256s = value; }
|
||||
}
|
||||
public List<string> SHA384s
|
||||
{
|
||||
get { return _sha384s; }
|
||||
set { _sha384s = value; }
|
||||
}
|
||||
public List<string> SHA512s
|
||||
{
|
||||
get { return _sha512s; }
|
||||
set { _sha512s = value; }
|
||||
}
|
||||
public ItemStatus ItemStatuses
|
||||
{
|
||||
get { return _itemStatuses; }
|
||||
set { _itemStatuses = value; }
|
||||
}
|
||||
public MachineType MachineTypes
|
||||
{
|
||||
get { return _machineTypes; }
|
||||
set { _machineTypes = value; }
|
||||
}
|
||||
public List<string> MachineNames { get; set; } = new List<string>();
|
||||
public List<string> MachineDescriptions { get; set; } = new List<string>();
|
||||
public List<string> ItemNames { get; set; } = new List<string>();
|
||||
public List<string> ItemTypes { get; set; } = new List<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
|
||||
|
||||
#region Negative
|
||||
|
||||
public List<string> NotMachineNames
|
||||
{
|
||||
get { return _notGameNames; }
|
||||
set { _notGameNames = value; }
|
||||
}
|
||||
public List<string> NotMachineDescriptions
|
||||
{
|
||||
get { return _notGameDescriptions; }
|
||||
set { _notGameDescriptions = value; }
|
||||
}
|
||||
public List<string> NotItemNames
|
||||
{
|
||||
get { return _notRomNames; }
|
||||
set { _notRomNames = value; }
|
||||
}
|
||||
public List<string> NotItemTypes
|
||||
{
|
||||
get { return _notRomTypes; }
|
||||
set { _notRomTypes = value; }
|
||||
}
|
||||
public List<string> NotCRCs
|
||||
{
|
||||
get { return _notCrcs; }
|
||||
set { _notCrcs = value; }
|
||||
}
|
||||
public List<string> NotMD5s
|
||||
{
|
||||
get { return _notMd5s; }
|
||||
set { _notMd5s = value; }
|
||||
}
|
||||
public List<string> NotSHA1s
|
||||
{
|
||||
get { return _notSha1s; }
|
||||
set { _notSha1s = value; }
|
||||
}
|
||||
public List<string> NotSHA256s
|
||||
{
|
||||
get { return _notSha256s; }
|
||||
set { _notSha256s = value; }
|
||||
}
|
||||
public List<string> NotSHA384s
|
||||
{
|
||||
get { return _notSha384s; }
|
||||
set { _notSha384s = value; }
|
||||
}
|
||||
public List<string> NotSHA512s
|
||||
{
|
||||
get { return _notSha512s; }
|
||||
set { _notSha512s = value; }
|
||||
}
|
||||
public ItemStatus NotItemStatuses
|
||||
{
|
||||
get { return _itemNotStatuses; }
|
||||
set { _itemNotStatuses = value; }
|
||||
}
|
||||
public MachineType NotMachineTypes
|
||||
{
|
||||
get { return _machineNotTypes; }
|
||||
set { _machineNotTypes = value; }
|
||||
}
|
||||
public List<string> NotMachineNames { get; set; } = new List<string>();
|
||||
public List<string> NotMachineDescriptions { get; set; } = new List<string>();
|
||||
public List<string> NotItemNames { get; set; } = new List<string>();
|
||||
public List<string> NotItemTypes { get; set; } = new List<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
|
||||
|
||||
#region Neutral
|
||||
|
||||
public long SizeGreaterThanOrEqual
|
||||
{
|
||||
get { return _sizeGreaterThanOrEqual; }
|
||||
set { _sizeGreaterThanOrEqual = value; }
|
||||
}
|
||||
public long SizeLessThanOrEqual
|
||||
{
|
||||
get { return _sizeLessThanOrEqual; }
|
||||
set { _sizeLessThanOrEqual = value; }
|
||||
}
|
||||
public long SizeEqualTo
|
||||
{
|
||||
get { return _sizeEqualTo; }
|
||||
set { _sizeEqualTo = value; }
|
||||
}
|
||||
public bool IncludeOfInGame
|
||||
{
|
||||
get { return _includeOfInGame; }
|
||||
set { _includeOfInGame = value; }
|
||||
}
|
||||
public bool? Runnable
|
||||
{
|
||||
get { return _runnable; }
|
||||
set { _runnable = value; }
|
||||
}
|
||||
public bool Single
|
||||
{
|
||||
get { return _single; }
|
||||
set { _single = value; }
|
||||
}
|
||||
public bool Trim
|
||||
{
|
||||
get { return _trim; }
|
||||
set { _trim = value; }
|
||||
}
|
||||
public string Root
|
||||
{
|
||||
get { return _root; }
|
||||
set { _root = value; }
|
||||
}
|
||||
public long SizeGreaterThanOrEqual { get; set; } = -1;
|
||||
public long SizeLessThanOrEqual { get; set; } = -1;
|
||||
public long SizeEqualTo { get; set; } = -1;
|
||||
public bool IncludeOfInGame { get; set; } = false;
|
||||
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
|
||||
|
||||
#endregion // Pubically facing variables
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty Filter object
|
||||
/// </summary>
|
||||
public Filter()
|
||||
{
|
||||
// Positive
|
||||
_gameNames = new List<string>();
|
||||
_gameDescriptions = new List<string>();
|
||||
_romNames = new List<string>();
|
||||
_romTypes = new List<string>();
|
||||
_crcs = new List<string>();
|
||||
_md5s = new List<string>();
|
||||
_sha1s = new List<string>();
|
||||
_sha256s = new List<string>();
|
||||
_sha384s = new List<string>();
|
||||
_sha512s = new List<string>();
|
||||
_itemStatuses = ItemStatus.NULL;
|
||||
_machineTypes = MachineType.NULL;
|
||||
|
||||
// Negative
|
||||
_notGameNames = new List<string>();
|
||||
_notGameDescriptions = new List<string>();
|
||||
_notRomNames = new List<string>();
|
||||
_notRomTypes = new List<string>();
|
||||
_notCrcs = new List<string>();
|
||||
_notMd5s = new List<string>();
|
||||
_notSha1s = new List<string>();
|
||||
_notSha256s = new List<string>();
|
||||
_notSha384s = new List<string>();
|
||||
_notSha512s = new List<string>();
|
||||
_itemNotStatuses = ItemStatus.NULL;
|
||||
_machineNotTypes = MachineType.NULL;
|
||||
|
||||
// Neutral
|
||||
_sizeGreaterThanOrEqual = -1;
|
||||
_sizeLessThanOrEqual = -1;
|
||||
_sizeEqualTo = -1;
|
||||
_includeOfInGame = false;
|
||||
_runnable = null;
|
||||
_single = false;
|
||||
_trim = false;
|
||||
_root = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance methods
|
||||
|
||||
/// <summary>
|
||||
@@ -320,16 +92,16 @@ namespace SabreTools.Library.DatFiles
|
||||
if (ItemPasses(item))
|
||||
{
|
||||
// If we are in single game mode, rename all games
|
||||
if (_single)
|
||||
if (this.Single)
|
||||
{
|
||||
item.MachineName = "!";
|
||||
}
|
||||
|
||||
// If we are in NTFS trim mode, trim the game name
|
||||
if (_trim)
|
||||
if (this.Trim)
|
||||
{
|
||||
// Windows max name length is 260
|
||||
int usableLength = 260 - item.MachineName.Length - _root.Length;
|
||||
int usableLength = 260 - item.MachineName.Length - this.Root.Length;
|
||||
if (item.Name.Length > usableLength)
|
||||
{
|
||||
string ext = Path.GetExtension(item.Name);
|
||||
@@ -373,17 +145,17 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Filter on machine type
|
||||
if (_machineTypes != MachineType.NULL && (item.MachineType & _machineTypes) == 0)
|
||||
if (this.MachineTypes != MachineType.NULL && (item.MachineType & this.MachineTypes) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_machineNotTypes != MachineType.NULL && (item.MachineType & _machineNotTypes) != 0)
|
||||
if (this.NotMachineTypes != MachineType.NULL && (item.MachineType & this.NotMachineTypes) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on machine runability
|
||||
if (_runnable != null && item.Runnable != _runnable)
|
||||
if (this.Runnable != null && item.Runnable != this.Runnable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -394,135 +166,135 @@ namespace SabreTools.Library.DatFiles
|
||||
Rom rom = (Rom)item;
|
||||
|
||||
// Filter on status
|
||||
if (_itemStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemStatuses) == 0)
|
||||
if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_itemNotStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatuses) != 0)
|
||||
if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on rom size
|
||||
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
||||
if (this.SizeEqualTo != -1 && rom.Size != this.SizeEqualTo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_sizeGreaterThanOrEqual != -1 && rom.Size < _sizeGreaterThanOrEqual)
|
||||
if (this.SizeGreaterThanOrEqual != -1 && rom.Size < this.SizeGreaterThanOrEqual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_sizeLessThanOrEqual != -1 && rom.Size > _sizeLessThanOrEqual)
|
||||
if (this.SizeLessThanOrEqual != -1 && rom.Size > this.SizeLessThanOrEqual)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on CRC
|
||||
if (_crcs.Count > 0)
|
||||
if (this.CRCs.Count > 0)
|
||||
{
|
||||
// If the CRC isn't in the list, return false
|
||||
if (!FindValueInList(_crcs, rom.CRC))
|
||||
if (!FindValueInList(this.CRCs, rom.CRC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notCrcs.Count > 0)
|
||||
if (this.NotCRCs.Count > 0)
|
||||
{
|
||||
// If the CRC is in the list, return false
|
||||
if (FindValueInList(_notCrcs, rom.CRC))
|
||||
if (FindValueInList(this.NotCRCs, rom.CRC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on MD5
|
||||
if (_md5s.Count > 0)
|
||||
if (this.MD5s.Count > 0)
|
||||
{
|
||||
// If the MD5 isn't in the list, return false
|
||||
if (!FindValueInList(_md5s, rom.MD5))
|
||||
if (!FindValueInList(this.MD5s, rom.MD5))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notMd5s.Count > 0)
|
||||
if (this.NotMD5s.Count > 0)
|
||||
{
|
||||
// If the MD5 is in the list, return false
|
||||
if (FindValueInList(_notMd5s, rom.MD5))
|
||||
if (FindValueInList(this.NotMD5s, rom.MD5))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA1
|
||||
if (_sha1s.Count > 0)
|
||||
// Filter on SHA-1
|
||||
if (this.SHA1s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha1s, rom.SHA1))
|
||||
if (!FindValueInList(this.SHA1s, rom.SHA1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha1s.Count > 0)
|
||||
if (this.NotSHA1s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha1s, rom.SHA1))
|
||||
if (FindValueInList(this.NotSHA1s, rom.SHA1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA256
|
||||
if (_sha256s.Count > 0)
|
||||
// Filter on SHA-256
|
||||
if (this.SHA256s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha256s, rom.SHA256))
|
||||
// If the SHA-256 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA256s, rom.SHA256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha256s.Count > 0)
|
||||
if (this.NotSHA256s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha256s, rom.SHA256))
|
||||
// If the SHA-256 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA256s, rom.SHA256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA384
|
||||
if (_sha384s.Count > 0)
|
||||
// Filter on SHA-384
|
||||
if (this.SHA384s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha384s, rom.SHA384))
|
||||
// If the SHA-384 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA384s, rom.SHA384))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha384s.Count > 0)
|
||||
if (this.NotSHA384s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha384s, rom.SHA384))
|
||||
// If the SHA-384 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA384s, rom.SHA384))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA512
|
||||
if (_sha512s.Count > 0)
|
||||
// Filter on SHA-512
|
||||
if (this.SHA512s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha512s, rom.SHA512))
|
||||
// If the SHA-512 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA512s, rom.SHA512))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha512s.Count > 0)
|
||||
if (this.NotSHA512s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha512s, rom.SHA512))
|
||||
// If the SHA-512 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA512s, rom.SHA512))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -533,116 +305,116 @@ namespace SabreTools.Library.DatFiles
|
||||
Disk rom = (Disk)item;
|
||||
|
||||
// Filter on status
|
||||
if (_itemStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemStatuses) == 0)
|
||||
if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_itemNotStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatuses) != 0)
|
||||
if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on MD5
|
||||
if (_md5s.Count > 0)
|
||||
if (this.MD5s.Count > 0)
|
||||
{
|
||||
// If the MD5 isn't in the list, return false
|
||||
if (!FindValueInList(_md5s, rom.MD5))
|
||||
if (!FindValueInList(this.MD5s, rom.MD5))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notMd5s.Count > 0)
|
||||
if (this.NotMD5s.Count > 0)
|
||||
{
|
||||
// If the MD5 is in the list, return false
|
||||
if (FindValueInList(_notMd5s, rom.MD5))
|
||||
if (FindValueInList(this.NotMD5s, rom.MD5))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA1
|
||||
if (_sha1s.Count > 0)
|
||||
// Filter on SHA-1
|
||||
if (this.SHA1s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha1s, rom.SHA1))
|
||||
if (!FindValueInList(this.SHA1s, rom.SHA1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha1s.Count > 0)
|
||||
if (this.NotSHA1s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha1s, rom.SHA1))
|
||||
if (FindValueInList(this.NotSHA1s, rom.SHA1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA256
|
||||
if (_sha256s.Count > 0)
|
||||
// Filter on SHA-256
|
||||
if (this.SHA256s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha256s, rom.SHA256))
|
||||
// If the SHA-256 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA256s, rom.SHA256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha256s.Count > 0)
|
||||
if (this.NotSHA256s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha256s, rom.SHA256))
|
||||
// If the SHA-256 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA256s, rom.SHA256))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA384
|
||||
if (_sha384s.Count > 0)
|
||||
// Filter on SHA-384
|
||||
if (this.SHA384s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha384s, rom.SHA384))
|
||||
// If the SHA-384 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA384s, rom.SHA384))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha384s.Count > 0)
|
||||
if (this.NotSHA384s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha384s, rom.SHA384))
|
||||
// If the SHA-384 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA384s, rom.SHA384))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on SHA512
|
||||
if (_sha512s.Count > 0)
|
||||
// Filter on SHA-512
|
||||
if (this.SHA512s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 isn't in the list, return false
|
||||
if (!FindValueInList(_sha512s, rom.SHA512))
|
||||
// If the SHA-512 isn't in the list, return false
|
||||
if (!FindValueInList(this.SHA512s, rom.SHA512))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notSha512s.Count > 0)
|
||||
if (this.NotSHA512s.Count > 0)
|
||||
{
|
||||
// If the SHA-1 is in the list, return false
|
||||
if (FindValueInList(_notSha512s, rom.SHA512))
|
||||
// If the SHA-512 is in the list, return false
|
||||
if (FindValueInList(this.NotSHA512s, rom.SHA512))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on game name
|
||||
if (_gameNames.Count > 0)
|
||||
// Filter on machine name
|
||||
if (this.MachineNames.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_gameNames, item.MachineName);
|
||||
bool found = FindValueInList(this.MachineNames, item.MachineName);
|
||||
|
||||
// If we are checking CloneOf and RomOf, add them in as well
|
||||
if (_includeOfInGame)
|
||||
if (this.IncludeOfInGame)
|
||||
{
|
||||
found |= FindValueInList(_gameNames, item.CloneOf);
|
||||
found |= FindValueInList(_gameNames, item.RomOf);
|
||||
found |= FindValueInList(this.MachineNames, item.CloneOf);
|
||||
found |= FindValueInList(this.MachineNames, item.RomOf);
|
||||
}
|
||||
|
||||
// If the game name was not found in the list, return false
|
||||
@@ -651,81 +423,81 @@ namespace SabreTools.Library.DatFiles
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notGameNames.Count > 0)
|
||||
if (this.NotMachineNames.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_notGameNames, item.MachineName);
|
||||
bool found = FindValueInList(this.NotMachineNames, item.MachineName);
|
||||
|
||||
// If we are checking CloneOf and RomOf, add them in as well
|
||||
if (_includeOfInGame)
|
||||
if (this.IncludeOfInGame)
|
||||
{
|
||||
found |= FindValueInList(_notGameNames, item.CloneOf);
|
||||
found |= FindValueInList(_notGameNames, item.RomOf);
|
||||
found |= FindValueInList(this.NotMachineNames, item.CloneOf);
|
||||
found |= FindValueInList(this.NotMachineNames, item.RomOf);
|
||||
}
|
||||
|
||||
// If the game name was found in the list, return false
|
||||
// If the machine name was found in the list, return false
|
||||
if (found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on game description
|
||||
if (_gameDescriptions.Count > 0)
|
||||
// Filter on machine description
|
||||
if (this.MachineDescriptions.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_gameDescriptions, item.MachineDescription);
|
||||
bool found = FindValueInList(this.MachineDescriptions, item.MachineDescription);
|
||||
|
||||
// If the game description was not found in the list, return false
|
||||
// If the machine description was not found in the list, return false
|
||||
if (!found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notGameDescriptions.Count > 0)
|
||||
if (this.NotMachineDescriptions.Count > 0)
|
||||
{
|
||||
bool found = FindValueInList(_notGameDescriptions, item.MachineDescription);
|
||||
bool found = FindValueInList(this.NotMachineDescriptions, item.MachineDescription);
|
||||
|
||||
// If the game description was found in the list, return false
|
||||
// If the machine description was found in the list, return false
|
||||
if (found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on rom name
|
||||
if (_romNames.Count > 0)
|
||||
// Filter on item name
|
||||
if (this.ItemNames.Count > 0)
|
||||
{
|
||||
// If the rom name was not found in the list, return false
|
||||
if (!FindValueInList(_romNames, item.Name))
|
||||
// If the item name was not found in the list, return false
|
||||
if (!FindValueInList(this.ItemNames, item.Name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notRomNames.Count > 0)
|
||||
if (this.NotItemNames.Count > 0)
|
||||
{
|
||||
// If the rom name was found in the list, return false
|
||||
if (FindValueInList(_notRomNames, item.Name))
|
||||
// If the item name was found in the list, return false
|
||||
if (FindValueInList(this.NotItemNames, item.Name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on rom type
|
||||
if (_romTypes.Count == 0 && _notRomTypes.Count == 0 && item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank)
|
||||
// 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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_romTypes.Count > 0)
|
||||
if (this.ItemTypes.Count > 0)
|
||||
{
|
||||
// If the rom type was not found in the list, return false
|
||||
if (!FindValueInList(_romTypes, item.ItemType.ToString()))
|
||||
// If the item type was not found in the list, return false
|
||||
if (!FindValueInList(this.ItemTypes, item.ItemType.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_notRomTypes.Count > 0)
|
||||
if (this.NotItemTypes.Count > 0)
|
||||
{
|
||||
// If the rom type was found in the list, return false
|
||||
if (FindValueInList(_notRomTypes, item.ItemType.ToString()))
|
||||
// If the item type was found in the list, return false
|
||||
if (FindValueInList(this.NotItemTypes, item.ItemType.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user