X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMLib.cpp;h=e3c29023fffc04797962496f86d7f948d1fb2a00;hb=327c33758d25e6ff1f90f9ab74ea219eaed934a9;hp=57411ec64f340fc70288a41e9d364eb33904831c;hpb=eed967098aa87503c59d09c8d5c0dc87485698e2;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMLib.cpp b/lib/creaDevManagerLib/modelCDMLib.cpp index 57411ec..e3c2902 100644 --- a/lib/creaDevManagerLib/modelCDMLib.cpp +++ b/lib/creaDevManagerLib/modelCDMLib.cpp @@ -121,12 +121,28 @@ const std::vector& modelCDMLib::GetLibraries() const } modelCDMLibrary* modelCDMLib::CreateLibrary( - 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 library folder with new name +#ifdef _WIN32 + std::string copyCommand = "xcopy \"" + this->path + CDMUtilities::SLASH + "template_lib\" \"" + this->path + CDMUtilities::SLASH + name + CDMUtilities::SLASH + "\" /Y"; +#else std::string copyCommand = "cp -r \"" + this->path + CDMUtilities::SLASH + "template_lib\" \"" + this->path + CDMUtilities::SLASH + name + "\""; +#endif if(system(copyCommand.c_str())) { result = new std::string("An error occurred while running '" + copyCommand + "'."); @@ -150,7 +166,11 @@ modelCDMLibrary* modelCDMLib::CreateLibrary( 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 + "'.");