/* * ControlCreaDevManagerMain.cpp * * Created on: 5/11/2012 * Author: daniel */ #include "ControlCreaDevManagerMain.h" #include #include ControlCreaDevManagerMain::ControlCreaDevManagerMain() { } ControlCreaDevManagerMain::~ControlCreaDevManagerMain() { } const modelCDMProjectsTree& ControlCreaDevManagerMain::GetActiveProjects() const { return projectsTree; } bool ControlCreaDevManagerMain::LoadActiveProjects() { // TODO LoadActiveProjects std::cerr << "LoadActiveProjects unimplemented yet" << std::endl; return true; } bool ControlCreaDevManagerMain::UpdateActiveProjects() { // TODO UpdateActiveProjects std::cerr << "UpdateActiveProjects unimplemented yet" << std::endl; return true; } const int ControlCreaDevManagerMain::OpenProject(const std::string& actualpath) { std::string path = actualpath; std::cout << "selection path: "<< path << std::endl; std::string path1 = path + "/Makefile"; FILE* pFile = fopen(path1.c_str(), "r"); if(pFile == NULL) // not the binary folder { std::cerr << path1 << ": file not found..." << std::endl; path1 = path + "/CMakeLists.txt"; pFile = fopen(path1.c_str(), "r"); if(pFile == NULL) //not the source folder { std::cerr << path1 << ": file not found..." << std::endl; return 1; }else{//source folder std::cout << "sources folder found..." << std::endl; fclose(pFile); } }else{//binary folder std::cout << "binary folder found..." << std::endl; fclose(pFile); std::ifstream readFile; readFile.open(path1.c_str()); std::string word; bool found = false; while(!found && readFile >> word) { //cout << word << endl; if(word == "CMAKE_SOURCE_DIR") { readFile >> word; readFile.ignore(); getline(readFile, word, '\n'); path = word; found = true; } } readFile.close(); if(!found) { std::cerr << "sources not found..." << std::endl; return 2; }else{ pFile = fopen(path.c_str(), "r"); std::cout << "sources at " << path << " open = " << (pFile != NULL) << std::endl; std::cout.flush(); } } projectsTree.SetRoot(path); projectsTree.populateNode(path); return 0; } bool ControlCreaDevManagerMain::CloseProject(const std::string& projectName) { // TODO CloseProject std::cerr << "CloseProject unimplemented yet" << std::endl; return true; }