/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sant�) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ /* * modelCDMFolder.cpp * * Created on: Nov 28, 2012 * Author: Daniel Felipe Gonzalez Obando */ #include "modelCDMFolder.h" #include #include #include "CDMUtilities.h" modelCDMFolder::modelCDMFolder() { this->CMakeLists = NULL; } modelCDMFolder::modelCDMFolder(const std::string& path, const int& level) { //set attributes this->children.clear(); this->level = level; this->CMakeLists = NULL; this->length = 0; std::vector words; std::string delimiters; //TODO::fix for windows delimiters = "/"; CDMUtilities::splitter::split(words, path, delimiters, CDMUtilities::splitter::no_empties); this->name = words[words.size()-1]; this->path = path; this->type = wxDIR_DIRS; std::string pathFixed(CDMUtilities::fixPath(path)); //check all folders 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); //if is an unknown folder, create folder this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1)); cont = dir.GetNext(&fileName); } 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(pathFixed + "/" + stdfileName, this->level + 1); this->children.push_back(this->CMakeLists); } else { this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1)); } //if is an unknown file, create file cont = dir.GetNext(&fileName); } } this->SortChildren(); } modelCDMFolder::~modelCDMFolder() { this->folders.clear(); this->CMakeLists = NULL; for (int i = 0; i < this->children.size(); i++) { if(this->children[i] != NULL) { delete this->children[i]; this->children[i] = NULL; } } this->children.clear(); } bool modelCDMFolder::CreateFolder(const std::string& name, std::string*& result, const std::string& path) { //TODO: implement method return true; } bool modelCDMFolder::OpenCMakeListsFile(std::string*& result) { //TODO: implement method return true; } const bool modelCDMFolder::Refresh(std::string*& result) { //TODO: implement method return true; } modelCDMCMakeListsFile* modelCDMFolder::GetCMakeLists() const { return this->CMakeLists; } std::vector modelCDMFolder::GetFolders() const { return this->folders; } bool modelCDMFolder::HasCMakeLists() { return this->CMakeLists != NULL; }