Boost logo

Boost Users :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2006-09-29 12:13:54


On 9/29/06, Andrei Danaila <adanaila_ca_at_[hidden]> wrote:
>
> Noob question, how do we rename a file obtained from a directory_iterator.
> i'm attempting to compile the following much simplified example.
>
> directory_iterator i("whateverPath");
> i++;
> // i know i++ exists
> rename (i->current_path(), TestRename);
>
> When i try to compile the above , it tells me that i is actually a "path"
> object not a directory iterator.

That is because you are dereferencing the iterator to the underlying
path object. The compiler is correct. Try:

rename (i.current_path(), TestRename); // dot not arrow!

> However, when i try to write something like
>
> path test=i;
>
> it tells me i is actually a directory iterator not a path object.

The compiler is again correct. Try:

path test=*i; // dereference the iterator to get the path

HTH,

--Mike


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