[SabreTools, DatFile, Enums, Flags] Overhaul splitting

This commit is contained in:
Matt Nadareski
2017-11-08 16:29:35 -08:00
parent e3461177ce
commit 6df461b2e9
6 changed files with 248 additions and 315 deletions

View File

@@ -4762,20 +4762,21 @@ namespace SabreTools.Library.DatFiles
outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true); outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
// Split and write the DAT // Split and write the DAT
switch (splitType) if ((splitType & ExternalSplitType.Extension) != 0)
{ {
case ExternalSplitType.Extension: SplitByExtension(outDir, inplace, exta, extb);
SplitByExtension(outDir, inplace, exta, extb); }
break; if ((splitType & ExternalSplitType.Hash) != 0)
case ExternalSplitType.Hash: {
SplitByHash(outDir, inplace); SplitByHash(outDir, inplace);
break; }
case ExternalSplitType.Level: if ((splitType & ExternalSplitType.Level) != 0)
SplitByLevel(outDir, inplace, shortname, basedat); {
break; SplitByLevel(outDir, inplace, shortname, basedat);
case ExternalSplitType.Type: }
SplitByType(outDir, inplace); if ((splitType & ExternalSplitType.Type) != 0)
break; {
SplitByType(outDir, inplace);
} }
// Now re-empty the DAT to make room for the next one // Now re-empty the DAT to make room for the next one

View File

@@ -258,18 +258,6 @@
SHA512, SHA512,
} }
/// <summary>
/// Determines how the DAT will be split on output
/// </summary>
public enum ExternalSplitType
{
None = 0,
Extension,
Hash,
Level,
Type,
}
/// <summary> /// <summary>
/// Determines forcemerging tag for DAT output /// Determines forcemerging tag for DAT output
/// </summary> /// </summary>

View File

@@ -222,6 +222,20 @@ namespace SabreTools.Library.Data
ALL = 0xFFFFFFF, ALL = 0xFFFFFFF,
} }
/// <summary>
/// Determines how the DAT will be split on output
/// </summary>
[Flags]
public enum ExternalSplitType
{
None = 0x0,
Extension = 0x01,
Hash = Extension << 1,
Level = Hash << 1,
Type = Level << 1,
}
/// <summary> /// <summary>
/// Determine what hashes to strip from the DAT /// Determine what hashes to strip from the DAT
/// </summary> /// </summary>

View File

