The [standard C++17 filesystem library](https://en.cppreference.com/w/cpp/filesystem) would help a lot for cross-platform `list_ports` functions.