Opened 10 years ago
#7545 new Bugs
filesystem::path::filename() specification wrong?
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | Cc: |
Description
According to the 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()