diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index 86afafcc..9d11dc0a 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -134,7 +134,7 @@ namespace SabreTools.Helper helptext.Add(" -ab, --add-blank Output blank files for folders"); helptext.Add(" -ad, --add-date Output dates for each file parsed"); helptext.Add(" -cf, --copy-files Copy files to the temp directory before parsing"); - helptext.Add(" -rh, --rem-head Remove headers from hash calculations"); + helptext.Add(" -h=, --header= Set a header skipper to use, blank means all"); helptext.Add(" -t=, --temp= Set the temporary directory to use"); helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)"); helptext.Add(" -es, --ext-split Split a DAT by two file extensions"); diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index 4343bc19..38e63d72 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -240,10 +240,12 @@ Options: If this flag is set, then all files that are going to be parsed are moved to the temporary directory before being hashed. This can be helpful in cases where the temp folder is located on an SSD and the user wants to take advantage of this. - -rh, --rem-head Remove headers from hash calculations - If this flag is set, then all files that have copier headers that are detected will + -h=, --header= Remove headers from hash calculations + If this is set, then all files that have copier headers that are detected will have them removed from the hash calculation. This will allow for a headered collection - to be hashed without possibly variant information. + to be hashed without possibly variant information. If a particular header skipper is + defined, and that skipper exists, then it will be used instead of trying to find one + that matches. -t=, --temp= Set the name of the temporary directory Optionally, a temp folder can be supplied in the case the default temp directory diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 9ca2414f..7a52d61f 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -97,7 +97,7 @@ namespace SabreTools int maxDegreeOfParallelism) { ForcePacking fp = ForcePacking.None; - switch (forcepack.ToLowerInvariant()) + switch (forcepack?.ToLowerInvariant()) { case "none": default: @@ -474,7 +474,7 @@ namespace SabreTools { // Set the special flags ForceMerging fm = ForceMerging.None; - switch (forcemerge.ToLowerInvariant()) + switch (forcemerge?.ToLowerInvariant()) { case "none": default: @@ -489,7 +489,7 @@ namespace SabreTools } ForceNodump fn = ForceNodump.None; - switch (forcend.ToLowerInvariant()) + switch (forcend?.ToLowerInvariant()) { case "none": default: @@ -507,7 +507,7 @@ namespace SabreTools } ForcePacking fp = ForcePacking.None; - switch (forcepack.ToLowerInvariant()) + switch (forcepack?.ToLowerInvariant()) { case "none": default: @@ -523,7 +523,7 @@ namespace SabreTools // Set the status flag for filtering ItemStatus itemStatus = ItemStatus.NULL; - switch(status.ToLowerInvariant()) + switch(status?.ToLowerInvariant()) { case "none": itemStatus = ItemStatus.None; diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 784908dc..5598d4b3 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -94,39 +94,39 @@ namespace SabreTools seq = -1; OutputFormat outputFormat = 0x0; StatOutputFormat statOutputFormat = StatOutputFormat.None; - string addext = null, + string addext = "", author = null, category = null, comment = null, - crc = null, - currentAllMerged = null, - currentMissingMerged = null, - currentNewMerged = null, + crc = "", + currentAllMerged = "", + currentMissingMerged = "", + currentNewMerged = "", date = null, description = null, email = null, - exta = null, - extb = null, + exta = "", + extb = "", filename = null, - forcemerge = null, - forcend = null, - forcepack = null, - gamename = null, + forcemerge = "", + forcend = "", + forcepack = "", + gamename = "", header = null, - homepage = null, + homepage = "", name = null, - md5 = null, - outDir = null, - postfix = null, - prefix = null, - repext = null, - romname = null, - romtype = null, - root = null, + md5 = "", + outDir = "", + postfix = "", + prefix = "", + repext = "", + romname = "", + romtype = "", + root = "", rootdir = null, - sha1 = null, - status = null, - tempDir = null, + sha1 = "", + status = "", + tempDir = "", url = null, version = null; List inputs = new List(); @@ -357,163 +357,163 @@ namespace SabreTools if (temparg.StartsWith("-ae=") || temparg.StartsWith("--add-ext=")) { - addext = temparg.Split('=')[1]; + addext = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-au=") || temparg.StartsWith("--author=")) { - author = temparg.Split('=')[1]; + author = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-ca=") || temparg.StartsWith("--category=")) { - category = temparg.Split('=')[1]; + category = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-co=") || temparg.StartsWith("--comment=")) { - comment = temparg.Split('=')[1]; + comment = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-com=") || temparg.StartsWith("--com=")) { - currentAllMerged = temparg.Split('=')[1]; + currentAllMerged = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-crc=") || temparg.StartsWith("--crc=")) { - crc = temparg.Split('=')[1]; + crc = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-da=") || temparg.StartsWith("--date=")) { - date = temparg.Split('=')[1]; + date = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-de=") || temparg.StartsWith("--desc=")) { - description = temparg.Split('=')[1]; + description = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-em=") || temparg.StartsWith("--email=")) { - email = temparg.Split('=')[1]; + email = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-exta=")) { - exta = temparg.Split('=')[1]; + exta = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-extb=")) { - extb = temparg.Split('=')[1]; + extb = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-f=") || temparg.StartsWith("--filename=")) { - filename = temparg.Split('=')[1]; + filename = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-fix=") || temparg.StartsWith("--fix=")) { - currentMissingMerged = temparg.Split('=')[1]; + currentMissingMerged = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-fm=") || temparg.StartsWith("--forcemerge=")) { - forcemerge = temparg.Split('=')[1]; + forcemerge = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-fn=") || temparg.StartsWith("--forcend=")) { - forcend = temparg.Split('=')[1]; + forcend = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-fp=") || temparg.StartsWith("--forcepack=")) { - forcepack = temparg.Split('=')[1]; + forcepack = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-gn=") || temparg.StartsWith("--game-name=")) { - gamename = temparg.Split('=')[1]; + gamename = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-h=") || temparg.StartsWith("--header=")) { - header = temparg.Split('=')[1]; + header = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-hp=") || temparg.StartsWith("--homepage=")) { - homepage = temparg.Split('=')[1]; + homepage = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-input=")) { - inputs.Add(temparg.Split('=')[1]); + inputs.Add(temparg.Split('=')[1] ?? ""); } else if (temparg.StartsWith("-is=") || temparg.StartsWith("--status=")) { - status = temparg.Split('=')[1]; + status = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-md5=") || temparg.StartsWith("--md5=")) { - md5 = temparg.Split('=')[1]; + md5 = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-mt=") || temparg.StartsWith("--mt=")) { - Int32.TryParse(temparg.Split('=')[1], out maxParallelism); + Int32.TryParse(temparg.Split('=')[1] ?? "", out maxParallelism); } else if (temparg.StartsWith("-n=") || temparg.StartsWith("--name=")) { - name = temparg.Split('=')[1]; + name = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-new=") || temparg.StartsWith("--new=")) { - currentNewMerged = temparg.Split('=')[1]; + currentNewMerged = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-out=") || temparg.StartsWith("--out=")) { - outDir = temparg.Split('=')[1]; + outDir = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-post=") || temparg.StartsWith("--postfix=")) { - postfix = temparg.Split('=')[1]; + postfix = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-pre=") || temparg.StartsWith("--prefix=")) { - prefix = temparg.Split('=')[1]; + prefix = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-r=") || temparg.StartsWith("--root=")) { - rootdir = temparg.Split('=')[1]; + rootdir = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-rd=") || temparg.StartsWith("--root-dir=")) { - root = temparg.Split('=')[1]; + root = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-re=") || temparg.StartsWith("--rep-ext=")) { - repext = temparg.Split('=')[1]; + repext = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-rn=") || temparg.StartsWith("--rom-name=")) { - romname = temparg.Split('=')[1]; + romname = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-rt=") || temparg.StartsWith("--rom-type=")) { - romtype = temparg.Split('=')[1]; + romtype = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-seq=") || temparg.StartsWith("--equal=")) { - seq = GetSizeFromString(temparg.Split('=')[1]); + seq = GetSizeFromString(temparg.Split('=')[1] ?? ""); } else if (temparg.StartsWith("-sgt=") || temparg.StartsWith("--greater=")) { - sgt = GetSizeFromString(temparg.Split('=')[1]); + sgt = GetSizeFromString(temparg.Split('=')[1] ?? ""); } else if (temparg.StartsWith("-sha1=") || temparg.StartsWith("--sha1=")) { - sha1 = temparg.Split('=')[1]; + sha1 = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-slt=") || temparg.StartsWith("--less=")) { - slt = GetSizeFromString(temparg.Split('=')[1]); + slt = GetSizeFromString(temparg.Split('=')[1] ?? ""); } else if (temparg.StartsWith("-t=") || temparg.StartsWith("--temp=")) { - tempDir = temparg.Split('=')[1]; + tempDir = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-u=") || temparg.StartsWith("-url=") || temparg.StartsWith("--url=")) { - url = temparg.Split('=')[1]; + url = temparg.Split('=')[1] ?? ""; } else if (temparg.StartsWith("-v=") || temparg.StartsWith("--version=")) { - version = temparg.Split('=')[1]; + version = temparg.Split('=')[1] ?? ""; } else if (File.Exists(temparg) || Directory.Exists(temparg)) {