]> Creatis software - bbtk.git/blob - kernel/src/bbtkConfigurationFile.cxx
#3510 Bug Install bbtk package Linux MacOs
[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     {
174       Utilities::replace( mPackage_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
175     } // for iStrVec
176
177     GetHelp(2);
178
179     // ==> First we look for bbtk_config.xml in "."
180     char buf[2048];
181     const char *currentDir = getcwd(buf, 2048);
182
183     if( !currentDir )
184       {
185         std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl;
186         // \todo : what else?
187         // How abort a constructor and warn the caller function?
188         // LG : throw an exception
189       }
190
191     //    std::string configXmlFullPathName = currentDir + mFile_separator + "bbtk_config.xml";
192     std::string configXmlFullPathName = currentDir ;
193     configXmlFullPathName += "/bbtk_config.xml";
194     Utilities::replace( configXmlFullPathName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
195
196     if ( Utilities::FileExists( configXmlFullPathName ))
197     {
198         bbtkMessage("config",1, "ConfigurationFile : [" << configXmlFullPathName <<
199                     "] found in current directory" << std::endl);
200         //Read(configXmlFullPathName.c_str());
201         // traiter le fichier local
202     }    else {   // ==> Then we look for bbtk_config.xml in ".bbtk"
203         configXmlFullPathName = Utilities::MakeUserSettingsFullFileName("bbtk_config.xml");
204         if (!Utilities::FileExists( configXmlFullPathName ))
205         {
206             // ==> Nothing found, we create bbtk_config.xml in ".bbtk"
207             InstallPath ();
208         } 
209     }
210
211     // In any case, deal with bbtk_config.xml!
212     Read(configXmlFullPathName.c_str());
213         
214   }
215   //=========================================================================
216
217   //=========================================================================
218   /// Destructor
219   ConfigurationFile::~ConfigurationFile()
220   {
221   }
222   //=========================================================================
223
224   //=========================================================================
225   void ConfigurationFile::InitializeDotBbtkStructure()
226   {
227     mDot_bbtk_path = Utilities::GetUserSettingsDir();
228     mDot_bbtk_is_new = false;
229     if (!Utilities::FileExists(mDot_bbtk_path)) mDot_bbtk_is_new = true;
230     Utilities::CreateDirectoryIfNeeded(mDot_bbtk_path);
231
232
233     mDoc_path = Utilities::MakeUserSettingsFullFileName("doc");
234     Utilities::CreateDirectoryIfNeeded(mDoc_path);
235
236     std::string bbdoc_path =
237       Utilities::MakeUserSettingsFullFileName("doc/bbdoc");
238     Utilities::CreateDirectoryIfNeeded(bbdoc_path);
239
240     // Create help_contents.html if does not exist
241     std::string filename = Utilities::MakeUserSettingsFullFileName("doc/help_contents.html");
242     if (!Utilities::FileExists(filename))
243       {
244                         bbtkDebugMessage("config",1,
245                          "* Creating [" << filename << "]" << std::endl);
246                         // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
247                         std::string doc_path = mInstall_path + "/"
248                           + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/";
249                         Utilities::MakeValidFileName(doc_path);
250
251                         std::ofstream f;
252                         f.open(filename.c_str(), std::ios::out );
253                         f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD "
254                           << "HTML 4.01 Transitional//EN\">"
255                           << "<html><head><title>Help Contents - bbtk "
256                           << GetVersion() << "</title>"
257                           << "<meta http-equiv=\"Content-Type\" content=\"text/html; "
258                           << "charset=iso-8859-1\"></head><H1>Help Contents</H1>"
259                           << "<a href=\"bbdoc/index-category.html#demo\" "
260                           << "target=\"information\">Demos</a><br>"
261                           << "<a href=\"bbdoc/index-category.html#example\" "
262                           << "target=\"information\">Examples</a>"
263                           << "<H2>Guides</H2>"
264                           << "<a href=\""
265                           << doc_path
266                           << "bbtkUsersGuide/bbtkUsersGuide.pdf"
267                           << "\" target=\"information\">User's Guide</a><br>"
268                           << "<a href=\""
269                           << doc_path
270                           << "bbtkDevelopersGuide/bbtkDevelopersGuide.pdf"
271                           << "\" target=\"information\">Developer's Guide</a><br>"
272                           << "<a href=\""
273                           << doc_path
274                           << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.pdf"
275                           << "\" target=\"information\">Package Developer's Guide</a><br>"
276                           << "<a href=\""
277                           << doc_path
278                           << "doxygen/bbtk/main.html"
279                           << "\" target=\"information\">bbtk library doxygen doc</a><br>"
280                           << "<H2>Boxes</H2>"
281                           << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">"
282                           << "Alphabetical list</a><br>"
283                           << "<a target=\"information\" href=\"bbdoc/index-package.html\">"
284                           << "List by package</a><br>"
285                           << "<a target=\"information\" href=\"bbdoc/index-category.html\">"
286                           << "List by category</a><br>"
287                           << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">"
288                           << "List of adaptors</a><br>"
289                           << "</body>"
290                   << "</html>";
291       } // if
292
293     mTemp_path = Utilities::MakeUserSettingsFullFileName("tmp");
294     Utilities::CreateDirectoryIfNeeded(mTemp_path);
295
296
297   }
298   //=========================================================================
299
300   //=========================================================================
301   void ConfigurationFile::CreateConfigXML( char *rootDirectory )
302   {
303     FILE *fp;
304     char configXml[250];
305     sprintf (configXml , "%s/bbtk_config.xml", rootDirectory);
306     bbtkDebugMessage("config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
307     fp = fopen (configXml, "w");
308     fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
309     fprintf(fp, "<config>\n");
310     fprintf(fp, "   <bbs_path>     </bbs_path>\n");
311     fprintf(fp, "   <package_path> </package_path>\n");
312     fprintf(fp, "</config>\n");
313     fclose(fp);
314   }
315   //=========================================================================
316
317
318
319
320   //=========================================================================
321   void ConfigurationFile::InstallPath ()
322   {
323     /*--------------------------------------------------
324       New policy for bbtk_config.xml :
325
326       if bbtk_config.xml found in current directory (user is an aware user!)
327       use it!
328
329       else if bbtk_config.xml found in HOME/.bbtk (user already worked with it)
330       use it!
331
332       else if bbtk_config.xml.tmp found in /usr/local/bin or c:\\Program Files\\BBTK\\bin
333       copy it as .bbtk/bbtk_config.xml
334
335       else (nothing installed)
336       create a minimum version in HOME/.bbtk
337       ----------------------------------------------------*/
338
339
340     // -----------------------------------------------------------------
341 #if defined(WIN32)
342
343     // installed bbtk_path
344     char bbtk_path[100];
345     strcpy(bbtk_path, "\"c:\\Program Files\\BBTK\\bin\"");
346     char bbtk_path2[100];
347     strcpy(bbtk_path2, "c:\\Program Files\\BBTK\\bin");
348
349     // rootDirectory
350     char rootDirectory[200];
351     sprintf(rootDirectory, "%s\\.bbtk",getenv("USERPROFILE"));
352     //  std::cout << "[" << rootDirectory << "]" << std::endl;
353
354     // configPath
355     char configPath[200];
356     sprintf(configPath, "%s\\bbtk_config.xml",rootDirectory);
357
358     // makeDir
359     char makeDir[250];
360     sprintf( makeDir, "mkdir \"%s\" ", rootDirectory);
361
362     // configXmlTmp
363     char configXmlTmp[250];
364     sprintf(configXmlTmp, "%s\\bbtk_config.xml.tmp", bbtk_path2);
365
366     // copyFile
367     char copyFile[250];
368
369     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found
370       {
371         // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
372         CreateConfigXML( rootDirectory );// create .bbtk
373         return;
374       }
375
376     sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory );
377         
378 // EED 2021-12-12
379         WCHAR    rootDirectory2[200];
380         MultiByteToWideChar( 0,0, rootDirectory, 200, rootDirectory2, 6);
381         LPCWSTR rootDirectory3 = rootDirectory2;
382         int attribs = GetFileAttributes (rootDirectory3);
383 //    int attribs = GetFileAttributes (rootDirectory);
384         
385         
386     bbtkMessage("config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl);
387     if ( attribs != 0xFFFFFFFF)
388     {
389                 if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) /// \TODO : check !
390                 {       
391 // EED 2021-12-12
392                         WCHAR    configPath2[200];
393                         MultiByteToWideChar( 0,0, configPath, 200, configPath2, 6);
394                         LPCWSTR configPath3 = configPath2;
395                         if ( GetFileAttributes( configPath3 ) == 0xFFFFFFFF)
396 //                      if ( GetFileAttributes( configPath ) == 0xFFFFFFFF)
397                         {
398                                 system(copyFile);
399                         }
400                 }
401     } else {
402                 system(makeDir);
403                 system(copyFile);
404         }
405   return;
406     // ------------------------------------------------------------------
407 #elif defined(__GNUC__)
408     // ------------------ create some usefull strings ----------------
409     // installed bbtk_path
410     char bbtk_path[1000];
411     strcpy(bbtk_path, Utilities::GetExecutablePath().c_str());  // JPR
412     //strcpy(bbtk_path, "/usr/local/bin");
413
414
415     std::string str_home=Utilities::GetEnvHome();
416
417         #if defined(WIN32)      
418                 str_home="C:"+str_home;
419         #endif
420
421     // rootDirectory
422     char rootDirectory[200];
423     sprintf( rootDirectory,  "%s/.bbtk", str_home.c_str());
424
425     // configPath
426     char configPath[200];
427     sprintf(configPath, "%s/bbtk_config.xml",rootDirectory);
428
429     // configXmlTmp
430     char configXmlTmp[250];
431     sprintf(configXmlTmp, "%s/bbtk_config.xml.tmp", bbtk_path);
432
433     // copyFile
434     char copyFile[250];
435
436     if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found (not installed)
437     {
438                 // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk
439                 CreateConfigXML( rootDirectory );// create .bbtk
440     } else {
441                 sprintf(copyFile,"cp %s  %s/bbtk_config.xml ",configXmlTmp,rootDirectory );
442                 if (!Utilities::FileExists(configPath))
443                 {
444                     system(copyFile);
445                 } // FileExists configPath
446     } // FileExists configXmlTmp
447       
448     return;
449
450     // ------------------------------------------------------------------
451 #else
452 /// \todo  ConfigurationFile::InstallPath() : exit when for not WIN32 and not__GNUC__
453
454   return;
455 #endif
456
457 }
458   //=========================================================================
459
460
461
462   //=========================================================================
463   // Gets the list of directories holding bb scripts, packages, dll, ... from the xml file
464   //      bbtk_config.xml
465
466   void ConfigurationFile::Read(const std::string& filename)
467   {
468
469     bbtkDebugMessage("config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl);
470
471     mConfig_xml_full_path = filename;
472     XMLResults* res = new XMLResults;
473     XMLNode BB = XMLNode::parseFile((XMLCSTR)filename.c_str(),(XMLCSTR)"config",res);
474
475     if ( res->error != eXMLErrorNone )
476       {
477         std::string mess = GetErrorMessage(res,filename);
478         delete res;
479         bbtkDebugMessage("config",1,mess<< std::endl);
480         bbtkError(mess);
481       }
482     delete res;
483
484     bbtkDebugMessage("config",1,"OK" << std::endl);
485
486     int i,j;
487
488     // Description
489     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"description"); i++)
490       {
491         std::string val;
492         GetTextOrClear(BB.getChildNode((XMLCSTR)"description",&j),val);
493         mDescription += val;
494       }
495
496     // Url
497     if( BB.nChildNode((XMLCSTR)"url") )
498       GetTextOrClear(BB.getChildNode((XMLCSTR)"url"),mUrl);
499
500     // Data_Path
501     if( BB.nChildNode((XMLCSTR)"data_path") )
502       GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path);
503
504     // install_path
505     //  if( BB.nChildNode((XMLCSTR)"install_path") )
506     //   GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
507
508     // add user bbs paths
509     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++)
510       {
511         std::string val;
512         GetTextOrClear(BB.getChildNode((XMLCSTR)"bbs_path",&j),val);
513         mBbs_paths.push_back(val);
514       }
515
516     // package_paths
517
518     // add user package path
519     for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"package_path"); i++)
520       {
521         std::string val;
522         GetTextOrClear(BB.getChildNode((XMLCSTR)"package_path",&j),val);
523         mPackage_paths.push_back(val);
524       }
525
526     // default_temp_dir
527     /*
528     if( BB.nChildNode((XMLCSTR)"default_temp_dir") )
529       GetTextOrClear(BB.getChildNode((XMLCSTR)"default_temp_dir"),mDefault_temp_dir);
530
531     if ( mDefault_temp_dir == "$") // no value found in config_xml
532       {
533         size_t pos = mConfig_xml_full_path.find("bbtk_config.xml");
534         mDefault_temp_dir = mConfig_xml_full_path.substr (0,pos);
535       }
536     */
537
538     GetHelp(2);
539   }
540   //=========================================================================
541
542   //=========================================================================
543   bool ConfigurationFile::AddPackagePathsAndWrite( const std::string& path )
544   {
545     bbtkDebugMessageInc("config",9,
546                         "ConfigurationFile::AddPackagePathsAndWrite("
547                         <<path<<")"<<std::endl);
548
549      XMLResults* res = new XMLResults;
550     XMLNode BB =
551       XMLNode::parseFile((XMLCSTR)Get_config_xml_full_path().c_str(),
552                          (XMLCSTR)"config",res);
553
554       if ( res->error != eXMLErrorNone )
555       {
556         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
557         delete res;
558         bbtkDebugMessage("config",1,mess<< std::endl);
559         bbtkError(mess);
560       }
561    delete res;
562
563         std::string bbs_path;
564 #ifdef _WIN32
565     bbs_path = path + "/bbs";
566     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
567     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
568     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
569     mBbs_paths.push_back(bbs_path);
570 #else
571     bbs_path = path + "/share/bbtk/bbs" ;
572     XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
573     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
574     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
575     mBbs_paths.push_back(bbs_path);
576
577     bbs_path = path + "/../../share/bbtk/bbs" ;
578     BBSPATH = BB.addChild((XMLCSTR)"bbs_path");
579     BBSPATH.addText((XMLCSTR)bbs_path.c_str());
580     Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
581     mBbs_paths.push_back(bbs_path);
582
583 #endif
584
585         std::string pack_path;
586 #ifdef _WIN32
587     pack_path = path;
588     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
589     PACKPATH.addText((XMLCSTR)pack_path.c_str());
590     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
591     mPackage_paths.push_back(pack_path);
592
593     pack_path = path + "/bin";
594     PACKPATH = BB.addChild((XMLCSTR)"package_path");
595     PACKPATH.addText((XMLCSTR)pack_path.c_str());
596     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
597     mPackage_paths.push_back(pack_path);
598
599 //    pack_path = path + "/RelWithDebInfo";
600 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
601 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
602 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
603 //    mPackage_paths.push_back(pack_path);
604
605 //    pack_path = path + "/Debug";
606 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
607 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
608 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
609 //    mPackage_paths.push_back(pack_path);
610
611 //    pack_path = path + "/Release";
612 //    PACKPATH = BB.addChild((XMLCSTR)"package_path");
613 //    PACKPATH.addText((XMLCSTR)pack_path.c_str());
614 //    Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
615 //    mPackage_paths.push_back(pack_path);
616 #else
617     pack_path = path ;
618     XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path");
619     PACKPATH.addText((XMLCSTR)pack_path.c_str());
620     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
621     mPackage_paths.push_back(pack_path);
622
623     #ifdef MACOSX
624         pack_path = path+"/../../lib/creatools" ;
625     #else
626         pack_path = path+"/../../lib64/creatools" ;
627     #endif 
628     PACKPATH = BB.addChild((XMLCSTR)"package_path");
629     PACKPATH.addText((XMLCSTR)pack_path.c_str());
630     Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR);
631     mPackage_paths.push_back(pack_path);
632
633 #endif
634
635
636 #ifdef _WIN32
637 #endif
638
639     XMLError err = BB.writeToFile((XMLCSTR)Get_config_xml_full_path().c_str());
640     if ( err != eXMLErrorNone )
641     {
642         std::string mess = GetErrorMessage(res,Get_config_xml_full_path());
643         bbtkDebugMessage("config",1,mess<< std::endl);
644         bbtkError(mess);
645     } // if err
646     return true;
647   }
648   //=========================================================================
649
650   //=========================================================================
651   void ConfigurationFile::GetHelp(int level) const
652   {
653     bbtkDebugMessageInc("config",9,"ConfigurationFile::GetHelp("<<level
654                         <<")"<<std::endl);
655
656     const std::string config_xml_full_path      = Get_config_xml_full_path();
657     const std::string description               = Get_description();
658     const std::string url                       = Get_doc_path();
659     const std::string data_path                 = Get_data_path();
660     const std::string default_temp_dir          = Get_default_temp_dir();
661     const std::string file_separator            = Get_file_separator();
662     const std::vector<std::string>bbs_paths     = Get_bbs_paths();
663     const std::vector<std::string>package_paths = Get_package_paths();
664
665     bbtkMessage("help",level, "============="   << std::endl);
666     bbtkMessage("help",level, "Configuration"   << std::endl);
667     bbtkMessage("help",level, "============="   << std::endl);
668     bbtkMessage("help",level, "bbtk_config.xml    : [" << config_xml_full_path  << "]" << std::endl);
669     bbtkMessage("help",level, "Documentation Path : [" << url             << "]" << std::endl);
670     bbtkMessage("help",level, "Data Path          : [" << data_path       << "]" << std::endl);
671     bbtkMessage("help",level, "Temp Directory     : [" << default_temp_dir << "]" << std::endl);
672     bbtkMessage("help",level, "File Separator     : [" << file_separator  << "]" << std::endl);
673
674     std::vector<std::string>::const_iterator i;
675
676     bbtkMessage("help",level, "BBS Paths   " << std::endl);
677     for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i )
678     {
679       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
680     }
681
682     bbtkMessage("help",level, "PACKAGE Paths : " << std::endl);
683     for (i = package_paths.begin(); i!=package_paths.end(); ++i )
684     {
685       bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl);
686     }
687
688     bbtkDebugDecTab("config",9);
689   }
690   //=========================================================================
691
692
693 } // namespace bbtk