|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-04-24 19:55:52
On Thu, Apr 24, 2008 at 6:29 PM, John Femiani <JOHN.FEMIANI_at_[hidden]> wrote:
> Robert Dailey wrote:
> > Robert Dailey schrieb:
> >
> > > boost::filesystem::path myPath(
> "C:/somefolder/somefile" );
> > > myPath += ".txt";
> > >
> > > Notice the 2nd line of code. This isn't legal. What is
> the cleanest way
> > > to append an extension to a file path? I don't think
> /= will work; if I
> > > remember correctly it will add "/.txt".
> >
> >
> > I think you basically have the option of doing:
> >
> > 1)
> > myPath = myPath.branch_path() / (myPath.leaf() +
> ".txt");
> >
> > 2)
> > string tmp = p.leaf();
> > p.remove_leaf();
> > p /= tmp + ".txt";
> >
> > Both are not really pretty...
> >
> > Regards,
> > Mika
> >
> >
> > I figured that would be the approach I would have to take. I'm
> making best efforts
> > to only append a filename when the extension is present, since as far
> as I can tell being preemptive like that is the cleanest solution.
>
> Have you looked at ::boost::filesystem::change_extension???
> Somehow it is referred to as replace_extension in the docs, but this
> function will do what you are discussing I think.
>
> -- John Femiani
I did not see that in the boost.filesystem.basic_path reference
documentation.
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