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 31 32 33 34 35
| int do_ls(char *rep)
{
DIR *dir;
struct dirent *direntry;
struct stat s;
dir = opendir(rep);
while ((direntry =readdir(dir)) != NULL)
{
stat(direntry->d_name, &s);
if ((s.st_mode & S_IFMT) == S_IFDIR)
{
do_ls(direntry->d_name);
}
else
{
aff_type(s.st_mode);
aff_perm(s.st_mode);
my_putchar(' ');
my_putnbr(s.st_nlink);
my_putchar(' ');
my_putstr(getpwuid(s.st_uid)->pw_name);
my_putchar(' ');
my_putstr(getgrgid(s.st_gid)->gr_name);
my_putchar(' ');
my_putnbr(s.st_size);
my_putchar(' ');
print_date(s.st_mtime);
my_putchar(' ');
my_putstr(direntry->d_name);
my_putchar('\n');
}
}
} |
Partager