-Fixed issue with controller over-writing

main
Harry van Haaren 2013-11-12 19:50:11 +00:00
parent e8275c2fb6
commit 5486d059a1
1 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,9 @@
#include <sys/stat.h>
#include <errno.h>
// to prompt the user of new filenames in case of overwrite
#include <FL/fl_ask.H>
#include "gui.hxx"
#include "gmastertrack.hxx"
@ -211,6 +214,14 @@ int DiskWriter::writeControllerFile(std::string name ,
stringstream controllerCfgPath;
controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << g->getName() << ".ctlr";
ifstream infile( controllerCfgPath.str().c_str() );
if ( infile.good() )
{
// file exists: ask user overwrite or rename?
LUPPP_WARN("Controller filename exists: prompting user to overwrite y/n?");
controllerCfgPath << ".newCtlr";
}
ofstream controllerCfgFile;
controllerCfgFile.open ( controllerCfgPath.str().c_str() );
controllerCfgFile << cJSON_Print( controllerJson );