Reputation: 21
For example I have this code. I use recursive_directory_iterator
. Do I need to close directories in this cycle or boost do it automatically?
void selective_search( const path &search_here, const std::string &exclude_this_directory)
{
using namespace boost::filesystem;
recursive_directory_iterator dir( search_here), end;
while (dir != end)
{
// make sure we don't recurse into certain directories
// note: maybe check for is_directory() here as well...
if (dir->path().filename() == exclude_this_directory)
{
dir.no_push(); // don't recurse into this directory.
}
// do other stuff here.
++dir;
}
}
Upvotes: 1
Views: 122
Reputation: 10165
Closing manually is not necessary. Directory iterator closes each entry when it is no longer needed.
Upvotes: 1