23 #include "eclipse_path.h" 26 #include <core/exception.h> 27 #include <eclipseclass.h> 46 EclipsePath::EclipsePath()
56 if (m_instance)
return;
59 m_instance->add_regex(boost::regex(
"@BASEDIR@"), BASEDIR);
60 m_instance->add_regex(boost::regex(
"@CONFDIR@"), CONFDIR);
61 m_instance->add_regex(boost::regex(
"@FAWKESDIR@"), FAWKES_BASEDIR);
69 create_initial_object();
81 paths.push_back(path);
91 instance()->add_path(path);
92 instance()->apply_regexes();
106 for (std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it){
113 #ifdef BOOST_FILESYSTEM_VERSION 120 catch (
const filesystem_error& ex)
135 std::vector<std::string>::iterator it;
136 for (i = 0, it = paths.begin(); it != paths.end(); ++it, i++){
137 for (std::map<boost::regex,std::string>::iterator re=regexes.begin(); re!=regexes.end(); ++re){
138 std::string result = boost::regex_replace(*it, re->first, re->second);
152 for ( std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it){
165 regexes.insert( std::pair<boost::regex,std::string>(re, str) );
176 if ( EC_succeed != EC_arg(1).is_string ( &filename ) )
178 printf(
"p_locate_file(): no filename given\n" );
181 if (EC_succeed != EC_arg(2).unify( EC_word(p.c_str()) ) ){
182 printf(
"p_locate_file(): could not bind return valie\n" );
185 return p.empty() ? EC_fail : EC_succeed;
void apply_regexes()
Apply the regexes to all paths.
void add_regex(boost::regex re, std::string str)
Add a regex.
static EclipsePath * instance()
Get the EclipsePath instance.
Fawkes library namespace.
void print_all_paths()
Debug method to print all path to the command line.
Class to determine the location of ECLiPSe-clp programs.
Base class for exceptions in Fawkes.
static void create_initial_object()
Create the initial EclipsePath object.
void add_path_check(std::string path)
Add a new path and apply regexes to all paths.
std::string locate_file(std::string filename)
Locate a file by filename.
void add_path(std::string path)
Add a new path.