]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMLib.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMLib.cpp
index 2324eb9148f0a706992f23a825daaaf70567a7cf..50b32f5e76c509fec9252a648bfc27286dcb46db 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "modelCDMLib.h"
 
+#include "CDMUtilities.h"
 #include "creaWx.h"
 #include "wx/dir.h"
 
@@ -47,10 +48,44 @@ modelCDMLib::modelCDMLib(const std::string& path, const int& level)
   this->name = "lib";
   this->level = level;
   this->path = path;
+
+
+
+  this->path = CDMUtilities::fixPath(path);
+  //open makelists file
+  std::string pathFixed(CDMUtilities::fixPath(path));
+
+  this->libraries.clear();
+    wxDir dir(crea::std2wx((pathFixed).c_str()));
+    if (dir.IsOpened())
+      {
+        wxString fileName;
+        bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+        while (cont)
+          {
+            std::string stdfileName = crea::wx2std(fileName);
+
+            modelCDMLibrary* library = new modelCDMLibrary(pathFixed + "/" + stdfileName, this->level + 1);
+            this->libraries.push_back(library);
+            this->children.push_back(library);
+
+            cont = dir.GetNext(&fileName);
+          }
+
+      }
+    this->SortChildren();
 }
 
 modelCDMLib::~modelCDMLib()
 {
+  for (int i = 0; i < this->libraries.size(); i++)
+    {
+      if(this->libraries[i] != NULL)
+        {
+          delete this->libraries[i];
+          this->libraries[i] = NULL;
+        }
+    }
 }
 
 bool modelCDMLib::CreateLibrary(