Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::filesystem::path] removing components of a path
From: Sean Farrow (sean.farrow_at_[hidden])
Date: 2019-03-07 19:57:13




-----Original Message-----
From: Boost-users <boost-users-bounces_at_[hidden]> On Behalf Of Michael Powell via Boost-users
Sent: 07 March 2019 19:53
To: boost-users_at_[hidden]
Cc: Michael Powell <mwpowellhtx_at_[hidden]>
Subject: Re: [Boost-users] [boost::filesystem::path] removing components of a path

On Thu, Mar 7, 2019 at 2:49 PM Sean Farrow via Boost-users <boost-users_at_[hidden]> wrote:
>
> Hi all,
>
>
>
> 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.

Natively, or via the FS API?
Via the fs API, this needs to be cross-platform.

I do not have the API right in front of me, but couldn't you peel off the children nodes to their parents until you found whether the current node was the match?
I could iterate the path, but wondered whether path has a method to ask whether part of a path exists?

I'm not positive, but I am pretty sure FS knows about relative v.
absolute paths, in this regard, as well.

> Any help appreciated.
>
> Kind regards
>
> Sean.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


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