29 #include <boost/filesystem/operations.hpp>
32 #include <opencog/util/Config.h>
33 #include <opencog/util/files.h>
34 #include <opencog/util/Logger.h>
35 #include <opencog/util/misc.h>
52 std::string load_exp(
"(load \"");
53 load_exp += filename +
"\")";
58 printf(
"Error: %s\n", rv.c_str());
71 std::vector<std::string> search_paths)
73 if (search_paths.empty()) {
77 for (
auto p : DEFAULT_MODULE_PATHS) {
78 search_paths.push_back(p);
79 search_paths.push_back(p +
"/examples/rule-engine");
80 search_paths.push_back(p +
"/opencog");
81 search_paths.push_back(p +
"/build");
82 search_paths.push_back(p +
"/build/opencog");
87 for (
const std::string& search_path : search_paths) {
88 boost::filesystem::path modulePath(search_path);
89 modulePath /= filename;
90 logger().debug(
"Searching path %s", modulePath.string().c_str());
91 if (boost::filesystem::exists(modulePath)) {
94 logger().info(
"Loaded %s", modulePath.string().c_str());
102 logger().warn(
"Failed to load file %s: %d %s",
103 filename.c_str(), rc, strerror(rc));
113 std::vector<std::string> search_paths)
116 std::vector<std::string> scm_modules;
117 tokenize(config()[
"SCM_PRELOAD"], std::back_inserter(scm_modules),
", ");
119 for (
const std::string& scm_module : scm_modules)
void eval_expr(const std::string &)
std::string poll_result()
virtual bool eval_error(void)
void load_scm_files_from_config(AtomSpace &atomSpace, std::vector< std::string > search_paths)
int load_scm_file(AtomSpace &as, const std::string &filename)
int load_scm_file_relative(AtomSpace &as, const std::string &filename, std::vector< std::string > search_paths)