#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()
{
//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;
else
{
std::cerr << "Couldn't open the directory" << std::endl;
- }
+ }*/
}
void ModelCreaDevManagerTree::populateNode(std::string path)