2016-10-26 21:02:01 -07:00
|
|
|
|
using System;
|
2017-01-11 17:27:25 -08:00
|
|
|
|
using System.Collections.Generic;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
|
|
|
|
|
using SabreTools.Helper.Data;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.Helper.Dats
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Filter
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Private instance variables
|
|
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
private List<string> _gameNames;
|
|
|
|
|
|
private List<string> _notGameNames;
|
|
|
|
|
|
private List<string> _romNames;
|
|
|
|
|
|
private List<string> _notRomNames;
|
|
|
|
|
|
private List<string> _romTypes;
|
|
|
|
|
|
private List<string> _notRomTypes;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
private long _sizeGreaterThanOrEqual;
|
|
|
|
|
|
private long _sizeLessThanOrEqual;
|
|
|
|
|
|
private long _sizeEqualTo;
|
2017-01-11 17:27:25 -08:00
|
|
|
|
private List<string> _crcs;
|
|
|
|
|
|
private List<string> _notCrcs;
|
|
|
|
|
|
private List<string> _md5s;
|
|
|
|
|
|
private List<string> _notMd5s;
|
|
|
|
|
|
private List<string> _sha1s;
|
|
|
|
|
|
private List<string> _notSha1s;
|
|
|
|
|
|
private ItemStatus _itemStatuses;
|
|
|
|
|
|
private ItemStatus _itemNotStatuses;
|
|
|
|
|
|
private MachineType _machineTypes;
|
|
|
|
|
|
private MachineType _machineNotTypes;
|
2017-01-08 23:20:58 -08:00
|
|
|
|
private bool? _runnable;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create an empty Filter object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Filter()
|
|
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
_gameNames = null;
|
|
|
|
|
|
_notGameNames = null;
|
|
|
|
|
|
_romNames = null;
|
|
|
|
|
|
_notRomNames = null;
|
|
|
|
|
|
_romTypes = null;
|
|
|
|
|
|
_notRomTypes = null;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
_sizeGreaterThanOrEqual = -1;
|
|
|
|
|
|
_sizeLessThanOrEqual = -1;
|
|
|
|
|
|
_sizeEqualTo = -1;
|
2017-01-11 17:27:25 -08:00
|
|
|
|
_crcs = null;
|
|
|
|
|
|
_notCrcs = null;
|
|
|
|
|
|
_md5s = null;
|
|
|
|
|
|
_notMd5s = null;
|
|
|
|
|
|
_sha1s = null;
|
|
|
|
|
|
_notSha1s = null;
|
|
|
|
|
|
_itemStatuses = ItemStatus.NULL;
|
|
|
|
|
|
_itemNotStatuses = ItemStatus.NULL;
|
|
|
|
|
|
_machineTypes = MachineType.NULL;
|
|
|
|
|
|
_machineNotTypes = MachineType.NULL;
|
2017-01-08 23:20:58 -08:00
|
|
|
|
_runnable = null;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a populated Filter object
|
|
|
|
|
|
/// </summary>
|
2017-01-11 17:27:25 -08:00
|
|
|
|
/// <param name="gamenames">Names of the games to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="romnames">Names of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="romtypes">Types of the roms to match</param>
|
2016-10-26 21:02:01 -07:00
|
|
|
|
/// <param name="sgt">Find roms greater than or equal to this size</param>
|
|
|
|
|
|
/// <param name="slt">Find roms less than or equal to this size</param>
|
|
|
|
|
|
/// <param name="seq">Find roms equal to this size</param>
|
2017-01-11 17:27:25 -08:00
|
|
|
|
/// <param name="crcs">CRCs of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="md5s">MD5s of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="sha1s">SHA-1s of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="itemStatuses">Select roms with the given status</param>
|
|
|
|
|
|
/// <param name="machineTypes">Select games with the given type</param>
|
|
|
|
|
|
/// <param name="notgamenames">Names of the games to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="notromnames">Names of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="notromtypes">Type of the roms to match</param>
|
|
|
|
|
|
/// <param name="notcrcs">CRCs of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="notmd5s">MD5s of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="notsha1s">SHA-1s of the roms to match (can use asterisk-partials)</param>
|
|
|
|
|
|
/// <param name="itemNotStatuses">Select roms without the given status</param>
|
|
|
|
|
|
/// <param name="machineNotTypes">Select games without the given type</param>
|
2017-01-08 23:20:58 -08:00
|
|
|
|
/// <param name="runnable">Select games that have a value for runnable</param>
|
2017-01-11 17:27:25 -08:00
|
|
|
|
public Filter(List<string> gamenames, List<string> romnames, List<string> romtypes, long sgt,
|
|
|
|
|
|
long slt, long seq, List<string> crcs, List<string> md5s, List<string> sha1s, ItemStatus itemStatuses,
|
|
|
|
|
|
MachineType machineTypes, List<string> notgamenames, List<string> notromnames, List<string> notromtypes,
|
|
|
|
|
|
List<string> notcrcs, List<string> notmd5s, List<string> notsha1s, ItemStatus itemNotStatuses,
|
|
|
|
|
|
MachineType machineNotTypes, bool? runnable)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
_gameNames = gamenames;
|
|
|
|
|
|
_notGameNames = notgamenames;
|
|
|
|
|
|
_romNames = romnames;
|
|
|
|
|
|
_notRomNames = notromnames;
|
|
|
|
|
|
_romTypes = romtypes;
|
|
|
|
|
|
_notRomTypes = notromtypes;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
_sizeGreaterThanOrEqual = sgt;
|
|
|
|
|
|
_sizeLessThanOrEqual = slt;
|
|
|
|
|
|
_sizeEqualTo = seq;
|
2017-01-11 17:27:25 -08:00
|
|
|
|
_crcs = crcs;
|
|
|
|
|
|
_notCrcs = notcrcs;
|
|
|
|
|
|
_md5s = md5s;
|
|
|
|
|
|
_notMd5s = notmd5s;
|
|
|
|
|
|
_sha1s = sha1s;
|
|
|
|
|
|
_notSha1s = notsha1s;
|
|
|
|
|
|
_itemStatuses = itemStatuses;
|
|
|
|
|
|
_itemNotStatuses = itemNotStatuses;
|
|
|
|
|
|
_machineTypes = machineTypes;
|
|
|
|
|
|
_machineNotTypes = machineNotTypes;
|
2017-01-08 23:20:58 -08:00
|
|
|
|
_runnable = runnable;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Check to see if a DatItem passes the filter
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="item">DatItem to check</param>
|
|
|
|
|
|
/// <param name="logger">Logger object for file and console output</param>
|
|
|
|
|
|
/// <returns>True if the file passed the filter, false otherwise</returns>
|
|
|
|
|
|
public bool ItemPasses(DatItem item, Logger logger)
|
|
|
|
|
|
{
|
2017-01-12 14:15:30 -08:00
|
|
|
|
// If the item is null, we automatically fail it
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If the item's machine is null, we automatically fail it
|
|
|
|
|
|
if (item.Machine == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-08 23:20:58 -08:00
|
|
|
|
// Filter on machine type
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_machineTypes != MachineType.NULL && (item.Machine.MachineType & _machineTypes) == 0)
|
2017-01-08 23:20:58 -08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_machineNotTypes != MachineType.NULL && (item.Machine.MachineType & _machineNotTypes) != 0)
|
2017-01-08 23:20:58 -08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on machine runability
|
|
|
|
|
|
if (_runnable != null && item.Machine.Runnable != _runnable)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-10-26 21:02:01 -07:00
|
|
|
|
// Take care of Rom and Disk specific differences
|
|
|
|
|
|
if (item.Type == ItemType.Rom)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rom rom = (Rom)item;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on status
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_itemStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemStatuses) == 0)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2016-12-05 10:53:08 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_itemNotStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatuses) != 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on rom size
|
|
|
|
|
|
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_sizeGreaterThanOrEqual != -1 && rom.Size < _sizeGreaterThanOrEqual)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_sizeLessThanOrEqual != -1 && rom.Size > _sizeLessThanOrEqual)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-05 10:53:08 -08:00
|
|
|
|
// Filter on CRC
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_crcs.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string crc in _crcs)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(crc))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (crc.StartsWith("*") && crc.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.CRC.ToLowerInvariant().Contains(crc.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (crc.StartsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.CRC.EndsWith(crc.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (crc.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.CRC.StartsWith(crc.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.Equals(rom.CRC, crc, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the CRC didn't match, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_notCrcs.Count > 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string crc in _notCrcs)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (crc.StartsWith("*") && crc.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.CRC.ToLowerInvariant().Contains(crc.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (crc.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.CRC.EndsWith(crc.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (crc.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.CRC.StartsWith(crc.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(rom.CRC, crc, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
// If the CRC matched, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on MD5
|
|
|
|
|
|
if (_md5s.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string md5 in _md5s)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(md5))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md5.StartsWith("*") && md5.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.ToLowerInvariant().Contains(md5.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (md5.StartsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.EndsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (md5.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.StartsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.Equals(rom.MD5, md5, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the MD5 didn't match, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_notMd5s.Count > 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string md5 in _notMd5s)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (md5.StartsWith("*") && md5.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.MD5.ToLowerInvariant().Contains(md5.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (md5.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.MD5.EndsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (md5.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.MD5.StartsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(rom.MD5, md5, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
// If the MD5 matched, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on SHA1
|
|
|
|
|
|
if (_sha1s.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string sha1 in _sha1s)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(sha1))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sha1.StartsWith("*") && sha1.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.ToLowerInvariant().Contains(sha1.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (sha1.StartsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.EndsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (sha1.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.StartsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.Equals(rom.SHA1, sha1, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the SHA1 didn't match, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_notSha1s.Count > 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string sha1 in _notSha1s)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (sha1.StartsWith("*") && sha1.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.ToLowerInvariant().Contains(sha1.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (sha1.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.EndsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (sha1.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.StartsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(rom.SHA1, sha1, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the SHA1 matched, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
else if (item.Type == ItemType.Disk)
|
|
|
|
|
|
{
|
|
|
|
|
|
Disk rom = (Disk)item;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on status
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_itemStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemStatuses) == 0)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2016-12-05 10:53:08 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_itemNotStatuses != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatuses) != 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-05 10:53:08 -08:00
|
|
|
|
// Filter on MD5
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_md5s.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string md5 in _md5s)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(md5))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md5.StartsWith("*") && md5.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.ToLowerInvariant().Contains(md5.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (md5.StartsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.EndsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (md5.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.MD5.StartsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.Equals(rom.MD5, md5, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If the MD5 didn't match, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_notMd5s.Count > 0)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string md5 in _notMd5s)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (md5.StartsWith("*") && md5.EndsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.MD5.ToLowerInvariant().Contains(md5.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (md5.StartsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.MD5.EndsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (md5.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (rom.MD5.StartsWith(md5.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(rom.MD5, md5, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the MD5 matched, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on SHA1
|
|
|
|
|
|
if (_sha1s.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string sha1 in _sha1s)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.IsNullOrEmpty(sha1))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sha1.StartsWith("*") && sha1.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.ToLowerInvariant().Contains(sha1.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (sha1.StartsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.EndsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (sha1.EndsWith("*"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!rom.SHA1.StartsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!String.Equals(rom.SHA1, sha1, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the SHA1 didn't match, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_notSha1s.Count > 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string sha1 in _notSha1s)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (sha1.StartsWith("*") && sha1.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.ToLowerInvariant().Contains(sha1.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (sha1.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.EndsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (sha1.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (rom.SHA1.StartsWith(sha1.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(rom.SHA1, sha1, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the SHA1 matched, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
// Filter on game name
|
|
|
|
|
|
if (_gameNames.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string name in _gameNames)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (name.StartsWith("*") && name.EndsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Machine.Name.ToLowerInvariant().Contains(name.ToLowerInvariant().Replace("*", "")))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.StartsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Machine.Name.EndsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.EndsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Machine.Name.StartsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!String.Equals(item.Machine.Name, name, StringComparison.InvariantCultureIgnoreCase))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the game name was not matched, return false
|
|
|
|
|
|
if (!found)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_notGameNames.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string name in _notGameNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (name.StartsWith("*") && name.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Machine.Name.ToLowerInvariant().Contains(name.ToLowerInvariant().Replace("*", "")))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Machine.Name.EndsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Machine.Name.StartsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(item.Machine.Name, name, StringComparison.InvariantCultureIgnoreCase))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the game name was matched, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
// Filter on rom name
|
|
|
|
|
|
if (_romNames.Count > 0)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string name in _romNames)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (name.StartsWith("*") && name.EndsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Name.ToLowerInvariant().Contains(name.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.StartsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Name.EndsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.EndsWith("*"))
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!item.Name.StartsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!String.Equals(item.Name, name, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the rom name was not matched, return false
|
|
|
|
|
|
if (!found)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (_notRomNames.Count > 0)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string name in _notRomNames)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (name.StartsWith("*") && name.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Name.ToLowerInvariant().Contains(name.ToLowerInvariant().Replace("*", "")))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.StartsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Name.EndsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else if (name.EndsWith("*"))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (item.Name.StartsWith(name.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
else
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(item.Name, name, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
found = false;
|
|
|
|
|
|
}
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
2017-01-11 17:27:25 -08:00
|
|
|
|
// If the rom name was matched, return false
|
|
|
|
|
|
if (!found)
|
2016-10-26 21:02:01 -07:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-10-26 21:02:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// Filter on rom type
|
|
|
|
|
|
if (_romTypes.Count == 0 && _notRomTypes.Count == 0 && item.Type != ItemType.Rom && item.Type != ItemType.Disk)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_romTypes.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string type in _romTypes)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (!String.Equals(item.Type.ToString(), type, StringComparison.InvariantCultureIgnoreCase))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the rom type was not found, return false
|
|
|
|
|
|
if (!found)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
}
|
|
|
|
|
|
if (_notRomTypes.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool found = true;
|
|
|
|
|
|
foreach (string type in _notRomTypes)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
if (String.Equals(item.Type.ToString(), type, StringComparison.InvariantCultureIgnoreCase))
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
found = false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-11 17:27:25 -08:00
|
|
|
|
|
|
|
|
|
|
// If the rom type was found, return false
|
|
|
|
|
|
if (!found)
|
2016-12-05 10:53:08 -08:00
|
|
|
|
{
|
2017-01-11 17:27:25 -08:00
|
|
|
|
return false;
|
2016-12-05 10:53:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-10-26 21:02:01 -07:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|