]> Creatis software - bbtk.git/blob - kernel/appli/bbPlugPackage/bbPlugPackage.cpp
*** empty log message ***
[bbtk.git] / kernel / appli / bbPlugPackage / bbPlugPackage.cpp
1
2 #include <bbtkConfigurationFile.h>
3 #include <bbtkUtilities.h>
4 #include <stdlib.h>
5 using namespace bbtk;
6
7
8 //==========================================================================
9 int main(int argc, char **argv)
10 {
11   if (argc!=2)
12     {
13       std::cout << "usage : bbPlugPackage <path_to_package>" << std::endl;
14       return 0;
15     }
16
17   std::string path(argv[1]);
18   std::string fname = path + "/bbtkPackage"; 
19
20   if ( ! Utilities::FileExists( fname ) )
21     {
22       std::cout << "* ERROR : The directory '"<<path<<"' does not contain a 'bbtkPackage' file"
23                 << std::endl;
24       return 1; 
25     }
26         
27   std::ifstream f;
28   f.open(fname.c_str());
29   std::string pname;
30   f >> pname;
31   f.close();
32   
33   
34   ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
35   
36   std::string command;
37   command = ConfigurationFile::GetInstance().Get_bin_path();
38   command += ConfigurationFile::GetInstance().Get_file_separator();
39   command += "bbRegeneratePackageDoc " + pname + " -q && ";
40   command += ConfigurationFile::GetInstance().Get_bin_path();
41   command += ConfigurationFile::GetInstance().Get_file_separator();
42   command += "bbRegenerateBoxesLists -q ";
43  
44   if ( ! system ( command.c_str() ) )
45     {
46       std::cout << "Package '" 
47                 << pname << "' successfully plugged in" << std::endl;
48     }
49   else 
50     {
51       std::cout << "An error occured while running '" 
52                 << command << "'" << std::endl;
53       return 1;
54     }
55   return 0;
56 }
57 //==========================================================================
58
59