mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Parsing to actual class
This commit is contained in:
@@ -705,7 +705,7 @@ CREATE TABLE IF NOT EXISTS dat (
|
|||||||
|
|
||||||
// Parse the Dat if possible
|
// Parse the Dat if possible
|
||||||
logger.User($"Adding from '{dat.Name}'");
|
logger.User($"Adding from '{dat.Name}'");
|
||||||
DatFile tempdat = DatTool.CreateAndParse(fullpath);
|
DatFile tempdat = Parser.CreateAndParse(fullpath);
|
||||||
|
|
||||||
// If the Dat wasn't empty, add the information
|
// If the Dat wasn't empty, add the information
|
||||||
SqliteCommand slc = null;
|
SqliteCommand slc = null;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ structure according to the original DAT master directory tree structure.";
|
|||||||
foreach (string key in foundDats.Keys)
|
foreach (string key in foundDats.Keys)
|
||||||
{
|
{
|
||||||
// Get the DAT file associated with the key
|
// Get the DAT file associated with the key
|
||||||
DatFile datFile = DatTool.CreateAndParse(Path.Combine(_dats, foundDats[key]));
|
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats, foundDats[key]));
|
||||||
|
|
||||||
// Set the depot values
|
// Set the depot values
|
||||||
datFile.Header.InputDepot = new DepotInformation(true, 4);
|
datFile.Header.InputDepot = new DepotInformation(true, 4);
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ in -old DAT file. Ignores those entries in -old that are not in -new.";
|
|||||||
DatFile datfile = DatFile.Create();
|
DatFile datfile = DatFile.Create();
|
||||||
datfile.Header.Name = name;
|
datfile.Header.Name = name;
|
||||||
datfile.Header.Description = description;
|
datfile.Header.Description = description;
|
||||||
DatTool.ParseInto(datfile, olddat);
|
Parser.ParseInto(datfile, olddat);
|
||||||
|
|
||||||
// Diff against the new datfile
|
// Diff against the new datfile
|
||||||
DatFile intDat = DatTool.CreateAndParse(newdat);
|
DatFile intDat = Parser.CreateAndParse(newdat);
|
||||||
DatTool.DiffAgainst(datfile, intDat, false);
|
DatTool.DiffAgainst(datfile, intDat, false);
|
||||||
DatTool.Write(intDat, outdat);
|
DatTool.Write(intDat, outdat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ namespace RombaSharp.Features
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the encapsulating datfile
|
// Create the encapsulating datfile
|
||||||
DatFile datfile = DatTool.CreateAndParse(olddat);
|
DatFile datfile = Parser.CreateAndParse(olddat);
|
||||||
|
|
||||||
// Diff against the new datfile
|
// Diff against the new datfile
|
||||||
DatFile intDat = DatTool.CreateAndParse(newdat);
|
DatFile intDat = Parser.CreateAndParse(newdat);
|
||||||
DatTool.DiffAgainst(datfile, intDat, false);
|
DatTool.DiffAgainst(datfile, intDat, false);
|
||||||
DatTool.Write(intDat, outdat);
|
DatTool.Write(intDat, outdat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace RombaSharp.Features
|
|||||||
foreach (string key in foundDats.Keys)
|
foreach (string key in foundDats.Keys)
|
||||||
{
|
{
|
||||||
// Get the DAT file associated with the key
|
// Get the DAT file associated with the key
|
||||||
DatFile datFile = DatTool.CreateAndParse(Path.Combine(_dats, foundDats[key]));
|
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats, foundDats[key]));
|
||||||
|
|
||||||
// Now loop through and see if all of the hash combinations exist in the database
|
// Now loop through and see if all of the hash combinations exist in the database
|
||||||
/* ended here */
|
/* ended here */
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ namespace SabreTools.DatFiles
|
|||||||
var input = inputs[i];
|
var input = inputs[i];
|
||||||
logger.User($"Adding DAT: {input.CurrentPath}");
|
logger.User($"Adding DAT: {input.CurrentPath}");
|
||||||
datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering());
|
datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering());
|
||||||
ParseInto(datFiles[i], input, i, keep: true);
|
Parser.ParseInto(datFiles[i], input, i, keep: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|||||||
@@ -1425,7 +1425,7 @@ namespace SabreTools.DatFiles
|
|||||||
|
|
||||||
staticLogger.Verbose($"Beginning stat collection for '{file.CurrentPath}'");
|
staticLogger.Verbose($"Beginning stat collection for '{file.CurrentPath}'");
|
||||||
List<string> games = new List<string>();
|
List<string> games = new List<string>();
|
||||||
DatFile datdata = DatTool.CreateAndParse(file.CurrentPath);
|
DatFile datdata = Parser.CreateAndParse(file.CurrentPath);
|
||||||
datdata.Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
datdata.Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
||||||
|
|
||||||
// Output single DAT stats (if asked)
|
// Output single DAT stats (if asked)
|
||||||
|
|||||||
@@ -4,12 +4,22 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
using SabreTools.Logging;
|
||||||
|
|
||||||
// This file represents all methods related to parsing from a file
|
// This file represents all methods related to parsing from a file
|
||||||
namespace SabreTools.DatFiles
|
namespace SabreTools.DatFiles
|
||||||
{
|
{
|
||||||
public partial class DatTool
|
public class Parser
|
||||||
{
|
{
|
||||||
|
#region Logging
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logging object
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Logger logger = new Logger();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a DatFile and parse a file into it
|
/// Create a DatFile and parse a file into it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -133,7 +133,7 @@ Reset the internal state: reset();";
|
|||||||
// Assume there could be multiple
|
// Assume there could be multiple
|
||||||
foreach (ParentablePath datFilePath in datFilePaths)
|
foreach (ParentablePath datFilePath in datFilePaths)
|
||||||
{
|
{
|
||||||
DatTool.ParseInto(datFile, datFilePath, index++);
|
Parser.ParseInto(datFile, datFilePath, index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace SabreTools.Features
|
|||||||
foreach (ParentablePath datfile in datfilePaths)
|
foreach (ParentablePath datfile in datfilePaths)
|
||||||
{
|
{
|
||||||
DatFile datdata = DatFile.Create();
|
DatFile datdata = DatFile.Create();
|
||||||
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
|
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
|
||||||
@@ -128,7 +128,7 @@ namespace SabreTools.Features
|
|||||||
DatFile datdata = DatFile.Create();
|
DatFile datdata = DatFile.Create();
|
||||||
foreach (ParentablePath datfile in datfilePaths)
|
foreach (ParentablePath datfile in datfilePaths)
|
||||||
{
|
{
|
||||||
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
// Create and fill the new DAT
|
// Create and fill the new DAT
|
||||||
DatFile internalDat = DatFile.Create(Header);
|
DatFile internalDat = DatFile.Create(Header);
|
||||||
DatTool.ParseInto(internalDat, file);
|
Parser.ParseInto(internalDat, file);
|
||||||
|
|
||||||
// Get the output directory
|
// Get the output directory
|
||||||
OutputDir = file.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
OutputDir = file.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace SabreTools.Features
|
|||||||
// Create a new base DatFile
|
// Create a new base DatFile
|
||||||
DatFile datFile = DatFile.Create(Header);
|
DatFile datFile = DatFile.Create(Header);
|
||||||
logger.User($"Processing '{Path.GetFileName(inputPath.CurrentPath)}'");
|
logger.User($"Processing '{Path.GetFileName(inputPath.CurrentPath)}'");
|
||||||
DatTool.ParseInto(datFile, inputPath, keep: true,
|
Parser.ParseInto(datFile, inputPath, keep: true,
|
||||||
keepext: datFile.Header.DatFormat.HasFlag(DatFormat.TSV)
|
keepext: datFile.Header.DatFormat.HasFlag(DatFormat.TSV)
|
||||||
|| datFile.Header.DatFormat.HasFlag(DatFormat.CSV)
|
|| datFile.Header.DatFormat.HasFlag(DatFormat.CSV)
|
||||||
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
|
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
|
||||||
@@ -294,7 +294,7 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
// Parse the path to a new DatFile
|
// Parse the path to a new DatFile
|
||||||
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
||||||
DatTool.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);
|
DatTool.ApplyExtras(repDat, Extras);
|
||||||
@@ -319,7 +319,7 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
// Parse the path to a new DatFile
|
// Parse the path to a new DatFile
|
||||||
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
||||||
DatTool.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);
|
DatTool.ApplyExtras(repDat, Extras);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
// Parse in from the file
|
// Parse in from the file
|
||||||
DatFile datdata = DatFile.Create();
|
DatFile datdata = DatFile.Create();
|
||||||
DatTool.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);
|
DatTool.ApplyExtras(datdata, Extras);
|
||||||
@@ -104,7 +104,7 @@ namespace SabreTools.Features
|
|||||||
DatFile datdata = DatFile.Create();
|
DatFile datdata = DatFile.Create();
|
||||||
foreach (ParentablePath datfile in datfilePaths)
|
foreach (ParentablePath datfile in datfilePaths)
|
||||||
{
|
{
|
||||||
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
|
|||||||
Reference in New Issue
Block a user