Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem - replace_extension question
From: Archie14 (admin_at_[hidden])
Date: 2011-04-20 16:28:40


Scott McMurray <me22.ca+boost <at> gmail.com> writes:

> 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:
path & path::replace_extension(const path & source)
  {
...
    // append source extension if any
    pos = source.m_pathname.rfind(dot);
    if (pos != string_type::npos)
      m_pathname += source.c_str() + pos;

    return *this;
  }

>
> >
> > 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?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net