[DatFile] Consolodate bucketing code; parallelize

This commit is contained in:
Matt Nadareski
2017-03-01 19:48:40 -08:00
parent 7fbdf87a42
commit aee20bfccf
7 changed files with 120 additions and 557 deletions

View File

@@ -405,7 +405,7 @@ namespace RombaSharp
// First get a list of SHA-1's from the input DATs
DatFile datroot = new DatFile { Type = "SuperDAT", };
datroot.PopulateFromDir(_dats, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, false, false, false, _tmpdir, false, null, 4, _logger);
datroot.BucketBySHA1(false, _logger, false);
datroot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
// Create a List of dat hashes in the database (SHA-1)
List<string> databaseDats = new List<string>();
@@ -435,7 +435,7 @@ namespace RombaSharp
unneeded.Add(hash);
}
}
datroot.BucketByGame(false, true, _logger, false);
datroot.BucketBy(SortedBy.Game, false /* mergeroms */, _logger, output: false, norename: true);
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
@@ -619,7 +619,7 @@ namespace RombaSharp
// Now rescan the depot itself
DatFile depot = new DatFile();
depot.PopulateFromDir(depotname, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, true, false, false, _tmpdir, false, null, _workers, _logger);
depot.BucketBySHA1(false, _logger, false);
depot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
// Set the base queries to use
string crcquery = "INSERT OR IGNORE INTO crc (crc) VALUES";

View File

