mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Add filtering support to D2D and Verify
Verify came for free since it uses the D2D code
This commit is contained in:
@@ -3277,8 +3277,9 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="copyFiles">True if files should be copied to the temp directory before hashing, false otherwise</param>
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <param name="chdsAsFiles">True if CHDs should be treated like regular files, false otherwise</param>
|
||||
/// <param name="filter">Filter object to be passed to the DatItem level</param>
|
||||
public bool PopulateFromDir(string basePath, Hash omitFromScan, bool bare, bool archivesAsFiles, SkipFileType skipFileType,
|
||||
bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles)
|
||||
bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles, Filter filter)
|
||||
{
|
||||
// If the description is defined but not the name, set the name from the description
|
||||
if (String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
|
||||
@@ -3379,6 +3380,12 @@ namespace SabreTools.Library.DatFiles
|
||||
Utilities.TryDeleteDirectory(tempDir);
|
||||
}
|
||||
|
||||
// If we have a valid filter, perform the filtering now
|
||||
if (filter != null && filter != default(Filter))
|
||||
{
|
||||
filter.FilterDatFile(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4523,8 +4530,9 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
/// <param name="chdsAsFiles">True if CHDs should be treated like regular files, false otherwise</param>
|
||||
/// <param name="filter">Filter object to be passed to the DatItem level</param>
|
||||
/// <returns>True if verification was a success, false otherwise</returns>
|
||||
public bool VerifyGeneric(List<string> inputs, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool chdsAsFiles)
|
||||
public bool VerifyGeneric(List<string> inputs, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool chdsAsFiles, Filter filter)
|
||||
{
|
||||
// TODO: We want the cross section of what's the folder and what's in the DAT. Right now, it just has what's in the DAT that's not in the folder
|
||||
bool success = true;
|
||||
@@ -4535,7 +4543,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
PopulateFromDir(input, (quickScan ? Hash.SecureHashes : Hash.DeepHashes) /* omitFromScan */, true /* bare */, false /* archivesAsFiles */,
|
||||
SkipFileType.None, false /* addBlanks */, false /* addDate */, "" /* tempDir */, false /* copyFiles */, headerToCheckAgainst, chdsAsFiles);
|
||||
SkipFileType.None, false /* addBlanks */, false /* addDate */, "" /* tempDir */, false /* copyFiles */, headerToCheckAgainst, chdsAsFiles, filter);
|
||||
}
|
||||
|
||||
// Setup the fixdat
|
||||
|
||||
@@ -330,6 +330,165 @@ Options:
|
||||
compare against the input DATs. This flag forces all CHDs to be
|
||||
treated like regular files.
|
||||
|
||||
-gn=, --game-name= Filter by game name
|
||||
Include only items with this game name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ngn=, --not-game-name= Filter by not game name
|
||||
Include only items without this game name in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-gd=, --game-description= Filter by game description
|
||||
Include only items with this game description in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-ngd=, --not-game-description= Filter by not game description
|
||||
Include only items without this game description in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-ofg, --match-of-tags Allow cloneof and romof tags to match game name filters
|
||||
If filter or exclude by game name is used, this flag will allow those
|
||||
filters to be checked against the romof and cloneof tags as well.
|
||||
This can allow for more advanced set-building, especially in
|
||||
arcade-based sets.
|
||||
|
||||
-rn=, --item-name= Filter by item name
|
||||
Include only items with this item name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nrn=, --not-item-name= Filter by not item name
|
||||
Include only items without this item name in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-rt=, --item-type= Filter by item type
|
||||
Include only items with this item type in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nrt=, --not-item-type= Filter by not item type
|
||||
Include only items without this item type in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sgt=, --greater= Filter by size >=
|
||||
Only include items whose size is greater than or equal to this value
|
||||
in the output DAT. Users can specify either a regular integer number
|
||||
or a number with a standard postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-slt=, --less= Filter by size =<
|
||||
Only include items whose size is less than or equal to this value in
|
||||
the output DAT. Users can specify either a regular integer number or
|
||||
a number with a standard postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-seq=, --equal= Filter by size ==
|
||||
Only include items of this exact size in the output DAT. Users can
|
||||
specify either a regular integer number or a number with a standard
|
||||
postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-crc=, --crc= Filter by CRC hash
|
||||
Include only items with this CRC hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ncrc=, --not-crc= Filter by not CRC hash
|
||||
Include only items without this CRC hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-md5=, --md5= Filter by MD5 hash
|
||||
Include only items with this MD5 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nmd5=, --not-md5= Filter by not MD5 hash
|
||||
Include only items without this MD5 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-sha1=, --sha1= Filter by SHA-1 hash
|
||||
Include only items with this SHA-1 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nsha1=, --not-sha1= Filter by not SHA-1 hash
|
||||
Include only items without this SHA-1 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha256=, --sha256= Filter by SHA-256 hash
|
||||
Include only items with this SHA-256 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha256=, --not-sha256= Filter by not SHA-256 hash
|
||||
Include only items without this SHA-256 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha384=, --sha384= Filter by SHA-384 hash
|
||||
Include only items with this SHA-384 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha384=, --not-sha384= Filter by not SHA-384 hash
|
||||
Include only items without this SHA-384 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha512=, --sha512= Filter by SHA-512 hash
|
||||
Include only items with this SHA-512 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha512=, --not-sha512= Filter by not SHA-512 hash
|
||||
Include only items without this SHA-512 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-is=, --status= Include only items with a given status
|
||||
Include only items with this item status in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Good, BadDump, Nodump, Verified
|
||||
|
||||
-nis=, --not-status= Exclude only items with a given status
|
||||
Include only items without this item status in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Good, BadDump, Nodump, Verified
|
||||
|
||||
-gt=, --game-type= Include only games with a given type
|
||||
Include only items with this game type in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Bios, Device, Mechanical
|
||||
|
||||
-ngt=, --not-game-type= Exclude only games with a given type
|
||||
Include only items without this game type in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Bios, Device, Mechanical
|
||||
|
||||
-run, --runnable Include only items that are marked runnable
|
||||
This allows users to include only verified runnable games.
|
||||
|
||||
-nrun, --not-runnable Include only items that are not marked runnable
|
||||
This allows users to include only unrunnable games.
|
||||
|
||||
-t=, --temp= Set the temporary directory to use
|
||||
Optionally, a temp folder can be supplied in the case the default
|
||||
temp directory is not preferred.
|
||||
@@ -1368,6 +1527,165 @@ Options:
|
||||
parent sets based on the cloneof and romof tags as well as device
|
||||
references. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-gn=, --game-name= Filter by game name
|
||||
Include only items with this game name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ngn=, --not-game-name= Filter by not game name
|
||||
Include only items without this game name in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-gd=, --game-description= Filter by game description
|
||||
Include only items with this game description in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-ngd=, --not-game-description= Filter by not game description
|
||||
Include only items without this game description in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-ofg, --match-of-tags Allow cloneof and romof tags to match game name filters
|
||||
If filter or exclude by game name is used, this flag will allow those
|
||||
filters to be checked against the romof and cloneof tags as well.
|
||||
This can allow for more advanced set-building, especially in
|
||||
arcade-based sets.
|
||||
|
||||
-rn=, --item-name= Filter by item name
|
||||
Include only items with this item name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nrn=, --not-item-name= Filter by not item name
|
||||
Include only items without this item name in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-rt=, --item-type= Filter by item type
|
||||
Include only items with this item type in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nrt=, --not-item-type= Filter by not item type
|
||||
Include only items without this item type in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sgt=, --greater= Filter by size >=
|
||||
Only include items whose size is greater than or equal to this value
|
||||
in the output DAT. Users can specify either a regular integer number
|
||||
or a number with a standard postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-slt=, --less= Filter by size =<
|
||||
Only include items whose size is less than or equal to this value in
|
||||
the output DAT. Users can specify either a regular integer number or
|
||||
a number with a standard postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-seq=, --equal= Filter by size ==
|
||||
Only include items of this exact size in the output DAT. Users can
|
||||
specify either a regular integer number or a number with a standard
|
||||
postfix. e.g. 8kb => 8000 or 8kib => 8192
|
||||
|
||||
-crc=, --crc= Filter by CRC hash
|
||||
Include only items with this CRC hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ncrc=, --not-crc= Filter by not CRC hash
|
||||
Include only items without this CRC hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-md5=, --md5= Filter by MD5 hash
|
||||
Include only items with this MD5 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nmd5=, --not-md5= Filter by not MD5 hash
|
||||
Include only items without this MD5 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-sha1=, --sha1= Filter by SHA-1 hash
|
||||
Include only items with this SHA-1 hash in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-nsha1=, --not-sha1= Filter by not SHA-1 hash
|
||||
Include only items without this SHA-1 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha256=, --sha256= Filter by SHA-256 hash
|
||||
Include only items with this SHA-256 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha256=, --not-sha256= Filter by not SHA-256 hash
|
||||
Include only items without this SHA-256 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha384=, --sha384= Filter by SHA-384 hash
|
||||
Include only items with this SHA-384 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha384=, --not-sha384= Filter by not SHA-384 hash
|
||||
Include only items without this SHA-384 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-sha512=, --sha512= Filter by SHA-512 hash
|
||||
Include only items with this SHA-512 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-nsha512=, --not-sha512= Filter by not SHA-512 hash
|
||||
Include only items without this SHA-512 hash in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-is=, --status= Include only items with a given status
|
||||
Include only items with this item status in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Good, BadDump, Nodump, Verified
|
||||
|
||||
-nis=, --not-status= Exclude only items with a given status
|
||||
Include only items without this item status in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Good, BadDump, Nodump, Verified
|
||||
|
||||
-gt=, --game-type= Include only games with a given type
|
||||
Include only items with this game type in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Bios, Device, Mechanical
|
||||
|
||||
-ngt=, --not-game-type= Exclude only games with a given type
|
||||
Include only items without this game type in the output. Multiple
|
||||
instances of this flag are allowed.
|
||||
Possible values are: None, Bios, Device, Mechanical
|
||||
|
||||
-run, --runnable Include only items that are marked runnable
|
||||
This allows users to include only verified runnable games.
|
||||
|
||||
-nrun, --not-runnable Include only items that are not marked runnable
|
||||
This allows users to include only unrunnable games.
|
||||
|
||||
** Section 3.0 - Examples
|
||||
|
||||
Here are a few usage examples based on features that are commonly used by most
|
||||
|
||||
Reference in New Issue
Block a user