X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMAppli.cpp;h=be0852a35a7ea5a13ee43e360cc85dcec9aa28e5;hb=327c33758d25e6ff1f90f9ab74ea219eaed934a9;hp=4f61e13de3c84c765474ec4d709b798e46a5a265;hpb=eed967098aa87503c59d09c8d5c0dc87485698e2;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMAppli.cpp b/lib/creaDevManagerLib/modelCDMAppli.cpp index 4f61e13..be0852a 100644 --- a/lib/creaDevManagerLib/modelCDMAppli.cpp +++ b/lib/creaDevManagerLib/modelCDMAppli.cpp @@ -121,12 +121,29 @@ const std::vector& modelCDMAppli::GetApplications() const } modelCDMApplication* modelCDMAppli::CreateApplication( - const std::string& name, + const std::string& namein, std::string*& result ) { + std::vector words; + CDMUtilities::splitter::split(words,namein," '/\\*\"%",CDMUtilities::splitter::no_empties); + std::string name; + for (int i = 0; i < (int)(words.size()); i++) + { + name += words[i]; + } + if (name == "") + { + result = new std::string("The given name is not valid: '/\\*\"% are forbidden."); + return NULL; + } //copy template application folder with new name +#ifdef _WIN32 + std::string copyCommand = "xcopy \"" + this->path + CDMUtilities::SLASH + "template_appli\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "\" /Y"; +#else std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_appli\" \"" + this->path + CDMUtilities::SLASH + name + "\""; +#endif + if(system(copyCommand.c_str())) { result = new std::string("An error occurred while running '" + copyCommand + "'."); @@ -150,7 +167,12 @@ modelCDMApplication* modelCDMAppli::CreateApplication( in.close(); out.close(); //delete old file and rename new file +#ifdef _WIN32 + std::string renameCommand = "move /Y \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\""; +#else std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "CMakeLists.txt\""; +#endif + if(system(renameCommand.c_str())) { result = new std::string("An error occurred while running '" + renameCommand + "'.");