Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::filesystem::path] removing components of a path
From: degski (degski_at_[hidden])
Date: 2019-03-08 06:49:56

On Thu, 7 Mar 2019 at 21:49, Sean Farrow via Boost-users <
boost-users_at_[hidden]> wrote:

> I’m revisiting boost::filesystem::path after not using it for a while and
> wondered whether there is a way to remove parts of a path deeper than a
> specific directory?
> By way of an example, assume I have the following path declared:
> boost::filesystem::path path =”d:\\test1\\test2\\test3.txt”
> what I want to do is determine whether test2 exists as part of the path
> and if it does remove everything after and including the found part of the
> path, so in this case \\test2\\test3.txt would be removed.
> I could do it by converting the path to a string, but wondered whether
> boost::filesystem could do this natively in some way.

Doing this is no problem whatsoever, you'll have to use the functionality
of the path-class. It has all the primitives to code this [and any other
kind of manipulation of paths] your-self, coz that's what you'll have to
do. See, f.e.
but there might be a few other bits and bobs that are equally or more
suited for coding the solution to your specific problem.


*"Big boys don't cry" - **Eric Stewart, Graham Gouldman*

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at