#include <bbtkConfigurationFile.h>
Public Member Functions | |
~ConfigurationFile () | |
Destructor. | |
void | GetHelp (int level) const |
bool | DotBbtkIsNew () |
Returns true iff the directory .bbtk has been created on construction. | |
const std::string & | Get_description () const |
const std::string & | Get_data_path () const |
const std::string & | Get_file_separator () const |
const std::string & | Get_dot_bbtk_path () const |
const std::string & | Get_bin_path () const |
const std::string & | Get_install_path () const |
const std::string & | Get_doc_path () const |
const std::string & | Get_root_bbs_path () const |
const std::vector< std::string > & | Get_bbs_paths () const |
const std::vector< std::string > & | Get_package_paths () const |
const std::string & | Get_config_xml_full_path () const |
const std::string & | Get_default_temp_dir () const |
bool | AddPackagePathsAndWrite (const std::string &package_root_path) |
Static Public Member Functions | |
static ConfigurationFile & | GetInstance () |
Private Member Functions | |
ConfigurationFile () | |
Constructor. | |
void | InstallPath () |
void | Read (const std::string &fileName) |
void | CreateConfigXML (char *rootDirectory) |
void | InitializeDotBbtkStructure () |
Private Attributes | |
std::string | mDescription |
std::string | mConfig_xml_full_path |
Where is the file bbtk_config.xml. | |
std::string | mBin_path |
std::string | mDot_bbtk_path |
The path to the .bbtk user's dir (e.g. /home/username/.bbtk). | |
std::string | mInstall_path |
The path to the install prefix (=mBinPath+"/.."). | |
std::string | mDoc_path |
The path to the doc folder (=mDot_bbtk_path+"/doc"). | |
std::string | mTemp_path |
Temp directory for generated data (=mDot_bbtk_path+"/tmp"). | |
std::string | mBbs_rel_path |
The relative path to the doc folder (=BBTK_BBS_REL_PATH). | |
std::string | mBbs_path |
The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path). | |
std::string | mData_path |
std::string | mFile_separator |
/ or \, depending on the OS | |
std::string | mUrl |
std::vector< std::string > | mBbs_paths |
Scripts. | |
std::vector< std::string > | mPackage_paths |
Package dlls. | |
std::vector< std::string > | mExt_dll_paths |
If Packages link against extern dlls. | |
bool | mDot_bbtk_is_new |
Definition at line 75 of file bbtkConfigurationFile.h.
bbtk::ConfigurationFile::~ConfigurationFile | ( | ) |
bbtk::ConfigurationFile::ConfigurationFile | ( | ) | [private] |
Constructor.
: better use ??
: better use BBTK_PACKAGE_LIB_PATH // JPR
Definition at line 53 of file bbtkConfigurationFile.cxx.
References BBTK_STRINGIFY_SYMBOL, bbtkMessage, bbtk::Utilities::FileExists(), bbtk::Utilities::GetExecutablePath(), GetHelp(), InitializeDotBbtkStructure(), InstallPath(), INVALID_FILE_SEPARATOR, bbtk::Utilities::MakeUserSettingsFullFileName(), mBbs_path, mBbs_paths, mBbs_rel_path, mBin_path, mData_path, mDoc_path, mFile_separator, mInstall_path, mPackage_paths, Read(), bbtk::Utilities::replace(), and VALID_FILE_SEPARATOR.
00054 { 00055 mFile_separator = VALID_FILE_SEPARATOR; 00056 00057 // ==> Set system paths 00058 mBin_path = Utilities::GetExecutablePath(); 00059 00060 /* EED 23 Mars 2009 00061 #ifdef MACOSX 00062 mInstall_path = mBin_path + "/../../../.."; 00063 #else 00064 mInstall_path = mBin_path + "/.."; 00065 #endif 00066 */ 00067 #ifdef MACOSX 00068 std::string macPath("Contents/MacOS"); 00069 int sbp = mBin_path.length(); 00070 int smp = macPath.length(); 00071 if (mBin_path.compare( sbp-smp, smp, macPath )==0 ) 00072 { 00073 mBin_path = mBin_path + "/../../.."; 00074 } 00075 #endif 00076 00078 mInstall_path = mBin_path + "/.."; 00079 00080 // The relative path to the doc folder (=BBTK_DOC_REL_PATH) 00081 // mDoc_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH); 00082 // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path) 00083 // mDoc_path = mInstall_path + "/" + mDoc_rel_path; 00084 // Have to create bbtk user's dirs if needed 00085 00086 // LG 27/01/09 : doc is now user dependent 00087 // and located in user's .bbtk dir /doc 00088 // All dirs under .bbtk user's dir are set and created by: 00089 InitializeDotBbtkStructure(); 00090 00091 // The relative path to the doc folder (=BBTK_BBS_REL_PATH) 00092 mBbs_rel_path = BBTK_STRINGIFY_SYMBOL(BBTK_BBS_REL_PATH); 00093 // The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path) 00094 mBbs_path = mInstall_path + "/" + mBbs_rel_path; 00095 00096 mData_path = mInstall_path + "/" + BBTK_STRINGIFY_SYMBOL(BBTK_DATA_REL_PATH); 00097 00098 Utilities::replace( mBin_path, 00099 INVALID_FILE_SEPARATOR, 00100 VALID_FILE_SEPARATOR); 00101 Utilities::replace( mInstall_path, 00102 INVALID_FILE_SEPARATOR, 00103 VALID_FILE_SEPARATOR); 00104 Utilities::replace( mBbs_path, 00105 INVALID_FILE_SEPARATOR, 00106 VALID_FILE_SEPARATOR); 00107 Utilities::replace( mData_path, 00108 INVALID_FILE_SEPARATOR, 00109 VALID_FILE_SEPARATOR); 00110 00111 bbtkMessage("config",1," ==> bin : '"<<mBin_path<<"'"<<std::endl); 00112 bbtkMessage("config",1," ==> prefix : '"<<mInstall_path<<"'"<<std::endl); 00113 bbtkMessage("config",1," ==> doc : '"<<mDoc_path<<"'"<<std::endl); 00114 bbtkMessage("config",1," ==> bbs : '"<<mBbs_path<<"'"<<std::endl); 00115 bbtkMessage("config",1," ==> data : '"<<mData_path<<"'"<<std::endl); 00116 00117 // bbs_paths 00118 // always add "." (current working directory) at the begining 00119 mBbs_paths.push_back( "." ); 00120 // add system bbs path 00121 mBbs_paths.push_back(mBbs_path); 00122 // add toolsbbtk/appli 00123 //EED std::string toolsappli_rel_path(mFile_separator); 00124 std::string toolsappli_rel_path("/"); 00125 //EED toolsappli_rel_path += "toolsbbtk" + mFile_separator + "appli"; 00126 toolsappli_rel_path += "toolsbbtk/appli"; 00127 // 00128 //----------------------------------------------------------- 00129 // LG : REMOVE BUGGY PATH WITH include *: 00130 // 00131 // mBbs_paths.push_back(mBbs_path + toolsappli_rel_path); 00132 //----------------------------------------------------------- 00133 int iStrVec,sizeStrVec; 00134 00135 sizeStrVec = mBbs_paths.size(); 00136 for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){ 00137 Utilities::replace( mBbs_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); 00138 } 00139 00140 00141 // always add "." (current working directory) at the begining 00142 mPackage_paths.push_back("."); 00143 // add system bin path (for build tree / standalone folder install) 00144 mPackage_paths.push_back(mBin_path); 00145 // add system lib path (for install tree) 00146 //EED mPackage_paths.push_back(mInstall_path + mFile_separator + "lib"); 00147 00148 //mPackage_paths.push_back(mInstall_path + "/lib"); // JPR 00149 //mPackage_paths.push_back(mInstall_path + "/lib64");// JPR 00150 00152 00153 mPackage_paths.push_back(mInstall_path + "/lib/creatools"); 00154 mPackage_paths.push_back(mInstall_path + "/lib64/creatools"); 00155 #ifdef WIN32 00156 // add bin/Debug bin/Release paths (for build/install tree) 00157 //EED mPackage_paths.push_back(mBin_path + mFile_separator + "Debug"); 00158 mPackage_paths.push_back(mBin_path + "/Debug"); 00159 //EED mPackage_paths.push_back(mBin_path + mFile_separator + "Release"); 00160 mPackage_paths.push_back(mBin_path + "/Release"); 00161 #endif 00162 00163 sizeStrVec = mPackage_paths.size(); 00164 for (iStrVec=0;iStrVec<sizeStrVec;iStrVec++){ 00165 Utilities::replace( mPackage_paths[iStrVec] , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); 00166 } 00167 00168 GetHelp(2); 00169 00170 // ==> First we look for bbtk_config.xml in "." 00171 char buf[2048]; 00172 const char *currentDir = getcwd(buf, 2048); 00173 00174 if( !currentDir ) 00175 { 00176 std::cerr << "Path was too long to fit on 2048 bytes ?!?" << std::endl; 00177 // \todo : what else? 00178 // How abort a constructor and warn the caller function? 00179 // LG : throw an exception 00180 } 00181 00182 // std::string configXmlFullPathName = currentDir + mFile_separator + "bbtk_config.xml"; 00183 std::string configXmlFullPathName = currentDir ; 00184 configXmlFullPathName += "/bbtk_config.xml"; 00185 Utilities::replace( configXmlFullPathName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); 00186 00187 if ( Utilities::FileExists( configXmlFullPathName )) 00188 { 00189 bbtkMessage("config",1, "ConfigurationFile : [" << configXmlFullPathName << 00190 "] found in current directory" << std::endl); 00191 //Read(configXmlFullPathName.c_str()); 00192 // traiter le fichier local 00193 } 00194 00195 // ==> Then we look for bbtk_config.xml in ".bbtk" 00196 else 00197 { 00198 configXmlFullPathName = Utilities::MakeUserSettingsFullFileName("bbtk_config.xml"); 00199 if (!Utilities::FileExists( configXmlFullPathName )) 00200 { 00201 // ==> Nothing found, we create bbtk_config.xml in ".bbtk" 00202 InstallPath (); 00203 } 00204 } 00205 00206 // In any case, deal with bbtk_config.xml! 00207 Read(configXmlFullPathName.c_str()); 00208 }
bool bbtk::ConfigurationFile::AddPackagePathsAndWrite | ( | const std::string & | package_root_path | ) |
Definition at line 522 of file bbtkConfigurationFile.cxx.
References XMLNode::addChild(), XMLNode::addText(), bbtkDebugMessage, bbtkDebugMessageInc, bbtkError, XMLResults::error, eXMLErrorNone, Get_config_xml_full_path(), bbtk::GetErrorMessage(), INVALID_FILE_SEPARATOR, mBbs_paths, mPackage_paths, XMLNode::parseFile(), bbtk::Utilities::replace(), VALID_FILE_SEPARATOR, XMLNode::writeToFile(), and XMLCSTR.
Referenced by bbtk::WxGUIScriptingInterface::OnMenuPlugPackage().
00523 { 00524 bbtkDebugMessageInc("config",9, 00525 "ConfigurationFile::AddPackagePathsAndWrite(" 00526 <<path<<")"<<std::endl); 00527 00528 XMLResults* res = new XMLResults; 00529 XMLNode BB = 00530 XMLNode::parseFile((XMLCSTR)Get_config_xml_full_path().c_str(), 00531 (XMLCSTR)"config",res); 00532 00533 if ( res->error != eXMLErrorNone ) 00534 { 00535 std::string mess = GetErrorMessage(res,Get_config_xml_full_path()); 00536 delete res; 00537 bbtkDebugMessage("config",1,mess<< std::endl); 00538 bbtkError(mess); 00539 } 00540 delete res; 00541 00542 #ifdef _WIN32 00543 std::string bbs_path = path + "/bbs"; 00544 #else 00545 std::string bbs_path = path + "/share/bbtk/bbs" ; 00546 #endif 00547 XMLNode BBSPATH = BB.addChild((XMLCSTR)"bbs_path"); 00548 BBSPATH.addText((XMLCSTR)bbs_path.c_str()); 00549 Utilities::replace(bbs_path, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR); 00550 mBbs_paths.push_back(bbs_path); 00551 00552 #ifdef _WIN32 00553 std::string pack_path = path + "/bin"; 00554 #else 00555 std::string pack_path = path ; 00556 #endif 00557 XMLNode PACKPATH = BB.addChild((XMLCSTR)"package_path"); 00558 PACKPATH.addText((XMLCSTR)pack_path.c_str()); 00559 Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR); 00560 mPackage_paths.push_back(pack_path); 00561 00562 #ifdef _WIN32 00563 pack_path = path + "/RelWithDebInfo"; 00564 PACKPATH = BB.addChild((XMLCSTR)"package_path"); 00565 PACKPATH.addText((XMLCSTR)pack_path.c_str()); 00566 Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR); 00567 mPackage_paths.push_back(pack_path); 00568 pack_path = path + "/Debug"; 00569 PACKPATH = BB.addChild((XMLCSTR)"package_path"); 00570 PACKPATH.addText((XMLCSTR)pack_path.c_str()); 00571 Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR); 00572 mPackage_paths.push_back(pack_path); 00573 pack_path = path + "/Release"; 00574 PACKPATH = BB.addChild((XMLCSTR)"package_path"); 00575 PACKPATH.addText((XMLCSTR)pack_path.c_str()); 00576 Utilities::replace(pack_path,INVALID_FILE_SEPARATOR,VALID_FILE_SEPARATOR); 00577 mPackage_paths.push_back(pack_path); 00578 #endif 00579 00580 00581 XMLError err = BB.writeToFile((XMLCSTR)Get_config_xml_full_path().c_str()); 00582 if ( err != eXMLErrorNone ) 00583 { 00584 std::string mess = GetErrorMessage(res,Get_config_xml_full_path()); 00585 bbtkDebugMessage("config",1,mess<< std::endl); 00586 bbtkError(mess); 00587 } 00588 00589 return true; 00590 }
void bbtk::ConfigurationFile::CreateConfigXML | ( | char * | rootDirectory | ) | [private] |
Definition at line 293 of file bbtkConfigurationFile.cxx.
References bbtkDebugMessage.
Referenced by InstallPath().
00294 { 00295 FILE *fp; 00296 char configXml[250]; 00297 sprintf (configXml , "%s/bbtk_config.xml", rootDirectory); 00298 bbtkDebugMessage("config",1, "in CreateConfigXML[" << configXml << "]" << std::endl); 00299 fp = fopen (configXml, "w"); 00300 fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"); 00301 fprintf(fp, "<config>\n"); 00302 fprintf(fp, " <bbs_path> </bbs_path>\n"); 00303 fprintf(fp, " <package_path> </package_path>\n"); 00304 fprintf(fp, "</config>\n"); 00305 fclose(fp); 00306 }
bool bbtk::ConfigurationFile::DotBbtkIsNew | ( | ) | [inline] |
Returns true iff the directory .bbtk has been created on construction.
Definition at line 90 of file bbtkConfigurationFile.h.
Referenced by bbtk::WxGUIScriptingInterface::WxGUIScriptingInterface().
00090 { return mDot_bbtk_is_new; }
const std::vector<std::string>& bbtk::ConfigurationFile::Get_bbs_paths | ( | ) | const [inline] |
Definition at line 111 of file bbtkConfigurationFile.h.
Referenced by GetHelp(), and bbtk::InterpreterVirtual::SwitchToFile().
00112 { return mBbs_paths;}
const std::string& bbtk::ConfigurationFile::Get_bin_path | ( | ) | const [inline] |
Definition at line 102 of file bbtkConfigurationFile.h.
Referenced by bbtk::Factory::CreateHtmlIndex(), bbtk::WxGUIScriptingInterface::DoRegenerateBoxesLists(), bbtk::WxGUIScriptingInterface::DoRegeneratePackageDoc(), bbtk::WxGUIConsole::OnMenuCreateIndex(), and bbtk::WxGUIScriptingInterface::WxGUITextEditorRunBBI().
00103 { return mBin_path;}
const std::string& bbtk::ConfigurationFile::Get_config_xml_full_path | ( | ) | const [inline] |
Definition at line 115 of file bbtkConfigurationFile.h.
Referenced by AddPackagePathsAndWrite(), GetHelp(), bbtk::WxGUIScriptingInterface::OnMenuEditConfig(), and bbtk::WxGUIConsole::OnMenuEditConfig().
00116 { return mConfig_xml_full_path;}
const std::string& bbtk::ConfigurationFile::Get_data_path | ( | ) | const [inline] |
Definition at line 95 of file bbtkConfigurationFile.h.
Referenced by GetHelp(), and bbtk::WxGUIScriptingInterface::WxGUIScriptingInterface().
00096 { return mData_path;}
const std::string& bbtk::ConfigurationFile::Get_default_temp_dir | ( | ) | const [inline] |
Definition at line 117 of file bbtkConfigurationFile.h.
Referenced by bbtk::ComplexBlackBox::bbInsertHTMLGraph(), GetHelp(), bbtk::WxGUICommand::OnBtnInclude(), bbtk::WxGUIConsole::OnMenuShowImageGraph(), bbtk::Package::Package(), bbtk::Executer::ShowGraphInstances(), bbtk::Factory::ShowGraphTypes(), and bbtk::WxGUIScriptingInterface::WxGUITextEditorRunBBI().
00118 { return mTemp_path;}
const std::string& bbtk::ConfigurationFile::Get_description | ( | ) | const [inline] |
Definition at line 92 of file bbtkConfigurationFile.h.
Referenced by GetHelp().
00093 { return mDescription;}
const std::string& bbtk::ConfigurationFile::Get_doc_path | ( | ) | const [inline] |
Definition at line 106 of file bbtkConfigurationFile.h.
Referenced by bbtk::Interpreter::commandHelp(), GetHelp(), bbtk::WxGUIHtmlBrowser::GoHome(), bbtk::WxGUIConsole::OnMenuCreateIndex(), bbtk::WxGUIConsole::OnMenuShowHTMLDoc(), bbtk::WxGUIScriptingInterface::OnMenuShowImageGraph(), and bbtk::Executer::ShowGraph().
00107 { return mDoc_path;}
const std::string& bbtk::ConfigurationFile::Get_dot_bbtk_path | ( | ) | const [inline] |
const std::string& bbtk::ConfigurationFile::Get_file_separator | ( | ) | const [inline] |
Definition at line 97 of file bbtkConfigurationFile.h.
Referenced by bbtk::Package::CreateFromDynamicLibrary(), bbtk::WxGUIScriptingInterface::DoRegenerateBoxesLists(), bbtk::WxGUIScriptingInterface::DoRegeneratePackageDoc(), bbtk::Utilities::ExpandLibName(), GetHelp(), bbtk::Utilities::MakePkgnameFromPath(), bbtk::WxGUIScriptingInterface::OnMenuShowImageGraph(), bbtk::Executer::ShowGraph(), bbtk::Factory::ShowGraphTypes(), bbtk::InterpreterVirtual::SwitchToFile(), and bbtk::WxGUIScriptingInterface::WxGUITextEditorRunBBI().
00098 { return mFile_separator;}
const std::string& bbtk::ConfigurationFile::Get_install_path | ( | ) | const [inline] |
const std::vector<std::string>& bbtk::ConfigurationFile::Get_package_paths | ( | ) | const [inline] |
Definition at line 113 of file bbtkConfigurationFile.h.
Referenced by GetHelp(), and bbtk::Factory::LoadPackage().
00114 { return mPackage_paths;}
const std::string& bbtk::ConfigurationFile::Get_root_bbs_path | ( | ) | const [inline] |
void bbtk::ConfigurationFile::GetHelp | ( | int | level | ) | const |
Definition at line 594 of file bbtkConfigurationFile.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkMessage, Get_bbs_paths(), Get_config_xml_full_path(), Get_data_path(), Get_default_temp_dir(), Get_description(), Get_doc_path(), Get_file_separator(), Get_package_paths(), and bbtk::i.
Referenced by bbtk::Interpreter::commandConfig(), ConfigurationFile(), and Read().
00595 { 00596 bbtkDebugMessageInc("config",9,"ConfigurationFile::GetHelp("<<level 00597 <<")"<<std::endl); 00598 00599 const std::string config_xml_full_path = Get_config_xml_full_path(); 00600 const std::string description = Get_description(); 00601 const std::string url = Get_doc_path(); 00602 const std::string data_path = Get_data_path(); 00603 const std::string default_temp_dir = Get_default_temp_dir(); 00604 const std::string file_separator = Get_file_separator(); 00605 const std::vector<std::string>bbs_paths = Get_bbs_paths(); 00606 const std::vector<std::string>package_paths = Get_package_paths(); 00607 00608 bbtkMessage("help",level, "=============" << std::endl); 00609 bbtkMessage("help",level, "Configuration" << std::endl); 00610 bbtkMessage("help",level, "=============" << std::endl); 00611 bbtkMessage("help",level, "bbtk_config.xml : [" << config_xml_full_path << "]" << std::endl); 00612 bbtkMessage("help",level, "Documentation Path : [" << url << "]" << std::endl); 00613 bbtkMessage("help",level, "Data Path : [" << data_path << "]" << std::endl); 00614 bbtkMessage("help",level, "Temp Directory : [" << default_temp_dir << "]" << std::endl); 00615 bbtkMessage("help",level, "File Separator : [" << file_separator << "]" << std::endl); 00616 00617 std::vector<std::string>::const_iterator i; 00618 00619 bbtkMessage("help",level, "BBS Paths " << std::endl); 00620 for (i = bbs_paths.begin(); i!=bbs_paths.end(); ++i ) 00621 { 00622 bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl); 00623 } 00624 00625 bbtkMessage("help",level, "PACKAGE Paths : " << std::endl); 00626 for (i = package_paths.begin(); i!=package_paths.end(); ++i ) 00627 { 00628 bbtkMessage("help",level,"--- ["<<*i<<"]"<<std::endl); 00629 } 00630 00631 bbtkDebugDecTab("config",9); 00632 }
static ConfigurationFile& bbtk::ConfigurationFile::GetInstance | ( | ) | [inline, static] |
Definition at line 79 of file bbtkConfigurationFile.h.
Referenced by bbtk::ComplexBlackBox::bbInsertHTMLGraph(), bbtk::Interpreter::commandConfig(), bbtk::Interpreter::commandHelp(), bbtk::Package::CreateFromDynamicLibrary(), bbtk::Factory::CreateHtmlIndex(), bbtk::WxGUIScriptingInterface::DoRegenerateBoxesLists(), bbtk::WxGUIScriptingInterface::DoRegeneratePackageDoc(), bbtk::Utilities::ExpandLibName(), bbtk::WxGUIHtmlBrowser::GoHome(), bbtk::Factory::LoadPackage(), bbtk::Utilities::MakePkgnameFromPath(), bbtk::WxGUICommand::OnBtnInclude(), bbtk::WxGUIConsole::OnMenuCreateIndex(), bbtk::WxGUIScriptingInterface::OnMenuEditConfig(), bbtk::WxGUIConsole::OnMenuEditConfig(), bbtk::WxGUIScriptingInterface::OnMenuPlugPackage(), bbtk::WxGUIConsole::OnMenuShowHTMLDoc(), bbtk::WxGUIScriptingInterface::OnMenuShowImageGraph(), bbtk::WxGUIConsole::OnMenuShowImageGraph(), bbtk::Package::Package(), bbtk::Executer::ShowGraph(), bbtk::Executer::ShowGraphInstances(), bbtk::Factory::ShowGraphTypes(), bbtk::InterpreterVirtual::SwitchToFile(), bbtk::WxGUIScriptingInterface::WxGUIScriptingInterface(), and bbtk::WxGUIScriptingInterface::WxGUITextEditorRunBBI().
00080 { 00081 static ConfigurationFile f; 00082 return f; 00083 }
void bbtk::ConfigurationFile::InitializeDotBbtkStructure | ( | ) | [private] |
Definition at line 219 of file bbtkConfigurationFile.cxx.
References BBTK_STRINGIFY_SYMBOL, bbtkDebugMessage, bbtk::Utilities::CreateDirectoryIfNeeded(), bbtk::Utilities::FileExists(), bbtk::Utilities::GetUserSettingsDir(), bbtk::GetVersion(), bbtk::Utilities::MakeUserSettingsFullFileName(), bbtk::Utilities::MakeValidFileName(), mDoc_path, mDot_bbtk_is_new, mDot_bbtk_path, mInstall_path, and mTemp_path.
Referenced by ConfigurationFile().
00220 { 00221 mDot_bbtk_path = Utilities::GetUserSettingsDir(); 00222 mDot_bbtk_is_new = false; 00223 if (!Utilities::FileExists(mDot_bbtk_path)) mDot_bbtk_is_new = true; 00224 Utilities::CreateDirectoryIfNeeded(mDot_bbtk_path); 00225 00226 mDoc_path = Utilities::MakeUserSettingsFullFileName("doc"); 00227 Utilities::CreateDirectoryIfNeeded(mDoc_path); 00228 00229 std::string bbdoc_path = 00230 Utilities::MakeUserSettingsFullFileName("doc/bbdoc"); 00231 Utilities::CreateDirectoryIfNeeded(bbdoc_path); 00232 00233 // Create help_contents.html if does not exist 00234 std::string filename = Utilities::MakeUserSettingsFullFileName("doc/help_contents.html"); 00235 if (!Utilities::FileExists(filename)) 00236 { 00237 bbtkDebugMessage("config",1, 00238 "* Creating [" << filename << "]" << std::endl); 00239 // The path to the doc folder (=mInstall_path+"/"+mDoc_rel_path) 00240 std::string doc_path = mInstall_path + "/" 00241 + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) + "/"; 00242 Utilities::MakeValidFileName(doc_path); 00243 00244 std::ofstream f; 00245 f.open(filename.c_str(), std::ios::out ); 00246 f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD " 00247 << "HTML 4.01 Transitional//EN\">" 00248 << "<html><head><title>Help Contents - bbtk " 00249 << GetVersion() << "</title>" 00250 << "<meta http-equiv=\"Content-Type\" content=\"text/html; " 00251 << "charset=iso-8859-1\"></head><H1>Help Contents</H1>" 00252 << "<a href=\"bbdoc/index-category.html#demo\" " 00253 << "target=\"information\">Demos</a><br>" 00254 << "<a href=\"bbdoc/index-category.html#example\" " 00255 << "target=\"information\">Examples</a>" 00256 << "<H2>Guides</H2>" 00257 << "<a href=\"" 00258 << doc_path 00259 << "bbtkUsersGuide/bbtkUsersGuide.pdf" 00260 << "\" target=\"information\">User's Guide</a><br>" 00261 << "<a href=\"" 00262 << doc_path 00263 << "bbtkDevelopersGuide/bbtkDevelopersGuide.pdf" 00264 << "\" target=\"information\">Developer's Guide</a><br>" 00265 << "<a href=\"" 00266 << doc_path 00267 << "bbtkPackageDevelopersGuide/bbtkPackageDevelopersGuide.pdf" 00268 << "\" target=\"information\">Package Developer's Guide</a><br>" 00269 << "<a href=\"" 00270 << doc_path 00271 << "doxygen/bbtk/main.html" 00272 << "\" target=\"information\">bbtk library doxygen doc</a><br>" 00273 << "<H2>Boxes</H2>" 00274 << "<a target=\"information\" href=\"bbdoc/index-alpha.html\">" 00275 << "Alphabetical list</a><br>" 00276 << "<a target=\"information\" href=\"bbdoc/index-package.html\">" 00277 << "List by package</a><br>" 00278 << "<a target=\"information\" href=\"bbdoc/index-category.html\">" 00279 << "List by category</a><br>" 00280 << "<a target=\"information\" href=\"bbdoc/index-adaptors.html\">" 00281 << "List of adaptors</a><br>" 00282 << "</body>" 00283 << "</html>"; 00284 } // if 00285 00286 mTemp_path = Utilities::MakeUserSettingsFullFileName("tmp"); 00287 Utilities::CreateDirectoryIfNeeded(mTemp_path); 00288 00289 }
void bbtk::ConfigurationFile::InstallPath | ( | ) | [private] |
Definition at line 313 of file bbtkConfigurationFile.cxx.
References bbtkMessage, CreateConfigXML(), bbtk::Utilities::FileExists(), and bbtk::Utilities::GetExecutablePath().
Referenced by ConfigurationFile().
00314 { 00315 00316 /*-------------------------------------------------- 00317 New policy for bbtk_config.xml : 00318 00319 if bbtk_config.xml found in current directory (user is an aware user!) 00320 use it! 00321 00322 else if bbtk_config.xml found in HOME/.bbtk (user already worked with it) 00323 use it! 00324 00325 else if bbtk_config.xml.tmp found in /usr/local/bin or c:\\Program Files\\BBTK\\bin 00326 copy it as .bbtk/bbtk_config.xml 00327 00328 else (nothing installed) 00329 create a minimum version in HOME/.bbtk 00330 ----------------------------------------------------*/ 00331 00332 00333 // ----------------------------------------------------------------- 00334 #if defined(__GNUC__) 00335 00336 // ------------------ create some usefull strings ---------------- 00337 // installed bbtk_path 00338 char bbtk_path[1000]; 00339 strcpy(bbtk_path, Utilities::GetExecutablePath().c_str()); // JPR 00340 //strcpy(bbtk_path, "/usr/local/bin"); 00341 00342 // rootDirectory 00343 char rootDirectory[200]; 00344 sprintf( rootDirectory, "%s/.bbtk", getenv("HOME")); 00345 00346 // configPath 00347 char configPath[200]; 00348 sprintf(configPath, "%s/bbtk_config.xml",rootDirectory); 00349 00350 // configXmlTmp 00351 char configXmlTmp[250]; 00352 sprintf(configXmlTmp, "%s/bbtk_config.xml.tmp", bbtk_path); 00353 00354 // copyFile 00355 char copyFile[250]; 00356 00357 if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found (not installed) 00358 { 00359 // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk 00360 CreateConfigXML( rootDirectory );// create .bbtk 00361 } 00362 else 00363 { 00364 sprintf(copyFile,"cp %s %s/bbtk_config.xml ",configXmlTmp,rootDirectory ); 00365 if (!Utilities::FileExists(configPath)) 00366 { 00367 system(copyFile); 00368 } 00369 } 00370 return; 00371 00372 // ------------------------------------------------------------------ 00373 #elif defined(WIN32) 00374 00375 00376 // installed bbtk_path 00377 char bbtk_path[100]; 00378 strcpy(bbtk_path, "\"c:\\Program Files\\BBTK\\bin\""); 00379 char bbtk_path2[100]; 00380 strcpy(bbtk_path2, "c:\\Program Files\\BBTK\\bin"); 00381 00382 // rootDirectory 00383 char rootDirectory[200]; 00384 sprintf(rootDirectory, "%s\\.bbtk",getenv("USERPROFILE")); 00385 // std::cout << "[" << rootDirectory << "]" << std::endl; 00386 00387 // configPath 00388 char configPath[200]; 00389 sprintf(configPath, "%s\\bbtk_config.xml",rootDirectory); 00390 00391 // makeDir 00392 char makeDir[250]; 00393 sprintf( makeDir, "mkdir \"%s\" ", rootDirectory); 00394 00395 // configXmlTmp 00396 char configXmlTmp[250]; 00397 sprintf(configXmlTmp, "%s\\bbtk_config.xml.tmp", bbtk_path2); 00398 00399 // copyFile 00400 char copyFile[250]; 00401 00402 if (!Utilities::FileExists(configXmlTmp)) // bbtk_config.xml.tmp not found 00403 { 00404 // if "bbtk_path/bbtk_config.xml.tmp" doesn't exist, hard-create a minimum version in .bbtk 00405 CreateConfigXML( rootDirectory );// create .bbtk 00406 return; 00407 } 00408 00409 sprintf(copyFile,"copy %s\\bbtk_config.xml.tmp \"%s\"\\bbtk_config.xml ",bbtk_path,rootDirectory ); 00410 00411 int attribs = GetFileAttributes (rootDirectory); 00412 bbtkMessage("config",1,std::hex << attribs << " " << FILE_ATTRIBUTE_DIRECTORY << std::endl); 00413 if ( attribs != 0xFFFFFFFF) 00414 { 00415 if ((attribs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) 00416 { 00417 if ( GetFileAttributes( configPath ) == 0xFFFFFFFF) 00418 { 00419 system(copyFile); 00420 } 00421 } 00422 } 00423 else 00424 { 00425 system(makeDir); 00426 system(copyFile); 00427 } 00428 return; 00429 // ------------------------------------------------------------------ 00430 #else 00432 00433 return; 00434 #endif 00435 00436 }
void bbtk::ConfigurationFile::Read | ( | const std::string & | fileName | ) | [private] |
Definition at line 445 of file bbtkConfigurationFile.cxx.
References bbtkDebugMessage, bbtkError, XMLResults::error, eXMLErrorNone, XMLNode::getChildNode(), bbtk::GetErrorMessage(), GetHelp(), bbtk::GetTextOrClear(), bbtk::i, mBbs_paths, mConfig_xml_full_path, mData_path, mDescription, mPackage_paths, mUrl, XMLNode::nChildNode(), XMLNode::parseFile(), and XMLCSTR.
Referenced by ConfigurationFile().
00446 { 00447 00448 bbtkDebugMessage("config",1,"ConfigurationFile::Read(" <<filename << ")" << std::endl); 00449 00450 mConfig_xml_full_path = filename; 00451 XMLResults* res = new XMLResults; 00452 XMLNode BB = XMLNode::parseFile((XMLCSTR)filename.c_str(),(XMLCSTR)"config",res); 00453 00454 if ( res->error != eXMLErrorNone ) 00455 { 00456 std::string mess = GetErrorMessage(res,filename); 00457 delete res; 00458 bbtkDebugMessage("config",1,mess<< std::endl); 00459 bbtkError(mess); 00460 } 00461 delete res; 00462 00463 bbtkDebugMessage("config",1,"OK" << std::endl); 00464 00465 int i,j; 00466 00467 // Description 00468 for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"description"); i++) 00469 { 00470 std::string val; 00471 GetTextOrClear(BB.getChildNode((XMLCSTR)"description",&j),val); 00472 mDescription += val; 00473 } 00474 00475 // Url 00476 if( BB.nChildNode((XMLCSTR)"url") ) 00477 GetTextOrClear(BB.getChildNode((XMLCSTR)"url"),mUrl); 00478 00479 // Data_Path 00480 if( BB.nChildNode((XMLCSTR)"data_path") ) 00481 GetTextOrClear(BB.getChildNode((XMLCSTR)"data_path"),mData_path); 00482 00483 // install_path 00484 // if( BB.nChildNode((XMLCSTR)"install_path") ) 00485 // GetTextOrClear(BB.getChildNode((XMLCSTR)"install_path"),mInstall_path); 00486 00487 // add user bbs paths 00488 for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"bbs_path"); i++) 00489 { 00490 std::string val; 00491 GetTextOrClear(BB.getChildNode((XMLCSTR)"bbs_path",&j),val); 00492 mBbs_paths.push_back(val); 00493 } 00494 00495 // package_paths 00496 00497 // add user package path 00498 for (i=0,j=0; i<BB.nChildNode((XMLCSTR)"package_path"); i++) 00499 { 00500 std::string val; 00501 GetTextOrClear(BB.getChildNode((XMLCSTR)"package_path",&j),val); 00502 mPackage_paths.push_back(val); 00503 } 00504 00505 // default_temp_dir 00506 /* 00507 if( BB.nChildNode((XMLCSTR)"default_temp_dir") ) 00508 GetTextOrClear(BB.getChildNode((XMLCSTR)"default_temp_dir"),mDefault_temp_dir); 00509 00510 if ( mDefault_temp_dir == "$") // no value found in config_xml 00511 { 00512 size_t pos = mConfig_xml_full_path.find("bbtk_config.xml"); 00513 mDefault_temp_dir = mConfig_xml_full_path.substr (0,pos); 00514 } 00515 */ 00516 00517 GetHelp(2); 00518 }
std::string bbtk::ConfigurationFile::mBbs_path [private] |
The path to the bbs folder (=mInstall_path+"/"+mBbs_rel_path).
Definition at line 148 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile().
std::vector<std::string> bbtk::ConfigurationFile::mBbs_paths [private] |
Scripts.
Definition at line 161 of file bbtkConfigurationFile.h.
Referenced by AddPackagePathsAndWrite(), ConfigurationFile(), and Read().
std::string bbtk::ConfigurationFile::mBbs_rel_path [private] |
The relative path to the doc folder (=BBTK_BBS_REL_PATH).
Definition at line 146 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile().
std::string bbtk::ConfigurationFile::mBin_path [private] |
Set automatically : The path to the executable (usually bbi)
Definition at line 136 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile().
std::string bbtk::ConfigurationFile::mConfig_xml_full_path [private] |
Where is the file bbtk_config.xml.
Definition at line 132 of file bbtkConfigurationFile.h.
Referenced by Read().
std::string bbtk::ConfigurationFile::mData_path [private] |
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
Definition at line 152 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile(), and Read().
std::string bbtk::ConfigurationFile::mDescription [private] |
std::string bbtk::ConfigurationFile::mDoc_path [private] |
The path to the doc folder (=mDot_bbtk_path+"/doc").
Definition at line 142 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile(), and InitializeDotBbtkStructure().
bool bbtk::ConfigurationFile::mDot_bbtk_is_new [private] |
Set to true by InitializeDotBbtkStructure() if .bbtk has been newly created
Definition at line 170 of file bbtkConfigurationFile.h.
Referenced by InitializeDotBbtkStructure().
std::string bbtk::ConfigurationFile::mDot_bbtk_path [private] |
The path to the .bbtk user's dir (e.g. /home/username/.bbtk).
Definition at line 138 of file bbtkConfigurationFile.h.
Referenced by InitializeDotBbtkStructure().
std::vector<std::string> bbtk::ConfigurationFile::mExt_dll_paths [private] |
std::string bbtk::ConfigurationFile::mFile_separator [private] |
/ or \, depending on the OS
Definition at line 155 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile().
std::string bbtk::ConfigurationFile::mInstall_path [private] |
The path to the install prefix (=mBinPath+"/..").
Definition at line 140 of file bbtkConfigurationFile.h.
Referenced by ConfigurationFile(), and InitializeDotBbtkStructure().
std::vector<std::string> bbtk::ConfigurationFile::mPackage_paths [private] |
Package dlls.
Definition at line 163 of file bbtkConfigurationFile.h.
Referenced by AddPackagePathsAndWrite(), ConfigurationFile(), and Read().
std::string bbtk::ConfigurationFile::mTemp_path [private] |
Temp directory for generated data (=mDot_bbtk_path+"/tmp").
Definition at line 144 of file bbtkConfigurationFile.h.
Referenced by InitializeDotBbtkStructure().
std::string bbtk::ConfigurationFile::mUrl [private] |
Read from bbtk_config.xml file Where the doc is
Definition at line 159 of file bbtkConfigurationFile.h.
Referenced by Read().