From dab6aaddf1a96e43dfa05d2a9fc4ad19ee31b419 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 10 Dec 2020 14:11:35 -0800 Subject: [PATCH] Modification to own class --- RombaSharp/Features/Dir2Dat.cs | 2 +- SabreTools.DatFiles/DirFromDat.cs | 7 ++-- .../{DatTool.Filtering.cs => Modification.cs} | 12 ++++++- SabreTools/Features/Batch.cs | 18 +++++----- SabreTools/Features/DatFromDir.cs | 8 ++--- SabreTools/Features/Update.cs | 34 +++++++++---------- SabreTools/Features/Verify.cs | 16 ++++----- 7 files changed, 54 insertions(+), 43 deletions(-) rename SabreTools.DatFiles/{DatTool.Filtering.cs => Modification.cs} (99%) diff --git a/RombaSharp/Features/Dir2Dat.cs b/RombaSharp/Features/Dir2Dat.cs index e1013624..3ca647d6 100644 --- a/RombaSharp/Features/Dir2Dat.cs +++ b/RombaSharp/Features/Dir2Dat.cs @@ -54,7 +54,7 @@ namespace RombaSharp.Features datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name; datfile.Header.Description = description; DirFromDat.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive); - DatTool.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }); + Modification.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }); Writer.Write(datfile, outdat); } } diff --git a/SabreTools.DatFiles/DirFromDat.cs b/SabreTools.DatFiles/DirFromDat.cs index 665751ff..02f269c0 100644 --- a/SabreTools.DatFiles/DirFromDat.cs +++ b/SabreTools.DatFiles/DirFromDat.cs @@ -10,11 +10,12 @@ using SabreTools.FileTypes; using SabreTools.IO; using SabreTools.Logging; -// This file represents all methods related to populating a DatFile -// from a set of files and directories namespace SabreTools.DatFiles { - // TODO: See if any of the methods can be broken up a bit more neatly + /// + /// This file represents all methods related to populating a DatFile + /// from a set of files and directories + /// public class DirFromDat { #region Logging diff --git a/SabreTools.DatFiles/DatTool.Filtering.cs b/SabreTools.DatFiles/Modification.cs similarity index 99% rename from SabreTools.DatFiles/DatTool.Filtering.cs rename to SabreTools.DatFiles/Modification.cs index 42652f08..06e07dc9 100644 --- a/SabreTools.DatFiles/DatTool.Filtering.cs +++ b/SabreTools.DatFiles/Modification.cs @@ -10,12 +10,22 @@ using SabreTools.Core; using SabreTools.DatItems; using SabreTools.Filtering; using SabreTools.IO; +using SabreTools.Logging; // This file represents all methods related to the Filtering namespace namespace SabreTools.DatFiles { - public partial class DatTool + public class Modification { + #region Logging + + /// + /// Logging object + /// + private static readonly Logger logger = new Logger(); + + #endregion + /// /// Apply cleaning methods to the DatFile /// diff --git a/SabreTools/Features/Batch.cs b/SabreTools/Features/Batch.cs index 974f639c..2f116655 100644 --- a/SabreTools/Features/Batch.cs +++ b/SabreTools/Features/Batch.cs @@ -160,7 +160,7 @@ Reset the internal state: reset();"; // TODO: We might not want to remove dates in the future Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }; dfdCleaner.ExcludeFields.Add(Field.DatItem_Date); - DatTool.ApplyCleaning(datFile, dfdCleaner); + Modification.ApplyCleaning(datFile, dfdCleaner); break; @@ -205,7 +205,7 @@ Reset the internal state: reset();"; filter.SetFilter(filterField, filterValue, filterRemove.Value); // Apply the filter blindly - DatTool.ApplyFilter(datFile, filter, filterPerMachine.Value); + Modification.ApplyFilter(datFile, filter, filterPerMachine.Value); // Cleanup after the filter // TODO: We might not want to remove immediately @@ -247,7 +247,7 @@ Reset the internal state: reset();"; extraIni.Items.Add(extraIniItem); // Apply the extra INI blindly - DatTool.ApplyExtras(datFile, extraIni); + Modification.ApplyExtras(datFile, extraIni); break; @@ -271,7 +271,7 @@ Reset the internal state: reset();"; } // Apply the merging flag - DatTool.ApplySplitting(datFile, mergingFlag, false); + Modification.ApplySplitting(datFile, mergingFlag, false); break; @@ -285,7 +285,7 @@ Reset the internal state: reset();"; } // Apply the logic - DatTool.MachineDescriptionToName(datFile); + Modification.MachineDescriptionToName(datFile); break; @@ -299,7 +299,7 @@ Reset the internal state: reset();"; } // Run the 1G1R functionality - DatTool.OneGamePerRegion(datFile, command.Arguments); + Modification.OneGamePerRegion(datFile, command.Arguments); break; @@ -313,7 +313,7 @@ Reset the internal state: reset();"; } // Apply the logic - DatTool.OneRomPerGame(datFile); + Modification.OneRomPerGame(datFile); break; @@ -327,7 +327,7 @@ Reset the internal state: reset();"; } // Run the removal functionality - DatTool.RemoveFieldsFromItems(datFile, command.Arguments.Select(s => s.AsField()).ToList()); + Modification.RemoveFieldsFromItems(datFile, command.Arguments.Select(s => s.AsField()).ToList()); break; @@ -341,7 +341,7 @@ Reset the internal state: reset();"; } // Apply the logic - DatTool.StripSceneDatesFromItems(datFile); + Modification.StripSceneDatesFromItems(datFile); break; diff --git a/SabreTools/Features/DatFromDir.cs b/SabreTools/Features/DatFromDir.cs index efd9d40b..236fab48 100644 --- a/SabreTools/Features/DatFromDir.cs +++ b/SabreTools/Features/DatFromDir.cs @@ -100,10 +100,10 @@ namespace SabreTools.Features if (success) { // Perform additional processing steps - DatTool.ApplyExtras(datdata, Extras); - DatTool.ApplySplitting(datdata, splitType, false); - DatTool.ApplyFilter(datdata, Filter); - DatTool.ApplyCleaning(datdata, Cleaner); + Modification.ApplyExtras(datdata, Extras); + Modification.ApplySplitting(datdata, splitType, false); + Modification.ApplyFilter(datdata, Filter); + Modification.ApplyCleaning(datdata, Cleaner); // Write out the file Writer.Write(datdata, OutputDir); diff --git a/SabreTools/Features/Update.cs b/SabreTools/Features/Update.cs index 73ec01ab..ae4b1e23 100644 --- a/SabreTools/Features/Update.cs +++ b/SabreTools/Features/Update.cs @@ -167,10 +167,10 @@ namespace SabreTools.Features || datFile.Header.DatFormat.HasFlag(DatFormat.SSV)); // Perform additional processing steps - DatTool.ApplyExtras(datFile, Extras); - DatTool.ApplySplitting(datFile, GetSplitType(features), false); - DatTool.ApplyFilter(datFile, Filter); - DatTool.ApplyCleaning(datFile, Cleaner); + Modification.ApplyExtras(datFile, Extras); + Modification.ApplySplitting(datFile, GetSplitType(features), false); + Modification.ApplyFilter(datFile, Filter); + Modification.ApplyCleaning(datFile, Cleaner); // Get the correct output path string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue)); @@ -205,10 +205,10 @@ namespace SabreTools.Features datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths); // Perform additional processing steps - DatTool.ApplyExtras(userInputDat, Extras); - DatTool.ApplySplitting(userInputDat, GetSplitType(features), false); - DatTool.ApplyFilter(userInputDat, Filter); - DatTool.ApplyCleaning(userInputDat, Cleaner); + Modification.ApplyExtras(userInputDat, Extras); + Modification.ApplySplitting(userInputDat, GetSplitType(features), false); + Modification.ApplyFilter(userInputDat, Filter); + Modification.ApplyCleaning(userInputDat, Cleaner); // Output only DatItems that are duplicated across inputs if (updateMode.HasFlag(UpdateMode.DiffDupesOnly)) @@ -297,10 +297,10 @@ namespace SabreTools.Features Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true); // Perform additional processing steps - DatTool.ApplyExtras(repDat, Extras); - DatTool.ApplySplitting(repDat, GetSplitType(features), false); - DatTool.ApplyFilter(repDat, Filter); - DatTool.ApplyCleaning(repDat, Cleaner); + Modification.ApplyExtras(repDat, Extras); + Modification.ApplySplitting(repDat, GetSplitType(features), false); + Modification.ApplyFilter(repDat, Filter); + Modification.ApplyCleaning(repDat, Cleaner); // Now replace the fields from the base DatFile DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue)); @@ -322,10 +322,10 @@ namespace SabreTools.Features Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true); // Perform additional processing steps - DatTool.ApplyExtras(repDat, Extras); - DatTool.ApplySplitting(repDat, GetSplitType(features), false); - DatTool.ApplyFilter(repDat, Filter); - DatTool.ApplyCleaning(repDat, Cleaner); + Modification.ApplyExtras(repDat, Extras); + Modification.ApplySplitting(repDat, GetSplitType(features), false); + Modification.ApplyFilter(repDat, Filter); + Modification.ApplyCleaning(repDat, Cleaner); // Now replace the fields from the base DatFile DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue)); @@ -342,7 +342,7 @@ namespace SabreTools.Features { // If we're in SuperDAT mode, prefix all games with their respective DATs if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase)) - DatTool.ApplySuperDAT(userInputDat, inputPaths); + Modification.ApplySuperDAT(userInputDat, inputPaths); Writer.Write(userInputDat, OutputDir); } diff --git a/SabreTools/Features/Verify.cs b/SabreTools/Features/Verify.cs index 68857b4f..9fc2491c 100644 --- a/SabreTools/Features/Verify.cs +++ b/SabreTools/Features/Verify.cs @@ -61,10 +61,10 @@ namespace SabreTools.Features Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true); // Perform additional processing steps - DatTool.ApplyExtras(datdata, Extras); - DatTool.ApplySplitting(datdata, splitType, true); - DatTool.ApplyFilter(datdata, Filter); - DatTool.ApplyCleaning(datdata, Cleaner); + Modification.ApplyExtras(datdata, Extras); + Modification.ApplySplitting(datdata, splitType, true); + Modification.ApplyFilter(datdata, Filter); + Modification.ApplyCleaning(datdata, Cleaner); // Set depot information datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; @@ -108,10 +108,10 @@ namespace SabreTools.Features } // Perform additional processing steps - DatTool.ApplyExtras(datdata, Extras); - DatTool.ApplySplitting(datdata, splitType, true); - DatTool.ApplyFilter(datdata, Filter); - DatTool.ApplyCleaning(datdata, Cleaner); + Modification.ApplyExtras(datdata, Extras); + Modification.ApplySplitting(datdata, splitType, true); + Modification.ApplyFilter(datdata, Filter); + Modification.ApplyCleaning(datdata, Cleaner); // Set depot information datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;