Consolidate file reading through the new FileReader class/interface. (#3321)

This commit is contained in:
Daniel Patterson
2016-11-30 19:08:01 -08:00
committed by GitHub
parent ef087f963d
commit 5a311012af
11 changed files with 438 additions and 290 deletions
+5 -10
View File
@@ -10,6 +10,7 @@
#include <boost/filesystem/fstream.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_int.hpp>
#include <storage/io.hpp>
#include <iterator>
#include <unordered_map>
@@ -43,20 +44,14 @@ class RasterGrid
ydim = _ydim;
_data.reserve(ydim * xdim);
boost::filesystem::ifstream stream(filepath, std::ios::binary);
if (!stream)
{
throw util::exception("Unable to open raster file.");
}
storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint);
stream.seekg(0, std::ios_base::end);
std::string buffer;
buffer.resize(static_cast<std::size_t>(stream.tellg()));
stream.seekg(0, std::ios_base::beg);
buffer.resize(file_reader.Size());
BOOST_ASSERT(buffer.size() > 1);
stream.read(&buffer[0], static_cast<std::streamsize>(buffer.size()));
file_reader.ReadInto(&buffer[0], buffer.size());
boost::algorithm::trim(buffer);