diff --git a/server/ModelLoader/README.md b/server/ModelLoader/README.md new file mode 100644 index 000000000..a3d4868c6 --- /dev/null +++ b/server/ModelLoader/README.md @@ -0,0 +1,3 @@ +## NOTE + +**projectGenerator** will overwrite your original configuration files (xxx.xml / xxx.conf / xxx.RobotHardware.conf) when there already exists original ones in your output direcrotry because this program generates xxx.xml, xxx.conf and xxx.RobotHardware.conf at the same time in the same directory. diff --git a/server/ModelLoader/projectGenerator.cpp b/server/ModelLoader/projectGenerator.cpp index efb9c695c..173235f52 100644 --- a/server/ModelLoader/projectGenerator.cpp +++ b/server/ModelLoader/projectGenerator.cpp @@ -20,6 +20,7 @@ #include #include #include "BodyInfo_impl.h" +#include using namespace std; void xmlTextWriterWriteProperty(const xmlTextWriterPtr writer, const std::string name, const std::string value) { @@ -297,6 +298,8 @@ int main (int argc, char** argv) std::vector inputs, filenames; // filenames is for conf file std::string conf_file_option, robothardware_conf_file_option, integrate("true"), dt("0.005"), timeStep(dt), joint_properties; bool use_highgain_mode(true); + struct stat st; + bool file_exist_flag = false; for (int i = 1; i < argc; ++ i) { std::string arg(argv[i]); @@ -345,6 +348,9 @@ int main (int argc, char** argv) } xmlTextWriterPtr writer; + if (stat(output.c_str(), &st) == 0) { + file_exist_flag = true; + } writer = xmlNewTextWriterFilename(output.c_str(), 0); xmlTextWriterSetIndent(writer, 4); xmlTextWriterStartElement(writer, BAD_CAST "grxui"); @@ -608,9 +614,15 @@ int main (int argc, char** argv) xmlFreeTextWriter(writer); + if (file_exist_flag) { + std::cerr << "\033[1;31mOver\033[0m"; + } std::cerr << "Writing project files to .... " << output << std::endl; { std::string conf_file = output.substr(0,output.find_last_of('.'))+".conf"; + if (stat(conf_file.c_str(), &st) == 0) { + std::cerr << "\033[1;31mOver\033[0m"; + } std::fstream s(conf_file.c_str(), std::ios::out); s << "model: file://" << filenames[0] << std::endl; @@ -621,6 +633,9 @@ int main (int argc, char** argv) { std::string conf_file = output.substr(0,output.find_last_of('.'))+".RobotHardware.conf"; + if (stat(conf_file.c_str(), &st) == 0) { + std::cerr << "\033[1;31mOver\033[0m"; + } std::fstream s(conf_file.c_str(), std::ios::out); s << "model: file://" << filenames[0] << std::endl;