Fix of Boost 1.79 deprecated boost::filesystem::ofstream #8238

Replacing boost::filesystem::fstream with boost::nowide::fstream
variants with the unfortunate cost of string path conversion on Windows
from 16 bits to UTF8 and back to 16 bits.

Unfortunately we cannot use std::filesystem yet as it is missing
on older MACs and because the interface is crooked minefield on Windows
see https://github.com/microsoft/STL/issues/909
This commit is contained in:
Vojtech Bubnik 2022-04-25 08:33:48 +02:00
parent 5047d4a10b
commit 408e56f039
3 changed files with 7 additions and 5 deletions

View File

@ -9,7 +9,7 @@
bool write_to_pot(boost::filesystem::path path, const std::vector<std::pair<std::string, std::string>>& data) bool write_to_pot(boost::filesystem::path path, const std::vector<std::pair<std::string, std::string>>& data)
{ {
boost::filesystem::ofstream file(std::move(path), std::ios_base::app); boost::nowide::ofstream file(path.string(), std::ios_base::app);
for (const auto& element : data) for (const auto& element : data)
{ {
//Example of .pot element //Example of .pot element

View File

@ -84,7 +84,7 @@ ConfigFileType guess_config_file_type(const ptree &tree)
VendorProfile VendorProfile::from_ini(const boost::filesystem::path &path, bool load_all) VendorProfile VendorProfile::from_ini(const boost::filesystem::path &path, bool load_all)
{ {
ptree tree; ptree tree;
boost::filesystem::ifstream ifs(path); boost::nowide::ifstream ifs(path.string());
boost::property_tree::read_ini(ifs, tree); boost::property_tree::read_ini(ifs, tree);
return VendorProfile::from_ini(tree, path, load_all); return VendorProfile::from_ini(tree, path, load_all);
} }

View File

@ -14,12 +14,14 @@
#include "libslic3r/Config.hpp" #include "libslic3r/Config.hpp"
#include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfig.hpp"
#include <map>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/nowide/fstream.hpp> #include <boost/nowide/fstream.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <boost/property_tree/ini_parser.hpp> #include <boost/property_tree/ini_parser.hpp>
#include <map>
#include <cereal/archives/binary.hpp> #include <cereal/archives/binary.hpp>
#include <cereal/types/string.hpp> #include <cereal/types/string.hpp>
#include <cereal/types/vector.hpp> #include <cereal/types/vector.hpp>
@ -65,7 +67,7 @@ inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, f
void write_used_binary(const std::vector<std::string>& ids) void write_used_binary(const std::vector<std::string>& ids)
{ {
boost::filesystem::ofstream file((boost::filesystem::path(data_dir()) / "cache" / "hints.cereal"), std::ios::binary); boost::nowide::ofstream file((boost::filesystem::path(data_dir()) / "cache" / "hints.cereal").string(), std::ios::binary);
cereal::BinaryOutputArchive archive(file); cereal::BinaryOutputArchive archive(file);
HintsCerealData cd { ids }; HintsCerealData cd { ids };
try try
@ -84,7 +86,7 @@ void read_used_binary(std::vector<std::string>& ids)
BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string(); BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
return; return;
} }
boost::filesystem::ifstream file(path); boost::nowide::ifstream file(path.string());
cereal::BinaryInputArchive archive(file); cereal::BinaryInputArchive archive(file);
HintsCerealData cd; HintsCerealData cd;
try try