From 4ab4a9afe8e642a5a5547240f6de22db0d6dfae4 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 2 Nov 2017 16:40:25 +0100 Subject: [PATCH] Fighting with boost::filesystem::directory_iterator --- xs/src/slic3r/GUI/GUI.cpp | 6 +++--- xs/src/slic3r/GUI/Preset.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 90cb0a93c..63cc7749d 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -98,11 +98,11 @@ std::vector scan_serial_ports() #else // UNIX and OS X std::initializer_list prefixes { "ttyUSB" , "ttyACM", "tty.", "cu.", "rfcomm" }; - for (auto &file : boost::filesystem::directory_iterator(boost::filesystem::path("/dev"))) { - std::string name = it->path().filename().string(); + for (auto &dir_entry : boost::filesystem::directory_iterator(boost::filesystem::path("/dev"))) { + std::string name = dir_entry.path().filename().string(); for (const char *prefix : prefixes) { if (boost::starts_with(name, prefix)) { - out.emplace_back(it->path().string()); + out.emplace_back(dir_entry.path().string()); break; } } diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 5b42b27a1..05d1c3927 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -241,14 +241,14 @@ void PresetCollection::load_presets(const std::string &dir_path, const std::stri m_dir_path = dir.string(); m_presets.erase(m_presets.begin()+1, m_presets.end()); t_config_option_keys keys = this->default_preset().config.keys(); - for (auto &file : boost::filesystem::directory_iterator(dir)) - if (boost::filesystem::is_regular_file(file.status()) && boost::algorithm::iends_with(file.path().filename().string(), ".ini")) { - std::string name = file.path().filename().string(); + for (auto &dir_entry : boost::filesystem::directory_iterator(dir)) + if (boost::filesystem::is_regular_file(dir_entry.status()) && boost::algorithm::iends_with(dir_entry.path().filename().string(), ".ini")) { + std::string name = dir_entry.path().filename().string(); // Remove the .ini suffix. name.erase(name.size() - 4); try { Preset preset(m_type, name, false); - preset.file = file.path().string(); + preset.file = dir_entry.path().string(); preset.load(keys); m_presets.emplace_back(preset); } catch (const boost::filesystem::filesystem_error &err) {