]> Creatis software - crea.git/blob - lib/creaDevManagerLib/ControlCreaDevManagerMain.cpp
add previous authors
[crea.git] / lib / creaDevManagerLib / ControlCreaDevManagerMain.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and 
11 #  abiding by the rules of distribution of free software. You can  use, 
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13 #  license as circulated by CEA, CNRS and INRIA at the following URL 
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability. 
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ 
26 */ 
27
28
29 /*
30  * ControlCreaDevManagerMain.cpp
31  *
32  *  Created on: 5/11/2012
33  *      Author: daniel
34  */
35
36 #include "ControlCreaDevManagerMain.h"
37
38 #include <cstdio>
39 #include <fstream>
40
41 ControlCreaDevManagerMain::ControlCreaDevManagerMain()
42 {
43 }
44
45 ControlCreaDevManagerMain::~ControlCreaDevManagerMain()
46 {
47 }
48
49 const modelCDMProjectsTree& ControlCreaDevManagerMain::GetActiveProjects() const
50 {
51   return projectsTree;
52 }
53
54 bool ControlCreaDevManagerMain::LoadActiveProjects()
55 {
56   // TODO LoadActiveProjects
57   std::cerr << "LoadActiveProjects unimplemented yet" << std::endl;
58   return true;
59 }
60
61 bool ControlCreaDevManagerMain::UpdateActiveProjects()
62 {
63   // TODO UpdateActiveProjects
64   std::cerr << "UpdateActiveProjects unimplemented yet" << std::endl;
65   return true;
66 }
67
68 const int ControlCreaDevManagerMain::OpenProject(const std::string& actualpath)
69 {
70   std::string path = actualpath;
71   std::cout << "selection path: "<< path << std::endl;
72   std::string path1 = path + "/Makefile";
73   FILE* pFile = fopen(path1.c_str(), "r");
74   if(pFile == NULL) // not the binary folder
75   {
76     std::cerr << path1 << ": file not found..." << std::endl;
77     path1 = path + "/CMakeLists.txt";
78     pFile = fopen(path1.c_str(), "r");
79     if(pFile == NULL) //not the source folder
80     {
81       std::cerr << path1 << ": file not found..." << std::endl;
82       return 1;
83     }else{//source folder
84       std::cout << "sources folder found..." << std::endl;
85       fclose(pFile);
86     }
87   }else{//binary folder
88     std::cout << "binary folder found..." << std::endl;
89     fclose(pFile);
90
91     std::ifstream readFile;
92     readFile.open(path1.c_str());
93     std::string word;
94     bool found = false;
95
96     while(!found && readFile >> word)
97     {
98       //cout << word << endl;
99       if(word == "CMAKE_SOURCE_DIR")
100       {
101         readFile >> word;
102         readFile.ignore();
103         getline(readFile, word, '\n');
104         path = word;
105         found = true;
106       }
107     }
108     readFile.close();
109
110     if(!found)
111     {
112         std::cerr << "sources not found..." << std::endl;
113
114         return 2;
115     }else{
116         pFile = fopen(path.c_str(), "r");
117         std::cout << "sources at " << path << " open = " << (pFile != NULL) << std::endl;
118         std::cout.flush();
119     }
120   }
121
122   projectsTree.SetRoot(path);
123   projectsTree.populateNode(path);
124   return 0;
125 }
126
127 bool ControlCreaDevManagerMain::CloseProject(const std::string& projectName)
128 {
129   // TODO CloseProject
130   std::cerr << "CloseProject unimplemented yet" << std::endl;
131   return true;
132 }