Frage

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

War es hilfreich?

Lösung

const std::string rndString = "quz";
boost::filesystem::path newPath = P.parent_path() / boost::filesystem::path(P.stem().string() + "_" + rndString + P.extension().string());
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top