close a directory
#include <dirent.h> int closedir( DIR *dirp );
The closedir() function closes the directory specified by dirp, and frees the memory allocated by opendir().
errno, opendir(), readdir(), rewinddir()
To get a list of files contained in the directory /home/fred of your node:
#include <stdio.h>
#include <dirent.h>
void main()
{
DIR *dirp;
struct dirent *direntp;
dirp = opendir( "/home/fred" );
if( dirp != NULL ) {
for(;;) {
direntp = readdir( dirp );
if( direntp == NULL )
break;
printf( "%s\n", direntp->d_name );
}
closedir( dirp );
}
}
POSIX 1003.1
All (except Netware, DOS/PM)