Opened 8 years ago
Closed 7 years ago
#10766 closed Bugs (fixed)
boost::filesystem::path::parent_path() with redundant separator returns wrong value
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | Cc: |
Description
boost::filesystem::path::parent_path() function with redundant separator at the end of directory don't return parent directory, it just removes this separator.
Ubuntu 12.04, gcc 4.6.3
Following test fails:
-
test/path_unit_test.cpp
diff --git test/path_unit_test.cpp test/path_unit_test.cpp index 67ccb9f..09c7f34 100644
namespace 662 662 CHECK(path("/").parent_path().string() == ""); 663 663 CHECK(path("/foo").parent_path().string() == "/"); 664 664 CHECK(path("/foo/bar").parent_path().string() == "/foo"); 665 CHECK(path("/foo/bar/").parent_path().string() == "/foo"); 665 666 666 667 CHECK(path("/foo/bar/baz.zoo").filename().string() == "baz.zoo"); 667 668
Attachments (2)
Change History (3)
by , 7 years ago
Attachment: | ticket_10766_fixbug.patch added |
---|
by , 7 years ago
Attachment: | ticket_10766_fixtest.patch added |
---|
As per my finding Boost considers parent path of /foo/ as /foo and not just /. This is shown in /libs/filesystem/path_test.cpp . But if still it is a bug, then here is the patch for bug and corresponding patch for path_test.cpp.
comment:1 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The behavior is correct, so there no bug in that sense.
There is a bug, however, in the sense that the reference documentation is unclear. To fix that, examples and notes have been added to the reference documentation to show why the returned value is in fact correct, and to provide rationale for that behavior. See [path.itr], and [path.decompose] parent_path() and filename() sections of the reference docs.
As a result of those doc changes, this issue is being marked as "fixed" rather than "invalid".
Thanks,
--Beman
Patch for bug.