]> Creatis software - bbtk.git/blob - kernel/appli/bbPlugPackage/bbPlugPackage.cpp
e8fd7f905b7eeb224acb136636e7d57bcf7ba8c6
[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 (int)1;
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" << std::endl;
23       return (int)2; 
24     }
25         
26   std::ifstream f;
27   f.open(fname.c_str());
28   std::string pname;
29   f >> pname;
30   f.close();
31   
32   
33   ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
34   
35   std::string command;
36 #if defined(WIN32)
37         command = "\"";
38 #endif
39   command += ConfigurationFile::GetInstance().Get_bin_path();
40   command += ConfigurationFile::GetInstance().Get_file_separator();
41   command += "bbRegeneratePackageDoc";
42 #if defined(WIN32)
43   command += "\"";
44 #endif
45   command += " " + pname + " -q";
46
47 if ( system ( command.c_str() ) )
48  {
49     std::cout << "An error occured while running '" 
50                 << command << "'" << std::endl;
51      // return 1; Feature #1676 - DFGO
52   }
53
54          
55
56   command = "";
57 #if defined(WIN32)
58   command = "\"";
59 #endif
60   command += ConfigurationFile::GetInstance().Get_bin_path();
61   command += ConfigurationFile::GetInstance().Get_file_separator();
62   command += "bbRegenerateBoxesLists";
63 #if defined(WIN32)
64   command += "\"";
65 #endif
66   command += " -q";
67  
68   if ( ! system ( command.c_str() ) )
69     {
70       std::cout << "Package '" 
71                 << pname << "' successfully plugged in" << std::endl;
72     }
73   else 
74     {
75       std::cout << "An error occured while running '" 
76                 << command << "'" << std::endl;
77       //return 1; Feature #1676 - DFGO
78     }
79   return (int)0;
80 }
81 //==========================================================================
82
83