Getting a Directory Listing
The first step in obtaining directory information from your system is to create a directory handle. A directory handle is something like a filehandle, except that instead of a file's contents, you read the contents of a directory through the directory handle. To open a directory handle, you use the opendir function:
opendir dirhandle, directory
In this syntax, dirhandle is the directory handle you want to open and directory is the name of the directory you want to read. If the directory handle cannot be opened—because you don't have permission to read the directory, the directory doesn't exist, or because of some other reason—the opendir function returns false. Directory handle variable names should be constructed ...