mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatFile] Get flag usage and override working for sort/sort-depot/verify/verify-depot
This commit is contained in:
@@ -217,6 +217,8 @@
|
||||
{
|
||||
None = 0,
|
||||
Split,
|
||||
Merged,
|
||||
NonMerged,
|
||||
Full,
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,12 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="softlist">True if SL XML names should be kept, false otherwise (default)</param>
|
||||
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
||||
public void Parse(string filename, int sysid, int srcid, Logger logger, bool keep = false, bool clean = false, bool softlist = false, bool keepext = false)
|
||||
/// <param name="useTags">True if tags from the DAT should be used to merge the output, false otherwise (default)</param>
|
||||
public void Parse(string filename, int sysid, int srcid, Logger logger,
|
||||
bool keep = false, bool clean = false, bool softlist = false, bool keepext = false, bool useTags = false)
|
||||
{
|
||||
Parse(filename, sysid, srcid, new Filter(), SplitType.None, false, false, "", logger, keep, clean, softlist, keepext);
|
||||
Parse(filename, sysid, srcid, new Filter(), SplitType.None, false, false, "", logger,
|
||||
keep: keep, clean: clean, softlist: softlist, keepext: keepext, useTags: useTags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,6 +58,7 @@ namespace SabreTools.Helper.Dats
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="softlist">True if SL XML names should be kept, false otherwise (default)</param>
|
||||
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
||||
/// <param name="useTags">True if tags from the DAT should be used to merge the output, false otherwise (default)</param>
|
||||
public void Parse(
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
@@ -75,7 +79,8 @@ namespace SabreTools.Helper.Dats
|
||||
bool keep = false,
|
||||
bool clean = false,
|
||||
bool softlist = false,
|
||||
bool keepext = false)
|
||||
bool keepext = false,
|
||||
bool useTags = false)
|
||||
{
|
||||
// Check the file extension first as a safeguard
|
||||
string ext = Path.GetExtension(filename).ToLowerInvariant();
|
||||
@@ -126,6 +131,29 @@ namespace SabreTools.Helper.Dats
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are using tags from the DAT, set the proper input for split type unless overridden
|
||||
if (useTags && splitType == SplitType.None)
|
||||
{
|
||||
switch (_forceMerging)
|
||||
{
|
||||
case ForceMerging.None:
|
||||
// No-op
|
||||
break;
|
||||
case ForceMerging.Split:
|
||||
splitType = SplitType.Split;
|
||||
break;
|
||||
case ForceMerging.Merged:
|
||||
splitType = SplitType.Merged;
|
||||
break;
|
||||
case ForceMerging.NonMerged:
|
||||
splitType = SplitType.NonMerged;
|
||||
break;
|
||||
case ForceMerging.Full:
|
||||
splitType = SplitType.FullNonMerged;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we pre-process the DAT with the splitting/merging mode
|
||||
switch (splitType)
|
||||
{
|
||||
@@ -726,6 +754,12 @@ namespace SabreTools.Helper.Dats
|
||||
case "split":
|
||||
ForceMerging = ForceMerging.Split;
|
||||
break;
|
||||
case "merged":
|
||||
ForceMerging = ForceMerging.Merged;
|
||||
break;
|
||||
case "nonmerged":
|
||||
ForceMerging = ForceMerging.NonMerged;
|
||||
break;
|
||||
case "full":
|
||||
ForceMerging = ForceMerging.Full;
|
||||
break;
|
||||
@@ -898,11 +932,17 @@ namespace SabreTools.Helper.Dats
|
||||
{
|
||||
switch (xtr.GetAttribute("forcemerging"))
|
||||
{
|
||||
case "none":
|
||||
ForceMerging = ForceMerging.None;
|
||||
break;
|
||||
case "split":
|
||||
ForceMerging = ForceMerging.Split;
|
||||
break;
|
||||
case "none":
|
||||
ForceMerging = ForceMerging.None;
|
||||
case "merged":
|
||||
ForceMerging = ForceMerging.Merged;
|
||||
break;
|
||||
case "nonmerged":
|
||||
ForceMerging = ForceMerging.NonMerged;
|
||||
break;
|
||||
case "full":
|
||||
ForceMerging = ForceMerging.Full;
|
||||
@@ -1094,11 +1134,17 @@ namespace SabreTools.Helper.Dats
|
||||
{
|
||||
switch (headreader.GetAttribute("forcemerging"))
|
||||
{
|
||||
case "none":
|
||||
ForceMerging = ForceMerging.None;
|
||||
break;
|
||||
case "split":
|
||||
ForceMerging = ForceMerging.Split;
|
||||
break;
|
||||
case "none":
|
||||
ForceMerging = ForceMerging.None;
|
||||
case "merged":
|
||||
ForceMerging = ForceMerging.Merged;
|
||||
break;
|
||||
case "nonmerged":
|
||||
ForceMerging = ForceMerging.NonMerged;
|
||||
break;
|
||||
case "full":
|
||||
ForceMerging = ForceMerging.Full;
|
||||
|
||||
@@ -258,6 +258,8 @@ namespace SabreTools.Helper.Dats
|
||||
(ForcePacking == ForcePacking.Zip ? "\tforcezipping yes\n" : "") +
|
||||
(ForceMerging == ForceMerging.Full ? "\tforcemerging full\n" : "") +
|
||||
(ForceMerging == ForceMerging.Split ? "\tforcemerging split\n" : "") +
|
||||
(ForceMerging == ForceMerging.Merged ? "\tforcemerging merged\n" : "") +
|
||||
(ForceMerging == ForceMerging.NonMerged ? "\tforcemerging nonmerged\n" : "") +
|
||||
")\n";
|
||||
break;
|
||||
case DatFormat.CSV:
|
||||
@@ -298,6 +300,8 @@ namespace SabreTools.Helper.Dats
|
||||
(ForcePacking == ForcePacking.Zip ? " forcepacking=\"zip\"" : "") +
|
||||
(ForceMerging == ForceMerging.Full ? " forcemerging=\"full\"" : "") +
|
||||
(ForceMerging == ForceMerging.Split ? " forcemerging=\"split\"" : "") +
|
||||
(ForceMerging == ForceMerging.Merged ? " forcemerging=\"merged\"" : "") +
|
||||
(ForceMerging == ForceMerging.NonMerged ? " forcemerging=\"nonmerged\"" : "") +
|
||||
(ForceNodump == ForceNodump.Ignore ? " forceitemStatus=\"ignore\"" : "") +
|
||||
(ForceNodump == ForceNodump.Obsolete ? " forceitemStatus=\"obsolete\"" : "") +
|
||||
(ForceNodump == ForceNodump.Required ? " forceitemStatus=\"required\"" : "") +
|
||||
@@ -361,7 +365,7 @@ namespace SabreTools.Helper.Dats
|
||||
"[DAT]\n" +
|
||||
"version=2.50\n" +
|
||||
"split=" + (ForceMerging == ForceMerging.Split ? "1" : "0") + "\n" +
|
||||
"merge=" + (ForceMerging == ForceMerging.Full ? "1" : "0") + "\n" +
|
||||
"merge=" + (ForceMerging == ForceMerging.Full || ForceMerging == ForceMerging.Merged ? "1" : "0") + "\n" +
|
||||
"[EMULATOR]\n" +
|
||||
"refname=" + Name + "\n" +
|
||||
"version=" + Description + "\n" +
|
||||
@@ -387,6 +391,8 @@ namespace SabreTools.Helper.Dats
|
||||
(ForcePacking == ForcePacking.Zip ? "\t\t\t<flag name=\"forcepacking\" value=\"zip\"/>\n" : "") +
|
||||
(ForceMerging == ForceMerging.Full ? "\t\t\t<flag name=\"forcemerging\" value=\"full\"/>\n" : "") +
|
||||
(ForceMerging == ForceMerging.Split ? "\t\t\t<flag name=\"forcemerging\" value=\"split\"/>\n" : "") +
|
||||
(ForceMerging == ForceMerging.Merged ? "\t\t\t<flag name=\"forcemerging\" value=\"merged\"/>\n" : "") +
|
||||
(ForceMerging == ForceMerging.NonMerged ? "\t\t\t<flag name=\"forcemerging\" value=\"nonmerged\"/>\n" : "") +
|
||||
(ForceNodump == ForceNodump.Ignore ? "\t\t\t<flag name=\"forceitemStatus\" value=\"ignore\"/>\n" : "") +
|
||||
(ForceNodump == ForceNodump.Obsolete ? "\t\t\t<flag name=\"forceitemStatus\" value=\"obsolete\"/>\n" : "") +
|
||||
(ForceNodump == ForceNodump.Required ? "\t\t\t<flag name=\"forceitemStatus\" value=\"required\"/>\n" : "") +
|
||||
@@ -404,6 +410,8 @@ namespace SabreTools.Helper.Dats
|
||||
(ForcePacking == ForcePacking.Zip ? " forcepacking=\"zip\"" : "") +
|
||||
(ForceMerging == ForceMerging.Full ? " forcemerging=\"full\"" : "") +
|
||||
(ForceMerging == ForceMerging.Split ? " forcemerging=\"split\"" : "") +
|
||||
(ForceMerging == ForceMerging.Merged ? " forcemerging=\"merged\"" : "") +
|
||||
(ForceMerging == ForceMerging.NonMerged ? " forcemerging=\"nonmerged\"" : "") +
|
||||
(ForceNodump == ForceNodump.Ignore ? " forceitemStatus=\"ignore\"" : "") +
|
||||
(ForceNodump == ForceNodump.Obsolete ? " forceitemStatus=\"obsolete\"" : "") +
|
||||
(ForceNodump == ForceNodump.Required ? " forceitemStatus=\"required\"" : "") +
|
||||
|
||||
@@ -1047,6 +1047,23 @@ Options:
|
||||
defined, and that skipper exists, then it will be used instead of trying to find one
|
||||
that matches.
|
||||
|
||||
-dm, --dat-merged Force checking merged sets in the output
|
||||
Preprocess the DAT to have parent sets contain all items from the children based
|
||||
on the cloneof tag. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-ds, --dat-split Force checking split sets in the output
|
||||
Preprocess the DAT to remove redundant files between parents and children based
|
||||
on the romof and cloneof tags. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-dnm, --dat-nonmerged Force checking non-merged sets in the output
|
||||
Preprocess the DAT to have child sets contain all items from the parent set based
|
||||
on the cloneof tag. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-df, --dat-fullnonmerged Force checking fully non-merged sets in the output
|
||||
Preprocess the DAT to have child sets contain all items from the parent sets based
|
||||
on the cloneof and romof tags as well as device references. This is incompatible with
|
||||
the other --dat-X flags.
|
||||
|
||||
-ved, --verify-depot Verify a depot against an input DAT
|
||||
When used, this will use an input DAT or set of DATs to blindly check against an input
|
||||
depot. This is based on the sort-depot code in which the base directories are assumed
|
||||
@@ -1068,6 +1085,23 @@ Options:
|
||||
defined, and that skipper exists, then it will be used instead of trying to find one
|
||||
that matches.
|
||||
|
||||
-dm, --dat-merged Force checking merged sets in the output
|
||||
Preprocess the DAT to have parent sets contain all items from the children based
|
||||
on the cloneof tag. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-ds, --dat-split Force checking split sets in the output
|
||||
Preprocess the DAT to remove redundant files between parents and children based
|
||||
on the romof and cloneof tags. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-dnm, --dat-nonmerged Force checking non-merged sets in the output
|
||||
Preprocess the DAT to have child sets contain all items from the parent set based
|
||||
on the cloneof tag. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-df, --dat-fullnonmerged Force checking fully non-merged sets in the output
|
||||
Preprocess the DAT to have child sets contain all items from the parent sets based
|
||||
on the cloneof and romof tags as well as device references. This is incompatible with
|
||||
the other --dat-X flags.
|
||||
|
||||
** Section 3.0 - Examples
|
||||
|
||||
Here, any user-requested examples will go
|
||||
|
||||
@@ -1231,6 +1231,26 @@ namespace SabreTools
|
||||
"Set a header skipper to use, blank means all",
|
||||
FeatureType.String,
|
||||
null));
|
||||
verify.AddFeature("dat-merged", new Feature(
|
||||
new List<string>() { "-dm", "--dat-merged" },
|
||||
"Force checking merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verify.AddFeature("dat-split", new Feature(
|
||||
new List<string>() { "-ds", "--dat-split" },
|
||||
"Force checking split sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verify.AddFeature("dat-nonmerged", new Feature(
|
||||
new List<string>() { "-dnm", "--dat-nonmerged" },
|
||||
"Force checking non-merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verify.AddFeature("dat-fullnonmerged", new Feature(
|
||||
new List<string>() { "-df", "--dat-fullnonmerged" },
|
||||
"Force checking fully non-merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
|
||||
// Create the Verify Depot feature
|
||||
Feature verifyDepot = new Feature(
|
||||
@@ -1253,6 +1273,26 @@ namespace SabreTools
|
||||
"Set a header skipper to use, blank means all",
|
||||
FeatureType.String,
|
||||
null));
|
||||
verifyDepot.AddFeature("dat-merged", new Feature(
|
||||
new List<string>() { "-dm", "--dat-merged" },
|
||||
"Force checking merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verifyDepot.AddFeature("dat-split", new Feature(
|
||||
new List<string>() { "-ds", "--dat-split" },
|
||||
"Force checking split sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verifyDepot.AddFeature("dat-nonmerged", new Feature(
|
||||
new List<string>() { "-dnm", "--dat-nonmerged" },
|
||||
"Force checking non-merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
verifyDepot.AddFeature("dat-fullnonmerged", new Feature(
|
||||
new List<string>() { "-df", "--dat-fullnonmerged" },
|
||||
"Force checking fully non-merged sets",
|
||||
FeatureType.Flag,
|
||||
null));
|
||||
|
||||
// Now, add all of the main features to the Help object
|
||||
help.Add("Help", helpFeature);
|
||||
|
||||
@@ -325,7 +325,8 @@ namespace SabreTools
|
||||
DatFile datdata = new DatFile();
|
||||
foreach (string datfile in datfiles)
|
||||
{
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger, keep: true, softlist: true);
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger,
|
||||
keep: true, softlist: true, useTags: true);
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
@@ -359,7 +360,8 @@ namespace SabreTools
|
||||
DatFile datdata = new DatFile();
|
||||
foreach (string datfile in datfiles)
|
||||
{
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger, keep: true, softlist: true);
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger,
|
||||
keep: true, softlist: true, useTags: true);
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
@@ -823,7 +825,9 @@ namespace SabreTools
|
||||
/// <param name="hashOnly">True if only hashes should be checked, false for full file information</param>
|
||||
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
private static void InitVerify(List<string> datfiles, List<string> inputs, string tempDir, bool hashOnly, bool quickScan, string headerToCheckAgainst)
|
||||
/// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param>
|
||||
private static void InitVerify(List<string> datfiles, List<string> inputs, string tempDir,
|
||||
bool hashOnly, bool quickScan, string headerToCheckAgainst, SplitType splitType)
|
||||
{
|
||||
// Get the archive scanning level
|
||||
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1);
|
||||
@@ -835,7 +839,8 @@ namespace SabreTools
|
||||
DatFile datdata = new DatFile();
|
||||
foreach (string datfile in datfiles)
|
||||
{
|
||||
datdata.Parse(datfile, 99, 99, _logger, keep: true, softlist: true);
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger,
|
||||
keep: true, softlist: true, useTags: true);
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
@@ -849,7 +854,9 @@ namespace SabreTools
|
||||
/// <param name="inputs">Input directories to compare against</param>
|
||||
/// <param name="tempDir">Temporary directory for archive extraction</param>
|
||||
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||
private static void InitVerifyDepot(List<string> datfiles, List<string> inputs, string tempDir, string headerToCheckAgainst)
|
||||
/// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param>
|
||||
private static void InitVerifyDepot(List<string> datfiles, List<string> inputs, string tempDir,
|
||||
string headerToCheckAgainst, SplitType splitType)
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
_logger.User("Populating internal DAT...");
|
||||
@@ -858,7 +865,8 @@ namespace SabreTools
|
||||
DatFile datdata = new DatFile();
|
||||
foreach (string datfile in datfiles)
|
||||
{
|
||||
datdata.Parse(datfile, 99, 99, _logger, keep: true, softlist: true);
|
||||
datdata.Parse(datfile, 99, 99, new Filter(), splitType, false /* trim */, false /* single */, null /* root */, _logger,
|
||||
keep: true, softlist: true, useTags: true);
|
||||
}
|
||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user