Skip to content
Snippets Groups Projects
Commit d82610c1 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Replace boost::filesystem::load_string_file with own implementation

boost::filesystem::load_string_file was removed in boost 1.84
parent 6fb00fd9
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!57Fix deprecations + updates
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment