I am using the recursive_directory_iterator boost iterator to recursively scan through a directory. However, when an iterator runs in a directory for which my application does not have access, an exception of the type "boost :: filesystem3 :: filesystem_error" is thrown, which stops the iterator, and the program is interrupted. In any case, I can instruct the iterator to skip such directories.
I tried the code suggested in Moving a directory with boost :: with no exceptions , however, this did not work for me. I am using boost version 1.49.
My code after executing this sentence (the best I could think of) is as follows:
void scand()
{
boost::system::error_code ec, no_err;
for (recursive_directory_iterator end, _path("/tmp", ec);
_path != end; _path.increment(ec)) {
if (ec != no_err) {
_path.pop();
continue;
}
cout << _path->path() << endl;
}
}
Thank you, Achmed.