Boost logo

Boost :

Subject: Re: [boost] [filesystem][lexical_cast] Lexical cast of filenames containing spaces
From: Daniel James (dnljms_at_[hidden])
Date: 2010-08-16 11:28:15


On 16 August 2010 14:59, Beman Dawes <bdawes_at_[hidden]> wrote:
> On Sat, Aug 14, 2010 at 6:20 AM, Daniel James <dnljms_at_[hidden]> wrote:
>> The problem is that filesystem v3's stream extractor treats spaces as
>> separators (which is the right thing to do IMO), so it only extracts
>> "file"...
>
>  boost::filesystem::path p("file name");
>  std::cout << p;
>
> The output is "file name".

That's not what's happening. I wasn't making a bug report for
filesystem, it's a problem with the way lexical_cast uses filesystem
in program_options. It's more to do with lexical_cast (which is why I
asked how it deals with strings, they must have the same problem). The
issue came up here:

http://lists.boost.org/boost-users/2010/08/61629.php

What's happening is something like:

std::stringstream ss;
boost::filesystem::path p
ss << "file name";
ss >> p;

Which just reads 'file'. But lexical_cast doesn't do that for strings,
so I assume there must be a specialization somewhere. So I wanted to
know if something could be added to filesystem or lexical_cast to deal
with this case. Or if that's just the way it works, and
program_options will have to contain a special case, which would be a
pity.

Daniel




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk