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