summaryrefslogtreecommitdiff
path: root/project2/common/environment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/common/environment.cpp')
-rw-r--r--project2/common/environment.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/project2/common/environment.cpp b/project2/common/environment.cpp
index 18d60a0..e99be54 100644
--- a/project2/common/environment.cpp
+++ b/project2/common/environment.cpp
@@ -90,20 +90,21 @@ Environment::getCurrent()
return currentEnv;
}
-boost::filesystem::path
-Environment::resolveScript(const std::string & group, const std::string & name) const
+ScriptReaderPtr
+Environment::resolveScript(const std::string & group, const std::string & name, bool ii) const
{
- boost::filesystem::path script(boost::filesystem::current_path() / group);
- BOOST_FOREACH(const boost::filesystem::path & e, boost::filesystem::path(name)) {
- if (boost::filesystem::is_directory(script / e)) {
- script /= e;
- }
- else {
- if (boost::filesystem::is_regular_file((script / e).replace_extension(".xml"))) {
- return ((script / e).replace_extension(".xml"));
- }
+ typedef std::map<std::string, boost::shared_ptr<ScriptReaderLoader> > ReaderLoaders;
+ BOOST_FOREACH(const ReaderLoaders::value_type & rl, *LoaderBase::objLoaders<ScriptReaderLoader>()) {
+ ScriptReaderPtr rs = rl.second->resolveScript(group, name);
+ if (rs) {
+ return rs;
}
}
- return script;
+ if (ii) {
+ throw DependencyNotFound(group, name);
+ }
+ else {
+ throw ScriptNotFound(group, name);
+ }
}