All over the internet it seems the accepted way of getting a directory's child count is to loop through its entries manually and count them. This seems far too tedious and generally there are other frameworks and API's that offer a convenience function to get child counts, one of them being QDir::count().
Is there a POSIX API that returns the number of entries in a directory efficiently? If so, I would imagine that this is the implementation of QDir::count(). If not, then perhaps it's done the way so many people are doing it, looping through the entries and counting them if they're appropriate.