]> 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 #if defined(WIN32)
38         command = "\"";
39 #endif
40   command += ConfigurationFile::GetInstance().Get_bin_path();
41   command += ConfigurationFile::GetInstance().Get_file_separator();
42   command += "bbRegeneratePackageDoc";
43 #if defined(WIN32)
44   command += "\"";
45 #endif
46   command += " " + pname + " -q";
47
48 if ( system ( command.c_str() ) )
49  {
50     std::cout << "An error occured while running '" 
51                 << command << "'" << std::endl;
52       return 1;
53   }
54
55          
56
57   command = "";
58 #if defined(WIN32)
59   command = "\"";
60 #endif
61   command += ConfigurationFile::GetInstance().Get_bin_path();
62   command += ConfigurationFile::GetInstance().Get_file_separator();
63   command += "bbRegenerateBoxesLists";
64 #if defined(WIN32)
65   command += "\"";
66 #endif
67   command += " -q";
68  
69   if ( ! system ( command.c_str() ) )
70     {
71       std::cout << "Package '" 
72                 << pname << "' successfully plugged in" << std::endl;
73     }
74   else 
75     {
76       std::cout << "An error occured while running '" 
77                 << command << "'" << std::endl;
78       return 1;
79     }
80   return 0;
81 }
82 //==========================================================================
83
84