summaryrefslogtreecommitdiff
path: root/src/module.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-05-20 04:31:18 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-05-20 04:31:18 (GMT)
commit8a83e334abceda6f5c119872f922da7cc99c7210 (patch)
treebbe1f2e20fa599ebfad4f89aebd5e46905630ead /src/module.cc
parent77a598ab7267d04f0b1fc0277e0314c3780313c0 (diff)
try to refactor the 'is_modified( includefile )' code
Diffstat (limited to 'src/module.cc')
-rw-r--r--src/module.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/module.cc b/src/module.cc
index 001c6c8..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);
@@ -194,14 +196,14 @@ std::string Module::dump(const std::string &indent, const std::string &name) con
return dump.str();
}
-#include <iostream>
void FileModule::registerInclude(const std::string &filename)
{
- std::cout << "reginclude" << filename << "\n";
+ 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;
}
/*!
@@ -252,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;
+}
+
contact: Jan Huwald // Impressum