[Boost-bugs] [Boost C++ Libraries] #7545: filesystem::path::filename() specification wrong?

Subject: [Boost-bugs] [Boost C++ Libraries] #7545: filesystem::path::filename() specification wrong?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-10-21 15:12:14


#7545: filesystem::path::filename() specification wrong?
----------------------------------------------------+-----------------------
 Reporter: Stefan Große Pawig <boost@…> | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.51.0 | Severity: Problem
 Keywords: |
----------------------------------------------------+-----------------------
 According to the
 [[http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/reference.html#Definitions|definition]]
 section of the boost::filesystem documentation,
 * a **path** consists of a root-name, a root-directory and (as relative-
 path) a sequence of filenames (all optional)
 * a **filename** is the name of a file, with slashes explicitly forbidden
 as part of the filename

 With these definitions, paths consisting entirely of root-name and/or
 root-directory parts (like {{{ "//net"}}}, {{{ "//net/" }}} and {{{
 "/"}}}) do not contain filenames.

 On the other hand, the specification of path::filename() says

   // Returns: // {{{ empty() ? path() : *--end() }}}

 without discrimination between the different parts. Consequently,
 * {{{ Path("//net").filename() == Path("//net") }}}
 * {{{ Path("/").filename() == Path("/") }}}
 instead of the expected empty {{{Path()}}}, and containing the forbidden
 slash.

 **Proposed fix:** \\
 To become consistent with the definitions, path::filename() should be
 specified as follows:

   // Returns: // {{{ relative_path().empty() ? path() : *--end() }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7545>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC