Boost C++ Libraries: Ticket #4611: path::operator / does not remove redundant separators https://svn.boost.org/trac10/ticket/4611 <p> The following code produces path3 as \abc<br />def\, which is not expected. </p> <pre class="wiki">filesystem::path path1("\\abc\\"); filesystem::path path2("\\def\\"); filesystem::path path3 = path1 / path2; </pre><p> Though the OS level API can handle duplicate path seps correctly, but it is not considered good practice to return path strings like this. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4611 Trac 1.4.3 neo_in_matrix@… Sun, 29 Aug 2010 15:57:16 GMT <link>https://svn.boost.org/trac10/ticket/4611#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4611#comment:1</guid> <description> <p> BTW, I have #define BOOST_FILESYSTEM_VERSION 3 so that I am using the newer version 3 of filesystem.hpp. </p> </description> <category>Ticket</category> </item> <item> <author>neo_in_matrix@…</author> <pubDate>Sun, 29 Aug 2010 16:00:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4611#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4611#comment:2</guid> <description> <p> Yeah... my first message is garbled by this bug system. </p> <p> Let's say the code is like this: </p> <pre class="wiki">filesystem::path path1("\\abc\\"); filesystem::path path2("\\xyz\\"); filesystem::path path3 = path1 / path2; //path3 will be \abc\\xyz\, which has redundant path seps. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Tue, 30 Dec 2014 23:06:21 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4611#comment:3 https://svn.boost.org/trac10/ticket/4611#comment:3 <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">wontfix</span> </li> </ul> <p> See <a class="ext-link" href="http://cplusplus.github.io/filesystem-ts/working-draft.html#path-appends"><span class="icon">​</span>http://cplusplus.github.io/filesystem-ts/working-draft.html#path-appends</a> </p> <p> The ISO C++ filesystem TS says: </p> <blockquote> <p> Appends <code>path::preferred_separator</code> to <code>pathname</code> unless: </p> </blockquote> <ul><li>an added separator would be redundant, or </li><li>would change a relative path to an absolute path [Note: An empty path is relative. — end note], or </li><li><code>p.empty()</code>, or </li><li><code>*p.native().cbegin()</code> is a directory separator. </li></ul><blockquote> <p> Then appends <code>p.native()</code> to <code>pathname</code>. </p> </blockquote> <p> Boost.Filesystem follows the TS here. The TS does not add a separator if it would be redundant, but if native() ends with a separator and the append argument begins with a separator, both are retained. </p> <p> You are free to report this to the C++ committee as defect, and if they decide to change the spec then Boost.Filesystem will follow their lead. But I'm not aware of any reason for adding a gratuitous difference between Boost and other implementation. </p> <p> Thanks for your interest in Boost.Filesystem, </p> <p> --Beman </p> <p> PS: Test case added to verify the library works as expected per your test case. </p> Ticket