2023-07-28 21:34:34 -04:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents parsing of a hashfile such as an SFV, MD5, or SHA-1 file
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal partial class Hashfile : 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 hashfile = new Serialization.Files.Hashfile().Deserialize(filename, _hash);
|
2024-03-10 00:30:56 -05:00
|
|
|
var metadata = new Serialization.CrossModel.Hashfile().Serialize(hashfile);
|
2023-07-28 21:34:34 -04:00
|
|
|
|
2024-03-10 00:30:56 -05:00
|
|
|
// Convert to the internal format
|
2024-03-10 22:49:15 -04:00
|
|
|
ConvertMetadata(metadata, filename, indexId, keep, statsOnly);
|
2023-07-28 21:34:34 -04:00
|
|
|
}
|
|
|
|
|
catch (Exception ex) when (!throwOnError)
|
|
|
|
|
{
|
|
|
|
|
string message = $"'{filename}' - An error occurred during parsing";
|
|
|
|
|
logger.Error(ex, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|