Boost logo

Boost :

Subject: Re: [boost] [filesystem] Issue with replace_extension
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-10-02 08:15:05


On Thu, Sep 30, 2010 at 11:29 AM, cheesy4poofs <cheesy4poofs_at_[hidden]> wrote:
> I've recently switched all our code to filesystem v3 and added
> BOOST_FILESYSTEM_NO_DEPRECATE on our builds for good measure.  One of the
> changes I had to fix was our use of change_extension(), which was modified
> to use the replace_extension() method.  However, some of our code started
> failing and I tracked it down to this example:
>
>        boost::filesystem::path p("C:\\database\\test\\filename");
>        p.replace_extension(".db");
>        std::cout << p.string() << std::endl;
>        // OUTPUT - C:\database\test\filename.db
>
>        p = "C:\\database.1\\test\\filename";
>        p.replace_extension(".db");  // bug?
>        std::cout << p.string() << std::endl;
>        // OUTPUT - C:\database.db
>
> As you can see, in the second example, it truncates the path and assumes the
> directory name "database.1" has the extension that needs replacing.
> change_extension() did not behave this way.
>
> Is this the expected behavior?

Looks like a bug to me.

I'm planning to work filesystem issues in a few days, so that fixes
get in for Boost 1.45.

Thanks,

--Beman


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