diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index 036bc4ab..829c5314 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -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"); diff --git a/SabreTools.Helper/Data/Enums.cs b/SabreTools.Helper/Data/Enums.cs index 737fe151..20cfd061 100644 --- a/SabreTools.Helper/Data/Enums.cs +++ b/SabreTools.Helper/Data/Enums.cs @@ -88,6 +88,7 @@ /// public enum ItemStatus { + NULL = -1, None = 0, Good = 1, BadDump = 2, diff --git a/SabreTools.Helper/Objects/Dat/DatFile.cs b/SabreTools.Helper/Objects/Dat/DatFile.cs index 42b7a2e4..c51fbf2a 100644 --- a/SabreTools.Helper/Objects/Dat/DatFile.cs +++ b/SabreTools.Helper/Objects/Dat/DatFile.cs @@ -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; } /// @@ -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 /// True if original extension should be kept, false otherwise (default) 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); } /// @@ -577,7 +577,7 @@ namespace SabreTools.Helper /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation /// Logger object for console and/or file output 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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -2430,7 +2430,7 @@ namespace SabreTools.Helper /// Logging object for console and file output public static void Update(List 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 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 /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation @@ -2582,7 +2582,7 @@ namespace SabreTools.Helper /// List of DatData objects representing headers private static List PopulateUserData(List 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\n" : "") + (datdata.ForceMerging == ForceMerging.Full ? "\t\t\t\n" : "") + (datdata.ForceMerging == ForceMerging.Split ? "\t\t\t\n" : "") + - (datdata.ForceNodump == ForceNodump.Ignore ? "\t\t\t\n" : "") + - (datdata.ForceNodump == ForceNodump.Obsolete ? "\t\t\t\n" : "") + - (datdata.ForceNodump == ForceNodump.Required ? "\t\t\t\n" : "") + + (datdata.ForceNodump == ForceNodump.Ignore ? "\t\t\t\n" : "") + + (datdata.ForceNodump == ForceNodump.Obsolete ? "\t\t\t\n" : "") + + (datdata.ForceNodump == ForceNodump.Required ? "\t\t\t\n" : "") + "\t\t\n" : "") + "\t\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\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 temp = new List(); 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) { diff --git a/SabreTools.Helper/Objects/Dat/DatItem.cs b/SabreTools.Helper/Objects/Dat/DatItem.cs index 9da6ae20..d42067f0 100644 --- a/SabreTools.Helper/Objects/Dat/DatItem.cs +++ b/SabreTools.Helper/Objects/Dat/DatItem.cs @@ -249,23 +249,19 @@ namespace SabreTools.Helper /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given status /// Logging object for console and file output /// Returns true if it should be included, false otherwise 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; } diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index 92feafdd..272b3123 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -550,10 +550,10 @@ Options: For each of the flags above, the user can specify a standard integer or one of the 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 diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 178e22ee..2aeb98ae 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -366,7 +366,7 @@ namespace SabreTools /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) + /// Select roms with the given item status /// /* Trimming info */ /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise @@ -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 diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index c869d5f6..45d35d21 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -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