Boost logo

Boost Users :

Subject: Re: [Boost-users] Changes breaking behavior of operators /, /= and << in filesystem v3?
From: PB (newbarker_at_[hidden])
Date: 2010-10-25 09:36:19


On Mon, Oct 25, 2010 at 8:41 AM, Roel Vanhout <roel.vanhout_at_[hidden]> wrote:
> Hello,
>
>
> I enabled filesystem v3 after upgrading to 1.44. The api changes that
> caused the compiler to signal errors were rather easy to fix. However
> when running my program, it behaves differently from the way it used
> to. I narrowed it down to the following:
>
> char buf[MAX_PATH];
> HRESULT res = ::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL,
> SHGFP_TYPE_CURRENT, buf);
> boost::filesystem::path result(buf);    // 'result' is after this
> "C:\Documents and Settings\rvanhout\Application Data"
> result /= "MyCompany";
>
> At this point, 'result' *still* contains "C:\Documents and
> Settings\rvanhout\Application Data" whereas with v2 it used to contain
> "C:\Documents and Settings\rvanhout\Application
> Data\MyCompany\MyProduct".
>
> (environment: Windows (obviously) with VS 2008 (vc9))
>
> There seem to be two way to get the desired behaviour:
>  - initialize the path with a trailing slash, like this:
> boost::filesystem::path result(buf + std::string("/"));
>  - convert 'buf' into a std::string first:  std::string str(buf);
> boost::filesystem::path result(str);

Are you hitting the situation described here?:
https://svn.boost.org/trac/boost/ticket/4640

It's something to do with the new template constructor being templated
on the array type and not the pointer type.

I had the same problem when I upgraded and got around the issue by
using &buf[0] rather than buf.

Regards,

Pete


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