diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index 74a70c992..9827886f9 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -34,6 +34,7 @@ // stl #include +#include namespace mapnik { @@ -55,7 +56,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 1e16c33d4..d1ec3d630 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -166,8 +166,7 @@ void datasource_cache::register_datasources(std::string const& str) #ifdef MAPNIK_THREADSAFE mutex::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; @@ -195,9 +194,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; + } boost::shared_ptr plugin = boost::make_shared(filename,"datasource_name"); if (plugin->valid()) { @@ -213,7 +218,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 @@ -229,7 +234,7 @@ bool datasource_cache::register_datasource(std::string const& filename) << "Exception caught while loading plugin library: " << filename << " (" << ex.what() << ")"; } - return success; + return false; } }