]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkConfigurationFile.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkConfigurationFile.cxx
index 167579f37f4636a17b3cf96dcf21309821993424..e3982866e38f4f0ff592f6ef5b17f050cacb1803 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkConfigurationFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/06 10:53:02 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/02/13 14:08:25 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See doc/license.txt or
@@ -42,16 +42,43 @@ ConfigurationFile::ConfigurationFile()
    std::string slash("/");
  #endif
  
-// ==> First we look for bbtk_config.xml in "."
-
+   // ==> Set system paths
+   mBin_path = execPath;
+   mInstall_path = mBin_path + slash + "..";
+   // The relative path to the doc folder (=BBTK_DOC_REL_PATH)
+   mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH);
+   // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path)
+   mDoc_path = mInstall_path + slash + mDoc_rel_path;
+   // The relative path to the doc folder (=BBTK_BBS_REL_PATH)
+   mBbs_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_BBS_REL_PATH);
+   // The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path)
+   mBbs_path = mInstall_path + slash + mBbs_rel_path;
+   // The relative path to the rsc folder (=BBTK_RSC_REL_PATH)
+   //   mRsc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_RSC_REL_PATH);
+   // The path to the rsc folder (=mInstall_path+"/"+mRsc_rel_path)
+   //   mRsc_path = mInstall_path + slash + mRsc_rel_path;
+   // The path to the bbtk data folder 
+   // Initialized to mInstall_path+"/"+BBTK_DATA_REL_PATH
+   // But can be overriden by value read from bbtk_config.xml
+   mData_path = mInstall_path + slash + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
+   //  MessageManager::SetMessageLevel("Config",1);
+   bbtkMessage("Config",1," ==> bin    : '"<<mBin_path<<"'"<<std::endl);
+   bbtkMessage("Config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl);
+   bbtkMessage("Config",1," ==> doc    : '"<<mDoc_path<<"'"<<std::endl);
+   bbtkMessage("Config",1," ==> bbs    : '"<<mBbs_path<<"'"<<std::endl);
+   //   bbtkMessage("Config",1," ==> rsc    : '"<<mRsc_path<<"'"<<std::endl);
+   bbtkMessage("Config",1," ==> data   : '"<<mData_path<<"'"<<std::endl);
+
+   // ==> First we look for bbtk_config.xml in "."
    char buf[2048];
    const char *currentDir = getcwd(buf, 2048);
      
    if( !currentDir )
    {
       std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl;
-      /// \todo : what else?
+      // \todo : what else?
       // How abort a constructor and warn the caller function?
+      // LG : throw an exception 
    }
 
    std::string configXmlFullPathName = currentDir + slash + "bbtk_config.xml";
@@ -123,15 +150,15 @@ void ConfigurationFile::CreateConfigXML( char *rootDirectory )
    bbtkMessage("Config",1, "in CreateConfigXML[" << configXml << "]" << std::endl);
    fp = fopen (configXml, "w");
    fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
-   fprintf(fp, "<!DOCTYPE config SYSTEM \"/mnt/windows/bbtk/bbtk_config.xml>\n");
+   //  fprintf(fp, "<!DOCTYPE config SYSTEM \"/mnt/windows/bbtk/bbtk_config.xml>\n");
    fprintf(fp, "<config>\n");
    fprintf(fp, "   <description>  </description>\n");
-   fprintf(fp, "   <url>  http://www.creatis.insa-lyon.fr/software/bbtk  </url>\n");
-   fprintf(fp, "   <install_path> </install_path>\n");
+   //   fprintf(fp, "   <url>  http://www.creatis.insa-lyon.fr/software/bbtk  </url>\n");
+   //  fprintf(fp, "   <install_path> </install_path>\n");
    fprintf(fp, "   <bbs_path>     </bbs_path>\n");
   // fprintf(fp, "   <ext_dll_path> </ext_dll_path>\n");
    fprintf(fp, "   <package_path> </package_path>\n");
-   fprintf(fp, "   <data_path> %s </data_path>\n", BBTK_DATA_PATH);
+   fprintf(fp, "   <data_path> </data_path>\n");//, BBTK_DATA_PATH);
    /// \todo find a decent default value !
    ///fprintf(fp, "   <default_temp_dir>  %s </default_temp_dir>\n", " ");
    // when $ will be found, default_temp_dir value will be replaced
@@ -376,13 +403,15 @@ void ConfigurationFile::Read(const std::string& filename)
      GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path);
 
   // install_path
-  if( BB.nChildNode((XMLCSTR)"install_path") )
-     GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
+  //  if( BB.nChildNode((XMLCSTR)"install_path") )
+  //   GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path);
 
   // always add "." (current working directory) at the begining
-
   // bbs_paths
   mBbs_paths.push_back("."); 
+  // add system bbs path 
+  mBbs_paths.push_back(mBbs_path);
+
   for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++) 
     {
       std::string val;