diff options
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/module.cc b/src/module.cc index e853457..2c7246e 100644 --- a/src/module.cc +++ b/src/module.cc @@ -46,6 +46,8 @@ AbstractModule::~AbstractModule() AbstractNode *AbstractModule::instantiate(const Context *ctx, const ModuleInstantiation *inst, const EvalContext *evalctx) const { + (void)ctx; // avoid unusued parameter warning + AbstractNode *node = new AbstractNode(inst); node->children = inst->instantiateChildren(evalctx); @@ -196,10 +198,12 @@ std::string Module::dump(const std::string &indent, const std::string &name) con void FileModule::registerInclude(const std::string &filename) { + PRINTB("filemodule reginclude %s", filename); struct stat st; memset(&st, 0, sizeof(struct stat)); - stat(filename.c_str(), &st); - this->includes[filename] = st.st_mtime; + bool valid = stat(filename.c_str(), &st); + IncludeFile inc = {filename,valid,st.st_mtime}; + this->includes[filename] = inc; } /*! @@ -250,3 +254,15 @@ AbstractNode *FileModule::instantiate(const Context *ctx, const ModuleInstantiat return node; } + +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; +} + |