From fae527517df56ac1a6f8a22a7737ef84cd5c094f Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 5 Oct 2022 17:06:01 -0300 Subject: [PATCH] Try to appease android's crappy toolchain --- llarp/util/file.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/llarp/util/file.cpp b/llarp/util/file.cpp index dcfb386cb..2cb914263 100644 --- a/llarp/util/file.cpp +++ b/llarp/util/file.cpp @@ -19,24 +19,23 @@ namespace llarp::util { - static std::pair - slurp_file_open(const fs::path& filename) + static std::streampos + slurp_file_open(const fs::path& filename, fs::ifstream& in) { - std::pair 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) > buffer_size) throw std::length_error{"file is too large for buffer"}; in.read(buffer, size);