From 8123a7d15f9698e1cdb7c8fc450e76497a6bfb0f Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Fri, 2 Nov 2012 09:29:03 +0000 Subject: [PATCH] Feature #1711 CreaDevManager application implementation: Changes to use wxDir instead of dirent.h --- .../ModelCreaDevManagerTree.cpp | 41 ++++++++++++++++--- .../ModelCreaDevManagerTreeNode.cpp | 7 ---- .../ModelCreaDevManagerTreeNode.h | 2 + 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/creaDevManagerLib/ModelCreaDevManagerTree.cpp b/lib/creaDevManagerLib/ModelCreaDevManagerTree.cpp index 4ae0ee2..64106b6 100644 --- a/lib/creaDevManagerLib/ModelCreaDevManagerTree.cpp +++ b/lib/creaDevManagerLib/ModelCreaDevManagerTree.cpp @@ -7,15 +7,14 @@ #include "ModelCreaDevManagerTree.h" -#include -#include -#include -#include #include #include #include #include #include +#include +#include + ModelCreaDevManagerTree::ModelCreaDevManagerTree() { @@ -100,6 +99,38 @@ void ModelCreaDevManagerTree::populateNode(ModelCreaDevManagerTreeNode& node) //std::cout << "populating " << node.GetName() << " path " << node.GetPath() << "..." << std::endl; std::vector * nodes = new std::vector ; + 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) diff --git a/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.cpp b/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.cpp index 29f8bd5..8486f80 100644 --- a/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.cpp +++ b/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.cpp @@ -7,13 +7,6 @@ #include "ModelCreaDevManagerTreeNode.h" -#include -#include -#include -#include -#include -#include - ModelCreaDevManagerTreeNode::ModelCreaDevManagerTreeNode(std::string path, std::string name, unsigned char type, int level) { this->_path = path; diff --git a/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.h b/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.h index 5644099..0cf4a56 100644 --- a/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.h +++ b/lib/creaDevManagerLib/ModelCreaDevManagerTreeNode.h @@ -11,6 +11,8 @@ #include #include + + class ModelCreaDevManagerTreeNode { public: -- 2.47.1