in reply to Quickly checking if a directory is empty
What you need to do is use readdir() but make sure you read one at at time, that is, not in array context