1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
int main( void ) {
DIR *currentDir,
*type;
struct dirent *fichier;
if( NULL == ( currentDir = opendir( "/var/run" ))) {
perror( "opendir()" );
} else {
while( NULL != ( fichier = readdir( currentDir ))) {
printf( "%s", fichier->d_name );
printf( "\n" );
if( NULL == ( type = opendir( fichier->d_name ))) {
}
closedir( type );
}
if( errno != 22 ) {
perror( "readdir()" );
}
closedir( currentDir );
}
return 0;
} |
Partager