| 12
 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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 
 |  
 
#include "my.h"
#include <grp.h>
#include <pwd.h>
 
int	parcour_rep(char *rep)
{
  struct dirent	*d;
  struct stat	info_file;
  DIR	*dir;
 
  if ((dir = opendir(rep)) == (NULL))
    {
      printf("impossible d'ouvrir %s\n", rep);
      return(0);
    }
  while ((d = readdir(dir)) != (NULL))
    {
      if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0)
	continue;
      else
	{
	  if (stat(d->d_name, &info_file) == - 1)
	    return(0);
	  if (S_ISDIR(info_file.st_mode))
	    printf("d :");
	  else
	    printf("- :");
	  printf("%s\n", d->d_name);
	}
    }
  closedir(dir);
}
 
 
int	main(int ac, char **av)
{
  DIR	*dir;
  char	*name;
 
  if (ac > 1)
    {
      if (av[1][0] == '-' && av[1][1] == 'l')
	{
	  parcour_rep(av[2]);
	  return(0);
	}
      return(0);
    }
  return (0);
} | 
Partager