diff --git a/RombaSharp/Features/Archive.cs b/RombaSharp/Features/Archive.cs
index ab2bc023..7986853a 100644
--- a/RombaSharp/Features/Archive.cs
+++ b/RombaSharp/Features/Archive.cs
@@ -193,7 +193,6 @@ have a current entry in the DAT index.";
onlyDirs,
outDir: _depots.Keys.ToList()[0],
outputFormat: OutputFormat.TorrentGzipRomba,
- updateDat: false,
asFiles: TreatAsFiles.AaruFormats | TreatAsFiles.CHDs);
}
}
diff --git a/RombaSharp/Features/Build.cs b/RombaSharp/Features/Build.cs
index 0076458c..5dd26670 100644
--- a/RombaSharp/Features/Build.cs
+++ b/RombaSharp/Features/Build.cs
@@ -67,8 +67,7 @@ structure according to the original DAT master directory tree structure.";
datFile.RebuildDepot(
onlineDepots,
outDir: outputFolder,
- outputFormat: (copy ? OutputFormat.TorrentGzipRomba : OutputFormat.TorrentZip),
- updateDat: false);
+ outputFormat: (copy ? OutputFormat.TorrentGzipRomba : OutputFormat.TorrentZip));
}
}
}
diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index 774c1719..08aebc22 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -2337,7 +2337,6 @@ namespace SabreTools.Library.DatFiles
/// True if input files should be deleted, false otherwise
/// True if the DAT should be used as a filter instead of a template, false otherwise
/// Output format that files should be written to
- /// True if the updated DAT should be output, false otherwise
/// True if rebuilding was a success, false otherwise
public bool RebuildDepot(
List inputs,
@@ -2345,8 +2344,7 @@ namespace SabreTools.Library.DatFiles
bool date = false,
bool delete = false,
bool inverse = false,
- OutputFormat outputFormat = OutputFormat.Folder,
- bool updateDat = true)
+ OutputFormat outputFormat = OutputFormat.Folder)
{
#region Perform setup
@@ -2445,11 +2443,11 @@ namespace SabreTools.Library.DatFiles
// Otherwise, we rebuild that file to all locations that we need to
bool usedInternally;
if (Items[hash][0].ItemType == ItemType.Disk)
- usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
+ usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, date, inverse, outputFormat, false /* isZip */);
else if (Items[hash][0].ItemType == ItemType.Media)
- usedInternally = RebuildIndividualFile(new Media(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
+ usedInternally = RebuildIndividualFile(new Media(fileinfo), foundpath, outDir, date, inverse, outputFormat, false /* isZip */);
else
- usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
+ usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, date, inverse, outputFormat, false /* isZip */);
// If we are supposed to delete the depot file, do so
if (delete && usedInternally)
@@ -2460,16 +2458,6 @@ namespace SabreTools.Library.DatFiles
#endregion
- // If we're updating the DAT, output to the rebuild directory
- if (updateDat)
- {
- Header.FileName = $"fixDAT_{Header.FileName}";
- Header.Name = $"fixDAT_{Header.Name}";
- Header.Description = $"fixDAT_{Header.Description}";
- Items.ClearMarked();
- Write(outDir);
- }
-
return success;
}
@@ -2483,7 +2471,6 @@ namespace SabreTools.Library.DatFiles
/// True if input files should be deleted, false otherwise
/// True if the DAT should be used as a filter instead of a template, false otherwise
/// Output format that files should be written to
- /// True if the updated DAT should be output, false otherwise
/// TreatAsFiles representing special format scanning
/// True if rebuilding was a success, false otherwise
public bool RebuildGeneric(
@@ -2494,7 +2481,6 @@ namespace SabreTools.Library.DatFiles
bool delete = false,
bool inverse = false,
OutputFormat outputFormat = OutputFormat.Folder,
- bool updateDat = true,
TreatAsFiles asFiles = 0x00)
{
#region Perform setup
@@ -2536,7 +2522,7 @@ namespace SabreTools.Library.DatFiles
if (File.Exists(input))
{
Globals.Logger.User($"Checking file: {input}");
- RebuildGenericHelper(input, outDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
+ RebuildGenericHelper(input, outDir, quickScan, date, delete, inverse, outputFormat, asFiles);
}
// If the input is a directory
@@ -2546,7 +2532,7 @@ namespace SabreTools.Library.DatFiles
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
Globals.Logger.User($"Checking file: {file}");
- RebuildGenericHelper(file, outDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
+ RebuildGenericHelper(file, outDir, quickScan, date, delete, inverse, outputFormat, asFiles);
}
}
}
@@ -2555,16 +2541,6 @@ namespace SabreTools.Library.DatFiles
#endregion
- // If we're updating the DAT, output to the rebuild directory
- if (updateDat)
- {
- Header.FileName = $"fixDAT_{Header.FileName}";
- Header.Name = $"fixDAT_{Header.Name}";
- Header.Description = $"fixDAT_{Header.Description}";
- Items.ClearMarked();
- Write(outDir);
- }
-
return success;
}
@@ -2578,7 +2554,6 @@ namespace SabreTools.Library.DatFiles
/// True if input files should be deleted, false otherwise
/// True if the DAT should be used as a filter instead of a template, false otherwise
/// Output format that files should be written to
- /// True if the updated DAT should be output, false otherwise
/// TreatAsFiles representing special format scanning
private void RebuildGenericHelper(
string file,
@@ -2588,7 +2563,6 @@ namespace SabreTools.Library.DatFiles
bool delete,
bool inverse,
OutputFormat outputFormat,
- bool updateDat,
TreatAsFiles asFiles)
{
// If we somehow have a null filename, return
@@ -2632,7 +2606,7 @@ namespace SabreTools.Library.DatFiles
else if (internalFileInfo.Type == FileType.None)
internalDatItem = new Rom(internalFileInfo);
- usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, null /* isZip */);
+ usedExternally = RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, null /* isZip */);
}
// Otherwise, loop through the entries and try to match
else
@@ -2640,7 +2614,7 @@ namespace SabreTools.Library.DatFiles
foreach (BaseFile entry in entries)
{
DatItem internalDatItem = DatItem.Create(entry);
- usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, updateDat, !isTorrentGzip /* isZip */);
+ usedInternally |= RebuildIndividualFile(internalDatItem, file, outDir, date, inverse, outputFormat, !isTorrentGzip /* isZip */);
}
}
@@ -2658,7 +2632,6 @@ namespace SabreTools.Library.DatFiles
/// True if the date from the DAT should be used if available, false otherwise
/// True if the DAT should be used as a filter instead of a template, false otherwise
/// Output format that files should be written to
- /// True if the updated DAT should be output, false otherwise
/// True if the input file is an archive, false if the file is TGZ, null otherwise
/// True if the file was able to be rebuilt, false otherwise
private bool RebuildIndividualFile(
@@ -2668,7 +2641,6 @@ namespace SabreTools.Library.DatFiles
bool date,
bool inverse,
OutputFormat outputFormat,
- bool updateDat,
bool? isZip)
{
// Set the initial output value
@@ -2693,7 +2665,7 @@ namespace SabreTools.Library.DatFiles
string sha1 = (datItem as Rom).SHA1 ?? string.Empty;
// Find if the file has duplicates in the DAT
- List dupes = Items.GetDuplicates(datItem, remove: updateDat);
+ List dupes = Items.GetDuplicates(datItem);
bool hasDuplicates = dupes.Count > 0;
// If either we have duplicates or we're filtering
@@ -2867,7 +2839,7 @@ namespace SabreTools.Library.DatFiles
Rom headerless = new Rom(transformStream.GetInfo(keepReadOpen: true));
// Find if the file has duplicates in the DAT
- dupes = Items.GetDuplicates(headerless, remove: updateDat);
+ dupes = Items.GetDuplicates(headerless);
hasDuplicates = dupes.Count > 0;
// If it has duplicates and we're not filtering, rebuild it
@@ -2977,8 +2949,8 @@ namespace SabreTools.Library.DatFiles
continue;
// Now we want to remove all duplicates from the DAT
- Items.GetDuplicates(new Rom(fileinfo), remove: true)
- .AddRange(Items.GetDuplicates(new Disk(fileinfo), remove: true));
+ Items.GetDuplicates(new Rom(fileinfo))
+ .AddRange(Items.GetDuplicates(new Disk(fileinfo)));
}
watch.Stop();
diff --git a/SabreTools.Library/DatFiles/ItemDictionary.cs b/SabreTools.Library/DatFiles/ItemDictionary.cs
index 60179f49..53fc4033 100644
--- a/SabreTools.Library/DatFiles/ItemDictionary.cs
+++ b/SabreTools.Library/DatFiles/ItemDictionary.cs
@@ -782,10 +782,9 @@ namespace SabreTools.Library.DatFiles
/// List all duplicates found in a DAT based on a DatItem
///
/// Item to try to match
- /// True to mark matched roms for removal from the input, false otherwise (default)
/// True if the DAT is already sorted accordingly, false otherwise (default)
/// List of matched DatItem objects
- public List GetDuplicates(DatItem datItem, bool remove = false, bool sorted = false)
+ public List GetDuplicates(DatItem datItem, bool sorted = false)
{
List output = new List();
@@ -806,6 +805,8 @@ namespace SabreTools.Library.DatFiles
for (int i = 0; i < roms.Count; i++)
{
DatItem other = roms[i];
+ if (other.Remove)
+ continue;
if (datItem.Equals(other))
{
@@ -818,13 +819,10 @@ namespace SabreTools.Library.DatFiles
}
}
- // If we're in removal mode, add back all roms with the proper flags
- if (remove)
- {
- Remove(key);
- AddRange(key, output);
- AddRange(key, left);
- }
+ // Add back all roms with the proper flags
+ Remove(key);
+ AddRange(key, output);
+ AddRange(key, left);
return output;
}
diff --git a/SabreTools/Features/Sort.cs b/SabreTools/Features/Sort.cs
index afeee244..380be3a3 100644
--- a/SabreTools/Features/Sort.cs
+++ b/SabreTools/Features/Sort.cs
@@ -101,10 +101,21 @@ namespace SabreTools.Features
datdata.Header.HeaderSkipper = Header.HeaderSkipper;
// If we have the depot flag, respect it
+ bool success;
if (Header.InputDepot?.IsActive ?? false)
- datdata.RebuildDepot(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat, updateDat);
+ success = datdata.RebuildDepot(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), date, delete, inverse, outputFormat);
else
- datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
+ success = datdata.RebuildGeneric(Inputs, Path.Combine(OutputDir, datdata.Header.FileName), quickScan, date, delete, inverse, outputFormat, asFiles);
+
+ // If we have a success and we're updating the DAT, write it out
+ if (success && updateDat)
+ {
+ datdata.Header.FileName = $"fixDAT_{Header.FileName}";
+ datdata.Header.Name = $"fixDAT_{Header.Name}";
+ datdata.Header.Description = $"fixDAT_{Header.Description}";
+ datdata.Items.ClearMarked();
+ datdata.Write(OutputDir);
+ }
}
}
@@ -131,10 +142,21 @@ namespace SabreTools.Features
watch.Stop();
// If we have the depot flag, respect it
+ bool success;
if (Header.InputDepot?.IsActive ?? false)
- datdata.RebuildDepot(Inputs, OutputDir, date, delete, inverse, outputFormat, updateDat);
+ success = datdata.RebuildDepot(Inputs, OutputDir, date, delete, inverse, outputFormat);
else
- datdata.RebuildGeneric(Inputs, OutputDir, quickScan, date, delete, inverse, outputFormat, updateDat, asFiles);
+ success = datdata.RebuildGeneric(Inputs, OutputDir, quickScan, date, delete, inverse, outputFormat, asFiles);
+
+ // If we have a success and we're updating the DAT, write it out
+ if (success && updateDat)
+ {
+ datdata.Header.FileName = $"fixDAT_{Header.FileName}";
+ datdata.Header.Name = $"fixDAT_{Header.Name}";
+ datdata.Header.Description = $"fixDAT_{Header.Description}";
+ datdata.Items.ClearMarked();
+ datdata.Write(OutputDir);
+ }
}
}
}