diff --git a/SabreTools.Library/DatFiles/Filter.cs b/SabreTools.Library/DatFiles/Filter.cs index aa23d769..94b3b4ff 100644 --- a/SabreTools.Library/DatFiles/Filter.cs +++ b/SabreTools.Library/DatFiles/Filter.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text.RegularExpressions; using SabreTools.Library.Data; using SabreTools.Library.DatItems; @@ -15,56 +14,100 @@ namespace SabreTools.Library.DatFiles /// /// Represents the filtering operations that need to be performed on a set of items, usually a DAT /// - public class Filter + public partial class Filter { #region Pubically facing variables - #region Positive + /// + /// Include or exclude machine names + /// + public FilterItem MachineName { get; set; } = new FilterItem(); - public List MachineNames { get; set; } = new List(); - public List MachineDescriptions { get; set; } = new List(); - public List ItemNames { get; set; } = new List(); - public List ItemTypes { get; set; } = new List(); - public List CRCs { get; set; } = new List(); - public List MD5s { get; set; } = new List(); - public List SHA1s { get; set; } = new List(); - public List SHA256s { get; set; } = new List(); - public List SHA384s { get; set; } = new List(); - public List SHA512s { get; set; } = new List(); - public ItemStatus ItemStatuses { get; set; } = ItemStatus.NULL; - public MachineType MachineTypes { get; set; } = MachineType.NULL; + /// + /// Include or exclude machine descriptions + /// + public FilterItem MachineDescription { get; set; } = new FilterItem(); - #endregion + /// + /// Include or exclude item names + /// + public FilterItem ItemName { get; set; } = new FilterItem(); - #region Negative + /// + /// Include or exclude item types + /// + public FilterItem ItemTypes { get; set; } = new FilterItem(); - public List NotMachineNames { get; set; } = new List(); - public List NotMachineDescriptions { get; set; } = new List(); - public List NotItemNames { get; set; } = new List(); - public List NotItemTypes { get; set; } = new List(); - public List NotCRCs { get; set; } = new List(); - public List NotMD5s { get; set; } = new List(); - public List NotSHA1s { get; set; } = new List(); - public List NotSHA256s { get; set; } = new List(); - public List NotSHA384s { get; set; } = new List(); - public List NotSHA512s { get; set; } = new List(); - public ItemStatus NotItemStatuses { get; set; } = ItemStatus.NULL; - public MachineType NotMachineTypes { get; set; } = MachineType.NULL; + /// + /// Include or exclude CRC32 hashes + /// + public FilterItem CRC { get; set; } = new FilterItem(); - #endregion + /// + /// Include or exclude MD5 hashes + /// + public FilterItem MD5 { get; set; } = new FilterItem(); - #region Neutral + /// + /// Include or exclude SHA-1 hashes + /// + public FilterItem SHA1 { get; set; } = new FilterItem(); - public long SizeGreaterThanOrEqual { get; set; } = -1; - public long SizeLessThanOrEqual { get; set; } = -1; - public long SizeEqualTo { get; set; } = -1; - public bool IncludeOfInGame { get; set; } = false; - public bool? Runnable { get; set; } = null; - public bool Single { get; set; } = false; - public bool Trim { get; set; } = false; - public string Root { get; set; } = null; + /// + /// Include or exclude SHA-256 hashes + /// + public FilterItem SHA256 { get; set; } = new FilterItem(); - #endregion + /// + /// Include or exclude SHA-384 hashes + /// + public FilterItem SHA384 { get; set; } = new FilterItem(); + + /// + /// Include or exclude SHA-512 hashes + /// + public FilterItem SHA512 { get; set; } = new FilterItem(); + + /// + /// Include or exclude item statuses + /// + public FilterItem ItemStatuses { get; set; } = new FilterItem() { Positive = ItemStatus.NULL, Negative = ItemStatus.NULL }; + + /// + /// Include or exclude machine types + /// + public FilterItem MachineTypes { get; set; } = new FilterItem() { Positive = MachineType.NULL, Negative = MachineType.NULL }; + + /// + /// Include or exclude item sizes + /// + /// Positive means "Greater than or equal", Negative means "Less than or equal", Neutral means "Equal" + public FilterItem Size { get; set; } = new FilterItem() { Positive = -1, Negative = -1, Neutral = -1 }; + + /// + /// Include romof and cloneof when filtering machine names + /// + public FilterItem IncludeOfInGame { get; set; } = new FilterItem() { Neutral = false }; + + /// + /// Include or exclude items with the "Runnable" tag + /// + public FilterItem Runnable { get; set; } = new FilterItem() { Neutral = null }; + + /// + /// Change all machine names to "!" + /// + public FilterItem Single { get; set; } = new FilterItem() { Neutral = false }; + + /// + /// Trim total machine and item name to not exceed NTFS limits + /// + public FilterItem Trim { get; set; } = new FilterItem() { Neutral = false }; + + /// + /// Include root directory when determing trim sizes + /// + public FilterItem Root { get; set; } = new FilterItem() { Neutral = null }; #endregion // Pubically facing variables @@ -92,16 +135,14 @@ namespace SabreTools.Library.DatFiles if (ItemPasses(item)) { // If we are in single game mode, rename all games - if (this.Single) - { + if (this.Single.Neutral) item.MachineName = "!"; - } // If we are in NTFS trim mode, trim the game name - if (this.Trim) + if (this.Trim.Neutral) { // Windows max name length is 260 - int usableLength = 260 - item.MachineName.Length - this.Root.Length; + int usableLength = 260 - item.MachineName.Length - this.Root.Neutral.Length; if (item.Name.Length > usableLength) { string ext = Path.GetExtension(item.Name); @@ -140,25 +181,17 @@ namespace SabreTools.Library.DatFiles { // If the item is null, we automatically fail it if (item == null) - { return false; - } // Filter on machine type - if (this.MachineTypes != MachineType.NULL && (item.MachineType & this.MachineTypes) == 0) - { + if (!this.MachineTypes.MatchesPositive(MachineType.NULL, item.MachineType)) return false; - } - if (this.NotMachineTypes != MachineType.NULL && (item.MachineType & this.NotMachineTypes) != 0) - { + if (this.MachineTypes.MatchesNegative(MachineType.NULL, item.MachineType)) return false; - } // Filter on machine runability - if (this.Runnable != null && item.Runnable != this.Runnable) - { + if (!this.Runnable.MatchesNeutral(null, item.Runnable)) return false; - } // Take care of Rom and Disk specific differences if (item.ItemType == ItemType.Rom) @@ -166,375 +199,139 @@ namespace SabreTools.Library.DatFiles Rom rom = (Rom)item; // Filter on status - if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0) - { + if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus)) return false; - } - if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0) - { + if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus)) return false; - } // Filter on rom size - if (this.SizeEqualTo != -1 && rom.Size != this.SizeEqualTo) - { + if (!this.Size.MatchesNeutral(-1, rom.Size)) + return false; + else if (!this.Size.MatchesPositive(-1, rom.Size)) + return false; + else if (!this.Size.MatchesNegative(-1, rom.Size)) return false; - } - else - { - if (this.SizeGreaterThanOrEqual != -1 && rom.Size < this.SizeGreaterThanOrEqual) - { - return false; - } - if (this.SizeLessThanOrEqual != -1 && rom.Size > this.SizeLessThanOrEqual) - { - return false; - } - } // Filter on CRC - if (this.CRCs.Count > 0) - { - // If the CRC isn't in the list, return false - if (!FindValueInList(this.CRCs, rom.CRC)) - { - return false; - } - } - if (this.NotCRCs.Count > 0) - { - // If the CRC is in the list, return false - if (FindValueInList(this.NotCRCs, rom.CRC)) - { - return false; - } - } + if (!this.CRC.MatchesPositiveSet(rom.CRC)) + return false; + if (this.CRC.MatchesNegativeSet(rom.CRC)) + return false; // Filter on MD5 - if (this.MD5s.Count > 0) - { - // If the MD5 isn't in the list, return false - if (!FindValueInList(this.MD5s, rom.MD5)) - { - return false; - } - } - if (this.NotMD5s.Count > 0) - { - // If the MD5 is in the list, return false - if (FindValueInList(this.NotMD5s, rom.MD5)) - { - return false; - } - } + if (!this.MD5.MatchesPositiveSet(rom.MD5)) + return false; + if (this.MD5.MatchesNegativeSet(rom.MD5)) + return false; // Filter on SHA-1 - if (this.SHA1s.Count > 0) - { - // If the SHA-1 isn't in the list, return false - if (!FindValueInList(this.SHA1s, rom.SHA1)) - { - return false; - } - } - if (this.NotSHA1s.Count > 0) - { - // If the SHA-1 is in the list, return false - if (FindValueInList(this.NotSHA1s, rom.SHA1)) - { - return false; - } - } + if (!this.SHA1.MatchesPositiveSet(rom.SHA1)) + return false; + if (this.SHA1.MatchesNegativeSet(rom.SHA1)) + return false; // Filter on SHA-256 - if (this.SHA256s.Count > 0) - { - // If the SHA-256 isn't in the list, return false - if (!FindValueInList(this.SHA256s, rom.SHA256)) - { - return false; - } - } - if (this.NotSHA256s.Count > 0) - { - // If the SHA-256 is in the list, return false - if (FindValueInList(this.NotSHA256s, rom.SHA256)) - { - return false; - } - } + if (!this.SHA256.MatchesPositiveSet(rom.SHA256)) + return false; + if (this.SHA256.MatchesNegativeSet(rom.SHA256)) + return false; // Filter on SHA-384 - if (this.SHA384s.Count > 0) - { - // If the SHA-384 isn't in the list, return false - if (!FindValueInList(this.SHA384s, rom.SHA384)) - { - return false; - } - } - if (this.NotSHA384s.Count > 0) - { - // If the SHA-384 is in the list, return false - if (FindValueInList(this.NotSHA384s, rom.SHA384)) - { - return false; - } - } + if (!this.SHA384.MatchesPositiveSet(rom.SHA384)) + return false; + if (this.SHA384.MatchesNegativeSet(rom.SHA384)) + return false; // Filter on SHA-512 - if (this.SHA512s.Count > 0) - { - // If the SHA-512 isn't in the list, return false - if (!FindValueInList(this.SHA512s, rom.SHA512)) - { - return false; - } - } - if (this.NotSHA512s.Count > 0) - { - // If the SHA-512 is in the list, return false - if (FindValueInList(this.NotSHA512s, rom.SHA512)) - { - return false; - } - } + if (!this.SHA512.MatchesPositiveSet(rom.SHA512)) + return false; + if (this.SHA512.MatchesNegativeSet(rom.SHA512)) + return false; } else if (item.ItemType == ItemType.Disk) { Disk rom = (Disk)item; // Filter on status - if (this.ItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.ItemStatuses) == 0) - { + if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus)) return false; - } - if (this.NotItemStatuses != ItemStatus.NULL && (rom.ItemStatus & this.NotItemStatuses) != 0) - { + if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus)) return false; - } // Filter on MD5 - if (this.MD5s.Count > 0) - { - // If the MD5 isn't in the list, return false - if (!FindValueInList(this.MD5s, rom.MD5)) - { - return false; - } - } - if (this.NotMD5s.Count > 0) - { - // If the MD5 is in the list, return false - if (FindValueInList(this.NotMD5s, rom.MD5)) - { - return false; - } - } + if (!this.MD5.MatchesPositiveSet(rom.MD5)) + return false; + if (this.MD5.MatchesNegativeSet(rom.MD5)) + return false; // Filter on SHA-1 - if (this.SHA1s.Count > 0) - { - // If the SHA-1 isn't in the list, return false - if (!FindValueInList(this.SHA1s, rom.SHA1)) - { - return false; - } - } - if (this.NotSHA1s.Count > 0) - { - // If the SHA-1 is in the list, return false - if (FindValueInList(this.NotSHA1s, rom.SHA1)) - { - return false; - } - } + if (!this.SHA1.MatchesPositiveSet(rom.SHA1)) + return false; + if (this.SHA1.MatchesNegativeSet(rom.SHA1)) + return false; // Filter on SHA-256 - if (this.SHA256s.Count > 0) - { - // If the SHA-256 isn't in the list, return false - if (!FindValueInList(this.SHA256s, rom.SHA256)) - { - return false; - } - } - if (this.NotSHA256s.Count > 0) - { - // If the SHA-256 is in the list, return false - if (FindValueInList(this.NotSHA256s, rom.SHA256)) - { - return false; - } - } + if (!this.SHA256.MatchesPositiveSet(rom.SHA256)) + return false; + if (this.SHA256.MatchesNegativeSet(rom.SHA256)) + return false; // Filter on SHA-384 - if (this.SHA384s.Count > 0) - { - // If the SHA-384 isn't in the list, return false - if (!FindValueInList(this.SHA384s, rom.SHA384)) - { - return false; - } - } - if (this.NotSHA384s.Count > 0) - { - // If the SHA-384 is in the list, return false - if (FindValueInList(this.NotSHA384s, rom.SHA384)) - { - return false; - } - } + if (!this.SHA384.MatchesPositiveSet(rom.SHA384)) + return false; + if (this.SHA384.MatchesNegativeSet(rom.SHA384)) + return false; // Filter on SHA-512 - if (this.SHA512s.Count > 0) - { - // If the SHA-512 isn't in the list, return false - if (!FindValueInList(this.SHA512s, rom.SHA512)) - { - return false; - } - } - if (this.NotSHA512s.Count > 0) - { - // If the SHA-512 is in the list, return false - if (FindValueInList(this.NotSHA512s, rom.SHA512)) - { - return false; - } - } + if (!this.SHA512.MatchesPositiveSet(rom.SHA512)) + return false; + if (this.SHA512.MatchesNegativeSet(rom.SHA512)) + return false; } // Filter on machine name - if (this.MachineNames.Count > 0) + bool machineNameFound = this.MachineName.MatchesPositiveSet(item.MachineName); + if (this.IncludeOfInGame.Neutral) { - bool found = FindValueInList(this.MachineNames, item.MachineName); - - // If we are checking CloneOf and RomOf, add them in as well - if (this.IncludeOfInGame) - { - found |= FindValueInList(this.MachineNames, item.CloneOf); - found |= FindValueInList(this.MachineNames, item.RomOf); - } - - // If the game name was not found in the list, return false - if (!found) - { - return false; - } + machineNameFound |= this.MachineName.MatchesPositiveSet(item.CloneOf); + machineNameFound |= this.MachineName.MatchesPositiveSet(item.RomOf); } - if (this.NotMachineNames.Count > 0) + if (!machineNameFound) + return false; + + machineNameFound = this.MachineName.MatchesNegativeSet(item.MachineName); + if (this.IncludeOfInGame.Neutral) { - bool found = FindValueInList(this.NotMachineNames, item.MachineName); - - // If we are checking CloneOf and RomOf, add them in as well - if (this.IncludeOfInGame) - { - found |= FindValueInList(this.NotMachineNames, item.CloneOf); - found |= FindValueInList(this.NotMachineNames, item.RomOf); - } - - // If the machine name was found in the list, return false - if (found) - { - return false; - } + machineNameFound |= this.MachineName.MatchesNegativeSet(item.CloneOf); + machineNameFound |= this.MachineName.MatchesNegativeSet(item.RomOf); } + if (machineNameFound) + return false; // Filter on machine description - if (this.MachineDescriptions.Count > 0) - { - bool found = FindValueInList(this.MachineDescriptions, item.MachineDescription); - - // If the machine description was not found in the list, return false - if (!found) - { - return false; - } - } - if (this.NotMachineDescriptions.Count > 0) - { - bool found = FindValueInList(this.NotMachineDescriptions, item.MachineDescription); - - // If the machine description was found in the list, return false - if (found) - { - return false; - } - } + if (!this.MachineDescription.MatchesPositiveSet(item.MachineDescription)) + return false; + if (this.MachineDescription.MatchesNegativeSet(item.MachineDescription)) + return false; // Filter on item name - if (this.ItemNames.Count > 0) - { - // If the item name was not found in the list, return false - if (!FindValueInList(this.ItemNames, item.Name)) - { - return false; - } - } - if (this.NotItemNames.Count > 0) - { - // If the item name was found in the list, return false - if (FindValueInList(this.NotItemNames, item.Name)) - { - return false; - } - } + if (!this.ItemName.MatchesPositiveSet(item.Name)) + return false; + if (this.ItemName.MatchesNegativeSet(item.Name)) + return false; // Filter on item type - if (this.ItemTypes.Count == 0 && this.NotItemTypes.Count == 0 && item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank) - { + if (this.ItemTypes.PositiveSet.Count == 0 && this.ItemTypes.NegativeSet.Count == 0 + && item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank) + return false; + if (!this.ItemTypes.MatchesPositiveSet(item.ItemType.ToString())) + return false; + if (this.ItemTypes.MatchesNegativeSet(item.ItemType.ToString())) return false; - } - if (this.ItemTypes.Count > 0) - { - // If the item type was not found in the list, return false - if (!FindValueInList(this.ItemTypes, item.ItemType.ToString())) - { - return false; - } - } - if (this.NotItemTypes.Count > 0) - { - // If the item type was found in the list, return false - if (FindValueInList(this.NotItemTypes, item.ItemType.ToString())) - { - return false; - } - } return true; } - /// - /// Generic code to check if a specific value is in the list given - /// - /// List to search for the value in - /// Value to search the list for - /// True if the value could be found, false otherwise - private bool FindValueInList(List haystack, string needle) - { - bool found = false; - foreach (string straw in haystack) - { - if (!String.IsNullOrWhiteSpace(straw)) - { - string regexStraw = straw; - - // If the straw has no special characters at all, treat it as an exact match - if (regexStraw == Regex.Escape(regexStraw)) - { - regexStraw = "^" + regexStraw + "$"; - } - - // Check if a match is found with the regex - found |= Regex.IsMatch(needle, regexStraw, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - } - } - - return found; - } - #endregion } } diff --git a/SabreTools.Library/DatFiles/FilterItem.cs b/SabreTools.Library/DatFiles/FilterItem.cs new file mode 100644 index 00000000..1139ad5f --- /dev/null +++ b/SabreTools.Library/DatFiles/FilterItem.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace SabreTools.Library.DatFiles +{ + /// + /// Represents a single filter within the overall filter + /// + /// Generic type representing the filtered object + public class FilterItem + { + /// + /// Single positive value for this filter + /// + public T Positive { get; set; } + + /// + /// List of positive values for this filter + /// + public List PositiveSet { get; set; } = new List(); + + /// + /// Single negative value for this filter + /// + public T Negative { get; set; } + + /// + /// List of negative values for this filter + /// + public List NegativeSet { get; set; } = new List(); + + /// + /// Single neutral value for this filter + /// + public T Neutral { get; set; } + + /// + /// List of neutral values for this filter + /// + public List NeutralSet { get; set; } = new List(); + + /// + /// Check if a value matches the positive filter + /// + /// Default value to check filter value + /// Value to check + /// True if the value was found in the positive filter, false otherwise + public bool MatchesPositive(T def, T value) + { + return Matches(this.Positive, def, value); + } + + /// + /// Check if a value matches the negative filter + /// + /// Default value to check filter value + /// Value to check + /// True if the value was found in the negative filter, false otherwise + public bool MatchesNegative(T def, T value) + { + return Matches(this.Negative, def, value); + } + + /// + /// Check if a value matches the neutral filter + /// + /// Default value to check filter value + /// Value to check + /// True if the value was found in the neutral filter, false otherwise + public bool MatchesNeutral(T def, T value) + { + return Matches(this.Neutral, def, value); + } + + /// + /// Check if the given value matches any of the positive filters + /// + /// Value to check + /// True if the value was found in a positive filter, false otherwise + public bool MatchesPositiveSet(T value) + { + return MatchesSet(this.PositiveSet, value); + } + + /// + /// Check if the given value matches any of the negative filters + /// + /// Value to check + /// True if the value was found in a negative filter, false otherwise + public bool MatchesNegativeSet(T value) + { + return MatchesSet(this.NegativeSet, value); + } + + /// + /// Check if the given value matches any of the neutral filters + /// + /// Value to check + /// True if the value was found in a neutral filter, false otherwise + public bool MatchesNeutralSet(T value) + { + return MatchesSet(this.NeutralSet, value); + } + + /// + /// Check if a value matches the supplied filter + /// + /// Value to check against + /// Default value to check filter value + /// Value to check + /// True if the value was found in the supplied filter, false otherwise + private bool Matches(T single, T def, T value) + { + // If the filter is default, we ignore + if (single.Equals(def)) + return true; + + // If we have a flag + if (typeof(T).IsEnum && (single as Enum).HasFlag(value as Enum)) + return true; + + return single.Equals(value); + } + + /// + /// Check if a value matches the supplied filter + /// + /// Set to check against + /// Value to check + /// True if the value was found in the supplied filter, false otherwise + private bool MatchesSet(List set, T value) + { + if (set.Count > 0) + { + if (this.FindValueInList(set, value)) + return true; + } + + return false; + } + + /// + /// Generic code to check if a specific value is in the list given + /// + /// List to search for the value in + /// Value to search the list for + /// True if the value could be found, false otherwise + private bool FindValueInList(List haystack, T needle) + { + bool found = false; + foreach (T straw in haystack) + { + if (straw is string) + { + string needleString = needle as string; + string strawString = straw as string; + if (!String.IsNullOrWhiteSpace(strawString)) + { + string regexStraw = strawString; + + // If the straw has no special characters at all, treat it as an exact match + if (regexStraw == Regex.Escape(regexStraw)) + { + regexStraw = "^" + regexStraw + "$"; + } + + // Check if a match is found with the regex + found |= Regex.IsMatch(needleString, regexStraw, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + } + } + else + { + found |= (needle.Equals(straw)); + } + } + + return found; + } + } +} diff --git a/SabreTools.Library/SabreTools.Library.csproj b/SabreTools.Library/SabreTools.Library.csproj index c7038ca3..0d6522a4 100644 --- a/SabreTools.Library/SabreTools.Library.csproj +++ b/SabreTools.Library/SabreTools.Library.csproj @@ -93,6 +93,7 @@ + diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 4efdc713..34a6889b 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -14,914 +14,914 @@ using Alphaleonis.Win32.Filesystem; namespace SabreTools { - /// - /// Entry class for the DATabase application - /// - /// TODO: Look into async read/write to make things quicker. Ask edc for help? - public partial class SabreTools - { - // Private required variables - private static Help _help; + /// + /// Entry class for the DATabase application + /// + /// TODO: Look into async read/write to make things quicker. Ask edc for help? + public partial class SabreTools + { + // Private required variables + private static Help _help; - /// - /// Entry class for the SabreTools application - /// - /// String array representing command line parameters - public static void Main(string[] args) - { - // Perform initial setup and verification - Globals.Logger = new Logger(true, "sabretools.log"); + /// + /// Entry class for the SabreTools application + /// + /// String array representing command line parameters + public static void Main(string[] args) + { + // Perform initial setup and verification + Globals.Logger = new Logger(true, "sabretools.log"); - // Create a new Help object for this program - _help = SabreTools.RetrieveHelp(); + // Create a new Help object for this program + _help = SabreTools.RetrieveHelp(); - // Get the location of the script tag, if it exists - int scriptLocation = (new List(args)).IndexOf("--script"); + // Get the location of the script tag, if it exists + int scriptLocation = (new List(args)).IndexOf("--script"); - // If output is being redirected or we are in script mode, don't allow clear screens - if (!Console.IsOutputRedirected && scriptLocation == -1) - { - Console.Clear(); - Build.PrepareConsole("SabreTools"); - } + // If output is being redirected or we are in script mode, don't allow clear screens + if (!Console.IsOutputRedirected && scriptLocation == -1) + { + Console.Clear(); + Build.PrepareConsole("SabreTools"); + } - // Now we remove the script tag because it messes things up - if (scriptLocation > -1) - { - List newargs = new List(args); - newargs.RemoveAt(scriptLocation); - args = newargs.ToArray(); - } + // Now we remove the script tag because it messes things up + if (scriptLocation > -1) + { + List newargs = new List(args); + newargs.RemoveAt(scriptLocation); + args = newargs.ToArray(); + } - // Credits take precidence over all - if ((new List(args)).Contains("--credits")) - { - _help.OutputCredits(); - Globals.Logger.Close(); - return; - } + // Credits take precidence over all + if ((new List(args)).Contains("--credits")) + { + _help.OutputCredits(); + Globals.Logger.Close(); + return; + } - // If there's no arguments, show help - if (args.Length == 0) - { - _help.OutputGenericHelp(); - Globals.Logger.Close(); - return; - } + // If there's no arguments, show help + if (args.Length == 0) + { + _help.OutputGenericHelp(); + Globals.Logger.Close(); + return; + } - // User flags - bool addBlankFiles = false, - addFileDates = false, - archivesAsFiles = false, - basedat = false, - chdsAsFiles = false, - cleanGameNames = false, - copyFiles = false, - delete = false, - depot = false, - descAsName = false, - hashOnly = false, - individual = false, - inplace = false, - inverse = false, - noAutomaticDate = false, - nostore = false, - onlySame = false, - quickScan = false, - removeUnicode = false, - showBaddumpColumn = false, - showNodumpColumn = false, - shortname = false, - skipFirstOutput = false, - updateDat = false; - Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually - OutputFormat outputFormat = OutputFormat.Folder; - ReplaceMode replaceMode = ReplaceMode.None; - SkipFileType skipFileType = SkipFileType.None; - SplittingMode splittingMode = SplittingMode.None; - SplitType splitType = SplitType.None; - StatReportFormat statDatFormat = StatReportFormat.None; - UpdateMode updateMode = UpdateMode.None; + // User flags + bool addBlankFiles = false, + addFileDates = false, + archivesAsFiles = false, + basedat = false, + chdsAsFiles = false, + cleanGameNames = false, + copyFiles = false, + delete = false, + depot = false, + descAsName = false, + hashOnly = false, + individual = false, + inplace = false, + inverse = false, + noAutomaticDate = false, + nostore = false, + onlySame = false, + quickScan = false, + removeUnicode = false, + showBaddumpColumn = false, + showNodumpColumn = false, + shortname = false, + skipFirstOutput = false, + updateDat = false; + Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually + OutputFormat outputFormat = OutputFormat.Folder; + ReplaceMode replaceMode = ReplaceMode.None; + SkipFileType skipFileType = SkipFileType.None; + SplittingMode splittingMode = SplittingMode.None; + SplitType splitType = SplitType.None; + StatReportFormat statDatFormat = StatReportFormat.None; + UpdateMode updateMode = UpdateMode.None; - // User inputs - int gz = 1, - rar = 1, - sevenzip = 1, - zip = 1; - long radix = 0; - string outDir = null, - tempDir = ""; - DatHeader datHeader = new DatHeader(); - Filter filter = new Filter(); - List basePaths = new List(); - List datfiles = new List(); - List exta = new List(); - List extb = new List(); - List inputs = new List(); - List updateFields = new List(); + // User inputs + int gz = 1, + rar = 1, + sevenzip = 1, + zip = 1; + long radix = 0; + string outDir = null, + tempDir = ""; + DatHeader datHeader = new DatHeader(); + Filter filter = new Filter(); + List basePaths = new List(); + List datfiles = new List(); + List exta = new List(); + List extb = new List(); + List inputs = new List(); + List updateFields = new List(); - // Get the first argument as a feature flag - string feature = args[0]; + // Get the first argument as a feature flag + string feature = args[0]; - // Verify that the flag is valid - if (!_help.TopLevelFlag(feature)) - { - Globals.Logger.User("'{0}' is not valid feature flag", feature); - _help.OutputIndividualFeature(feature); - Globals.Logger.Close(); - return; - } + // Verify that the flag is valid + if (!_help.TopLevelFlag(feature)) + { + Globals.Logger.User("'{0}' is not valid feature flag", feature); + _help.OutputIndividualFeature(feature); + Globals.Logger.Close(); + return; + } - // Now get the proper name for the feature - feature = _help.GetFeatureName(feature); + // Now get the proper name for the feature + feature = _help.GetFeatureName(feature); - // If we had the help feature first - if (feature == "Help") - { - // If we had something else after help - if (args.Length > 1) - { - _help.OutputIndividualFeature(args[1]); - Globals.Logger.Close(); - return; - } - // Otherwise, show generic help - else - { - _help.OutputGenericHelp(); - Globals.Logger.Close(); - return; - } - } - else if (feature == "Help (Detailed)") - { - // If we had something else after help - if (args.Length > 1) - { - _help.OutputIndividualFeature(args[1], includeLongDescription: true); - Globals.Logger.Close(); - return; - } - // Otherwise, show generic help - else - { - _help.OutputAllHelp(); - Globals.Logger.Close(); - return; - } - } + // If we had the help feature first + if (feature == "Help") + { + // If we had something else after help + if (args.Length > 1) + { + _help.OutputIndividualFeature(args[1]); + Globals.Logger.Close(); + return; + } + // Otherwise, show generic help + else + { + _help.OutputGenericHelp(); + Globals.Logger.Close(); + return; + } + } + else if (feature == "Help (Detailed)") + { + // If we had something else after help + if (args.Length > 1) + { + _help.OutputIndividualFeature(args[1], includeLongDescription: true); + Globals.Logger.Close(); + return; + } + // Otherwise, show generic help + else + { + _help.OutputAllHelp(); + Globals.Logger.Close(); + return; + } + } - // Now verify that all other flags are valid - for (int i = 1; i < args.Length; i++) - { - // Verify that the current flag is proper for the feature - if (!_help[feature].ValidateInput(args[i])) - { - Globals.Logger.Error("Invalid input detected: {0}", args[i]); - _help.OutputIndividualFeature(feature); - Globals.Logger.Close(); - return; - } + // Now verify that all other flags are valid + for (int i = 1; i < args.Length; i++) + { + // Verify that the current flag is proper for the feature + if (!_help[feature].ValidateInput(args[i])) + { + Globals.Logger.Error("Invalid input detected: {0}", args[i]); + _help.OutputIndividualFeature(feature); + Globals.Logger.Close(); + return; + } - // Special precautions for files and directories - if (File.Exists(args[i]) || Directory.Exists(args[i])) - { - inputs.Add(args[i]); - } - } + // Special precautions for files and directories + if (File.Exists(args[i]) || Directory.Exists(args[i])) + { + inputs.Add(args[i]); + } + } - // Now loop through all inputs - Dictionary features = _help.GetEnabledFeatures(); - foreach (KeyValuePair feat in features) - { - // Check all of the flag names and translate to arguments - switch (feat.Key) - { - #region User Flags + // Now loop through all inputs + Dictionary features = _help.GetEnabledFeatures(); + foreach (KeyValuePair feat in features) + { + // Check all of the flag names and translate to arguments + switch (feat.Key) + { + #region User Flags - case "add-blank-files": - addBlankFiles = true; - break; - case "add-date": - addFileDates = true; - break; - case "all-stats": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); - statDatFormat = StatReportFormat.All; - break; - case "archives-as-files": - archivesAsFiles = true; - break; - case "baddump-column": - showBaddumpColumn = true; - break; - case "base": - basedat = true; - break; - case "base-replace": - updateMode |= UpdateMode.BaseReplace; - break; - case "chds-as-Files": - chdsAsFiles = true; - break; - case "copy-files": - copyFiles = true; - break; - case "clean": - cleanGameNames = true; - break; - case "csv": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); - statDatFormat |= StatReportFormat.CSV; - break; - case "dat-device-non-merged": - splitType = SplitType.DeviceNonMerged; - break; - case "dat-full-non-merged": - splitType = SplitType.FullNonMerged; - break; - case "dat-merged": - splitType = SplitType.Merged; - break; - case "dat-non-merged": - splitType = SplitType.NonMerged; - break; - case "dat-split": - splitType = SplitType.Split; - break; - case "dedup": - datHeader.DedupeRoms = DedupeType.Full; - break; - case "delete": - delete = true; - break; - case "depot": - depot = true; - break; - case "depreciated": - // Remove the Logiqx standard output if this is included - if ((datHeader.DatFormat & DatFormat.Logiqx) != 0) - { - datHeader.DatFormat &= ~DatFormat.Logiqx; - } - datHeader.DatFormat |= DatFormat.LogiqxDepreciated; - break; - case "description-as-name": - descAsName = true; - break; - case "diff-against": - updateMode |= UpdateMode.DiffAgainst; - break; - case "diff-all": - updateMode |= UpdateMode.AllDiffs; - break; - case "diff-cascade": - updateMode |= UpdateMode.DiffCascade; - break; - case "diff-duplicates": - updateMode |= UpdateMode.DiffDupesOnly; - break; - case "diff-individuals": - updateMode |= UpdateMode.DiffIndividualsOnly; - break; - case "diff-no-duplicates": - updateMode |= UpdateMode.DiffNoDupesOnly; - break; - case "diff-reverse-cascade": - updateMode |= UpdateMode.DiffReverseCascade; - break; - case "exclude-of": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.CloneOf] = true; - datHeader.ExcludeFields[(int)Field.MachineType] = true; - datHeader.ExcludeFields[(int)Field.RomOf] = true; - datHeader.ExcludeFields[(int)Field.Runnable] = true; - datHeader.ExcludeFields[(int)Field.SampleOf] = true; - break; - case "extension": - splittingMode |= SplittingMode.Extension; - break; - case "game-dedup": - datHeader.DedupeRoms = DedupeType.Game; - break; - case "game-prefix": - datHeader.GameName = true; - break; - case "hash": - splittingMode |= SplittingMode.Hash; - break; - case "hash-only": - hashOnly = true; - break; - case "html": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); - statDatFormat |= StatReportFormat.HTML; - break; - case "individual": - individual = true; - break; - case "inplace": - inplace = true; - break; - case "inverse": - inverse = true; - break; - case "keep-empty-games": - datHeader.KeepEmptyGames = true; - break; - case "level": - splittingMode |= SplittingMode.Level; - break; - case "match-of-tags": - filter.IncludeOfInGame = true; - break; - case "merge": - updateMode |= UpdateMode.Merge; - break; - case "no-automatic-date": - noAutomaticDate = true; - break; - case "nodump-column": - showNodumpColumn = true; - break; - case "not-runnable": - filter.Runnable = false; - break; - case "no-store-header": - nostore = true; - break; - case "one-rom-per-game": - datHeader.OneRom = true; - break; - case "only-same": - onlySame = true; - break; - // TODO: Remove all "output-*" variant flags - case "output-all": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.ALL; - break; - case "output-attractmode": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.AttractMode; - break; - case "output-cmp": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.ClrMamePro; - break; - case "output-csv": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.CSV; - break; - case "output-doscenter": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.DOSCenter; - break; - case "output-listrom": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.Listrom; - break; - case "output-listxml": // TODO: Not added to readme yet - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - datHeader.DatFormat |= DatFormat.Listxml; - break; - case "output-miss": - datHeader.DatFormat |= DatFormat.MissFile; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-md5": - datHeader.DatFormat |= DatFormat.RedumpMD5; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-offlinelist": - datHeader.DatFormat |= DatFormat.OfflineList; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-romcenter": - datHeader.DatFormat |= DatFormat.RomCenter; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sabredat": - datHeader.DatFormat |= DatFormat.SabreDat; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sfv": - datHeader.DatFormat |= DatFormat.RedumpSFV; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sha1": - datHeader.DatFormat |= DatFormat.RedumpSHA1; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sha256": - datHeader.DatFormat |= DatFormat.RedumpSHA256; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sha384": - datHeader.DatFormat |= DatFormat.RedumpSHA384; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-sha512": - datHeader.DatFormat |= DatFormat.RedumpSHA512; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-softwarelist": - datHeader.DatFormat |= DatFormat.SoftwareList; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-ssv": - datHeader.DatFormat |= DatFormat.SSV; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-tsv": - datHeader.DatFormat |= DatFormat.TSV; - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - break; - case "output-xml": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); - // Only set this flag if the depreciated flag is not already - if ((datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0) - { - datHeader.DatFormat |= DatFormat.Logiqx; - } - break; - case "quick": - quickScan = true; - break; - case "quotes": - datHeader.Quotes = true; - break; - case "remove-extensions": - datHeader.RemoveExtension = true; - break; - case "remove-md5": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.MD5] = true; - break; - case "remove-sha1": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.SHA1] = true; - break; - case "remove-sha256": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.SHA256] = true; - break; - case "remove-sha384": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.SHA384] = true; - break; - case "remove-sha512": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); - datHeader.ExcludeFields[(int)Field.SHA512] = true; - break; - case "remove-unicode": - removeUnicode = true; - break; - case "reverse-base-name": - updateMode |= UpdateMode.ReverseBaseReplace; - break; - case "romba": - datHeader.Romba = true; - break; - case "roms": - datHeader.UseRomName = true; - break; - case "runnable": - filter.Runnable = true; - break; - case "scan-all": - sevenzip = 0; - gz = 0; - rar = 0; - zip = 0; - break; - case "scene-date-strip": - datHeader.SceneDateStrip = true; - break; - case "short": - shortname = true; - break; - case "size": - splittingMode |= SplittingMode.Size; - break; - case "skip-archives": - skipFileType = SkipFileType.Archive; - break; - case "skip-files": - skipFileType = SkipFileType.File; - break; - case "skip-first-output": - skipFirstOutput = true; - break; - case "skip-md5": - omitFromScan |= Hash.MD5; - break; - case "skip-sha1": - omitFromScan |= Hash.SHA1; - break; - case "skip-sha256": - omitFromScan &= ~Hash.SHA256; // This needs to be inverted later - break; - case "skip-sha384": - omitFromScan &= ~Hash.SHA384; // This needs to be inverted later - break; - case "skip-sha512": - omitFromScan &= ~Hash.SHA512; // This needs to be inverted later - break; - case "single-set": - filter.Single = true; - break; - case "superdat": - datHeader.Type = "SuperDAT"; - break; - case "tar": - outputFormat = OutputFormat.TapeArchive; - break; - case "text": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); - statDatFormat |= StatReportFormat.Textfile; - break; - case "torrent-7zip": - outputFormat = OutputFormat.Torrent7Zip; - break; - case "torrent-gzip": - outputFormat = OutputFormat.TorrentGzip; - break; - case "torrent-lrzip": - outputFormat = OutputFormat.TorrentLRZip; - break; - case "torrent-lz4": - outputFormat = OutputFormat.TorrentLZ4; - break; - case "torrent-rar": - outputFormat = OutputFormat.TorrentRar; - break; - case "torrent-xz": - outputFormat = OutputFormat.TorrentXZ; - break; - case "torrent-zip": - outputFormat = OutputFormat.TorrentZip; - break; - case "torrent-zpaq": - outputFormat = OutputFormat.TorrentZPAQ; - break; - case "torrent-zstd": - outputFormat = OutputFormat.TorrentZstd; - break; - case "trim": - filter.Trim = true; - break; - case "tsv": - Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); - statDatFormat |= StatReportFormat.TSV; - break; - case "type": - splittingMode |= SplittingMode.Type; - break; - case "update-dat": - updateDat = true; - break; - case "update-description": - replaceMode |= ReplaceMode.Description; - break; - case "update-game-type": - replaceMode |= ReplaceMode.MachineType; - break; - case "update-hashes": - replaceMode |= ReplaceMode.Hash; - break; - case "update-manufacturer": - replaceMode |= ReplaceMode.Manufacturer; - break; - case "update-names": - replaceMode |= ReplaceMode.ItemName; - break; - case "update-parents": - replaceMode |= ReplaceMode.Parents; - break; - case "update-year": - replaceMode |= ReplaceMode.Year; - break; + case "add-blank-files": + addBlankFiles = true; + break; + case "add-date": + addFileDates = true; + break; + case "all-stats": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); + statDatFormat = StatReportFormat.All; + break; + case "archives-as-files": + archivesAsFiles = true; + break; + case "baddump-column": + showBaddumpColumn = true; + break; + case "base": + basedat = true; + break; + case "base-replace": + updateMode |= UpdateMode.BaseReplace; + break; + case "chds-as-Files": + chdsAsFiles = true; + break; + case "copy-files": + copyFiles = true; + break; + case "clean": + cleanGameNames = true; + break; + case "csv": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); + statDatFormat |= StatReportFormat.CSV; + break; + case "dat-device-non-merged": + splitType = SplitType.DeviceNonMerged; + break; + case "dat-full-non-merged": + splitType = SplitType.FullNonMerged; + break; + case "dat-merged": + splitType = SplitType.Merged; + break; + case "dat-non-merged": + splitType = SplitType.NonMerged; + break; + case "dat-split": + splitType = SplitType.Split; + break; + case "dedup": + datHeader.DedupeRoms = DedupeType.Full; + break; + case "delete": + delete = true; + break; + case "depot": + depot = true; + break; + case "depreciated": + // Remove the Logiqx standard output if this is included + if ((datHeader.DatFormat & DatFormat.Logiqx) != 0) + { + datHeader.DatFormat &= ~DatFormat.Logiqx; + } + datHeader.DatFormat |= DatFormat.LogiqxDepreciated; + break; + case "description-as-name": + descAsName = true; + break; + case "diff-against": + updateMode |= UpdateMode.DiffAgainst; + break; + case "diff-all": + updateMode |= UpdateMode.AllDiffs; + break; + case "diff-cascade": + updateMode |= UpdateMode.DiffCascade; + break; + case "diff-duplicates": + updateMode |= UpdateMode.DiffDupesOnly; + break; + case "diff-individuals": + updateMode |= UpdateMode.DiffIndividualsOnly; + break; + case "diff-no-duplicates": + updateMode |= UpdateMode.DiffNoDupesOnly; + break; + case "diff-reverse-cascade": + updateMode |= UpdateMode.DiffReverseCascade; + break; + case "exclude-of": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.CloneOf] = true; + datHeader.ExcludeFields[(int)Field.MachineType] = true; + datHeader.ExcludeFields[(int)Field.RomOf] = true; + datHeader.ExcludeFields[(int)Field.Runnable] = true; + datHeader.ExcludeFields[(int)Field.SampleOf] = true; + break; + case "extension": + splittingMode |= SplittingMode.Extension; + break; + case "game-dedup": + datHeader.DedupeRoms = DedupeType.Game; + break; + case "game-prefix": + datHeader.GameName = true; + break; + case "hash": + splittingMode |= SplittingMode.Hash; + break; + case "hash-only": + hashOnly = true; + break; + case "html": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); + statDatFormat |= StatReportFormat.HTML; + break; + case "individual": + individual = true; + break; + case "inplace": + inplace = true; + break; + case "inverse": + inverse = true; + break; + case "keep-empty-games": + datHeader.KeepEmptyGames = true; + break; + case "level": + splittingMode |= SplittingMode.Level; + break; + case "match-of-tags": + filter.IncludeOfInGame.Neutral = true; + break; + case "merge": + updateMode |= UpdateMode.Merge; + break; + case "no-automatic-date": + noAutomaticDate = true; + break; + case "nodump-column": + showNodumpColumn = true; + break; + case "not-runnable": + filter.Runnable.Neutral = false; + break; + case "no-store-header": + nostore = true; + break; + case "one-rom-per-game": + datHeader.OneRom = true; + break; + case "only-same": + onlySame = true; + break; + // TODO: Remove all "output-*" variant flags + case "output-all": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.ALL; + break; + case "output-attractmode": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.AttractMode; + break; + case "output-cmp": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.ClrMamePro; + break; + case "output-csv": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.CSV; + break; + case "output-doscenter": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.DOSCenter; + break; + case "output-listrom": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.Listrom; + break; + case "output-listxml": // TODO: Not added to readme yet + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + datHeader.DatFormat |= DatFormat.Listxml; + break; + case "output-miss": + datHeader.DatFormat |= DatFormat.MissFile; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-md5": + datHeader.DatFormat |= DatFormat.RedumpMD5; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-offlinelist": + datHeader.DatFormat |= DatFormat.OfflineList; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-romcenter": + datHeader.DatFormat |= DatFormat.RomCenter; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sabredat": + datHeader.DatFormat |= DatFormat.SabreDat; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sfv": + datHeader.DatFormat |= DatFormat.RedumpSFV; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sha1": + datHeader.DatFormat |= DatFormat.RedumpSHA1; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sha256": + datHeader.DatFormat |= DatFormat.RedumpSHA256; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sha384": + datHeader.DatFormat |= DatFormat.RedumpSHA384; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-sha512": + datHeader.DatFormat |= DatFormat.RedumpSHA512; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-softwarelist": + datHeader.DatFormat |= DatFormat.SoftwareList; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-ssv": + datHeader.DatFormat |= DatFormat.SSV; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-tsv": + datHeader.DatFormat |= DatFormat.TSV; + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + break; + case "output-xml": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _outputTypeListInput.Flags)); + // Only set this flag if the depreciated flag is not already + if ((datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0) + { + datHeader.DatFormat |= DatFormat.Logiqx; + } + break; + case "quick": + quickScan = true; + break; + case "quotes": + datHeader.Quotes = true; + break; + case "remove-extensions": + datHeader.RemoveExtension = true; + break; + case "remove-md5": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.MD5] = true; + break; + case "remove-sha1": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.SHA1] = true; + break; + case "remove-sha256": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.SHA256] = true; + break; + case "remove-sha384": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.SHA384] = true; + break; + case "remove-sha512": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); + datHeader.ExcludeFields[(int)Field.SHA512] = true; + break; + case "remove-unicode": + removeUnicode = true; + break; + case "reverse-base-name": + updateMode |= UpdateMode.ReverseBaseReplace; + break; + case "romba": + datHeader.Romba = true; + break; + case "roms": + datHeader.UseRomName = true; + break; + case "runnable": + filter.Runnable.Neutral = true; + break; + case "scan-all": + sevenzip = 0; + gz = 0; + rar = 0; + zip = 0; + break; + case "scene-date-strip": + datHeader.SceneDateStrip = true; + break; + case "short": + shortname = true; + break; + case "size": + splittingMode |= SplittingMode.Size; + break; + case "skip-archives": + skipFileType = SkipFileType.Archive; + break; + case "skip-files": + skipFileType = SkipFileType.File; + break; + case "skip-first-output": + skipFirstOutput = true; + break; + case "skip-md5": + omitFromScan |= Hash.MD5; + break; + case "skip-sha1": + omitFromScan |= Hash.SHA1; + break; + case "skip-sha256": + omitFromScan &= ~Hash.SHA256; // This needs to be inverted later + break; + case "skip-sha384": + omitFromScan &= ~Hash.SHA384; // This needs to be inverted later + break; + case "skip-sha512": + omitFromScan &= ~Hash.SHA512; // This needs to be inverted later + break; + case "single-set": + filter.Single.Neutral = true; + break; + case "superdat": + datHeader.Type = "SuperDAT"; + break; + case "tar": + outputFormat = OutputFormat.TapeArchive; + break; + case "text": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); + statDatFormat |= StatReportFormat.Textfile; + break; + case "torrent-7zip": + outputFormat = OutputFormat.Torrent7Zip; + break; + case "torrent-gzip": + outputFormat = OutputFormat.TorrentGzip; + break; + case "torrent-lrzip": + outputFormat = OutputFormat.TorrentLRZip; + break; + case "torrent-lz4": + outputFormat = OutputFormat.TorrentLZ4; + break; + case "torrent-rar": + outputFormat = OutputFormat.TorrentRar; + break; + case "torrent-xz": + outputFormat = OutputFormat.TorrentXZ; + break; + case "torrent-zip": + outputFormat = OutputFormat.TorrentZip; + break; + case "torrent-zpaq": + outputFormat = OutputFormat.TorrentZPAQ; + break; + case "torrent-zstd": + outputFormat = OutputFormat.TorrentZstd; + break; + case "trim": + filter.Trim.Neutral = true; + break; + case "tsv": + Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _reportTypeListInput.Flags)); + statDatFormat |= StatReportFormat.TSV; + break; + case "type": + splittingMode |= SplittingMode.Type; + break; + case "update-dat": + updateDat = true; + break; + case "update-description": + replaceMode |= ReplaceMode.Description; + break; + case "update-game-type": + replaceMode |= ReplaceMode.MachineType; + break; + case "update-hashes": + replaceMode |= ReplaceMode.Hash; + break; + case "update-manufacturer": + replaceMode |= ReplaceMode.Manufacturer; + break; + case "update-names": + replaceMode |= ReplaceMode.ItemName; + break; + case "update-parents": + replaceMode |= ReplaceMode.Parents; + break; + case "update-year": + replaceMode |= ReplaceMode.Year; + break; - #endregion + #endregion - #region User Int32 Inputs + #region User Int32 Inputs - case "7z": - sevenzip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; - break; - case "gz": - gz = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; - break; - case "rar": - rar = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; - break; - case "threads": - int val = (int)feat.Value.GetValue(); - if (val != Int32.MinValue) - { - Globals.MaxThreads = val; - } - break; - case "zip": - zip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; - break; + case "7z": + sevenzip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; + break; + case "gz": + gz = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; + break; + case "rar": + rar = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; + break; + case "threads": + int val = (int)feat.Value.GetValue(); + if (val != Int32.MinValue) + { + Globals.MaxThreads = val; + } + break; + case "zip": + zip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; + break; - #endregion + #endregion - #region User Int64 Inputs + #region User Int64 Inputs - case "radix": - radix = (long)feat.Value.GetValue() == Int64.MinValue ? (long)feat.Value.GetValue() : 0; - break; + case "radix": + radix = (long)feat.Value.GetValue() == Int64.MinValue ? (long)feat.Value.GetValue() : 0; + break; - #endregion + #endregion - #region User List Inputs + #region User List Inputs - case "base-dat": - basePaths.AddRange((List)feat.Value.GetValue()); - break; - case "crc": - filter.CRCs.AddRange((List)feat.Value.GetValue()); - break; - case "dat": - datfiles.AddRange((List)feat.Value.GetValue()); - break; - case "exclude-field": // TODO: Use this - foreach (string field in (List)feat.Value.GetValue()) - { - datHeader.ExcludeFields[(int)Utilities.GetField(field)] = true; - } - break; - case "exta": - exta.AddRange((List)feat.Value.GetValue()); - break; - case "extb": - extb.AddRange((List)feat.Value.GetValue()); - break; - case "game-description": - filter.MachineDescriptions.AddRange((List)feat.Value.GetValue()); - break; - case "game-name": - filter.MachineNames.AddRange((List)feat.Value.GetValue()); - break; - case "game-type": - foreach (string mach in (List)feat.Value.GetValue()) - { - filter.MachineTypes |= Utilities.GetMachineType(mach); - } - break; - case "item-name": - filter.ItemNames.AddRange((List)feat.Value.GetValue()); - break; - case "item-type": - filter.ItemTypes.AddRange((List)feat.Value.GetValue()); - break; - case "md5": - filter.MD5s.AddRange((List)feat.Value.GetValue()); - break; - case "not-crc": - filter.NotCRCs.AddRange((List)feat.Value.GetValue()); - break; - case "not-game-description": - filter.NotMachineDescriptions.AddRange((List)feat.Value.GetValue()); - break; - case "not-game-name": - filter.NotMachineNames.AddRange((List)feat.Value.GetValue()); - break; - case "not-game-type": - foreach (string nmach in (List)feat.Value.GetValue()) - { - filter.NotMachineTypes |= Utilities.GetMachineType(nmach); - } - break; - case "not-item-name": - filter.NotItemNames.AddRange((List)feat.Value.GetValue()); - break; - case "not-item-type": - filter.NotItemTypes.AddRange((List)feat.Value.GetValue()); - break; - case "not-md5": - filter.NotMD5s.AddRange((List)feat.Value.GetValue()); - break; - case "not-sha1": - filter.NotSHA1s.AddRange((List)feat.Value.GetValue()); - break; - case "not-sha256": - filter.NotSHA256s.AddRange((List)feat.Value.GetValue()); - break; - case "not-sha384": - filter.NotSHA384s.AddRange((List)feat.Value.GetValue()); - break; - case "not-sha512": - filter.NotSHA512s.AddRange((List)feat.Value.GetValue()); - break; - case "not-status": - foreach (string nstat in (List)feat.Value.GetValue()) - { - filter.NotItemStatuses |= Utilities.GetItemStatus(nstat); - } - break; - case "output-type": - foreach (string ot in (List)feat.Value.GetValue()) - { - DatFormat dftemp = Utilities.GetDatFormat(ot); - if (dftemp != DatFormat.Logiqx - || (dftemp == DatFormat.Logiqx && (datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0)) - { - datHeader.DatFormat |= dftemp; - } - } - break; - case "report-type": - foreach (string rt in (List)feat.Value.GetValue()) - { - statDatFormat |= Utilities.GetStatFormat(rt); - } - break; - case "sha1": - filter.SHA1s.AddRange((List)feat.Value.GetValue()); - break; - case "sha256": - filter.SHA256s.AddRange((List)feat.Value.GetValue()); - break; - case "sha384": - filter.SHA384s.AddRange((List)feat.Value.GetValue()); - break; - case "sha512": - filter.SHA512s.AddRange((List)feat.Value.GetValue()); - break; - case "status": - foreach (string stat in (List)feat.Value.GetValue()) - { - filter.ItemStatuses |= Utilities.GetItemStatus(stat); - } - break; - case "update-field": // TODO: Use this - foreach (string field in (List)feat.Value.GetValue()) - { - updateFields.Add(Utilities.GetField(field)); - } - break; + case "base-dat": + basePaths.AddRange((List)feat.Value.GetValue()); + break; + case "crc": + filter.CRC.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "dat": + datfiles.AddRange((List)feat.Value.GetValue()); + break; + case "exclude-field": // TODO: Use this + foreach (string field in (List)feat.Value.GetValue()) + { + datHeader.ExcludeFields[(int)Utilities.GetField(field)] = true; + } + break; + case "exta": + exta.AddRange((List)feat.Value.GetValue()); + break; + case "extb": + extb.AddRange((List)feat.Value.GetValue()); + break; + case "game-description": + filter.MachineDescription.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "game-name": + filter.MachineName.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "game-type": + foreach (string mach in (List)feat.Value.GetValue()) + { + filter.MachineTypes.Positive |= Utilities.GetMachineType(mach); + } + break; + case "item-name": + filter.ItemName.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "item-type": + filter.ItemTypes.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "md5": + filter.MD5.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-crc": + filter.CRC.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-game-description": + filter.MachineDescription.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-game-name": + filter.MachineName.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-game-type": + foreach (string nmach in (List)feat.Value.GetValue()) + { + filter.MachineTypes.Negative |= Utilities.GetMachineType(nmach); + } + break; + case "not-item-name": + filter.ItemName.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-item-type": + filter.ItemTypes.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-md5": + filter.MD5.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-sha1": + filter.SHA1.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-sha256": + filter.SHA256.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-sha384": + filter.SHA384.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-sha512": + filter.SHA512.NegativeSet.AddRange((List)feat.Value.GetValue()); + break; + case "not-status": + foreach (string nstat in (List)feat.Value.GetValue()) + { + filter.ItemStatuses.Negative |= Utilities.GetItemStatus(nstat); + } + break; + case "output-type": + foreach (string ot in (List)feat.Value.GetValue()) + { + DatFormat dftemp = Utilities.GetDatFormat(ot); + if (dftemp != DatFormat.Logiqx + || (dftemp == DatFormat.Logiqx && (datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0)) + { + datHeader.DatFormat |= dftemp; + } + } + break; + case "report-type": + foreach (string rt in (List)feat.Value.GetValue()) + { + statDatFormat |= Utilities.GetStatFormat(rt); + } + break; + case "sha1": + filter.SHA1.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "sha256": + filter.SHA256.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "sha384": + filter.SHA384.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "sha512": + filter.SHA512.PositiveSet.AddRange((List)feat.Value.GetValue()); + break; + case "status": + foreach (string stat in (List)feat.Value.GetValue()) + { + filter.ItemStatuses.Positive |= Utilities.GetItemStatus(stat); + } + break; + case "update-field": // TODO: Use this + foreach (string field in (List)feat.Value.GetValue()) + { + updateFields.Add(Utilities.GetField(field)); + } + break; - #endregion + #endregion - #region User String Inputs + #region User String Inputs - case "add-extension": - datHeader.AddExtension = (string)feat.Value.GetValue(); - break; - case "author": - datHeader.Author = (string)feat.Value.GetValue(); - break; - case "category": - datHeader.Category = (string)feat.Value.GetValue(); - break; - case "comment": - datHeader.Comment = (string)feat.Value.GetValue(); - break; - case "date": - datHeader.Date = (string)feat.Value.GetValue(); - break; - case "description": - datHeader.Description = (string)feat.Value.GetValue(); - break; - case "email": - datHeader.Email = (string)feat.Value.GetValue(); - break; - case "equal": - filter.SizeEqualTo = Utilities.GetSizeFromString((string)feat.Value.GetValue()); - break; - case "filename": - datHeader.FileName = (string)feat.Value.GetValue(); - break; - case "forcemerging": - datHeader.ForceMerging = Utilities.GetForceMerging((string)feat.Value.GetValue()); - break; - case "forcenodump": - datHeader.ForceNodump = Utilities.GetForceNodump((string)feat.Value.GetValue()); - break; - case "forcepacking": - datHeader.ForcePacking = Utilities.GetForcePacking((string)feat.Value.GetValue()); - break; - case "greater": - filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString((string)feat.Value.GetValue()); - break; - case "header": - datHeader.Header = (string)feat.Value.GetValue(); - break; - case "homepage": - datHeader.Homepage = (string)feat.Value.GetValue(); - break; - case "less": - filter.SizeLessThanOrEqual = Utilities.GetSizeFromString((string)feat.Value.GetValue()); - break; - case "name": - datHeader.Name = (string)feat.Value.GetValue(); - break; - case "output-dir": - outDir = (string)feat.Value.GetValue(); - break; - case "postfix": - datHeader.Postfix = (string)feat.Value.GetValue(); - break; - case "prefix": - datHeader.Prefix = (string)feat.Value.GetValue(); - break; - case "replace-extension": - datHeader.ReplaceExtension = (string)feat.Value.GetValue(); - break; - case "root": - datHeader.RootDir = (string)feat.Value.GetValue(); - break; - case "root-dir": - filter.Root = (string)feat.Value.GetValue(); - break; - case "temp": - tempDir = (string)feat.Value.GetValue(); - break; - case "url": - datHeader.Url = (string)feat.Value.GetValue(); - break; - case "version": - datHeader.Version = (string)feat.Value.GetValue(); - break; + case "add-extension": + datHeader.AddExtension = (string)feat.Value.GetValue(); + break; + case "author": + datHeader.Author = (string)feat.Value.GetValue(); + break; + case "category": + datHeader.Category = (string)feat.Value.GetValue(); + break; + case "comment": + datHeader.Comment = (string)feat.Value.GetValue(); + break; + case "date": + datHeader.Date = (string)feat.Value.GetValue(); + break; + case "description": + datHeader.Description = (string)feat.Value.GetValue(); + break; + case "email": + datHeader.Email = (string)feat.Value.GetValue(); + break; + case "equal": + filter.Size.Neutral = Utilities.GetSizeFromString((string)feat.Value.GetValue()); + break; + case "filename": + datHeader.FileName = (string)feat.Value.GetValue(); + break; + case "forcemerging": + datHeader.ForceMerging = Utilities.GetForceMerging((string)feat.Value.GetValue()); + break; + case "forcenodump": + datHeader.ForceNodump = Utilities.GetForceNodump((string)feat.Value.GetValue()); + break; + case "forcepacking": + datHeader.ForcePacking = Utilities.GetForcePacking((string)feat.Value.GetValue()); + break; + case "greater": + filter.Size.Positive = Utilities.GetSizeFromString((string)feat.Value.GetValue()); + break; + case "header": + datHeader.Header = (string)feat.Value.GetValue(); + break; + case "homepage": + datHeader.Homepage = (string)feat.Value.GetValue(); + break; + case "less": + filter.Size.Negative = Utilities.GetSizeFromString((string)feat.Value.GetValue()); + break; + case "name": + datHeader.Name = (string)feat.Value.GetValue(); + break; + case "output-dir": + outDir = (string)feat.Value.GetValue(); + break; + case "postfix": + datHeader.Postfix = (string)feat.Value.GetValue(); + break; + case "prefix": + datHeader.Prefix = (string)feat.Value.GetValue(); + break; + case "replace-extension": + datHeader.ReplaceExtension = (string)feat.Value.GetValue(); + break; + case "root": + datHeader.RootDir = (string)feat.Value.GetValue(); + break; + case "root-dir": + filter.Root.Neutral = (string)feat.Value.GetValue(); + break; + case "temp": + tempDir = (string)feat.Value.GetValue(); + break; + case "url": + datHeader.Url = (string)feat.Value.GetValue(); + break; + case "version": + datHeader.Version = (string)feat.Value.GetValue(); + break; - #endregion - } - } + #endregion + } + } - // Now take care of each mode in succesion - switch (feature) - { - case "Help": - // No-op as this should be caught - break; - // Create a DAT from a directory or set of directories - case "DATFromDir": - VerifyInputs(inputs, feature); - InitDatFromDir(inputs, datHeader, omitFromScan, noAutomaticDate, archivesAsFiles, chdsAsFiles, - skipFileType, addBlankFiles, addFileDates, tempDir, outDir, copyFiles, filter); - break; - // If we're in header extract and remove mode - case "Extract": - VerifyInputs(inputs, feature); - InitExtractRemoveHeader(inputs, outDir, nostore); - break; - // If we're in header restore mode - case "Restore": - VerifyInputs(inputs, feature); - InitReplaceHeader(inputs, outDir); - break; - case "Script": - // No-op as this should be caught - break; - // If we're using the sorter - case "Sort": - InitSort(datfiles, inputs, outDir, depot, quickScan, addFileDates, delete, inverse, - outputFormat, datHeader.Romba, sevenzip, gz, rar, zip, updateDat, datHeader.Header, - splitType, chdsAsFiles, individual); - break; - // Split a DAT by the split type - case "Split": - VerifyInputs(inputs, feature); - InitSplit(inputs, outDir, inplace, datHeader.DatFormat, splittingMode, exta, extb, shortname, basedat, radix); - break; - // Get statistics on input files - case "Stats": - VerifyInputs(inputs, feature); - InitStats(inputs, datHeader.FileName, outDir, individual, showBaddumpColumn, showNodumpColumn, statDatFormat); - break; - // Convert, update, merge, diff, and filter a DAT or folder of DATs - case "Update": - VerifyInputs(inputs, feature); - InitUpdate(inputs, basePaths, datHeader, updateMode, inplace, skipFirstOutput, noAutomaticDate, filter, - splitType, outDir, cleanGameNames, removeUnicode, descAsName, replaceMode, onlySame); - break; - // If we're using the verifier - case "Verify": - VerifyInputs(inputs, feature); - InitVerify(datfiles, inputs, depot, hashOnly, quickScan, datHeader.Header, splitType, chdsAsFiles, individual, filter); - break; - // If nothing is set, show the help - default: - _help.OutputGenericHelp(); - break; - } + // Now take care of each mode in succesion + switch (feature) + { + case "Help": + // No-op as this should be caught + break; + // Create a DAT from a directory or set of directories + case "DATFromDir": + VerifyInputs(inputs, feature); + InitDatFromDir(inputs, datHeader, omitFromScan, noAutomaticDate, archivesAsFiles, chdsAsFiles, + skipFileType, addBlankFiles, addFileDates, tempDir, outDir, copyFiles, filter); + break; + // If we're in header extract and remove mode + case "Extract": + VerifyInputs(inputs, feature); + InitExtractRemoveHeader(inputs, outDir, nostore); + break; + // If we're in header restore mode + case "Restore": + VerifyInputs(inputs, feature); + InitReplaceHeader(inputs, outDir); + break; + case "Script": + // No-op as this should be caught + break; + // If we're using the sorter + case "Sort": + InitSort(datfiles, inputs, outDir, depot, quickScan, addFileDates, delete, inverse, + outputFormat, datHeader.Romba, sevenzip, gz, rar, zip, updateDat, datHeader.Header, + splitType, chdsAsFiles, individual); + break; + // Split a DAT by the split type + case "Split": + VerifyInputs(inputs, feature); + InitSplit(inputs, outDir, inplace, datHeader.DatFormat, splittingMode, exta, extb, shortname, basedat, radix); + break; + // Get statistics on input files + case "Stats": + VerifyInputs(inputs, feature); + InitStats(inputs, datHeader.FileName, outDir, individual, showBaddumpColumn, showNodumpColumn, statDatFormat); + break; + // Convert, update, merge, diff, and filter a DAT or folder of DATs + case "Update": + VerifyInputs(inputs, feature); + InitUpdate(inputs, basePaths, datHeader, updateMode, inplace, skipFirstOutput, noAutomaticDate, filter, + splitType, outDir, cleanGameNames, removeUnicode, descAsName, replaceMode, onlySame); + break; + // If we're using the verifier + case "Verify": + VerifyInputs(inputs, feature); + InitVerify(datfiles, inputs, depot, hashOnly, quickScan, datHeader.Header, splitType, chdsAsFiles, individual, filter); + break; + // If nothing is set, show the help + default: + _help.OutputGenericHelp(); + break; + } - Globals.Logger.Close(); - return; - } + Globals.Logger.Close(); + return; + } - private static void VerifyInputs(List inputs, string feature) - { - if (inputs.Count == 0) - { - Globals.Logger.Error("This feature requires at least one input"); - _help.OutputIndividualFeature(feature); - Environment.Exit(0); - } - } - } + private static void VerifyInputs(List inputs, string feature) + { + if (inputs.Count == 0) + { + Globals.Logger.Error("This feature requires at least one input"); + _help.OutputIndividualFeature(feature); + Environment.Exit(0); + } + } + } }