[ALL] Fix CMP parsing again, add NotNodump option for filter

This commit is contained in:
Matt Nadareski
2016-09-21 16:46:01 -07:00
parent 0dca764563
commit f512fa5b50
7 changed files with 101 additions and 7 deletions

View File

@@ -226,7 +226,7 @@ namespace SabreTools.Helper
helptext.Add(" -sha1=, --sha1= Filter by SHA-1 hash");
helptext.Add(" -is=, --status= Include only items with a given status");
helptext.Add(" Supported values are:");
helptext.Add(" None, Good, BadDump, Nodump, Verified");
helptext.Add(" None, Good, BadDump, Nodump, Verified, NotNodump");
helptext.Add(" -out= Output directory (overridden by --inplace)");
helptext.Add("");
helptext.Add("Filenames and directories can't start with a reserved string");

View File

@@ -88,12 +88,13 @@
/// </summary>
public enum ItemStatus
{
NULL = -1,
NULL = -1, // This is a fake flag that is used for filter only
None = 0,
Good = 1,
BadDump = 2,
Nodump = 3,
Verified = 4,
NotNodump = 5, // This is a fake flag that is used for filter only
}
#endregion

View File

@@ -819,8 +819,30 @@ namespace SabreTools.Helper
{
continue;
}
// Special case for itemStatus...
else if (gc[i] == "itemStatus" && attrib != "status" && attrib != "flags")
// Special cases for item statuses
else if (gc[i] == "good" && attrib != "status" && attrib != "flags")
{
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.Good;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.Good;
}
}
else if (gc[i] == "baddump" && attrib != "status" && attrib != "flags")
{
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.BadDump;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.BadDump;
}
}
else if (gc[i] == "nodump" && attrib != "status" && attrib != "flags")
{
if (item.Type == ItemType.Rom)
{
@@ -831,6 +853,17 @@ namespace SabreTools.Helper
((Disk)item).ItemStatus = ItemStatus.Nodump;
}
}
else if (gc[i] == "verified" && attrib != "status" && attrib != "flags")
{
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.Verified;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.Verified;
}
}
// Even number of quotes, not in a quote, not in attribute
else if (Regex.Matches(gc[i], "\"").Count % 2 == 0 && !quote && attrib == "")
{
@@ -934,6 +967,48 @@ namespace SabreTools.Helper
}
i++;
break;
// Special cases for item statuses
case "good":
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.Good;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.Good;
}
break;
case "baddump":
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.BadDump;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.BadDump;
}
break;
case "nodump":
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.Nodump;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.Nodump;
}
break;
case "verified":
if (item.Type == ItemType.Rom)
{
((Rom)item).ItemStatus = ItemStatus.Verified;
}
else if (item.Type == ItemType.Disk)
{
((Disk)item).ItemStatus = ItemStatus.Verified;
}
break;
}
attrib = "";

View File

@@ -261,9 +261,16 @@ namespace SabreTools.Helper
Rom rom = (Rom)itemdata;
// Filter on status
if (itemStatus != ItemStatus.NULL && rom.ItemStatus != itemStatus)
if (itemStatus != ItemStatus.NULL)
{
return false;
if (itemStatus == ItemStatus.NotNodump && rom.ItemStatus == ItemStatus.Nodump)
{
return false;
}
else if (itemStatus != ItemStatus.NotNodump && rom.ItemStatus != itemStatus)
{
return false;
}
}
// Filter on rom size

View File

@@ -553,7 +553,7 @@ Options:
-is=, status= Include only items with a given status
Include items with one of the supported values:
None, Good, BadDump, Nodump, Verified
None, Good, BadDump, Nodump, Verified, NotNodump
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If a path

View File

@@ -513,6 +513,9 @@ namespace SabreTools
case "verified":
itemStatus = ItemStatus.Verified;
break;
case "notnodump":
itemStatus = ItemStatus.NotNodump;
break;
}
// Normalize the extensions

View File

@@ -216,10 +216,18 @@ namespace SabreTools
case "--merge":
merge = true;
break;
case "-nd":
case "--nodump":
status = "Nodump";
break;
case "-nm":
case "--noMD5":
noMD5 = true;
break;
case "-nnd":
case "--not-nodump":
status = "NotNodump";
break;
case "-ns":
case "--noSHA1":
noSHA1 = true;