
I am constructing full path out of directory (c:\temp), filename(test) and extension (txt). boost::filesystem::path mypath(dir); // mypath="c:\temp" mypath /= filename; // mypath="c:\temp\test" If I call mypath.replace_extension("txt") it will fail because there is no dot character yet. To proceed further I have to add "." using direct string manipulation, that kind of break the logic of using filesystem::path. Question: how to construct full path using directory, filename and extension strings using only filesystem::path methods?

On Wed, Apr 20, 2011 at 11:18, Archie14
If I call mypath.replace_extension("txt") it will fail because there is no dot character yet. To proceed further I have to add "." using direct string manipulation, that kind of break the logic of using filesystem::path.
That's odd. Usually a file named "test" is considered to have a stem of "test" and an extension of "". (Note that "test.txt" has an extension of ".txt", but replace_extension adds the dot if the extension doesn't start with one.)
Question: how to construct full path using directory, filename and extension strings using only filesystem::path methods?
I'd suggest filing a feature request for an "add_extension" mention. You make a good point that there should be some way other than operator+ to get "pack.tar.gz" from "pack.tar" and "gz". ~ Scott

That's odd. Usually a file named "test" is considered to have a stem of "test" and an extension of "". (Note that "test.txt" has an extension of ".txt", but replace_extension adds the dot if the extension doesn't start with one.) Apparently it works (I can't reproduce it now, don't have it installed) in filesystem v2. I was using "replace_extenstion" often and only when updated to 46.1 the code started to break. This is how it is currently implemented:
Scott McMurray
Question: how to construct full path using directory, filename and
extension
strings using only filesystem::path methods?
I'd suggest filing a feature request for an "add_extension" mention.
You make a good point that there should be some way other than operator+ to get "pack.tar.gz" from "pack.tar" and "gz".
~ Scott
Where do I file the request?

On Wed, Apr 20, 2011 at 13:28, Archie14
Where do I file the request?
Same as a bug, just a feature request bug: http://www.boost.org/support/bugs.html
participants (2)
-
Archie14
-
Scott McMurray