Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem::native
From: Christopher J. Pisz (cpisz_at_[hidden])
Date: 2016-11-10 18:07:58


On 11/10/2016 4:51 PM, Gavin Lambert wrote:
> On 11/11/2016 09:05, Christopher J. Pisz wrote:
>> Great! I say to myself.
>> I then Google up the boost doc here:
>> http://www.boost.org/doc/libs/1_62_0/libs/filesystem/doc/portability_guide.htm
>>
> [...]
>> Boost says the following path is not valid for the native operating
>> system: D:\Programing Projects\Git Workspace\Common\x64\Debug
>> Boost says the following path is not valid for the native operating
>> system: D:Programing Projects\Git Workspace\Common\x64\Debug\
>> Boost says the following path is not valid for the native operating
>> system: D:/Programing Projects/Git Workspace/Common/x64/Debug
>> Boost says the following path is not valid for the native operating
>> system: D:/Programing Projects/Git Workspace/Common/x64/Debug/
>>
>> What is wrong with that path that it says it is not valid for my native
>> Windows 10 operating system?
>
> After looking at the implementation and reading the docs more carefully:
>
> Your assumptions were wrong. :)
>
> It turns out that the portability functions (native() and friends) do
> not check *paths* for validity, they check *path components* (eg.
> individual filenames).
>
> In particular the path separator characters are considered invalid.
>
> This is why "\PATH" is considered valid, because this is treated as
> "PATH", while "\\PATH" is not valid because the backslash is invalid in
> a filename.
>
> So if you wanted to use those, you'd need to wrap it in a path() first
> and iterate over each element to test if it is valid.

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.

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.


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