Boost logo

Boost Users :

From: Peter Klotz (peter.klotz_at_[hidden])
Date: 2003-07-20 03:06:00


Hi Christian

> I have an std::string contains something like C:\Test\Media\Cloud.dds.
> Now i want to extract the Cloud.dds.
>
> This is, what i have tried:
> fs::path temp(Name, fs::native);
> fs::directory_iterator dir_itr(temp);
> Name = dir_itr->leaf();
>
> Where is my error? This code throughs an exception.

The directory_iterator class expects a directory as its constructor
argument, not a file.

Use the following code to get the file name.

fs::path temp(Name, fs::native);
Name = temp.leaf();

If you do not need the path object, this should be the shortest way.

Name = fs::path(Name, fs::native).leaf();

Best regards, Peter.


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