diff --git a/src/diskwriter.cxx b/src/diskwriter.cxx index 4cad6fc..a87d0eb 100644 --- a/src/diskwriter.cxx +++ b/src/diskwriter.cxx @@ -10,6 +10,9 @@ #include #include +// to prompt the user of new filenames in case of overwrite +#include + #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 );