[SabreTools] Fix new flag

This commit is contained in:
Matt Nadareski
2016-10-03 22:08:10 -07:00
parent d8ff7f7943
commit b5d01db1d7
4 changed files with 74 additions and 72 deletions

View File

@@ -134,7 +134,7 @@ namespace SabreTools.Helper
helptext.Add(" -ab, --add-blank Output blank files for folders"); helptext.Add(" -ab, --add-blank Output blank files for folders");
helptext.Add(" -ad, --add-date Output dates for each file parsed"); 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(" -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(" -t=, --temp= Set the temporary directory to use");
helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)"); helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)");
helptext.Add(" -es, --ext-split Split a DAT by two file extensions"); helptext.Add(" -es, --ext-split Split a DAT by two file extensions");

View File

@@ -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 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. temp folder is located on an SSD and the user wants to take advantage of this.
-rh, --rem-head Remove headers from hash calculations -h=, --header= Remove headers from hash calculations
If this flag is set, then all files that have copier headers that are detected will 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 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 -t=, --temp= Set the name of the temporary directory
Optionally, a temp folder can be supplied in the case the default temp directory Optionally, a temp folder can be supplied in the case the default temp directory

View File

@@ -97,7 +97,7 @@ namespace SabreTools
int maxDegreeOfParallelism) int maxDegreeOfParallelism)
{ {
ForcePacking fp = ForcePacking.None; ForcePacking fp = ForcePacking.None;
switch (forcepack.ToLowerInvariant()) switch (forcepack?.ToLowerInvariant())
{ {
case "none": case "none":
default: default:
@@ -474,7 +474,7 @@ namespace SabreTools
{ {
// Set the special flags // Set the special flags
ForceMerging fm = ForceMerging.None; ForceMerging fm = ForceMerging.None;
switch (forcemerge.ToLowerInvariant()) switch (forcemerge?.ToLowerInvariant())
{ {
case "none": case "none":
default: default:
@@ -489,7 +489,7 @@ namespace SabreTools
} }
ForceNodump fn = ForceNodump.None; ForceNodump fn = ForceNodump.None;
switch (forcend.ToLowerInvariant()) switch (forcend?.ToLowerInvariant())
{ {
case "none": case "none":
default: default:
@@ -507,7 +507,7 @@ namespace SabreTools
} }
ForcePacking fp = ForcePacking.None; ForcePacking fp = ForcePacking.None;
switch (forcepack.ToLowerInvariant()) switch (forcepack?.ToLowerInvariant())
{ {
case "none": case "none":
default: default:
@@ -523,7 +523,7 @@ namespace SabreTools
// Set the status flag for filtering // Set the status flag for filtering
ItemStatus itemStatus = ItemStatus.NULL; ItemStatus itemStatus = ItemStatus.NULL;
switch(status.ToLowerInvariant()) switch(status?.ToLowerInvariant())
{ {
case "none": case "none":
itemStatus = ItemStatus.None; itemStatus = ItemStatus.None;

View File

@@ -94,39 +94,39 @@ namespace SabreTools
seq = -1; seq = -1;
OutputFormat outputFormat = 0x0; OutputFormat outputFormat = 0x0;
StatOutputFormat statOutputFormat = StatOutputFormat.None; StatOutputFormat statOutputFormat = StatOutputFormat.None;
string addext = null, string addext = "",
author = null, author = null,
category = null, category = null,
comment = null, comment = null,
crc = null, crc = "",
currentAllMerged = null, currentAllMerged = "",
currentMissingMerged = null, currentMissingMerged = "",
currentNewMerged = null, currentNewMerged = "",
date = null, date = null,
description = null, description = null,
email = null, email = null,
exta = null, exta = "",
extb = null, extb = "",
filename = null, filename = null,
forcemerge = null, forcemerge = "",
forcend = null, forcend = "",
forcepack = null, forcepack = "",
gamename = null, gamename = "",
header = null, header = null,
homepage = null, homepage = "",
name = null, name = null,
md5 = null, md5 = "",
outDir = null, outDir = "",
postfix = null, postfix = "",
prefix = null, prefix = "",
repext = null, repext = "",
romname = null, romname = "",
romtype = null, romtype = "",
root = null, root = "",
rootdir = null, rootdir = null,
sha1 = null, sha1 = "",
status = null, status = "",
tempDir = null, tempDir = "",
url = null, url = null,
version = null; version = null;
List<string> inputs = new List<string>(); List<string> inputs = new List<string>();
@@ -357,163 +357,163 @@ namespace SabreTools
if (temparg.StartsWith("-ae=") || temparg.StartsWith("--add-ext=")) if (temparg.StartsWith("-ae=") || temparg.StartsWith("--add-ext="))
{ {
addext = temparg.Split('=')[1]; addext = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-au=") || temparg.StartsWith("--author=")) else if (temparg.StartsWith("-au=") || temparg.StartsWith("--author="))
{ {
author = temparg.Split('=')[1]; author = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-ca=") || temparg.StartsWith("--category=")) else if (temparg.StartsWith("-ca=") || temparg.StartsWith("--category="))
{ {
category = temparg.Split('=')[1]; category = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-co=") || temparg.StartsWith("--comment=")) else if (temparg.StartsWith("-co=") || temparg.StartsWith("--comment="))
{ {
comment = temparg.Split('=')[1]; comment = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-com=") || temparg.StartsWith("--com=")) else if (temparg.StartsWith("-com=") || temparg.StartsWith("--com="))
{ {
currentAllMerged = temparg.Split('=')[1]; currentAllMerged = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-crc=") || temparg.StartsWith("--crc=")) else if (temparg.StartsWith("-crc=") || temparg.StartsWith("--crc="))
{ {
crc = temparg.Split('=')[1]; crc = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-da=") || temparg.StartsWith("--date=")) else if (temparg.StartsWith("-da=") || temparg.StartsWith("--date="))
{ {
date = temparg.Split('=')[1]; date = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-de=") || temparg.StartsWith("--desc=")) else if (temparg.StartsWith("-de=") || temparg.StartsWith("--desc="))
{ {
description = temparg.Split('=')[1]; description = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-em=") || temparg.StartsWith("--email=")) else if (temparg.StartsWith("-em=") || temparg.StartsWith("--email="))
{ {
email = temparg.Split('=')[1]; email = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-exta=")) else if (temparg.StartsWith("-exta="))
{ {
exta = temparg.Split('=')[1]; exta = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-extb=")) else if (temparg.StartsWith("-extb="))
{ {
extb = temparg.Split('=')[1]; extb = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-f=") || temparg.StartsWith("--filename=")) else if (temparg.StartsWith("-f=") || temparg.StartsWith("--filename="))
{ {
filename = temparg.Split('=')[1]; filename = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-fix=") || temparg.StartsWith("--fix=")) else if (temparg.StartsWith("-fix=") || temparg.StartsWith("--fix="))
{ {
currentMissingMerged = temparg.Split('=')[1]; currentMissingMerged = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-fm=") || temparg.StartsWith("--forcemerge=")) else if (temparg.StartsWith("-fm=") || temparg.StartsWith("--forcemerge="))
{ {
forcemerge = temparg.Split('=')[1]; forcemerge = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-fn=") || temparg.StartsWith("--forcend=")) else if (temparg.StartsWith("-fn=") || temparg.StartsWith("--forcend="))
{ {
forcend = temparg.Split('=')[1]; forcend = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-fp=") || temparg.StartsWith("--forcepack=")) 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=")) 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=")) else if (temparg.StartsWith("-h=") || temparg.StartsWith("--header="))
{ {
header = temparg.Split('=')[1]; header = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-hp=") || temparg.StartsWith("--homepage=")) else if (temparg.StartsWith("-hp=") || temparg.StartsWith("--homepage="))
{ {
homepage = temparg.Split('=')[1]; homepage = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-input=")) else if (temparg.StartsWith("-input="))
{ {
inputs.Add(temparg.Split('=')[1]); inputs.Add(temparg.Split('=')[1] ?? "");
} }
else if (temparg.StartsWith("-is=") || temparg.StartsWith("--status=")) else if (temparg.StartsWith("-is=") || temparg.StartsWith("--status="))
{ {
status = temparg.Split('=')[1]; status = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-md5=") || temparg.StartsWith("--md5=")) else if (temparg.StartsWith("-md5=") || temparg.StartsWith("--md5="))
{ {
md5 = temparg.Split('=')[1]; md5 = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-mt=") || temparg.StartsWith("--mt=")) 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=")) else if (temparg.StartsWith("-n=") || temparg.StartsWith("--name="))
{ {
name = temparg.Split('=')[1]; name = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-new=") || temparg.StartsWith("--new=")) else if (temparg.StartsWith("-new=") || temparg.StartsWith("--new="))
{ {
currentNewMerged = temparg.Split('=')[1]; currentNewMerged = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-out=") || temparg.StartsWith("--out=")) else if (temparg.StartsWith("-out=") || temparg.StartsWith("--out="))
{ {
outDir = temparg.Split('=')[1]; outDir = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-post=") || temparg.StartsWith("--postfix=")) else if (temparg.StartsWith("-post=") || temparg.StartsWith("--postfix="))
{ {
postfix = temparg.Split('=')[1]; postfix = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-pre=") || temparg.StartsWith("--prefix=")) else if (temparg.StartsWith("-pre=") || temparg.StartsWith("--prefix="))
{ {
prefix = temparg.Split('=')[1]; prefix = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-r=") || temparg.StartsWith("--root=")) 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=")) 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=")) 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=")) 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=")) 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=")) 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=")) 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=")) else if (temparg.StartsWith("-sha1=") || temparg.StartsWith("--sha1="))
{ {
sha1 = temparg.Split('=')[1]; sha1 = temparg.Split('=')[1] ?? "";
} }
else if (temparg.StartsWith("-slt=") || temparg.StartsWith("--less=")) 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=")) 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=")) 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=")) else if (temparg.StartsWith("-v=") || temparg.StartsWith("--version="))
{ {
version = temparg.Split('=')[1]; version = temparg.Split('=')[1] ?? "";
} }
else if (File.Exists(temparg) || Directory.Exists(temparg)) else if (File.Exists(temparg) || Directory.Exists(temparg))
{ {