mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatFile, Enums] Add split as a valid splittype
This commit is contained in:
@@ -315,9 +315,10 @@ namespace SabreTools.Helper.Data
|
|||||||
helptext.Add(" -xof, --exclude-of Exclude romof, cloneof, sampleof tags");
|
helptext.Add(" -xof, --exclude-of Exclude romof, cloneof, sampleof tags");
|
||||||
helptext.Add(" -clean Clean game names according to WoD standards");
|
helptext.Add(" -clean Clean game names according to WoD standards");
|
||||||
helptext.Add(" -sl, --softlist Use Software List name instead of description");
|
helptext.Add(" -sl, --softlist Use Software List name instead of description");
|
||||||
helptext.Add(" -dnm, --dat-nm Create non-merged sets in the output DAT");
|
|
||||||
helptext.Add(" -dm, --dat-merge Create merged sets in the output DAT");
|
helptext.Add(" -dm, --dat-merge Create merged sets in the output DAT");
|
||||||
helptext.Add(" -df, --dat-fnm Create fully merged sets in the output");
|
helptext.Add(" -ds, --dat-sp Create split sets in the output DAT");
|
||||||
|
helptext.Add(" -dnm, --dat-nm Create non-merged sets in the output DAT");
|
||||||
|
helptext.Add(" -df, --dat-fnm Create fully non-merged sets in the output");
|
||||||
helptext.Add(" -trim Trim file names to fit NTFS length");
|
helptext.Add(" -trim Trim file names to fit NTFS length");
|
||||||
helptext.Add(" -rd=, --root-dir= Set the root directory for calc");
|
helptext.Add(" -rd=, --root-dir= Set the root directory for calc");
|
||||||
helptext.Add(" -si, --single All game names replaced by '!'");
|
helptext.Add(" -si, --single All game names replaced by '!'");
|
||||||
|
|||||||
@@ -263,6 +263,7 @@
|
|||||||
NonMerged,
|
NonMerged,
|
||||||
Merged,
|
Merged,
|
||||||
FullNonMerged,
|
FullNonMerged,
|
||||||
|
Split,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -878,6 +878,219 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use cloneof and romof tags to create split sets and remove the tags
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mergeroms">True if roms should be deduped, false otherwise</param>
|
||||||
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
|
public void CreateSplitSets(bool mergeroms, Logger logger, bool output = true)
|
||||||
|
{
|
||||||
|
logger.User("Creating split sets from the DAT");
|
||||||
|
|
||||||
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
|
BucketByGame(mergeroms, true, logger, output);
|
||||||
|
_sortedBy = SortedBy.Default;
|
||||||
|
|
||||||
|
// Now we want to loop through all of the games and set the correct information
|
||||||
|
List<string> games = Keys.ToList();
|
||||||
|
foreach (string game in games)
|
||||||
|
{
|
||||||
|
// If the game has no items in it, we want to continue
|
||||||
|
if (this[game].Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if the game has a parent or not
|
||||||
|
string parent = null;
|
||||||
|
if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf))
|
||||||
|
{
|
||||||
|
parent = this[game][0].Machine.CloneOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent doesnt exist, we want to continue
|
||||||
|
if (String.IsNullOrEmpty(parent))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent doesn't have any items, we want to continue
|
||||||
|
if (this[parent].Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent exists and has items, we copy the items from the parent to the current game
|
||||||
|
Machine currentMachine = this[game][0].Machine;
|
||||||
|
List<DatItem> parentItems = this[parent];
|
||||||
|
foreach (DatItem item in parentItems)
|
||||||
|
{
|
||||||
|
// Figure out the type of the item and remove it accordingly
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.Archive:
|
||||||
|
Archive archive = ((Archive)item).Clone() as Archive;
|
||||||
|
if (this[game].Contains(archive))
|
||||||
|
{
|
||||||
|
this[game].Remove(archive);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.BiosSet:
|
||||||
|
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
||||||
|
if (this[game].Contains(biosSet))
|
||||||
|
{
|
||||||
|
this[game].Remove(biosSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Disk:
|
||||||
|
Disk disk = ((Disk)item).Clone() as Disk;
|
||||||
|
if (this[game].Contains(disk))
|
||||||
|
{
|
||||||
|
this[game].Remove(disk);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Release:
|
||||||
|
Release release = ((Release)item).Clone() as Release;
|
||||||
|
if (this[game].Contains(release))
|
||||||
|
{
|
||||||
|
this[game].Remove(release);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Rom:
|
||||||
|
Rom rom = ((Rom)item).Clone() as Rom;
|
||||||
|
if (this[game].Contains(rom))
|
||||||
|
{
|
||||||
|
this[game].Remove(rom);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Sample:
|
||||||
|
Sample sample = ((Sample)item).Clone() as Sample;
|
||||||
|
if (this[game].Contains(sample))
|
||||||
|
{
|
||||||
|
this[game].Remove(sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we want to get the parent romof tag and put it in each of the items
|
||||||
|
List<DatItem> items = this[game];
|
||||||
|
string romof = this[parent][0].Machine.RomOf;
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
item.Machine.RomOf = romof;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||||
|
games = Keys.ToList();
|
||||||
|
foreach (string game in games)
|
||||||
|
{
|
||||||
|
// If the game has no items in it, we want to continue
|
||||||
|
if (this[game].Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if the game has a parent or not
|
||||||
|
string parent = null;
|
||||||
|
if (!String.IsNullOrEmpty(this[game][0].Machine.RomOf))
|
||||||
|
{
|
||||||
|
parent = this[game][0].Machine.RomOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent doesnt exist, we want to continue
|
||||||
|
if (String.IsNullOrEmpty(parent))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent doesn't have any items, we want to continue
|
||||||
|
if (this[parent].Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the parent exists and has items, we remove the items that are in the parent from the current game
|
||||||
|
Machine currentMachine = this[game][0].Machine;
|
||||||
|
List<DatItem> parentItems = this[parent];
|
||||||
|
foreach (DatItem item in parentItems)
|
||||||
|
{
|
||||||
|
// Figure out the type of the item and add it accordingly
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.Archive:
|
||||||
|
Archive archive = ((Archive)item).Clone() as Archive;
|
||||||
|
if (this[game].Contains(archive))
|
||||||
|
{
|
||||||
|
this[game].Remove(archive);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.BiosSet:
|
||||||
|
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
||||||
|
if (this[game].Contains(biosSet))
|
||||||
|
{
|
||||||
|
this[game].Remove(biosSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Disk:
|
||||||
|
Disk disk = ((Disk)item).Clone() as Disk;
|
||||||
|
if (this[game].Contains(disk))
|
||||||
|
{
|
||||||
|
this[game].Remove(disk);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Release:
|
||||||
|
Release release = ((Release)item).Clone() as Release;
|
||||||
|
if (this[game].Contains(release))
|
||||||
|
{
|
||||||
|
this[game].Remove(release);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Rom:
|
||||||
|
Rom rom = ((Rom)item).Clone() as Rom;
|
||||||
|
if (this[game].Contains(rom))
|
||||||
|
{
|
||||||
|
this[game].Remove(rom);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.Sample:
|
||||||
|
Sample sample = ((Sample)item).Clone() as Sample;
|
||||||
|
if (this[game].Contains(sample))
|
||||||
|
{
|
||||||
|
this[game].Remove(sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||||
|
games = Keys.ToList();
|
||||||
|
foreach (string game in games)
|
||||||
|
{
|
||||||
|
List<DatItem> items = this[game];
|
||||||
|
foreach (DatItem item in items)
|
||||||
|
{
|
||||||
|
item.Machine.CloneOf = null;
|
||||||
|
item.Machine.RomOf = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion // Instance Methods
|
#endregion // Instance Methods
|
||||||
|
|||||||
@@ -127,17 +127,20 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now we pre-process the DAT with the splitting/merging mode
|
// Now we pre-process the DAT with the splitting/merging mode
|
||||||
if (splitType == SplitType.NonMerged)
|
switch (splitType)
|
||||||
{
|
{
|
||||||
CreateNonMergedSets(false, logger, output: false);
|
case SplitType.FullNonMerged:
|
||||||
}
|
CreateFullyNonMergedSets(false, logger, output: false);
|
||||||
else if (splitType == SplitType.Merged)
|
break;
|
||||||
{
|
case SplitType.NonMerged:
|
||||||
CreateMergedSets(false, logger, output: false);
|
CreateNonMergedSets(false, logger, output: false);
|
||||||
}
|
break;
|
||||||
else if (splitType == SplitType.FullNonMerged)
|
case SplitType.Merged:
|
||||||
{
|
CreateMergedSets(false, logger, output: false);
|
||||||
CreateFullyNonMergedSets(false, logger, output: false);
|
break;
|
||||||
|
case SplitType.Split:
|
||||||
|
CreateSplitSets(false, logger, output: false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -730,15 +730,21 @@ Options:
|
|||||||
Enabling this flag allows for the original name to be preserved and keeping
|
Enabling this flag allows for the original name to be preserved and keeping
|
||||||
the description as just a description.
|
the description as just a description.
|
||||||
|
|
||||||
-dnm, --dat-nm Create non-merged sets in the output DAT
|
|
||||||
-dm, --dat-merge Create merged sets in the output DAT
|
-dm, --dat-merge Create merged sets in the output DAT
|
||||||
-df, --dat-fnm Create fully merged sets (including devices) in the output DAT
|
Preprocess the DAT to have parent sets contain all items from the children based
|
||||||
Each of the above flags allow for preprocessing an outputted DAT in the case that
|
on the cloneof tag.
|
||||||
your DAT manager of choice doesn't allow these on the fly. Non-merged will copy all
|
|
||||||
parent items to the children so that each archive or folder contains everything
|
-ds, --dat-sp Create split sets in the output DAT
|
||||||
necessary for each game. Fully non-merged copies all parent and device items to the
|
Preprocess the DAT to remove redundant files between parents and children based
|
||||||
children as well. Merge will copy all child items to a subfolder of the parent,
|
on the romof and cloneof tags.
|
||||||
reducing the space taken up on disk.
|
|
||||||
|
-dnm, --dat-nm Create non-merged sets in the output DAT
|
||||||
|
Preprocess the DAT to have child sets contain all items from the parent set based
|
||||||
|
on the cloneof tag.
|
||||||
|
|
||||||
|
-df, --dat-fnm Create fully non-merged sets in the output DAT
|
||||||
|
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.
|
||||||
|
|
||||||
-trim Trim file names to fit NTFS length
|
-trim Trim file names to fit NTFS length
|
||||||
In the cases where files will have too long a name, this allows for trimming
|
In the cases where files will have too long a name, this allows for trimming
|
||||||
|
|||||||
@@ -284,6 +284,10 @@ namespace SabreTools
|
|||||||
case "--dat-nm":
|
case "--dat-nm":
|
||||||
splitType = SplitType.NonMerged;
|
splitType = SplitType.NonMerged;
|
||||||
break;
|
break;
|
||||||
|
case "-ds":
|
||||||
|
case "--dat-sp":
|
||||||
|
splitType = SplitType.Split;
|
||||||
|
break;
|
||||||
case "-f":
|
case "-f":
|
||||||
case "--files":
|
case "--files":
|
||||||
parseArchivesAsFiles = true;
|
parseArchivesAsFiles = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user