summaryrefslogtreecommitdiff
path: root/src/module.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-05-25 21:45:13 (GMT)
committerMarius Kintel <marius@kintel.net>2013-05-25 21:45:13 (GMT)
commitcc6ac10e47ff67fd1d4f5fb8c61fea300f163b1d (patch)
tree2226c6c1ded88cde597a6a882894dd0ae8f50320 /src/module.cc
parent9740232b080ac3d2fe87309fb51a892faf6ea913 (diff)
Search paths when looking for previously missing includes. Should provide most of what's needed for #364
Diffstat (limited to 'src/module.cc')
-rw-r--r--src/module.cc30
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;
}
-
contact: Jan Huwald // Impressum