mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Filter] Add support for filtering on machine type
This commit is contained in:
@@ -359,6 +359,12 @@ namespace SabreTools.Helper.Data
|
|||||||
helptext.Add(" -nis=, --not-status= Exclude items with a given status");
|
helptext.Add(" -nis=, --not-status= Exclude items with a given status");
|
||||||
helptext.Add(" Supported values are:");
|
helptext.Add(" Supported values are:");
|
||||||
helptext.Add(" None, Good, BadDump, Nodump, Verified");
|
helptext.Add(" None, Good, BadDump, Nodump, Verified");
|
||||||
|
helptext.Add(" -gt=, --game-type= Include only games with a given type");
|
||||||
|
helptext.Add(" Supported values are:");
|
||||||
|
helptext.Add(" None, Bios, Device, Mechanical");
|
||||||
|
helptext.Add(" -ngt=, --not-gtype= Exclude only games with a given type");
|
||||||
|
helptext.Add(" Supported values are:");
|
||||||
|
helptext.Add(" None, Bios, Device, Mechanical");
|
||||||
helptext.Add(" -out= Output directory (overridden by --inplace)");
|
helptext.Add(" -out= Output directory (overridden by --inplace)");
|
||||||
helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)");
|
helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)");
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace SabreTools.Helper.Dats
|
|||||||
private string _notSha1;
|
private string _notSha1;
|
||||||
private ItemStatus _itemStatus;
|
private ItemStatus _itemStatus;
|
||||||
private ItemStatus _itemNotStatus;
|
private ItemStatus _itemNotStatus;
|
||||||
|
private MachineType _machineType;
|
||||||
|
private MachineType _machineNotType;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -65,17 +67,19 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// <param name="md5">MD5 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="md5">MD5 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="itemStatus">Select roms with the given status</param>
|
/// <param name="itemStatus">Select roms with the given status</param>
|
||||||
|
/// <param name="machineType">Select games with the given type</param>
|
||||||
/// <param name="notgamename">Name of the game to match (can use asterisk-partials)</param>
|
/// <param name="notgamename">Name of the game to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notromname">Name of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notromname">Name of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notromtype">Type of the rom to match</param>
|
/// <param name="notromtype">Type of the rom to match</param>
|
||||||
/// <param name="notcrc">CRC of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notcrc">CRC of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notmd5">MD5 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notmd5">MD5 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="itemNotStatus">Select roms with the given status</param>
|
/// <param name="itemNotStatus">Select roms without the given status</param>
|
||||||
|
/// <param name="machineNotType">Select games without the given type</param>
|
||||||
public Filter(string gamename, string romname, string romtype, long sgt,
|
public Filter(string gamename, string romname, string romtype, long sgt,
|
||||||
long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus,
|
long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus,
|
||||||
string notgamename, string notromname, string notromtype, string notcrc, string notmd5,
|
MachineType machineType, string notgamename, string notromname, string notromtype,
|
||||||
string notsha1, ItemStatus itemNotStatus)
|
string notcrc, string notmd5, string notsha1, ItemStatus itemNotStatus, MachineType machineNotType)
|
||||||
{
|
{
|
||||||
_gameName = gamename;
|
_gameName = gamename;
|
||||||
_notGameName = notgamename;
|
_notGameName = notgamename;
|
||||||
@@ -94,6 +98,8 @@ namespace SabreTools.Helper.Dats
|
|||||||
_notSha1 = notsha1;
|
_notSha1 = notsha1;
|
||||||
_itemStatus = itemStatus;
|
_itemStatus = itemStatus;
|
||||||
_itemNotStatus = itemNotStatus;
|
_itemNotStatus = itemNotStatus;
|
||||||
|
_machineType = machineType;
|
||||||
|
_machineNotType = machineNotType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -119,6 +125,16 @@ namespace SabreTools.Helper.Dats
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter on machine type
|
||||||
|
if (_machineType != MachineType.NULL && rom.Machine.MachineType != _machineType)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_machineNotType != MachineType.NULL && rom.Machine.MachineType == _machineNotType)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Filter on rom size
|
// Filter on rom size
|
||||||
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -825,9 +825,17 @@ Options:
|
|||||||
None, Good, BadDump, Nodump, Verified
|
None, Good, BadDump, Nodump, Verified
|
||||||
|
|
||||||
-nis=, --not-status= Exclude only items with a given status
|
-nis=, --not-status= Exclude only items with a given status
|
||||||
Include items with one of the supported values:
|
Exclude items with one of the supported values:
|
||||||
None, Good, BadDump, Nodump, Verified
|
None, Good, BadDump, Nodump, Verified
|
||||||
|
|
||||||
|
-gt=, --game-type= Include only items with the given game type
|
||||||
|
Include items with one of the supported values:
|
||||||
|
None, Bios, Device, Mechanical
|
||||||
|
|
||||||
|
-ngt=, --not-gtype= Exclude only items with a given game type
|
||||||
|
Exclude items with one of the supported values:
|
||||||
|
None, Bios, Device, Mechanical
|
||||||
|
|
||||||
-out= Set the name of the output directory
|
-out= Set the name of the output directory
|
||||||
This sets an output folder to be used when the files are created. If a path
|
This sets an output folder to be used when the files are created. If a path
|
||||||
is not defined, the application directory is used instead.
|
is not defined, the application directory is used instead.
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ namespace SabreTools
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrap converting and updating DAT file from any format to any format
|
/// Wrap converting and updating DAT file from any format to any format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">List of input filenames</param>
|
/// <param name="inputs">List of input filenames</param>
|
||||||
/// /* Normal DAT header info */
|
/// /* Normal DAT header info */
|
||||||
/// <param name="filename">New filename</param>
|
/// <param name="filename">New filename</param>
|
||||||
/// <param name="name">New name</param>
|
/// <param name="name">New name</param>
|
||||||
@@ -437,13 +437,15 @@ namespace SabreTools
|
|||||||
/// <param name="md5">MD5 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="md5">MD5 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="status">Select roms with the given item status</param>
|
/// <param name="status">Select roms with the given item status</param>
|
||||||
|
/// <param name="gametype">Select games with the given type</param>
|
||||||
/// <param name="notgamename">Name of the game to match (can use asterisk-partials)</param>
|
/// <param name="notgamename">Name of the game to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notromname">Name of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notromname">Name of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notromtype">Type of the rom to match</param>
|
/// <param name="notromtype">Type of the rom to match</param>
|
||||||
/// <param name="notcrc">CRC of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notcrc">CRC of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notmd5">MD5 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notmd5">MD5 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="notstatus">Select roms with the given item status</param>
|
/// <param name="notstatus">Select roms without the given item status</param>
|
||||||
|
/// <param name="notgametype">Select games without the given type</param>
|
||||||
/// /* Trimming info */
|
/// /* Trimming info */
|
||||||
/// <param name="trim">True if we are supposed to trim names to NTFS length, false otherwise</param>
|
/// <param name="trim">True if we are supposed to trim names to NTFS length, false otherwise</param>
|
||||||
/// <param name="single">True if all games should be replaced by '!', false otherwise</param>
|
/// <param name="single">True if all games should be replaced by '!', false otherwise</param>
|
||||||
@@ -506,6 +508,7 @@ namespace SabreTools
|
|||||||
string md5,
|
string md5,
|
||||||
string sha1,
|
string sha1,
|
||||||
string status,
|
string status,
|
||||||
|
string gametype,
|
||||||
string notgamename,
|
string notgamename,
|
||||||
string notromname,
|
string notromname,
|
||||||
string notromtype,
|
string notromtype,
|
||||||
@@ -513,6 +516,7 @@ namespace SabreTools
|
|||||||
string notmd5,
|
string notmd5,
|
||||||
string notsha1,
|
string notsha1,
|
||||||
string notstatus,
|
string notstatus,
|
||||||
|
string notgametype,
|
||||||
|
|
||||||
/* Trimming info */
|
/* Trimming info */
|
||||||
bool trim,
|
bool trim,
|
||||||
@@ -619,6 +623,44 @@ namespace SabreTools
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the machine type flag for filtering
|
||||||
|
MachineType machineType = MachineType.NULL;
|
||||||
|
switch(gametype?.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
machineType = MachineType.None;
|
||||||
|
break;
|
||||||
|
case "bios":
|
||||||
|
machineType = MachineType.Bios;
|
||||||
|
break;
|
||||||
|
case "device":
|
||||||
|
machineType = MachineType.Device;
|
||||||
|
break;
|
||||||
|
case "mech":
|
||||||
|
case "mechanical":
|
||||||
|
machineType = MachineType.Mechanical;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the not machine type flag for filtering
|
||||||
|
MachineType machineNotType = MachineType.NULL;
|
||||||
|
switch (gametype?.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
machineNotType = MachineType.None;
|
||||||
|
break;
|
||||||
|
case "bios":
|
||||||
|
machineNotType = MachineType.Bios;
|
||||||
|
break;
|
||||||
|
case "device":
|
||||||
|
machineNotType = MachineType.Device;
|
||||||
|
break;
|
||||||
|
case "mech":
|
||||||
|
case "mechanical":
|
||||||
|
machineNotType = MachineType.Mechanical;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize the extensions
|
// Normalize the extensions
|
||||||
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
|
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
|
||||||
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
|
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
|
||||||
@@ -689,8 +731,8 @@ namespace SabreTools
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create the Filter object to be used
|
// Create the Filter object to be used
|
||||||
Filter filter = new Filter(gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus,
|
Filter filter = new Filter(gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, machineType,
|
||||||
notgamename, notromname, notromtype, notcrc, notmd5, notsha1, itemNotStatus);
|
notgamename, notromname, notromtype, notcrc, notmd5, notsha1, itemNotStatus, machineNotType);
|
||||||
|
|
||||||
userInputDat.DetermineUpdateType(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist,
|
userInputDat.DetermineUpdateType(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist,
|
||||||
filter, trim, single, root, maxDegreeOfParallelism, _logger);
|
filter, trim, single, root, maxDegreeOfParallelism, _logger);
|
||||||
|
|||||||
@@ -127,12 +127,14 @@ namespace SabreTools
|
|||||||
forcend = "",
|
forcend = "",
|
||||||
forcepack = "",
|
forcepack = "",
|
||||||
gamename = "",
|
gamename = "",
|
||||||
|
gametype = "",
|
||||||
header = null,
|
header = null,
|
||||||
homepage = null,
|
homepage = null,
|
||||||
md5 = "",
|
md5 = "",
|
||||||
name = null,
|
name = null,
|
||||||
notcrc = null,
|
notcrc = null,
|
||||||
notgamename = null,
|
notgamename = null,
|
||||||
|
notgametype = "",
|
||||||
notmd5 = null,
|
notmd5 = null,
|
||||||
notromname = null,
|
notromname = null,
|
||||||
notromtype = null,
|
notromtype = null,
|
||||||
@@ -540,6 +542,10 @@ namespace SabreTools
|
|||||||
case "--game-name":
|
case "--game-name":
|
||||||
gamename = args[++i];
|
gamename = args[++i];
|
||||||
break;
|
break;
|
||||||
|
case "-gt":
|
||||||
|
case "--game-type":
|
||||||
|
gametype = args[++i];
|
||||||
|
break;
|
||||||
case "-gz":
|
case "-gz":
|
||||||
case "--gz":
|
case "--gz":
|
||||||
if (!Int32.TryParse(args[++i], out gz))
|
if (!Int32.TryParse(args[++i], out gz))
|
||||||
@@ -579,6 +585,10 @@ namespace SabreTools
|
|||||||
case "--not-game":
|
case "--not-game":
|
||||||
notgamename = args[++i];
|
notgamename = args[++i];
|
||||||
break;
|
break;
|
||||||
|
case "-ngt":
|
||||||
|
case "--not-gtype":
|
||||||
|
notgametype = args[++i];
|
||||||
|
break;
|
||||||
case "-nis":
|
case "-nis":
|
||||||
case "--not-status":
|
case "--not-status":
|
||||||
notstatus = args[++i];
|
notstatus = args[++i];
|
||||||
@@ -765,6 +775,10 @@ namespace SabreTools
|
|||||||
case "--game-name":
|
case "--game-name":
|
||||||
gamename = split[1];
|
gamename = split[1];
|
||||||
break;
|
break;
|
||||||
|
case "-gt":
|
||||||
|
case "--game-type":
|
||||||
|
gametype = split[1];
|
||||||
|
break;
|
||||||
case "-gz":
|
case "-gz":
|
||||||
case "--gz":
|
case "--gz":
|
||||||
if (!Int32.TryParse(split[1], out gz))
|
if (!Int32.TryParse(split[1], out gz))
|
||||||
@@ -804,6 +818,10 @@ namespace SabreTools
|
|||||||
case "--not-game":
|
case "--not-game":
|
||||||
notgamename = split[1];
|
notgamename = split[1];
|
||||||
break;
|
break;
|
||||||
|
case "-ngt":
|
||||||
|
case "--not-gtype":
|
||||||
|
notgametype = split[1];
|
||||||
|
break;
|
||||||
case "-nis":
|
case "-nis":
|
||||||
case "--not-status":
|
case "--not-status":
|
||||||
notstatus = split[1];
|
notstatus = split[1];
|
||||||
@@ -1038,8 +1056,8 @@ namespace SabreTools
|
|||||||
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
|
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
|
||||||
superdat, forcemerge, forcend, forcepack, excludeOf, datFormat, usegame, prefix,
|
superdat, forcemerge, forcend, forcepack, excludeOf, datFormat, usegame, prefix,
|
||||||
postfix, quotes, repext, addext, remext, datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName,
|
postfix, quotes, repext, addext, remext, datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName,
|
||||||
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, status,
|
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, status, gametype,
|
||||||
notgamename, notromname, notromtype, notcrc, notmd5, notsha1, notstatus,
|
notgamename, notromname, notromtype, notcrc, notmd5, notsha1, notstatus, notgametype,
|
||||||
trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism);
|
trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user