Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem::native
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-11-10 18:23:25


On 11/11/2016 12:07, Christopher J. Pisz wrote:
> The docs really should clarify that. Google searches all over point to
> this function for that purpose and it is even marked as an answer on
> Stack Overflow.

It is mentioned in the comments on that answer that it only works on the
filename portion of the path.

And it is mentioned in the docs, as long as you don't interpret
"filename" and "path" to be the same thing.

In particular note the description of windows_name().

> If we cannot check for a valid path using this function, then does boost
> indeed provide us a means for checking that a path is valid?
>
> ...Where valid means the given path does not necessarily point to a file
> or directory, but could point to one if it was first created.

As I mentioned in my other reply, you can use exists(). Or if it
doesn't exist, you can try creating it. Otherwise I'm not aware of
anything that'd do it, other than iterating the path and checking each
component separately.

Most of the time, given a directory path, exists() or
create_directories() would be the simplest option (though the latter
throws on failure).


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