Modification to own class

This commit is contained in:
Matt Nadareski
2020-12-10 14:11:35 -08:00
parent 8f67c3e525
commit dab6aaddf1
7 changed files with 54 additions and 43 deletions

View File

@@ -54,7 +54,7 @@ namespace RombaSharp.Features
datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name; datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name;
datfile.Header.Description = description; datfile.Header.Description = description;
DirFromDat.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive); 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); Writer.Write(datfile, outdat);
} }
} }

View File

@@ -10,11 +10,12 @@ using SabreTools.FileTypes;
using SabreTools.IO; using SabreTools.IO;
using SabreTools.Logging; using SabreTools.Logging;
// This file represents all methods related to populating a DatFile
// from a set of files and directories
namespace SabreTools.DatFiles namespace SabreTools.DatFiles
{ {
// TODO: See if any of the methods can be broken up a bit more neatly /// <summary>
/// This file represents all methods related to populating a DatFile
/// from a set of files and directories
/// </summary>
public class DirFromDat public class DirFromDat
{ {
#region Logging #region Logging

View File

@@ -10,12 +10,22 @@ using SabreTools.Core;
using SabreTools.DatItems; using SabreTools.DatItems;
using SabreTools.Filtering; using SabreTools.Filtering;
using SabreTools.IO; using SabreTools.IO;
using SabreTools.Logging;
// This file represents all methods related to the Filtering namespace // This file represents all methods related to the Filtering namespace
namespace SabreTools.DatFiles namespace SabreTools.DatFiles
{ {
public partial class DatTool public class Modification
{ {
#region Logging
/// <summary>
/// Logging object
/// </summary>
private static readonly Logger logger = new Logger();
#endregion
/// <summary> /// <summary>
/// Apply cleaning methods to the DatFile /// Apply cleaning methods to the DatFile
/// </summary> /// </summary>

View File

@@ -160,7 +160,7 @@ Reset the internal state: reset();";
// TODO: We might not want to remove dates in the future // TODO: We might not want to remove dates in the future
Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() }; Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() };
dfdCleaner.ExcludeFields.Add(Field.DatItem_Date); dfdCleaner.ExcludeFields.Add(Field.DatItem_Date);
DatTool.ApplyCleaning(datFile, dfdCleaner); Modification.ApplyCleaning(datFile, dfdCleaner);
break; break;
@@ -205,7 +205,7 @@ Reset the internal state: reset();";
filter.SetFilter(filterField, filterValue, filterRemove.Value); filter.SetFilter(filterField, filterValue, filterRemove.Value);
// Apply the filter blindly // Apply the filter blindly
DatTool.ApplyFilter(datFile, filter, filterPerMachine.Value); Modification.ApplyFilter(datFile, filter, filterPerMachine.Value);
// Cleanup after the filter // Cleanup after the filter
// TODO: We might not want to remove immediately // TODO: We might not want to remove immediately
@@ -247,7 +247,7 @@ Reset the internal state: reset();";
extraIni.Items.Add(extraIniItem); extraIni.Items.Add(extraIniItem);
// Apply the extra INI blindly // Apply the extra INI blindly
DatTool.ApplyExtras(datFile, extraIni); Modification.ApplyExtras(datFile, extraIni);
break; break;
@@ -271,7 +271,7 @@ Reset the internal state: reset();";
} }
// Apply the merging flag // Apply the merging flag
DatTool.ApplySplitting(datFile, mergingFlag, false); Modification.ApplySplitting(datFile, mergingFlag, false);
break; break;
@@ -285,7 +285,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
DatTool.MachineDescriptionToName(datFile); Modification.MachineDescriptionToName(datFile);
break; break;
@@ -299,7 +299,7 @@ Reset the internal state: reset();";
} }
// Run the 1G1R functionality // Run the 1G1R functionality
DatTool.OneGamePerRegion(datFile, command.Arguments); Modification.OneGamePerRegion(datFile, command.Arguments);
break; break;
@@ -313,7 +313,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
DatTool.OneRomPerGame(datFile); Modification.OneRomPerGame(datFile);
break; break;
@@ -327,7 +327,7 @@ Reset the internal state: reset();";
} }
// Run the removal functionality // 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; break;
@@ -341,7 +341,7 @@ Reset the internal state: reset();";
} }
// Apply the logic // Apply the logic
DatTool.StripSceneDatesFromItems(datFile); Modification.StripSceneDatesFromItems(datFile);
break; break;

View File

