]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMPackage.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMPackage.cpp
index b201b50095cc35650b7dd231496e32e897636bf9..044171b9eea1e0ebe5e51f5df480f48af33df96f 100644 (file)
@@ -55,6 +55,67 @@ modelCDMPackage::modelCDMPackage(const std::string& path, const int& level)
   this->namePackage = this->name;
   this->level = level;
   this->path = path;
+
+  //check all folders and files
+  wxDir dir(crea::std2wx((path).c_str()));
+  if (dir.IsOpened())
+    {
+      wxString fileName;
+
+      //folders
+      bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+          //if src, check for black boxes
+          if(stdfileName == "src")
+            {
+              wxDir srcF(crea::std2wx((path + delimiters + "src").c_str()));
+              if (srcF.IsOpened())
+                {
+                  wxString srcName;
+                  bool innerCont = srcF.GetFirst(&srcName, wxT("*.h"), wxDIR_FILES);
+                  while (innerCont)
+                    {
+                      if(crea::wx2std(srcName.substr(0,2)) == "bb")
+                        {
+                          modelCDMBlackBox* blackbox = new modelCDMBlackBox(crea::wx2std(srcName), path + delimiters + "src", this->level + 1);
+                          this->blackBoxes.push_back(blackbox);
+                          this->children.push_back(blackbox);
+                        }
+                      innerCont = srcF.GetNext(&srcName);
+                    }
+                }
+            }
+          //if is an unknown folder, create folder
+          else
+            {
+              this->children.push_back(new modelCDMFolder(path + delimiters + stdfileName, this->level + 1));
+            }
+          cont = dir.GetNext(&fileName);
+        }
+
+      //files
+      cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+      while (cont)
+        {
+          std::string stdfileName = crea::wx2std(fileName);
+
+          //if CMakeLists, create CMakeLists
+          if(stdfileName == "CMakeLists.txt")
+            {
+              this->CMakeLists = new modelCDMCMakeListsFile(path + delimiters + stdfileName, this->level + 1);
+              this->children.push_back(this->CMakeLists);
+            }
+          else
+            {
+              this->children.push_back(new modelCDMFile(path + delimiters + stdfileName, this->level + 1));
+            }
+          //if is an unknown file, create file
+          cont = dir.GetNext(&fileName);
+        }
+    }
+  this->SortChildren();
 }
 
 modelCDMPackage::~modelCDMPackage()
@@ -101,7 +162,7 @@ bool modelCDMPackage::SetAuthorsEmail(const std::string& email, std::string*& re
 bool modelCDMPackage::SetVersion(const std::string& version, std::string*& result)
 {
   //TODO: implement method
-    return true;
+  return true;
 }
 
 bool modelCDMPackage::SetDescription(const std::string& description, std::string*& result)