]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <Daniel.Gonzalez@creatis.insa-lyon.fr>
Fri, 2 Nov 2012 09:29:03 +0000 (09:29 +0000)
committerDaniel Gonzalez <Daniel.Gonzalez@creatis.insa-lyon.fr>
Fri, 2 Nov 2012 09:29:03 +0000 (09:29 +0000)
CreaDevManager application implementation:

Changes to use wxDir instead of dirent.h

lib/creaDevManagerLib/ModelCreaDevManagerTree.cpp
lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.cpp
lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.h

index 4ae0ee2885920e0bb3d4975c435f7d014fa7dd40..64106b672c06401d47954b359b4d5ab16e50fda8 100644 (file)
@@ -7,15 +7,14 @@
 
 #include "ModelCreaDevManagerTree.h"
 
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
 #include <iostream>
 #include <sstream>
 #include <algorithm>
 #include <string>
 #include <cstring>
+#include <creaWx.h>
+#include <wx/dir.h>
+
 
 ModelCreaDevManagerTree::ModelCreaDevManagerTree()
 {
@@ -100,6 +99,38 @@ void ModelCreaDevManagerTree::populateNode(ModelCreaDevManagerTreeNode& node)
   //std::cout << "populating " << node.GetName() << " path " << node.GetPath() << "..." << std::endl;
   std::vector <ModelCreaDevManagerTreeNode>*  nodes = new std::vector <ModelCreaDevManagerTreeNode>;
 
+  std::string path = node.GetPath()+node.GetName()+"/";
+
+  wxDir dir(wxString(path.c_str()));
+  if (!dir.IsOpened())
+  {
+    std::cerr << "Couldn't open the directory" << std::endl;
+    return;
+  }
+
+  wxString fileName;
+  bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
+  while (cont)
+  {
+    ModelCreaDevManagerTreeNode innerNode = ModelCreaDevManagerTreeNode(path, crea::wx2std(fileName), wxDIR_DIRS, node.GetLevel()+1);
+    this->populateNode(innerNode);
+    nodes->push_back(innerNode);
+    cont = dir.GetNext(&fileName);
+  }
+
+  cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
+  while (cont)
+  {
+    ModelCreaDevManagerTreeNode innerNode = ModelCreaDevManagerTreeNode(path, crea::wx2std(fileName), wxDIR_FILES, node.GetLevel()+1);
+    nodes->push_back(innerNode);
+    cont = dir.GetNext(&fileName);
+  }
+
+  sort (nodes->begin(), nodes->end(), CompareNodeItem);
+  node.SetChildren(*nodes);
+
+  /*
+
   DIR *dp;
   struct dirent *ep;
 
@@ -133,7 +164,7 @@ void ModelCreaDevManagerTree::populateNode(ModelCreaDevManagerTreeNode& node)
   else
   {
     std::cerr << "Couldn't open the directory" << std::endl;
-  }
+  }*/
 }
 
 void ModelCreaDevManagerTree::populateNode(std::string path)
index 29f8bd5faa3061b735e5a70dcdafab9e6316a41e..8486f8054c37f34889aa595415c1d83d691b5e71 100644 (file)
@@ -7,13 +7,6 @@
 
 #include "ModelCreaDevManagerTreeNode.h"
 
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <iostream>
-#include <algorithm>
-
 ModelCreaDevManagerTreeNode::ModelCreaDevManagerTreeNode(std::string path, std::string name, unsigned char type, int level)
 {
   this->_path = path;
index 564409989dd2be7f63b4cfd892a6864ef989f851..0cf4a56241d7d10f0b66c9cd132bcce72bbdc489 100644 (file)
@@ -11,6 +11,8 @@
 #include <vector>
 #include <iostream>
 
+
+
 class ModelCreaDevManagerTreeNode
 {
   public: