Fighting with boost::filesystem::directory_iterator

This commit is contained in:
bubnikv 2017-11-02 16:40:25 +01:00
parent 7551006102
commit 4ab4a9afe8
2 changed files with 7 additions and 7 deletions

View file

@ -98,11 +98,11 @@ std::vector<std::string> scan_serial_ports()
#else
// UNIX and OS X
std::initializer_list<const char*> 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;
}
}