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.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);
}
}

View File

@@ -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
/// <summary>
/// This file represents all methods related to populating a DatFile
/// from a set of files and directories
/// </summary>
public class DirFromDat
{
#region Logging

View File

@@ -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
/// <summary>
/// Logging object
/// </summary>
private static readonly Logger logger = new Logger();
#endregion
/// <summary>
/// Apply cleaning methods to the DatFile
/// </summary>

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;