@@ -100,10 +100,10 @@ namespace SabreTools.Features
if (success) if (success)
{ {
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(datdata, Extras); Modification.ApplyExtras(datdata, Extras);
DatTool.ApplySplitting(datdata, splitType, false); Modification.ApplySplitting(datdata, splitType, false);
DatTool.ApplyFilter(datdata, Filter); Modification.ApplyFilter(datdata, Filter);
DatTool.ApplyCleaning(datdata, Cleaner); Modification.ApplyCleaning(datdata, Cleaner);
// Write out the file // Write out the file
Writer.Write(datdata, OutputDir); Writer.Write(datdata, OutputDir);

View File

@@ -167,10 +167,10 @@ namespace SabreTools.Features
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV)); || datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(datFile, Extras); Modification.ApplyExtras(datFile, Extras);
DatTool.ApplySplitting(datFile, GetSplitType(features), false); Modification.ApplySplitting(datFile, GetSplitType(features), false);
DatTool.ApplyFilter(datFile, Filter); Modification.ApplyFilter(datFile, Filter);
DatTool.ApplyCleaning(datFile, Cleaner); Modification.ApplyCleaning(datFile, Cleaner);
// Get the correct output path // Get the correct output path
string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue)); string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
@@ -205,10 +205,10 @@ namespace SabreTools.Features
datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths); datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths);
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(userInputDat, Extras); Modification.ApplyExtras(userInputDat, Extras);
DatTool.ApplySplitting(userInputDat, GetSplitType(features), false); Modification.ApplySplitting(userInputDat, GetSplitType(features), false);
DatTool.ApplyFilter(userInputDat, Filter); Modification.ApplyFilter(userInputDat, Filter);
DatTool.ApplyCleaning(userInputDat, Cleaner); Modification.ApplyCleaning(userInputDat, Cleaner);
// Output only DatItems that are duplicated across inputs // Output only DatItems that are duplicated across inputs
if (updateMode.HasFlag(UpdateMode.DiffDupesOnly)) if (updateMode.HasFlag(UpdateMode.DiffDupesOnly))
@@ -297,10 +297,10 @@ namespace SabreTools.Features
Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true); Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(repDat, Extras); Modification.ApplyExtras(repDat, Extras);
DatTool.ApplySplitting(repDat, GetSplitType(features), false); Modification.ApplySplitting(repDat, GetSplitType(features), false);
DatTool.ApplyFilter(repDat, Filter); Modification.ApplyFilter(repDat, Filter);
DatTool.ApplyCleaning(repDat, Cleaner); Modification.ApplyCleaning(repDat, Cleaner);
// Now replace the fields from the base DatFile // Now replace the fields from the base DatFile
DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue)); DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue));
@@ -322,10 +322,10 @@ namespace SabreTools.Features
Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true); Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(repDat, Extras); Modification.ApplyExtras(repDat, Extras);
DatTool.ApplySplitting(repDat, GetSplitType(features), false); Modification.ApplySplitting(repDat, GetSplitType(features), false);
DatTool.ApplyFilter(repDat, Filter); Modification.ApplyFilter(repDat, Filter);
DatTool.ApplyCleaning(repDat, Cleaner); Modification.ApplyCleaning(repDat, Cleaner);
// Now replace the fields from the base DatFile // Now replace the fields from the base DatFile
DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue)); 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 we're in SuperDAT mode, prefix all games with their respective DATs
if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase)) if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase))
DatTool.ApplySuperDAT(userInputDat, inputPaths); Modification.ApplySuperDAT(userInputDat, inputPaths);
Writer.Write(userInputDat, OutputDir); Writer.Write(userInputDat, OutputDir);
} }

View File

@@ -61,10 +61,10 @@ namespace SabreTools.Features
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true); Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(datdata, Extras); Modification.ApplyExtras(datdata, Extras);
DatTool.ApplySplitting(datdata, splitType, true); Modification.ApplySplitting(datdata, splitType, true);
DatTool.ApplyFilter(datdata, Filter); Modification.ApplyFilter(datdata, Filter);
DatTool.ApplyCleaning(datdata, Cleaner); Modification.ApplyCleaning(datdata, Cleaner);
// Set depot information // Set depot information
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
@@ -108,10 +108,10 @@ namespace SabreTools.Features
} }
// Perform additional processing steps // Perform additional processing steps
DatTool.ApplyExtras(datdata, Extras); Modification.ApplyExtras(datdata, Extras);
DatTool.ApplySplitting(datdata, splitType, true); Modification.ApplySplitting(datdata, splitType, true);
DatTool.ApplyFilter(datdata, Filter); Modification.ApplyFilter(datdata, Filter);
DatTool.ApplyCleaning(datdata, Cleaner); Modification.ApplyCleaning(datdata, Cleaner);
// Set depot information // Set depot information
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation; datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;