]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMFolder.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMFolder.cpp
index 28d7a9581e7a96479c013b2dc444e60012393c25..c1ef911dfd0b9efce843b402adc4529efd1dea1a 100644 (file)
@@ -47,21 +47,14 @@ modelCDMFolder::modelCDMFolder()
   this->CMakeLists = NULL;
 }
 
-modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
+modelCDMFolder::modelCDMFolder(const std::string& path, const std::string& name, const int& level)
 {
   //set attributes
   this->children.clear();
   this->level = level;
   this->CMakeLists = NULL;
   this->length = 0;
-
-  std::vector<std::string> words;
-  std::string delimiters;
-  //TODO::fix for windows
-  delimiters = "/";
-  CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties);
-  this->name = words[words.size()-1];
-
+  this->name = name;
   this->path = path;
   this->type = wxDIR_DIRS;
 
@@ -77,7 +70,7 @@ modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
           std::string stdfileName = crea::wx2std(fileName);
 
           //if is an unknown folder, create folder
-          this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
+          this->children.push_back(new modelCDMFolder(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
 
           cont = dir.GetNext(&fileName);
         }
@@ -90,12 +83,12 @@ modelCDMFolder::modelCDMFolder(const std::string& path, const int& level)
           //if CMakeLists, create CMakeLists
           if(stdfileName == "CMakeLists.txt")
             {
-              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
+              this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(this->CMakeLists);
             }
           else
             {
-              this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
+              this->children.push_back(new modelCDMFile(pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
             }
           //if is an unknown file, create file
           cont = dir.GetNext(&fileName);
@@ -123,13 +116,13 @@ modelCDMFolder::~modelCDMFolder()
 modelCDMFolder* modelCDMFolder::CreateFolder(const std::string& name, std::string*& result)
 {
   //TODO:: mkdir depending on OS
-  std::string command = "mkdir " + path + "/" + name;
+  std::string command = "mkdir \"" + path + CDMUtilities::SLASH + name + "\"";
   if(system(command.c_str()))
     {
       result = new std::string("Error executing: " + command + ".");
       return NULL;
     }
-  modelCDMFolder* folder = new modelCDMFolder(path + "/" + name, level + 1);
+  modelCDMFolder* folder = new modelCDMFolder(path + CDMUtilities::SLASH + name, name, level + 1);
   this->folders.push_back(folder);
   this->children.push_back(folder);
 
@@ -187,7 +180,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
             }
           if(!found)
             {
-              modelCDMFolder* folder = new modelCDMFolder(this->path + "/" + stdfileName, this->level + 1);
+              modelCDMFolder* folder = new modelCDMFolder(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->folders.push_back(folder);
               this->children.push_back(folder);
             }
@@ -204,7 +197,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
             {
               if (this->CMakeLists == NULL)
                 {
-                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + "/" + stdfileName, this->level + 1);
+                  this->CMakeLists = new modelCDMCMakeListsFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(this->CMakeLists);
                 }
               else
@@ -215,6 +208,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
                     return false;
                 }
             }
+
           //if is an unknown file, create file
           else
             {
@@ -232,7 +226,7 @@ const bool modelCDMFolder::Refresh(std::string*& result)
 
               if(!found)
                 {
-                  modelCDMFile* file = new modelCDMFile(this->path + "/" + stdfileName, this->level + 1);
+                  modelCDMFile* file = new modelCDMFile(this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
                   this->children.push_back(file);
                 }
             }