|
Boost Users : |
Subject: [Boost-users] How to skip a sub-directory with filesystem3::recursive_directory_iterator in case of exception?
From: Tan, Tom (Shanghai) (TTan_at_[hidden])
Date: 2011-03-30 08:35:09
I am iterating a mapped network drive under windows, K:\, under which
are 3 sub directories A, B, C, where K:\B is only visible itself but
cannot be iterated into due to group policy.
With code below:
boost::system::error_code ec;
for (recursive_directory_iterator itr(root, ec), itr_end; itr!=itr_end;
itr++)
{ ... }
It throws in itr++ when itr->path() == "K:\B".
I would like to skip going into k:\B and go on with K:\C, so I code like
this:
for (recursive_directory_iterator itr(root, ec), itr_end; itr!=itr_end;
)
{
... ;
itr.increment(ec);
}
It does not solve my problem, but introduces one more:
itr will never equal to itr_end even though all item are iterated over,
and this happens for any normal folder such as K:\A. thus never get's
out of for loop until the internal
vetor<directory_iterator>::operator+=() asserts.
Again, I tried something like below.
for (recursive_directory_iterator itr(root, ec), itr_end; itr!=itr_end;
)
{
... ;
itr.increment(ec);
if(ec) itr.pop();
}
This time itr.pop() assertion fails because "pop() on
recursive_directory_iterator with level < 1"
Anybody got some advice? Thanks.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net