mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatTools] Add flag usage to Diff
This commit is contained in:
@@ -1603,7 +1603,7 @@ namespace SabreTools.Helper
|
|||||||
// Modify the Dictionary if necessary and output the results
|
// Modify the Dictionary if necessary and output the results
|
||||||
if (diff != 0 && cascade == null)
|
if (diff != 0 && cascade == null)
|
||||||
{
|
{
|
||||||
DiffNoCascade(outputDirectory, userData, newInputFileNames, logger);
|
DiffNoCascade(diff, outputDirectory, userData, newInputFileNames, logger);
|
||||||
}
|
}
|
||||||
// If we're in cascade and diff, output only cascaded diffs
|
// If we're in cascade and diff, output only cascaded diffs
|
||||||
else if (diff != 0 && cascade != null)
|
else if (diff != 0 && cascade != null)
|
||||||
@@ -1924,41 +1924,56 @@ namespace SabreTools.Helper
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Output non-cascading diffs
|
/// Output non-cascading diffs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="diff">Non-zero flag for diffing mode, zero otherwise</param>
|
||||||
/// <param name="outdir">Output directory to write the DATs to</param>
|
/// <param name="outdir">Output directory to write the DATs to</param>
|
||||||
/// <param name="userData">Main DatData to draw information from</param>
|
/// <param name="userData">Main DatData to draw information from</param>
|
||||||
/// <param name="inputs">List of inputs to write out from</param>
|
/// <param name="inputs">List of inputs to write out from</param>
|
||||||
/// <param name="logger">Logging object for console and file output</param>
|
/// <param name="logger">Logging object for console and file output</param>
|
||||||
public static void DiffNoCascade(string outdir, Dat userData, List<string> inputs, Logger logger)
|
public static void DiffNoCascade(DiffMode diff, string outdir, Dat userData, List<string> inputs, Logger logger)
|
||||||
{
|
{
|
||||||
DateTime start = DateTime.Now;
|
DateTime start = DateTime.Now;
|
||||||
logger.User("Initializing all output DATs");
|
logger.User("Initializing all output DATs");
|
||||||
|
|
||||||
|
// Default vars for use
|
||||||
|
string post = "";
|
||||||
|
Dat outerDiffData = new Dat();
|
||||||
|
Dat dupeData = new Dat();
|
||||||
|
|
||||||
// Don't have External dupes
|
// Don't have External dupes
|
||||||
string post = " (No Duplicates)";
|
if ((diff & DiffMode.NoDupes) != 0)
|
||||||
Dat outerDiffData = (Dat)userData.CloneHeader();
|
{
|
||||||
outerDiffData.FileName += post;
|
post = " (No Duplicates)";
|
||||||
outerDiffData.Name += post;
|
outerDiffData = (Dat)userData.CloneHeader();
|
||||||
outerDiffData.Description += post;
|
outerDiffData.FileName += post;
|
||||||
|
outerDiffData.Name += post;
|
||||||
|
outerDiffData.Description += post;
|
||||||
|
}
|
||||||
|
|
||||||
// Have External dupes
|
// Have External dupes
|
||||||
post = " (Duplicates)";
|
if ((diff & DiffMode.Dupes) != 0)
|
||||||
Dat dupeData = (Dat)userData.CloneHeader();
|
{
|
||||||
dupeData.FileName += post;
|
post = " (Duplicates)";
|
||||||
dupeData.Name += post;
|
dupeData = (Dat)userData.CloneHeader();
|
||||||
dupeData.Description += post;
|
dupeData.FileName += post;
|
||||||
|
dupeData.Name += post;
|
||||||
|
dupeData.Description += post;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a list of DatData objects representing individual output files
|
// Create a list of DatData objects representing individual output files
|
||||||
List<Dat> outDats = new List<Dat>();
|
List<Dat> outDats = new List<Dat>();
|
||||||
|
|
||||||
// Loop through each of the inputs and get or create a new DatData object
|
// Loop through each of the inputs and get or create a new DatData object
|
||||||
for (int j = 0; j < inputs.Count; j++)
|
if ((diff & DiffMode.Individuals) != 0)
|
||||||
{
|
{
|
||||||
post = " (" + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
for (int j = 0; j < inputs.Count; j++)
|
||||||
Dat diffData = (Dat)userData.CloneHeader();
|
{
|
||||||
diffData.FileName += post;
|
post = " (" + Path.GetFileNameWithoutExtension(inputs[j].Split('¬')[0]) + " Only)";
|
||||||
diffData.Name += post;
|
Dat diffData = (Dat)userData.CloneHeader();
|
||||||
diffData.Description += post;
|
diffData.FileName += post;
|
||||||
outDats.Add(diffData);
|
diffData.Name += post;
|
||||||
|
diffData.Description += post;
|
||||||
|
outDats.Add(diffData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
|
||||||
|
|
||||||
@@ -1975,51 +1990,63 @@ namespace SabreTools.Helper
|
|||||||
foreach (Rom rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
// No duplicates
|
// No duplicates
|
||||||
if (rom.Dupe < DupeType.ExternalHash)
|
if ((diff & DiffMode.NoDupes) != 0 || (diff & DiffMode.Individuals) != 0)
|
||||||
{
|
{
|
||||||
// Individual DATs that are output
|
if (rom.Dupe < DupeType.ExternalHash)
|
||||||
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
|
|
||||||
{
|
{
|
||||||
outDats[rom.Metadata.SystemID].Roms[key].Add(rom);
|
// Individual DATs that are output
|
||||||
}
|
if ((diff & DiffMode.Individuals) != 0)
|
||||||
else
|
{
|
||||||
{
|
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
|
||||||
List<Rom> tl = new List<Rom>();
|
{
|
||||||
tl.Add(rom);
|
outDats[rom.Metadata.SystemID].Roms[key].Add(rom);
|
||||||
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
List<Rom> tl = new List<Rom>();
|
||||||
|
tl.Add(rom);
|
||||||
|
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Merged no-duplicates DAT
|
// Merged no-duplicates DAT
|
||||||
Rom newrom = rom;
|
if ((diff & DiffMode.NoDupes) != 0)
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
{
|
||||||
|
Rom newrom = rom;
|
||||||
|
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (outerDiffData.Roms.ContainsKey(key))
|
if (outerDiffData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
outerDiffData.Roms[key].Add(newrom);
|
outerDiffData.Roms[key].Add(newrom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Rom> tl = new List<Rom>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outerDiffData.Roms.Add(key, tl);
|
outerDiffData.Roms.Add(key, tl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicates only
|
// Duplicates only
|
||||||
if (rom.Dupe >= DupeType.ExternalHash)
|
if ((diff & DiffMode.Dupes) != 0)
|
||||||
{
|
{
|
||||||
Rom newrom = rom;
|
if (rom.Dupe >= DupeType.ExternalHash)
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
{
|
||||||
|
Rom newrom = rom;
|
||||||
|
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (dupeData.Roms.ContainsKey(key))
|
if (dupeData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
dupeData.Roms[key].Add(newrom);
|
dupeData.Roms[key].Add(newrom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Rom> tl = new List<Rom>();
|
List<Rom> tl = new List<Rom>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
dupeData.Roms.Add(key, tl);
|
dupeData.Roms.Add(key, tl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user