I have this piece of Boost code that iterates through files in a directory:
void someFuncToIterateFiles() {
if( exists( directory ) )
{
directory_iterator end ;
for( directory_iterator iter(directory) ; iter != end ; ++iter ) {
if ( !is_directory( *iter ) )
{
// this is a file
cout << iter->path;
// rest of the code
}
}
}
}
I have found that sometimes when its read a directory which exists and is about to start iterating through files, the program simply halts and there is no error or segmentation fault. The rest of the code bit is not executed at all, and the function returns to the caller This is very strange as I haven’t come across anything like this before. No exception is thrown, unless this needs us to explicitly use a try-catch exception handler.
Has anyone experienced this with Boost? I cannot debug but only use cout statements as some of my dependency libraries are compiled in release mode.
path is not a field, it is a method, so you should call it like that:
cout << iter->path();