2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
31 #include "boost/filesystem.hpp"
32 //#include "boost/filesystem/operations.hpp"
33 //#include "boost/filesystem/path.hpp"
35 namespace bf = boost::filesystem;
37 //using namespace bbtk;
39 int main(int argc, char **argv)
43 std::cout << "usage : bbConfigurator <path_to_bbs> <package_name> <output_path>" << std::endl;
47 std::string path_bbs(argv[1]);
48 std::string package_name(argv[2]);
49 std::string path_out(argv[3]);
51 std::vector<bf::path> files;
53 bf::path pth(path_bbs.c_str());
54 if(bf::exists(pth) && bf::is_directory(pth))
56 bf::directory_iterator end_itr;
57 for(bf::directory_iterator itr(pth); itr != end_itr; ++itr)
59 if(!is_directory(itr->status()))
61 std::string nm(itr->path().filename().string());
62 if(nm.substr(nm.size()-4) == ".bbs")
64 std::cout << itr->path().filename().string() << std::endl;
65 files.push_back(itr->path());
72 std::cout<< "the path to the bbs's should be a folder and not a file.";
76 for (int i = 0; i < (int)files.size()-1; ++i) {
77 for (int j = i+1; j < (int)files.size(); ++j) {
78 if(files[j].filename().string() < files[i].filename().string())
80 bf::path tmp = files[i];
88 std::string fname = path_out + "\\" + package_name + ".bbp";
90 std::string fname = path_out + "/" + package_name + ".bbp";
93 std::ofstream out(fname.c_str());
94 out << "#-----------------------------------------" << std::endl;
95 out << "# Include script for bbtk package '" << package_name << "'" << std::endl;
96 out << "# Automatically generated by bbpConfigurator" << std::endl;
97 out << "#-----------------------------------------" << std::endl;
98 out << "load "<< package_name << std::endl;
99 out << "#-----------------------------------------" << std::endl;
100 out << "package "<< package_name << std::endl;
101 out << "#-----------------------------------------" << std::endl;
103 //each bbs file ordered.
104 //include [package_name]/boxes/[file_bbs]
105 //#-----------------------------------------
106 for (int i = 0; i < (int)files.size(); ++i) {
107 out << "include " << package_name << "/boxes/" << files[i].filename().string() << std::endl;
108 out << "#-----------------------------------------" << std::endl;
111 out << "endpackage" << std::endl;
112 out << "#-- EOF ----------------------------------" << std::endl;
118 //==========================================================================