diff --git a/src/linkahead/utility.cpp b/src/linkahead/utility.cpp index f15e53970ef49b5d89935d36c66d50654b2914ef..fe229d16976c5abd9b9090bb06de7c67917248b1 100644 --- a/src/linkahead/utility.cpp +++ b/src/linkahead/utility.cpp @@ -19,20 +19,21 @@ * */ #include "linkahead/utility.h" -#include "linkahead/data_type.h" // for AtomicDataType, atomicdatatype_names -#include "linkahead/entity.h" // for Importance, Role, importance_names #include <boost/beast/core/detail/base64.hpp> // for encoded_size #include <boost/beast/core/detail/base64.ipp> // for encode -#include <boost/filesystem/string_file.hpp> // for load_string_file #include <boost/json/stream_parser.hpp> // for stream_parser #include <boost/json/value.hpp> // for value #include <cassert> // for assert -#include <map> // for map, operator!=, _Rb_tree_const_iterator -#include <memory> // for allocator, unique_ptr -#include <stdexcept> // for logic_error +#include <cstdint> // for uintmax_t +#include <limits> // for numeric_limits +#include <map> // for map, _Rb_tree_const_it... +#include <memory> // for shared_ptr, allocator +#include <stdexcept> // for out_of_range, length_e... #include <type_traits> // for underlying_type_t #include <typeinfo> // for type_info -#include <utility> // for pair +#include <utility> // for pair, move +#include "linkahead/data_type.h" // for AtomicDataType, atomic... +#include "linkahead/entity.h" // for Importance, Role, impo... namespace linkahead::utility { @@ -106,7 +107,20 @@ template <> auto getEnumValueFromName<Role>(const std::string &name) -> Role { auto load_string_file(const path &file_path) -> std::string { std::string result; - boost::filesystem::load_string_file(file_path.string(), result); + + // adapted from boost::filesystem::load_string_file, which was removed in 1.84 + std::ifstream file; + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + file.open(file_path, std::ios_base::binary); + const std::uintmax_t sz = std::filesystem::file_size(file_path); + if ((sz > static_cast<std::uintmax_t>((std::numeric_limits<std::streamsize>::max)()))) { + throw(std::length_error("File size exceeds max read size")); + } + result.resize(static_cast<std::size_t>(sz), '\0'); + if (sz > 0U) { + file.read(result.data(), static_cast<std::streamsize>(sz)); + } + return result; }