forked from Kistler-Group/sdbus-cpp
fix(codegen): check fstream status and report in case of failure (#462)
This commit is contained in:
@@ -53,7 +53,7 @@ int BaseGenerator::transformXmlToFile(const Document& doc, const char* filename)
|
|||||||
int BaseGenerator::writeToFile(const char* filename, const std::string& data) const
|
int BaseGenerator::writeToFile(const char* filename, const std::string& data) const
|
||||||
{
|
{
|
||||||
std::ofstream file(filename);
|
std::ofstream file(filename);
|
||||||
if (file.bad())
|
if (file.fail())
|
||||||
{
|
{
|
||||||
std::cerr << "Unable to write file " << filename << endl;
|
std::cerr << "Unable to write file " << filename << endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -186,7 +186,10 @@ int main(int argc, char **argv)
|
|||||||
std::cerr << "Generating proxy header " << proxy << endl;
|
std::cerr << "Generating proxy header " << proxy << endl;
|
||||||
}
|
}
|
||||||
ProxyGenerator pg;
|
ProxyGenerator pg;
|
||||||
pg.transformXmlToFile(doc, proxy);
|
if(pg.transformXmlToFile(doc, proxy)) {
|
||||||
|
std::cerr << "Failed to generate proxy header" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adaptor)
|
if (adaptor)
|
||||||
@@ -196,7 +199,11 @@ int main(int argc, char **argv)
|
|||||||
std::cerr << "Generating adaptor header " << adaptor << endl;
|
std::cerr << "Generating adaptor header " << adaptor << endl;
|
||||||
}
|
}
|
||||||
AdaptorGenerator ag;
|
AdaptorGenerator ag;
|
||||||
ag.transformXmlToFile(doc, adaptor);
|
if(ag.transformXmlToFile(doc, adaptor)) {
|
||||||
|
std::cerr << "Failed to generate adaptor header" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user