mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix default format setting, add tests
This commit is contained in:
@@ -155,13 +155,23 @@ namespace SabreTools.DatTools
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
/// <remarks>
|
||||
/// Code must remove the existing format in order to ensure the format is derived
|
||||
/// from the input file instead. This should be addressed later by either always
|
||||
/// deriving the format, or by setting a flag for this to be done automatically.
|
||||
// </remarks>
|
||||
public static DatFile ParseStatistics(string? filename, bool throwOnError = false)
|
||||
{
|
||||
// Null filenames are invalid
|
||||
if (filename == null)
|
||||
return CreateDatFile();
|
||||
{
|
||||
DatFile empty = CreateDatFile();
|
||||
empty.Header.RemoveField(DatHeader.DatFormatKey);
|
||||
return empty;
|
||||
}
|
||||
|
||||
DatFile datFile = CreateDatFile();
|
||||
datFile.Header.RemoveField(DatHeader.DatFormatKey);
|
||||
ParseInto(datFile, filename, statsOnly: true, throwOnError: throwOnError);
|
||||
return datFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user