In windows, on my system, my program would crash when I attempted to iterate over "system volume information", a hidden file on the C: drive. Boost returns true for is_directory on this entry, but crashes when attempting to iterate over it.
I ended up doing this.
1 2 3 4
if (is_directory (SMdata->DirectoryPath[Selected])) {
if (SMdata->DirectoryPath[Selected].path().filename().string() != "System Volume Information")
std::copy(boost::filesystem::directory_iterator(SMdata->DirectoryPath[Selected]), boost::filesystem::directory_iterator(), back_inserter(ItDir));
}
I think there may be other hidden files you need to watch out for as well.