]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMAppli.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMAppli.cpp
index 4f61e13de3c84c765474ec4d709b798e46a5a265..be0852a35a7ea5a13ee43e360cc85dcec9aa28e5 100644 (file)
@@ -121,12 +121,29 @@ const std::vector<modelCDMApplication*>& modelCDMAppli::GetApplications() const
 }
 
 modelCDMApplication* modelCDMAppli::CreateApplication(
-    const std::string& name,
+    const std::string& namein,
     std::string*& result
 )
 {
+  std::vector<std::string> 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 + "'.");