Boost logo

Boost Users :

Subject: Re: [Boost-users] Program Options of Filesystem Path's - confused!
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2010-08-14 01:35:17


John Dlugosz wrote:

> OK, If I take a po:wvalue<std::wstring>()->notifier(&datadir_set)
> the string gets passed to datadir_set, and within that function it implicitly converts the string
> to a fs::wpath instance to call set_me. It works as expected.
>
> void set_me (const fs::wpath& p);
>
> void datadir_set (const std::wstring& s)
> {
> wcout << L"** set data dir to " << s << L".\n";
> set_me (s);
> }
>
>
> However, if I declare the program option as
> po::wvalue<fs::wpath>()->notifier(&set_me)
>
> then when it runs I get "invalid option value". It apparently can't convert the argv token into a
> wpath? But it's not a compile-time error so it thinks it knows how to, but gets an error actually
> doing it?
>
> I have no trouble passing long string literals to the constructor, e.g.
> fs::wpath f1 (L"C:\\here\\there.txt");
>
> The program option takes "." on the command line just fine, so it's the specific value of the
> string it doesn't like! I tried with Unix-style slashes, with no difference.
>
> A little experimenting tells me that it doesn't like having spaces in the string! Note that the
> quotes are understood by the run-time library that calls main, so the whole string (without
> surrounding quotes) is present in one element of argv. It works just fine when taking the
> argument as a string.
>
> This seems like a bug, somewhere.

Try:

        lexical_cast<fs::wpath>(fs::wpath("the path that fails"))

If that fails, it means operator>> is mishandling spaces in paths.

- Volodya


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