#5118 closed Bugs (fixed)
replace_extension doesn't work as specified in documentation
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.45.0 | Severity: | Problem |
Keywords: | extension | Cc: | jonathan.jones@… |
Description
- From Reference (see http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v3/doc/reference.html#path-replace_extension):
path& replace_extension(const path& new_extension = path()); Postcondition: extension() == replacement, where replacement is new_extension if new_extension.empty() || new_extension[0] == the dot character, otherwise replacement is the dot character followed by new_extension. Returns: *this
Testing this behavior
path ph("foo.txt"); std::cout << ph.replace_extension("exe");
Output:
foo
Eather change the Reference or fix it in code.
- Current implementation doesn't allow to work with complex extentions.
path ph("foo.txt"); std::cout << ph.replace_extention(".tar.bz2");
Output:
foo.bz2
- There is no function to just add extension.
something like that:
path ph("foo.txt"); std::cout << ph.add_extension("bz2");
Expected output:
foo.txt.bz2
Attachments (1)
Change History (8)
comment:1 by , 11 years ago
by , 11 years ago
Attachment: | replace_ext_fix.patch added |
---|
Here is a patch for replace_extension method
comment:3 by , 11 years ago
And it is still in 1.48.0
The "Boost Filesystem Do List" found in "boost_1_48_0/libs/filesystem/v3/doc/do_list.html" indicates that the behavior has changed from v2 to v3.
On the do list for documentation: Document behavior of path::replace_extension has change WRT argument w/o a dot.
Also, "boost_1_48_0/libs/filesystem/v3/test/path_test.cpp" includes multiple tests for this "new" functionality.
The documentation should be updated or the patch should be applied!
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 11 years ago
The documentation, implementation, and test cases have all had fixes applied. The documentation had failed to mention that any existing extension is removed. The behavior for simple cases has been reverted to the Version 2 behavior, but with corrections so that complex replacements now work. Two test cases from #5118 have been added.
This ticket also includes a request for an "add_extension" function. That's been deferred since there is a pending request for += operator that would cover the requested functionality.
Thanks,
--Beman
comment:7 by , 9 years ago
Cc: | added |
---|
This is also a regression from V2 -> V3, because in V2 this works as documented.