Boost C++ Libraries: Ticket #4329: filesystem::basename is completely erratic https://svn.boost.org/trac10/ticket/4329 <p> The attached program shows that basename is broken. I've tried 1.33.1, where it prints (as I would have expected): </p> <p> a a b b c c d d e e </p> <p> Using 1.35.0, 1.40.0, 1.42.0, it prints: </p> <p> a b / c d e </p> <p> Observe the exceptional behavior of basename("a/b/") returning "/". </p> <p> IMHO, basename's behaviour shouldn't differ from Posix's basename. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4329 Trac 1.4.3 Richard B. Kreckel <kreckel@…> Wed, 09 Jun 2010 21:10:53 GMT attachment set https://svn.boost.org/trac10/ticket/4329 https://svn.boost.org/trac10/ticket/4329 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fs.cc</span> </li> </ul> Ticket anonymous Fri, 11 Jun 2010 06:19:46 GMT <link>https://svn.boost.org/trac10/ticket/4329#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4329#comment:1</guid> <description> <p> Reproducible on Debian GNU/Linux kernel 2.6.32-3-amd64. According to the filesystem documentation, though, basename is a deprecated convenience function. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Wed, 24 Dec 2014 19:19:57 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4329#comment:2 https://svn.boost.org/trac10/ticket/4329#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> Sorry for the delay in closing this issue. The function is now a member of path, and has been renamed <code>stem()</code>. The actual problem was fixed years ago. </p> <p> A reworked version of the test program was tested against the current version of the library: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/filesystem.hpp&gt; using boost::filesystem::path; int main() { std::cout &lt;&lt; path("a").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c/").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c/d").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c/d/").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c/d/e").stem() &lt;&lt; std::endl; std::cout &lt;&lt; path("a/b/c/d/e/").stem() &lt;&lt; std::endl; return 0; } </pre><p> Output: </p> <pre class="wiki">"a" "." "b" "." "c" "." "d" "." "e" "." </pre><p> That is the expected output according to the C++ Filesystem TS, which is now the base document for boost.filesystem. </p> <p> Thanks, </p> <p> --Beman </p> Ticket