Handle more IDDB-specific places that use Machine information

This commit is contained in:
Matt Nadareski
2024-03-20 11:22:33 -04:00
parent 49f09ffb2b
commit 9185b4e238
6 changed files with 735 additions and 16 deletions

View File

@@ -61,5 +61,31 @@ namespace SabreTools.DatFiles
logger.User($"'{outfile}' written!{Environment.NewLine}");
return true;
}
/// <inheritdoc/>
public override bool WriteToFileDB(string outfile, bool ignoreblanks = false, bool throwOnError = false)
{
try
{
logger.User($"Writing to '{outfile}'...");
// Serialize the input file in two steps
var internalFormat = ConvertMetadata(ignoreblanks);
var specificFormat = Activator.CreateInstance<V>().Deserialize(internalFormat);
if (!Activator.CreateInstance<U>().Serialize(specificFormat, outfile))
{
logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
return false;
}
}
catch (Exception ex) when (!throwOnError)
{
logger.Error(ex);
return false;
}
logger.User($"'{outfile}' written!{Environment.NewLine}");
return true;
}
}
}