From a96fc9e9cc79f7e28f23021718f32171026010fa Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Jun 2014 12:55:59 -0700 Subject: [PATCH] fix unicode handling in is_regular_file check - refs #2273 --- include/mapnik/util/fs.hpp | 1 + src/font_engine_freetype.cpp | 2 +- src/fs.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/mapnik/util/fs.hpp b/include/mapnik/util/fs.hpp index 28158ebff..04775cdeb 100644 --- a/include/mapnik/util/fs.hpp +++ b/include/mapnik/util/fs.hpp @@ -33,6 +33,7 @@ namespace mapnik { namespace util { MAPNIK_DECL bool exists(std::string const& value); MAPNIK_DECL bool is_directory(std::string const& value); +MAPNIK_DECL bool is_regular_file(std::string const& value); MAPNIK_DECL bool remove(std::string const& value); MAPNIK_DECL bool is_relative(std::string const& value); MAPNIK_DECL std::string make_relative(std::string const& filepath, std::string const& base); diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index b6581c56b..e493dde5d 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -185,7 +185,7 @@ bool freetype_engine::register_fonts(std::string const& dir, bool recurse) std::string base_name = itr->filename(); #endif if (!boost::algorithm::starts_with(base_name,".") && - boost::filesystem::is_regular_file(file_name) && + mapnik::util::is_regular_file(file_name) && is_font_file(file_name)) { if (mapnik::freetype_engine::register_font(file_name)) diff --git a/src/fs.cpp b/src/fs.cpp index 9eb01214b..bb7c3ab03 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -88,6 +88,15 @@ namespace util { #endif } + bool is_regular_file(std::string const& filepath) + { +#ifdef _WINDOWS + return boost::filesystem::is_regular_file(mapnik::utf8_to_utf16(filepath)); +#else + return boost::filesystem::is_regular_file(filepath); +#endif + } + bool remove(std::string const& filepath) { #ifdef _WINDOWS