Opened 12 years ago
Closed 12 years ago
#4702 closed Bugs (fixed)
replace_extension truncates path
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.44.0 | Severity: | Problem |
Keywords: | replace_extension | Cc: |
Description
I've recently switched all our code to filesystem v3 and added BOOST_FILESYSTEM_NO_DEPRECATE on our builds for good measure. One of the changes I had to fix was our use of change_extension(), which was modified to use the replace_extension() method. However, some of our code started failing and I tracked it down to this example:
boost::filesystem::path p("C:
database
test
filename"); p.replace_extension(".db"); std::cout << p.string() << std::endl; OUTPUT - C:\database\test\filename.db
p = "C:
database.1
test
filename"; p.replace_extension(".db"); bug? std::cout << p.string() << std::endl; OUTPUT - C:\database.db
As you can see, in the second example, it truncates the path and assumes the directory name "database.1" has the extension that needs replacing. change_extension() did not behave this way.
Is this the expected behavior?
Apparently, it didn't like the backslashes, let me try the examples again: