diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index a5f16236f..a56c989af 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -35,6 +35,7 @@ // stl #include +#include namespace mapnik { @@ -56,7 +57,7 @@ private: ~datasource_cache(); std::map > plugins_; bool registered_; - std::vector plugin_directories_; + std::set plugin_directories_; }; } diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 507e1f093..335ee2bb2 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -165,8 +165,7 @@ void datasource_cache::register_datasources(std::string const& str) #ifdef MAPNIK_THREADSAFE mapnik::scoped_lock lock(mutex_); #endif - // TODO - only push unique paths - plugin_directories_.push_back(str); + plugin_directories_.insert(str); if (mapnik::util::exists(str) && mapnik::util::is_directory(str)) { boost::filesystem::directory_iterator end_itr; @@ -194,9 +193,15 @@ void datasource_cache::register_datasources(std::string const& str) bool datasource_cache::register_datasource(std::string const& filename) { - bool success = false; try { + if (!mapnik::util::exists(filename)) + { + MAPNIK_LOG_ERROR(datasource_cache) + << "Cannot load '" + << filename << "' (plugin does not exist)"; + return false; + } std::shared_ptr plugin = std::make_shared(filename,"datasource_name"); if (plugin->valid()) { @@ -212,7 +217,7 @@ bool datasource_cache::register_datasource(std::string const& filename) MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Registered=" << plugin->name(); - success = true; + return true; } } else @@ -228,7 +233,7 @@ bool datasource_cache::register_datasource(std::string const& filename) << "Exception caught while loading plugin library: " << filename << " (" << ex.what() << ")"; } - return success; + return false; } }