diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index b6014da2e..d9d7bafb7 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -62,8 +62,13 @@ dbf_file::dbf_file(std::string const& file_name) boost::optional memory = mapped_memory_cache::instance().find(file_name,true); if (memory) { + mapped_region_ = *memory; file_.buffer(static_cast((*memory)->get_address()),(*memory)->get_size()); } + else + { + throw std::runtime_error("could not create file mapping for "+file_name); + } #endif if (file_) { diff --git a/plugins/input/shape/dbfile.hpp b/plugins/input/shape/dbfile.hpp index b4a0a9bbe..3659c1cb8 100644 --- a/plugins/input/shape/dbfile.hpp +++ b/plugins/input/shape/dbfile.hpp @@ -27,6 +27,7 @@ #include #include #include +#include // boost #include @@ -57,6 +58,7 @@ private: std::vector fields_; #ifdef SHAPE_MEMORY_MAPPED_FILE boost::interprocess::ibufferstream file_; + mapnik::mapped_region_ptr mapped_region_; #else std::ifstream file_; #endif diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 6e5631824..9daa50906 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -138,6 +138,7 @@ public: #ifdef SHAPE_MEMORY_MAPPED_FILE typedef ibufferstream file_source_type; typedef shape_record record_type; + mapnik::mapped_region_ptr mapped_region_; #else typedef std::ifstream file_source_type; typedef shape_record record_type; @@ -162,7 +163,12 @@ public: if (memory) { - file_.buffer(static_cast((*memory)->get_address()), (*memory)->get_size()); + mapped_region_ = *memory; + file_.buffer(static_cast((*memory)->get_address()),(*memory)->get_size()); + } + else + { + throw std::runtime_error("could not create file mapping for "+file_name); } #endif }