FIX:fixed issue with chinese path

jira:[Fixed the issue of failed loading of configuration files under Chinese path]

Change-Id: I9badd8fc158fcf49f46411ac4e5f72d58823eeb2
This commit is contained in:
tao wang 2024-01-07 09:57:38 +08:00 committed by Lane.Wei
parent 689331e2bf
commit aa8d7acf3b
4 changed files with 10 additions and 8 deletions

View File

@ -2212,7 +2212,8 @@ int Print::get_hrc_by_nozzle_type(const NozzleType&type)
static std::map<std::string, int>nozzle_type_to_hrc;
if (nozzle_type_to_hrc.empty()) {
fs::path file_path = fs::path(resources_dir()) / "info" / "nozzle_info.json";
std::ifstream in(file_path.string());
boost::nowide::ifstream in(file_path.string());
//std::ifstream in(file_path.string());
json j;
try {
j = json::parse(in);

View File

@ -5534,7 +5534,7 @@ std::vector<std::string> DeviceManager::get_resolution_supported(std::string typ
std::vector<std::string> resolution_supported;
std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json";
std::ifstream json_file(config_file.c_str());
boost::nowide::ifstream json_file(config_file.c_str());
try {
json jj;
if (json_file.is_open()) {
@ -5556,7 +5556,7 @@ std::vector<std::string> DeviceManager::get_compatible_machine(std::string type_
{
std::vector<std::string> compatible_machine;
std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json";
std::ifstream json_file(config_file.c_str());
boost::nowide::ifstream json_file(config_file.c_str());
try {
json jj;
if (json_file.is_open()) {
@ -5575,10 +5575,12 @@ std::vector<std::string> DeviceManager::get_compatible_machine(std::string type_
}
bool DeviceManager::load_filaments_blacklist_config(std::string config_file)
bool DeviceManager::load_filaments_blacklist_config()
{
filaments_blacklist = json::object();
std::ifstream json_file(config_file.c_str());
std::string config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
boost::nowide::ifstream json_file(config_file.c_str());
try {
if (json_file.is_open()) {

View File

@ -1029,7 +1029,7 @@ public:
static bool get_printer_is_enclosed(std::string type_str);
static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str);
static bool load_filaments_blacklist_config(std::string config_file);
static bool load_filaments_blacklist_config();
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
static std::string load_gcode(std::string type_str, std::string gcode_file);
};

View File

@ -1280,8 +1280,7 @@ void GUI_App::post_init()
});
std::string filaments_blacklist_config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
DeviceManager::load_filaments_blacklist_config(encode_path(filaments_blacklist_config_file.c_str()));
DeviceManager::load_filaments_blacklist_config();
// remove old log files over LOG_FILES_MAX_NUM
std::string log_addr = data_dir();