Announcement

Collapse
No announcement yet.

[os] read directory entries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [os] read directory entries

    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_valueschar ** 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;

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia