
number of entries in directory
In article <6qo03r$...@portal.gmu.edu>,
hmor...@site.gmu.edu (Hany Morcos (CS)) writes:
Unfortunately not. Probably the best you can do is
DIR *dp;
size_t n = 0;
dp = opendir (".");
if (dp)
while (readdir (dp))
n++;
/* Now N holds the number of entries (including "." and ".."). */
Note that you can find the number of entries in a directory which are
themselves directories by using the link count. Many (most?)
implementations of find use this trick to reduce the number of stat()s
needed in a directory.
--
Aaron Crane <aaron.cr...@pobox.com> <URL:http://pobox.com/~aaronc/>