superslicer-prerelease/0007-boost1.84.patch

35 lines
1.9 KiB
Diff
Raw Permalink Normal View History

diff --git a/src/slic3r/GUI/ScriptExecutor.cpp b/src/slic3r/GUI/ScriptExecutor.cpp
index 3e10680e46..3dcbf9643f 100644
--- a/src/slic3r/GUI/ScriptExecutor.cpp
+++ b/src/slic3r/GUI/ScriptExecutor.cpp
@@ -827,6 +827,20 @@ void as_back_custom_initial_value(int preset_type, std::string& key) {
/////// main script fucntions //////
+// stolen from https://www.boost.org/doc/libs/1_79_0/boost/filesystem/string_file.hpp
+static inline void load_string_file(boost::filesystem::path const& p, std::string& str)
+{
+ boost::filesystem::ifstream file;
+ file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
+ file.open(p, std::ios_base::binary);
+ const boost::uintmax_t sz = boost::filesystem::file_size(p);
+ if (BOOST_UNLIKELY(sz > static_cast< boost::uintmax_t >((std::numeric_limits< std::streamsize >::max)())))
+ BOOST_FILESYSTEM_THROW(std::length_error("File size exceeds max read size"));
+ str.resize(static_cast< std::size_t >(sz), '\0');
+ if (sz > 0u)
+ file.read(&str[0], static_cast< std::streamsize >(sz));
+}
+
//TODO: add "unset" function, that revert to last value (befoer a scripted set) if a set has been made since last not-scripted change.
void ScriptContainer::init(const std::string& tab_key, Tab* tab)
{
@@ -960,7 +974,7 @@ void ScriptContainer::init(const std::string& tab_key, Tab* tab)
//res = builder.AddSectionFromFile(ui_script_file.string().c_str()); //seems to be problematic on cyrillic locale
{
std::string all_file;
- boost::filesystem::load_string_file(ui_script_file, all_file);
+ load_string_file(ui_script_file, all_file);
res = builder.AddSectionFromMemory(ui_script_file.string().c_str(), all_file.c_str(), (unsigned int)(all_file.length()), 0);
}
if (res < 0) throw CompileErrorException("Error, can't build the script for tab " + tab_key);