]> Creatis software - bbtk.git/blob - kernel/src/bbtkConfigurationFile.cxx
#342 8BBTK Feature New Normal - Clean PlugPackage Windows
[bbtk.git] / kernel / src / bbtkConfigurationFile.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
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
9  #
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.
16  #
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
21  #  liability.
22  #
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  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbtkConfigurationFile.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:49:01 $
33   Version:   $Revision: 1.38 $
34 =========================================================================*/
35
36
37
38 /**
39  *\file
40  *\brief Class bbtk::ConfigurationFile
41  */
42
43 #include "bbtkConfigurationFile.h"
44 #include "bbtkMessageManager.h"
45 #include "bbtkXML.h"
46 #include "bbtkUtilities.h"
47
48 #include "creaSystem.h"
49
50 #if defined(WIN32)
51 # include <direct.h> // for getcwd
52 # include <windows.h>
53 #endif
54
55
56 namespace bbtk
57 {
58   //====================================================================
59   /// Constructor
60   ConfigurationFile::ConfigurationFile()
61   {
62     mFile_separator = VALID_FILE_SEPARATOR;
63
64     // ==> Set system paths
65     mBin_path = Utilities::GetExecutablePath();
66
67
68 /*      EED 23 Mars 2009
69 #ifdef MACOSX
70     mInstall_path = mBin_path + "/../../../..";
71 #else
72     mInstall_path = mBin_path + "/..";
73 #endif
74 */
75 #ifdef MACOSX
76           std::string macPath("Contents/MacOS");
77           int sbp = mBin_path.length();
78           int smp = macPath.length();
79           if (mBin_path.compare( sbp-smp, smp, macPath )==0 )
80           {
81                   mBin_path = mBin_path + "/../../..";
82           }
83 #endif
84
85
86 ///\TODO : better use ??
87           mInstall_path = mBin_path + "/..";
88
89     // The relative path to the doc folder (=BBTK_DOC_REL_PATH)
90     //    mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH);
91     // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
92     //    mDoc_path = mInstall_path + "/" + mDoc_rel_path;
93     // Have to create bbtk user's dirs if needed
94
95     // LG 27/01/09 : doc is now user dependent
96     //               and located in user's .bbtk dir /doc
97     // All dirs under .bbtk user's dir are set and created by:
98     InitializeDotBbtkStructure();
99
100     // The relative path to the doc folder (=BBTK_BBS_REL_PATH)
101     mBbs_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_BBS_REL_PATH);
102     // The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
103     mBbs_path = mInstall_path + "/" + mBbs_rel_path;
104
105     mData_path = mInstall_path + "/" + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
106
107     Utilities::replace( mBin_path,
108                         INVALID_FILE_SEPARATOR,
109                         VALID_FILE_SEPARATOR);
110     Utilities::replace( mInstall_path,
111                         INVALID_FILE_SEPARATOR,
112                         VALID_FILE_SEPARATOR);
113     Utilities::replace( mBbs_path,
114                         INVALID_FILE_SEPARATOR,
115                         VALID_FILE_SEPARATOR);
116     Utilities::replace( mData_path,
117                         INVALID_FILE_SEPARATOR,
118                         VALID_FILE_SEPARATOR);
119
120     bbtkMessage("config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
121     bbtkMessage("config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
122     bbtkMessage("config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
123     bbtkMessage("config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
124     bbtkMessage("config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
125
126     // bbs_paths
127     // always add "." (current working directory) at the begining
128     mBbs_paths.push_back( "." );
129     // add system bbs path
130     mBbs_paths.push_back(mBbs_path);
131     // add toolsbbtk/appli
132 //EED    std::string toolsappli_rel_path(mFile_separator);
133     std::string toolsappli_rel_path("/");
134 //EED    toolsappli_rel_path +=  "toolsbbtk" + mFile_separator + "appli";
135     toolsappli_rel_path +=  "toolsbbtk/appli";
136     //
137     //-----------------------------------------------------------
138     // LG : REMOVE BUGGY PATH WITH include *:
139     //
140     //    mBbs_paths.push_back(mBbs_path + toolsappli_rel_path);
141     //-----------------------------------------------------------
142     int iStrVec,sizeStrVec;
143
144     sizeStrVec = mBbs_paths.size();
145     for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
146       Utilities::replace( mBbs_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
147     }
148
149     // always add "." (current working directory) at the begining
150     mPackage_paths.push_back(".");
151     // add system bin path (for build tree / standalone folder install)
152     mPackage_paths.push_back(mBin_path);
153     // add system lib path (for install tree)
154     //EED    mPackage_paths.push_back(mInstall_path + mFile_separator + "lib");
155     
156     //mPackage_paths.push_back(mInstall_path + "/lib"); // JPR
157     //mPackage_paths.push_back(mInstall_path + "/lib64");// JPR
158     
159     ///\TODO : better use BBTK_PACKAGE_LIB_PATH  // JPR
160     
161     mPackage_paths.push_back(mInstall_path + "/lib/creatools");
162     mPackage_paths.push_back(mInstall_path + "/lib64/creatools");
163 #ifdef WIN32
164     // add bin/Debug bin/Release paths (for build/install tree)
165     //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Debug");
166     mPackage_paths.push_back(mBin_path + "/Debug");
167     //EED    mPackage_paths.push_back(mBin_path + mFile_separator + "Release");
168     mPackage_paths.push_back(mBin_path + "/Release");
169 #endif
170
171     sizeStrVec = mPackage_paths.size();
172     for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){
173       Utilities::replace( mPackage_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
174     }
175
176     GetHelp(2);
177
178     // ==> First we look for bbtk_config.xml in "."
179     char buf[2048];
180     const char *currentDir = getcwd(buf, 2048);
181
182     if( !currentDir )
183       {
184         std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl;
185         // \todo : what else?
186         // How abort a constructor and warn the caller function?
187         // LG : throw an exception
188       }
189
190     //    std::string configXmlFullPathName = currentDir + mFile_separator + "bbtk_config.xml";
191     std::string configXmlFullPathName = currentDir ;
192     configXmlFullPathName += "/bbtk_config.xml";
193     Utilities::replace( configXmlFullPathName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
194
195     if ( Utilities::FileExists( configXmlFullPathName ))
196       {
197         bbtkMessage("config",1, "ConfigurationFile : [" << configXmlFullPathName <<
198                     "] found in current directory" << std::endl);
199         //Read(configXmlFullPathName.c_str());
200         // traiter le fichier local
201       }
202
203     // ==> Then we look for bbtk_config.xml in ".bbtk"
204     else
205       {
206         configXmlFullPathName = Utilities::MakeUserSettingsFullFileName("bbtk_config.xml");
207         if (!Utilities::FileExists( configXmlFullPathName ))
208           {
209             // ==> Nothing found, we create bbtk_config.xml in ".bbtk"
210             InstallPath ();
211           }
212       }
213
214     // In any case, deal with bbtk_config.xml!
215     Read(configXmlFullPathName.c_str());
216         
217   }
218   //=========================================================================
219
220   //=========================================================================
221   /// Destructor
222   ConfigurationFile::~ConfigurationFile()
223   {
224   }
225   //=========================================================================
226
227   //=========================================================================
228   void ConfigurationFile::InitializeDotBbtkStructure()
229   {
230     mDot_bbtk_path = Utilities::GetUserSettingsDir();
231     mDot_bbtk_is_new = false;
232     if (!Utilities::FileExists(mDot_bbtk_path)) mDot_bbtk_is_new = true;
233     Utilities::CreateDirectoryIfNeeded(mDot_bbtk_path);
234
235
236     mDoc_path = Utilities::MakeUserSettingsFullFileName("doc");
237     Utilities::CreateDirectoryIfNeeded(mDoc_path);
238
239     std::string bbdoc_path =
240       Utilities::MakeUserSettingsFullFileName("doc/bbdoc");
241     Utilities::CreateDirectoryIfNeeded(bbdoc_path);
242
243     // Create help_contents.html if does not exist
244     std::string filename = Utilities::MakeUserSettingsFullFileName("doc/help_contents.html");
245     if (!Utilities::FileExists(filename))
246       {
247                         bbtkDebugMessage("config",1,
248                          "* Creating [" << filename << "]" << std::endl);
249                         // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
250                         std::string doc_path = mInstall_path + "/"
251                           + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/";
252                         Utilities::MakeValidFileName(doc_path);
253
254                         std::ofstream f;
255                         f.open(filename.c_str(), std::ios::out );
256                         f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
257                           << "HTML 4.01 Transitional//EN\">"
258                           << "<html><head><title>Help Contents - bbtk "
259                           << GetVersion() << "</title>"
260                           << "<meta http-equiv=\"Content-Type\" content=\"text/html; "
261                           << "charset=iso-8859-1\"></head><H1>Help Contents</H1>"
262                           << "<a href=\"bbdoc/index-category.html#demo\" "
263                           << "target=\"information\">Demos</a><br>"
264                           << "<a href=\"bbdoc/index-category.html#example\" "
265                           << "target=\"information\">Examples</a>"
266                           << "<H2>Guides</H2>"
267                           << "<a href=\""
268                           << doc_path
269                           << "bbtkUsersGuide/bbtkUsersGuide.pdf"
270                           << "\" target=\"information\">User's Guide</a><br>"
271                           << "<a href=\""
272                           << doc_path
273                           << "bbtkDevelopersGuide/bbtkDevelopersGuide.pdf"
274                           << "\" target=\"information\">Developer's Guide</a><br>"
275                           << "<a href=\""
276                           << doc_path
277                           << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.pdf"
278                           << "\" target=\"information\">Package Developer's Guide</a><br>"
279                           << "<a href=\""
280                           << doc_path
281                           << "doxygen/bbtk/main.html"
282                           << "\" target=\"information\">bbtk library doxygen doc</a><br>"
283                           << "<H2>Boxes</H2>"
284                           << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">"
285                           << "Alphabetical list</a><br>"
286                           << "<a target=\"information\" href=\"bbdoc/index-package.html\">"
287                           << "List by package</a><br>"
288                           << "<a target=\"information\" href=\"bbdoc/index-category.html\">"
289                           << "List by category</a><br>"
290                           << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">"
291                           << "List of adaptors</a><br>"
292                           << "</body>"
293                   << "</html>";
294       } // if
295
296     mTemp_path = Utilities::MakeUserSettingsFullFileName("tmp");
297     Utilities::CreateDirectoryIfNeeded(mTemp_path);
298
299
300   }
301   //=========================================================================
302
303   //=========================================================================
304   void ConfigurationFile::CreateConfigXML( char *rootDirectory )
305   {
306     FILE *fp;
307     char configXml[250];
308     sprintf (configXml , "%s/bbtk_config.xml", rootDirectory);
309     bbtkDebugMessage("config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
310     fp = fopen (configXml, "w");
311     fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
312     fprintf(fp, "<config>\n");
313     fprintf(fp, "   <bbs_path>     </bbs_path>\n");
314     fprintf(fp, "   <package_path> </package_path>\n");
315     fprintf(fp, "</config>\n");
316     fclose(fp);
317   }
318   //=========================================================================
319
320
321
322
323   //=========================================================================
324   void ConfigurationFile::InstallPath ()
325   {
326
327     /*--------------------------------------------------
328       New policy for bbtk_config.xml :
329
330       if bbtk_config.xml found in current directory (user is an aware user!)
331       use it!
332
333       else if bbtk_config.xml found in HOME/.bbtk (user already worked with it)
334       use it!
335
336       else if bbtk_config.xml.tmp found in /usr/local/bin or c:\\Program Files\\BBTK\\bin
337       copy it as .bbtk/bbtk_config.xml
338
339       else (nothing installed)
340       create a minimum version in HOME/.bbtk
341       ----------------------------------------------------*/
342
343
344     // -----------------------------------------------------------------
345 #if defined(WIN32)
346
347     // installed bbtk_path
348     char bbtk_path[100];
349     strcpy(bbtk_path, "\"c:\\Program Files\\BBTK\\bin\"");
350     char bbtk_path2[100];
351     strcpy(bbtk_path2, "c:\\Program Files\\BBTK\\bin");
352
353     // rootDirectory
354     char rootDirectory[200];
355     sprintf(rootDirectory, "%s\\.bbtk",getenv("USERPROFILE"));
356     //  std::cout << "[" << rootDirectory << "]" << std::endl;
357
358     // configPath
359     char configPath[200];
360     sprintf(configPath, "%s\\bbtk_config.xml",rootDirectory);
361
362     // makeDir
363     char makeDir[250];
364     sprintf( makeDir, "mkdir \"%s\" ", rootDirectory);
365
366     // configXmlTmp
367     char configXmlTmp[250];
368     sprintf(configXmlTmp, "%s\\bbtk_config.xml.tmp", bbtk_path2);
369
370     // copyFile
371     char copyFile[250];
372
373     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found
374       {
375         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
376         CreateConfigXML( rootDirectory );// create .bbtk
377         return;
378       }
379
380     sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory );
381
382         WCHAR    rootDirectory2[200];
383         MultiByteToWideChar( 0,0, rootDirectory, 200, rootDirectory2, 6);
384         LPCWSTR rootDirectory3 = rootDirectory2;
385         int attribs = GetFileAttributes (rootDirectory3);
386 //    int attribs = GetFileAttributes (rootDirectory3);
387         
388         
389     bbtkMessage("config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
390     if ( attribs != 0xFFFFFFFF)
391     {
392                 if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) /// \TODO : check !
393                 {       
394                         WCHAR    configPath2[200];
395                         MultiByteToWideChar( 0,0, configPath, 200, configPath2, 6);
396                         LPCWSTR configPath3 = configPath2;
397                         if ( GetFileAttributes( configPath3 ) == 0xFFFFFFFF)
398                         //if ( GetFileAttributes( configPath ) == 0xFFFFFFFF)
399                         {
400                                 system(copyFile);
401                         }
402                 }
403     } else {
404                 system(makeDir);
405                 system(copyFile);
406         }
407   return;
408     // ------------------------------------------------------------------
409 #elif defined(__GNUC__)
410     // ------------------ create some usefull strings ----------------
411     // installed bbtk_path
412     char bbtk_path[1000];
413     strcpy(bbtk_path, Utilities::GetExecutablePath().c_str());  // JPR
414     //strcpy(bbtk_path, "/usr/local/bin");
415
416
417     std::string str_home=Utilities::GetEnvHome();
418
419         #if defined(WIN32)      
420                 str_home="C:"+str_home;
421         #endif
422
423     // rootDirectory
424     char rootDirectory[200];
425     sprintf( rootDirectory,  "%s/.bbtk", str_home.c_str());
426
427     // configPath
428     char configPath[200];
429     sprintf(configPath, "%s/bbtk_config.xml",rootDirectory);
430
431     // configXmlTmp
432     char configXmlTmp[250];
433     sprintf(configXmlTmp, "%s/bbtk_config.xml.tmp", bbtk_path);
434
435     // copyFile
436     char copyFile[250];
437
438     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found (not installed)
439     {
440                 // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
441                 CreateConfigXML( rootDirectory );// create .bbtk
442     } else {
443                 sprintf(copyFile,"cp %s  %s/bbtk_config.xml ",configXmlTmp,rootDirectory );
444                 if (!Utilities::FileExists(configPath))
445                 {
446                     system(copyFile);
447                 } // FileExists configPath
448     } // FileExists configXmlTmp
449     return;
450
451     // ------------------------------------------------------------------
452 #else
453 /// \todo  ConfigurationFile::InstallPath() : exit when for not WIN32 and not__GNUC__
454
455   return;
456 #endif
457
458 }
459   //=========================================================================
460
461
462
463   //=========================================================================
464   // Gets the list of directories holding bb scripts, packages, dll, ... from the xml file
465   //      bbtk_config.xml
466
467   void ConfigurationFile::Read(const std::string& filename)
468   {
469
470     bbtkDebugMessage("config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
471
472     mConfig_xml_full_path = filename;
473     XMLResults* res = new XMLResults;
474     XMLNode BB = XMLNode::parseFile((XMLCSTR)filename.c_str(),(XMLCSTR)"config",res);
475
476     if ( res->error != eXMLErrorNone )
477       {
478         std::string mess = GetErrorMessage(res,filename);
479         delete res;
480         bbtkDebugMessage("config",1,mess<< std::endl);
481         bbtkError(mess);
482       }
483     delete res;
484
485     bbtkDebugMessage("config",1,"OK" << std::endl);
486
487     int i,j;
488
489     // Description
490     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"description"); i++)
491       {
492         std::string val;
493         GetTextOrClear(BB.getChildNode((XMLCSTR)"description",&j),val);
494         mDescription += val;
495       }
496
497     // Url
498     if( BB.nChildNode((XMLCSTR)"url") )
499       GetTextOrClear(BB.getChildNode((XMLCSTR)"url"),mUrl);
500
501     // Data_Path
502     if( BB.nChildNode((XMLCSTR)"data_path") )
503       GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path);
504
505     // install_path
506     //  if( BB.nChildNode((XMLCSTR)"install_path") )
507     //   GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
508
509     // add user bbs paths
510     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++)
511       {
512         std::string val;
513         GetTextOrClear(BB.getChildNode((XMLCSTR)"bbs_path",&j),val);
514         mBbs_paths.push_back(val);
515       }
516
517     // package_paths
518
519     // add user package path
520     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"package_path"); i++)
521       {
522         std::string val;
523         GetTextOrClear(BB.getChildNode((XMLCSTR)"package_path",&j),val);
524         mPackage_paths.push_back(val);
525       }
526
527     // default_temp_dir
528     /*
529     if( BB.nChildNode((XMLCSTR)"default_temp_dir") )
530       GetTextOrClear(BB.getChildNode((XMLCSTR)"default_temp_dir"),mDefault_temp_dir);
531
532     if ( mDefault_temp_dir == "$") // no value found in config_xml
533       {
534         size_t pos = mConfig_xml_full_path.find("bbtk_config.xml");
535         mDefault_temp_dir = mConfig_xml_full_path.substr (0,pos);
536       }
537     */
538
539     GetHelp(2);
540   }
541   //=========================================================================
542
543   //=========================================================================
544   bool ConfigurationFile::AddPackagePathsAndWrite( const std::string& path )
545   {
546     bbtkDebugMessageInc("config",9,
547                         "ConfigurationFile::AddPackagePathsAndWrite("
548                         <<path<<")"<<std::endl);
549
550      XMLResults* res = new XMLResults;
551     XMLNode BB =
552       XMLNode::parseFile((XMLCSTR)Get_config_xml_full_path().c_str(),
553                          (XMLCSTR)"config",res);
554
555     if ( res->error != eXMLErrorNone )
556       {
557         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
558         delete res;
559         bbtkDebugMessage("config",1,mess<< std::endl);
560         bbtkError(mess);
561       }
562    delete res;
563
564         std::string bbs_path;
565 #ifdef _WIN32
566     bbs_path = path + "/bbs";
567     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
568     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
569     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
570     mBbs_paths.push_back(bbs_path);
571 #else
572     bbs_path = path + "/share/bbtk/bbs" ;
573     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
574     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
575     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
576     mBbs_paths.push_back(bbs_path);
577
578     bbs_path = path + "/../../share/bbtk/bbs" ;
579     BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
580     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
581     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
582     mBbs_paths.push_back(bbs_path);
583
584 #endif
585
586         std::string pack_path;
587 #ifdef _WIN32
588     pack_path = path;
589     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
590     PACKPATH.addText((XMLCSTR)pack_path.c_str());
591     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
592     mPackage_paths.push_back(pack_path);
593
594     pack_path = path + "/bin";
595     PACKPATH = BB.addChild((XMLCSTR)"package_path");
596     PACKPATH.addText((XMLCSTR)pack_path.c_str());
597     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
598     mPackage_paths.push_back(pack_path);
599
600 //    pack_path = path + "/RelWithDebInfo";
601 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
602 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
603 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
604 //    mPackage_paths.push_back(pack_path);
605
606 //    pack_path = path + "/Debug";
607 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
608 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
609 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
610 //    mPackage_paths.push_back(pack_path);
611
612 //    pack_path = path + "/Release";
613 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
614 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
615 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
616 //    mPackage_paths.push_back(pack_path);
617 #else
618     pack_path = path ;
619     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
620     PACKPATH.addText((XMLCSTR)pack_path.c_str());
621     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
622     mPackage_paths.push_back(pack_path);
623
624     pack_path = path+"/../../lib64/creatools" ;
625     PACKPATH = BB.addChild((XMLCSTR)"package_path");
626     PACKPATH.addText((XMLCSTR)pack_path.c_str());
627     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
628     mPackage_paths.push_back(pack_path);
629
630 #endif
631
632
633 #ifdef _WIN32
634 #endif
635
636
637     XMLError err = BB.writeToFile((XMLCSTR)Get_config_xml_full_path().c_str());
638     if ( err != eXMLErrorNone )
639       {
640         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
641         bbtkDebugMessage("config",1,mess<< std::endl);
642         bbtkError(mess);
643       }
644
645     return true;
646   }
647   //=========================================================================
648
649   //=========================================================================
650   void ConfigurationFile::GetHelp(int level) const
651   {
652     bbtkDebugMessageInc("config",9,"ConfigurationFile::GetHelp("<<level
653                         <<")"<<std::endl);
654
655     const std::string config_xml_full_path      = Get_config_xml_full_path();
656     const std::string description               = Get_description();
657     const std::string url                       = Get_doc_path();
658     const std::string data_path                 = Get_data_path();
659     const std::string default_temp_dir          = Get_default_temp_dir();
660     const std::string file_separator            = Get_file_separator();
661     const std::vector<std::string>bbs_paths     = Get_bbs_paths();
662     const std::vector<std::string>package_paths = Get_package_paths();
663
664     bbtkMessage("help",level, "============="   << std::endl);
665     bbtkMessage("help",level, "Configuration"   << std::endl);
666     bbtkMessage("help",level, "============="   << std::endl);
667     bbtkMessage("help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl);
668     bbtkMessage("help",level, "Documentation Path : [" << url             << "]" << std::endl);
669     bbtkMessage("help",level, "Data Path          : [" << data_path       << "]" << std::endl);
670     bbtkMessage("help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
671     bbtkMessage("help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
672
673     std::vector<std::string>::const_iterator i;
674
675     bbtkMessage("help",level, "BBS Paths   " << std::endl);
676     for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i )
677     {
678       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
679     }
680
681     bbtkMessage("help",level, "PACKAGE Paths : " << std::endl);
682     for (i = package_paths.begin(); i!=package_paths.end(); ++i )
683     {
684       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
685     }
686
687     bbtkDebugDecTab("config",9);
688   }
689   //=========================================================================
690
691
692 } // namespace bbtk