From 184d9dd43bad5bfcee467103bf03cc22252b9718 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 b2e2de14b..1b6cd78e6 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -213,7 +213,7 @@ bool freetype_engine::register_fonts_impl(std::string const& dir, FT_LibraryRec_ 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_impl(file_name, library)) diff --git a/src/fs.cpp b/src/fs.cpp index bd78663e2..bcb109f32 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