Try to appease android's crappy toolchain

pull/2005/head
Jason Rhinelander 2 years ago
parent 75e382604b
commit fae527517d
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262

@ -19,24 +19,23 @@
namespace llarp::util
{
static std::pair<fs::ifstream, std::streampos>
slurp_file_open(const fs::path& filename)
static std::streampos
slurp_file_open(const fs::path& filename, fs::ifstream& in)
{
std::pair<fs::ifstream, std::streampos> f;
auto& [in, size] = f;
in.exceptions(std::ifstream::failbit | std::ifstream::badbit);
in.open(filename, std::ios::binary | std::ios::in);
in.seekg(0, std::ios::end);
size = in.tellg();
auto size = in.tellg();
in.seekg(0, std::ios::beg);
return f;
return size;
}
std::string
slurp_file(const fs::path& filename)
{
fs::ifstream in;
std::string contents;
auto [in, size] = slurp_file_open(filename);
auto size = slurp_file_open(filename, in);
contents.resize(size);
in.read(contents.data(), size);
return contents;
@ -45,7 +44,8 @@ namespace llarp::util
size_t
slurp_file(const fs::path& filename, char* buffer, size_t buffer_size)
{
auto [in, size] = slurp_file_open(filename);
fs::ifstream in;
auto size = slurp_file_open(filename, in);
if (static_cast<size_t>(size) > buffer_size)
throw std::length_error{"file is too large for buffer"};
in.read(buffer, size);

Loading…
Cancel
Save