Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.filesystem3] directory name from a directory iterator
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2010-12-23 11:33:56


Sean Farrow wrote:
> Hi:
>
> I have the following code to iterate through sub directories:
>
> for (boost::filesystem::directory_iterator end,
> dir(DirectoryToIterate); dir != end; ++dir ) {
>
> if (boost::filesystem::is_directory(dir->status()))
>
>
> TempVec.push_back(boost::filesystem::path(dir->path()).generic_wstring());
>
> }
>
> I’m getting the following output which I expect:
>
> C:/Documents and Settings/All Users/Application Data/Freedom
> Scientific/JAWS/12.0/Settings/enu
>
> I have two questions:
>
> Firstly how do I just obtain the last directory in this case enu (with
> out any slashes)?

see:

http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v3/doc/reference.html#path-decomposition

and

http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v3/doc/reference.html#Path-decomposition-table

> And secondly, is there a method of the path object that gives me the
> path in windows form (i.e with the \ character replacing the / character.)

See:
http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v3/doc/reference.html#path-native-format-observers

Jeff


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