* add support for unicode (utf16) paths on windows
This commit is contained in:
parent
35a8582043
commit
154c93017a
3 changed files with 19 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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 <mapnik/debug.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#include <mapnik/noncopyable.hpp>
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue