mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Writing to actual class
This commit is contained in:
@@ -64,7 +64,7 @@ in -old DAT file. Ignores those entries in -old that are not in -new.";
|
|||||||
// Diff against the new datfile
|
// Diff against the new datfile
|
||||||
DatFile intDat = Parser.CreateAndParse(newdat);
|
DatFile intDat = Parser.CreateAndParse(newdat);
|
||||||
DatTool.DiffAgainst(datfile, intDat, false);
|
DatTool.DiffAgainst(datfile, intDat, false);
|
||||||
DatTool.Write(intDat, outdat);
|
Writer.Write(intDat, outdat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace RombaSharp.Features
|
|||||||
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() });
|
DatTool.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() });
|
||||||
DatTool.Write(datfile, outdat);
|
Writer.Write(datfile, outdat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace RombaSharp.Features
|
|||||||
// Diff against the new datfile
|
// Diff against the new datfile
|
||||||
DatFile intDat = Parser.CreateAndParse(newdat);
|
DatFile intDat = Parser.CreateAndParse(newdat);
|
||||||
DatTool.DiffAgainst(datfile, intDat, false);
|
DatTool.DiffAgainst(datfile, intDat, false);
|
||||||
DatTool.Write(intDat, outdat);
|
Writer.Write(intDat, outdat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ namespace SabreTools.DatFiles
|
|||||||
newDatFile.Header.Type = null;
|
newDatFile.Header.Type = null;
|
||||||
|
|
||||||
// Write out the temporary DAT to the proper directory
|
// Write out the temporary DAT to the proper directory
|
||||||
DatTool.Write(newDatFile, outDir);
|
Writer.Write(newDatFile, outDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,12 +4,22 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.Logging;
|
||||||
|
|
||||||
// This file represents all methods related to writing to a file
|
// This file represents all methods related to writing to a file
|
||||||
namespace SabreTools.DatFiles
|
namespace SabreTools.DatFiles
|
||||||
{
|
{
|
||||||
public partial class DatTool
|
public class Writer
|
||||||
{
|
{
|
||||||
|
#region Logging
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logging object
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Logger logger = new Logger();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and open an output file for writing direct from a dictionary
|
/// Create and open an output file for writing direct from a dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -405,7 +405,7 @@ Reset the internal state: reset();";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write out the dat with the current state
|
// Write out the dat with the current state
|
||||||
DatTool.Write(datFile, outputDirectory, overwrite: overwrite.Value);
|
Writer.Write(datFile, outputDirectory, overwrite: overwrite.Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Reset the internal state
|
// Reset the internal state
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace SabreTools.Features
|
|||||||
DatTool.ApplyCleaning(datdata, Cleaner);
|
DatTool.ApplyCleaning(datdata, Cleaner);
|
||||||
|
|
||||||
// Write out the file
|
// Write out the file
|
||||||
DatTool.Write(datdata, OutputDir);
|
Writer.Write(datdata, OutputDir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace SabreTools.Features
|
|||||||
datdata.Header.Name = $"fixDAT_{Header.Name}";
|
datdata.Header.Name = $"fixDAT_{Header.Name}";
|
||||||
datdata.Header.Description = $"fixDAT_{Header.Description}";
|
datdata.Header.Description = $"fixDAT_{Header.Description}";
|
||||||
datdata.Items.ClearMarked();
|
datdata.Items.ClearMarked();
|
||||||
DatTool.Write(datdata, OutputDir);
|
Writer.Write(datdata, OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ namespace SabreTools.Features
|
|||||||
datdata.Header.Name = $"fixDAT_{Header.Name}";
|
datdata.Header.Name = $"fixDAT_{Header.Name}";
|
||||||
datdata.Header.Description = $"fixDAT_{Header.Description}";
|
datdata.Header.Description = $"fixDAT_{Header.Description}";
|
||||||
datdata.Items.ClearMarked();
|
datdata.Items.ClearMarked();
|
||||||
DatTool.Write(datdata, OutputDir);
|
Writer.Write(datdata, OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ namespace SabreTools.Features
|
|||||||
InternalStopwatch watch = new InternalStopwatch("Outputting extension-split DATs");
|
InternalStopwatch watch = new InternalStopwatch("Outputting extension-split DATs");
|
||||||
|
|
||||||
// Output both possible DatFiles
|
// Output both possible DatFiles
|
||||||
DatTool.Write(extADat, OutputDir);
|
Writer.Write(extADat, OutputDir);
|
||||||
DatTool.Write(extBDat, OutputDir);
|
Writer.Write(extBDat, OutputDir);
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ namespace SabreTools.Features
|
|||||||
// Loop through each type DatFile
|
// Loop through each type DatFile
|
||||||
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
|
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
|
||||||
{
|
{
|
||||||
DatTool.Write(typeDats[itemType], OutputDir);
|
Writer.Write(typeDats[itemType], OutputDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -109,8 +109,8 @@ namespace SabreTools.Features
|
|||||||
InternalStopwatch watch = new InternalStopwatch("Outputting size-split DATs");
|
InternalStopwatch watch = new InternalStopwatch("Outputting size-split DATs");
|
||||||
|
|
||||||
// Output both possible DatFiles
|
// Output both possible DatFiles
|
||||||
DatTool.Write(lessThan, OutputDir);
|
Writer.Write(lessThan, OutputDir);
|
||||||
DatTool.Write(greaterThan, OutputDir);
|
Writer.Write(greaterThan, OutputDir);
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ namespace SabreTools.Features
|
|||||||
// Loop through each type DatFile
|
// Loop through each type DatFile
|
||||||
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
|
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
|
||||||
{
|
{
|
||||||
DatTool.Write(typeDats[itemType], OutputDir);
|
Writer.Write(typeDats[itemType], OutputDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace SabreTools.Features
|
|||||||
string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
|
|
||||||
// Try to output the file, overwriting only if it's not in the current directory
|
// Try to output the file, overwriting only if it's not in the current directory
|
||||||
DatTool.Write(datFile, realOutDir, overwrite: GetBoolean(features, InplaceValue));
|
Writer.Write(datFile, realOutDir, overwrite: GetBoolean(features, InplaceValue));
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -216,7 +216,7 @@ namespace SabreTools.Features
|
|||||||
DatFile dupeData = DatTool.DiffDuplicates(userInputDat, inputPaths);
|
DatFile dupeData = DatTool.DiffDuplicates(userInputDat, inputPaths);
|
||||||
|
|
||||||
InternalStopwatch watch = new InternalStopwatch("Outputting duplicate DAT");
|
InternalStopwatch watch = new InternalStopwatch("Outputting duplicate DAT");
|
||||||
DatTool.Write(dupeData, OutputDir, overwrite: false);
|
Writer.Write(dupeData, OutputDir, overwrite: false);
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ namespace SabreTools.Features
|
|||||||
DatFile outerDiffData = DatTool.DiffNoDuplicates(userInputDat, inputPaths);
|
DatFile outerDiffData = DatTool.DiffNoDuplicates(userInputDat, inputPaths);
|
||||||
|
|
||||||
InternalStopwatch watch = new InternalStopwatch("Outputting no duplicate DAT");
|
InternalStopwatch watch = new InternalStopwatch("Outputting no duplicate DAT");
|
||||||
DatTool.Write(outerDiffData, OutputDir, overwrite: false);
|
Writer.Write(outerDiffData, OutputDir, overwrite: false);
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ namespace SabreTools.Features
|
|||||||
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
|
|
||||||
// Try to output the file
|
// Try to output the file
|
||||||
DatTool.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -280,7 +280,7 @@ namespace SabreTools.Features
|
|||||||
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
|
|
||||||
// Try to output the file
|
// Try to output the file
|
||||||
DatTool.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
@@ -307,7 +307,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Finally output the diffed DatFile
|
// Finally output the diffed DatFile
|
||||||
string interOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
string interOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
DatTool.Write(repDat, interOutDir, overwrite: GetBoolean(features, InplaceValue));
|
Writer.Write(repDat, interOutDir, overwrite: GetBoolean(features, InplaceValue));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Finally output the replaced DatFile
|
// Finally output the replaced DatFile
|
||||||
string interOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
string interOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
DatTool.Write(repDat, interOutDir, overwrite: GetBoolean(features, InplaceValue));
|
Writer.Write(repDat, interOutDir, overwrite: GetBoolean(features, InplaceValue));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ namespace SabreTools.Features
|
|||||||
if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase))
|
||||||
DatTool.ApplySuperDAT(userInputDat, inputPaths);
|
DatTool.ApplySuperDAT(userInputDat, inputPaths);
|
||||||
|
|
||||||
DatTool.Write(userInputDat, OutputDir);
|
Writer.Write(userInputDat, OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Now write out if there are any items left
|
// Now write out if there are any items left
|
||||||
datdata.WriteStatsToConsole();
|
datdata.WriteStatsToConsole();
|
||||||
DatTool.Write(datdata, OutputDir);
|
Writer.Write(datdata, OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise, process all DATs into the same output
|
// Otherwise, process all DATs into the same output
|
||||||
@@ -141,7 +141,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Now write out if there are any items left
|
// Now write out if there are any items left
|
||||||
datdata.WriteStatsToConsole();
|
datdata.WriteStatsToConsole();
|
||||||
DatTool.Write(datdata, OutputDir);
|
Writer.Write(datdata, OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user