@@ -365,30 +365,6 @@ Options:
created. If the user specifies that only 1 thread is to be used, it created. If the user specifies that only 1 thread is to be used, it
defaults to the original, serial implementation of the DFD code. defaults to the original, serial implementation of the DFD code.
-es, --ext-split Split a DAT by two file extensions
For a DAT, or set of DATs, allow for splitting based on a list of input
extensions. This can allow for combined DAT files, such as those
combining two separate systems, to be split. Files with any extensions
not listed in the input lists will be included in both outputted DAT
files.
-exta= First extension (multiple allowed)
Set the extensions to be used to populate the first DAT. If more
than one extension is defined, they must be placed in separate flags
-extb= Second extension (multiple allowed)
Set the extensions to be used to populate the second DAT. If more
than one extension is defined, they must be placed in separate flags
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead.
-ip, --inplace Write to the input directories
This will write out the split files to the source folder instead of
writing them out to the runtime folder by default (or the output
folder if overridden).
-ex, --extract Backup and remove copier headers -ex, --extract Backup and remove copier headers
This will detect, store, and remove copier headers from a file or folder This will detect, store, and remove copier headers from a file or folder
of files. The headers are backed up and collated by the hash of the of files. The headers are backed up and collated by the hash of the
@@ -414,56 +390,6 @@ Options:
By default, all headers that are removed from files are backed up in By default, all headers that are removed from files are backed up in
the database. This flag allows users to skip that step entirely, the database. This flag allows users to skip that step entirely,
avoiding caching the headers at all. avoiding caching the headers at all.
-hs, --hash-split Split a DAT or folder by best-available hashes
For a DAT, or set of DATs, allow for splitting based on the best
available hash for each file within. The order of preference for the
outputted DATs is as follows:
- Nodump
- SHA-512 available
- SHA-386 available
- SHA-256 available
- SHA-1 available
- MD5 available
- CRC or worse available
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead.
-ip, --inplace Write to the input directories
This will write out the split files to the source folder instead of
writing them out to the runtime folder by default (or the output
folder if overridden).
-ls, --lvl-split Split a SuperDAT or folder by lowest available level
For a DAT, or set of DATs, allow for splitting based on the lowest
available level of game name. That is, if a game name is top/mid/last,
then it will create an output DAT for the parent directory "mid" in a
folder called "top" with a game called "last".
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead.
-ip, --inplace Write to the input directories
This will write out the split files to the source folder instead of
writing them out to the runtime folder by default (or the output
folder if overridden).
-s, --short Use short names for outputted DATs
Instead of using ClrMamePro-style long names for DATs, use just the
name of the folder as the name of the DAT. This can be used in
conjunction with --base to output in the format of "Original Name
(Name)" instead.
-ba, --base Use source DAT as base name for outputs
If splitting an entire folder of DATs, some output files may be
normally overwritten since the names would be the same. With this
flag, the original DAT name is used in the output name, in the
format of "Original Name (Dir - Name)". This can be used in
conjunction with --short to output in the format of "Original Name
(Name)" instead.
-re, --restore Restore copier headers from a variety of file types -re, --restore Restore copier headers from a variety of file types
This will make use of stored copier headers and reapply them to files if This will make use of stored copier headers and reapply them to files if
@@ -484,6 +410,73 @@ Options:
-out= Set the name of the output directory -out= Set the name of the output directory
This sets an output folder to be used when the files are created. If This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead. a path is not defined, the application directory is used instead.
-sp, --split Split input DATs by a given criteria
This feature allows the user to split input DATs by a number of different
possible criteria. See the individual input information for details. More
than one split type is allowed at a time.
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead.
-ip, --inplace Write to the input directories
This will write out the split files to the source folder instead of
writing them out to the runtime folder by default (or the output
folder if overridden).
-es, --ext Split a DAT by two file extensions
For a DAT, or set of DATs, allow for splitting based on a list of
input extensions. This can allow for combined DAT files, such as
those combining two separate systems, to be split. Files with any
extensions not listed in the input lists will be included in both
outputted DAT files.
-exta= First extension (multiple allowed)
Set the extensions to be used to populate the first DAT. If more
than one extension is defined, they must be placed in separate
flags
-extb= Second extension (multiple allowed)
Set the extensions to be used to populate the second DAT. If
more than one extension is defined, they must be placed in
separate flags
-hs, --hash Split a DAT or folder by best-available hashes
For a DAT, or set of DATs, allow for splitting based on the best
available hash for each file within. The order of preference for the
outputted DATs is as follows:
- Nodump
- SHA-512 available
- SHA-386 available
- SHA-256 available
- SHA-1 available
- MD5 available
- CRC or worse available
-ls, --level Split a SuperDAT or folder by lowest available level
For a DAT, or set of DATs, allow for splitting based on the lowest
available level of game name. That is, if a game name is top/mid/
last, then it will create an output DAT for the parent directory
"mid" in a folder called "top" with a game called "last".
-s, --short Use short names for outputted DATs
Instead of using ClrMamePro-style long names for DATs, use just
the name of the folder as the name of the DAT. This can be used
in conjunction with --base to output in the format of "Original
Name (Name)" instead.
-ba, --base Use source DAT as base name for outputs
If splitting an entire folder of DATs, some output files may be
normally overwritten since the names would be the same. With
this flag, the original DAT name is used in the output name, in
the format of "Original Name (Dir - Name)". This can be used in
conjunction with --short to output in the format of "Original
Name (Name)" instead.
-ts, --type Split DAT(s) or folder by file types (rom/disk)
For a DAT, or set of DATs, allow for splitting based on the types of
the files, specifically if the type is a rom or a disk.
-ss, --sort Sort input files by a set of DATs -ss, --sort Sort input files by a set of DATs
This feature allows the user to quickly rebuild based on a supplied DAT This feature allows the user to quickly rebuild based on a supplied DAT
@@ -718,19 +711,6 @@ Options:
-txt, --text Output in generic text format -txt, --text Output in generic text format
Output all rom information in generic text format. If no other format Output all rom information in generic text format. If no other format
flags are enabled, this is the default output. flags are enabled, this is the default output.
-ts, --type-split Split DAT(s) or folder by file types (rom/disk)
For a DAT, or set of DATs, allow for splitting based on the types of the
files, specifically if the type is a rom or a disk.
-out= Set the name of the output directory
This sets an output folder to be used when the files are created. If
a path is not defined, the application directory is used instead.
-ip, --inplace Write to the input directories
This will write out the split files to the source folder instead of
writing them out to the runtime folder by default (or the output
folder if overridden).
-ud, --update Update and manipulate DAT(s) -ud, --update Update and manipulate DAT(s)
This is the multitool part of the program, allowing for almost every This is the multitool part of the program, allowing for almost every

