KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using the boost iterator "recursive_directory_iterator" to recursively scan through a directory. However, when the iterator runs into a directory for which my application does not have access, exception of type "boost::filesystem3::filesystem_error" is thrown, which halts the iterator and the program aborts. Is there anyway I can instruct the iterator to skip over such directories. I tried the code suggested at Traversing a directory with boost::filesystem without throwing exceptions However, it did nor work for me. I am using boost version 1.49. My code after following the suggestion (the best I could come up with), looks as follows: void scand() { boost::system::error_code ec, no_err; // Read dir contents recurs 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, Ahmed.
Tags (comma-separated)
Save Edits
Cancel