mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatFile, Enums, Flags] Overhaul splitting
This commit is contained in:
@@ -4762,20 +4762,21 @@ namespace SabreTools.Library.DatFiles
|
||||
outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
|
||||
|
||||
// Split and write the DAT
|
||||
switch (splitType)
|
||||
if ((splitType & ExternalSplitType.Extension) != 0)
|
||||
{
|
||||
case ExternalSplitType.Extension:
|
||||
SplitByExtension(outDir, inplace, exta, extb);
|
||||
break;
|
||||
case ExternalSplitType.Hash:
|
||||
}
|
||||
if ((splitType & ExternalSplitType.Hash) != 0)
|
||||
{
|
||||
SplitByHash(outDir, inplace);
|
||||
break;
|
||||
case ExternalSplitType.Level:
|
||||
}
|
||||
if ((splitType & ExternalSplitType.Level) != 0)
|
||||
{
|
||||
SplitByLevel(outDir, inplace, shortname, basedat);
|
||||
break;
|
||||
case ExternalSplitType.Type:
|
||||
}
|
||||
if ((splitType & ExternalSplitType.Type) != 0)
|
||||
{
|
||||
SplitByType(outDir, inplace);
|
||||
break;
|
||||
}
|
||||
|
||||
// Now re-empty the DAT to make room for the next one
|
||||
|
||||
@@ -258,18 +258,6 @@
|
||||
SHA512,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines how the DAT will be split on output
|
||||
/// </summary>
|
||||
public enum ExternalSplitType
|
||||
{
|
||||
None = 0,
|
||||
Extension,
|
||||
Hash,
|
||||
Level,
|
||||
Type,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines forcemerging tag for DAT output
|
||||
/// </summary>
|
||||
|
||||
@@ -222,6 +222,20 @@ namespace SabreTools.Library.Data
|
||||
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>
|
||||
/// Determine what hashes to strip from the DAT
|
||||
/// </summary>
|
||||
|
||||
@@ -365,30 +365,6 @@ Options:
|
||||
created. If the user specifies that only 1 thread is to be used, it
|
||||
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
|
||||
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
|
||||
@@ -415,56 +391,6 @@ Options:
|
||||
the database. This flag allows users to skip that step entirely,
|
||||
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
|
||||
This will make use of stored copier headers and reapply them to files if
|
||||
they match the included hash. More than one header can be applied to a
|
||||
@@ -485,6 +411,73 @@ Options:
|
||||
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.
|
||||
|
||||
-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
|
||||
This feature allows the user to quickly rebuild based on a supplied DAT
|
||||
file(s). By default all files will be rebuilt to uncompressed folders in
|
||||
@@ -719,19 +712,6 @@ Options:
|
||||
Output all rom information in generic text format. If no other format
|
||||
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)
|
||||
This is the multitool part of the program, allowing for almost every
|
||||
manipulation to a DAT, or set of DATs. This is also a combination of
|
||||
|
||||
@@ -318,77 +318,6 @@ namespace SabreTools
|
||||
FeatureType.Flag,
|
||||
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
|
||||
Feature restore = new Feature(
|
||||
new List<string>() { "-re", "--restore" },
|
||||
@@ -582,6 +511,63 @@ namespace SabreTools
|
||||
FeatureType.String,
|
||||
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
|
||||
Feature stats = new Feature(
|
||||
new List<string>() { "-st", "--stats" },
|
||||
@@ -639,23 +625,6 @@ namespace SabreTools
|
||||
FeatureType.Flag,
|
||||
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
|
||||
Feature update = new Feature(
|
||||
new List<string>() { "-ud", "--update" },
|
||||
@@ -1431,13 +1400,10 @@ namespace SabreTools
|
||||
help.Add("Script", script);
|
||||
help.Add("DATFromDir", datFromDir);
|
||||
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("Sort", sort);
|
||||
help.Add("Split", split);
|
||||
help.Add("Stats", stats);
|
||||
help.Add("Type Split", typeSplit);
|
||||
help.Add("Update", update);
|
||||
help.Add("Verify", verify);
|
||||
|
||||
|
||||
@@ -77,10 +77,7 @@ namespace SabreTools
|
||||
extract = false,
|
||||
restore = false,
|
||||
sort = false,
|
||||
splitByExt = false,
|
||||
splitByHash = false,
|
||||
splitByLevel = false,
|
||||
splitByType = false,
|
||||
split = false,
|
||||
stats = false,
|
||||
update = false,
|
||||
verify = false;
|
||||
@@ -122,6 +119,7 @@ namespace SabreTools
|
||||
usegame = true;
|
||||
DatFormat datFormat = 0x0;
|
||||
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 stripHash = 0x0;
|
||||
OutputFormat outputFormat = OutputFormat.Folder;
|
||||
@@ -199,22 +197,10 @@ namespace SabreTools
|
||||
case "--dfd":
|
||||
datFromDir = true;
|
||||
break;
|
||||
case "-es":
|
||||
case "--ext-split":
|
||||
splitByExt = true;
|
||||
break;
|
||||
case "-ex":
|
||||
case "--extract":
|
||||
extract = true;
|
||||
break;
|
||||
case "-hs":
|
||||
case "--hash-split":
|
||||
splitByHash = true;
|
||||
break;
|
||||
case "-ls":
|
||||
case "--lvl-split":
|
||||
splitByLevel = true;
|
||||
break;
|
||||
case "-re":
|
||||
case "--restore":
|
||||
restore = true;
|
||||
@@ -222,6 +208,10 @@ namespace SabreTools
|
||||
case "--script":
|
||||
// No-op for script mode, allowing for retaining the screen
|
||||
break;
|
||||
case "-sp":
|
||||
case "--split":
|
||||
split = true;
|
||||
break;
|
||||
case "-ss":
|
||||
case "--sort":
|
||||
sort = true;
|
||||
@@ -230,10 +220,6 @@ namespace SabreTools
|
||||
case "--stats":
|
||||
stats = true;
|
||||
break;
|
||||
case "-ts":
|
||||
case "--type-split":
|
||||
splitByType = true;
|
||||
break;
|
||||
case "-ud":
|
||||
case "--update":
|
||||
update = true;
|
||||
@@ -372,6 +358,10 @@ namespace SabreTools
|
||||
case "--dat-split":
|
||||
splitType = SplitType.Split;
|
||||
break;
|
||||
case "-es":
|
||||
case "--ext":
|
||||
externalSplitType |= ExternalSplitType.Extension;
|
||||
break;
|
||||
case "-f":
|
||||
case "--files":
|
||||
archivesAsFiles = true;
|
||||
@@ -392,6 +382,10 @@ namespace SabreTools
|
||||
case "--html":
|
||||
statDatFormat |= StatReportFormat.HTML;
|
||||
break;
|
||||
case "-hs":
|
||||
case "--hash":
|
||||
externalSplitType |= ExternalSplitType.Hash;
|
||||
break;
|
||||
case "-ic":
|
||||
case "--ignore-chd":
|
||||
chdsAsFiles = true;
|
||||
@@ -404,6 +398,10 @@ namespace SabreTools
|
||||
case "--inplace":
|
||||
inplace = true;
|
||||
break;
|
||||
case "-ls":
|
||||
case "--level":
|
||||
externalSplitType |= ExternalSplitType.Level;
|
||||
break;
|
||||
case "-m":
|
||||
case "--merge":
|
||||
merge = true;
|
||||
@@ -628,6 +626,10 @@ namespace SabreTools
|
||||
case "--trim":
|
||||
trim = true;
|
||||
break;
|
||||
case "-ts":
|
||||
case "--type":
|
||||
externalSplitType |= ExternalSplitType.Type;
|
||||
break;
|
||||
case "-tsv":
|
||||
case "--tsv":
|
||||
statDatFormat |= StatReportFormat.TSV;
|
||||
@@ -939,132 +941,132 @@ namespace SabreTools
|
||||
if (temparg.StartsWith("-") && temparg.Contains("="))
|
||||
{
|
||||
// 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 (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
|
||||
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":
|
||||
if (!Int32.TryParse(split[1], out sevenzip))
|
||||
if (!Int32.TryParse(argsplit[1], out sevenzip))
|
||||
{
|
||||
sevenzip = 1;
|
||||
}
|
||||
break;
|
||||
case "-ae":
|
||||
case "--add-ext":
|
||||
addext = split[1];
|
||||
addext = argsplit[1];
|
||||
break;
|
||||
case "-au":
|
||||
case "--author":
|
||||
author = split[1];
|
||||
author = argsplit[1];
|
||||
break;
|
||||
case "-bd":
|
||||
case "--base-dat":
|
||||
basePaths.Add(split[1]);
|
||||
basePaths.Add(argsplit[1]);
|
||||
break;
|
||||
case "-ca":
|
||||
case "--category=":
|
||||
category = split[1];
|
||||
category = argsplit[1];
|
||||
break;
|
||||
case "-co":
|
||||
case "--comment":
|
||||
comment = split[1];
|
||||
comment = argsplit[1];
|
||||
break;
|
||||
case "-crc":
|
||||
case "--crc":
|
||||
filter.CRCs.Add(split[1]);
|
||||
filter.CRCs.Add(argsplit[1]);
|
||||
break;
|
||||
case "-da":
|
||||
case "--date":
|
||||
date = split[1];
|
||||
date = argsplit[1];
|
||||
break;
|
||||
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();
|
||||
return;
|
||||
}
|
||||
datfiles.Add(split[1]);
|
||||
datfiles.Add(argsplit[1]);
|
||||
break;
|
||||
case "-de":
|
||||
case "--desc":
|
||||
description = split[1];
|
||||
description = argsplit[1];
|
||||
break;
|
||||
case "-em":
|
||||
case "--email":
|
||||
email = split[1];
|
||||
email = argsplit[1];
|
||||
break;
|
||||
case "-exta":
|
||||
case "--exta":
|
||||
exta.Add(split[1]);
|
||||
exta.Add(argsplit[1]);
|
||||
break;
|
||||
case "-extb":
|
||||
case "--extb":
|
||||
extb.Add(split[1]);
|
||||
extb.Add(argsplit[1]);
|
||||
break;
|
||||
case "-f":
|
||||
case "--filename":
|
||||
filename = split[1];
|
||||
filename = argsplit[1];
|
||||
break;
|
||||
case "-fm":
|
||||
case "--forcemerge":
|
||||
forcemerge = split[1];
|
||||
forcemerge = argsplit[1];
|
||||
break;
|
||||
case "-fn":
|
||||
case "--forcend":
|
||||
forcend = split[1];
|
||||
forcend = argsplit[1];
|
||||
break;
|
||||
case "-fp":
|
||||
case "--forcepack":
|
||||
forcepack = split[1];
|
||||
forcepack = argsplit[1];
|
||||
break;
|
||||
case "-gn":
|
||||
case "--game-name":
|
||||
filter.GameNames.Add(split[1]);
|
||||
filter.GameNames.Add(argsplit[1]);
|
||||
break;
|
||||
case "-gt":
|
||||
case "--game-type":
|
||||
filter.MachineTypes |= Filter.GetMachineTypeFromString(split[1]);
|
||||
filter.MachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
|
||||
break;
|
||||
case "-gz":
|
||||
case "--gz":
|
||||
if (!Int32.TryParse(split[1], out gz))
|
||||
if (!Int32.TryParse(argsplit[1], out gz))
|
||||
{
|
||||
gz = 2;
|
||||
}
|
||||
break;
|
||||
case "-h":
|
||||
case "--header":
|
||||
header = split[1];
|
||||
header = argsplit[1];
|
||||
break;
|
||||
case "-hp":
|
||||
case "--homepage":
|
||||
homepage = split[1];
|
||||
homepage = argsplit[1];
|
||||
break;
|
||||
case "-is":
|
||||
case "--status":
|
||||
filter.ItemStatuses |= Filter.GetStatusFromString(split[1]);
|
||||
filter.ItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
|
||||
break;
|
||||
case "-md5":
|
||||
case "--md5":
|
||||
filter.MD5s.Add(split[1]);
|
||||
filter.MD5s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-mt":
|
||||
case "--mt":
|
||||
if (Int32.TryParse(split[1], out int odop))
|
||||
if (Int32.TryParse(argsplit[1], out int odop))
|
||||
{
|
||||
Globals.MaxThreads = odop;
|
||||
}
|
||||
@@ -1075,139 +1077,139 @@ namespace SabreTools
|
||||
break;
|
||||
case "-n":
|
||||
case "--name":
|
||||
name = split[1];
|
||||
name = argsplit[1];
|
||||
break;
|
||||
case "-ncrc":
|
||||
case "--not-crc":
|
||||
filter.NotCRCs.Add(split[i]);
|
||||
filter.NotCRCs.Add(argsplit[i]);
|
||||
break;
|
||||
case "-ngn":
|
||||
case "--not-game":
|
||||
filter.NotGameNames.Add(split[1]);
|
||||
filter.NotGameNames.Add(argsplit[1]);
|
||||
break;
|
||||
case "-ngt":
|
||||
case "--not-gtype":
|
||||
filter.NotMachineTypes |= Filter.GetMachineTypeFromString(split[1]);
|
||||
filter.NotMachineTypes |= Filter.GetMachineTypeFromString(argsplit[1]);
|
||||
break;
|
||||
case "-nis":
|
||||
case "--not-status":
|
||||
filter.NotItemStatuses |= Filter.GetStatusFromString(split[1]);
|
||||
filter.NotItemStatuses |= Filter.GetStatusFromString(argsplit[1]);
|
||||
break;
|
||||
case "-nmd5":
|
||||
case "--not-md5":
|
||||
filter.NotMD5s.Add(split[1]);
|
||||
filter.NotMD5s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nrn":
|
||||
case "--not-rom":
|
||||
filter.NotRomNames.Add(split[1]);
|
||||
filter.NotRomNames.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nrt":
|
||||
case "--not-type":
|
||||
filter.NotRomTypes.Add(split[1]);
|
||||
filter.NotRomTypes.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nsha1":
|
||||
case "--not-sha1":
|
||||
filter.NotSHA1s.Add(split[1]);
|
||||
filter.NotSHA1s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nsha256":
|
||||
case "--not-sha256":
|
||||
filter.NotSHA256s.Add(split[1]);
|
||||
filter.NotSHA256s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nsha384":
|
||||
case "--not-sha384":
|
||||
filter.NotSHA384s.Add(split[1]);
|
||||
filter.NotSHA384s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-nsha512":
|
||||
case "--not-sha512":
|
||||
filter.NotSHA512s.Add(split[1]);
|
||||
filter.NotSHA512s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-out":
|
||||
case "--out":
|
||||
outDir = split[1];
|
||||
outDir = argsplit[1];
|
||||
break;
|
||||
case "-post":
|
||||
case "--postfix":
|
||||
postfix = split[1];
|
||||
postfix = argsplit[1];
|
||||
break;
|
||||
case "-pre":
|
||||
case "--prefix":
|
||||
prefix = split[1];
|
||||
prefix = argsplit[1];
|
||||
break;
|
||||
case "-r":
|
||||
case "--root":
|
||||
rootdir = split[1];
|
||||
rootdir = argsplit[1];
|
||||
break;
|
||||
case "-rar":
|
||||
case "--rar":
|
||||
if (!Int32.TryParse(split[1], out rar))
|
||||
if (!Int32.TryParse(argsplit[1], out rar))
|
||||
{
|
||||
rar = 2;
|
||||
}
|
||||
break;
|
||||
case "-rd":
|
||||
case "--root-dir":
|
||||
root = split[1];
|
||||
root = argsplit[1];
|
||||
break;
|
||||
case "-reg":
|
||||
case "--region":
|
||||
regions.Add(split[1]);
|
||||
regions.Add(argsplit[1]);
|
||||
break;
|
||||
case "-rep":
|
||||
case "--rep-ext":
|
||||
repext = split[1];
|
||||
repext = argsplit[1];
|
||||
break;
|
||||
case "-rn":
|
||||
case "--rom-name":
|
||||
filter.RomNames.Add(split[1]);
|
||||
filter.RomNames.Add(argsplit[1]);
|
||||
break;
|
||||
case "-rt":
|
||||
case "--rom-type":
|
||||
filter.RomTypes.Add(split[1]);
|
||||
filter.RomTypes.Add(argsplit[1]);
|
||||
break;
|
||||
case "-seq":
|
||||
case "--equal":
|
||||
filter.SizeEqualTo = Utilities.GetSizeFromString(split[1]);
|
||||
filter.SizeEqualTo = Utilities.GetSizeFromString(argsplit[1]);
|
||||
break;
|
||||
case "-sgt":
|
||||
case "--greater":
|
||||
filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString(split[1]);
|
||||
filter.SizeGreaterThanOrEqual = Utilities.GetSizeFromString(argsplit[1]);
|
||||
break;
|
||||
case "-sha1":
|
||||
case "--sha1":
|
||||
filter.SHA1s.Add(split[1]);
|
||||
filter.SHA1s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-sha256":
|
||||
case "--sha256":
|
||||
filter.SHA256s.Add(split[1]);
|
||||
filter.SHA256s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-sha384":
|
||||
case "--sha384":
|
||||
filter.SHA384s.Add(split[1]);
|
||||
filter.SHA384s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-sha512":
|
||||
case "--sha512":
|
||||
filter.SHA512s.Add(split[1]);
|
||||
filter.SHA512s.Add(argsplit[1]);
|
||||
break;
|
||||
case "-slt":
|
||||
case "--less":
|
||||
filter.SizeLessThanOrEqual = Utilities.GetSizeFromString(split[1]);
|
||||
filter.SizeLessThanOrEqual = Utilities.GetSizeFromString(argsplit[1]);
|
||||
break;
|
||||
case "-t":
|
||||
case "--temp":
|
||||
tempDir = split[1];
|
||||
tempDir = argsplit[1];
|
||||
break;
|
||||
case "-u":
|
||||
case "-url":
|
||||
case "--url":
|
||||
url = split[1];
|
||||
url = argsplit[1];
|
||||
break;
|
||||
case "-v":
|
||||
case "--version":
|
||||
version = split[1];
|
||||
version = argsplit[1];
|
||||
break;
|
||||
case "-zip":
|
||||
case "--zip":
|
||||
if (!Int32.TryParse(split[1], out zip))
|
||||
if (!Int32.TryParse(argsplit[1], out zip))
|
||||
{
|
||||
zip = 1;
|
||||
}
|
||||
@@ -1241,7 +1243,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// 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");
|
||||
_help.OutputGenericHelp();
|
||||
@@ -1250,7 +1252,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// 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");
|
||||
_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 (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");
|
||||
_help.OutputIndividualFeature(feature);
|
||||
@@ -1297,28 +1299,10 @@ namespace SabreTools
|
||||
outputFormat, romba, sevenzip, gz, rar, zip, updateDat, header, splitType, chdsAsFiles);
|
||||
}
|
||||
|
||||
// Split a DAT by extension
|
||||
else if (splitByExt)
|
||||
// Split a DAT by the split type
|
||||
else if (split)
|
||||
{
|
||||
InitSplit(inputs, outDir, inplace, ExternalSplitType.Extension, 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);
|
||||
InitSplit(inputs, outDir, inplace, externalSplitType, exta, extb, shortname, basedat);
|
||||
}
|
||||
|
||||
// Get statistics on input files
|
||||
|
||||
Reference in New Issue
Block a user