Consolidate file reading through the new FileReader class/interface. (#3321)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user