[ALL] Add full status filtering

This commit is contained in:
Matt Nadareski
2016-09-21 16:19:58 -07:00
parent ae27ba2157
commit 0dca764563
7 changed files with 106 additions and 95 deletions

View File

@@ -224,8 +224,9 @@ namespace SabreTools.Helper
helptext.Add(" -crc=, --crc= Filter by CRC hash");
helptext.Add(" -md5=, --md5= Filter by MD5 hash");
helptext.Add(" -sha1=, --sha1= Filter by SHA-1 hash");
helptext.Add(" -nd, --nodump Include only match nodump roms");
helptext.Add(" -nnd, --not-nodump Exclude all nodump roms");
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(" -out= Output directory (overridden by --inplace)");
helptext.Add("");
helptext.Add("Filenames and directories can't start with a reserved string");

View File

@@ -88,6 +88,7 @@
/// </summary>
public enum ItemStatus
{
NULL = -1,
None = 0,
Good = 1,
BadDump = 2,

View File

@@ -55,7 +55,7 @@ namespace SabreTools.Helper
private long _crcCount;
private long _md5Count;
private long _sha1Count;
private long _nodumpCount;
private long _itemStatusCount;
#endregion
@@ -258,8 +258,8 @@ namespace SabreTools.Helper
}
public long NodumpCount
{
get { return _nodumpCount; }
set { _nodumpCount = value; }
get { return _itemStatusCount; }
set { _itemStatusCount = value; }
}
#endregion
@@ -328,7 +328,7 @@ namespace SabreTools.Helper
_crcCount = 0;
_md5Count = 0;
_sha1Count = 0;
_nodumpCount = 0;
_itemStatusCount = 0;
}
/// <summary>
@@ -378,7 +378,7 @@ namespace SabreTools.Helper
_crcCount = 0;
_md5Count = 0;
_sha1Count = 0;
_nodumpCount = 0;
_itemStatusCount = 0;
}
#endregion
@@ -558,7 +558,7 @@ namespace SabreTools.Helper
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
public static void Parse(string filename, int sysid, int srcid, ref DatFile datdata, Logger logger, bool keep = false, bool clean = false, bool softlist = false, bool keepext = false)
{
Parse(filename, sysid, srcid, ref datdata, null, null, null, -1, -1, -1, null, null, null, null, false, false, "", logger, keep, clean, softlist, keepext);
Parse(filename, sysid, srcid, ref datdata, null, null, null, -1, -1, -1, null, null, null, ItemStatus.NULL, false, false, "", logger, keep, clean, softlist, keepext);
}
/// <summary>
@@ -577,7 +577,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -603,7 +603,7 @@ namespace SabreTools.Helper
string crc,
string md5,
string sha1,
bool? nodump,
ItemStatus itemStatus,
// Rom renaming
bool trim,
@@ -640,14 +640,14 @@ namespace SabreTools.Helper
switch (GetOutputFormat(filename, logger))
{
case OutputFormat.ClrMamePro:
ParseCMP(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, keep, clean);
ParseCMP(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean);
break;
case OutputFormat.RomCenter:
ParseRC(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, clean);
ParseRC(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, clean);
break;
case OutputFormat.SabreDat:
case OutputFormat.Xml:
ParseXML(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, keep, clean, softlist);
ParseXML(filename, sysid, srcid, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean, softlist);
break;
default:
return;
@@ -670,7 +670,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -694,7 +694,7 @@ namespace SabreTools.Helper
string crc,
string md5,
string sha1,
bool? nodump,
ItemStatus itemStatus,
// Rom renaming
bool trim,
@@ -819,8 +819,8 @@ namespace SabreTools.Helper
{
continue;
}
// Special case for nodump...
else if (gc[i] == "nodump" && attrib != "status" && attrib != "flags")
// Special case for itemStatus...
else if (gc[i] == "itemStatus" && attrib != "status" && attrib != "flags")
{
if (item.Type == ItemType.Rom)
{
@@ -904,7 +904,7 @@ namespace SabreTools.Helper
((Disk)item).ItemStatus = ItemStatus.BadDump;
}
}
else if (val.ToLowerInvariant() == "nodump")
else if (val.ToLowerInvariant() == "itemStatus")
{
if (item.Type == ItemType.Rom)
{
@@ -1032,7 +1032,7 @@ namespace SabreTools.Helper
((Disk)item).ItemStatus = ItemStatus.BadDump;
}
}
else if (val.ToLowerInvariant() == "nodump")
else if (val.ToLowerInvariant() == "itemStatus")
{
if (item.Type == ItemType.Rom)
{
@@ -1073,7 +1073,7 @@ namespace SabreTools.Helper
// Now process and add the rom
string key = "";
ParseAddHelper(item, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(item, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
}
// If the line is anything but a rom or disk and we're in a block
else if (Regex.IsMatch(line, Constants.ItemPatternCMP) && block)
@@ -1234,7 +1234,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -1257,7 +1257,7 @@ namespace SabreTools.Helper
string crc,
string md5,
string sha1,
bool? nodump,
ItemStatus itemStatus,
// Rom renaming
bool trim,
@@ -1374,7 +1374,7 @@ namespace SabreTools.Helper
// Now process and add the rom
string key = "";
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
}
}
}
@@ -1399,7 +1399,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -1424,7 +1424,7 @@ namespace SabreTools.Helper
string crc,
string md5,
string sha1,
bool? nodump,
ItemStatus itemStatus,
// Rom renaming
bool trim,
@@ -1461,7 +1461,7 @@ namespace SabreTools.Helper
Rom rom = new Rom("null", tempgame);
// Now process and add the rom
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
}
// Regardless, end the current folder
@@ -1630,9 +1630,9 @@ namespace SabreTools.Helper
break;
}
}
if (headreader.GetAttribute("forcenodump") != null)
if (headreader.GetAttribute("forceitemStatus") != null)
{
switch (headreader.GetAttribute("forcenodump"))
switch (headreader.GetAttribute("forceitemStatus"))
{
case "obsolete":
datdata.ForceNodump = ForceNodump.Obsolete;
@@ -1698,7 +1698,7 @@ namespace SabreTools.Helper
break;
}
break;
case "forcenodump":
case "forceitemStatus":
switch (content)
{
case "obsolete":
@@ -1838,7 +1838,7 @@ namespace SabreTools.Helper
DatItem relrom = new Release(subreader.GetAttribute("name"), subreader.GetAttribute("region"), subreader.GetAttribute("language"), date, defaultrel);
// Now process and add the rom
ParseAddHelper(relrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(relrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
subreader.Read();
break;
@@ -1860,7 +1860,7 @@ namespace SabreTools.Helper
tempname, null, gamedesc, null, null, romof, cloneof, sampleof, null, false, null, null, sysid, filename, srcid, null);
// Now process and add the rom
ParseAddHelper(biosrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(biosrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
subreader.Read();
break;
@@ -1869,7 +1869,7 @@ namespace SabreTools.Helper
romof, cloneof, sampleof, null, false, null, null, sysid, filename, srcid, null);
// Now process and add the rom
ParseAddHelper(archiverom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(archiverom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
subreader.Read();
break;
@@ -1878,7 +1878,7 @@ namespace SabreTools.Helper
romof, cloneof, sampleof, null, false, null, null, sysid, filename, srcid, null);
// Now process and add the rom
ParseAddHelper(samplerom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(samplerom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
subreader.Read();
break;
@@ -1898,7 +1898,7 @@ namespace SabreTools.Helper
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
its = ItemStatus.BadDump;
}
if (subreader.GetAttribute("flags") == "nodump" || subreader.GetAttribute("status") == "nodump")
if (subreader.GetAttribute("flags") == "itemStatus" || subreader.GetAttribute("status") == "itemStatus")
{
logger.Log("Nodump detected: " +
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
@@ -1973,7 +1973,7 @@ namespace SabreTools.Helper
}
// Now process and add the rom
ParseAddHelper(inrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(inrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
subreader.Read();
break;
@@ -1992,7 +1992,7 @@ namespace SabreTools.Helper
Rom inrom = new Rom("null", tempname);
// Now process and add the rom
ParseAddHelper(inrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(inrom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
// Regardless, end the current folder
if (parent.Count == 0)
@@ -2022,7 +2022,7 @@ namespace SabreTools.Helper
case "file":
empty = false;
// If the rom is nodump, flag it
// If the rom is itemStatus, flag it
its = ItemStatus.None;
flagreader = xtr.ReadSubtree();
if (flagreader != null)
@@ -2053,7 +2053,7 @@ namespace SabreTools.Helper
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
its = ItemStatus.BadDump;
break;
case "nodump":
case "itemStatus":
logger.Log("Nodump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != "" ?
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
its = ItemStatus.Nodump;
@@ -2133,7 +2133,7 @@ namespace SabreTools.Helper
}
// Now process and add the rom
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
ParseAddHelper(rom, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key);
xtr.Read();
break;
@@ -2162,13 +2162,13 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
/// <param name="logger">Logger object for console and/or file output</param>
private static void ParseAddHelper(DatItem item, ref DatFile datdata, string gamename, string romname, string romtype, long sgt, long slt,
long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, bool clean, Logger logger, out string key)
long seq, string crc, string md5, string sha1, ItemStatus itemStatus, bool trim, bool single, string root, bool clean, Logger logger, out string key)
{
key = "";
@@ -2206,7 +2206,7 @@ namespace SabreTools.Helper
// If the file has no size and it's not the above case, skip and log
else if (itemRom.Type == ItemType.Rom && (itemRom.Size == 0 || itemRom.Size == -1))
{
logger.Warning("Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
logger.Warning("Incomplete entry for \"" + itemRom.Name + "\" will be output as itemStatus");
itemRom.ItemStatus = ItemStatus.Nodump;
}
@@ -2224,7 +2224,7 @@ namespace SabreTools.Helper
}
// If the rom passes the filter, include it
if (DatItem.Filter(item, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, logger))
if (DatItem.Filter(item, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, logger))
{
// If we are in single game mode, rename all games
if (single)
@@ -2422,7 +2422,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -2430,7 +2430,7 @@ namespace SabreTools.Helper
/// <param name="logger">Logging object for console and file output</param>
public static void Update(List<string> inputFileNames, DatFile datdata, OutputFormat outputFormat, string outDir, bool merge,
DiffMode diff, bool? cascade, bool inplace, bool skip, bool bare, bool clean, bool softlist, string gamename, string romname, string romtype,
long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, int maxDegreeOfParallelism,
long sgt, long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus, bool trim, bool single, string root, int maxDegreeOfParallelism,
Logger logger)
{
// If we're in merging or diffing mode, use the full list of inputs
@@ -2485,7 +2485,7 @@ namespace SabreTools.Helper
DatFile userData;
List<DatFile> datHeaders = PopulateUserData(newInputFileNames, inplace, clean, softlist,
outDir, datdata, out userData, gamename, romname, romtype, sgt, slt, seq,
crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, logger);
crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, logger);
// Modify the Dictionary if necessary and output the results
if (diff != 0 && cascade == null)
@@ -2521,7 +2521,7 @@ namespace SabreTools.Helper
DatFile innerDatdata = (DatFile)datdata.CloneHeader();
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
Parse(inputFileName, 0, 0, ref innerDatdata, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single,
romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single,
root, logger, true, clean, softlist, keepext: (innerDatdata.XSV != null));
// If we have roms, output them
@@ -2542,7 +2542,7 @@ namespace SabreTools.Helper
DatFile innerDatdata = (DatFile)datdata.Clone();
innerDatdata.Files = null;
Parse(file, 0, 0, ref innerDatdata, gamename, romname, romtype, sgt,
slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, true, clean, keepext: (datdata.XSV != null));
slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, true, clean, keepext: (datdata.XSV != null));
// If we have roms, output them
if (innerDatdata.Files != null && innerDatdata.Files.Count != 0)
@@ -2573,7 +2573,7 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</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="root">String representing root directory to compare against for length calculation</param>
@@ -2582,7 +2582,7 @@ namespace SabreTools.Helper
/// <returns>List of DatData objects representing headers</returns>
private static List<DatFile> PopulateUserData(List<string> inputs, bool inplace, bool clean, bool softlist, string outDir,
DatFile inputDat, out DatFile userData, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc,
string md5, string sha1, bool? nodump, bool trim, bool single, string root, int maxDegreeOfParallelism, Logger logger)
string md5, string sha1, ItemStatus itemStatus, bool trim, bool single, string root, int maxDegreeOfParallelism, Logger logger)
{
DatFile[] datHeaders = new DatFile[inputs.Count];
DateTime start = DateTime.Now;
@@ -2603,7 +2603,7 @@ namespace SabreTools.Helper
};
Parse(input.Split('¬')[0], i, 0, ref datHeaders[i], gamename, romname, romtype, sgt, slt, seq,
crc, md5, sha1, nodump, trim, single, root, logger, true, clean, softlist);
crc, md5, sha1, itemStatus, trim, single, root, logger, true, clean, softlist);
});
logger.User("Processing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
@@ -3243,9 +3243,9 @@ namespace SabreTools.Helper
(datdata.ForcePacking == ForcePacking.Zip ? "\t\t\t<flag name=\"forcepacking\" value=\"zip\"/>\n" : "") +
(datdata.ForceMerging == ForceMerging.Full ? "\t\t\t<flag name=\"forcemerging\" value=\"full\"/>\n" : "") +
(datdata.ForceMerging == ForceMerging.Split ? "\t\t\t<flag name=\"forcemerging\" value=\"split\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Ignore ? "\t\t\t<flag name=\"forcenodump\" value=\"ignore\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Obsolete ? "\t\t\t<flag name=\"forcenodump\" value=\"obsolete\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Required ? "\t\t\t<flag name=\"forcenodump\" value=\"required\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Ignore ? "\t\t\t<flag name=\"forceitemStatus\" value=\"ignore\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Obsolete ? "\t\t\t<flag name=\"forceitemStatus\" value=\"obsolete\"/>\n" : "") +
(datdata.ForceNodump == ForceNodump.Required ? "\t\t\t<flag name=\"forceitemStatus\" value=\"required\"/>\n" : "") +
"\t\t</flags>\n"
: "") +
"\t</header>\n" +
@@ -3274,9 +3274,9 @@ namespace SabreTools.Helper
(datdata.ForcePacking == ForcePacking.Zip ? " forcepacking=\"zip\"" : "") +
(datdata.ForceMerging == ForceMerging.Full ? " forcemerging=\"full\"" : "") +
(datdata.ForceMerging == ForceMerging.Split ? " forcemerging=\"split\"" : "") +
(datdata.ForceNodump == ForceNodump.Ignore ? " forcenodump=\"ignore\"" : "") +
(datdata.ForceNodump == ForceNodump.Obsolete ? " forcenodump=\"obsolete\"" : "") +
(datdata.ForceNodump == ForceNodump.Required ? " forcenodump=\"required\"" : "") +
(datdata.ForceNodump == ForceNodump.Ignore ? " forceitemStatus=\"ignore\"" : "") +
(datdata.ForceNodump == ForceNodump.Obsolete ? " forceitemStatus=\"obsolete\"" : "") +
(datdata.ForceNodump == ForceNodump.Required ? " forceitemStatus=\"required\"" : "") +
" />\n"
: "") +
"\t</header>\n";
@@ -4104,7 +4104,7 @@ namespace SabreTools.Helper
// Create each of the respective output DATs
logger.User("Creating and populating new DATs");
DatFile nodump = new DatFile
DatFile itemStatus = new DatFile
{
FileName = datdata.FileName + " (Nodump)",
Name = datdata.Name + " (Nodump)",
@@ -4229,19 +4229,19 @@ namespace SabreTools.Helper
continue;
}
// If the file is a nodump
// If the file is a itemStatus
if ((rom.Type == ItemType.Rom && ((Rom)rom).ItemStatus == ItemStatus.Nodump)
|| (rom.Type == ItemType.Disk && ((Disk)rom).ItemStatus == ItemStatus.Nodump))
{
if (nodump.Files.ContainsKey(key))
if (itemStatus.Files.ContainsKey(key))
{
nodump.Files[key].Add(rom);
itemStatus.Files[key].Add(rom);
}
else
{
List<DatItem> temp = new List<DatItem>();
temp.Add(rom);
nodump.Files.Add(key, temp);
itemStatus.Files.Add(key, temp);
}
}
// If the file has a SHA-1
@@ -4318,9 +4318,9 @@ namespace SabreTools.Helper
// Now, output all of the files to the output directory
logger.User("DAT information created, outputting new files");
bool success = true;
if (nodump.Files.Count > 0)
if (itemStatus.Files.Count > 0)
{
success &= WriteDatfile(nodump, outDir, logger);
success &= WriteDatfile(itemStatus, outDir, logger);
}
if (sha1.Files.Count > 0)
{

View File

@@ -249,23 +249,19 @@ namespace SabreTools.Helper
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="itemStatus">Select roms with the given status</param>
/// <param name="logger">Logging object for console and file output</param>
/// <returns>Returns true if it should be included, false otherwise</returns>
public static bool Filter(DatItem itemdata, string gamename, string romname, string romtype, long sgt,
long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger)
long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus, Logger logger)
{
// Take care of Rom and Disk specific differences
if (itemdata.Type == ItemType.Rom)
{
Rom rom = (Rom)itemdata;
// Filter on nodump status
if (nodump == true && rom.ItemStatus != ItemStatus.Nodump)
{
return false;
}
if (nodump == false && rom.ItemStatus == ItemStatus.Nodump)
// Filter on status
if (itemStatus != ItemStatus.NULL && rom.ItemStatus != itemStatus)
{
return false;
}
@@ -390,12 +386,8 @@ namespace SabreTools.Helper
{
Disk rom = (Disk)itemdata;
// Filter on nodump status
if (nodump == true && rom.ItemStatus != ItemStatus.Nodump)
{
return false;
}
if (nodump == false && rom.ItemStatus == ItemStatus.Nodump)
// Filter on status
if (itemStatus != ItemStatus.NULL && rom.ItemStatus != itemStatus)
{
return false;
}

View File

@@ -551,9 +551,9 @@ Options:
various standard postfixes for size:
e.g. 8kb => 8000 or 8kib => 8192
-nd, --nodump Include only match nodump roms
-nnd, --not-nodump Exclude all nodump roms
These flags allow for filtering based on the nodump status in the source DAT(s)
-is=, status= Include only items with a given status
Include items with one of the supported values:
None, Good, BadDump, Nodump, Verified
-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

@@ -366,7 +366,7 @@ namespace SabreTools
/// <param name="crc">CRC 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="nodump">Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump)</param>
/// <param name="status">Select roms with the given item status</param>
/// /* Trimming info */
/// <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>
@@ -429,7 +429,7 @@ namespace SabreTools
string crc,
string md5,
string sha1,
bool? nodump,
string status,
/* Trimming info */
bool trim,
@@ -494,6 +494,27 @@ namespace SabreTools
break;
}
// Set the status flag for filtering
ItemStatus itemStatus = ItemStatus.NULL;
switch(status.ToLowerInvariant())
{
case "none":
itemStatus = ItemStatus.None;
break;
case "good":
itemStatus = ItemStatus.Good;
break;
case "baddump":
itemStatus = ItemStatus.BadDump;
break;
case "nodump":
itemStatus = ItemStatus.Nodump;
break;
case "verified":
itemStatus = ItemStatus.Verified;
break;
}
// Normalize the extensions
addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext);
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
@@ -564,7 +585,7 @@ namespace SabreTools
};
DatFile.Update(inputs, userInputDat, outputFormat, outDir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, _logger);
}
#endregion

View File

@@ -81,7 +81,6 @@ namespace SabreTools
update = false,
usegame = true;
bool? cascade = null,
nodump = null,
tsv = null;
DiffMode diffMode = 0x0;
int maxParallelism = 4;
@@ -120,6 +119,7 @@ namespace SabreTools
root = "",
rootdir = "",
sha1 = "",
status = "",
tempDir = "",
url = "",
version = "";
@@ -216,18 +216,10 @@ namespace SabreTools
case "--merge":
merge = true;
break;
case "-nd":
case "--nodump":
nodump = true;
break;
case "-nm":
case "--noMD5":
noMD5 = true;
break;
case "-nnd":
case "--not-nodump":
nodump = false;
break;
case "-ns":
case "--noSHA1":
noSHA1 = true;
@@ -415,6 +407,10 @@ namespace SabreTools
{
inputs.Add(temparg.Split('=')[1]);
}
else if (temparg.StartsWith("-is=") || temparg.StartsWith("--status="))
{
status = temparg.Split('=')[1];
}
else if (temparg.StartsWith("-md5=") || temparg.StartsWith("--md5="))
{
md5 = temparg.Split('=')[1];
@@ -582,7 +578,7 @@ namespace SabreTools
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outDir, clean, softlist, dedup, maxParallelism);
romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, clean, softlist, dedup, maxParallelism);
}
// If nothing is set, show the help