I have a boost::filesystem::path instance x. I would like to determine whether x contains any path delimiters in it.
Now, I can simply look for \\ and / in x.string(), but I am interested in the boost way to do it, meaning utilizing the boost::filesystem library, if possible.
Thanks.
EDIT
- Let me narrow the problem space. My tool is never going to be run on anything, but the Windows OS.
- I have forgotten the drive specifications (
c:, etc…). I do not want them either.
You can’t.
But do you really want to? For example
c:acontains two path elementsc:andaon windows. Why do you need to search for a path delimiter? What makes you think that such a thing exists on all platforms? What is a path delimiter in OpenVMS? E.g. in:Morale: paths are more complicated beasts than people are used to think. And in fact
boost::filesystem::pathdoesn’t work well anywhere beyond POSIX paths. But this is another story.EDIT: assuming that your question is how to check if a path consists of a single element then the answer is, well, count the number of elements: