diff options
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/module.cc b/src/module.cc index 2c7246e..27e01ff 100644 --- a/src/module.cc +++ b/src/module.cc @@ -32,6 +32,7 @@ #include "expression.h" #include "function.h" #include "printutils.h" +#include "parsersettings.h" #include <boost/filesystem.hpp> namespace fs = boost::filesystem; @@ -196,14 +197,15 @@ std::string Module::dump(const std::string &indent, const std::string &name) con return dump.str(); } -void FileModule::registerInclude(const std::string &filename) +void FileModule::registerInclude(const std::string &localpath, + const std::string &fullpath) { - PRINTB("filemodule reginclude %s", filename); + PRINTB("filemodule reginclude %s -> %s", localpath % fullpath); struct stat st; memset(&st, 0, sizeof(struct stat)); - bool valid = stat(filename.c_str(), &st); - IncludeFile inc = {filename,valid,st.st_mtime}; - this->includes[filename] = inc; + bool valid = stat(fullpath.c_str(), &st); + IncludeFile inc = {fullpath, valid, st.st_mtime}; + this->includes[localpath] = inc; } /*! @@ -257,12 +259,14 @@ AbstractNode *FileModule::instantiate(const Context *ctx, const ModuleInstantiat bool FileModule::include_modified(IncludeFile inc) { - struct stat st; - memset(&st, 0, sizeof(struct stat)); - // todo - search paths - bool valid = stat(inc.filename.c_str(), &st); - if (inc.valid != valid) return true; - if (st.st_mtime > inc.mtime) return true; - return false; + struct stat st; + memset(&st, 0, sizeof(struct stat)); + // FIXME: Detect removal of previously found files + fs::path fullpath = find_valid_path(this->path, inc.filename); + if (!fullpath.empty()) { + bool valid = stat(inc.filename.c_str(), &st); + if (inc.valid != valid) return true; + if (st.st_mtime > inc.mtime) return true; + } + return false; } - |