Article 50CDQ testing if a directory is empty

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).latest?d=yIl2AUoC8zA latest?i=6kanW1a7Jbs:ur-H7Ws6JGk:F7zBnMy latest?i=6kanW1a7Jbs:ur-H7Ws6JGk:V_sGLiP latest?d=qj6IDK7rITs latest?i=6kanW1a7Jbs:ur-H7Ws6JGk:gIN9vFw6kanW1a7Jbs
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments