mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Move output to the proper place
This commit is contained in:
@@ -405,7 +405,7 @@ namespace RombaSharp
|
|||||||
// First get a list of SHA-1's from the input DATs
|
// First get a list of SHA-1's from the input DATs
|
||||||
DatFile datroot = new DatFile { Type = "SuperDAT", };
|
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.PopulateFromDir(_dats, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, false, false, false, _tmpdir, false, null, 4, _logger);
|
||||||
datroot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
datroot.BucketBy(SortedBy.SHA1, false /* mergeroms */, _logger);
|
||||||
|
|
||||||
// Create a List of dat hashes in the database (SHA-1)
|
// Create a List of dat hashes in the database (SHA-1)
|
||||||
List<string> databaseDats = new List<string>();
|
List<string> databaseDats = new List<string>();
|
||||||
@@ -435,7 +435,7 @@ namespace RombaSharp
|
|||||||
unneeded.Add(hash);
|
unneeded.Add(hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
datroot.BucketBy(SortedBy.Game, false /* mergeroms */, _logger, output: false, norename: true);
|
datroot.BucketBy(SortedBy.Game, false /* mergeroms */, _logger, norename: true);
|
||||||
|
|
||||||
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
_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
|
// Now rescan the depot itself
|
||||||
DatFile depot = new DatFile();
|
DatFile depot = new DatFile();
|
||||||
depot.PopulateFromDir(depotname, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, true, false, false, _tmpdir, false, null, _workers, _logger);
|
depot.PopulateFromDir(depotname, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, true, false, false, _tmpdir, false, null, _workers, _logger);
|
||||||
depot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
depot.BucketBy(SortedBy.SHA1, false /* mergeroms */, _logger);
|
||||||
|
|
||||||
// Set the base queries to use
|
// Set the base queries to use
|
||||||
string crcquery = "INSERT OR IGNORE INTO crc (crc) VALUES";
|
string crcquery = "INSERT OR IGNORE INTO crc (crc) VALUES";
|
||||||
|
|||||||
@@ -438,9 +438,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the number of keys in the file dictionary
|
/// Get the number of DatItems in the file dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Number of keys in the file dictionary</returns>
|
/// <returns>Number of DatItems in the file dictionary</returns>
|
||||||
public long Count
|
public long Count
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -345,12 +345,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (_itemType == ItemType.Rom)
|
if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).SHA512;
|
key = ((Rom)this).SHA512;
|
||||||
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)this).SHA512;
|
key = ((Disk)this).SHA512;
|
||||||
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,12 +362,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (_itemType == ItemType.Rom)
|
if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).SHA384;
|
key = ((Rom)this).SHA384;
|
||||||
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)this).SHA384;
|
key = ((Disk)this).SHA384;
|
||||||
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,12 +379,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (_itemType == ItemType.Rom)
|
if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).SHA256;
|
key = ((Rom)this).SHA256;
|
||||||
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)this).SHA256;
|
key = ((Disk)this).SHA256;
|
||||||
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,12 +396,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (_itemType == ItemType.Rom)
|
if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).SHA1;
|
key = ((Rom)this).SHA1;
|
||||||
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)this).SHA1;
|
key = ((Disk)this).SHA1;
|
||||||
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,12 +413,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (_itemType == ItemType.Rom)
|
if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).MD5;
|
key = ((Rom)this).MD5;
|
||||||
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)this).MD5;
|
key = ((Disk)this).MD5;
|
||||||
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,21 +426,21 @@ namespace SabreTools.Helper.Dats
|
|||||||
else if (_itemType == ItemType.Disk)
|
else if (_itemType == ItemType.Disk)
|
||||||
{
|
{
|
||||||
key = ((Disk)this).MD5;
|
key = ((Disk)this).MD5;
|
||||||
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've gotten here and we have a Rom, sort by CRC
|
// If we've gotten here and we have a Rom, sort by CRC
|
||||||
else if (_itemType == ItemType.Rom)
|
else if (_itemType == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)this).CRC;
|
key = ((Rom)this).CRC;
|
||||||
datdata.BucketBy(SortedBy.CRC, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.CRC, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we use -1 as the key
|
// Otherwise, we use -1 as the key
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = "-1";
|
key = "-1";
|
||||||
datdata.BucketBy(SortedBy.Size, false /* mergeroms */, logger, output: false);
|
datdata.BucketBy(SortedBy.Size, false /* mergeroms */, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// <param name="bucketBy">SortedBy enum representing how to sort the individual items</param>
|
/// <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="mergeroms">True if roms should be deduped, false otherwise</param>
|
||||||
/// <param name="logger">Logger object for file and console output</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 key should be lowercased (default), 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="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
|
||||||
public void BucketBy(SortedBy bucketBy, bool mergeroms, Logger logger, bool output = true, bool lower = true, bool norename = true)
|
public void BucketBy(SortedBy bucketBy, bool mergeroms, Logger logger, bool lower = true, bool norename = true)
|
||||||
{
|
{
|
||||||
// If we already have the right sorting, trust it
|
// If we already have the right sorting, trust it
|
||||||
if (_sortedBy == bucketBy)
|
if (_sortedBy == bucketBy)
|
||||||
@@ -34,8 +33,8 @@ namespace SabreTools.Helper.Dats
|
|||||||
// Set the sorted type
|
// Set the sorted type
|
||||||
_sortedBy = bucketBy;
|
_sortedBy = bucketBy;
|
||||||
|
|
||||||
|
// Create the temporary dictionary to sort into
|
||||||
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
|
SortedDictionary<string, List<DatItem>> sortable = new SortedDictionary<string, List<DatItem>>();
|
||||||
long count = 0;
|
|
||||||
|
|
||||||
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by " + bucketBy);
|
logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by " + bucketBy);
|
||||||
|
|
||||||
@@ -55,7 +54,6 @@ namespace SabreTools.Helper.Dats
|
|||||||
// Now add each of the roms to their respective games
|
// Now add each of the roms to their respective games
|
||||||
foreach (DatItem rom in roms)
|
foreach (DatItem rom in roms)
|
||||||
{
|
{
|
||||||
count++;
|
|
||||||
string newkey = "";
|
string newkey = "";
|
||||||
|
|
||||||
switch (bucketBy)
|
switch (bucketBy)
|
||||||
@@ -137,12 +135,6 @@ namespace SabreTools.Helper.Dats
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Output the count if told to
|
|
||||||
if (output)
|
|
||||||
{
|
|
||||||
logger.User("A total of " + count + " items will be written out to file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now assign the dictionary back
|
// Now assign the dictionary back
|
||||||
_files = sortable;
|
_files = sortable;
|
||||||
}
|
}
|
||||||
@@ -156,13 +148,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mergeroms">True if roms should be deduped, false otherwise</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="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 CreateFullyNonMergedSets(bool mergeroms, Logger logger)
|
||||||
public void CreateFullyNonMergedSets(bool mergeroms, Logger logger, bool output = true)
|
|
||||||
{
|
{
|
||||||
logger.User("Creating fully non-merged sets from the DAT");
|
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
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
|
BucketBy(SortedBy.Game, mergeroms, logger, norename: true);
|
||||||
_sortedBy = SortedBy.Default;
|
_sortedBy = SortedBy.Default;
|
||||||
|
|
||||||
// Now we want to loop through all of the games and set the correct information
|
// Now we want to loop through all of the games and set the correct information
|
||||||
@@ -184,13 +175,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mergeroms">True if roms should be deduped, false otherwise</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="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 CreateMergedSets(bool mergeroms, Logger logger)
|
||||||
public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true)
|
|
||||||
{
|
{
|
||||||
logger.User("Creating merged sets from the DAT");
|
logger.User("Creating merged sets from the DAT");
|
||||||
|
|
||||||
// For sake of ease, the first thing we want to do is sort by game
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
|
BucketBy(SortedBy.Game, mergeroms, logger, norename: true);
|
||||||
_sortedBy = SortedBy.Default;
|
_sortedBy = SortedBy.Default;
|
||||||
|
|
||||||
// Now we want to loop through all of the games and set the correct information
|
// Now we want to loop through all of the games and set the correct information
|
||||||
@@ -208,13 +198,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mergeroms">True if roms should be deduped, false otherwise</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="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 CreateNonMergedSets(bool mergeroms, Logger logger)
|
||||||
public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true)
|
|
||||||
{
|
{
|
||||||
logger.User("Creating non-merged sets from the DAT");
|
logger.User("Creating non-merged sets from the DAT");
|
||||||
|
|
||||||
// For sake of ease, the first thing we want to do is sort by game
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
|
BucketBy(SortedBy.Game, mergeroms, logger, norename: true);
|
||||||
_sortedBy = SortedBy.Default;
|
_sortedBy = SortedBy.Default;
|
||||||
|
|
||||||
// Now we want to loop through all of the games and set the correct information
|
// Now we want to loop through all of the games and set the correct information
|
||||||
@@ -232,13 +221,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mergeroms">True if roms should be deduped, false otherwise</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="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)
|
||||||
public void CreateSplitSets(bool mergeroms, Logger logger, bool output = true)
|
|
||||||
{
|
{
|
||||||
logger.User("Creating split sets from the DAT");
|
logger.User("Creating split sets from the DAT");
|
||||||
|
|
||||||
// For sake of ease, the first thing we want to do is sort by game
|
// For sake of ease, the first thing we want to do is sort by game
|
||||||
BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true);
|
BucketBy(SortedBy.Game, mergeroms, logger, norename: true);
|
||||||
_sortedBy = SortedBy.Default;
|
_sortedBy = SortedBy.Default;
|
||||||
|
|
||||||
// Now we want to loop through all of the games and set the correct information
|
// Now we want to loop through all of the games and set the correct information
|
||||||
|
|||||||
@@ -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
|
// Now that we have a list of depots, we want to sort the input DAT by SHA-1
|
||||||
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger);
|
||||||
|
|
||||||
// Then we want to loop through each of the hashes and see if we can rebuild
|
// Then we want to loop through each of the hashes and see if we can rebuild
|
||||||
List<string> hashes = Keys.ToList();
|
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
|
// Now that we have a list of depots, we want to sort the input DAT by SHA-1
|
||||||
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger);
|
||||||
|
|
||||||
// Then we want to loop through each of the hashes and see if we can rebuild
|
// Then we want to loop through each of the hashes and see if we can rebuild
|
||||||
List<string> hashes = Keys.ToList();
|
List<string> hashes = Keys.ToList();
|
||||||
@@ -941,7 +941,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
if (hashOnly)
|
if (hashOnly)
|
||||||
{
|
{
|
||||||
// First we need to sort by hash to get duplicates
|
// First we need to sort by hash to get duplicates
|
||||||
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false);
|
BucketBy(SortedBy.SHA1, false /* mergeroms */, logger);
|
||||||
|
|
||||||
// Then follow the same tactics as before
|
// Then follow the same tactics as before
|
||||||
foreach (string key in Keys)
|
foreach (string key in Keys)
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
// Bucket roms by game name and optionally dedupe
|
// Bucket roms by game name and optionally dedupe
|
||||||
BucketBy(SortedBy.Game, MergeRoms, logger, norename: norename);
|
BucketBy(SortedBy.Game, MergeRoms, logger, norename: norename);
|
||||||
|
|
||||||
|
// Output the number of items we're going to be writing
|
||||||
|
logger.User("A total of " + Count + " items will be written out to file");
|
||||||
|
|
||||||
// Filter the DAT by 1G1R rules, if we're supposed to
|
// Filter the DAT by 1G1R rules, if we're supposed to
|
||||||
// TODO: Create 1G1R logic before write
|
// TODO: Create 1G1R logic before write
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user