PHP Code:
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <st***.h>
#include <stdlib.h>
/***
* _ _
* (_) (_)
* __ ____ _ _ _____ ___ ___ ___ ___ _ __ ___
* \ \/ / _` | |/ _ \ \ / / |/ _ \ / __/ _ \| '_ ` _ \
* > < (_| | | (_) \ V /| | (_) | (_| (_) | | | | | |
* /_/\_\__, |_|\___/ \_/ |_|\___(_)___\___/|_| |_| |_|
* __/ |
* |___/
*
*
* Utilizzo : directory [nome-directory]
* stampa su stdout tutti i file/cartelle contenuti in nome-directory
*
*
*/
int main ( int n_values, char ** values ) {
DIR * directory;
struct dirent * dir_entry;
directory = opendir(*(values + 1));
if ( directory == NULL ){
fprintf(stderr,"Impossibile leggere directory %s\n",*(values + 1));
exit (-2);
}
fprintf(stderr,"La directory %s contienre le seguenti entry:\n",*(values + 1));
for ( dir_entry = readdir(directory); \
dir_entry != NULL; \
dir_entry = readdir(directory)){
fprintf(stdout,"-- %s\n",(char *) &(dir_entry->d_name));
}
closedir(directory);
return 0;
}