Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Boost Filesystem: How to modify stem from a path?

I'm using the Boost Filesystem library. I have a path

boost::filesystem::path P("/foo/bar.baz");

I want to modify the stem part of path p to "bar_quz", so path P stays

/foo/bar_quz.baz

Can someone help me? Thanks

like image 398
ireallydontknow Avatar asked Oct 31 '13 16:10

ireallydontknow


1 Answers

const std::string rndString = "quz";
boost::filesystem::path newPath = P.parent_path() / boost::filesystem::path(P.stem().string() + "_" + rndString + P.extension().string());
like image 117
Shmil The Cat Avatar answered Nov 01 '22 03:11

Shmil The Cat