Boost logo

Boost Users :

Subject: Re: [Boost-users] [Filesystem] There must be a better way to do path decomposition
From: Richard (legalize+jeeves_at_[hidden])
Date: 2011-08-03 18:04:18


[Please do not mail me a copy of your followup]

boost-users_at_[hidden] spake the secret code
<4E397DB2.1020203_at_[hidden]> thusly:

>On 03.08.2011 18:16, Ramon F Herrera wrote:
>> I tried to capture `*it' in a string and in a string_type but the
>> compiler does not like the '=' operator.
>
>I just tested that in Filesystem v3 and there decomposed path parts are
>still of type filesystem::path.
>
>So my code looks something like this in v3.
>fs::path tmp("/foo/bar/path");
>for(fs::path::const_iterator it = tmp.begin();
> it != tmp.end(); ++it)
>{
> std::string tmpS = (*it).string();
> std::wstring tmpWs = (*it).wstring();
>}
>
>So maybe switching to v3 (if your code is still v2) might be a solution
>(since it's anyway the default).

The problem with v3 filesystem is that its a PITA to write code that
conditionally compiles to ANSI and wide character strings because they
changed it string() and wstring() accessors from the *same* class.

With std::string and std::wstring I can make my own typedef:

#if defined(_UNICODE)
typedef std::wstring tstring;
#else
typedef std::string tstring;
#endif

and then use tstring for all my string objects.

With filesystem v3 this is impossible because you can't create a
typedef for "narrow filesystem paths" or "wide filesystem paths"
because it tries to be both at the same time.

I haven't been able to find any documentation explaining *why* this
class now tries to be both a wide string and a narrow string, but
unfortunately it makes v3 filesystem very unusable IMO.

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
 <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
      Legalize Adulthood! <http://legalizeadulthood.wordpress.com>

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