1 From 408e56f0390f20aaf793e0aa0c70c4d9544401d4 Mon Sep 17 00:00:00 2001
2 From: Vojtech Bubnik <bubnikv@gmail.com>
3 Date: Mon, 25 Apr 2022 08:33:48 +0200
4 Subject: [PATCH] Fix of Boost 1.79 deprecated boost::filesystem::ofstream
5 #8238 Replacing boost::filesystem::fstream with boost::nowide::fstream
6 variants with the unfortunate cost of string path conversion on Windows from
7 16 bits to UTF8 and back to 16 bits.
9 Unfortunately we cannot use std::filesystem yet as it is missing
10 on older MACs and because the interface is crooked minefield on Windows
11 see https://github.com/microsoft/STL/issues/909
13 src/hints/HintsToPot.cpp | 2 +-
14 src/libslic3r/Preset.cpp | 2 +-
15 src/slic3r/GUI/HintNotification.cpp | 8 +++++---
16 3 files changed, 7 insertions(+), 5 deletions(-)
18 diff --git a/src/hints/HintsToPot.cpp b/src/hints/HintsToPot.cpp
19 index 7c8029cdeb..4791f0612f 100644
20 --- a/src/hints/HintsToPot.cpp
21 +++ b/src/hints/HintsToPot.cpp
24 bool write_to_pot(boost::filesystem::path path, const std::vector<std::pair<std::string, std::string>>& data)
26 - boost::filesystem::ofstream file(std::move(path), std::ios_base::app);
27 + boost::nowide::ofstream file(path.string(), std::ios_base::app);
28 for (const auto& element : data)
30 //Example of .pot element
31 diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp
32 index f3a1c15b3e..f171cb14dd 100644
33 --- a/src/libslic3r/Preset.cpp
34 +++ b/src/libslic3r/Preset.cpp
35 @@ -84,7 +84,7 @@ ConfigFileType guess_config_file_type(const ptree &tree)
36 VendorProfile VendorProfile::from_ini(const boost::filesystem::path &path, bool load_all)
39 - boost::filesystem::ifstream ifs(path);
40 + boost::nowide::ifstream ifs(path.string());
41 boost::property_tree::read_ini(ifs, tree);
42 return VendorProfile::from_ini(tree, path, load_all);
44 diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp
45 index 93e0fb3259..820b74eedb 100644
46 --- a/src/slic3r/GUI/HintNotification.cpp
47 +++ b/src/slic3r/GUI/HintNotification.cpp
49 #include "libslic3r/Config.hpp"
50 #include "libslic3r/PrintConfig.hpp"
54 #include <boost/algorithm/string/replace.hpp>
55 #include <boost/filesystem.hpp>
56 #include <boost/nowide/fstream.hpp>
57 #include <boost/log/trivial.hpp>
58 #include <boost/property_tree/ini_parser.hpp>
61 #include <cereal/archives/binary.hpp>
62 #include <cereal/types/string.hpp>
63 #include <cereal/types/vector.hpp>
64 @@ -65,7 +67,7 @@ inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, f
66 void write_used_binary(const std::vector<std::string>& ids)
68 - boost::filesystem::ofstream file((boost::filesystem::path(data_dir()) / "cache" / "hints.cereal"), std::ios::binary);
69 + boost::nowide::ofstream file((boost::filesystem::path(data_dir()) / "cache" / "hints.cereal").string(), std::ios::binary);
70 cereal::BinaryOutputArchive archive(file);
71 HintsCerealData cd { ids };
73 @@ -84,7 +86,7 @@ void read_used_binary(std::vector<std::string>& ids)
74 BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
77 - boost::filesystem::ifstream file(path);
78 + boost::nowide::ifstream file(path.string());
79 cereal::BinaryInputArchive archive(file);