View File

@@ -318,77 +318,6 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
null)); null));
// Create the Extension Split feature
Feature extSplit = new Feature(
new List<string>() { "-es", "--ext-split" },
"Split DAT(s) by two file extensions",
FeatureType.Flag,
null);
extSplit.AddFeature("exta", new Feature(
new List<string>() { "-exta", "--exta" },
"First extension (multiple allowed)",
FeatureType.List,
null));
extSplit.AddFeature("extb", new Feature(
new List<string>() { "-extb", "--extb" },
"Second extension (multiple allowed)",
FeatureType.List,
null));
extSplit.AddFeature("out", new Feature(
new List<string>() { "-out", "--out" },
"Output directory",
FeatureType.String,
null));
extSplit.AddFeature("inplace", new Feature(
new List<string>() { "-ip", "--inplace" },
"Write to the input directories",
FeatureType.Flag,
null));
// Create the Hash Split feature
Feature hashSplit = new Feature(
new List<string>() { "-hs", "--hash-split" },
"Split DAT(s) or folder by best-available hashes",
FeatureType.Flag,
null);
hashSplit.AddFeature("out", new Feature(
new List<string>() { "-out", "--out" },
"Output directory",
FeatureType.String,
null));
hashSplit.AddFeature("inplace", new Feature(
new List<string>() { "-ip", "--inplace" },
"Write to the input directories",
FeatureType.Flag,
null));
// Create the Level Split feature
Feature levelSplit = new Feature(
new List<string>() { "-ls", "--lvl-split" },
"Split a SuperDAT or folder by internal path",
FeatureType.Flag,
null);
levelSplit.AddFeature("out", new Feature(
new List<string>() { "-out", "--out" },
"Output directory",
FeatureType.String,
null));
levelSplit.AddFeature("inplace", new Feature(
new List<string>() { "-ip", "--inplace" },
"Write to the input directories",
FeatureType.Flag,
null));
levelSplit.AddFeature("short", new Feature(
new List<string>() { "-s", "--short" },
"Use short output names",
FeatureType.Flag,
null));
levelSplit.AddFeature("base", new Feature(
new List<string>() { "-ba", "--base" },
"Use source DAT as base name for outputs",
FeatureType.Flag,
null));
// Create the Restore feature // Create the Restore feature
Feature restore = new Feature( Feature restore = new Feature(
new List<string>() { "-re", "--restore" }, new List<string>() { "-re", "--restore" },
@@ -580,7 +509,64 @@ namespace SabreTools
new List<string>() { "-mt", "--mt" }, new List<string>() { "-mt", "--mt" },
"Amount of threads to use (default 4, -1 unlimted)", "Amount of threads to use (default 4, -1 unlimted)",
FeatureType.String, FeatureType.String,
null)); null));
// Create the Split feature
Feature split = new Feature(
new List<string>() { "-sp", "--split" },
"Split input DATs by a given criteria",
FeatureType.Flag,
null);
split.AddFeature("out", new Feature(
new List<string>() { "-out", "--out" },
"Output directory",
FeatureType.String,
null));
split.AddFeature("inplace", new Feature(
new List<string>() { "-ip", "--inplace" },
"Write to the input directories",
FeatureType.Flag,
null));
split.AddFeature("ext", new Feature(
new List<string>() { "-es", "--ext" },
"Split DAT(s) by two file extensions",
FeatureType.Flag,
null));
split["ext"].AddFeature("exta", new Feature(
new List<string>() { "-exta", "--exta" },
"First extension (multiple allowed)",
FeatureType.List,
null));
split["ext"].AddFeature("extb", new Feature(
new List<string>() { "-extb", "--extb" },
"Second extension (multiple allowed)",
FeatureType.List,
null));
split.AddFeature("hash", new Feature(
new List<string>() { "-hs", "--hash" },
"Split DAT(s) or folder by best-available hashes",
FeatureType.Flag,
null));
split.AddFeature("level", new Feature(
new List<string>() { "-ls", "--level" },
"Split a SuperDAT or folder by internal path",
FeatureType.Flag,
null));
split["level"].AddFeature("short", new Feature(
new List<string>() { "-s", "--short" },
"Use short output names",
FeatureType.Flag,
null));
split["level"].AddFeature("base", new Feature(
new List<string>() { "-ba", "--base" },
"Use source DAT as base name for outputs",
FeatureType.Flag,
null));
split.AddFeature("type", new Feature(
new List<string>() { "-ts", "--type" },
"Split DAT(s) or folder by file types (rom/disk)",
FeatureType.Flag,
null));
// Create the Stats feature // Create the Stats feature
Feature stats = new Feature( Feature stats = new Feature(
@@ -639,23 +625,6 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
null)); null));
// Create the Type Split feature
Feature typeSplit = new Feature(
new List<string>() { "-ts", "--type-split" },
"Split DAT(s) or folder by file types (rom/disk)",
FeatureType.Flag,
null);
typeSplit.AddFeature("out", new Feature(
new List<string>() { "-out", "--out" },
"Output directory",
FeatureType.String,
null));
typeSplit.AddFeature("inplace", new Feature(
new List<string>() { "-ip", "--inplace" },
"Write to the input directories",
FeatureType.Flag,
null));
// Create the Update feature // Create the Update feature
Feature update = new Feature( Feature update = new Feature(
new List<string>() { "-ud", "--update" }, new List<string>() { "-ud", "--update" },
@@ -1431,13 +1400,10 @@ namespace SabreTools
help.Add("Script", script); help.Add("Script", script);
help.Add("DATFromDir", datFromDir); help.Add("DATFromDir", datFromDir);
help.Add("Extract", extract); help.Add("Extract", extract);
help.Add("Extension Split", extSplit);
help.Add("Hash Split", hashSplit);
help.Add("Level Split", levelSplit);
help.Add("Restore", restore); help.Add("Restore", restore);
help.Add("Sort", sort); help.Add("Sort", sort);
help.Add("Split", split);
help.Add("Stats", stats); help.Add("Stats", stats);
help.Add("Type Split", typeSplit);
help.Add("Update", update); help.Add("Update", update);
help.Add("Verify", verify); help.Add("Verify", verify);

View File

@@ -77,10 +77,7 @@ namespace SabreTools
extract = false, extract = false,
restore = false, restore = false,
sort = false, sort = false,
splitByExt = false, split = false,
splitByHash = false,
splitByLevel = false,
splitByType = false,
stats = false, stats = false,
update = false, update = false,
verify = false; verify = false;
@@ -122,6 +119,7 @@ namespace SabreTools
usegame = true; usegame = true;
DatFormat datFormat = 0x0; DatFormat datFormat = 0x0;
DedupeType dedup = DedupeType.None; DedupeType dedup = DedupeType.None;
ExternalSplitType externalSplitType = ExternalSplitType.None;
Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
Hash stripHash = 0x0; Hash stripHash = 0x0;
OutputFormat outputFormat = OutputFormat.Folder; OutputFormat outputFormat = OutputFormat.Folder;
@@ -199,22 +197,10 @@ namespace SabreTools
case "--dfd": case "--dfd":
datFromDir = true; datFromDir = true;
break; break;
case "-es":
case "--ext-split":
splitByExt = true;
break;
case "-ex": case "-ex":
case "--extract": case "--extract":
extract = true; extract = true;
break; break;
case "-hs":
case "--hash-split":
splitByHash = true;
break;
case "-ls":
case "--lvl-split":
splitByLevel = true;
break;
case "-re": case "-re":
case "--restore": case "--restore":
restore = true; restore = true;
@@ -222,6 +208,10 @@ namespace SabreTools
case "--script": case "--script":
// No-op for script mode, allowing for retaining the screen // No-op for script mode, allowing for retaining the screen
break; break;
case "-sp":
case "--split":
split = true;
break;
case "-ss": case "-ss":
case "--sort": case "--sort":
sort = true; sort = true;
@@ -230,10 +220,6 @@ namespace SabreTools
case "--stats": case "--stats":
stats = true; stats = true;
break; break;
case "-ts":
case "--type-split":
splitByType = true;
break;
case "-ud": case "-ud":
case "--update": case "--update":
update = true; update = true;
@@ -372,6 +358,10 @@ namespace SabreTools
case "--dat-split": case "--dat-split":
splitType = SplitType.Split; splitType = SplitType.Split;
break; break;
case "-es":
case "--ext":
externalSplitType |= ExternalSplitType.Extension;
break;
case "-f": case "-f":
case "--files": case "--files":
archivesAsFiles = true; archivesAsFiles = true;
@@ -392,6 +382,10 @@ namespace SabreTools
case "--html": case "--html":
statDatFormat |= StatReportFormat.HTML; statDatFormat |= StatReportFormat.HTML;
break; break;
case "-hs":
case "--hash":
externalSplitType |= ExternalSplitType.Hash;
break;
case "-ic": case "-ic":
case "--ignore-chd": case "--ignore-chd":
chdsAsFiles = true; chdsAsFiles = true;
@@ -404,6 +398,10 @@ namespace SabreTools
case "--inplace": case "--inplace":
inplace = true; inplace = true;
break; break;
case "-ls":
case "--level":
externalSplitType |= ExternalSplitType.Level;
break;
case "-m": case "-m":
case "--merge": case "--merge":
merge = true; merge = true;
@@ -628,6 +626,10 @@ namespace SabreTools
case "--trim": case "--trim":
trim = true; trim = true;
break; break;
case "-ts":
case "--type":
externalSplitType |= ExternalSplitType.Type;
break;
case "-tsv": case "-tsv":
case "--tsv": case "--tsv":
statDatFormat |= StatReportFormat.TSV; statDatFormat |= StatReportFormat.TSV;
@@ -939,132 +941,132 @@ namespace SabreTools
if (temparg.StartsWith("-") && temparg.Contains("=")) if (temparg.StartsWith("-") && temparg.Contains("="))
{ {
// Split the argument // Split the argument
string[] split = temparg.Split('='); string[] argsplit = temparg.Split('=');
// If we have a null second argument, we set it to be a blank // If we have a null second argument, we set it to be a blank
if (split[1] == null) if (argsplit[1] == null)
{ {
split[1] = ""; argsplit[1] = "";
} }
// If we have more than 2 items in the split, we want to combine the other parts again // If we have more than 2 items in the split, we want to combine the other parts again
else if (split.Length > 2) else if (argsplit.Length > 2)
{ {
split[1] = string.Join("=", split.Skip(1)); argsplit[1] = string.Join("=", argsplit.Skip(1));
} }
switch (split[0]) switch (argsplit[0])
{ {
case "-7z": case "-7z":
case "--7z": case "--7z":
if (!Int32.TryParse(split[1], out sevenzip)) if (!Int32.TryParse(argsplit[1], out sevenzip))
{ {
sevenzip = 1; sevenzip = 1;
} }
break; break;
case "-ae": case "-ae":
case "--add-ext": case "--add-ext":
addext = split[1]; addext = argsplit[1];
break; break;
case "-au": case "-au":
case "--author": case "--author":
author = split[1]; author = argsplit[1];
break; break;
case "-bd": case "-bd":
case "--base-dat": case "--base-dat":
basePaths.Add(split[1]); basePaths.Add(argsplit[1]);
break; break;
case "-ca": case "-ca":
case "--category=": case "--category=":
category = split[1]; category = argsplit[1];
break; break;
case "-co": case "-co":
case "--comment": case "--comment":
comment = split[1]; comment = argsplit[1];
break; break;
case "-crc": case "-crc":
case "--crc": case "--crc":
filter.CRCs.Add(split[1]); filter.CRCs.Add(argsplit[1]);
break; break;
case "-da": case "-da":
case "--date": case "--date":
date = split[1]; date = argsplit[1];
break; break;
case "-dat": case "-dat":
case "--dat": case "--dat":
if (!File.Exists(split[1]) && !Directory.Exists(split[1])) if (!File.Exists(argsplit[1]) && !Directory.Exists(argsplit[1]))
{ {
Globals.Logger.Error("Must be a valid file or folder of DATs: {0}", split[1]); Globals.Logger.Error("Must be a valid file or folder of DATs: {0}", argsplit[1]);
Globals.Logger.Close(); Globals.Logger.Close();
return; return;
} }
datfiles.Add(split[1]); datfiles.Add(argsplit[1]);
break; break;
case "-de": case "-de":
case "--desc": case "--desc":
description = split[1]; description = argsplit[1];
break; break;
case "-em": case "-em":
case "--email": case "--email":
email = split[1]; email = argsplit[1];
break; break;
case "-exta": case "-exta":
case "--exta": case "--exta":
exta.Add(split[1]); exta.Add(argsplit[1]);
break; break;
case "-extb": case "-extb":
case "--extb": case "--extb":
extb.Add(split[1]); extb.Add(argsplit[1]);
break; break;
case "-f": case "-f":
case "--filename": case "--filename":
filename = split[1]; filename = argsplit[1];
break; break;
case "-fm": case "-fm":
case "--forcemerge": case "--forcemerge":
forcemerge = split[1]; forcemerge = argsplit[1];
break; break;
case "-fn": case "-fn":
case "--forcend": case "--forcend":
forcend = split[1]; forcend = argsplit[1];
break; break;
case "-fp": case "-fp":
case "--forcepack": case "--forcepack":
forcepack = split[1]; forcepack = argsplit[1];
break; break;
case "-gn": case "-gn":
case "--game-name": case "--game-name":
filter.GameNames.Add(split[1]); filter.GameNames.Add(argsplit[1]);
break; break;
case "-gt": case "-gt":
case "--game-type": case "--game-type":
filter.MachineTypes |= Filter.GetMachineTypeFromString(split[1]); filter.MachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
break; break;
case "-gz": case "-gz":
case "--gz": case "--gz":
if (!Int32.TryParse(split[1], out gz)) if (!Int32.TryParse(argsplit[1], out gz))
{ {
gz = 2; gz = 2;
} }
break; break;
case "-h": case "-h":
case "--header": case "--header":
header = split[1]; header = argsplit[1];
break; break;
case "-hp": case "-hp":
case "--homepage": case "--homepage":
homepage = split[1]; homepage = argsplit[1];
break; break;
case "-is": case "-is":
case "--status": case "--status":
filter.ItemStatuses |= Filter.GetStatusFromString(split[1]); filter.ItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
break; break;
case "-md5": case "-md5":
case "--md5": case "--md5":
filter.MD5s.Add(split[1]); filter.MD5s.Add(argsplit[1]);
break; break;
case "-mt": case "-mt":
case "--mt": case "--mt":
if (Int32.TryParse(split[1], out int odop)) if (Int32.TryParse(argsplit[1], out int odop))
{ {
Globals.MaxThreads = odop; Globals.MaxThreads = odop;
} }
@@ -1075,139 +1077,139 @@ namespace SabreTools
break; break;
case "-n": case "-n":
case "--name": case "--name":
name = split[1]; name = argsplit[1];
break; break;
case "-ncrc": case "-ncrc":
case "--not-crc": case "--not-crc":
filter.NotCRCs.Add(split[i]); filter.NotCRCs.Add(argsplit[i]);
break; break;
case "-ngn": case "-ngn":
case "--not-game": case "--not-game":
filter.NotGameNames.Add(split[1]); filter.NotGameNames.Add(argsplit[1]);
break; break;
case "-ngt": case "-ngt":
case "--not-gtype": case "--not-gtype":
filter.NotMachineTypes |= Filter.GetMachineTypeFromString(split[1]); filter.NotMachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
break; break;
case "-nis": case "-nis":
case "--not-status": case "--not-status":
filter.NotItemStatuses |= Filter.GetStatusFromString(split[1]); filter.NotItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
break; break;
case "-nmd5": case "-nmd5":
case "--not-md5": case "--not-md5":
filter.NotMD5s.Add(split[1]); filter.NotMD5s.Add(argsplit[1]);
break; break;
case "-nrn": case "-nrn":
case "--not-rom": case "--not-rom":
filter.NotRomNames.Add(split[1]); filter.NotRomNames.Add(argsplit[1]);
break; break;
case "-nrt": case "-nrt":
case "--not-type": case "--not-type":
filter.NotRomTypes.Add(split[1]); filter.NotRomTypes.Add(argsplit[1]);
break; break;
case "-nsha1": case "-nsha1":
case "--not-sha1": case "--not-sha1":
filter.NotSHA1s.Add(split[1]); filter.NotSHA1s.Add(argsplit[1]);
break; break;
case "-nsha256": case "-nsha256":
case "--not-sha256": case "--not-sha256":
filter.NotSHA256s.Add(split[1]); filter.NotSHA256s.Add(argsplit[1]);
break; break;
case "-nsha384": case "-nsha384":
case "--not-sha384": case "--not-sha384":
filter.NotSHA384s.Add(split[1]); filter.NotSHA384s.Add(argsplit[1]);
break; break;
case "-nsha512": case "-nsha512":
case "--not-sha512": case "--not-sha512":
filter.NotSHA512s.Add(split[1]); filter.NotSHA512s.Add(argsplit[1]);
break; break;
case "-out": case "-out":
case "--out": case "--out":
outDir = split[1]; outDir = argsplit[1];
break; break;
case "-post": case "-post":
case "--postfix": case "--postfix":
postfix = split[1]; postfix = argsplit[1];
break; break;
case "-pre": case "-pre":
case "--prefix": case "--prefix":
prefix = split[1]; prefix = argsplit[1];
break; break;
case "-r": case "-r":
case "--root": case "--root":
rootdir = split[1]; rootdir = argsplit[1];
break; break;
case "-rar": case "-rar":
case "--rar": case "--rar":
if (!Int32.TryParse(split[1], out rar)) if (!Int32.TryParse(argsplit[1], out rar))
{ {
rar = 2; rar = 2;
} }
break; break;
case "-rd": case "-rd":
case "--root-dir": case "--root-dir":
root = split[1]; root = argsplit[1];
break; break;
case "-reg": case "-reg":
case "--region": case "--region":
regions.Add(split[1]); regions.Add(argsplit[1]);
break; break;
case "-rep": case "-rep":
case "--rep-ext": case "--rep-ext":
repext = split[1]; repext = argsplit[1];
break; break;
case "-rn": case "-rn":
case "--rom-name": case "--rom-name":
filter.RomNames.Add(split[1]); filter.RomNames.Add(argsplit[1]);
break; break;
case "-rt": case "-rt":
case "--rom-type": case "--rom-type":
filter.RomTypes.Add(split[1]); filter.RomTypes.Add(argsplit[1]);
break; break;
case "-seq": case "-seq":
case "--equal": case "--equal":
filter.SizeEqualTo = Utilities.GetSizeFromString(split[1]); filter.SizeEqualTo = Utilities.GetSizeFromString(argsplit[1]);
break; break;
case "-sgt": case "-sgt":
case "--greater": case "--greater":
filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString(split[1]); filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString(argsplit[1]);
break; break;
case "-sha1": case "-sha1":
case "--sha1": case "--sha1":
filter.SHA1s.Add(split[1]); filter.SHA1s.Add(argsplit[1]);
break; break;
case "-sha256": case "-sha256":
case "--sha256": case "--sha256":
filter.SHA256s.Add(split[1]); filter.SHA256s.Add(argsplit[1]);
break; break;
case "-sha384": case "-sha384":
case "--sha384": case "--sha384":
filter.SHA384s.Add(split[1]); filter.SHA384s.Add(argsplit[1]);
break; break;
case "-sha512": case "-sha512":
case "--sha512": case "--sha512":
filter.SHA512s.Add(split[1]); filter.SHA512s.Add(argsplit[1]);
break; break;
case "-slt": case "-slt":
case "--less": case "--less":
filter.SizeLessThanOrEqual = Utilities.GetSizeFromString(split[1]); filter.SizeLessThanOrEqual = Utilities.GetSizeFromString(argsplit[1]);
break; break;
case "-t": case "-t":
case "--temp": case "--temp":
tempDir = split[1]; tempDir = argsplit[1];
break; break;
case "-u": case "-u":
case "-url": case "-url":
case "--url": case "--url":
url = split[1]; url = argsplit[1];
break; break;
case "-v": case "-v":
case "--version": case "--version":
version = split[1]; version = argsplit[1];
break; break;
case "-zip": case "-zip":
case "--zip": case "--zip":
if (!Int32.TryParse(split[1], out zip)) if (!Int32.TryParse(argsplit[1], out zip))
{ {
zip = 1; zip = 1;
} }
@@ -1241,7 +1243,7 @@ namespace SabreTools
} }
// If none of the feature flags is enabled, show the help screen // If none of the feature flags is enabled, show the help screen
if (!(datFromDir | extract | restore | sort | splitByExt | splitByHash | splitByLevel | splitByType | stats | update | verify)) if (!(datFromDir | extract | restore | sort | split | stats | update | verify))
{ {
Globals.Logger.Error("At least one feature switch must be enabled"); Globals.Logger.Error("At least one feature switch must be enabled");
_help.OutputGenericHelp(); _help.OutputGenericHelp();
@@ -1250,7 +1252,7 @@ namespace SabreTools
} }
// If more than one switch is enabled, show the help screen // If more than one switch is enabled, show the help screen
if (!(datFromDir ^ extract ^ restore ^ sort ^ splitByExt ^ splitByHash ^ splitByLevel ^ splitByType ^ stats ^ update ^ verify)) if (!(datFromDir ^ extract ^ restore ^ sort ^ split ^ stats ^ update ^ verify))
{ {
Globals.Logger.Error("Only one feature switch is allowed at a time"); Globals.Logger.Error("Only one feature switch is allowed at a time");
_help.OutputGenericHelp(); _help.OutputGenericHelp();
@@ -1260,7 +1262,7 @@ namespace SabreTools
// If a switch that requires a filename is set and no file is, show the help screen // If a switch that requires a filename is set and no file is, show the help screen
if (inputs.Count == 0 if (inputs.Count == 0
&& (datFromDir || extract || restore || splitByExt || splitByHash || splitByLevel || splitByType || stats || update || verify)) && (datFromDir || extract || restore || split || stats || update || verify))
{ {
Globals.Logger.Error("This feature requires at least one input"); Globals.Logger.Error("This feature requires at least one input");
_help.OutputIndividualFeature(feature); _help.OutputIndividualFeature(feature);
@@ -1297,28 +1299,10 @@ namespace SabreTools
outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, splitType, chdsAsFiles); outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, splitType, chdsAsFiles);
} }
// Split a DAT by extension // Split a DAT by the split type
else if (splitByExt) else if (split)
{ {
InitSplit(inputs, outDir, inplace, ExternalSplitType.Extension, exta, extb, shortname, basedat); InitSplit(inputs, outDir, inplace, externalSplitType, exta, extb, shortname, basedat);
}
// Split a DAT by available hashes
else if (splitByHash)
{
InitSplit(inputs, outDir, inplace, ExternalSplitType.Hash, exta, extb, shortname, basedat);
}
// Split a SuperDAT by lowest available level
else if (splitByLevel)
{
InitSplit(inputs, outDir, inplace, ExternalSplitType.Level, exta, extb, shortname, basedat);
}
// Split a DAT by item type
else if (splitByType)
{
InitSplit(inputs, outDir, inplace, ExternalSplitType.Type, exta, extb, shortname, basedat);
} }
// Get statistics on input files // Get statistics on input files