Is there any idiomatic way to get number of components in a path using filesystem library? Or have I missed some method for this?
Or do I have to, like, call parent_path() until I get to the root?
How about the size() method?
boost::filesystem::path p;
// fill p
std::cout << p.size() << std::endl;
will give you the number of components.
Also path iterators don't iterate over the string of the path, but over the components of the path. So this should work too:
std::distance(p.begin(), p.end());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With