Boost logo

Boost :

Subject: [boost] [filesystem] Issue with replace_extension
From: cheesy4poofs (cheesy4poofs_at_[hidden])
Date: 2010-09-30 11:29:44

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");
        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?


Boost list run by bdawes at, gregod at, cpdaniel at, john at