@@ -345,12 +345,12 @@ namespace SabreTools.Helper.Dats
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).SHA512;
datdata.BucketBySHA512(false, logger, false);
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false);
}
else
{
key = ((Disk)this).SHA512;
datdata.BucketBySHA512(false, logger, false);
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false);
}
}
@@ -362,12 +362,12 @@ namespace SabreTools.Helper.Dats
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).SHA384;
datdata.BucketBySHA384(false, logger, false);
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false);
}
else
{
key = ((Disk)this).SHA384;
datdata.BucketBySHA384(false, logger, false);
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false);
}
}
@@ -379,12 +379,12 @@ namespace SabreTools.Helper.Dats
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).SHA256;
datdata.BucketBySHA256(false, logger, false);
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false);
}
else
{
key = ((Disk)this).SHA256;
datdata.BucketBySHA256(false, logger, false);
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false);
}
}
@@ -396,12 +396,12 @@ namespace SabreTools.Helper.Dats
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).SHA1;
datdata.BucketBySHA1(false, logger, false);
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
}
else
{
key = ((Disk)this).SHA1;
datdata.BucketBySHA1(false, logger, false);
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
}
}
@@ -413,12 +413,12 @@ namespace SabreTools.Helper.Dats
if (_itemType == ItemType.Rom)
{
key = ((Rom)this).MD5;
datdata.BucketByMD5(false, logger, false);
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
}
else
{
key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false);
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
}
}
@@ -426,21 +426,21 @@ namespace SabreTools.Helper.Dats
else if (_itemType == ItemType.Disk)
{
key = ((Disk)this).MD5;
datdata.BucketByMD5(false, logger, false);
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
}
// If we've gotten here and we have a Rom, sort by CRC
else if (_itemType == ItemType.Rom)
{
key = ((Rom)this).CRC;
datdata.BucketByCRC(false, logger, false);
datdata.BucketBy(SortedBy.CRC, false /* mergeroms */, logger, output: false);
}
// Otherwise, we use -1 as the key
else
{
key = "-1";
datdata.BucketBySize(false, logger, false);
datdata.BucketBy(SortedBy.Size, false /* mergeroms */, logger, output: false);
}
return key;

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using SabreTools.Helper.Data;
@@ -14,99 +15,34 @@ namespace SabreTools.Helper.Dats
#region Bucketing [MODULAR DONE]
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by CRC
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by a user-defined method
/// </summary>
/// <param name="bucketBy">SortedBy enum representing how to sort the individual items</param>
/// <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 BucketByCRC(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.CRC)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.CRC;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by CRC");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).CRC : Constants.CRCZero);
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by Game
/// </summary>
/// <param name="mergeroms">True if roms should be deduped, false otherwise</param>
/// <param name="lower">True if the key should be lowercased (default), false otherwise</param>
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</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>
/// <param name="lower">True if the game should be lowercased (default), false otherwise</param>
public void BucketByGame(bool mergeroms, bool norename, Logger logger, bool output = true, bool lower = true)
public void BucketBy(SortedBy bucketBy, bool mergeroms, Logger logger, bool output = true, bool lower = true, bool norename = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.Game)
if (_sortedBy == bucketBy)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.Game;
_sortedBy = bucketBy;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by game");
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by " + bucketBy);
// Process each all of the roms
// First do the initial sort of all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
Parallel.ForEach(keys,
key =>
{
List<DatItem> roms = this[key];
@@ -120,7 +56,15 @@ namespace SabreTools.Helper.Dats
foreach (DatItem rom in roms)
{
count++;
string newkey = (norename ? ""
string newkey = "";
switch (bucketBy)
{
case SortedBy.CRC:
newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).CRC : Constants.CRCZero);
break;
case SortedBy.Game:
newkey = (norename ? ""
: rom.SystemID.ToString().PadLeft(10, '0')
+ "-"
+ rom.SourceID.ToString().PadLeft(10, '0') + "-")
@@ -133,362 +77,43 @@ namespace SabreTools.Helper.Dats
}
newkey = HttpUtility.HtmlEncode(newkey);
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, norename);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by MD5
/// </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 BucketByMD5(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.MD5)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.MD5;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by MD5");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom
break;
case SortedBy.MD5:
newkey = (rom.Type == ItemType.Rom
? ((Rom)rom).MD5
: (rom.Type == ItemType.Disk
? ((Disk)rom).MD5
: Constants.MD5Zero));
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA1
/// </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 BucketBySHA1(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.SHA1)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.SHA1;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-1");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom
break;
case SortedBy.SHA1:
newkey = (rom.Type == ItemType.Rom
? ((Rom)rom).SHA1
: (rom.Type == ItemType.Disk
? ((Disk)rom).SHA1
: Constants.SHA1Zero));
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA256
/// </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 BucketBySHA256(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.SHA256)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.SHA256;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-256");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom
break;
case SortedBy.SHA256:
newkey = (rom.Type == ItemType.Rom
? ((Rom)rom).SHA256
: (rom.Type == ItemType.Disk
? ((Disk)rom).SHA256
: Constants.SHA256Zero));
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA384
/// </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 BucketBySHA384(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.SHA384)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.SHA384;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-384");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom
break;
case SortedBy.SHA384:
newkey = (rom.Type == ItemType.Rom
? ((Rom)rom).SHA384
: (rom.Type == ItemType.Disk
? ((Disk)rom).SHA384
: Constants.SHA384Zero));
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA512
/// </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 BucketBySHA512(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.SHA512)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.SHA512;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-512");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom
break;
case SortedBy.SHA512:
newkey = (rom.Type == ItemType.Rom
? ((Rom)rom).SHA512
: (rom.Type == ItemType.Disk
? ((Disk)rom).SHA512
: Constants.SHA512Zero));
break;
}
if (!sortable.ContainsKey(newkey))
{
@@ -496,88 +121,26 @@ namespace SabreTools.Helper.Dats
}
sortable[newkey].Add(rom);
}
}
});
// Now go through and sort all of the lists
// Now go through and sort all of the individual lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
Parallel.ForEach(keys,
key =>
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
lock (sortable)
{
sortable[key] = sortedlist;
}
});
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
}
// Now assign the dictionary back
_files = sortable;
}
/// <summary>
/// Take the arbitrarily sorted Files Dictionary and convert to one sorted by Size
/// </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 BucketBySize(bool mergeroms, Logger logger, bool output = true)
{
// If we already have the right sorting, trust it
if (_sortedBy == SortedBy.Size)
{
return;
}
// Set the sorted type
_sortedBy = SortedBy.Size;
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
long count = 0;
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by size");
// Process each all of the roms
List<string> keys = Keys.ToList();
foreach (string key in keys)
{
List<DatItem> roms = this[key];
// If we're merging the roms, do so
if (mergeroms)
{
roms = DatItem.Merge(roms, logger);
}
// Now add each of the roms to their respective games
foreach (DatItem rom in roms)
{
count++;
string newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).Size.ToString() : "-1");
if (!sortable.ContainsKey(newkey))
{
sortable.Add(newkey, new List<DatItem>());
}
sortable[newkey].Add(rom);
}
}
// Now go through and sort all of the lists
keys = sortable.Keys.ToList();
foreach (string key in keys)
{
List<DatItem> sortedlist = sortable[key];
DatItem.Sort(ref sortedlist, false);
sortable[key] = sortedlist;
}
// Output the count if told to
if (output)
{
logger.User("A total of " + count + " file hashes will be written out to file");
logger.User("A total of " + count + " items will be written out to file");
}
// Now assign the dictionary back
@@ -599,7 +162,7 @@ namespace SabreTools.Helper.Dats
logger.User("Creating fully non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output);
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information
@@ -627,7 +190,7 @@ namespace SabreTools.Helper.Dats
logger.User("Creating merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output);
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information
@@ -651,7 +214,7 @@ namespace SabreTools.Helper.Dats
logger.User("Creating non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output);
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information
@@ -675,7 +238,7 @@ namespace SabreTools.Helper.Dats
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);
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
_sortedBy = SortedBy.Default;
// Now we want to loop through all of the games and set the correct information

View File

@@ -145,7 +145,7 @@ namespace SabreTools.Helper.Dats
}
// Now that we have a list of depots, we want to sort the input DAT by SHA-1
BucketBySHA1(false, logger, output: false);
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
// Then we want to loop through each of the hashes and see if we can rebuild
List<string> hashes = Keys.ToList();
@@ -830,7 +830,7 @@ namespace SabreTools.Helper.Dats
}
// Now that we have a list of depots, we want to sort the input DAT by SHA-1
BucketBySHA1(false, logger, output: false);
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
// Then we want to loop through each of the hashes and see if we can rebuild
List<string> hashes = Keys.ToList();
@@ -941,7 +941,7 @@ namespace SabreTools.Helper.Dats
if (hashOnly)
{
// First we need to sort by hash to get duplicates
BucketBySHA1(true, logger, output: false);
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
// Then follow the same tactics as before
foreach (string key in Keys)

View File

@@ -322,7 +322,7 @@ namespace SabreTools.Helper.Dats
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
// First, organize by games so that we can do the right thing
BucketByGame(false, true, logger, output: false, lower: false);
BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, lower: false, norename: true);
// Create a temporary DAT to add things to
DatFile tempDat = new DatFile(this);

View File

@@ -116,7 +116,7 @@ namespace SabreTools.Helper.Dats
RecalculateStats();
}
BucketByGame(false, true, logger, false);
BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, norename: true);
if (TotalSize < 0)
{
TotalSize = Int64.MaxValue + TotalSize;
@@ -387,7 +387,7 @@ namespace SabreTools.Helper.Dats
List<string> games = new List<string>();
DatFile datdata = new DatFile();
datdata.Parse(filename.Item1, 0, 0, logger);
datdata.BucketByGame(false, true, logger, false);
datdata.BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, norename: true);
// Output single DAT stats (if asked)
logger.User("Adding stats for file '" + filename.Item1 + "'\n", false);

View File

@@ -109,7 +109,7 @@ namespace SabreTools.Helper.Dats
}
// Bucket roms by game name and optionally dedupe
BucketByGame(MergeRoms, norename, logger);
BucketBy(SortedBy.Game, MergeRoms, logger, norename: norename);
// Filter the DAT by 1G1R rules, if we're supposed to
// TODO: Create 1G1R logic before write