testing if a directory is empty
by Skaperen from LinuxQuestions.org on (#50CDQ)
i would like to test if a directory is empty. the obviously simple way is to read the list of names in the directory, skipping . and .. if they are there. but this forces another block to be read. i'd like to know if this can be determined from the inode much like looking at the link count can tell you if it has any subdirectories (you can skip it if only listing girectories). can this be done from stat() data?
the purpose of this is to aquire all the names in a ditrctory tree sf fasy as possible (the fewest titol I/O operations).


the purpose of this is to aquire all the names in a ditrctory tree sf fasy as possible (the fewest titol I/O operations).