23 #include "eclipse_path.h"
25 #include <core/exception.h>
27 #include <eclipseclass.h>
31 using namespace boost::filesystem;
46 EclipsePath::EclipsePath()
60 m_instance->add_regex(boost::regex(
"@BASEDIR@"), BASEDIR);
61 m_instance->add_regex(boost::regex(
"@CONFDIR@"), CONFDIR);
62 m_instance->add_regex(boost::regex(
"@FAWKESDIR@"), FAWKES_BASEDIR);
71 create_initial_object();
81 paths.push_back(path);
90 instance()->add_path(path);
91 instance()->apply_regexes();
105 for (std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it) {
112 #ifdef BOOST_FILESYSTEM_VERSION
118 }
catch (
const filesystem_error &ex) {
131 std::vector<std::string>::iterator it;
132 for (i = 0, it = paths.begin(); it != paths.end(); ++it, i++) {
133 for (std::map<boost::regex, std::string>::iterator re = regexes.begin(); re != regexes.end();
135 std::string result = boost::regex_replace(*it, re->first, re->second);
148 for (std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it) {
161 regexes.insert(std::make_pair(re, str));
172 if (EC_succeed != EC_arg(1).is_string(&filename)) {
173 printf(
"p_locate_file(): no filename given\n");
176 if (EC_succeed != EC_arg(2).unify(EC_word(p.c_str()))) {
177 printf(
"p_locate_file(): could not bind return valie\n");
180 return p.empty() ? EC_fail : EC_succeed;
Class to determine the location of ECLiPSe-clp programs.
void add_path(const std::string &path)
Add a new path.
static EclipsePath * instance()
Get the EclipsePath instance.
std::string locate_file(const std::string &filename)
Locate a file by filename.
static void create_initial_object()
Create the initial EclipsePath object.
void add_path_check(const std::string &path)
Add a new path and apply regexes to all paths.
void print_all_paths()
Debug method to print all path to the command line.
void apply_regexes()
Apply the regexes to all paths.
void add_regex(boost::regex re, const std::string &str)
Add a regex.
Base class for exceptions in Fawkes.
Fawkes library namespace.