- std::string configXmlFullPathName = currentDir + slash + "bbtk_config.xml";
-
- if ( FileExists( configXmlFullPathName ))
- {
- bbtkMessage("Config",1, "ConfigurationFile : [" << configXmlFullPathName <<
- "] found in current directory" << std::endl);
- //Read(configXmlFullPathName.c_str());
- // traiter le fichier local
- }
-
-// ==> Then we look for bbtk_config.xml in ".bbtk"
- else
- {
- #if defined(__GNUC__)
- std::string str_home(getenv("HOME"));
- #elif defined(_WIN32)
- std::string str_home(getenv("USERPROFILE"));
- #endif
- configXmlFullPathName = str_home + slash + ".bbtk/bbtk_config.xml";
- if (!FileExists( configXmlFullPathName ))
- {
- // ==> Nothing found, we create bbtk_config.xml in ".bbtk"
- InstallPath ();
+ //====================================================================
+ /// Constructor
+ ConfigurationFile::ConfigurationFile()
+ {
+ // file separator
+#if defined(_WIN32)
+ mFile_separator = "\\";
+#else
+ mFile_separator = "/";
+#endif
+
+ // ==> Set system paths
+ mBin_path = GetExecutablePath();
+ mInstall_path = mBin_path + mFile_separator + "..";
+ // 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 + mFile_separator + 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 + mFile_separator + 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 + mFile_separator + 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 + mFile_separator + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH);
+
+ 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);
+
+
+ // bbs_paths
+ // always add "." (current working directory) at the begining
+ mBbs_paths.push_back(".");
+ // add system bbs path
+ mBbs_paths.push_back(mBbs_path);
+
+ // always add "." (current working directory) at the begining
+ mPackage_paths.push_back(".");
+#ifndef WIN32
+ // add system bin path (for build tree)
+ // mPackage_paths.push_back(mBin_path);
+ // add system lib path (for install tree)
+ mPackage_paths.push_back(mInstall_path + mFile_separator + "lib");
+#else
+ // add bin/Debug bin/Release paths (for build/install tree)
+ mPackage_paths.push_back(mBin_path + mFile_separator + "Debug");
+ mPackage_paths.push_back(mBin_path + mFile_separator + "Release");
+#endif
+
+ GetHelp(2);
+
+ // ==> 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?
+ // How abort a constructor and warn the caller function?
+ // LG : throw an exception