fix(codegen): check fstream status and report in case of failure (#462)

This commit is contained in:
Karl Ljungkvist
2024-10-31 12:48:19 +01:00
committed by GitHub
parent c55907069b
commit 84130b1406
2 changed files with 10 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ int BaseGenerator::transformXmlToFile(const Document& doc, const char* filename)
int BaseGenerator::writeToFile(const char* filename, const std::string& data) const
{
std::ofstream file(filename);
if (file.bad())
if (file.fail())
{
std::cerr << "Unable to write file " << filename << endl;
return 1;