C++ Boost Filesystem:如何修改路径中的词干?

ire*_*now 13 c++ boost boost-filesystem

我正在使用Boost Filesystem库.我有一条路

boost::filesystem::path P("/foo/bar.baz");
Run Code Online (Sandbox Code Playgroud)

我想将路径p的词干部分修改为"bar_quz",因此路径P保持不变

/foo/bar_quz.baz

有人能帮我吗?谢谢

Shm*_*Cat 13

const std::string rndString = "quz";
boost::filesystem::path newPath = P.parent_path() / boost::filesystem::path(P.stem().string() + "_" + rndString + P.extension().string());
Run Code Online (Sandbox Code Playgroud)