Boost C++ Libraries: Ticket #4702: replace_extension truncates path https://svn.boost.org/trac10/ticket/4702 <p> 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: </p> <blockquote> <p> boost::filesystem::path p("C:<br />database<br />test<br />filename"); p.replace_extension(".db"); std::cout &lt;&lt; p.string() &lt;&lt; std::endl; <em> OUTPUT - C:\database\test\filename.db </em></p> </blockquote> <blockquote> <p> p = "C:<br />database.1<br />test<br />filename"; p.replace_extension(".db"); <em> bug? std::cout &lt;&lt; p.string() &lt;&lt; std::endl; </em> OUTPUT - C:\database.db </p> </blockquote> <p> 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. </p> <p> Is this the expected behavior? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4702 Trac 1.4.3 anonymous Fri, 01 Oct 2010 18:59:37 GMT <link>https://svn.boost.org/trac10/ticket/4702#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4702#comment:1</guid> <description> <p> Apparently, it didn't like the backslashes, let me try the examples again: </p> <blockquote> <p> boost::filesystem::path p("/database/test/filename"); p.replace_extension(".db"); std::cout &lt;&lt; p.string() &lt;&lt; std::endl; <em> OUTPUT - /database/test/filename.db </em></p> </blockquote> <blockquote> <p> p = "/database.1/test/filename"; p.replace_extension(".db"); <em> bug? std::cout &lt;&lt; p.string() &lt;&lt; std::endl; </em> OUTPUT - /database.db </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Mon, 04 Oct 2010 13:21:47 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4702#comment:2 https://svn.boost.org/trac10/ticket/4702#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65748" title="Fix #4702">[65748]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4702" title="#4702: Bugs: replace_extension truncates path (closed: fixed)">#4702</a> </p> Ticket