From c378ddb55e791cba642ada857daf7162dc49828d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 6 Jan 2011 00:29:03 +0000 Subject: [PATCH] boost filesystem v3 support, ported from trunk --- src/datasource_cache.cpp | 33 ++++++++++++++++++++++++--------- src/font_engine_freetype.cpp | 8 ++++++++ src/load_map.cpp | 15 ++++++++++++--- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 6850c5fc7..9f77e6992 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -44,8 +44,8 @@ namespace mapnik { - using namespace std; - using namespace boost; +//using namespace std; +//using namespace boost; bool is_input_plugin (std::string const& filename) { @@ -77,7 +77,7 @@ std::vector datasource_cache::plugin_directories_; } datasource_ptr ds; - map >::iterator itr=plugins_.find(*type); + std::map >::iterator itr=plugins_.find(*type); if ( itr == plugins_.end() ) { throw config_error(string("Could not create datasource. No plugin ") + @@ -141,26 +141,35 @@ std::string datasource_cache::plugin_directories() mutex::scoped_lock lock(mapnik::singleton::mutex_); #endif - filesystem::path path(str); + boost::filesystem::path path(str); plugin_directories_.push_back(str); - filesystem::directory_iterator end_itr; + boost::filesystem::directory_iterator end_itr; if (exists(path) && is_directory(path)) { - for (filesystem::directory_iterator itr(path);itr!=end_itr;++itr ) + for (boost::filesystem::directory_iterator itr(path);itr!=end_itr;++itr ) { #if BOOST_VERSION < 103400 if (!is_directory( *itr ) && is_input_plugin(itr->leaf())) #else +#if (BOOST_FILESYSTEM_VERSION == 3) + if (!is_directory( *itr ) && is_input_plugin(itr->path().filename().string())) +#else // v2 if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf())) #endif - +#endif { try { - lt_dlhandle module=lt_dlopen(itr->string().c_str()); + +#if (BOOST_FILESYSTEM_VERSION == 3) + lt_dlhandle module = lt_dlopen(itr->path().string().c_str()); +#else // v2 + lt_dlhandle module = lt_dlopen(itr->string().c_str()); + +#endif if (module) { datasource_name* ds_name = @@ -175,7 +184,13 @@ std::string datasource_cache::plugin_directories() } else { - std::clog << "Problem loading plugin library: " << itr->string().c_str() << " (libtool error: " << lt_dlerror() << ")" << std::endl; +#if (BOOST_FILESYSTEM_VERSION == 3) + std::clog << "Problem loading plugin library: " << itr->path().string() + << " (dlopen failed - plugin likely has an unsatified dependency or incompatible ABI)" << std::endl; +#else // v2 + std::clog << "Problem loading plugin library: " << itr->string() + << " (dlopen failed - plugin likely has an unsatified dependency or incompatible ABI)" << std::endl; +#endif } } catch (...) {} diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index afa87d055..8c75a5ff8 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -99,11 +99,19 @@ bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { if (boost::filesystem::is_directory(*itr) && recurse) { +#if (BOOST_FILESYSTEM_VERSION == 3) + if (!register_fonts(itr->path().string(), true)) return false; +#else // v2 if (!register_fonts(itr->string(), true)) return false; +#endif } else { +#if (BOOST_FILESYSTEM_VERSION == 3) + mapnik::freetype_engine::register_font(itr->path().string()); +#else // v2 mapnik::freetype_engine::register_font(itr->string()); +#endif } } return true; diff --git a/src/load_map.cpp b/src/load_map.cpp index dbbe93b83..6fe15b2ec 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -534,8 +534,11 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) map.addLayer(lyr); - } catch (const config_error & ex) { - if ( ! name.empty() ) { + } + catch (const config_error & ex) + { + if ( ! name.empty() ) + { ex.append_context(string("(encountered during parsing of layer '") + name + "' in map '" + filename_ + "')"); } throw; @@ -1712,8 +1715,14 @@ std::string map_parser::ensure_relative_to_xml( boost::optional opt { boost::filesystem::path xml_path = filename_; boost::filesystem::path rel_path = *opt_path; - if ( !rel_path.has_root_path() ) { + if ( !rel_path.has_root_path() ) + { +#if (BOOST_FILESYSTEM_VERSION == 3) + boost::filesystem::path full = boost::filesystem::absolute(xml_path.branch_path()/rel_path).normalize(); +#else // v2 boost::filesystem::path full = boost::filesystem::complete(xml_path.branch_path()/rel_path).normalize(); +#endif + #ifdef MAPNIK_DEBUG std::clog << "\nModifying relative paths to be relative to xml...\n"; std::clog << "original base path: " << *opt_path << "\n";