Why doesn’t the file system have a function that tells you the number of files in a directory?
Raymond Chen
There are any number of bits of information you might want to query from the file system, such as the number of files in a directory or the total size of the files in a directory. Why doesn't the file system keep track of these things? Well, of course, one answer is that it certainly couldn't keep track of every possible fragment of information ...