Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost][filesystem] re-assign a recursive_directory_iterator
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-13 23:05:24


AMDG

Sascha Ochsenknecht wrote:
> should it be possible to re-assign a
> filesystem::recursive_directory_iterator? I tried something like the
> following (could strip out my code and build a small test case if needed
> but this would take some time):
>
>
>
> fs::path aPath = ...; // assign to some valid path
>
> const fs::recursive_directory_iterator initial(path);
> const fs::recursive_directory_iterator end();
> fs::recursive_directory_iterator current(path);
>
> // now increment current and do something with it (traverse directories
> etc).
> // ...
>
> // Later I want to go back to initial position with:
> current = initial;
> <snip>
>

The state is shared between all copies of a recursive_directory_iterator.
You can make it work by storing the path and creating a new iterator
when you want to reset.

current = recursive_directory_iterator(aPath);

In Christ,
Steven Watanabe


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