From 154c93017acece13d6b451286db12d6a16135b71 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Tue, 21 May 2013 09:42:55 -0700 Subject: [PATCH] * add support for unicode (utf16) paths on windows --- plugins/input/shape/dbfile.cpp | 2 ++ plugins/input/shape/shape_datasource.cpp | 17 ++++++++++++++--- plugins/input/shape/shapefile.hpp | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 7902eb4ab..b6014da2e 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -50,6 +50,8 @@ dbf_file::dbf_file(std::string const& file_name) record_length_(0), #ifdef SHAPE_MEMORY_MAPPED_FILE file_(), +#elif defined(_WINDOWS) + file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary), #else file_(file_name.c_str() ,std::ios::in | std::ios::binary), #endif diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index a98121ec8..391d9cb8b 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2011 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -34,6 +34,7 @@ // mapnik #include #include +#include #include #include #include @@ -76,18 +77,28 @@ shape_datasource::shape_datasource(const parameters ¶ms) shape_name_ = *file; boost::algorithm::ireplace_last(shape_name_,".shp",""); - +#ifdef _WINDOWS + if (!boost::filesystem::exists(mapnik::utf8_to_utf16(shape_name_) + L".shp")) +#else if (!boost::filesystem::exists(shape_name_ + ".shp")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist"); } - +#ifdef _WINDOWS + if (boost::filesystem::is_directory(mapnik::utf8_to_utf16(shape_name_) + L".shp")) +#else if (boost::filesystem::is_directory(shape_name_ + ".shp")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' appears to be a directory not a file"); } +#ifdef _WINDOWS + if (!boost::filesystem::exists(mapnik::utf8_to_utf16(shape_name_) + L".dbf")) +#else if (!boost::filesystem::exists(shape_name_ + ".dbf")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".dbf' does not exist"); } diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index c082b09d4..9df691119 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include #include #include @@ -149,6 +150,8 @@ public: shape_file(std::string const& file_name) : #ifdef SHAPE_MEMORY_MAPPED_FILE file_() +#elif defined (_WINDOWS) + file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary) #else file_(file_name.c_str(), std::ios::in | std::ios::binary) #endif