2023-07-29 21:24:16 -04:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents parsing a value-separated DAT
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal partial class SeparatedValue : DatFile
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Deserialize the input file
|
2023-09-11 01:20:21 -04:00
|
|
|
var metadataFile = new Serialization.Files.SeparatedValue().Deserialize(filename, _delim);
|
2024-03-10 00:59:53 -05:00
|
|
|
var metadata = new Serialization.CrossModel.SeparatedValue().Serialize(metadataFile);
|
2023-07-29 21:24:16 -04:00
|
|
|
|
2024-03-10 00:59:53 -05:00
|
|
|
// Convert to the internal format
|
|
|
|
|
ConvertMetadata(metadata, filename, indexId, statsOnly);
|
2023-07-29 21:24:16 -04:00
|
|
|
}
|
|
|
|
|
catch (Exception ex) when (!throwOnError)
|
|
|
|
|
{
|
|
|
|
|
string message = $"'{filename}' - An error occurred during parsing";
|
|
|
|
|
logger.Error(ex, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|